From d02e7cbf4fd8636376ac962b99880c29eea15edf Mon Sep 17 00:00:00 2001 From: Bhartendu Kumar Date: Mon, 24 Mar 2025 04:31:15 +0530 Subject: [PATCH 1/4] fixed a type in Roo-Code/src/core/diff/strategies/new-unified/index.ts (hunk changed to chunk) in the section: # apply_diff Tool - Generate Precise Code Changes in point 3, changed from 3. Group related changes: - Keep related modifications in the same hunk to 3. Group related changes: - Keep related modifications in the same chunk --- src/core/diff/strategies/new-unified/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/diff/strategies/new-unified/index.ts b/src/core/diff/strategies/new-unified/index.ts index 5b385616f6f..04ad6266d0b 100644 --- a/src/core/diff/strategies/new-unified/index.ts +++ b/src/core/diff/strategies/new-unified/index.ts @@ -130,7 +130,7 @@ Generate a unified diff that can be cleanly applied to modify code files. - Preserve exact indentation 3. Group related changes: - - Keep related modifications in the same hunk + - Keep related modifications in the same chunk - Start new hunks for logically separate changes - When modifying functions/methods, include the entire block From 1854c5da218ad037199d3140a340d9499d48c59f Mon Sep 17 00:00:00 2001 From: Bhartendu Kumar Date: Tue, 25 Mar 2025 09:49:21 +0530 Subject: [PATCH 2/4] Update index.ts, typo in hunk -> chunk in system prompt for unified diff edit "hunk" is used in this whole file for "chunk". But for function names and variables it is ok. When the hard coded system prompt to be sent for LLMs contains "hunk" for "chunk". Then better to correct this typo atleast in system prompt. --- src/core/diff/strategies/new-unified/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/diff/strategies/new-unified/index.ts b/src/core/diff/strategies/new-unified/index.ts index 04ad6266d0b..07e93675af1 100644 --- a/src/core/diff/strategies/new-unified/index.ts +++ b/src/core/diff/strategies/new-unified/index.ts @@ -131,7 +131,7 @@ Generate a unified diff that can be cleanly applied to modify code files. 3. Group related changes: - Keep related modifications in the same chunk - - Start new hunks for logically separate changes + - Start new chunks for logically separate changes - When modifying functions/methods, include the entire block ## Requirements: From 68bf1b5741f45e8364efe88b976607fcdea8c8a6 Mon Sep 17 00:00:00 2001 From: Bhartendu Kumar Date: Tue, 25 Mar 2025 09:54:44 +0530 Subject: [PATCH 3/4] Update index.ts, typo "hunk" -> "chunk" changed in System prompt and error messages. Retained hunk in function, variables names. Retained typo "hunk" in variables and functions. But the System prompt for unified diff edit, that goes to LLMs and the error messages, changed the typo. --- src/core/diff/strategies/new-unified/index.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/core/diff/strategies/new-unified/index.ts b/src/core/diff/strategies/new-unified/index.ts index 07e93675af1..cc72da25510 100644 --- a/src/core/diff/strategies/new-unified/index.ts +++ b/src/core/diff/strategies/new-unified/index.ts @@ -246,7 +246,7 @@ Your diff here if (!parsedDiff.hunks.length) { return { success: false, - error: "No hunks found in diff. Please ensure your diff includes actual changes and follows the unified diff format.", + error: "No chunks found in diff. Please ensure your diff includes actual changes and follows the unified diff format.", } } @@ -259,7 +259,7 @@ Your diff here } = findBestMatch(contextStr, result, 0, this.confidenceThreshold) if (confidence < this.confidenceThreshold) { - console.log("Full hunk application failed, trying sub-hunks strategy") + console.log("Full chunk application failed, trying sub-chunks strategy") // Try splitting the hunk into smaller hunks const subHunks = this.splitHunk(hunk) let subHunkSuccess = true @@ -304,7 +304,7 @@ Your diff here errorMsg += `- Context Lines: ${contextLines} out of ${totalLines} total lines (${Math.floor( contextRatio * 100, )}%)\n` - errorMsg += `- Attempted to split into ${subHunks.length} sub-hunks but still failed\n` + errorMsg += `- Attempted to split into ${subHunks.length} sub-chunks but still failed\n` if (contextRatio < 0.2) { errorMsg += "\nPossible Issues:\n" @@ -318,7 +318,7 @@ Your diff here errorMsg += "\nPossible Issues:\n" errorMsg += "- The diff may be targeting a different version of the file\n" errorMsg += - "- There may be too many changes in a single hunk, try splitting the changes into multiple hunks\n" + "- There may be too many changes in a single chunk, try splitting the changes into multiple chunks\n" } if (startLine && endLine) { From 73b573caa603668f631c9e792cdb6681bb3d7fa9 Mon Sep 17 00:00:00 2001 From: Bhartendu Kumar Date: Tue, 25 Mar 2025 09:59:32 +0530 Subject: [PATCH 4/4] Update unified.ts, "hunk" -> "chunk" Changed hunk to chunk in the System prompt for unified diff edit , as this will be sent to LLMs. Rest in function calls and variables, did not change. as that's not affecting performance. --- src/core/diff/strategies/unified.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/core/diff/strategies/unified.ts b/src/core/diff/strategies/unified.ts index f4d6ead6aab..e3ae8642d9c 100644 --- a/src/core/diff/strategies/unified.ts +++ b/src/core/diff/strategies/unified.ts @@ -24,13 +24,13 @@ Format Requirements: - Use actual file paths - NO timestamps after paths -2. Hunks: +2. Chunks: \`\`\` @@ -lineStart,lineCount +lineStart,lineCount @@ -removed line +added line \`\`\` - - Each hunk starts with @@ showing line numbers for changes + - Each chunk starts with @@ showing line numbers for changes - Format: @@ -originalStart,originalCount +newStart,newCount @@ - Use - for removed/changed lines - Use + for new/modified lines @@ -96,10 +96,10 @@ Best Practices: - Remove complete old version with - lines - Add complete new version with + lines - Include correct line numbers -2. Moving code requires two hunks: - - First hunk: Remove from old location - - Second hunk: Add to new location -3. One hunk per logical change +2. Moving code requires two chunks: + - First chunk: Remove from old location + - Second chunk: Add to new location +3. One chunk per logical change 4. Verify line numbers match the line numbers you have in the file Usage: