Skip to content

Commit d789692

Browse files
roomote[bot]roomotemrubensdaniel-lxs
authored
feat: add run_slash_command tool for executing slash commands (#7473)
Co-authored-by: Roo Code <[email protected]> Co-authored-by: Matt Rubens <[email protected]> Co-authored-by: Daniel Riccio <[email protected]>
1 parent 130ce29 commit d789692

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+972
-0
lines changed

packages/types/src/experiment.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export const experimentIds = [
1111
"multiFileApplyDiff",
1212
"preventFocusDisruption",
1313
"imageGeneration",
14+
"runSlashCommand",
1415
] as const
1516

1617
export const experimentIdsSchema = z.enum(experimentIds)
@@ -26,6 +27,7 @@ export const experimentsSchema = z.object({
2627
multiFileApplyDiff: z.boolean().optional(),
2728
preventFocusDisruption: z.boolean().optional(),
2829
imageGeneration: z.boolean().optional(),
30+
runSlashCommand: z.boolean().optional(),
2931
})
3032

3133
export type Experiments = z.infer<typeof experimentsSchema>

packages/types/src/tool.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export const toolNames = [
3434
"fetch_instructions",
3535
"codebase_search",
3636
"update_todo_list",
37+
"run_slash_command",
3738
"generate_image",
3839
] as const
3940

src/core/assistant-message/presentAssistantMessage.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import { attemptCompletionTool } from "../tools/attemptCompletionTool"
2828
import { newTaskTool } from "../tools/newTaskTool"
2929

3030
import { updateTodoListTool } from "../tools/updateTodoListTool"
31+
import { runSlashCommandTool } from "../tools/runSlashCommandTool"
3132
import { generateImageTool } from "../tools/generateImageTool"
3233

3334
import { formatResponse } from "../prompts/responses"
@@ -222,6 +223,8 @@ export async function presentAssistantMessage(cline: Task) {
222223
const modeName = getModeBySlug(mode, customModes)?.name ?? mode
223224
return `[${block.name} in ${modeName} mode: '${message}']`
224225
}
226+
case "run_slash_command":
227+
return `[${block.name} for '${block.params.command}'${block.params.args ? ` with args: ${block.params.args}` : ""}]`
225228
case "generate_image":
226229
return `[${block.name} for '${block.params.path}']`
227230
}
@@ -549,6 +552,9 @@ export async function presentAssistantMessage(cline: Task) {
549552
askFinishSubTaskApproval,
550553
)
551554
break
555+
case "run_slash_command":
556+
await runSlashCommandTool(cline, block, askApproval, handleError, pushToolResult, removeClosingTag)
557+
break
552558
case "generate_image":
553559
await generateImageTool(cline, block, askApproval, handleError, pushToolResult, removeClosingTag)
554560
break

src/core/prompts/tools/index.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import { getSwitchModeDescription } from "./switch-mode"
2525
import { getNewTaskDescription } from "./new-task"
2626
import { getCodebaseSearchDescription } from "./codebase-search"
2727
import { getUpdateTodoListDescription } from "./update-todo-list"
28+
import { getRunSlashCommandDescription } from "./run-slash-command"
2829
import { getGenerateImageDescription } from "./generate-image"
2930
import { CodeIndexManager } from "../../../services/code-index/manager"
3031

@@ -57,6 +58,7 @@ const toolDescriptionMap: Record<string, (args: ToolArgs) => string | undefined>
5758
apply_diff: (args) =>
5859
args.diffStrategy ? args.diffStrategy.getToolDescription({ cwd: args.cwd, toolOptions: args.toolOptions }) : "",
5960
update_todo_list: (args) => getUpdateTodoListDescription(args),
61+
run_slash_command: () => getRunSlashCommandDescription(),
6062
generate_image: (args) => getGenerateImageDescription(args),
6163
}
6264

@@ -136,6 +138,11 @@ export function getToolDescriptionsForMode(
136138
tools.delete("generate_image")
137139
}
138140

141+
// Conditionally exclude run_slash_command if experiment is not enabled
142+
if (!experiments?.runSlashCommand) {
143+
tools.delete("run_slash_command")
144+
}
145+
139146
// Map tool descriptions for allowed tools
140147
const descriptions = Array.from(tools).map((toolName) => {
141148
const descriptionFn = toolDescriptionMap[toolName]
@@ -171,5 +178,6 @@ export {
171178
getInsertContentDescription,
172179
getSearchAndReplaceDescription,
173180
getCodebaseSearchDescription,
181+
getRunSlashCommandDescription,
174182
getGenerateImageDescription,
175183
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/**
2+
* Generates the run_slash_command tool description.
3+
*/
4+
export function getRunSlashCommandDescription(): string {
5+
return `## run_slash_command
6+
Description: Execute a slash command to get specific instructions or content. Slash commands are predefined templates that provide detailed guidance for common tasks.
7+
8+
Parameters:
9+
- command: (required) The name of the slash command to execute (e.g., "init", "test", "deploy")
10+
- args: (optional) Additional arguments or context to pass to the command
11+
12+
Usage:
13+
<run_slash_command>
14+
<command>command_name</command>
15+
<args>optional arguments</args>
16+
</run_slash_command>
17+
18+
Examples:
19+
20+
1. Running the init command to analyze a codebase:
21+
<run_slash_command>
22+
<command>init</command>
23+
</run_slash_command>
24+
25+
2. Running a command with additional context:
26+
<run_slash_command>
27+
<command>test</command>
28+
<args>focus on integration tests</args>
29+
</run_slash_command>
30+
31+
The command content will be returned for you to execute or follow as instructions.`
32+
}

0 commit comments

Comments
 (0)