fix(#2796): roadmap-update-plan-progress accepts --phase flag form (#2815)

* fix(#2796): roadmap update-plan-progress accepts --phase flag form

roadmap-update-plan-progress used positional-only arg parsing: args[0].
When execute-phase.md:228 calls it with --phase <N>, args[0] was the
literal string "--phase", which findPhase received as the phase number.
findPhase returned found:false, causing updated:false with no write.
ROADMAP.md plan checkboxes silently never advanced.

Fix: check for --phase <value> first; fall back to the first non-flag
positional argument for backward-compatible direct calls.

Regression test: tests/bug-2796-arg-parsing-regression.test.cjs

* fix(#2796): address CodeRabbit — guard --phase against flag-like values, bash fence
This commit is contained in:
Tom Boucher
2026-04-28 20:22:30 -04:00
committed by GitHub
parent b959b1844f
commit fa78692167
2 changed files with 170 additions and 1 deletions

View File

@@ -15,7 +15,23 @@ import { GSDError, ErrorClassification } from '../errors.js';
import type { QueryHandler } from './utils.js';
export const roadmapUpdatePlanProgress: QueryHandler = async (args, projectDir, workstream) => {
const phaseNum = args[0];
// Support --phase <N> flag form in addition to positional (fixes #2796).
// execute-phase.md:228 passes --phase so positional-only parsing silently
// took the literal string "--phase" as the phase value.
const phaseIdx = args.indexOf('--phase');
let phaseNum: string;
const phaseFlagValue = phaseIdx !== -1 ? args[phaseIdx + 1] : undefined;
if (
phaseIdx !== -1 &&
phaseFlagValue !== undefined &&
!String(phaseFlagValue).startsWith('--')
) {
phaseNum = String(phaseFlagValue);
} else {
// Positional: skip any leading flag tokens in case of mixed invocations.
const positional = args.filter((a) => !String(a).startsWith('--'));
phaseNum = positional[0] ? String(positional[0]) : '';
}
if (!phaseNum) {
throw new GSDError('phase number required for roadmap update-plan-progress', ErrorClassification.Validation);
}