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