replaceInCurrentMilestone() locates content by finding the last </details> in the ROADMAP and only operates on text after that boundary. When the current (in-progress) milestone section is itself wrapped in a <details> block (the standard /gsd-new-project layout), the phase section's **Plans:** counter lives INSIDE that block. The replacement target ends up in the empty space after the block's closing </details>, so the regex never matches and the plan count stays at 0/N permanently. Fix: switch the plan count update to use direct .replace() on the full roadmapContent, consistent with the checkbox and progress table updates that already use this pattern. The phase-scoped heading regex (### Phase N: ...) is specific enough to avoid matching archived phases. Adds two regression tests covering: (1) plan count updates inside a <details>-wrapped current milestone, and (2) phase 2 plan count is not corrupted when completing phase 1.
This commit is contained in:
@@ -736,13 +736,20 @@ function cmdPhaseComplete(cwd, phaseNum, raw) {
|
||||
return '|' + cells.join('|') + '|';
|
||||
});
|
||||
|
||||
// Update plan count in phase section
|
||||
// Update plan count in phase section.
|
||||
// Use direct .replace() rather than replaceInCurrentMilestone() so this
|
||||
// works when the current milestone section is itself inside a <details>
|
||||
// block (the standard /gsd-new-project layout). replaceInCurrentMilestone
|
||||
// scopes to content after the last </details>, which misses content inside
|
||||
// the current milestone's own <details> wrapper (#2005).
|
||||
// The phase-scoped heading pattern is specific enough to avoid matching
|
||||
// archived phases (which belong to different milestones).
|
||||
const planCountPattern = new RegExp(
|
||||
`(#{2,4}\\s*Phase\\s+${phaseEscaped}[\\s\\S]*?\\*\\*Plans:\\*\\*\\s*)[^\\n]+`,
|
||||
'i'
|
||||
);
|
||||
roadmapContent = replaceInCurrentMilestone(
|
||||
roadmapContent, planCountPattern,
|
||||
roadmapContent = roadmapContent.replace(
|
||||
planCountPattern,
|
||||
`$1${summaryCount}/${planCount} plans complete`
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user