fix(#1591): match bold checklist phase markers in isLastPhase fallback
The #1591 checkbox broadening matched `- [ ] Phase N:` but not the
canonical bold form the roadmap template emits (`- [ ] **Phase N: Name**`),
so a <details>-wrapped bold checklist with no next-phase directory still
fell through to is_last_phase=true and a false 'Milestone complete'. Allow
optional **/__ emphasis after the marker and stop the name capture at
emphasis so bold names slug cleanly. Surfaced by adversarial (codex) review.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
(cherry picked from commit ad94b38a69)
This commit is contained in:
@@ -1649,15 +1649,18 @@ function cmdPhaseComplete(cwd: string, phaseNum: string, raw: boolean): void {
|
||||
try {
|
||||
const roadmapForPhases = extractCurrentMilestone(roadmapContent, cwd);
|
||||
// #1591: match BOTH heading-style phases (`### Phase N:`) AND
|
||||
// checkbox-list items (`- [ ] Phase N:` / `- [x] Phase N:`). When
|
||||
// the active milestone's checklist is `- [ ]` items inside a
|
||||
// <details> block (and the next phase has no directory yet, so the
|
||||
// disk-based resolver finds nothing), this roadmap-enumeration
|
||||
// fallback is the only path that can find the next phase. The prior
|
||||
// heading-only pattern missed checkbox items → is_last_phase=true on
|
||||
// a mid-milestone phase. The marker alternation is the only change;
|
||||
// the number/name captures are unchanged.
|
||||
const phasePattern = /(?:#{2,4}|-\s*\[[ xX]\])\s*Phase\s+(\d+[A-Z]?(?:\.\d+)*)\s*:\s*([^\n]+)/gi;
|
||||
// checkbox-list items, INCLUDING the canonical bold form the roadmap
|
||||
// template emits (`- [ ] **Phase N: Name**`). When the active
|
||||
// milestone's checklist is `- [ ]` items inside a <details> block
|
||||
// (and the next phase has no directory yet, so the disk-based
|
||||
// resolver finds nothing), this roadmap-enumeration fallback is the
|
||||
// only path that can find the next phase. The prior heading-only
|
||||
// pattern missed checkbox items, and a checkbox-only broadening still
|
||||
// missed the bold template rows → is_last_phase=true on a mid-milestone
|
||||
// phase. Allow optional `**`/`__` emphasis after the marker and stop
|
||||
// the name capture at emphasis so bold names slug cleanly; the number
|
||||
// capture is unchanged.
|
||||
const phasePattern = /(?:#{2,4}|-\s*\[[ xX]\])\s*(?:\*\*|__)?\s*Phase\s+(\d+[A-Z]?(?:\.\d+)*)\s*:\s*([^\n*]+)/gi;
|
||||
let pm: RegExpExecArray | null;
|
||||
while ((pm = phasePattern.exec(roadmapForPhases)) !== null) {
|
||||
if (comparePhaseNum(pm[1], phaseNum) > 0) {
|
||||
|
||||
Reference in New Issue
Block a user