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

Method execute

src/core/tools/ListFilesTool.ts:22–69  ·  view source on GitHub ↗
(params: ListFilesParams, task: Task, callbacks: ToolCallbacks)

Source from the content-addressed store, hash-verified

20 readonly name = "list_files" as const
21
22 async execute(params: ListFilesParams, task: Task, callbacks: ToolCallbacks): Promise<void> {
23 const { path: relDirPath, recursive } = params
24 const { askApproval, handleError, pushToolResult } = callbacks
25
26 try {
27 if (!relDirPath) {
28 task.consecutiveMistakeCount++
29 task.recordToolError("list_files")
30 task.didToolFailInCurrentTurn = true
31 pushToolResult(await task.sayAndCreateMissingParamError("list_files", "path"))
32 return
33 }
34
35 task.consecutiveMistakeCount = 0
36
37 const absolutePath = path.resolve(task.cwd, relDirPath)
38 const isOutsideWorkspace = isPathOutsideWorkspace(absolutePath)
39
40 const [files, didHitLimit] = await listFiles(absolutePath, recursive || false, 200)
41 const { showRooIgnoredFiles = false } = (await task.providerRef.deref()?.getState()) ?? {}
42
43 const result = formatResponse.formatFilesList(
44 absolutePath,
45 files,
46 didHitLimit,
47 task.rooIgnoreController,
48 showRooIgnoredFiles,
49 task.rooProtectedController,
50 )
51
52 const sharedMessageProps: ClineSayTool = {
53 tool: !recursive ? "listFilesTopLevel" : "listFilesRecursive",
54 path: getReadablePath(task.cwd, relDirPath),
55 isOutsideWorkspace,
56 }
57
58 const completeMessage = JSON.stringify({ ...sharedMessageProps, content: result } satisfies ClineSayTool)
59 const didApprove = await askApproval("tool", completeMessage)
60
61 if (!didApprove) {
62 return
63 }
64
65 pushToolResult(result)
66 } catch (error) {
67 await handleError("listing files", error)
68 }
69 }
70
71 override async handlePartial(task: Task, block: ToolUse<"list_files">): Promise<void> {
72 const relDirPath: string | undefined = block.params.path

Callers

nothing calls this directly

Calls 9

isPathOutsideWorkspaceFunction · 0.90
listFilesFunction · 0.90
getReadablePathFunction · 0.90
pushToolResultFunction · 0.85
askApprovalFunction · 0.85
handleErrorFunction · 0.85
recordToolErrorMethod · 0.80
getStateMethod · 0.65

Tested by

no test coverage detected