cmdPhaseAdd computed maxPhase from ROADMAP.md only, allowing orphan directories on disk (untracked in roadmap) to silently collide with newly added phases. The new phase's mkdirSync succeeded against the existing directory, contaminating it with fresh content. Fix: take max(roadmapMax, diskMax) where diskMax scans .planning/phases/ and strips optional project_code prefix before parsing the leading integer. Backlog orphans (>=999) are skipped. Adds 3 regression tests covering: - orphan dir with number higher than roadmap max - prefixed orphan dirs (project_code-NN-slug) - no collision when orphan number is lower than roadmap max Fixes #2026 Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
87 KiB
87 KiB