| 540 | } |
| 541 | |
| 542 | function summarizePlanUpdate(text: string) { |
| 543 | const taskMatches = [...text.matchAll(/\[[ xX]\]/g)]; |
| 544 | if (taskMatches.length > 0) { |
| 545 | const completed = taskMatches.filter((match) => |
| 546 | match[0].toLowerCase().includes("x"), |
| 547 | ).length; |
| 548 | return `${completed}/${taskMatches.length} complete`; |
| 549 | } |
| 550 | |
| 551 | const stepCount = text |
| 552 | .split(/\r?\n/) |
| 553 | .filter((line) => /^\s*(?:[-*]|\d+[.)])\s+\S/.test(line)).length; |
| 554 | return stepCount > 0 ? `${stepCount} step${stepCount === 1 ? "" : "s"}` : ""; |
| 555 | } |
| 556 | |
| 557 | function upsertMetadata( |
| 558 | d: TranscriptDraft, |