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