(toolUseResult)
| 1736 | } |
| 1737 | |
| 1738 | function extractDiffBundle(toolUseResult) { |
| 1739 | const candidates = collectFileEditResults(toolUseResult) |
| 1740 | if (candidates.length === 0) { |
| 1741 | return null |
| 1742 | } |
| 1743 | |
| 1744 | const files = new Map() |
| 1745 | let totalAdded = 0 |
| 1746 | let totalRemoved = 0 |
| 1747 | |
| 1748 | for (const result of candidates) { |
| 1749 | const structuredPatch = |
| 1750 | Array.isArray(result.structuredPatch) && result.structuredPatch.length > 0 |
| 1751 | ? result.structuredPatch |
| 1752 | : result.type === 'create' && typeof result.content === 'string' |
| 1753 | ? buildSyntheticCreatePatch(result.content) |
| 1754 | : [] |
| 1755 | |
| 1756 | const counts = countPatchLines(structuredPatch) |
| 1757 | totalAdded += counts.added |
| 1758 | totalRemoved += counts.removed |
| 1759 | |
| 1760 | files.set(result.filePath, { |
| 1761 | filePath: result.filePath, |
| 1762 | isNewFile: result.type === 'create', |
| 1763 | linesAdded: counts.added, |
| 1764 | linesRemoved: counts.removed, |
| 1765 | patchPreview: buildPatchPreview(structuredPatch), |
| 1766 | }) |
| 1767 | } |
| 1768 | |
| 1769 | return { |
| 1770 | files: [...files.values()], |
| 1771 | stats: { |
| 1772 | filesChanged: files.size, |
| 1773 | linesAdded: totalAdded, |
| 1774 | linesRemoved: totalRemoved, |
| 1775 | }, |
| 1776 | } |
| 1777 | } |
| 1778 | |
| 1779 | function summarizeDiffBundle(diff) { |
| 1780 | if (!diff) { |
no test coverage detected