| 1 | import generateRepoMap from "../../util/generateRepoMap"; |
| 2 | import { resolveRelativePathInDir } from "../../util/ideUtils"; |
| 3 | |
| 4 | import { ToolImpl } from "."; |
| 5 | import { getStringArg } from "../parseArgs"; |
| 6 | |
| 7 | export const viewSubdirectoryImpl: ToolImpl = async (args: any, extras) => { |
| 8 | const directory_path = getStringArg(args, "directory_path"); |
| 9 | |
| 10 | const uri = await resolveRelativePathInDir(directory_path, extras.ide); |
| 11 | |
| 12 | if (!uri) { |
| 13 | throw new Error(`Directory path "${directory_path}" does not exist.`); |
| 14 | } |
| 15 | |
| 16 | const repoMap = await generateRepoMap(extras.llm, extras.ide, { |
| 17 | dirUris: [uri], |
| 18 | outputRelativeUriPaths: true, |
| 19 | includeSignatures: false, |
| 20 | }); |
| 21 | |
| 22 | return [ |
| 23 | { |
| 24 | name: "Repo map", |
| 25 | description: `Map of ${directory_path}`, |
| 26 | content: repoMap, |
| 27 | }, |
| 28 | ]; |
| 29 | }; |