feat(sdk): strip fenced code blocks before UAT item scan (#3184)
Cycle 6 of ~15: adds fenced-block stripping pass to stripMarkdownInjection. Docs-and-examples inside code fences no longer pollute the item roster. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -141,4 +141,40 @@ result: pass
|
|||||||
await rm(localTmp, { recursive: true, force: true });
|
await rm(localTmp, { recursive: true, force: true });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('ignores ### item content inside fenced code blocks', async () => {
|
||||||
|
const localTmp = await mkdtemp(join(tmpdir(), 'gsd-uat-c6-'));
|
||||||
|
try {
|
||||||
|
const phaseDir = join(localTmp, '.planning', 'phases', '05-fenced-injection');
|
||||||
|
await mkdir(phaseDir, { recursive: true });
|
||||||
|
const content = `---
|
||||||
|
status: complete
|
||||||
|
phase: 5
|
||||||
|
source: roadmap
|
||||||
|
started: 2026-05-18T00:00:00Z
|
||||||
|
updated: 2026-05-18T00:00:00Z
|
||||||
|
---
|
||||||
|
|
||||||
|
Some prose.
|
||||||
|
|
||||||
|
\`\`\`markdown
|
||||||
|
### 1. Fenced example
|
||||||
|
expected: blah
|
||||||
|
result: pass
|
||||||
|
\`\`\`
|
||||||
|
|
||||||
|
### 1. Real item
|
||||||
|
expected: real
|
||||||
|
result: pass
|
||||||
|
`;
|
||||||
|
await writeFile(join(phaseDir, '05-HUMAN-UAT.md'), content);
|
||||||
|
|
||||||
|
const result = await isPhaseUatPassed(localTmp, '5');
|
||||||
|
expect(result.items.length).toBe(1);
|
||||||
|
expect(result.items[0].name).toBe('Real item');
|
||||||
|
expect(result.passed).toBe(true);
|
||||||
|
} finally {
|
||||||
|
await rm(localTmp, { recursive: true, force: true });
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -43,6 +43,8 @@ interface UatItem {
|
|||||||
function stripMarkdownInjection(content: string): string {
|
function stripMarkdownInjection(content: string): string {
|
||||||
// Pass 1: strip YAML frontmatter region (---\n...\n---)
|
// Pass 1: strip YAML frontmatter region (---\n...\n---)
|
||||||
let s = content.replace(/^---\r?\n[\s\S]*?\r?\n---/m, '');
|
let s = content.replace(/^---\r?\n[\s\S]*?\r?\n---/m, '');
|
||||||
|
// Pass 2: strip fenced code blocks (``` ... ```)
|
||||||
|
s = s.replace(/```[\s\S]*?```/g, '');
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user