|
2 | 2 |
|
3 | 3 | ## Project Structure & Module Organization |
4 | 4 |
|
5 | | -npm workspaces monorepo; packages live under `packages/`. |
| 5 | +npm workspaces monorepo under `packages/`. |
6 | 6 |
|
7 | | -- `packages/core/src/` — LLM session (`session.ts`), prompt/tool definitions (`prompt.ts`), settings resolution (`settings.ts`), `tools/` (10 built-in handlers), `common/` (permissions, OpenAI client, DeepSeek Files API, file history), `mcp/`. |
8 | | -- `packages/cli/src/` — Ink/React terminal UI: `cli.tsx` entry, `ui/views`, `ui/components`, `ui/core`, `ui/hooks`, `tests/`. |
9 | | -- `packages/vscode-ide-companion/` — VSCode extension companion. |
10 | | -- `docs/` — user documentation; `scripts/` — build/release tooling; `dist/` — bundled CLI output (gitignored). |
| 7 | +- `packages/core/src/` — `session.ts` (LLM loop, streaming, retry, compaction), `tools/` (10 handlers), `common/` (permissions, OpenAI client, model capabilities, file history), `mcp/`, `templates/`. |
| 8 | +- `packages/cli/src/` — Ink/React terminal UI (`cli.tsx`, `ui/views`, `ui/components`, `ui/core`, `ui/hooks`); `packages/vscode-ide-companion/` — VSCode companion. |
| 9 | +- `docs/` — user docs; `scripts/` — build/release tooling; `dist/` — bundled output (gitignored). |
11 | 10 |
|
12 | 11 | ## Build, Test, and Development Commands |
13 | 12 |
|
14 | | -All commands run from the repo root. |
15 | | - |
16 | | -- `npm run typecheck`, `npm run lint`, `npm run format:check` — type/lint/format checks; `npm run check` runs all three. |
17 | | -- `npm run build` — full build (core + CLI bundle + assets); `npm run bundle` — esbuild bundle + git info; `npm run build:vscode` — VSCode companion. |
18 | | -- `npm test` — all workspace tests; `npm run start` — run the built CLI. |
| 13 | +- `npm run check` — typecheck/lint/format check; `npm test` — all workspace tests. |
| 14 | +- `npm run build` — full build; `npm run bundle` — esbuild bundle + git info; `npm run start` — run the built CLI. |
19 | 15 | - Single test: `node packages/core/src/tests/run-tests.mjs packages/core/src/tests/session.test.ts`. |
20 | | -- Manual run: `node packages/cli/dist/cli.js` (after `npm run bundle`). |
21 | 16 |
|
22 | 17 | ## Coding Style & Naming Conventions |
23 | 18 |
|
24 | | -- 2-space indent, double quotes, semicolons, `es5` trailing commas, 120-char lines, LF endings. |
25 | | -- TypeScript strict; `import type` for type-only imports; `_` prefix for unused vars; ES2022/ESNext; JSX `react-jsx`. |
26 | | -- Prettier + ESLint; Husky/lint-staged formats staged files on commit. |
27 | | -- Files: `kebab-case.ts`; components `kebab-case.tsx`; tests `*.test.ts`. |
| 19 | +- 2-space indent, double quotes, semicolons, `es5` trailing commas, 120-char lines, LF endings; TypeScript strict. |
| 20 | +- `import type` for type-only imports; `_` prefix for unused vars; ES2022/ESNext; JSX `react-jsx`. |
| 21 | +- Prettier + ESLint; Husky/lint-staged formats staged files. Files: `kebab-case.ts`, `kebab-case.tsx`, `*.test.ts`. |
28 | 22 |
|
29 | 23 | ## Testing Guidelines |
30 | 24 |
|
31 | 25 | - Node native test runner (`node:test`) via `tsx`; assertions with `node:assert/strict`. |
32 | | -- Tests live in `packages/*/src/tests/` matching the source module name; descriptive `describe`/`test` names. |
33 | | -- Run `npm test` before submitting a PR. |
| 26 | +- Tests live in `packages/*/src/tests/`, named after the source module. Run `npm test` before PRs. |
34 | 27 |
|
35 | 28 | ## Commit & Pull Request Guidelines |
36 | 29 |
|
37 | 30 | - Conventional commits: `feat:`, `fix:`, `chore:`, `refactor:`, `style:`, `test:`, `docs:`, `perf:`, `build:`. |
38 | | -- PRs: clear description, linked issues, screenshots for UI changes, `npm run check && npm test` passing, no unintended `dist/` or `package-lock.json` changes. |
| 31 | +- PRs: clear description, linked issues, UI screenshots, passing `npm run check && npm test`, no unintended `dist/`/`package-lock.json` changes. |
39 | 32 |
|
40 | 33 | ## Architecture Overview |
41 | 34 |
|
42 | | -- `@vegamo/deepcode-cli` renders a terminal UI with Ink; `SessionManager` (`@vegamo/deepcode-core`) drives the LLM loop — prompts, streaming, `ToolExecutor`, context compaction (`contextWindow`/`autoCompactWindow`). |
43 | | -- Connectivity: `createOpenAIClient()` (180s keep-alive) with DeepCode Plus fallback; errors normalized via `describeLlmError()`. |
44 | | -- Tools: 10 built-ins — `bash`, `read`, `write`, `edit`, `skill`, `AskUserQuestion`, `UpdatePlan`, `WebSearch`, `ReadImage`, `UnderstandImage`. `ReadImage` (multimodal models) returns the image itself, validated/downscaled via Sharp; `UnderstandImage` is the plugin-backed fallback. `read` returns a `snippet_id` for subsequent `edit` calls. |
45 | | -- Images: `supportsMultimodal()` + `multimodal` setting choose `ReadImage` vs `UnderstandImage`; `filesApiEnabled` uploads images to the DeepSeek Files API, caching file IDs in `~/.deepcode/files-api-cache.json`. |
46 | | -- Permissions (`permissions.ts`) control allow/deny/ask by scope; `file-history.ts` provides undo via lightweight Git branches. |
47 | | -- Models: default `deepseek-v4-flash`; `/model` offers `deepseek-v4-pro`, `deepseek-v4-flash`, `deepseek-v4-flash-vision-exp` with reasoning effort `low`/`high`/`max`. |
48 | | -- Slash commands: `/skills`, `/model`, `/plan`, `/new`, `/init`, `/resume`, `/fork`, `/continue`, `/undo`, `/mcp`, `/raw`, `/exit`, plus dynamic `/skill-name`. Plan Mode (`/plan` or `Shift+Tab`) requires `<proposed_plan>` approval before writes. |
| 35 | +- `@vegamo/deepcode-cli` (Ink TUI) uses `SessionManager` (`@vegamo/deepcode-core`) to drive the LLM loop: prompts, streaming preview, tools, retry, compaction. |
| 36 | +- Connectivity: `createOpenAIClient()` (180s keep-alive) with DeepCode Plus fallback; `describeLlmError()` normalizes errors. |
| 37 | +- Tools: 10 built-ins — `bash`, `read`, `write`, `edit`, `skill`, `AskUserQuestion`, `UpdatePlan`, `WebSearch`, `ReadImage`, `UnderstandImage`; `read` returns a `snippet_id` for `edit`. |
| 38 | +- Images: `supportsMultimodal()` + `multimodal` choose `ReadImage` vs `UnderstandImage`; `filesApiEnabled` uploads via the DeepSeek Files API. |
| 39 | +- Permissions: 12 scopes incl. `read-in-tmp`/`write-in-tmp`; `addWorkingDirs` extends the workspace; `file-history.ts` provides undo. |
| 40 | +- Models: default `deepseek-flash` (V4.1 Flash); `/model` offers `deepseek-flash`, `deepseek-v4-pro`, `deepseek-v4-flash`, `deepseek-v4-flash-vision-exp` with thinking effort `low`/`high`/`max`. |
| 41 | +- Slash commands: `/skills`, `/model`, `/plan`, `/new`, `/init`, `/resume`, `/fork`, `/continue`, `/undo`, `/mcp`, `/raw`, `/exit`, plus dynamic `/skill-name`. Plan Mode gates writes behind `<proposed_plan>` approval. |
49 | 42 | - CLI flags: `-p`, `-x`, `-r`, `-f`, `-l`, `-v`, `-h`. |
50 | 43 |
|
51 | 44 | ## Agent-Specific Instructions |
52 | 45 |
|
53 | | -- AGENTS.md loads from `./AGENTS.md`, `./.deepcode/AGENTS.md`, or `~/.deepcode/AGENTS.md` (first found wins). |
54 | | -- Skills: `~/.agents/skills/<name>/SKILL.md` (user) or `./.agents/skills/<name>/SKILL.md` (project); legacy `./.deepcode/skills/` also scanned. Call the `skill` tool for full instructions. Bundled: `deepcode-self-refer`, `image-generator`, `skill-digester`, `skill-writer`. |
55 | | -- Prompt file references: `@path/to/file`. |
| 46 | +- AGENTS.md loads from `./.deepcode/AGENTS.md`, `./AGENTS.md`, then `~/.deepcode/AGENTS.md` (first found wins). |
| 47 | +- Skills load from `./.deepcode/skills`, `./.agents/skills`, or `~` equivalents; call the `skill` tool. Bundled: `deepcode-self-refer`, `image-generator`, `video-generator`, `skill-digester`, `skill-writer`. |
| 48 | +- File references: `@path/to/file`. |
0 commit comments