(args: Record<string, unknown>, context: ToolContext)
| 51 | } |
| 52 | |
| 53 | export 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 | } |
nothing calls this directly
no test coverage detected