Merge pull request #5358 from continuedev/dallin/lazy-edit-tool
Lazy Edit Tool
This commit is contained in:
commit
cbfc6a241d
4 changed files with 9 additions and 8 deletions
|
|
@ -3,7 +3,7 @@ import { BUILT_IN_GROUP_NAME, BuiltInToolNames } from "../builtIn";
|
|||
|
||||
export interface EditToolArgs {
|
||||
filepath: string;
|
||||
new_contents: string;
|
||||
changes: string;
|
||||
}
|
||||
|
||||
export const editFileTool: Tool = {
|
||||
|
|
@ -20,16 +20,17 @@ export const editFileTool: Tool = {
|
|||
"Use this tool to edit an existing file. If you don't know the contents of the file, read it first.",
|
||||
parameters: {
|
||||
type: "object",
|
||||
required: ["filepath", "new_contents"],
|
||||
required: ["filepath", "changes"],
|
||||
properties: {
|
||||
filepath: {
|
||||
type: "string",
|
||||
description:
|
||||
"The path of the file to edit, relative to the root of the workspace.",
|
||||
},
|
||||
new_contents: {
|
||||
changes: {
|
||||
type: "string",
|
||||
description: "The new file contents",
|
||||
description:
|
||||
"Any modifications to the file, showing only needed changes. Do NOT wrap this in a codeblock. Use brief language-appropriate placeholders for large unmodified sections, e.g. '// ... rest of code here ...'",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -6,12 +6,12 @@ import { useAppSelector } from "../../../redux/hooks";
|
|||
|
||||
type EditToolCallProps = {
|
||||
relativeFilePath: string;
|
||||
newContents: string;
|
||||
changes: string;
|
||||
toolCallId?: string;
|
||||
};
|
||||
|
||||
export function EditFile(props: EditToolCallProps) {
|
||||
const src = `\`\`\`${getMarkdownLanguageTagForFile(props.relativeFilePath ?? "test.txt")} ${props.relativeFilePath}\n${props.newContents ?? ""}\n\`\`\``;
|
||||
const src = `\`\`\`${getMarkdownLanguageTagForFile(props.relativeFilePath ?? "test.txt")} ${props.relativeFilePath}\n${props.changes ?? ""}\n\`\`\``;
|
||||
|
||||
const isStreaming = useAppSelector((state) => state.session.isStreaming);
|
||||
const states = useAppSelector((store) => store.session.codeBlockApplyStates);
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ function FunctionSpecificToolCallDiv({
|
|||
return (
|
||||
<EditFile
|
||||
relativeFilePath={args.filepath}
|
||||
newContents={args.new_contents}
|
||||
changes={args.changes}
|
||||
toolCallId={toolCall.id}
|
||||
/>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ export const editToolImpl: ClientToolImpl = async (
|
|||
}
|
||||
const apply = await extras.ideMessenger.request("applyToFile", {
|
||||
streamId: extras.activeToolStreamId,
|
||||
text: args.new_contents,
|
||||
text: args.changes,
|
||||
toolCallId,
|
||||
filepath: firstUriMatch,
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue