Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/core/diff/strategies/new-unified/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ 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
- Start new hunks for logically separate changes
- Keep related modifications in the same chunk
- Start new chunks for logically separate changes
- When modifying functions/methods, include the entire block

## Requirements:
Expand Down Expand Up @@ -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.",
}
}

Expand All @@ -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
Expand Down Expand Up @@ -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"
Expand All @@ -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) {
Expand Down
12 changes: 6 additions & 6 deletions src/core/diff/strategies/unified.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down