Skip to content

Commit 8db9d2f

Browse files
committed
refactor: clean up AGENTS.md files to only include non-obvious patterns
- Reduced main AGENTS.md from 65 to 21 lines - Reduced .roo/rules-code/AGENTS.md from 39 to 11 lines - Reduced .roo/rules-debug/AGENTS.md from 40 to 13 lines - Reduced .roo/rules-ask/AGENTS.md from 39 to 8 lines - Reduced .roo/rules-architect/AGENTS.md from 42 to 10 lines Removed all obvious information like standard commands, framework defaults, and common patterns. Files now only contain truly non-obvious, project-specific gotchas discovered by reading the actual code.
1 parent 2581fcc commit 8db9d2f

File tree

5 files changed

+44
-207
lines changed

5 files changed

+44
-207
lines changed

.roo/rules-architect/AGENTS.md

Lines changed: 8 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,10 @@
11
# Architect Mode Rules
22

3-
## Design Principles
4-
5-
- **VSCode Extension Architecture**: Work within VSCode's webview + extension host model
6-
- **Monorepo Organization**: Maintain clear separation between packages
7-
- **Provider Pattern**: New AI providers must follow existing interface patterns
8-
- **State Management**: React hooks for UI, VSCode context for extension state
9-
10-
## Package Structure Requirements
11-
12-
- New packages go in `packages/` directory
13-
- Must include proper TypeScript configuration extending base
14-
- Shared types belong in `packages/types/src/`
15-
- Follow existing naming conventions (e.g., @roo-code/package-name)
16-
17-
## API Design
18-
19-
- All providers implement Provider interface from packages/types
20-
- IPC messages must be strongly typed
21-
- Backwards compatibility required for existing provider contracts
22-
- Error handling must include proper error types and recovery
23-
24-
## Performance Considerations
25-
26-
- Large JSON operations must use streaming (see safeWriteJson)
27-
- Webview content should lazy-load heavy components
28-
- Code indexing happens asynchronously in background
29-
- Terminal operations should not block UI
30-
31-
## Evals Database & Migrations
32-
33-
- Evals database schemas in `packages/evals/src/db/`
34-
- Migrations required for schema changes
35-
- Use proper transaction handling for data consistency
36-
37-
## Security Patterns
38-
39-
- Never expose sensitive data in webview
40-
- API keys stored in VSCode SecretStorage
41-
- File operations must validate paths
42-
- Command execution requires user approval
3+
## Non-Obvious Architecture Constraints
4+
5+
- Providers MUST be stateless - hidden caching layer assumes this
6+
- Webview and extension communicate through specific IPC channel patterns only
7+
- React hooks required because external state libraries break webview isolation
8+
- Large JSON operations must use `safeWriteJson()` for streaming (prevents memory issues)
9+
- TypeScript `noUncheckedIndexedAccess: true` - array/object access may return undefined
10+
- Import paths in packages/ require `.js` extensions despite TypeScript source

.roo/rules-ask/AGENTS.md

Lines changed: 5 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,8 @@
11
# Ask Mode Rules
22

3-
## Documentation Sources
3+
## Non-Obvious Documentation Context
44

5-
- Main documentation: README.md, CONTRIBUTING.md, CHANGELOG.md
6-
- API docs: Check provider implementations in `src/api/providers/`
7-
- UI patterns: Reference `webview-ui/src/components/` for React components
8-
- Types: Refer to `packages/types/src/` for TypeScript interfaces
9-
10-
## Code Examples
11-
12-
- Provider examples: Each provider in `src/api/providers/` shows implementation patterns
13-
- Test examples: `src/__tests__/` and `webview-ui/src/**/*.test.tsx`
14-
- IPC patterns: `packages/ipc/src/` for communication examples
15-
- Custom modes: Check `.roo/rules-*/` directories for mode-specific patterns
16-
17-
## Architecture Explanations
18-
19-
- **Monorepo Structure**:
20-
- `src/` - VSCode extension backend
21-
- `webview-ui/` - React frontend
22-
- `packages/` - Shared libraries
23-
- `apps/` - Additional applications
24-
- **Webview Architecture**: VSCode extension hosts React app via webview API
25-
- **Provider Pattern**: All AI providers implement common interface for consistency
26-
- **IPC Communication**: Typed messages between extension and webview
27-
28-
## Command References
29-
30-
- Build commands: See `package.json` scripts section
31-
- Test commands: Must run from workspace directory with package.json
32-
- Development: F5 launches extension in new VSCode window
33-
- VSIX packaging: `pnpm vsix` creates installable package
34-
35-
## Localization
36-
37-
- i18n files in `locales/` directory
38-
- Extension uses vscode.l10n API for translations
39-
- Webview uses i18next for React component translations
5+
- `src/` contains VSCode extension code, NOT generic source (counterintuitive naming)
6+
- Two separate i18n systems: root `locales/` for extension, `webview-ui/src/i18n/` for UI
7+
- Provider examples in `src/api/providers/` are canonical reference (docs may be outdated)
8+
- Webview runs in VSCode context with restrictions (no localStorage, limited browser APIs)

