| 550 | } |
| 551 | |
| 552 | function formatPatchFailureMessage(params: { |
| 553 | path: string |
| 554 | attemptedStrategies: string[] |
| 555 | lastError?: string |
| 556 | }): string { |
| 557 | const { path, attemptedStrategies, lastError } = params |
| 558 | |
| 559 | return [ |
| 560 | `Failed to apply patch to ${path}.`, |
| 561 | attemptedStrategies.length > 0 |
| 562 | ? `Tried strategies: ${attemptedStrategies.join(', ')}.` |
| 563 | : undefined, |
| 564 | lastError ? `Last error: ${lastError}.` : undefined, |
| 565 | 'Please re-read the file and generate a patch with exact context lines.', |
| 566 | ] |
| 567 | .filter(Boolean) |
| 568 | .join(' ') |
| 569 | } |
| 570 | |
| 571 | function successResult(file: string, action: PatchAction): ApplyPatchJson { |
| 572 | return { |