mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-08-28 05:27:24 +00:00
Add a built-in /init slash command (#7381)
Co-authored-by: Hannes Rudolph <hrudolph@gmail.com>
This commit is contained in:
parent
c7d2b72cab
commit
2c82f4c950
28 changed files with 486 additions and 53 deletions
|
|
@ -15,7 +15,7 @@ describe("Command Integration Tests", () => {
|
|||
commands.forEach((command) => {
|
||||
expect(command.name).toBeDefined()
|
||||
expect(typeof command.name).toBe("string")
|
||||
expect(command.source).toMatch(/^(project|global)$/)
|
||||
expect(command.source).toMatch(/^(project|global|built-in)$/)
|
||||
expect(command.content).toBeDefined()
|
||||
expect(typeof command.content).toBe("string")
|
||||
})
|
||||
|
|
@ -43,7 +43,7 @@ describe("Command Integration Tests", () => {
|
|||
|
||||
expect(loadedCommand).toBeDefined()
|
||||
expect(loadedCommand?.name).toBe(firstCommand.name)
|
||||
expect(loadedCommand?.source).toMatch(/^(project|global)$/)
|
||||
expect(loadedCommand?.source).toMatch(/^(project|global|built-in)$/)
|
||||
expect(loadedCommand?.content).toBeDefined()
|
||||
expect(typeof loadedCommand?.content).toBe("string")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2619,6 +2619,7 @@ export const webviewMessageHandler = async (
|
|||
source: command.source,
|
||||
filePath: command.filePath,
|
||||
description: command.description,
|
||||
argumentHint: command.argumentHint,
|
||||
}))
|
||||
await provider.postMessageToWebview({
|
||||
type: "commands",
|
||||
|
|
|
|||
104
src/services/command/__tests__/built-in-commands.spec.ts
Normal file
104
src/services/command/__tests__/built-in-commands.spec.ts
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
import { describe, it, expect } from "vitest"
|
||||
import { getBuiltInCommands, getBuiltInCommand, getBuiltInCommandNames } from "../built-in-commands"
|
||||
|
||||
describe("Built-in Commands", () => {
|
||||
describe("getBuiltInCommands", () => {
|
||||
it("should return all built-in commands", async () => {
|
||||
const commands = await getBuiltInCommands()
|
||||
|
||||
expect(commands).toHaveLength(1)
|
||||
expect(commands.map((cmd) => cmd.name)).toEqual(expect.arrayContaining(["init"]))
|
||||
|
||||
// Verify all commands have required properties
|
||||
commands.forEach((command) => {
|
||||
expect(command.name).toBeDefined()
|
||||
expect(typeof command.name).toBe("string")
|
||||
expect(command.content).toBeDefined()
|
||||
expect(typeof command.content).toBe("string")
|
||||
expect(command.source).toBe("built-in")
|
||||
expect(command.filePath).toMatch(/^<built-in:.+>$/)
|
||||
expect(command.description).toBeDefined()
|
||||
expect(typeof command.description).toBe("string")
|
||||
})
|
||||
})
|
||||
|
||||
it("should return commands with proper content", async () => {
|
||||
const commands = await getBuiltInCommands()
|
||||
|
||||
const initCommand = commands.find((cmd) => cmd.name === "init")
|
||||
expect(initCommand).toBeDefined()
|
||||
expect(initCommand!.content).toContain("AGENTS.md")
|
||||
expect(initCommand!.content).toContain(".roo/rules-")
|
||||
expect(initCommand!.description).toBe(
|
||||
"Analyze codebase and create concise AGENTS.md files for AI assistants",
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe("getBuiltInCommand", () => {
|
||||
it("should return specific built-in command by name", async () => {
|
||||
const initCommand = await getBuiltInCommand("init")
|
||||
|
||||
expect(initCommand).toBeDefined()
|
||||
expect(initCommand!.name).toBe("init")
|
||||
expect(initCommand!.source).toBe("built-in")
|
||||
expect(initCommand!.filePath).toBe("<built-in:init>")
|
||||
expect(initCommand!.content).toContain("AGENTS.md")
|
||||
expect(initCommand!.description).toBe(
|
||||
"Analyze codebase and create concise AGENTS.md files for AI assistants",
|
||||
)
|
||||
})
|
||||
|
||||
it("should return undefined for non-existent command", async () => {
|
||||
const nonExistentCommand = await getBuiltInCommand("non-existent")
|
||||
expect(nonExistentCommand).toBeUndefined()
|
||||
})
|
||||
|
||||
it("should handle empty string command name", async () => {
|
||||
const emptyCommand = await getBuiltInCommand("")
|
||||
expect(emptyCommand).toBeUndefined()
|
||||
})
|
||||
})
|
||||
|
||||
describe("getBuiltInCommandNames", () => {
|
||||
it("should return all built-in command names", async () => {
|
||||
const names = await getBuiltInCommandNames()
|
||||
|
||||
expect(names).toHaveLength(1)
|
||||
expect(names).toEqual(expect.arrayContaining(["init"]))
|
||||
// Order doesn't matter since it's based on filesystem order
|
||||
expect(names.sort()).toEqual(["init"])
|
||||
})
|
||||
|
||||
it("should return array of strings", async () => {
|
||||
const names = await getBuiltInCommandNames()
|
||||
|
||||
names.forEach((name) => {
|
||||
expect(typeof name).toBe("string")
|
||||
expect(name.length).toBeGreaterThan(0)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe("Command Content Validation", () => {
|
||||
it("init command should have comprehensive content", async () => {
|
||||
const command = await getBuiltInCommand("init")
|
||||
const content = command!.content
|
||||
|
||||
// Should contain key sections
|
||||
expect(content).toContain("Please analyze this codebase")
|
||||
expect(content).toContain("Build/lint/test commands")
|
||||
expect(content).toContain("Code style guidelines")
|
||||
expect(content).toContain("mode-specific rule directories")
|
||||
expect(content).toContain("analysis_workflow")
|
||||
|
||||
// Should mention important concepts
|
||||
expect(content).toContain("AGENTS.md")
|
||||
expect(content).toContain(".roo/rules-")
|
||||
expect(content).toContain("rules-code")
|
||||
expect(content).toContain("rules-debug")
|
||||
expect(content).toContain("rules-ask")
|
||||
expect(content).toContain("rules-architect")
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
@ -9,6 +9,11 @@ vi.mock("../roo-config", () => ({
|
|||
getGlobalRooDirectory: vi.fn(() => "/mock/global/.roo"),
|
||||
getProjectRooDirectoryForCwd: vi.fn(() => "/mock/project/.roo"),
|
||||
}))
|
||||
vi.mock("../built-in-commands", () => ({
|
||||
getBuiltInCommands: vi.fn(() => Promise.resolve([])),
|
||||
getBuiltInCommand: vi.fn(() => Promise.resolve(undefined)),
|
||||
getBuiltInCommandNames: vi.fn(() => Promise.resolve([])),
|
||||
}))
|
||||
|
||||
const mockFs = vi.mocked(fs)
|
||||
|
||||
|
|
|
|||
260
src/services/command/built-in-commands.ts
Normal file
260
src/services/command/built-in-commands.ts
Normal file
|
|
@ -0,0 +1,260 @@
|
|||
import { Command } from "./commands"
|
||||
|
||||
interface BuiltInCommandDefinition {
|
||||
name: string
|
||||
description: string
|
||||
argumentHint?: string
|
||||
content: string
|
||||
}
|
||||
|
||||
const BUILT_IN_COMMANDS: Record<string, BuiltInCommandDefinition> = {
|
||||
init: {
|
||||
name: "init",
|
||||
description: "Analyze codebase and create concise AGENTS.md files for AI assistants",
|
||||
content: `<task>
|
||||
Please analyze this codebase and create an AGENTS.md file containing:
|
||||
1. Build/lint/test commands - especially for running a single test
|
||||
2. Code style guidelines including imports, formatting, types, naming conventions, error handling, etc.
|
||||
</task>
|
||||
|
||||
<initialization>
|
||||
<purpose>
|
||||
Create (or update) a concise AGENTS.md file that enables immediate productivity for AI assistants.
|
||||
Focus on project-specific, non-obvious information. Prioritize brevity and scannability.
|
||||
|
||||
Usage notes:
|
||||
- The file you create will be given to agentic coding agents (such as yourself) that operate in this repository
|
||||
- Keep the main AGENTS.md concise - aim for about 20 lines, but use more if the project complexity requires it
|
||||
- If there's already an AGENTS.md, improve it
|
||||
- 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
|
||||
- Be sure to prefix the file with: "# AGENTS.md\\n\\nThis file provides guidance to agents when working with code in this repository."
|
||||
</purpose>
|
||||
|
||||
<todo_list_creation>
|
||||
If the update_todo_list tool is available, create a todo list with these focused analysis steps:
|
||||
|
||||
1. Quick scan for existing docs
|
||||
- AI assistant rules (.cursorrules, CLAUDE.md, AGENTS.md, .roorules)
|
||||
- README and key documentation
|
||||
|
||||
2. Identify stack
|
||||
- Language, framework, build tools
|
||||
- Package manager and dependencies
|
||||
|
||||
3. Extract commands
|
||||
- Build, test, lint, run
|
||||
- Critical directory-specific commands
|
||||
|
||||
4. Map core architecture
|
||||
- Main components and flow
|
||||
- Key entry points
|
||||
|
||||
5. Document critical patterns
|
||||
- Project-specific utilities
|
||||
- Non-standard approaches
|
||||
|
||||
6. Extract code style
|
||||
- From config files only
|
||||
- Key conventions
|
||||
|
||||
7. Testing specifics
|
||||
- Framework and run commands
|
||||
- Directory requirements
|
||||
|
||||
8. Compile concise AGENTS.md
|
||||
- Essential sections only
|
||||
- Brief, scannable format
|
||||
- Project-specific focus
|
||||
|
||||
9. Create mode-specific rule directories
|
||||
- Create directory structures for the four core modes: .roo/rules-code/, .roo/rules-ask/, .roo/rules-architect/, .roo/rules-debug/
|
||||
- Create mode-specific AGENTS.md files 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
|
||||
|
||||
Note: If update_todo_list is not available, proceed with the analysis workflow directly without creating a todo list.
|
||||
</todo_list_creation>
|
||||
</initialization>
|
||||
|
||||
<analysis_workflow>
|
||||
Follow the comprehensive analysis workflow to:
|
||||
|
||||
1. **Discovery Phase**: Find existing documentation and AI assistant rules
|
||||
2. **Project Identification**: Identify language, stack, and build system
|
||||
3. **Command Extraction**: Extract and verify essential commands
|
||||
4. **Architecture Mapping**: Create visual flow diagrams of core processes
|
||||
5. **Component Analysis**: Document key components and their interactions
|
||||
6. **Pattern Analysis**: Identify project-specific patterns and conventions
|
||||
7. **Code Style Extraction**: Extract formatting and naming conventions
|
||||
8. **Security & Performance**: Document critical patterns if relevant
|
||||
9. **Testing Discovery**: Understand testing setup and practices
|
||||
10. **Example Extraction**: Find real examples from the codebase
|
||||
</analysis_workflow>
|
||||
|
||||
<output_structure>
|
||||
<main_file>
|
||||
Create AGENTS.md with:
|
||||
- Header: "# AGENTS.md\\n\\nThis file provides guidance to agents when working with code in this repository."
|
||||
- Project overview (brief description, core functionality, key technologies)
|
||||
- Build/lint/test commands - especially for running a single test
|
||||
- Code style guidelines including imports, formatting, types, naming conventions, error handling, etc.
|
||||
- Architecture overview (visual flow diagrams using ASCII/markdown)
|
||||
- Development guides (step-by-step for common tasks)
|
||||
- Project-specific patterns (custom utilities, non-standard approaches)
|
||||
- Testing guidelines (how to write and run tests)
|
||||
- Critical rules (must-follow requirements)
|
||||
|
||||
Keep it concise (aim for ~20 lines, but expand as needed for complex projects) and focused on essential, project-specific information.
|
||||
Include existing AI assistant rules from CLAUDE.md, Cursor rules (.cursor/rules/ or .cursorrules), or Copilot rules (.github/copilot-instructions.md).
|
||||
</main_file>
|
||||
|
||||
<mode_specific_files>
|
||||
Additionally, create mode-specific rule directories and AGENTS.md files.
|
||||
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.
|
||||
|
||||
Example structure:
|
||||
\`\`\`
|
||||
AGENTS.md # General project guidance
|
||||
.roo/
|
||||
├── rules-code/
|
||||
│ └── AGENTS.md # Code mode specific instructions
|
||||
├── rules-debug/
|
||||
│ └── AGENTS.md # Debug mode specific instructions
|
||||
├── rules-ask/
|
||||
│ └── AGENTS.md # Ask mode specific instructions
|
||||
└── rules-architect/
|
||||
└── AGENTS.md # Architect mode specific instructions
|
||||
\`\`\`
|
||||
|
||||
Create mode-specific AGENTS.md files in:
|
||||
|
||||
.roo/rules-code/AGENTS.md - Project-specific coding rules:
|
||||
- Custom utilities that must be used
|
||||
- API patterns and retry mechanisms
|
||||
- UI component guidelines
|
||||
- Database query patterns
|
||||
- Provider implementation requirements
|
||||
- Test coverage requirements
|
||||
|
||||
Example of actual rules to document:
|
||||
\`\`\`
|
||||
# Project Coding Rules
|
||||
- All API calls must use the retry mechanism in src/api/providers/utils/
|
||||
- UI components should use Tailwind CSS classes, not inline styles
|
||||
- New providers must implement the Provider interface in packages/types/src/
|
||||
- Database queries must use the query builder in packages/evals/src/db/queries/
|
||||
- Always use safeWriteJson() from src/utils/ instead of JSON.stringify for file writes
|
||||
- Test coverage required for all new features in src/ and webview-ui/
|
||||
\`\`\`
|
||||
|
||||
.roo/rules-debug/AGENTS.md - Project-specific debugging approaches:
|
||||
- Where to find logs and debug output
|
||||
- Common debugging tools and commands
|
||||
- Test patterns for reproducing issues
|
||||
- Database and migration debugging
|
||||
- IPC and communication debugging
|
||||
- Build-specific debugging tips
|
||||
|
||||
Example of actual rules to document:
|
||||
\`\`\`
|
||||
# Project Debug Rules
|
||||
- Check VSCode extension logs in the Debug Console
|
||||
- For webview issues, inspect the webview dev tools via Command Palette
|
||||
- Provider issues: check src/api/providers/__tests__/ for similar test patterns
|
||||
- Database issues: run migrations in packages/evals/src/db/migrations/
|
||||
- IPC communication issues: review packages/ipc/src/ message patterns
|
||||
- Always reproduce in both development and production extension builds
|
||||
\`\`\`
|
||||
|
||||
.roo/rules-ask/AGENTS.md - Project documentation context:
|
||||
- Repository structure explanation
|
||||
- Where to find examples and patterns
|
||||
- Key documentation locations
|
||||
- Build and test command references
|
||||
- Localization and i18n patterns
|
||||
- Architecture-specific explanations
|
||||
|
||||
Example of actual rules to document:
|
||||
\`\`\`
|
||||
# Project Documentation Rules
|
||||
- Reference the monorepo structure: src/ (VSCode extension), apps/ (web apps), packages/ (shared)
|
||||
- Explain provider patterns by referencing existing ones in src/api/providers/
|
||||
- For UI questions, reference webview-ui/ React components and their patterns
|
||||
- Point to package.json scripts for build/test commands
|
||||
- Reference locales/ for i18n patterns when discussing translations
|
||||
- Always mention the VSCode webview architecture when discussing UI
|
||||
\`\`\`
|
||||
|
||||
.roo/rules-architect/AGENTS.md - Project architectural considerations:
|
||||
- Extension and plugin architecture
|
||||
- State management patterns
|
||||
- Database schema requirements
|
||||
- Package organization rules
|
||||
- API compatibility requirements
|
||||
- Performance and scaling considerations
|
||||
|
||||
Example of actual rules to document:
|
||||
\`\`\`
|
||||
# Project Architecture Rules
|
||||
- New features must work within VSCode extension + webview architecture
|
||||
- Provider implementations must be stateless and cacheable
|
||||
- UI state management uses React hooks, not external state libraries
|
||||
- Database schema changes require migrations in packages/evals/src/db/migrations/
|
||||
- New packages must follow the existing monorepo structure in packages/
|
||||
- API changes must maintain backward compatibility with existing provider contracts
|
||||
\`\`\`
|
||||
</mode_specific_files>
|
||||
</output_structure>
|
||||
|
||||
<quality_criteria>
|
||||
- Include visual flow diagrams (ASCII/markdown) for architecture
|
||||
- Provide actionable, step-by-step guides
|
||||
- Focus on non-obvious, project-specific information
|
||||
- Include real code examples from the project
|
||||
- Be concise and scannable
|
||||
- Adapt to the specific project needs
|
||||
- Document only what's essential for productivity
|
||||
</quality_criteria>
|
||||
|
||||
Remember: The goal is to create documentation that enables AI assistants to be immediately productive in this codebase, focusing on project-specific knowledge that isn't obvious from the code structure alone.`,
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all built-in commands as Command objects
|
||||
*/
|
||||
export async function getBuiltInCommands(): Promise<Command[]> {
|
||||
return Object.values(BUILT_IN_COMMANDS).map((cmd) => ({
|
||||
name: cmd.name,
|
||||
content: cmd.content,
|
||||
source: "built-in" as const,
|
||||
filePath: `<built-in:${cmd.name}>`,
|
||||
description: cmd.description,
|
||||
argumentHint: cmd.argumentHint,
|
||||
}))
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a specific built-in command by name
|
||||
*/
|
||||
export async function getBuiltInCommand(name: string): Promise<Command | undefined> {
|
||||
const cmd = BUILT_IN_COMMANDS[name]
|
||||
if (!cmd) return undefined
|
||||
|
||||
return {
|
||||
name: cmd.name,
|
||||
content: cmd.content,
|
||||
source: "built-in" as const,
|
||||
filePath: `<built-in:${name}>`,
|
||||
description: cmd.description,
|
||||
argumentHint: cmd.argumentHint,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get names of all built-in commands
|
||||
*/
|
||||
export async function getBuiltInCommandNames(): Promise<string[]> {
|
||||
return Object.keys(BUILT_IN_COMMANDS)
|
||||
}
|
||||
|
|
@ -2,27 +2,35 @@ import fs from "fs/promises"
|
|||
import * as path from "path"
|
||||
import matter from "gray-matter"
|
||||
import { getGlobalRooDirectory, getProjectRooDirectoryForCwd } from "../roo-config"
|
||||
import { getBuiltInCommands, getBuiltInCommand } from "./built-in-commands"
|
||||
|
||||
export interface Command {
|
||||
name: string
|
||||
content: string
|
||||
source: "global" | "project"
|
||||
source: "global" | "project" | "built-in"
|
||||
filePath: string
|
||||
description?: string
|
||||
argumentHint?: string
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all available commands from both global and project directories
|
||||
* Get all available commands from built-in, global, and project directories
|
||||
* Priority order: project > global > built-in (later sources override earlier ones)
|
||||
*/
|
||||
export async function getCommands(cwd: string): Promise<Command[]> {
|
||||
const commands = new Map<string, Command>()
|
||||
|
||||
// Scan global commands first
|
||||
// Add built-in commands first (lowest priority)
|
||||
const builtInCommands = await getBuiltInCommands()
|
||||
for (const command of builtInCommands) {
|
||||
commands.set(command.name, command)
|
||||
}
|
||||
|
||||
// Scan global commands (override built-in)
|
||||
const globalDir = path.join(getGlobalRooDirectory(), "commands")
|
||||
await scanCommandDirectory(globalDir, "global", commands)
|
||||
|
||||
// Scan project commands (these override global ones)
|
||||
// Scan project commands (highest priority - override both global and built-in)
|
||||
const projectDir = path.join(getProjectRooDirectoryForCwd(cwd), "commands")
|
||||
await scanCommandDirectory(projectDir, "project", commands)
|
||||
|
||||
|
|
@ -31,13 +39,14 @@ export async function getCommands(cwd: string): Promise<Command[]> {
|
|||
|
||||
/**
|
||||
* Get a specific command by name (optimized to avoid scanning all commands)
|
||||
* Priority order: project > global > built-in
|
||||
*/
|
||||
export async function getCommand(cwd: string, name: string): Promise<Command | undefined> {
|
||||
// Try to find the command directly without scanning all commands
|
||||
const projectDir = path.join(getProjectRooDirectoryForCwd(cwd), "commands")
|
||||
const globalDir = path.join(getGlobalRooDirectory(), "commands")
|
||||
|
||||
// Check project directory first (project commands override global ones)
|
||||
// Check project directory first (highest priority)
|
||||
const projectCommand = await tryLoadCommand(projectDir, name, "project")
|
||||
if (projectCommand) {
|
||||
return projectCommand
|
||||
|
|
@ -45,7 +54,12 @@ export async function getCommand(cwd: string, name: string): Promise<Command | u
|
|||
|
||||
// Check global directory if not found in project
|
||||
const globalCommand = await tryLoadCommand(globalDir, name, "global")
|
||||
return globalCommand
|
||||
if (globalCommand) {
|
||||
return globalCommand
|
||||
}
|
||||
|
||||
// Check built-in commands if not found in project or global (lowest priority)
|
||||
return await getBuiltInCommand(name)
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ import { ModelRecord, RouterModels } from "./api"
|
|||
// Command interface for frontend/backend communication
|
||||
export interface Command {
|
||||
name: string
|
||||
source: "global" | "project"
|
||||
source: "global" | "project" | "built-in"
|
||||
filePath?: string
|
||||
description?: string
|
||||
argumentHint?: string
|
||||
|
|
|
|||
|
|
@ -16,6 +16,9 @@ interface SlashCommandItemProps {
|
|||
export const SlashCommandItem: React.FC<SlashCommandItemProps> = ({ command, onDelete, onClick }) => {
|
||||
const { t } = useAppTranslation()
|
||||
|
||||
// Built-in commands cannot be edited or deleted
|
||||
const isBuiltIn = command.source === "built-in"
|
||||
|
||||
const handleEdit = () => {
|
||||
if (command.filePath) {
|
||||
vscode.postMessage({
|
||||
|
|
@ -40,33 +43,42 @@ export const SlashCommandItem: React.FC<SlashCommandItemProps> = ({ command, onD
|
|||
<div className="px-4 py-2 text-sm flex items-center group hover:bg-vscode-list-hoverBackground">
|
||||
{/* Command name - clickable */}
|
||||
<div className="flex-1 min-w-0 cursor-pointer" onClick={() => onClick?.(command)}>
|
||||
<span className="truncate text-vscode-foreground">{command.name}</span>
|
||||
<div>
|
||||
<span className="truncate text-vscode-foreground">{command.name}</span>
|
||||
{command.description && (
|
||||
<div className="text-xs text-vscode-descriptionForeground truncate mt-0.5">
|
||||
{command.description}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Action buttons */}
|
||||
<div className="flex items-center gap-2 ml-2">
|
||||
<StandardTooltip content={t("chat:slashCommands.editCommand")}>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
tabIndex={-1}
|
||||
onClick={handleEdit}
|
||||
className="size-6 flex items-center justify-center opacity-60 hover:opacity-100">
|
||||
<Edit className="w-4 h-4" />
|
||||
</Button>
|
||||
</StandardTooltip>
|
||||
{/* Action buttons - only show for non-built-in commands */}
|
||||
{!isBuiltIn && (
|
||||
<div className="flex items-center gap-2 ml-2">
|
||||
<StandardTooltip content={t("chat:slashCommands.editCommand")}>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
tabIndex={-1}
|
||||
onClick={handleEdit}
|
||||
className="size-6 flex items-center justify-center opacity-60 hover:opacity-100">
|
||||
<Edit className="w-4 h-4" />
|
||||
</Button>
|
||||
</StandardTooltip>
|
||||
|
||||
<StandardTooltip content={t("chat:slashCommands.deleteCommand")}>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
tabIndex={-1}
|
||||
onClick={handleDelete}
|
||||
className="size-6 flex items-center justify-center opacity-60 hover:opacity-100 hover:text-red-400">
|
||||
<Trash2 className="w-4 h-4" />
|
||||
</Button>
|
||||
</StandardTooltip>
|
||||
</div>
|
||||
<StandardTooltip content={t("chat:slashCommands.deleteCommand")}>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
tabIndex={-1}
|
||||
onClick={handleDelete}
|
||||
className="size-6 flex items-center justify-center opacity-60 hover:opacity-100 hover:text-red-400">
|
||||
<Trash2 className="w-4 h-4" />
|
||||
</Button>
|
||||
</StandardTooltip>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import React, { useState } from "react"
|
||||
import { Plus, Globe, Folder } from "lucide-react"
|
||||
import { Plus, Globe, Folder, Settings } from "lucide-react"
|
||||
|
||||
import type { Command } from "@roo/ExtensionMessage"
|
||||
|
||||
|
|
@ -90,6 +90,7 @@ export const SlashCommandsList: React.FC<SlashCommandsListProps> = ({ commands,
|
|||
}
|
||||
|
||||
// Group commands by source
|
||||
const builtInCommands = commands.filter((cmd) => cmd.source === "built-in")
|
||||
const globalCommands = commands.filter((cmd) => cmd.source === "global")
|
||||
const projectCommands = commands.filter((cmd) => cmd.source === "project")
|
||||
|
||||
|
|
@ -177,6 +178,24 @@ export const SlashCommandsList: React.FC<SlashCommandsListProps> = ({ commands,
|
|||
</div>
|
||||
</>
|
||||
)}
|
||||
|
||||
{/* Built-in Commands Section */}
|
||||
{builtInCommands.length > 0 && (
|
||||
<>
|
||||
<div className="px-3 py-1.5 text-xs font-medium text-vscode-descriptionForeground flex items-center gap-1.5 mt-4">
|
||||
<Settings className="w-3 h-3" />
|
||||
{t("chat:slashCommands.builtInCommands")}
|
||||
</div>
|
||||
{builtInCommands.map((command) => (
|
||||
<SlashCommandItem
|
||||
key={`built-in-${command.name}`}
|
||||
command={command}
|
||||
onDelete={handleDeleteClick}
|
||||
onClick={handleCommandClick}
|
||||
/>
|
||||
))}
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
3
webview-ui/src/i18n/locales/ca/chat.json
generated
3
webview-ui/src/i18n/locales/ca/chat.json
generated
|
|
@ -368,7 +368,8 @@
|
|||
"slashCommands": {
|
||||
"tooltip": "Gestionar ordres de barra",
|
||||
"title": "Ordres de Barra",
|
||||
"description": "Crea ordres de barra personalitzades per accedir ràpidament a indicacions i fluxos de treball utilitzats amb freqüència. <DocsLink>Documentació</DocsLink>",
|
||||
"description": "Utilitza ordres de barra integrades o crea personalitzades per accedir ràpidament a indicacions i fluxos de treball utilitzats amb freqüència. <DocsLink>Documentació</DocsLink>",
|
||||
"builtInCommands": "Ordres Integrades",
|
||||
"globalCommands": "Ordres Globals",
|
||||
"workspaceCommands": "Ordres de l'Espai de Treball",
|
||||
"globalCommand": "Ordre global",
|
||||
|
|
|
|||
3
webview-ui/src/i18n/locales/de/chat.json
generated
3
webview-ui/src/i18n/locales/de/chat.json
generated
|
|
@ -368,7 +368,8 @@
|
|||
"slashCommands": {
|
||||
"tooltip": "Slash-Befehle verwalten",
|
||||
"title": "Slash-Befehle",
|
||||
"description": "Erstelle benutzerdefinierte Slash-Befehle für schnellen Zugriff auf häufig verwendete Prompts und Workflows. <DocsLink>Dokumentation</DocsLink>",
|
||||
"description": "Verwende eingebaute Slash-Befehle oder erstelle benutzerdefinierte für schnellen Zugriff auf häufig verwendete Prompts und Workflows. <DocsLink>Dokumentation</DocsLink>",
|
||||
"builtInCommands": "Eingebaute Befehle",
|
||||
"globalCommands": "Globale Befehle",
|
||||
"workspaceCommands": "Arbeitsbereich-Befehle",
|
||||
"globalCommand": "Globaler Befehl",
|
||||
|
|
|
|||
|
|
@ -361,7 +361,8 @@
|
|||
"slashCommands": {
|
||||
"tooltip": "Manage slash commands",
|
||||
"title": "Slash Commands",
|
||||
"description": "Create custom slash commands for quick access to frequently used prompts and workflows. <DocsLink>Docs</DocsLink>",
|
||||
"description": "Use built-in slash commands or create custom ones for quick access to frequently used prompts and workflows. <DocsLink>Docs</DocsLink>",
|
||||
"builtInCommands": "Built-in Commands",
|
||||
"globalCommands": "Global Commands",
|
||||
"workspaceCommands": "Workspace Commands",
|
||||
"globalCommand": "Global command",
|
||||
|
|
|
|||
3
webview-ui/src/i18n/locales/es/chat.json
generated
3
webview-ui/src/i18n/locales/es/chat.json
generated
|
|
@ -368,7 +368,8 @@
|
|||
"slashCommands": {
|
||||
"tooltip": "Gestionar comandos de barra",
|
||||
"title": "Comandos de Barra",
|
||||
"description": "Crea comandos de barra personalizados para acceder rápidamente a prompts y flujos de trabajo utilizados con frecuencia. <DocsLink>Documentación</DocsLink>",
|
||||
"description": "Usa comandos de barra integrados o crea personalizados para acceder rápidamente a prompts y flujos de trabajo utilizados con frecuencia. <DocsLink>Documentación</DocsLink>",
|
||||
"builtInCommands": "Comandos Integrados",
|
||||
"globalCommands": "Comandos Globales",
|
||||
"workspaceCommands": "Comandos del Espacio de Trabajo",
|
||||
"globalCommand": "Comando global",
|
||||
|
|
|
|||
3
webview-ui/src/i18n/locales/fr/chat.json
generated
3
webview-ui/src/i18n/locales/fr/chat.json
generated
|
|
@ -368,7 +368,8 @@
|
|||
"slashCommands": {
|
||||
"tooltip": "Gérer les commandes slash",
|
||||
"title": "Commandes Slash",
|
||||
"description": "Créez des commandes slash personnalisées pour accéder rapidement aux prompts et flux de travail fréquemment utilisés. <DocsLink>Documentation</DocsLink>",
|
||||
"description": "Utilisez les commandes slash intégrées ou créez des personnalisées pour accéder rapidement aux prompts et flux de travail fréquemment utilisés. <DocsLink>Documentation</DocsLink>",
|
||||
"builtInCommands": "Commandes Intégrées",
|
||||
"globalCommands": "Commandes Globales",
|
||||
"workspaceCommands": "Commandes de l'Espace de Travail",
|
||||
"globalCommand": "Commande globale",
|
||||
|
|
|
|||
3
webview-ui/src/i18n/locales/hi/chat.json
generated
3
webview-ui/src/i18n/locales/hi/chat.json
generated
|
|
@ -368,7 +368,8 @@
|
|||
"slashCommands": {
|
||||
"tooltip": "स्लैश कमांड प्रबंधित करें",
|
||||
"title": "स्लैश कमांड",
|
||||
"description": "बार-बार उपयोग किए जाने वाले प्रॉम्प्ट और वर्कफ़्लो तक त्वरित पहुंच के लिए कस्टम स्लैश कमांड बनाएं। <DocsLink>दस्तावेज़</DocsLink>",
|
||||
"description": "बिल्ट-इन स्लैश कमांड का उपयोग करें या बार-बार उपयोग किए जाने वाले प्रॉम्प्ट और वर्कफ़्लो तक त्वरित पहुंच के लिए कस्टम स्लैश कमांड बनाएं। <DocsLink>दस्तावेज़</DocsLink>",
|
||||
"builtInCommands": "बिल्ट-इन कमांड",
|
||||
"globalCommands": "वैश्विक कमांड",
|
||||
"workspaceCommands": "कार्यक्षेत्र कमांड",
|
||||
"globalCommand": "वैश्विक कमांड",
|
||||
|
|
|
|||
3
webview-ui/src/i18n/locales/id/chat.json
generated
3
webview-ui/src/i18n/locales/id/chat.json
generated
|
|
@ -374,7 +374,8 @@
|
|||
"slashCommands": {
|
||||
"tooltip": "Kelola perintah slash",
|
||||
"title": "Perintah Slash",
|
||||
"description": "Buat perintah slash kustom untuk akses cepat ke prompt dan alur kerja yang sering digunakan. <DocsLink>Dokumentasi</DocsLink>",
|
||||
"description": "Gunakan perintah slash bawaan atau buat kustom untuk akses cepat ke prompt dan alur kerja yang sering digunakan. <DocsLink>Dokumentasi</DocsLink>",
|
||||
"builtInCommands": "Perintah Bawaan",
|
||||
"globalCommands": "Perintah Global",
|
||||
"workspaceCommands": "Perintah Workspace",
|
||||
"globalCommand": "Perintah global",
|
||||
|
|
|
|||
3
webview-ui/src/i18n/locales/it/chat.json
generated
3
webview-ui/src/i18n/locales/it/chat.json
generated
|
|
@ -368,7 +368,8 @@
|
|||
"slashCommands": {
|
||||
"tooltip": "Gestisci comandi slash",
|
||||
"title": "Comandi Slash",
|
||||
"description": "Crea comandi slash personalizzati per accedere rapidamente a prompt e flussi di lavoro utilizzati frequentemente. <DocsLink>Documentazione</DocsLink>",
|
||||
"description": "Usa comandi slash integrati o crea personalizzati per accedere rapidamente a prompt e flussi di lavoro utilizzati frequentemente. <DocsLink>Documentazione</DocsLink>",
|
||||
"builtInCommands": "Comandi Integrati",
|
||||
"globalCommands": "Comandi Globali",
|
||||
"workspaceCommands": "Comandi dello Spazio di Lavoro",
|
||||
"globalCommand": "Comando globale",
|
||||
|
|
|
|||
3
webview-ui/src/i18n/locales/ja/chat.json
generated
3
webview-ui/src/i18n/locales/ja/chat.json
generated
|
|
@ -368,7 +368,8 @@
|
|||
"slashCommands": {
|
||||
"tooltip": "スラッシュコマンドを管理",
|
||||
"title": "スラッシュコマンド",
|
||||
"description": "よく使用するプロンプトやワークフローに素早くアクセスするためのカスタムスラッシュコマンドを作成します。<DocsLink>ドキュメント</DocsLink>",
|
||||
"description": "組み込みスラッシュコマンドを使用するか、よく使用するプロンプトやワークフローに素早くアクセスするためのカスタムスラッシュコマンドを作成します。<DocsLink>ドキュメント</DocsLink>",
|
||||
"builtInCommands": "組み込みコマンド",
|
||||
"globalCommands": "グローバルコマンド",
|
||||
"workspaceCommands": "ワークスペースコマンド",
|
||||
"globalCommand": "グローバルコマンド",
|
||||
|
|
|
|||
3
webview-ui/src/i18n/locales/ko/chat.json
generated
3
webview-ui/src/i18n/locales/ko/chat.json
generated
|
|
@ -368,7 +368,8 @@
|
|||
"slashCommands": {
|
||||
"tooltip": "슬래시 명령 관리",
|
||||
"title": "슬래시 명령",
|
||||
"description": "자주 사용하는 프롬프트와 워크플로우에 빠르게 액세스할 수 있는 사용자 정의 슬래시 명령을 만듭니다. <DocsLink>문서</DocsLink>",
|
||||
"description": "내장 슬래시 명령을 사용하거나 자주 사용하는 프롬프트와 워크플로우에 빠르게 액세스할 수 있는 사용자 정의 슬래시 명령을 만듭니다. <DocsLink>문서</DocsLink>",
|
||||
"builtInCommands": "내장 명령",
|
||||
"globalCommands": "전역 명령",
|
||||
"workspaceCommands": "작업 공간 명령",
|
||||
"globalCommand": "전역 명령",
|
||||
|
|
|
|||
3
webview-ui/src/i18n/locales/nl/chat.json
generated
3
webview-ui/src/i18n/locales/nl/chat.json
generated
|
|
@ -368,7 +368,8 @@
|
|||
"slashCommands": {
|
||||
"tooltip": "Slash-opdrachten beheren",
|
||||
"title": "Slash-opdrachten",
|
||||
"description": "Maak aangepaste slash-opdrachten voor snelle toegang tot veelgebruikte prompts en workflows. <DocsLink>Documentatie</DocsLink>",
|
||||
"description": "Gebruik ingebouwde slash-opdrachten of maak aangepaste voor snelle toegang tot veelgebruikte prompts en workflows. <DocsLink>Documentatie</DocsLink>",
|
||||
"builtInCommands": "Ingebouwde Opdrachten",
|
||||
"globalCommands": "Globale Opdrachten",
|
||||
"workspaceCommands": "Werkruimte Opdrachten",
|
||||
"globalCommand": "Globale opdracht",
|
||||
|
|
|
|||
3
webview-ui/src/i18n/locales/pl/chat.json
generated
3
webview-ui/src/i18n/locales/pl/chat.json
generated
|
|
@ -368,7 +368,8 @@
|
|||
"slashCommands": {
|
||||
"tooltip": "Zarządzaj poleceniami slash",
|
||||
"title": "Polecenia Slash",
|
||||
"description": "Twórz niestandardowe polecenia slash dla szybkiego dostępu do często używanych promptów i przepływów pracy. <DocsLink>Dokumentacja</DocsLink>",
|
||||
"description": "Używaj wbudowanych poleceń slash lub twórz niestandardowe dla szybkiego dostępu do często używanych promptów i przepływów pracy. <DocsLink>Dokumentacja</DocsLink>",
|
||||
"builtInCommands": "Polecenia Wbudowane",
|
||||
"globalCommands": "Polecenia Globalne",
|
||||
"workspaceCommands": "Polecenia Obszaru Roboczego",
|
||||
"globalCommand": "Polecenie globalne",
|
||||
|
|
|
|||
3
webview-ui/src/i18n/locales/pt-BR/chat.json
generated
3
webview-ui/src/i18n/locales/pt-BR/chat.json
generated
|
|
@ -368,7 +368,8 @@
|
|||
"slashCommands": {
|
||||
"tooltip": "Gerenciar comandos de barra",
|
||||
"title": "Comandos de Barra",
|
||||
"description": "Crie comandos de barra personalizados para acesso rápido a prompts e fluxos de trabalho usados com frequência. <DocsLink>Documentação</DocsLink>",
|
||||
"description": "Use comandos de barra integrados ou crie personalizados para acesso rápido a prompts e fluxos de trabalho usados com frequência. <DocsLink>Documentação</DocsLink>",
|
||||
"builtInCommands": "Comandos Integrados",
|
||||
"globalCommands": "Comandos Globais",
|
||||
"workspaceCommands": "Comandos do Espaço de Trabalho",
|
||||
"globalCommand": "Comando global",
|
||||
|
|
|
|||
3
webview-ui/src/i18n/locales/ru/chat.json
generated
3
webview-ui/src/i18n/locales/ru/chat.json
generated
|
|
@ -368,7 +368,8 @@
|
|||
"slashCommands": {
|
||||
"tooltip": "Управление слэш-командами",
|
||||
"title": "Слэш-команды",
|
||||
"description": "Создавайте пользовательские слэш-команды для быстрого доступа к часто используемым промптам и рабочим процессам. <DocsLink>Документация</DocsLink>",
|
||||
"description": "Используйте встроенные слэш-команды или создавайте пользовательские для быстрого доступа к часто используемым промптам и рабочим процессам. <DocsLink>Документация</DocsLink>",
|
||||
"builtInCommands": "Встроенные команды",
|
||||
"globalCommands": "Глобальные команды",
|
||||
"workspaceCommands": "Команды рабочего пространства",
|
||||
"globalCommand": "Глобальная команда",
|
||||
|
|
|
|||
3
webview-ui/src/i18n/locales/tr/chat.json
generated
3
webview-ui/src/i18n/locales/tr/chat.json
generated
|
|
@ -368,7 +368,8 @@
|
|||
"slashCommands": {
|
||||
"tooltip": "Eğik çizgi komutlarını yönet",
|
||||
"title": "Eğik Çizgi Komutları",
|
||||
"description": "Sık kullanılan komut istemleri ve iş akışlarına hızlı erişim için özel eğik çizgi komutları oluşturun. <DocsLink>Belgeler</DocsLink>",
|
||||
"description": "Yerleşik eğik çizgi komutlarını kullanın veya sık kullanılan komut istemleri ve iş akışlarına hızlı erişim için özel komutlar oluşturun. <DocsLink>Belgeler</DocsLink>",
|
||||
"builtInCommands": "Yerleşik Komutlar",
|
||||
"globalCommands": "Genel Komutlar",
|
||||
"workspaceCommands": "Çalışma Alanı Komutları",
|
||||
"globalCommand": "Genel komut",
|
||||
|
|
|
|||
3
webview-ui/src/i18n/locales/vi/chat.json
generated
3
webview-ui/src/i18n/locales/vi/chat.json
generated
|
|
@ -368,7 +368,8 @@
|
|||
"slashCommands": {
|
||||
"tooltip": "Quản lý lệnh gạch chéo",
|
||||
"title": "Lệnh Gạch Chéo",
|
||||
"description": "Tạo lệnh gạch chéo tùy chỉnh để truy cập nhanh vào các lời nhắc và quy trình làm việc thường dùng. <DocsLink>Tài liệu</DocsLink>",
|
||||
"description": "Sử dụng lệnh gạch chéo tích hợp sẵn hoặc tạo tùy chỉnh để truy cập nhanh vào các lời nhắc và quy trình làm việc thường dùng. <DocsLink>Tài liệu</DocsLink>",
|
||||
"builtInCommands": "Lệnh Tích Hợp",
|
||||
"globalCommands": "Lệnh Toàn Cục",
|
||||
"workspaceCommands": "Lệnh Không Gian Làm Việc",
|
||||
"globalCommand": "Lệnh toàn cục",
|
||||
|
|
|
|||
3
webview-ui/src/i18n/locales/zh-CN/chat.json
generated
3
webview-ui/src/i18n/locales/zh-CN/chat.json
generated
|
|
@ -368,7 +368,8 @@
|
|||
"slashCommands": {
|
||||
"tooltip": "管理斜杠命令",
|
||||
"title": "斜杠命令",
|
||||
"description": "创建自定义斜杠命令,快速访问常用提示词和工作流程。<DocsLink>文档</DocsLink>",
|
||||
"description": "使用内置斜杠命令或创建自定义命令,快速访问常用提示词和工作流程。<DocsLink>文档</DocsLink>",
|
||||
"builtInCommands": "内置命令",
|
||||
"globalCommands": "全局命令",
|
||||
"workspaceCommands": "工作区命令",
|
||||
"globalCommand": "全局命令",
|
||||
|
|
|
|||
3
webview-ui/src/i18n/locales/zh-TW/chat.json
generated
3
webview-ui/src/i18n/locales/zh-TW/chat.json
generated
|
|
@ -368,7 +368,8 @@
|
|||
"slashCommands": {
|
||||
"tooltip": "管理斜線命令",
|
||||
"title": "斜線命令",
|
||||
"description": "建立自訂斜線命令,以便快速存取常用的提示詞和工作流程。<DocsLink>說明文件</DocsLink>",
|
||||
"description": "使用內建斜線命令或建立自訂命令,以便快速存取常用的提示詞和工作流程。<DocsLink>說明文件</DocsLink>",
|
||||
"builtInCommands": "內建命令",
|
||||
"globalCommands": "全域命令",
|
||||
"workspaceCommands": "工作區命令",
|
||||
"globalCommand": "全域命令",
|
||||
|
|
|
|||
|
|
@ -169,7 +169,7 @@ export function getContextMenuOptions(
|
|||
if (matchingCommands.length > 0) {
|
||||
results.push({
|
||||
type: ContextMenuOptionType.SectionHeader,
|
||||
label: "Custom Commands",
|
||||
label: "Commands",
|
||||
})
|
||||
results.push(...matchingCommands)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue