Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions packages/types/src/experiment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const experimentIds = [
"multiFileApplyDiff",
"preventFocusDisruption",
"imageGeneration",
"runSlashCommand",
] as const

export const experimentIdsSchema = z.enum(experimentIds)
Expand All @@ -26,6 +27,7 @@ export const experimentsSchema = z.object({
multiFileApplyDiff: z.boolean().optional(),
preventFocusDisruption: z.boolean().optional(),
imageGeneration: z.boolean().optional(),
runSlashCommand: z.boolean().optional(),
})

export type Experiments = z.infer<typeof experimentsSchema>
Expand Down
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",
"generate_image",
] as const

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 { generateImageTool } from "../tools/generateImageTool"

import { formatResponse } from "../prompts/responses"
Expand Down Expand Up @@ -222,6 +223,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}` : ""}]`
case "generate_image":
return `[${block.name} for '${block.params.path}']`
}
Expand Down Expand Up @@ -549,6 +552,9 @@ export async function presentAssistantMessage(cline: Task) {
askFinishSubTaskApproval,
)
break
case "run_slash_command":
await runSlashCommandTool(cline, block, askApproval, handleError, pushToolResult, removeClosingTag)
break
case "generate_image":
await generateImageTool(cline, block, askApproval, handleError, pushToolResult, removeClosingTag)
break
Expand Down
8 changes: 8 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 { getGenerateImageDescription } from "./generate-image"
import { CodeIndexManager } from "../../../services/code-index/manager"

Expand Down Expand Up @@ -57,6 +58,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(),
generate_image: (args) => getGenerateImageDescription(args),
}

Expand Down Expand Up @@ -136,6 +138,11 @@ export function getToolDescriptionsForMode(
tools.delete("generate_image")
}

// Conditionally exclude run_slash_command if experiment is not enabled
if (!experiments?.runSlashCommand) {
tools.delete("run_slash_command")
}

// Map tool descriptions for allowed tools
const descriptions = Array.from(tools).map((toolName) => {
const descriptionFn = toolDescriptionMap[toolName]
Expand Down Expand Up @@ -171,5 +178,6 @@ export {
getInsertContentDescription,
getSearchAndReplaceDescription,
getCodebaseSearchDescription,
getRunSlashCommandDescription,
getGenerateImageDescription,
}
32 changes: 32 additions & 0 deletions src/core/prompts/tools/run-slash-command.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* 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.

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>

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