MCPcopy Create free account
hub / github.com/Work-Fisher/code-claw / listDir

Function listDir

compatible-shell/src/tools.mjs:185–200  ·  view source on GitHub ↗
(workspaceDir, input)

Source from the content-addressed store, hash-verified

183}
184
185async function listDir(workspaceDir, input) {
186 const requestedPath = typeof input.path === 'string' && input.path ? input.path : '.'
187 const absolutePath = resolveWorkspacePath(workspaceDir, requestedPath)
188 const entries = await fs.readdir(absolutePath, { withFileTypes: true })
189
190 return {
191 ok: true,
192 path: toWorkspaceRelative(workspaceDir, absolutePath),
193 entries: entries
194 .slice(0, 200)
195 .map(entry => ({
196 name: entry.name,
197 type: entry.isDirectory() ? 'directory' : entry.isFile() ? 'file' : 'other',
198 })),
199 }
200}
201
202async function readFile(workspaceDir, input) {
203 if (typeof input.path !== 'string' || !input.path) {

Callers 1

dispatchToolFunction · 0.85

Calls 2

resolveWorkspacePathFunction · 0.85
toWorkspaceRelativeFunction · 0.85

Tested by

no test coverage detected