From 2b559c058fc5cf0a7ca91c9f8dfcbe9ea8bb453f Mon Sep 17 00:00:00 2001 From: Yann Roberto <165009858+shoyann@users.noreply.github.com> Date: Tue, 17 Nov 2026 16:03:16 +0800 Subject: [PATCH] fix(ci): validate OpenSpec baseline headings in CRLF files --- scripts/ci/validate-openspec-syntax.js | 2 +- tests/ci/validate-openspec-syntax.test.js | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/scripts/ci/validate-openspec-syntax.js b/scripts/ci/validate-openspec-syntax.js index 3c0649817..773ea4fe6 100644 --- a/scripts/ci/validate-openspec-syntax.js +++ b/scripts/ci/validate-openspec-syntax.js @@ -221,7 +221,7 @@ function collectEnforcedAnchors(content) { */ function splitBlocks(content) { const blocks = []; - const lines = content.split('\n'); + const lines = content.split(/\r?\n/); let current = null; for (const line of lines) { let m = line.match(REQUIREMENT_RE); diff --git a/tests/ci/validate-openspec-syntax.test.js b/tests/ci/validate-openspec-syntax.test.js index f2ae4d73e..9a4d05520 100644 --- a/tests/ci/validate-openspec-syntax.test.js +++ b/tests/ci/validate-openspec-syntax.test.js @@ -194,6 +194,22 @@ describe('validate-openspec-syntax (v1 schema)', () => { }); describe('structural validation', () => { + for (const [name, eol] of [['LF', '\n'], ['CRLF', '\r\n']]) { + it(`reports both missing baseline elements with ${name} line endings`, () => { + const content = ['### Requirement: Checkout', '### Invariant: Total', ''].join(eol); + const root = makeTempProject({ 'spec.md': content }); + try { + const result = runValidator(root); + assert.strictEqual(result.exitCode, 1, result.stdout); + const { errors } = JSON.parse(result.stdout); + assert.ok(errors.some(error => error.includes('Requirement "Checkout" has no Scenario'))); + assert.ok(errors.some(error => error.includes('Invariant "Total" missing anchor'))); + } finally { + fs.rmSync(root, { recursive: true, force: true }); + } + }); + } + it('flags a Requirement with no Scenario', () => { const root = makeTempProject({ 'noscen/spec.md':