Skip to content

Commit 5e5c69a

Browse files
roomotehannesrudolph
authored andcommitted
Fixes #5206: Update apply_diff tool documentation to accurately reflect multi-file capabilities (#5232)
* Fixes #5206 * Fix failing test: Update snapshot after documentation changes - Updated system-prompt.spec.ts snapshot to match new tool descriptions - Changes reflect updated multi-file diff strategy documentation - Addresses test failure mentioned in PR #5232 comment by @mrubens
1 parent 687ce40 commit 5e5c69a

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

src/core/diff/strategies/multi-file-search-replace.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ export class MultiFileSearchReplaceDiffStrategy implements DiffStrategy {
9595
9696
Description: Request to apply targeted modifications to one or more files by searching for specific sections of content and replacing them. This tool supports both single-file and multi-file operations, allowing you to make changes across multiple files in a single request.
9797
98+
**IMPORTANT: You MUST use multiple files in a single operation whenever possible to maximize efficiency and minimize back-and-forth.**
99+
98100
You can perform multiple distinct search and replace operations within a single \`apply_diff\` call by providing multiple SEARCH/REPLACE blocks in the \`diff\` parameter. This is the preferred way to make several targeted changes efficiently.
99101
100102
The SEARCH section must exactly match existing content including whitespace and indentation.
@@ -157,7 +159,7 @@ def calculate_total(items):
157159
</args>
158160
</apply_diff>
159161
160-
Search/Replace content with multi edits in one file:
162+
Search/Replace content with multi edits across multiple files:
161163
<apply_diff>
162164
<args>
163165
<file>

src/core/diff/strategies/multi-search-replace.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export class MultiSearchReplaceDiffStrategy implements DiffStrategy {
9393
getToolDescription(args: { cwd: string; toolOptions?: { [key: string]: string } }): string {
9494
return `## apply_diff
9595
Description: Request to apply targeted modifications to an existing file by searching for specific sections of content and replacing them. This tool is ideal for precise, surgical edits when you know the exact content to change. It helps maintain proper indentation and formatting.
96-
You can perform multiple distinct search and replace operations within a single \`apply_diff\` call by providing multiple SEARCH/REPLACE blocks in the \`diff\` parameter. This is the preferred way to make several targeted changes to one file efficiently.
96+
You can perform multiple distinct search and replace operations within a single \`apply_diff\` call by providing multiple SEARCH/REPLACE blocks in the \`diff\` parameter. This is the preferred way to make several targeted changes efficiently.
9797
The SEARCH section must exactly match existing content including whitespace and indentation.
9898
If you're not confident in the exact content to search for, use the read_file tool first to get the exact content.
9999
When applying the diffs, be extra careful to remember to change any closing brackets or other syntax that may be affected by the diff farther down in the file.
@@ -145,7 +145,7 @@ def calculate_total(items):
145145
146146
\`\`\`
147147
148-
Search/Replace content with multi edits:
148+
Search/Replace content with multiple edits:
149149
\`\`\`
150150
<<<<<<< SEARCH
151151
:start_line:1

src/core/prompts/__tests__/__snapshots__/system-prompt/with-diff-enabled-true.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ Examples:
168168

169169
## apply_diff
170170
Description: Request to apply targeted modifications to an existing file by searching for specific sections of content and replacing them. This tool is ideal for precise, surgical edits when you know the exact content to change. It helps maintain proper indentation and formatting.
171-
You can perform multiple distinct search and replace operations within a single `apply_diff` call by providing multiple SEARCH/REPLACE blocks in the `diff` parameter. This is the preferred way to make several targeted changes to one file efficiently.
171+
You can perform multiple distinct search and replace operations within a single `apply_diff` call by providing multiple SEARCH/REPLACE blocks in the `diff` parameter. This is the preferred way to make several targeted changes efficiently.
172172
The SEARCH section must exactly match existing content including whitespace and indentation.
173173
If you're not confident in the exact content to search for, use the read_file tool first to get the exact content.
174174
When applying the diffs, be extra careful to remember to change any closing brackets or other syntax that may be affected by the diff farther down in the file.
@@ -220,7 +220,7 @@ def calculate_total(items):
220220

221221
```
222222

223-
Search/Replace content with multi edits:
223+
Search/Replace content with multiple edits:
224224
```
225225
<<<<<<< SEARCH
226226
:start_line:1

0 commit comments

Comments
 (0)