Skip to content

Commit ff7b957

Browse files
committed
merge main
2 parents caf5b56 + e925e7b commit ff7b957

File tree

1 file changed

+7
-17
lines changed

1 file changed

+7
-17
lines changed

core/tools/definitions/searchAndReplaceInFile.ts

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ export interface SearchAndReplaceInFileArgs {
1010
export const NO_PARALLEL_TOOL_CALLING_INSRUCTION =
1111
"Note this tool CANNOT be called in parallel.";
1212

13-
const SEARCH_AND_REPLACE_TOOL_DESCRIPTION = `Request to replace sections of content in an existing file using multiple SEARCH/REPLACE blocks that define exact changes to specific parts of the file. This tool should be used when you need to make targeted changes to specific parts of a file. ${NO_PARALLEL_TOOL_CALLING_INSRUCTION}`;
14-
const SEARCH_AND_REPLACE_FILEPATH_DESCRIPTION =
15-
"The path of the file to modify, relative to the root of the workspace.";
1613
const SEARCH_AND_REPLACE_EXAMPLE_BLOCK = `------- SEARCH
1714
[exact content to find]
1815
=======
@@ -39,7 +36,8 @@ const SEARCH_AND_REPLACE_RULES = `Critical rules:
3936
* DO NOT make back-to-back tool calls. Instead interleave with brief explanation of what each will do. For example, instead of [explanation, tool call, tool call] you should do [explanation, tool call, explanation, tool call]
4037
6. Special operations:
4138
* To move code: Use two SEARCH/REPLACE blocks (one to delete from original + one to insert at new location)
42-
* To delete code: Use empty REPLACE section`;
39+
* To delete code: Use empty REPLACE section
40+
7. You should always read the file before trying to edit it, to ensure you know the up-to-date file contents`;
4341

4442
const SEARCH_AND_REPLACE_DIFFS_DESCRIPTION = `An array of strings, each containing one or more SEARCH/REPLACE blocks following this exact format:
4543
\`\`\`
@@ -72,14 +70,14 @@ export const searchAndReplaceInFileTool: Tool = {
7270
isInstant: false,
7371
function: {
7472
name: BuiltInToolNames.SearchAndReplaceInFile,
75-
description: SEARCH_AND_REPLACE_TOOL_DESCRIPTION,
73+
description: `Request to replace sections of content in an existing file using multiple SEARCH/REPLACE blocks that define exact changes to specific parts of the file. This tool should be used when you need to make targeted changes to specific parts of a file. ${NO_PARALLEL_TOOL_CALLING_INSRUCTION}`,
7674
parameters: {
7775
type: "object",
7876
required: ["filepath", "diffs"],
7977
properties: {
8078
filepath: {
8179
type: "string",
82-
description: SEARCH_AND_REPLACE_FILEPATH_DESCRIPTION,
80+
description: `The path of the file to modify, relative to the root of the workspace.`,
8381
},
8482
diffs: {
8583
type: "array",
@@ -92,7 +90,7 @@ export const searchAndReplaceInFileTool: Tool = {
9290
},
9391
},
9492
systemMessageDescription: {
95-
prefix: `To make targeted edits by replacing sections of content in an existing file, use the ${BuiltInToolNames.SearchAndReplaceInFile} tool with a "diffs" argument containing an array of SEARCH/REPLACE blocks that define exact changes to specific parts of the file.
93+
prefix: `To make targeted edits by replacing sections of content in an existing file, use the ${BuiltInToolNames.SearchAndReplaceInFile} tool with a filepath (relative to the root of the workspace) and a "diffs" argument containing an array of SEARCH/REPLACE blocks that define exact changes to specific parts of the file.
9694
Each block should follow this format:
9795
${SEARCH_AND_REPLACE_EXAMPLE_BLOCK}
9896
@@ -104,16 +102,8 @@ ${SEARCH_AND_REPLACE_RULES}
104102
[
105103
"diffs",
106104
`[
107-
"------- SEARCH
108-
[exact content to find]
109-
=======
110-
[new content to replace with]
111-
+++++++ REPLACE",
112-
"------- SEARCH
113-
[exact content to find]
114-
=======
115-
[new content to replace with]
116-
+++++++ REPLACE"
105+
"${SEARCH_AND_REPLACE_EXAMPLE_BLOCK}",
106+
"${SEARCH_AND_REPLACE_EXAMPLE_BLOCK}"
117107
]`,
118108
],
119109
],

0 commit comments

Comments
 (0)