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

Function formatToolOutput

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

Source from the content-addressed store, hash-verified

103 * Format tool output for display (used in the message body, header shows tool name separately)
104 */
105export function formatToolOutput(toolInfo: Record<string, unknown>): string {
106 const toolName = (toolInfo.tool as string) || "unknown"
107
108 switch (toolName) {
109 case "switchMode": {
110 const mode = (toolInfo.mode as string) || "unknown"
111 const reason = toolInfo.reason as string
112 return `→ ${mode} mode${reason ? `\n ${reason}` : ""}`
113 }
114
115 case "switch_mode": {
116 const mode = (toolInfo.mode_slug as string) || (toolInfo.mode as string) || "unknown"
117 const reason = toolInfo.reason as string
118 return `→ ${mode} mode${reason ? `\n ${reason}` : ""}`
119 }
120
121 case "execute_command": {
122 const command = toolInfo.command as string
123 return `$ ${command || "(no command)"}`
124 }
125
126 case "read_file": {
127 const files = toolInfo.files as Array<{ path: string }> | undefined
128 const path = toolInfo.path as string
129 if (files && files.length > 0) {
130 return files.map((f) => `📄 ${f.path}`).join("\n")
131 }
132 return `📄 ${path || "(no path)"}`
133 }
134
135 case "write_to_file": {
136 const writePath = toolInfo.path as string
137 return `📝 ${writePath || "(no path)"}`
138 }
139
140 case "apply_diff": {
141 const diffPath = toolInfo.path as string
142 return `✏️ ${diffPath || "(no path)"}`
143 }
144
145 case "search_files": {
146 const searchPath = toolInfo.path as string
147 const regex = toolInfo.regex as string
148 return `🔍 "${regex}" in ${searchPath || "."}`
149 }
150
151 case "list_files": {
152 const listPath = toolInfo.path as string
153 const recursive = toolInfo.recursive as boolean
154 return `📁 ${listPath || "."}${recursive ? " (recursive)" : ""}`
155 }
156
157 case "attempt_completion": {
158 const result = toolInfo.result as string
159 if (result) {
160 const truncated = result.length > 100 ? result.substring(0, 100) + "..." : result
161 return `✅ ${truncated}`
162 }

Callers 1

useMessageHandlersFunction · 0.85

Calls 1

entriesMethod · 0.80

Tested by

no test coverage detected