Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions get-shit-done/bin/lib/phase.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -346,11 +346,13 @@ function cmdPhaseAdd(cwd, description, raw, customId) {
dirName = `${prefix}${newPhaseId}-${slug}`;
} else {
// Sequential mode: find highest integer phase number (in current milestone only)
// Skip 999.x backlog phases β€” they live outside the active sequence
const phasePattern = /#{2,4}\s*Phase\s+(\d+)[A-Z]?(?:\.\d+)*:/gi;
let maxPhase = 0;
let m;
while ((m = phasePattern.exec(content)) !== null) {
const num = parseInt(m[1], 10);
if (num >= 999) continue; // backlog phases use 999.x numbering
if (num > maxPhase) maxPhase = num;
}

Expand Down
37 changes: 37 additions & 0 deletions tests/phase.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,43 @@ describe('phase add command', () => {
const roadmap = fs.readFileSync(path.join(tmpDir, '.planning', 'ROADMAP.md'), 'utf-8');
assert.ok(roadmap.includes('**Requirements**: TBD'), 'new phase entry should include Requirements TBD');
});

test('skips 999.x backlog phases when calculating next phase number', () => {
fs.writeFileSync(
path.join(tmpDir, '.planning', 'ROADMAP.md'),
`# Roadmap v1.0

### Phase 1: Foundation
**Goal:** Setup

### Phase 2: API
**Goal:** Build API

### Phase 3: UI
**Goal:** Build UI

### Phase 999.1: Future Idea A
**Goal:** Backlog item

### Phase 999.2: Future Idea B
**Goal:** Backlog item

---
`
);

const result = runGsdTools('phase add Dashboard', tmpDir);
assert.ok(result.success, `Command failed: ${result.error}`);

const output = JSON.parse(result.output);
assert.strictEqual(output.phase_number, 4, 'should be phase 4, not 1000');
assert.strictEqual(output.slug, 'dashboard');

assert.ok(
fs.existsSync(path.join(tmpDir, '.planning', 'phases', '04-dashboard')),
'directory should be 04-dashboard, not 1000-dashboard'
);
});
});

// ─────────────────────────────────────────────────────────────────────────────
Expand Down