|
1 | | -# Code Quality Rules |
| 1 | +# Roo Code Development Guide |
2 | 2 |
|
3 | | -1. Test Coverage: |
| 3 | +## Build & Test Commands |
4 | 4 |
|
5 | | - - Before attempting completion, always make sure that any code changes have test coverage |
6 | | - - Ensure all tests pass before submitting changes |
7 | | - - The vitest framework is used for testing; the `describe`, `test`, `it`, etc functions are defined by default in `tsconfig.json` and therefore don't need to be imported |
8 | | - - Tests must be run from the same directory as the `package.json` file that specifies `vitest` in `devDependencies` |
| 5 | +```bash |
| 6 | +pnpm install # Install dependencies |
| 7 | +pnpm test # Run all tests |
| 8 | +pnpm lint # Run ESLint |
| 9 | +pnpm check-types # TypeScript type checking |
| 10 | +pnpm build # Build the project |
| 11 | +pnpm format # Format code with Prettier |
9 | 12 |
|
10 | | -2. Lint Rules: |
| 13 | +# Run a single test file (from src/ directory) |
| 14 | +pnpm test path/to/test.spec.ts |
| 15 | +``` |
11 | 16 |
|
12 | | - - Never disable any lint rules without explicit user approval |
| 17 | +## Code Style Guidelines |
13 | 18 |
|
14 | | -3. Styling Guidelines: |
15 | | - - Use Tailwind CSS classes instead of inline style objects for new markup |
16 | | - - VSCode CSS variables must be added to webview-ui/src/index.css before using them in Tailwind classes |
17 | | - - Example: `<div className="text-md text-vscode-descriptionForeground mb-2" />` instead of style objects |
| 19 | +- **TypeScript**: Strict mode enabled, use explicit types |
| 20 | +- **Testing**: Vitest with globals, no imports needed for `describe`, `test`, `it` |
| 21 | +- **Linting**: ESLint with TypeScript rules, never disable without approval |
| 22 | +- **Formatting**: Prettier for consistent code style |
| 23 | +- **Imports**: Use relative paths, organize by external/internal/types |
| 24 | +- **Naming**: camelCase for variables/functions, PascalCase for types/classes |
| 25 | +- **Files**: kebab-case for filenames, `.test.ts` or `.spec.ts` for tests |
18 | 26 |
|
19 | | -# Adding a New Setting |
| 27 | +## UI Development |
20 | 28 |
|
21 | | -To add a new setting that persists its state, follow the steps in docs/settings.md |
| 29 | +- Use Tailwind CSS classes instead of inline styles |
| 30 | +- VSCode CSS variables go in `webview-ui/src/index.css` |
| 31 | +- Example: `<div className="text-vscode-descriptionForeground" />` |
| 32 | + |
| 33 | +## Error Handling |
| 34 | + |
| 35 | +- Use try-catch for async operations |
| 36 | +- Log errors with context using the logger utility |
| 37 | +- Provide meaningful error messages to users |
| 38 | + |
| 39 | +## Testing Requirements |
| 40 | + |
| 41 | +- All code changes must have test coverage |
| 42 | +- Run tests from the directory containing package.json |
| 43 | +- Tests use mocks in `src/__mocks__/` for VSCode APIs |
| 44 | + |
| 45 | +## Monorepo Structure |
| 46 | + |
| 47 | +This is a pnpm workspace monorepo using Turbo for build orchestration: |
| 48 | + |
| 49 | +### Main Workspaces |
| 50 | + |
| 51 | +- `/src` - Main VSCode extension code (package: roo-cline) |
| 52 | +- `/webview-ui` - React-based UI components (@roo-code/vscode-webview) |
| 53 | +- `/apps/` - Additional applications: |
| 54 | + - `vscode-e2e` - End-to-end tests using Mocha |
| 55 | + - `vscode-nightly` - Nightly build configuration |
| 56 | + - `web-docs` - Documentation website |
| 57 | + - `web-evals` - Evaluation system web app |
| 58 | + - `web-roo-code` - Main website |
| 59 | +- `/packages/` - Shared packages: |
| 60 | + - `types` - Shared TypeScript types (@roo-code/types) |
| 61 | + - `cloud` - Cloud integration utilities |
| 62 | + - `telemetry` - Analytics and telemetry |
| 63 | + - `config-eslint` - Shared ESLint configuration |
| 64 | + - `config-typescript` - Shared TypeScript configuration |
| 65 | + - `ipc` - Inter-process communication utilities |
| 66 | + |
| 67 | +### Key Dependencies |
| 68 | + |
| 69 | +- Build: Turbo, pnpm workspaces |
| 70 | +- Testing: Vitest (unit), Mocha (E2E) |
| 71 | +- UI: React 18, Tailwind CSS, Radix UI |
| 72 | +- Bundling: Vite (webview), esbuild (extension) |
0 commit comments