Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/types/src/tool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export const toolNames = [
"fetch_instructions",
"codebase_search",
"update_todo_list",
"run_slash_command",
] as const

export const toolNamesSchema = z.enum(toolNames)
Expand Down
6 changes: 6 additions & 0 deletions src/core/assistant-message/presentAssistantMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { attemptCompletionTool } from "../tools/attemptCompletionTool"
import { newTaskTool } from "../tools/newTaskTool"

import { updateTodoListTool } from "../tools/updateTodoListTool"
import { runSlashCommandTool } from "../tools/runSlashCommandTool"

import { formatResponse } from "../prompts/responses"
import { validateToolUse } from "../tools/validateToolUse"
Expand Down Expand Up @@ -221,6 +222,8 @@ export async function presentAssistantMessage(cline: Task) {
const modeName = getModeBySlug(mode, customModes)?.name ?? mode
return `[${block.name} in ${modeName} mode: '${message}']`
}
case "run_slash_command":
return `[${block.name} for '${block.params.command}'${block.params.args ? ` with args: ${block.params.args}` : ""}]`
}
}

Expand Down Expand Up @@ -546,6 +549,9 @@ export async function presentAssistantMessage(cline: Task) {
askFinishSubTaskApproval,
)
break
case "run_slash_command":
await runSlashCommandTool(cline, block, askApproval, handleError, pushToolResult, removeClosingTag)
break
}

break
Expand Down
3 changes: 3 additions & 0 deletions src/core/prompts/tools/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { getSwitchModeDescription } from "./switch-mode"
import { getNewTaskDescription } from "./new-task"
import { getCodebaseSearchDescription } from "./codebase-search"
import { getUpdateTodoListDescription } from "./update-todo-list"
import { getRunSlashCommandDescription } from "./run-slash-command"
import { CodeIndexManager } from "../../../services/code-index/manager"

// Map of tool names to their description functions
Expand Down Expand Up @@ -56,6 +57,7 @@ const toolDescriptionMap: Record<string, (args: ToolArgs) => string | undefined>
apply_diff: (args) =>
args.diffStrategy ? args.diffStrategy.getToolDescription({ cwd: args.cwd, toolOptions: args.toolOptions }) : "",
update_todo_list: (args) => getUpdateTodoListDescription(args),
run_slash_command: () => getRunSlashCommandDescription(),
}

export function getToolDescriptionsForMode(
Expand Down Expand Up @@ -164,4 +166,5 @@ export {
getInsertContentDescription,
getSearchAndReplaceDescription,
getCodebaseSearchDescription,
getRunSlashCommandDescription,
}
37 changes: 37 additions & 0 deletions src/core/prompts/tools/run-slash-command.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/**
* Generates the run_slash_command tool description.
*/
export function getRunSlashCommandDescription(): string {
return `## run_slash_command
Description: Execute a slash command to get specific instructions or content. Slash commands are predefined templates that provide detailed guidance for common tasks. Commands can be built-in, defined globally, or project-specific.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we mention in the description that commands are executed in priority order (project > global > built-in)? This would help users understand which command will be executed when there are multiple commands with the same name:

Suggested change
Description: Execute a slash command to get specific instructions or content. Slash commands are predefined templates that provide detailed guidance for common tasks. Commands can be built-in, defined globally, or project-specific.
Description: Execute a slash command to get specific instructions or content. Slash commands are predefined templates that provide detailed guidance for common tasks. Commands can be built-in, defined globally, or project-specific. When multiple commands with the same name exist, they are prioritized as: project > global > built-in.


Parameters:
- command: (required) The name of the slash command to execute (e.g., "init", "test", "deploy")
- args: (optional) Additional arguments or context to pass to the command

Usage:
<run_slash_command>
<command>command_name</command>
<args>optional arguments</args>
</run_slash_command>

Examples:

1. Running the init command to analyze a codebase:
<run_slash_command>
<command>init</command>
</run_slash_command>

2. Running a command with additional context:
<run_slash_command>
<command>test</command>
<args>focus on integration tests</args>
</run_slash_command>

Note: Available commands depend on the project and global configuration. The tool will list available commands if an invalid command is specified. Commands can be:
- Built-in: Predefined commands like "init" for codebase analysis
- Global: Custom commands defined in ~/.roo/commands/
- Project: Project-specific commands defined in .roo/commands/

The command content will be returned for you to execute or follow as instructions.`
}
Loading
Loading