.roo/rules-code/AGENTS.md

Lines changed: 6 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,10 @@
11
# Code Mode Rules
22

3-
## JSON File Operations
3+
## Critical Non-Obvious Patterns
44

5-
- **MANDATORY**: Use `safeWriteJson()` from `src/utils/safeWriteJson.ts` for ALL JSON writes
6-
- Never use `JSON.stringify` with direct file writes - always use `safeWriteJson`
7-
- `safeWriteJson` handles directory creation, atomic writes, and locking automatically
8-
9-
## Provider Implementation
10-
11-
- All new providers MUST implement the Provider interface from `packages/types/src/`
12-
- Provider implementations go in `src/api/providers/`
13-
- Each provider needs proper error handling and retry mechanisms
14-
15-
## UI Component Guidelines
16-
17-
- Use Tailwind CSS classes exclusively - no inline styles
5+
- **MANDATORY**: Use `safeWriteJson()` from `src/utils/safeWriteJson.ts` for ALL JSON writes (prevents corruption via atomic writes with locking)
6+
- Tests MUST run from workspace directory: `cd src && npx vitest run` (NOT from root)
187
- VSCode CSS variables must be added to `webview-ui/src/index.css` before use
19-
- React components use functional components with hooks
20-
- State management via React hooks, not external state libraries
21-
22-
## Testing Requirements
23-
24-
- All new features require test coverage
25-
- Tests use vitest framework (vi, describe, test, it are global)
26-
- Run tests from workspace directory: `cd src && npx vitest run`
27-
- Never run tests from project root
28-
29-
## IPC Communication
30-
31-
- Use packages/ipc for webview ↔ extension communication
32-
- Messages must be typed using interfaces from packages/types
33-
- Handle all async operations with proper error boundaries
34-
35-
## File Restrictions
36-
37-
- Code mode can edit all file types
38-
- Always verify file exists before operations
39-
- Use proper file locking for concurrent access safety
8+
- State management via React hooks only (external state libraries break webview isolation)
9+
- Providers MUST be stateless (hidden caching layer assumes this)
10+
- Import paths in packages/ require `.js` extensions despite TypeScript source

.roo/rules-debug/AGENTS.md

Lines changed: 8 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,13 @@
11
# Debug Mode Rules
22

3-
## Debugging Entry Points
3+
## Non-Obvious Debug Access
44

5-
- VSCode Debug Console shows extension logs via `outputChannel`
6-
- Webview DevTools accessible via Command Palette → "Developer: Open Webview Developer Tools"
7-
- Extension host debugging: Press F5 to launch new VSCode window with extension loaded
5+
- Webview DevTools: Command Palette → "Developer: Open Webview Developer Tools" (NOT F12)
6+
- Extension logs: VSCode Output panel → "Roo Code" channel
7+
- Extension Host output channel shows different logs than Debug Console
88

9-
## Common Debug Patterns
9+
## Critical Debug Patterns
1010

11-
- Provider issues: Check `src/api/providers/__tests__/` for test patterns
12-
- IPC communication: Review `packages/ipc/src/` for message flow
13-
- Webview state issues: Check React DevTools in webview developer tools
14-
- Extension activation: Review `src/extension.ts` and `src/activate/`
15-
16-
## Log Locations
17-
18-
- Extension logs: VSCode Output panel → "Roo Code"
19-
- Terminal command logs: Check TerminalRegistry in `src/integrations/terminal/`
20-
- MCP server logs: Check McpServerManager output
21-
- Cloud service logs: Check CloudService initialization in extension.ts
22-
23-
## Testing Debug Workflow
24-
25-
1. Add console.log or debugger statements
26-
2. Run tests with: `cd src && npx vitest run --reporter=verbose`
27-
3. For UI tests: `cd webview-ui && npx vitest run --reporter=verbose`
28-
4. Use VSCode's built-in debugger for stepping through code
29-
30-
## Performance Debugging
31-
32-
- Memory issues: Check for proper cleanup in `deactivate()` function
33-
- Slow operations: Profile with Chrome DevTools for webview
34-
- Extension performance: Use VSCode's Extension Host profiler
35-
36-
## Error Handling
37-
38-
- All async operations should have try-catch blocks
39-
- Errors should be logged to outputChannel
40-
- Critical errors should provide user-friendly messages via vscode.window.showErrorMessage
11+
- IPC messages fail silently without try/catch in `packages/ipc/src/`
12+
- Tests MUST run from workspace directory: `cd src && npx vitest run`
13+
- Webview runs in restricted context (no localStorage, limited browser APIs)

AGENTS.md

Lines changed: 17 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -2,64 +2,20 @@
22

33
This file provides guidance to agents when working with code in this repository.
44

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

Comments
 (0)