continue-custom/gui/src/util/clientTools/editImpl.ts
2025-06-26 11:13:31 -07:00

28 lines
692 B
TypeScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { resolveRelativePathInDir } from "core/util/ideUtils";
import { v4 as uuid } from "uuid";
import { ClientToolImpl } from "./callClientTool";
export const editToolImpl: ClientToolImpl = async (
args,
toolCallId,
extras,
) => {
const firstUriMatch = await resolveRelativePathInDir(
args.filepath,
extras.ideMessenger.ide,
);
if (!firstUriMatch) {
throw new Error(`${args.filepath} does not exist`);
}
const streamId = uuid();
extras.ideMessenger.post("applyToFile", {
streamId,
text: args.changes,
toolCallId,
filepath: firstUriMatch,
});
return {
respondImmediately: false,
output: undefined, // No immediate output.
};
};