Merge pull request #3799 from mastertyko/fix/3778-parseplan-filename-task-ids

fix(gsd): ignore filename headings in parsePlan
This commit is contained in:
Jeremy McSpadden 2026-04-08 21:13:22 -05:00 committed by GitHub
commit 04d4ea1774
2 changed files with 28 additions and 1 deletions

View file

@ -210,7 +210,9 @@ function _parsePlanImpl(content: string): SlicePlan {
for (const line of lines) {
const cbMatch = line.match(/^-\s+\[([ xX])\]\s+\*\*([\w.]+):\s+(.+?)\*\*\s*(.*)/);
// Heading-style: ### T01 -- Title, ### T01: Title, ### T01 — Title
const hdMatch = !cbMatch ? line.match(/^#{2,4}\s+([\w.]+)\s*(?:--|—|:)\s*(.+)/) : null;
const hdMatch = !cbMatch
? line.match(/^#{2,4}\s+([A-Z]+\d+(?:\.[A-Z]+\d+)*)\s*(?:--|—|:)\s*(.+)/)
: null;
if (cbMatch || hdMatch) {
const taskId = cbMatch ? cbMatch[2] : hdMatch![1];
// Skip tasks already found in the Tasks section

View file

@ -703,6 +703,31 @@ Widget description.
assert.deepStrictEqual(p.tasks[0].title, 'Build the widget', 'em-dash heading T01 title');
});
test('parsePlan: filename subheadings do not become task ids', () => {
const content = `# S15: Filename Headings
**Goal:** Ignore file-reference subheadings inside task descriptions.
**Demo:** Only real task ids are parsed.
## Tasks
- [ ] **T01: First task** \`est:10m\`
Implement the feature.
### constraints.py \`add_off_request_tiered()\`
- preserve behavior
### annotations.py \`annotate()\`
- keep metadata
`;
const p = parsePlan(content);
assert.deepStrictEqual(p.tasks.map((task) => task.id), ['T01'], 'filename subheadings should not create extra tasks');
assert.deepStrictEqual(p.tasks[0].title, 'First task', 'real task should still parse normally');
assert.ok(p.tasks[0].description.includes('preserve behavior'), 'detail lines under filename subheadings should remain attached to the task');
assert.ok(p.tasks[0].description.includes('keep metadata'), 'later detail lines should also remain attached to the task');
});
test('parsePlan: mixed checkbox and heading-style tasks', () => {
const content = `# S14: Mixed Format