(patch: StructuredPatchHunk[])
| 493 | } |
| 494 | |
| 495 | export function getEditsForPatch(patch: StructuredPatchHunk[]): FileEdit[] { |
| 496 | return patch.map(hunk => { |
| 497 | // Extract the changes from this hunk |
| 498 | const contextLines: string[] = [] |
| 499 | const oldLines: string[] = [] |
| 500 | const newLines: string[] = [] |
| 501 | |
| 502 | // Parse each line and categorize it |
| 503 | for (const line of hunk.lines) { |
| 504 | if (line.startsWith(' ')) { |
| 505 | // Context line - appears in both versions |
| 506 | contextLines.push(line.slice(1)) |
| 507 | oldLines.push(line.slice(1)) |
| 508 | newLines.push(line.slice(1)) |
| 509 | } else if (line.startsWith('-')) { |
| 510 | // Deleted line - only in old version |
| 511 | oldLines.push(line.slice(1)) |
| 512 | } else if (line.startsWith('+')) { |
| 513 | // Added line - only in new version |
| 514 | newLines.push(line.slice(1)) |
| 515 | } |
| 516 | } |
| 517 | |
| 518 | return { |
| 519 | old_string: oldLines.join('\n'), |
| 520 | new_string: newLines.join('\n'), |
| 521 | replace_all: false, |
| 522 | } |
| 523 | }) |
| 524 | } |
| 525 | |
| 526 | /** |
| 527 | * Contains replacements to de-sanitize strings from Claude |
no test coverage detected