Skip to content

Commit 1d799ea

Browse files
committed
refactor: move single block warning to notice section and make more concise
- Move warning from prepended text to notice tag format - Remove 'for the LLM' phrase to make message more concise - Add same warning logic to multiApplyDiffTool for consistency - Warning now appears as a notice after the main result message
1 parent dd7a9d3 commit 1d799ea

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

src/core/tools/applyDiffTool.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,15 +190,15 @@ export async function applyDiffToolLegacy(
190190

191191
// Check for single SEARCH/REPLACE block warning
192192
const searchBlocks = (diffContent.match(/<<<<<<< SEARCH/g) || []).length
193-
const singleBlockWarning =
193+
const singleBlockNotice =
194194
searchBlocks === 1
195-
? "Making multiple related changes in a single apply_diff is more efficient for the LLM. If other changes are needed in this file, please include them as additional SEARCH/REPLACE blocks.\n\n"
195+
? "\n<notice>Making multiple related changes in a single apply_diff is more efficient. If other changes are needed in this file, please include them as additional SEARCH/REPLACE blocks.</notice>"
196196
: ""
197197

198198
if (partFailHint) {
199-
pushToolResult(partFailHint + message)
199+
pushToolResult(partFailHint + message + singleBlockNotice)
200200
} else {
201-
pushToolResult(singleBlockWarning + message)
201+
pushToolResult(message + singleBlockNotice)
202202
}
203203

204204
await cline.diffViewProvider.reset()

src/core/tools/multiApplyDiffTool.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -596,8 +596,22 @@ ${errorDetails ? `\nTechnical details:\n${errorDetails}\n` : ""}
596596
await cline.say("diff_error", allDiffErrors.join("\n"))
597597
}
598598

599+
// Check for single SEARCH/REPLACE block warning
600+
let totalSearchBlocks = 0
601+
for (const operation of operations) {
602+
for (const diffItem of operation.diff) {
603+
const searchBlocks = (diffItem.content.match(/<<<<<<< SEARCH/g) || []).length
604+
totalSearchBlocks += searchBlocks
605+
}
606+
}
607+
608+
const singleBlockNotice =
609+
totalSearchBlocks === 1
610+
? "\n<notice>Making multiple related changes in a single apply_diff is more efficient. If other changes are needed in this file, please include them as additional SEARCH/REPLACE blocks.</notice>"
611+
: ""
612+
599613
// Push the final result combining all operation results
600-
pushToolResult(results.join("\n\n"))
614+
pushToolResult(results.join("\n\n") + singleBlockNotice)
601615
return
602616
} catch (error) {
603617
await handleError("applying diff", error)

0 commit comments

Comments
 (0)