You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -95,31 +95,81 @@ We use GitHub to host code, to track issues and feature requests, as well as acc
95
95
96
96
## Project Structure
97
97
98
-
- `/src` - Main source code
99
-
- `/scripts` - Build and development scripts
100
-
- `/resources` - Application resources
101
-
- `/build` - Build configuration
102
-
- `/out` - Build output
98
+
- `src/main/`: Electron main process. Presenters live here (window/tab/thread/config/llmProvider/mcp/config/knowledge/sync/floating button/deeplink/OAuth, etc.).
99
+
- `src/preload/`: Context-isolated IPC bridge; only exposes whitelisted APIs to the renderer.
- `src/shared/`: Shared types/utilities and presenter contracts used by both processes.
102
+
- `runtime/`: Bundled runtimes used by MCP and agent tooling (Node/uv).
103
+
- `scripts/`, `resources/`: Build, packaging, and asset pipelines.
104
+
- `build/`, `out/`, `dist/`: Build outputs (do not edit manually).
105
+
- `docs/`: Design docs and guides.
106
+
- `test/`: Vitest suites for main/renderer.
103
107
104
-
## Code Style
108
+
## Architecture Overview
105
109
106
-
- We use ESLint for JavaScript/TypeScript linting
107
-
- Prettier for code formatting
108
-
- EditorConfig for maintaining consistent coding styles
110
+
### Design Principles
109
111
110
-
Please ensure your code follows our style guidelines by running:
112
+
- **Presenter pattern**: All system capabilities are in main-process presenters; the renderer calls them via the typed `usePresenter` hook and preload bridge.
113
+
- **Multi-window + multi-tab shell**: WindowPresenter and TabPresenter manage true Electron windows/BrowserViews with detach/move support; an EventBus fans out cross-process events.
114
+
- **Clear data boundaries**: Chat data lives in SQLite (`app_db/chat.db`), settings in Electron Store, knowledge bases in DuckDB, and backups via SyncPresenter. Renderer never touches the filesystem directly.
115
+
- **Tooling-first runtime**: LLMProviderPresenter handles streaming, rate limits, and provider instances (cloud/local/ACP agent). MCPPresenter boots MCP servers, router marketplace, and in-memory tools with a bundled Node runtime.
- **LLM pipeline**: `LLMProviderPresenter` orchestrates providers with rate-limit guards, per-provider instances, model discovery, ModelScope sync, custom model import, Ollama lifecycle, embeddings, and the agent loop (tool calls, streaming states). Session persistence for ACP agents lives in `AcpSessionPersistence`.
144
+
- **MCP stack**: `McpPresenter` uses ServerManager/ToolManager/McpRouterManager to start/stop servers, choose npm registries, auto-start default/builtin servers, and surface tools/prompts/resources. Supports StreamableHTTP/SSE/Stdio transports and a debugging UI.
145
+
- **ACP (Agent Client Protocol)**: ACP providers spawn agent processes, map notifications into chat blocks, and feed the **ACP Workspace** (plan panel with incremental updates, terminal output, and a guarded file tree that requires `registerWorkdir`). PlanStateManager deduplicates plan items and keeps recent completions.
146
+
- **Knowledge & search**: Built-in knowledge bases use DuckDB/vector pipelines with text splitters and MCP-backed configs; search assistants auto-select models and support API + simulated-browser engines via MCP or custom templates.
- **Use presenters, not Node APIs in the renderer**: All OS/network/filesystem work should go through the preload bridge and presenters. Keep features multi-window-safe by scoping state to `tabId`/`windowId`.
152
+
- **i18n everywhere**: All user-visible strings belong in `src/renderer/src/i18n`; avoid hardcoded text in components.
153
+
- **State & UI**: Favor Pinia stores and composition utilities; keep components stateless where possible and compatible with detached tabs. Consider artifacts, variants, and streaming states when touching chat flows.
154
+
- **LLM/MCP/ACP changes**: Respect rate limits; clean up active streams before switching providers; emit events via `eventBus`. For MCP, persist changes through `configPresenter` and surface server start/stop events. For ACP, always call `registerWorkdir` before reading the filesystem and clear plan/workspace state when sessions end.
155
+
- **Data & persistence**: Use `sqlitePresenter` for conversation data, `configPresenter` for settings/providers, and `syncPresenter` for backup/import. Do not write directly into `appData` from the renderer.
156
+
- **Testing & quality gates**: Before sending a PR, run `pnpm run format`, `pnpm run lint`, `pnpm run typecheck`, and relevant `pnpm test*` suites. Use `pnpm run i18n` to validate locale keys when adding strings.
157
+
158
+
## Code Style
159
+
160
+
- TypeScript + Vue 3 Composition API + Pinia; Tailwind + shadcn/ui for styling.
161
+
- Prettier enforces single quotes and no semicolons; `pnpm run format` before committing.
162
+
- OxLint is used for linting (`pnpm run lint`). Type checking via `pnpm run typecheck` (node + web targets).
163
+
- Tests use Vitest (`test/main`, `test/renderer`). Name tests `*.test.ts`/`*.spec.ts`.
0 commit comments