Elffuss BraidHub

kikocis/continue public

627d7d0d1f85 · 848 BRawPermalink
1import { resolveRelativePathInDir } from "core/util/ideUtils";
2import { v4 as uuid } from "uuid";
3import { ClientToolImpl } from "./callClientTool";
4export const editToolImpl: ClientToolImpl = async (
5 args,
6 toolCallId,
7 extras,
8) => {
9 if (!args.filepath || !args.changes) {
10 throw new Error(
11 "`filepath` and `changes` arguments are required to edit an existing file.",
12 );
13 }
14 const firstUriMatch = await resolveRelativePathInDir(
15 args.filepath,
16 extras.ideMessenger.ide,
17 );
18 if (!firstUriMatch) {
19 throw new Error(`${args.filepath} does not exist`);
20 }
21 const streamId = uuid();
22 extras.ideMessenger.post("applyToFile", {
23 streamId,
24 text: args.changes,
25 toolCallId,
26 filepath: firstUriMatch,
27 });
28
29 return {
30 respondImmediately: false,
31 output: undefined, // No immediate output.
32 };
33};