Elffuss BraidHub

kikocis/continue public

32d59361d5be · 660 BRawPermalink
1import { resolveRelativePathInDir } from "../../util/ideUtils";
2import { getUriPathBasename } from "../../util/uri";
3
4import { ToolImpl } from ".";
5
6export const readFileImpl: ToolImpl = async (args, extras) => {
7 const firstUriMatch = await resolveRelativePathInDir(
8 args.filepath,
9 extras.ide,
10 );
11 if (!firstUriMatch) {
12 throw new Error(`Could not find file ${args.filepath}`);
13 }
14 const content = await extras.ide.readFile(firstUriMatch);
15 return [
16 {
17 name: getUriPathBasename(args.filepath),
18 description: args.filepath,
19 content,
20 uri: {
21 type: "file",
22 value: firstUriMatch,
23 },
24 },
25 ];
26};