MCPcopy Create free account
hub / github.com/MatterAIOrg/OrbCode / listFiles

Function listFiles

src/tools/executors/listFiles.ts:53–70  ·  view source on GitHub ↗
(args: Record<string, unknown>, context: ToolContext)

Source from the content-addressed store, hash-verified

51}
52
53export async function listFiles(args: Record<string, unknown>, context: ToolContext): Promise<ToolResult> {
54 const dirPath = resolveWorkspacePath(context.cwd, String(args.path ?? "."))
55 const recursive = Boolean(args.recursive)
56
57 if (!fs.existsSync(dirPath)) {
58 return { text: `Directory not found: ${dirPath}`, isError: true }
59 }
60
61 const entries = walkFiles(dirPath, recursive)
62 if (entries.length === 0) {
63 return { text: `Directory ${dirPath} is empty.` }
64 }
65 let text = entries.join("\n")
66 if (entries.length >= MAX_ENTRIES) {
67 text += `\n\n(Truncated at ${MAX_ENTRIES} entries.)`
68 }
69 return { text }
70}

Callers

nothing calls this directly

Calls 2

resolveWorkspacePathFunction · 0.85
walkFilesFunction · 0.85

Tested by

no test coverage detected