refactor(#1782): ADR-1769 Phase 2 — advancePlan migration onto Transition Module (#1783)
Migrates cmdStateAdvancePlan (~80-line RMW callback) onto the
transitionCore dispatch established in Phase 1 (#1775):
- src/state-transition.cts:
- Add {kind: 'advancePlan'} to StateTransitionIntent union
- Extend StateTransitionResult with optional data field for
intent-specific output (advanced, currentPlan, totalPlans)
- advancePlanCore: parses legacy + compound plan formats, handles
advance vs phase-complete branching, strips frontmatter before
body mutation (#1255 pattern — codex Phase 2 HIGH finding),
uses stateReplaceFieldIfTemplate for template-default-aware
field replacement (Knuth invariant), mutates ## Current Position
section via mutateCurrentPositionForAdvance
- mutateCurrentPositionForAdvance: inlined section mutation (avoids
circular dep with state.cjs's updateCurrentPositionFields)
- src/state.cts:cmdStateAdvancePlan: collapsed to 30-line dispatch
- tests/state-transition.test.cjs: 5 characterization tests
(advance, phase-complete, error, compound format, frontmatter #1255)
Codex gpt-5.5/high review: 1 HIGH blocking (frontmatter strip — fixed),
1 medium follow-up (StateTransitionResult.data shape discrimination —
noted for Phases 3-7).
gsd-test: 21893/21893 PASS (Linux docker).
Closes #1782