Skip to content

Commit e1c8878

Browse files
authored
fix: edit tool prompt updates to encourage multi edits to avoid linting effects (#7998)
fix: prompt updates for linting effects
1 parent f97f4d0 commit e1c8878

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

core/tools/definitions/multiEdit.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { Tool } from "../..";
22
import { BUILT_IN_GROUP_NAME, BuiltInToolNames } from "../builtIn";
33
import { NO_PARALLEL_TOOL_CALLING_INSTRUCTION } from "./editFile";
4-
import { singleFindAndReplaceTool } from "./singleFindAndReplace";
54

65
export interface EditOperation {
76
old_string: string;
@@ -25,8 +24,7 @@ export const multiEditTool: Tool = {
2524
isInstant: false,
2625
function: {
2726
name: BuiltInToolNames.MultiEdit,
28-
description: `This is a tool for making multiple edits to a single file in one operation. It is built on top of the ${singleFindAndReplaceTool.function.name} and allows you to perform multiple find-and-replace operations efficiently.
29-
Prefer this tool over the ${singleFindAndReplaceTool.function.name} tool when you need to make multiple edits to the same file.
27+
description: `Use this tool to make multiple edits to a single file in one operation. It allows you to perform multiple find-and-replace operations efficiently.
3028
3129
To make multiple edits to a file, provide the following:
3230
1. filepath: The path to the file to modify, RELATIVE to the project/workspace root (verify the directory path is correct)
@@ -36,6 +34,7 @@ To make multiple edits to a file, provide the following:
3634
- replace_all: Replace all occurrences of old_string. This parameter is optional and defaults to false.
3735
3836
IMPORTANT:
37+
- Files may be modified between tool calls by users, linters, etc, so always make all edits in one tool call where possible. For example, do not only edit imports if there are other changes in the file, as unused imports may be removed by a linter between tool calls.
3938
- All edits are applied in sequence, in the order they are provided
4039
- Each edit operates on the result of the previous edit, so plan your edits carefully to avoid conflicts between sequential operations
4140
- Edits are atomic - all edits must be valid for the operation to succeed - if any edit fails, none will be applied

extensions/cli/src/tools/multiEdit.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
getLanguageFromFilePath,
1111
} from "../telemetry/utils.js";
1212

13-
import { validateAndResolveFilePath } from "./edit.js";
13+
import { editTool, validateAndResolveFilePath } from "./edit.js";
1414
import { readFileTool } from "./readFile.js";
1515
import { Tool } from "./types.js";
1616
import { generateDiff } from "./writeFile.js";
@@ -31,8 +31,8 @@ export const multiEditTool: Tool = {
3131
displayName: "MultiEdit",
3232
readonly: false,
3333
isBuiltIn: true,
34-
description: `This is a tool for making multiple edits to a single file in one operation. It allows you to perform multiple find-and-replace operations efficiently.
35-
This tool is ideal when you need to make multiple edits to the same file.
34+
description: `Use this tool to make multiple edits to a single file in one operation. It allows you to perform multiple find-and-replace operations efficiently.
35+
Prefer this tool over the ${editTool.name} tool when you need to make multiple edits to the same file.
3636
3737
To make multiple edits to a file, provide the following:
3838
1. file_path: The absolute path to the file to modify. Relative paths can also be used (resolved against cwd) but absolute is preferred
@@ -42,6 +42,7 @@ To make multiple edits to a file, provide the following:
4242
- replace_all: Replace all occurrences of old_string. This parameter is optional and defaults to false.
4343
4444
IMPORTANT:
45+
- Files may be modified between tool calls by users, linters, etc, so always make all edits in one tool call where possible. For example, do not only edit imports if there are other changes in the file, as unused imports may be removed by a linter between tool calls.
4546
- All edits are applied in sequence, in the order they are provided
4647
- Each edit operates on the result of the previous edit, so plan your edits carefully to avoid conflicts between sequential operations
4748
- Edits are atomic - all edits must be valid for the operation to succeed - if any edit fails, none will be applied

0 commit comments

Comments
 (0)