|
2 | 2 |
|
3 | 3 | This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
4 | 4 |
|
5 | | -## Project Overview |
| 5 | +## Philosophy |
6 | 6 |
|
7 | | -Pake is a tool that turns any webpage into a desktop app with Rust, using Tauri framework. It's much lighter than Electron (~5M vs ~100M+) and provides better performance. The project consists of a CLI tool for packaging web apps and the core Tauri application framework. |
| 7 | +- **Incremental progress over big bangs**: Break complex tasks into manageable stages |
| 8 | +- **Learn from existing code**: Understand patterns before implementing new features |
| 9 | +- **Clear intent over clever code**: Prioritize readability and maintainability |
8 | 10 |
|
9 | | -## Commands |
| 11 | +## Project Overview |
10 | 12 |
|
11 | | -### Development |
| 13 | +Pake transforms any webpage into a lightweight desktop app using Rust and Tauri. It's significantly lighter than Electron (~5M vs ~100M+) with better performance. |
12 | 14 |
|
13 | | -```bash |
14 | | -# Install dependencies |
15 | | -npm i |
| 15 | +**Core Architecture:** |
16 | 16 |
|
17 | | -# Local development (right-click to open debug mode) |
18 | | -npm run dev |
| 17 | +- **CLI Tool** (`bin/`): TypeScript-based command interface |
| 18 | +- **Tauri App** (`src-tauri/`): Rust desktop framework |
| 19 | +- **Injection System**: Custom CSS/JS injection for webpages |
19 | 20 |
|
20 | | -# CLI development with hot reload |
21 | | -npm run cli:dev |
| 21 | +## Development Workflow |
22 | 22 |
|
23 | | -# Build CLI tools |
24 | | -npm run cli:build |
25 | | -``` |
| 23 | +### 1. Planning Phase |
26 | 24 |
|
27 | | -### Building |
| 25 | +Break complex work into 3-5 stages: |
28 | 26 |
|
29 | | -```bash |
30 | | -# Production build |
31 | | -npm run build |
| 27 | +1. Understand existing patterns in codebase |
| 28 | +2. Plan implementation approach |
| 29 | +3. Write tests first (when applicable) |
| 30 | +4. Implement minimal working solution |
| 31 | +5. Refactor and optimize |
32 | 32 |
|
33 | | -# Debug build |
34 | | -npm run build:debug |
| 33 | +### 2. Implementation Flow |
35 | 34 |
|
36 | | -# Mac universal build (Intel + M1) |
37 | | -npm run build:mac |
| 35 | +**Understanding First:** |
38 | 36 |
|
39 | | -# Generate app configuration |
40 | | -npm run build:config |
| 37 | +```bash |
| 38 | +# Explore codebase structure |
| 39 | +find src-tauri/src -name "*.rs" | head -10 |
| 40 | +grep -r "window_config" src-tauri/src/ |
41 | 41 | ``` |
42 | 42 |
|
43 | | -### CLI Usage |
| 43 | +**Development Commands:** |
44 | 44 |
|
45 | 45 | ```bash |
46 | | -# Install CLI globally |
47 | | -npm install -g pake-cli |
48 | | - |
49 | | -# Package a webpage |
50 | | -pake https://example.com --name MyApp --width 1200 --height 800 |
| 46 | +# Install dependencies |
| 47 | +npm i |
51 | 48 |
|
52 | | -# Also supports names with spaces (cross-platform compatible) |
53 | | -# pake https://translate.google.com --name "Google Translate" --hide-title-bar |
| 49 | +# Development with hot reload |
| 50 | +npm run dev |
54 | 51 |
|
55 | | -# Development with custom options |
56 | | -# Modify DEFAULT_DEV_PAKE_OPTIONS in bin/defaults.ts |
| 52 | +# CLI development |
57 | 53 | npm run cli:dev |
| 54 | + |
| 55 | +# Production build |
| 56 | +npm run build |
58 | 57 | ``` |
59 | 58 |
|
60 | | -### Analysis |
| 59 | +### 3. Testing and Validation |
| 60 | + |
| 61 | +**Key Testing Commands:** |
61 | 62 |
|
62 | 63 | ```bash |
63 | | -# Analyze binary size |
64 | | -npm run analyze |
| 64 | +# Debug build for development |
| 65 | +npm run build:debug |
| 66 | + |
| 67 | +# Multi-platform testing |
| 68 | +npm run build:mac # macOS universal build |
65 | 69 | ``` |
66 | 70 |
|
67 | | -## Architecture |
| 71 | +**Testing Checklist:** |
68 | 72 |
|
69 | | -### Core Components |
| 73 | +- [ ] Test on target platforms |
| 74 | +- [ ] Verify injection system works |
| 75 | +- [ ] Check system tray integration |
| 76 | +- [ ] Validate window behavior |
70 | 77 |
|
71 | | -1. **CLI Tool** (`bin/`): Node.js/TypeScript-based command-line interface |
| 78 | +## Core Components |
72 | 79 |
|
73 | | -- `bin/cli.ts` - Main CLI entry point with Commander.js |
74 | | -- `bin/builders/` - Platform-specific builders (Mac, Windows, Linux) |
75 | | -- `bin/options/` - CLI option processing and validation |
76 | | -- `bin/utils/` - Utility functions for URL validation, platform detection |
| 80 | +### CLI Tool (`bin/`) |
77 | 81 |
|
78 | | -2. **Tauri Application** (`src-tauri/`): Rust-based desktop app framework |
| 82 | +- `bin/cli.ts` - Main entry point |
| 83 | +- `bin/builders/` - Platform-specific builders |
| 84 | +- `bin/options/` - Configuration processing |
79 | 85 |
|
80 | | -- `src-tauri/src/lib.rs` - Main application entry point |
81 | | -- `src-tauri/src/app/` - Application modules (config, window, system tray, shortcuts) |
82 | | -- `src-tauri/src/inject/` - JavaScript/CSS injection for web pages |
83 | | -- `src-tauri/pake.json` - Default app configuration |
| 86 | +### Tauri Application (`src-tauri/`) |
84 | 87 |
|
85 | | -3. **Build System**: Uses Rollup for CLI bundling and Tauri for app packaging |
| 88 | +- `src/lib.rs` - Application entry point |
| 89 | +- `src/app/` - Core modules (window, tray, shortcuts) |
| 90 | +- `src/inject/` - Web page injection logic |
86 | 91 |
|
87 | | -### Configuration System |
| 92 | +### Key Configuration Files |
88 | 93 |
|
89 | | -- **pake.json**: Main configuration file defining window properties, user agents, system tray settings |
90 | | -- **tauri.conf.json**: Tauri-specific configuration |
91 | | -- Platform-specific configs: `tauri.macos.conf.json`, `tauri.windows.conf.json`, `tauri.linux.conf.json` |
| 94 | +- `pake.json` - App configuration |
| 95 | +- `tauri.conf.json` - Tauri settings |
| 96 | +- Platform configs: `tauri.{macos,windows,linux}.conf.json` |
92 | 97 |
|
93 | | -### Key Features Implementation |
| 98 | +## Problem-Solving Approach |
94 | 99 |
|
95 | | -- **Window Management**: `src-tauri/src/app/window.rs` - Window creation, sizing, title bar handling |
96 | | -- **System Tray**: `src-tauri/src/app/setup.rs` - Cross-platform system tray integration |
97 | | -- **Window Close Behavior**: `src-tauri/src/lib.rs` - Configurable close behavior (hide vs exit) |
98 | | -- **Global Shortcuts**: Activation shortcuts for bringing app to foreground |
99 | | -- **Web Integration**: Custom user agents, proxy support, CSS/JS injection |
100 | | -- **Multi-platform**: Builds for macOS (Intel/M1), Windows, Linux (deb/appimage/rpm) |
| 100 | +**When stuck:** |
101 | 101 |
|
102 | | -## File Injection System |
| 102 | +1. **Limit attempts to 3** before stopping to reassess |
| 103 | +2. **Document what doesn't work** and why |
| 104 | +3. **Research alternative approaches** in similar projects |
| 105 | +4. **Question assumptions** - is there a simpler way? |
103 | 106 |
|
104 | | -The project supports injecting custom CSS/JS files into webpages: |
| 107 | +**Example debugging flow:** |
105 | 108 |
|
106 | | -- Files in `src-tauri/src/inject/` contain the injection logic |
107 | | -- Use `--inject` CLI option to specify custom files |
108 | | -- Supports both local and remote injection files |
| 109 | +```bash |
| 110 | +# 1. Check logs |
| 111 | +npm run dev 2>&1 | grep -i error |
| 112 | + |
| 113 | +# 2. Verify dependencies |
| 114 | +cargo check --manifest-path=src-tauri/Cargo.toml |
| 115 | + |
| 116 | +# 3. Test minimal reproduction |
| 117 | +# Create simple test case isolating the issue |
| 118 | +``` |
109 | 119 |
|
110 | | -## Platform-Specific Notes |
| 120 | +## Platform-Specific Development |
111 | 121 |
|
112 | 122 | ### macOS |
113 | 123 |
|
114 | | -- Supports universal builds (Intel + M1) with `--multi-arch` |
115 | | -- Hide title bar option available with `--hide-title-bar` |
| 124 | +- Universal builds: `--multi-arch` flag |
116 | 125 | - Uses `.icns` icons |
| 126 | +- Title bar customization available |
117 | 127 |
|
118 | 128 | ### Windows |
119 | 129 |
|
120 | | -- Requires specific build tools and redistributables (see bin/README.md) |
| 130 | +- Requires Visual Studio Build Tools |
121 | 131 | - Uses `.ico` icons |
122 | | -- Supports installer language configuration |
| 132 | +- MSI installer support |
123 | 133 |
|
124 | 134 | ### Linux |
125 | 135 |
|
126 | | -- Multiple package formats: deb, appimage, rpm |
127 | | -- Requires specific system dependencies (libwebkit2gtk, etc.) |
| 136 | +- Multiple formats: deb, AppImage, rpm |
| 137 | +- Requires `libwebkit2gtk` and dependencies |
128 | 138 | - Uses `.png` icons |
129 | 139 |
|
130 | | -## Development Workflow |
| 140 | +## Quality Standards |
| 141 | + |
| 142 | +**Code Standards:** |
| 143 | + |
| 144 | +- Prefer composition over inheritance |
| 145 | +- Use explicit types over implicit |
| 146 | +- Write self-documenting code |
| 147 | +- Follow existing patterns consistently |
| 148 | + |
| 149 | +**Commit Guidelines:** |
131 | 150 |
|
132 | | -1. **CLI Development**: Modify `bin/defaults.ts` for default options, use `npm run cli:dev` for hot reload |
133 | | -2. **Core App Development**: Work in `src-tauri/src/`, use `npm run dev` for Tauri development |
134 | | -3. **Testing**: Build with `--debug` flag for development tools and verbose logging |
135 | | -4. **Multi-platform**: Test builds on respective platforms or use GitHub Actions |
| 151 | +- Commit working code incrementally |
| 152 | +- Use clear, descriptive messages |
| 153 | +- Never bypass commit hooks |
| 154 | +- Test before committing |
136 | 155 |
|
137 | | -## Branch Management |
| 156 | +## Branch Strategy |
138 | 157 |
|
139 | | -- `dev` branch: Active development, feature PRs should target this branch |
140 | | -- `main` branch: Release branch for tags and publishing |
| 158 | +- `dev` - Active development, target for PRs |
| 159 | +- `main` - Release branch for stable versions |
141 | 160 |
|
142 | 161 | ## Prerequisites |
143 | 162 |
|
144 | | -- Node.js >=16.0.0 |
145 | | -- Rust >=1.78.0 (installed automatically by CLI if missing) |
146 | | -- Platform-specific build tools (see Tauri prerequisites) |
| 163 | +- Node.js ≥22.0.0 (recommended LTS, older versions ≥16.0.0 may work) |
| 164 | +- Rust ≥1.89.0 (recommended stable, older versions ≥1.78.0 may work) |
| 165 | +- Platform build tools (see CONTRIBUTING.md for details) |
0 commit comments