| 55 | } |
| 56 | |
| 57 | function updateLoop(projectRoot, id, patch = {}, options = {}) { |
| 58 | const current = readLoop(projectRoot, id); |
| 59 | if (!current) throw new Error(`Loop not found: ${id}`); |
| 60 | const updated = { |
| 61 | ...current, |
| 62 | ...patch, |
| 63 | status: patch.status ? normalizeStatus(patch.status) : current.status, |
| 64 | updatedAt: nowIso(options), |
| 65 | }; |
| 66 | writeJson(loopPath(projectRoot, id), updated); |
| 67 | return updated; |
| 68 | } |
| 69 | |
| 70 | function appendLoopRun(projectRoot, id, run = {}, options = {}) { |
| 71 | const current = readLoop(projectRoot, id); |