engine-compare imports the coordinator's title limit and trim instead of a copy whose reason went with Arm B; the autonomy gate exports one parser and its test runs in-process with two CLI runs; one import scanner in lib-imports; the fenced-section walker shared from tests/helpers/md-section.mjs instead of six copies; plan-gate hash in-process; living-paths scans once; routing drops the orchestrator filter whose files are gone; small leftovers removed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
26 lines
994 B
JavaScript
26 lines
994 B
JavaScript
// tests/helpers/md-section.mjs
|
|
// The text of one markdown section, for the prose-pin tests.
|
|
|
|
import { strict as assert } from 'node:assert';
|
|
import { findSection } from '../../lib/parsers/plan-schema.mjs';
|
|
|
|
/**
|
|
* The text of a heading's section (level from its #-count), up to the next
|
|
* heading of the same or a higher level outside a fence. The heading must exist.
|
|
* @param {string} text
|
|
* @param {string} heading - e.g. `## Phase 8 — Final report`
|
|
* @returns {string}
|
|
*/
|
|
export function sectionText(text, heading) {
|
|
const level = heading.match(/^#+/)[0].length;
|
|
const s = findSection(text, heading.replace(/^#+ /, ''), level);
|
|
assert.ok(s, `missing ${heading}`);
|
|
const lines = s.text.split('\n');
|
|
let fenced = false;
|
|
for (let i = 1; i < lines.length; i++) {
|
|
if (/^\s{0,3}(`{3,}|~{3,})/.test(lines[i])) fenced = !fenced;
|
|
const m = !fenced && lines[i].match(/^(#+) /);
|
|
if (m && m[1].length < level) return lines.slice(0, i).join('\n');
|
|
}
|
|
return s.text;
|
|
}
|