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

Function extractToolData

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

Source from the content-addressed store, hash-verified

7 * This provides rich data for tool-specific renderers
8 */
9export function extractToolData(toolInfo: Record<string, unknown>): ToolData {
10 const toolName = (toolInfo.tool as string) || "unknown"
11
12 // Base tool data with common fields
13 const toolData: ToolData = {
14 tool: toolName,
15 path: toolInfo.path as string | undefined,
16 isOutsideWorkspace: toolInfo.isOutsideWorkspace as boolean | undefined,
17 isProtected: toolInfo.isProtected as boolean | undefined,
18 content: toolInfo.content as string | undefined,
19 reason: toolInfo.reason as string | undefined,
20 }
21
22 // Extract diff-related fields
23 if (toolInfo.diff !== undefined) {
24 toolData.diff = toolInfo.diff as string
25 }
26 if (toolInfo.diffStats !== undefined) {
27 const stats = toolInfo.diffStats as { added?: number; removed?: number }
28 if (typeof stats.added === "number" && typeof stats.removed === "number") {
29 toolData.diffStats = { added: stats.added, removed: stats.removed }
30 }
31 }
32
33 // Extract search-related fields
34 if (toolInfo.regex !== undefined) {
35 toolData.regex = toolInfo.regex as string
36 }
37 if (toolInfo.filePattern !== undefined) {
38 toolData.filePattern = toolInfo.filePattern as string
39 }
40 if (toolInfo.query !== undefined) {
41 toolData.query = toolInfo.query as string
42 }
43
44 // Extract mode-related fields
45 if (toolInfo.mode !== undefined) {
46 toolData.mode = toolInfo.mode as string
47 }
48 if (toolInfo.mode_slug !== undefined) {
49 toolData.mode = toolInfo.mode_slug as string
50 }
51
52 // Extract command-related fields
53 if (toolInfo.command !== undefined) {
54 toolData.command = toolInfo.command as string
55 }
56 if (toolInfo.output !== undefined) {
57 toolData.output = toolInfo.output as string
58 }
59
60 // Extract batch file operations
61 if (Array.isArray(toolInfo.files)) {
62 toolData.batchFiles = (toolInfo.files as Array<Record<string, unknown>>).map((f) => ({
63 path: (f.path as string) || "",
64 lineSnippet: f.lineSnippet as string | undefined,
65 isOutsideWorkspace: f.isOutsideWorkspace as boolean | undefined,
66 key: f.key as string | undefined,

Callers 1

useMessageHandlersFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected