|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +Kunkun is a cross-platform desktop application built with Tauri (Rust backend) and SvelteKit (frontend). It's an extensible launcher/utility app that supports custom extensions developed in various web frameworks. |
| 8 | + |
| 9 | +## Development Commands |
| 10 | + |
| 11 | +### Essential Commands |
| 12 | +- `pnpm install` - Install all dependencies |
| 13 | +- `pnpm build` - Build all packages and submodules |
| 14 | +- `pnpm dev` - Start development servers for all packages |
| 15 | +- `pnpm lint` - Run linting across all packages |
| 16 | +- `pnpm test` - Run tests across all packages |
| 17 | +- `pnpm check-types` - Run TypeScript type checking |
| 18 | +- `pnpm format` - Format code with Prettier |
| 19 | + |
| 20 | +### Desktop App Specific |
| 21 | +- `pnpm --filter @kksh/desktop tauri dev` - Run desktop app in development mode |
| 22 | +- `cd apps/desktop && pnpm tauri dev` - Alternative way to run desktop app |
| 23 | +- `cd apps/desktop && pnpm tauri build` - Build desktop app for production |
| 24 | + |
| 25 | +### Prerequisites for Development |
| 26 | +- Node.js ≥22 |
| 27 | +- pnpm 10.7.0+ (package manager) |
| 28 | +- Rust (for Tauri backend) |
| 29 | +- Bun, Deno (for various tools) |
| 30 | +- protobuf (`brew install protobuf` on macOS) |
| 31 | +- cmake (`brew install cmake` on macOS) |
| 32 | + |
| 33 | +## Architecture |
| 34 | + |
| 35 | +### Monorepo Structure |
| 36 | +- **apps/**: Main applications |
| 37 | + - `desktop/`: Primary Tauri desktop app (SvelteKit frontend + Rust backend) |
| 38 | + - `cli/`: Command-line interface |
| 39 | + - `create-kunkun/`: Scaffolding tool for extensions |
| 40 | +- **packages/**: Shared libraries and utilities |
| 41 | + - `ui/`: Shared UI components |
| 42 | + - `types/`: TypeScript type definitions |
| 43 | + - `extension/`: Extension development framework |
| 44 | + - `drizzle/`: Database ORM setup |
| 45 | + - `tauri-plugins/`: Custom Tauri plugins |
| 46 | + - `templates/`: Extension templates |
| 47 | + - `extensions/`: Sample/demo extensions |
| 48 | +- **vendors/**: Third-party dependencies and custom plugins |
| 49 | + |
| 50 | +### Key Technologies |
| 51 | +- **Frontend**: SvelteKit 2 with TypeScript, TailwindCSS, Vite |
| 52 | +- **Backend**: Rust with Tauri 2.x framework |
| 53 | +- **Database**: SQLite with Drizzle ORM |
| 54 | +- **Build System**: Turbo (monorepo orchestration) + pnpm workspaces |
| 55 | +- **UI Framework**: Custom component library built on Tailwind + Radix |
| 56 | + |
| 57 | +### Extension System |
| 58 | +- Extensions can be built with React, Vue, Svelte, SvelteKit, Nuxt, or vanilla JS |
| 59 | +- Templates available in `packages/templates/` for each framework |
| 60 | +- Extensions run in isolated contexts with permission-based APIs |
| 61 | +- Custom Tauri plugins provide system access (clipboard, fs, network, etc.) |
| 62 | + |
| 63 | +### Rust Backend Architecture |
| 64 | +- Custom Tauri plugins for extended functionality: |
| 65 | + - `tauri-plugin-jarvis`: Core extension runtime |
| 66 | + - `tauri-plugin-network`: Network operations |
| 67 | + - `tauri-plugin-system-info`: System information |
| 68 | + - `tauri-plugin-user-input`: Input handling |
| 69 | + - `tauri-plugin-keyring`: Secure credential storage |
| 70 | +- gRPC communication for some internal services |
| 71 | +- Cross-platform support with platform-specific dependencies |
| 72 | + |
| 73 | +## Development Workflow |
| 74 | + |
| 75 | +### Setting Up Development Environment |
| 76 | +```bash |
| 77 | +git clone https://github.com/kunkunsh/kunkun.git --recursive |
| 78 | +pnpm install |
| 79 | +pnpm build # Build submodules first |
| 80 | +``` |
| 81 | + |
| 82 | +### Working with Extensions |
| 83 | +- Use `apps/create-kunkun` to scaffold new extensions |
| 84 | +- Extension templates are in `packages/templates/` |
| 85 | +- Test extensions in the desktop app's extension manager |
| 86 | + |
| 87 | +### Database Development |
| 88 | +- Uses Drizzle ORM with SQLite backend |
| 89 | +- Database package located in `packages/drizzle/` |
| 90 | +- Migrations and schema definitions managed through Drizzle |
| 91 | + |
| 92 | +## Testing and Quality |
| 93 | + |
| 94 | +### Linting and Type Checking |
| 95 | +- ESLint configuration in `packages/config-eslint/` |
| 96 | +- TypeScript config in `packages/typescript-config/` |
| 97 | +- Prettier for code formatting |
| 98 | +- `turbo lint` and `turbo check-types` run across all packages |
| 99 | + |
| 100 | +### Build Process |
| 101 | +- Turbo orchestrates builds across the monorepo |
| 102 | +- Each package defines its own build scripts |
| 103 | +- Dependencies built in topological order via `dependsOn` in turbo.json |
| 104 | + |
| 105 | +## Platform-Specific Notes |
| 106 | + |
| 107 | +### macOS |
| 108 | +- Requires additional security permissions for system access |
| 109 | +- `mac-security-rs` package handles platform-specific APIs |
| 110 | +- Uses private macOS APIs for enhanced functionality |
| 111 | + |
| 112 | +### Dependencies |
| 113 | +- Most packages use workspace dependencies for internal packages |
| 114 | +- External dependencies centrally managed in root package.json |
| 115 | +- Rust dependencies managed via workspace Cargo.toml |
| 116 | + |
| 117 | +## Extension Development Framework |
| 118 | + |
| 119 | +Extensions have access to: |
| 120 | +- File system APIs (through Tauri plugins) |
| 121 | +- Network requests |
| 122 | +- Clipboard operations |
| 123 | +- System information |
| 124 | +- Secure storage (keyring) |
| 125 | +- UI components from shared library |
| 126 | + |
| 127 | +The extension system supports both headless (worker) extensions and full UI extensions with multiple framework options. |
0 commit comments