Sed-pipeline (16 patterns, longest-match-first) sweeper residuelle ultra*-treff i prose, command-narrativ, agent-prompts, hook-kommentarer, doc-prosa. Pipeline-utvidelser fra V4-prompten: - BSD-syntax [[:<:]]ultra[[:>:]] istedenfor \bultra\b (BSD sed mangler \b) - 6 compound-patterns for ultraplan/ultraexecute/ultraresearch/ultrabrief/ ultrareview/ultracontinue uten -local-suffiks - ultra*-stats glob -> trek*-stats glob - Linje-eksklusjon redusert til ultra-cc-architect (Q8); session-state- eksklusjonen var over-protektiv - File-eksklusjon utvidet til settings.json, package.json, plugin.json, hele .claude/-treet (gitignored + V5-territorium) Q8-undantak holdt: architecture-discovery.mjs + project-discovery.mjs urort. Filnavn-konvensjon holdt: .session-state.local.json + *.local.* preservert. Manuell narrative-fix: tests/lib/agent-frontmatter.test.mjs linje 10 mangled "/ultra*-local" til "/voyage*-local" (ingen slik kommando finnes); korrigert til "/trek*". Residualer utenfor scope (V5 handterer): package.json + .claude-plugin/ plugin.json (Step 12-14 versjons-bump). .claude/* er gitignored spec-historikk med tilsiktet BEFORE/AFTER-narrativ. Part of voyage-rebrand session 3 (Wave 4 / Step 10). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
74 lines
2.7 KiB
JavaScript
74 lines
2.7 KiB
JavaScript
import { test } from 'node:test';
|
||
import { strict as assert } from 'node:assert';
|
||
import { splitFrontmatter, parseFrontmatter, parseDocument } from '../../lib/util/frontmatter.mjs';
|
||
|
||
test('splitFrontmatter — basic LF', () => {
|
||
const r = splitFrontmatter('---\nfoo: bar\n---\nbody here\n');
|
||
assert.equal(r.hasFrontmatter, true);
|
||
assert.equal(r.frontmatter, 'foo: bar');
|
||
assert.equal(r.body, 'body here\n');
|
||
});
|
||
|
||
test('splitFrontmatter — CRLF tolerated', () => {
|
||
const r = splitFrontmatter('---\r\nfoo: bar\r\n---\r\nbody\r\n');
|
||
assert.equal(r.hasFrontmatter, true);
|
||
assert.equal(r.frontmatter, 'foo: bar');
|
||
});
|
||
|
||
test('splitFrontmatter — BOM stripped', () => {
|
||
const r = splitFrontmatter('---\nfoo: bar\n---\n');
|
||
assert.equal(r.hasFrontmatter, true);
|
||
});
|
||
|
||
test('splitFrontmatter — no frontmatter', () => {
|
||
const r = splitFrontmatter('# title\nbody only\n');
|
||
assert.equal(r.hasFrontmatter, false);
|
||
assert.match(r.body, /title/);
|
||
});
|
||
|
||
test('parseFrontmatter — string scalars', () => {
|
||
const r = parseFrontmatter('type: trekbrief\nslug: jwt-auth\n');
|
||
assert.equal(r.valid, true);
|
||
assert.equal(r.parsed.type, 'trekbrief');
|
||
assert.equal(r.parsed.slug, 'jwt-auth');
|
||
});
|
||
|
||
test('parseFrontmatter — number, bool, null', () => {
|
||
const r = parseFrontmatter('research_topics: 3\nautoResearch: true\nfoo: false\nbar: null\n');
|
||
assert.equal(r.parsed.research_topics, 3);
|
||
assert.equal(r.parsed.autoResearch, true);
|
||
assert.equal(r.parsed.foo, false);
|
||
assert.equal(r.parsed.bar, null);
|
||
});
|
||
|
||
test('parseFrontmatter — quoted strings', () => {
|
||
const r = parseFrontmatter('plan_version: "1.7"\nname: \'test thing\'\n');
|
||
assert.equal(r.parsed.plan_version, '1.7');
|
||
assert.equal(r.parsed.name, 'test thing');
|
||
});
|
||
|
||
test('parseFrontmatter — list of scalars', () => {
|
||
const r = parseFrontmatter('keywords:\n - planning\n - research\n - agents\n');
|
||
assert.equal(r.valid, true);
|
||
assert.deepEqual(r.parsed.keywords, ['planning', 'research', 'agents']);
|
||
});
|
||
|
||
test('parseFrontmatter — rejects nested dict', () => {
|
||
const r = parseFrontmatter('a: 1\n b: 2\n');
|
||
assert.equal(r.valid, false);
|
||
assert.ok(r.errors.find(e => e.code === 'FM_INDENT'));
|
||
});
|
||
|
||
test('parseDocument — full pipeline', () => {
|
||
const text = '---\ntype: trekbrief\nresearch_topics: 2\n---\n\n# Body\n\ncontent\n';
|
||
const r = parseDocument(text);
|
||
assert.equal(r.valid, true);
|
||
assert.equal(r.parsed.frontmatter.type, 'trekbrief');
|
||
assert.match(r.parsed.body, /content/);
|
||
});
|
||
|
||
test('parseDocument — missing frontmatter is an error', () => {
|
||
const r = parseDocument('# just markdown\nno frontmatter here\n');
|
||
assert.equal(r.valid, false);
|
||
assert.ok(r.errors.find(e => e.code === 'FM_MISSING'));
|
||
});
|