|
2 | 2 |
|
3 | 3 | This file provides guidance to agents when working with code in this repository. |
4 | 4 |
|
5 | | -## Project Overview |
6 | | - |
7 | | -Roo Code - AI-powered autonomous coding agent VSCode extension with React webview UI, supporting multiple AI providers and custom modes. |
8 | | - |
9 | | -## Build/Test/Lint Commands |
10 | | - |
11 | | -```bash |
12 | | -# Install dependencies (from root) |
13 | | -pnpm install |
14 | | - |
15 | | -# Build entire project |
16 | | -pnpm build |
17 | | - |
18 | | -# Run tests (CRITICAL: run from workspace directory containing package.json) |
19 | | -cd src && npx vitest run tests/user.test.ts # Backend tests |
20 | | -cd webview-ui && npx vitest run src/components/Button.test.tsx # UI tests |
21 | | - |
22 | | -# Lint/format |
23 | | -pnpm lint |
24 | | -pnpm format |
25 | | -``` |
26 | | - |
27 | | -## Code Style |
28 | | - |
29 | | -- **Formatting**: Tabs (4 width), 120 char lines, no semicolons, bracket same line |
30 | | -- **Imports**: ESM modules, use `.js` extensions in packages/ |
31 | | -- **Types**: TypeScript strict mode, `noUncheckedIndexedAccess: true` |
32 | | -- **Naming**: camelCase functions/variables, PascalCase components/classes |
33 | | -- **UI**: Tailwind CSS classes only (no inline styles), VSCode CSS vars via webview-ui/src/index.css |
34 | | - |
35 | | -## Architecture |
36 | | - |
37 | | -``` |
38 | | -src/ # VSCode extension backend (TypeScript) |
39 | | -├── extension.ts # Entry point, registers providers & commands |
40 | | -├── api/providers/ # AI provider implementations |
41 | | -├── core/webview/ # Webview provider & IPC |
42 | | -└── utils/ # Utilities (MUST use safeWriteJson for JSON writes) |
43 | | -
|
44 | | -webview-ui/ # React frontend |
45 | | -├── src/components/ # React components with Tailwind CSS |
46 | | -└── src/hooks/ # Custom React hooks |
47 | | -
|
48 | | -packages/ # Shared packages |
49 | | -├── types/ # Shared TypeScript types |
50 | | -├── ipc/ # IPC communication layer |
51 | | -└── evals/ # Evaluation framework |
52 | | -``` |
53 | | - |
54 | | -## Critical Patterns |
55 | | - |
56 | | -- **JSON Writes**: ALWAYS use `safeWriteJson()` from src/utils/safeWriteJson.ts (atomic writes with locking) |
57 | | -- **Testing**: Run vitest from workspace directory containing package.json, NOT from project root |
58 | | -- **Providers**: Implement Provider interface from packages/types/src/ |
59 | | -- **Webview**: VSCode webview architecture with IPC messaging between extension and UI |
60 | | - |
61 | | -## Development |
62 | | - |
63 | | -- **Debug**: Press F5 in VSCode to launch extension host |
64 | | -- **Hot Reload**: Webview changes appear immediately, core changes auto-reload in dev mode |
65 | | -- **VSIX**: `pnpm vsix` to build, `pnpm install:vsix` to install locally |
| 5 | +## Critical Non-Obvious Patterns |
| 6 | + |
| 7 | +- **JSON Writes**: MUST use `safeWriteJson()` from `src/utils/safeWriteJson.ts` for ALL JSON writes (atomic writes with locking, handles streaming) |
| 8 | +- **Test Execution**: Tests MUST run from workspace directory: `cd src && npx vitest run` or `cd webview-ui && npx vitest run` (NOT from root) |
| 9 | +- **Import Extensions**: Use `.js` extensions in packages/ imports despite TypeScript source files |
| 10 | +- **Bootstrap**: `pnpm install` auto-bootstraps via `scripts/bootstrap.mjs` if pnpm not found |
| 11 | +- **Webview DevTools**: Access via Command Palette → "Developer: Open Webview Developer Tools" (not F12) |
| 12 | +- **VSCode CSS Variables**: Must be added to `webview-ui/src/index.css` before use in components |
| 13 | +- **React Hooks Required**: External state libraries break webview isolation - use React hooks only |
| 14 | +- **noUncheckedIndexedAccess**: TypeScript strict mode with this enabled - array/object access may return undefined |
| 15 | + |
| 16 | +## Architecture Gotchas |
| 17 | + |
| 18 | +- `src/` contains VSCode extension backend (not generic source) |
| 19 | +- `webview-ui/` is React frontend in VSCode webview (restricted APIs, no localStorage) |
| 20 | +- IPC messages between extension/webview must use typed interfaces from `packages/types` |
| 21 | +- Provider implementations must be stateless (hidden caching layer assumes this) |
0 commit comments