another attempt, but from scratch.

This commit is contained in:
Hannes Rudolph 2025-08-25 16:56:22 -06:00
parent 8db9d2f7d7
commit 053e159c65
5 changed files with 55 additions and 51 deletions

View file

@ -1,10 +1,7 @@
# Architect Mode Rules
# Project Architecture Rules (Non-Obvious Only)
## Non-Obvious Architecture Constraints
- Providers MUST be stateless - hidden caching layer assumes this
- Webview and extension communicate through specific IPC channel patterns only
- React hooks required because external state libraries break webview isolation
- Large JSON operations must use `safeWriteJson()` for streaming (prevents memory issues)
- TypeScript `noUncheckedIndexedAccess: true` - array/object access may return undefined
- Import paths in packages/ require `.js` extensions despite TypeScript source
- Webview and extension communicate ONLY through `src/core/webview/webviewMessageHandler.ts` patterns
- React hooks required in webview - external state libraries break VSCode webview isolation
- Monorepo has circular dependency on types package (intentional design)
- `safeWriteJson()` mandatory for JSON writes - uses atomic writes with file locking
- Database operations require specific directory: must `cd packages/evals` before running migrations

View file

@ -1,8 +1,7 @@
# Ask Mode Rules
# Project Documentation Rules (Non-Obvious Only)
## Non-Obvious Documentation Context
- `src/` contains VSCode extension code, NOT generic source (counterintuitive naming)
- Two separate i18n systems: root `locales/` for extension, `webview-ui/src/i18n/` for UI
- Provider examples in `src/api/providers/` are canonical reference (docs may be outdated)
- Webview runs in VSCode context with restrictions (no localStorage, limited browser APIs)
- `src/` contains VSCode extension code, NOT general source (counterintuitive naming)
- `webview-ui/` is React UI in VSCode webview with severe restrictions (no localStorage, limited APIs)
- Two separate i18n systems: `locales/` for extension, `webview-ui/src/i18n/` for UI
- Monorepo workspace roots are `"src"` and `"webview-ui"` (not standard `packages/` structure)
- Extension bundled with custom `esbuild.mjs`, webview uses Vite

View file

@ -1,10 +1,8 @@
# Code Mode Rules
# Project Coding Rules (Non-Obvious Only)
## Critical Non-Obvious Patterns
- **MANDATORY**: Use `safeWriteJson()` from `src/utils/safeWriteJson.ts` for ALL JSON writes (prevents corruption via atomic writes with locking)
- Tests MUST run from workspace directory: `cd src && npx vitest run` (NOT from root)
- VSCode CSS variables must be added to `webview-ui/src/index.css` before use
- State management via React hooks only (external state libraries break webview isolation)
- Providers MUST be stateless (hidden caching layer assumes this)
- Import paths in packages/ require `.js` extensions despite TypeScript source
- Always use `safeWriteJson()` from `src/utils/safeWriteJson.ts` instead of `JSON.stringify` for file writes (prevents corruption)
- Extension code in `src/` directory, NOT in `apps/` (counterintuitive structure)
- Webview UI in `webview-ui/` runs with restricted APIs - no localStorage, limited browser features
- IPC patterns MUST follow `src/core/webview/webviewMessageHandler.ts` structure
- Tests must be in `__tests__` folders or `.spec.ts` files (vitest won't find them otherwise)
- VSCode API mocked differently: `src/__mocks__/vscode.js` vs `webview-ui/src/__mocks__/vscode.ts`

View file

@ -1,13 +1,7 @@
# Debug Mode Rules
# Project Debug Rules (Non-Obvious Only)
## Non-Obvious Debug Access
- Webview DevTools: Command Palette → "Developer: Open Webview Developer Tools" (NOT F12)
- Extension logs: VSCode Output panel → "Roo Code" channel
- Extension Host output channel shows different logs than Debug Console
## Critical Debug Patterns
- IPC messages fail silently without try/catch in `packages/ipc/src/`
- Tests MUST run from workspace directory: `cd src && npx vitest run`
- Webview runs in restricted context (no localStorage, limited browser APIs)
- Extension logs only visible in "Extension Host" output channel, NOT Debug Console
- Webview dev tools accessed via Command Palette > "Developer: Open Webview Developer Tools" (not F12)
- Database migrations MUST run from `packages/evals/` directory: `cd packages/evals && pnpm db:migrate`
- IPC messages fail silently if not wrapped in try/catch in webview message handlers
- Two separate mock systems: `src/__mocks__/vscode.js` for extension, `webview-ui/src/__mocks__/vscode.ts` for UI

View file

@ -2,20 +2,36 @@
This file provides guidance to agents when working with code in this repository.
## Critical Non-Obvious Patterns
## Critical Non-Obvious Rules
- **JSON Writes**: MUST use `safeWriteJson()` from `src/utils/safeWriteJson.ts` for ALL JSON writes (atomic writes with locking, handles streaming)
- **Test Execution**: Tests MUST run from workspace directory: `cd src && npx vitest run` or `cd webview-ui && npx vitest run` (NOT from root)
- **Import Extensions**: Use `.js` extensions in packages/ imports despite TypeScript source files
- **Bootstrap**: `pnpm install` auto-bootstraps via `scripts/bootstrap.mjs` if pnpm not found
- **Webview DevTools**: Access via Command Palette → "Developer: Open Webview Developer Tools" (not F12)
- **VSCode CSS Variables**: Must be added to `webview-ui/src/index.css` before use in components
- **React Hooks Required**: External state libraries break webview isolation - use React hooks only
- **noUncheckedIndexedAccess**: TypeScript strict mode with this enabled - array/object access may return undefined
- **MUST** use `safeWriteJson()` from `src/utils/safeWriteJson.ts` for ALL JSON file writes (prevents corruption via atomic writes with locking)
- Test files exempt from safeWriteJson rule
## Architecture Gotchas
## Project Structure (Non-Standard)
- `src/` contains VSCode extension backend (not generic source)
- `webview-ui/` is React frontend in VSCode webview (restricted APIs, no localStorage)
- IPC messages between extension/webview must use typed interfaces from `packages/types`
- Provider implementations must be stateless (hidden caching layer assumes this)
- `src/` contains VSCode extension code (NOT general source - counterintuitive naming)
- `webview-ui/` is the React UI that runs in VSCode webview (separate from extension)
- Two separate i18n systems: root `locales/` for extension, `webview-ui/src/i18n/` for UI
- Monorepo uses pnpm workspaces with unusual paths: `"src"` and `"webview-ui"` as workspace roots
## Testing Specifics
- Tests MUST be in `__tests__` folders or `.spec.ts` files (vitest configured this way)
- VSCode module mocked at `src/__mocks__/vscode.js` and `webview-ui/src/__mocks__/vscode.ts`
- Run single test: `pnpm test -- path/to/test.spec.ts`
## Build Commands (Directory-Sensitive)
- Database operations MUST run from `packages/evals/` directory: `cd packages/evals && pnpm db:migrate`
- Extension bundling uses custom `esbuild.mjs` script, not standard vite/webpack
## Webview Restrictions
- Webview has NO localStorage, limited browser APIs
- IPC communication through specific patterns in `src/core/webview/webviewMessageHandler.ts`
- State management requires React hooks only (external state libraries break isolation)
## Code Style (Non-Standard)
- Tabs not spaces (4-width), no semicolons, bracket same line
- Line width 120 chars (not default 80)