fix(3088): append missing STATE narrative sections on milestone close

This commit is contained in:
Tom Boucher
2026-05-04 23:29:45 -04:00
parent 2dcf374da0
commit 67684626d8
4 changed files with 44 additions and 8 deletions

View File

@@ -215,13 +215,20 @@ function cmdMilestoneComplete(cwd, version, options, raw) {
`Last activity: ${today} — Milestone ${version} completed and archived\n\n`;
if (positionPattern.test(stateContent)) {
stateContent = stateContent.replace(positionPattern, (_m, header) => `${header}${closedPositionBody}`);
} else {
stateContent = `${stateContent.trimEnd()}\n\n## Current Position\n${closedPositionBody}`;
}
// Normalize operator-next-step tails that can become stale after close.
stateContent = stateContent.replace(
/(##\s*Operator Next Steps\s*\n)([\s\S]*?)(?=\n##|$)/i,
`$1\n- Start the next milestone with /gsd-new-milestone\n\n`,
);
const operatorPattern = /(##\s*Operator Next Steps\s*\n)([\s\S]*?)(?=\n##|$)/i;
if (operatorPattern.test(stateContent)) {
stateContent = stateContent.replace(
operatorPattern,
`$1\n- Start the next milestone with /gsd-new-milestone\n\n`,
);
} else {
stateContent = `${stateContent.trimEnd()}\n\n## Operator Next Steps\n\n- Start the next milestone with /gsd-new-milestone\n`;
}
writeStateMd(statePath, stateContent, cwd);
}