| 68 | |
| 69 | // Parser implementation |
| 70 | function parsePatchHeader( |
| 71 | lines: string[], |
| 72 | startIdx: number, |
| 73 | ): { filePath: string; movePath?: string; nextIdx: number } | null { |
| 74 | const line = lines[startIdx] |
| 75 | |
| 76 | if (line.startsWith("*** Add File:")) { |
| 77 | const filePath = line.slice("*** Add File:".length).trim() |
| 78 | return filePath ? { filePath, nextIdx: startIdx + 1 } : null |
| 79 | } |
| 80 | |
| 81 | if (line.startsWith("*** Delete File:")) { |
| 82 | const filePath = line.slice("*** Delete File:".length).trim() |
| 83 | return filePath ? { filePath, nextIdx: startIdx + 1 } : null |
| 84 | } |
| 85 | |
| 86 | if (line.startsWith("*** Update File:")) { |
| 87 | const filePath = line.slice("*** Update File:".length).trim() |
| 88 | let movePath: string | undefined |
| 89 | let nextIdx = startIdx + 1 |
| 90 | |
| 91 | // Check for move directive |
| 92 | if (nextIdx < lines.length && lines[nextIdx].startsWith("*** Move to:")) { |
| 93 | movePath = lines[nextIdx].slice("*** Move to:".length).trim() |
| 94 | nextIdx++ |
| 95 | } |
| 96 | |
| 97 | return filePath ? { filePath, movePath, nextIdx } : null |
| 98 | } |
| 99 | |
| 100 | return null |
| 101 | } |
| 102 | |
| 103 | function parseUpdateFileChunks(lines: string[], startIdx: number): { chunks: UpdateFileChunk[]; nextIdx: number } { |
| 104 | const chunks: UpdateFileChunk[] = [] |