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

Function formatToolAskMessage

apps/cli/src/ui/utils/tools.ts:199–246  ·  view source on GitHub ↗
(toolInfo: Record<string, unknown>)

Source from the content-addressed store, hash-verified

197 * Format tool ask message for user approval prompt
198 */
199export function formatToolAskMessage(toolInfo: Record<string, unknown>): string {
200 const toolName = (toolInfo.tool as string) || "unknown"
201
202 switch (toolName) {
203 case "switchMode":
204 case "switch_mode": {
205 const mode = (toolInfo.mode as string) || (toolInfo.mode_slug as string) || "unknown"
206 const reason = toolInfo.reason as string
207 return `Switch to ${mode} mode?${reason ? `\nReason: ${reason}` : ""}`
208 }
209
210 case "execute_command": {
211 const command = toolInfo.command as string
212 return `Run command?\n$ ${command || "(no command)"}`
213 }
214
215 case "read_file": {
216 const files = toolInfo.files as Array<{ path: string }> | undefined
217 const path = toolInfo.path as string
218 if (files && files.length > 0) {
219 return `Read ${files.length} file(s)?\n${files.map((f) => ` ${f.path}`).join("\n")}`
220 }
221 return `Read file: ${path || "(no path)"}`
222 }
223
224 case "write_to_file": {
225 const writePath = toolInfo.path as string
226 return `Write to file: ${writePath || "(no path)"}`
227 }
228
229 case "apply_diff": {
230 const diffPath = toolInfo.path as string
231 return `Apply changes to: ${diffPath || "(no path)"}`
232 }
233
234 default: {
235 const params = Object.entries(toolInfo)
236 .filter(([key]) => key !== "tool")
237 .map(([key, value]) => {
238 const displayValue = typeof value === "string" ? value : JSON.stringify(value)
239 const truncated = displayValue.length > 80 ? displayValue.substring(0, 80) + "..." : displayValue
240 return ` ${key}: ${truncated}`
241 })
242 .join("\n")
243 return `${toolName}${params ? `\n${params}` : ""}`
244 }
245 }
246}
247
248/**
249 * Parse TODO items from tool info

Callers 1

useMessageHandlersFunction · 0.85

Calls 1

entriesMethod · 0.80

Tested by

no test coverage detected