fix(roadmap): handle 5-column progress tables with Milestone column
The regex-based table parser captured a fixed number of columns,
so 5-column tables (Phase | Milestone | Plans | Status | Completed)
had the Milestone column eaten and Status/Date written to wrong cells.
Replaced regex with cell-based `split('|')` parsing that detects
column count (4 or 5) and updates the correct cells by index.
Affects both `cmdRoadmapUpdatePlanProgress` and `cmdPhaseComplete`.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1468,6 +1468,46 @@ describe('phase complete command', () => {
|
||||
const req = fs.readFileSync(path.join(tmpDir, '.planning', 'REQUIREMENTS.md'), 'utf-8');
|
||||
assert.ok(req.includes('- [ ] **AMT-01**'), 'AMT-01 should remain unchanged');
|
||||
});
|
||||
|
||||
test('preserves Milestone column in 5-column progress table', () => {
|
||||
fs.writeFileSync(
|
||||
path.join(tmpDir, '.planning', 'ROADMAP.md'),
|
||||
`# Roadmap
|
||||
|
||||
- [ ] Phase 1: Foundation
|
||||
|
||||
### Phase 1: Foundation
|
||||
**Goal:** Setup
|
||||
**Plans:** 1 plans
|
||||
|
||||
## Progress
|
||||
|
||||
| Phase | Milestone | Plans Complete | Status | Completed |
|
||||
|-------|-----------|----------------|--------|-----------|
|
||||
| 1. Foundation | v1.0 | 0/1 | Planned | |
|
||||
`
|
||||
);
|
||||
fs.writeFileSync(
|
||||
path.join(tmpDir, '.planning', 'STATE.md'),
|
||||
`# State\n\n**Current Phase:** 01\n**Status:** In progress\n**Current Plan:** 01-01\n**Last Activity:** 2025-01-01\n**Last Activity Description:** Working\n`
|
||||
);
|
||||
|
||||
const p1 = path.join(tmpDir, '.planning', 'phases', '01-foundation');
|
||||
fs.mkdirSync(p1, { recursive: true });
|
||||
fs.writeFileSync(path.join(p1, '01-01-PLAN.md'), '# Plan');
|
||||
fs.writeFileSync(path.join(p1, '01-01-SUMMARY.md'), '# Summary');
|
||||
|
||||
const result = runGsdTools('phase complete 1', tmpDir);
|
||||
assert.ok(result.success, `Command failed: ${result.error}`);
|
||||
|
||||
const roadmap = fs.readFileSync(path.join(tmpDir, '.planning', 'ROADMAP.md'), 'utf-8');
|
||||
const rowMatch = roadmap.match(/^\|[^\n]*1\. Foundation[^\n]*$/m);
|
||||
assert.ok(rowMatch, 'table row should exist');
|
||||
const cells = rowMatch[0].split('|').slice(1, -1).map(c => c.trim());
|
||||
assert.strictEqual(cells.length, 5, 'should have 5 columns');
|
||||
assert.strictEqual(cells[1], 'v1.0', 'Milestone column should be preserved');
|
||||
assert.ok(cells[3].includes('Complete'), 'Status column should be Complete');
|
||||
});
|
||||
});
|
||||
|
||||
// ─────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -792,6 +792,38 @@ describe('roadmap update-plan-progress command', () => {
|
||||
assert.ok(roadmap.includes('[ ] 50-02-PLAN.md') || roadmap.includes('[ ] 50-02'),
|
||||
'incomplete plan checkbox should remain unchecked');
|
||||
});
|
||||
|
||||
test('preserves Milestone column in 5-column progress table', () => {
|
||||
const roadmapContent = `# Roadmap
|
||||
|
||||
### Phase 50: Build
|
||||
**Goal:** Build stuff
|
||||
**Plans:** 1 plans
|
||||
|
||||
## Progress
|
||||
|
||||
| Phase | Milestone | Plans Complete | Status | Completed |
|
||||
|-------|-----------|----------------|--------|-----------|
|
||||
| 50. Build | v2.0 | 0/1 | Planned | |
|
||||
`;
|
||||
fs.writeFileSync(path.join(tmpDir, '.planning', 'ROADMAP.md'), roadmapContent);
|
||||
|
||||
const p50 = path.join(tmpDir, '.planning', 'phases', '50-build');
|
||||
fs.mkdirSync(p50, { recursive: true });
|
||||
fs.writeFileSync(path.join(p50, '50-01-PLAN.md'), '# Plan');
|
||||
fs.writeFileSync(path.join(p50, '50-01-SUMMARY.md'), '# Summary');
|
||||
|
||||
const result = runGsdTools('roadmap update-plan-progress 50', tmpDir);
|
||||
assert.ok(result.success, `Command failed: ${result.error}`);
|
||||
|
||||
const roadmap = fs.readFileSync(path.join(tmpDir, '.planning', 'ROADMAP.md'), 'utf-8');
|
||||
const rowMatch = roadmap.match(/^\|[^\n]*50\. Build[^\n]*$/m);
|
||||
assert.ok(rowMatch, 'table row should exist');
|
||||
const cells = rowMatch[0].split('|').slice(1, -1).map(c => c.trim());
|
||||
assert.strictEqual(cells.length, 5, 'should have 5 columns');
|
||||
assert.strictEqual(cells[1], 'v2.0', 'Milestone column should be preserved');
|
||||
assert.ok(cells[3].includes('Complete'), 'Status column should show Complete');
|
||||
});
|
||||
});
|
||||
|
||||
// ─────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user