READ THIS FIRST: This file serves as the single source of truth for any AI agent (Claude, Gemini, Cursor, etc.) working on the Pake repository. It aggregates architectural context, development workflows, and behavioral guidelines.
- Incremental progress over big bangs: Break complex tasks into manageable stages.
- Learn from existing code: Understand patterns before implementing new features.
- Clear intent over clever code: Prioritize readability and maintainability.
- Simple over complex: Keep all implementations simple and straightforward - prioritize solving problems and ease of maintenance over complex solutions.
- Shame in guessing APIs, Honor in careful research.
- Shame in vague execution, Honor in seeking confirmation.
- Shame in assuming business logic, Honor in human verification.
- Shame in creating interfaces, Honor in reusing existing ones.
- Shame in skipping validation, Honor in proactive testing.
- Shame in breaking architecture, Honor in following specifications.
- Shame in pretending to understand, Honor in honest ignorance.
- Shame in blind modification, Honor in careful refactoring.
- English Only: usage of Chinese comments is strictly forbidden.
- No Unnecessary Comments: For simple, obvious code, let the code speak for itself.
- Self-Documenting Code: Prefer explicit types and clear naming over inline documentation.
- Composition over Inheritance: Favor functional patterns where applicable (Rust).
Name: Pake Purpose: Turn any webpage into a lightweight desktop app on macOS, Windows, and Linux. Core Value: Significantly smaller (~5MB) and faster than Electron equivalents. Mechanism: Uses Rust and Tauri to wrap web content in a system webview (WebView2 on Windows, WebKit on macOS/Linux).
- Core Framework: Tauri v2 (Rust)
- CLI: TypeScript, Node.js, Commander.js
- Frontend: HTML/CSS/JS (Injected into webviews)
- Package Manager: pnpm
bin/: The CLI tool source code.cli.ts: Entry point.builders/: Logic for building apps (Mac, Win, Linux).options/: CLI argument parsing.
src-tauri/: The Main Desktop Application.src/main.rs: Entry point, callslib.rs.src/lib.rs: Core Logic. Menu setup, plugin initialization (window-state,oauth,http, etc.), application lifecycle, and event handling.src/inject/: Javascript files injected into the target website.tauri.conf.json: Default configuration.pake.json: Capabilities config.
dist/: Compiled CLI output.
- Understand: Study existing patterns in codebase.
- Plan: Break complex work into stages.
- Test: Write tests first (when applicable).
- Implement: Minimal working solution.
- Refactor: Optimize and clean up.
Commands:
pnpm i: Install dependencies.pnpm run cli: Run CLI in watch mode.pnpm run dev: Run App in dev mode (hot reload).pnpm test: Run comprehensive test suite.
pnpm run cli:build: Build CLI.pnpm run build: Build App.pnpm run build:debug: Build App with debug info.
- CI/CD handles releases via GitHub Actions.
- Versions are managed in
package.jsonandsrc-tauri/tauri.conf.json.
- Uses
commanderfor argument parsing. - Validates URLs and numbers.
BuilderProviderselects the correct builder based on platform.- Key Options:
--width,--height,--icon,--inject,--hide-title-bar.
lib.rs: The brain.- Sets up the menu (Mac vs others).
- Configures plugins (
window-state,single-instance,opener, etc.). - Handles custom commands:
download_file,send_notification. - Manages window events (hide on close).
- Window Management:
- Uses
tauri-plugin-window-stateto remember window sizes/positions. - Supports "Start to Tray" and "Hide on Close".
- Uses
- Path:
src-tauri/src/inject/ - Mechanism: Tauri injects these scripts at runtime.
- Functionality:
- Custom CSS override.
- Keyboard shortcuts (Zoom, Navigation).
- Platform-specific tweaks.
- Adding a CLI Option:
- Update
bin/types.ts(Interface). - Update
bin/defaults.ts(Default value). - Update
bin/cli.ts(Commander option). - Update
bin/options/index.ts(Processing). - Update
src-tauri/src/app/config.rs(Struct definition) if it needs to pass to Rust.
- Update
- Modifying Menu: Edit
src-tauri/src/lib.rsinsidesetupclosure. - Updating Injected Script: Edit
src-tauri/src/inject/event.jsorcomponent.js.