|
| 1 | +import { Command } from "./commands" |
| 2 | + |
| 3 | +interface BuiltInCommandDefinition { |
| 4 | + name: string |
| 5 | + description: string |
| 6 | + argumentHint?: string |
| 7 | + content: string |
| 8 | +} |
| 9 | + |
| 10 | +const BUILT_IN_COMMANDS: Record<string, BuiltInCommandDefinition> = { |
| 11 | + init: { |
| 12 | + name: "init", |
| 13 | + description: "Initialize a project with recommended rules and configuration", |
| 14 | + content: `Please analyze this codebase and create an AGENTS.md file containing: |
| 15 | +1. Build/lint/test commands - especially for running a single test |
| 16 | +2. Code style guidelines including imports, formatting, types, naming conventions, error handling, etc. |
| 17 | +
|
| 18 | +Usage notes: |
| 19 | +- The file you create will be given to agentic coding agents (such as yourself) that operate in this repository. Make it about 20 lines long. |
| 20 | +- If there's already an AGENTS.md, improve it. |
| 21 | +- If there are Claude Code rules (in CLAUDE.md), Cursor rules (in .cursor/rules/ or .cursorrules), or Copilot rules (in .github/copilot-instructions.md), make sure to include them. |
| 22 | +- Be sure to prefix the file with the following text: |
| 23 | +
|
| 24 | +# AGENTS.md |
| 25 | +
|
| 26 | +This file provides guidance to agents when working with code in this repository. |
| 27 | +
|
| 28 | +Additionally, please: |
| 29 | +1. **Create mode-specific rule directories** - Create directory structures for the four core modes: \`.roo/rules-code/\`, \`.roo/rules-ask/\`, \`.roo/rules-architect/\`, and \`.roo/rules-debug/\` |
| 30 | +2. **Create mode-specific AGENTS.md files** - Within each of these four mode directories, research and then create an AGENTS.md file with rules specific to that mode's purpose and capabilities. These rules should provide additive context and not just repeat the mode definitions. Only include rules that you have high confidence are accurate, valuable, and non-obvious. |
| 31 | +
|
| 32 | +**For the complete list of available modes with detailed descriptions, refer to the system prompt.** The system prompt contains comprehensive information about each mode's purpose, when to use it, and its specific capabilities. |
| 33 | +
|
| 34 | +Example structure with specific instructions: |
| 35 | +
|
| 36 | +\\\`\\\`\\\` |
| 37 | +AGENTS.md # General project guidance |
| 38 | +.roo/ |
| 39 | +├── rules-code/ |
| 40 | +│ └── AGENTS.md # Code mode specific instructions |
| 41 | +├── rules-debug/ |
| 42 | +│ └── AGENTS.md # Debug mode specific instructions |
| 43 | +├── rules-ask/ |
| 44 | +│ └── AGENTS.md # Ask mode specific instructions |
| 45 | +└── rules-architect/ |
| 46 | + └── AGENTS.md # Architect mode specific instructions |
| 47 | +\\\`\\\`\\\` |
| 48 | +
|
| 49 | +**Example project-specific instructions:** |
| 50 | +
|
| 51 | +**\`.roo/rules-code/AGENTS.md\`** - Project-specific coding rules: |
| 52 | +\\\`\\\`\\\` |
| 53 | +# Project Coding Rules |
| 54 | +
|
| 55 | +- All API calls must use the retry mechanism in src/api/providers/utils/ |
| 56 | +- UI components should use Tailwind CSS classes, not inline styles |
| 57 | +- New providers must implement the Provider interface in packages/types/src/ |
| 58 | +- Database queries must use the query builder in packages/evals/src/db/queries/ |
| 59 | +- Always use safeWriteJson() from src/utils/ instead of JSON.stringify for file writes |
| 60 | +- Test coverage required for all new features in src/ and webview-ui/ |
| 61 | +\\\`\\\`\\\` |
| 62 | +
|
| 63 | +**\`.roo/rules-debug/AGENTS.md\`** - Project-specific debugging approaches: |
| 64 | +\\\`\\\`\\\` |
| 65 | +# Project Debug Rules |
| 66 | +
|
| 67 | +- Check VSCode extension logs in the Debug Console |
| 68 | +- For webview issues, inspect the webview dev tools via Command Palette |
| 69 | +- Provider issues: check src/api/providers/__tests__/ for similar test patterns |
| 70 | +- Database issues: run migrations in packages/evals/src/db/migrations/ |
| 71 | +- IPC communication issues: review packages/ipc/src/ message patterns |
| 72 | +- Always reproduce in both development and production extension builds |
| 73 | +\\\`\\\`\\\` |
| 74 | +
|
| 75 | +**\`.roo/rules-ask/AGENTS.md\`** - Project-specific explanation context: |
| 76 | +\\\`\\\`\\\` |
| 77 | +# Project Documentation Rules |
| 78 | +
|
| 79 | +- Reference the monorepo structure: src/ (VSCode extension), apps/ (web apps), packages/ (shared) |
| 80 | +- Explain provider patterns by referencing existing ones in src/api/providers/ |
| 81 | +- For UI questions, reference webview-ui/ React components and their patterns |
| 82 | +- Point to package.json scripts for build/test commands |
| 83 | +- Reference locales/ for i18n patterns when discussing translations |
| 84 | +- Always mention the VSCode webview architecture when discussing UI |
| 85 | +\\\`\\\`\\\` |
| 86 | +
|
| 87 | +**\`.roo/rules-architect/AGENTS.md\`** - Project-specific architectural considerations: |
| 88 | +\\\`\\\`\\\` |
| 89 | +# Project Architecture Rules |
| 90 | +
|
| 91 | +- New features must work within VSCode extension + webview architecture |
| 92 | +- Provider implementations must be stateless and cacheable |
| 93 | +- UI state management uses React hooks, not external state libraries |
| 94 | +- Database schema changes require migrations in packages/evals/src/db/migrations/ |
| 95 | +- New packages must follow the existing monorepo structure in packages/ |
| 96 | +- API changes must maintain backward compatibility with existing provider contracts |
| 97 | +\\\`\\\`\\\` |
| 98 | +
|
| 99 | +This structure provides both general project guidance and specialized instructions for the four core modes' specific domains and workflows. |
| 100 | +`, |
| 101 | + }, |
| 102 | +} |
| 103 | + |
| 104 | +/** |
| 105 | + * Get all built-in commands as Command objects |
| 106 | + */ |
| 107 | +export async function getBuiltInCommands(): Promise<Command[]> { |
| 108 | + return Object.values(BUILT_IN_COMMANDS).map((cmd) => ({ |
| 109 | + name: cmd.name, |
| 110 | + content: cmd.content, |
| 111 | + source: "built-in" as const, |
| 112 | + filePath: `<built-in:${cmd.name}>`, |
| 113 | + description: cmd.description, |
| 114 | + argumentHint: cmd.argumentHint, |
| 115 | + })) |
| 116 | +} |
| 117 | + |
| 118 | +/** |
| 119 | + * Get a specific built-in command by name |
| 120 | + */ |
| 121 | +export async function getBuiltInCommand(name: string): Promise<Command | undefined> { |
| 122 | + const cmd = BUILT_IN_COMMANDS[name] |
| 123 | + if (!cmd) return undefined |
| 124 | + |
| 125 | + return { |
| 126 | + name: cmd.name, |
| 127 | + content: cmd.content, |
| 128 | + source: "built-in" as const, |
| 129 | + filePath: `<built-in:${name}>`, |
| 130 | + description: cmd.description, |
| 131 | + argumentHint: cmd.argumentHint, |
| 132 | + } |
| 133 | +} |
| 134 | + |
| 135 | +/** |
| 136 | + * Get names of all built-in commands |
| 137 | + */ |
| 138 | +export async function getBuiltInCommandNames(): Promise<string[]> { |
| 139 | + return Object.keys(BUILT_IN_COMMANDS) |
| 140 | +} |
0 commit comments