Elffuss BraidHub

kikocis/continue public

9ea2d7361601 · 883 BRawPermalink
1import generateRepoMap from "../../util/generateRepoMap";
2import { resolveRelativePathInDir } from "../../util/ideUtils";
3
4import { ToolImpl } from ".";
5
6export const viewSubdirectoryImpl: ToolImpl = async (args: any, extras) => {
7 if (!args?.directory_path) {
8 throw new Error(
9 "`directory_path` argument is required to view a map of a subdirectory, and cannot be empty",
10 );
11 }
12 const { directory_path } = args;
13
14 const uri = await resolveRelativePathInDir(directory_path, extras.ide);
15
16 if (!uri) {
17 throw new Error(`Directory path "${directory_path}" does not exist.`);
18 }
19
20 const repoMap = await generateRepoMap(extras.llm, extras.ide, {
21 dirUris: [uri],
22 outputRelativeUriPaths: true,
23 includeSignatures: false,
24 });
25
26 return [
27 {
28 name: "Repo map",
29 description: `Map of ${directory_path}`,
30 content: repoMap,
31 },
32 ];
33};