MCPcopy Create free account
hub / github.com/Zoo-Code-Org/Zoo-Code / execute

Method execute

src/core/tools/RunSlashCommandTool.ts:22–137  ·  view source on GitHub ↗
(params: RunSlashCommandParams, task: Task, callbacks: ToolCallbacks)

Source from the content-addressed store, hash-verified

20 readonly name = "run_slash_command" as const
21
22 async execute(params: RunSlashCommandParams, task: Task, callbacks: ToolCallbacks): Promise<void> {
23 const { command: commandName, args } = params
24 const { askApproval, handleError, pushToolResult } = callbacks
25
26 // Check if run slash command experiment is enabled
27 const provider = task.providerRef.deref()
28 const state = await provider?.getState()
29 const isRunSlashCommandEnabled = experiments.isEnabled(
30 state?.experiments ?? {},
31 EXPERIMENT_IDS.RUN_SLASH_COMMAND,
32 )
33
34 if (!isRunSlashCommandEnabled) {
35 pushToolResult(
36 formatResponse.toolError(
37 "Run slash command is an experimental feature that must be enabled in settings. Please enable 'Run Slash Command' in the Experimental Settings section.",
38 ),
39 )
40 return
41 }
42
43 try {
44 if (!commandName) {
45 task.consecutiveMistakeCount++
46 task.recordToolError("run_slash_command")
47 task.didToolFailInCurrentTurn = true
48 pushToolResult(await task.sayAndCreateMissingParamError("run_slash_command", "command"))
49 return
50 }
51
52 task.consecutiveMistakeCount = 0
53
54 // Get the command from the commands service
55 const command = await getCommand(task.cwd, commandName)
56
57 if (!command) {
58 const currentMode = state?.mode ?? "code"
59 const skillsManager = provider?.getSkillsManager()
60 const skillContent = await resolveSkillContentForMode(skillsManager, commandName, currentMode)
61
62 if (skillContent) {
63 const skillMessage = buildSkillApprovalMessage(commandName, args, skillContent)
64 const didApprove = await askApproval("tool", skillMessage)
65
66 if (!didApprove) {
67 return
68 }
69
70 pushToolResult(buildSkillResult(commandName, args, skillContent))
71 return
72 }
73
74 // Get available commands for error message
75 const availableCommands = await getCommandNames(task.cwd)
76 task.recordToolError("run_slash_command")
77 task.didToolFailInCurrentTurn = true
78 pushToolResult(
79 formatResponse.toolError(

Callers

nothing calls this directly

Calls 15

getCommandFunction · 0.90
buildSkillResultFunction · 0.90
getCommandNamesFunction · 0.90
getModeBySlugFunction · 0.90
pushToolResultFunction · 0.85
askApprovalFunction · 0.85
handleErrorFunction · 0.85
isEnabledMethod · 0.80
recordToolErrorMethod · 0.80

Tested by

no test coverage detected