Elffuss BraidHub

kikocis/continue public

6bd56445a990 · 647 BRawPermalink
1import { getUriDescription } from "../../util/uri";
2
3import { ToolImpl } from ".";
4
5export const readCurrentlyOpenFileImpl: ToolImpl = async (args, extras) => {
6 const result = await extras.ide.getCurrentFile();
7
8 if (!result) {
9 return [];
10 }
11
12 const { relativePathOrBasename, last2Parts, baseName } = getUriDescription(
13 result.path,
14 await extras.ide.getWorkspaceDirs(),
15 );
16
17 return [
18 {
19 name: `Current file: ${baseName}`,
20 description: last2Parts,
21 content: `\`\`\`${relativePathOrBasename}\n${result.contents}\n\`\`\``,
22 uri: {
23 type: "file",
24 value: result.path,
25 },
26 },
27 ];
28};