ktg-plugin-marketplace/scripts/okf-frontmatter.mjs
Kjell Tore Guttormsen 548a9abab3 docs(okf): retract false okr verdict-parity claim + fold in 7 distilled notes
The shared checker (scripts/okf-check.mjs) was lifted from okr once (c06e4d7,
2026-06-29) and never updated; okr hardened its checker afterward (skip
innboks/dot-dirs + scoped checkBundle @ 3b45be7, 2026-06-30; BOM/CRLF
normalization @ 482effb, 2026-07-17). The two have diverged and are NOT
verdict-identical. Retract the "byte-identical / verdict parity is verified"
claim everywhere it stood (spec.md section 7, log.md incl. a handed-out
conformance flag, and both script headers), replacing it with a precise, dated
provenance note. Establishing parity is tracked separate work
(check-okf-parity.mjs); fixes go upstream-first (drift is two-way). No code
behavior changed. Also folds the round's 7 distilled architecture notes into
log.md. Tests 33/33.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-23 22:05:13 +02:00

34 lines
1.3 KiB
JavaScript

// okf-frontmatter.mjs
// Minimal flat-frontmatter reader for the shared OKF conformance checker.
// Provenance: vendored from okr's lib/frontmatter.mjs at c06e4d7 so the catalog-hosted
// checker is self-contained — zero npm dependencies, no cross-repo import. The checker
// only reads (never writes), so only parseFrontmatter().get is vendored. okr has since
// added BOM/CRLF normalization here (lib/frontmatter.mjs:23); this copy has not, so the
// two have diverged and are no longer byte-identical (parity is the parity-gate's job,
// not this file's).
const FM_RE = /^---\n([\s\S]*?)\n---/;
export function parseFrontmatter(content) {
const match = String(content).match(FM_RE);
const raw = match ? match[1] : null;
const get = (key) => {
if (raw === null) return null;
const m = raw.match(new RegExp(`^\\s*${key}:\\s*(.*)$`, 'm'));
if (!m) return null;
let v = m[1].trim();
if (v === '') return null;
const q = v[0];
if (q === '"' || q === "'") {
const end = v.indexOf(q, 1);
if (end !== -1) return v.slice(1, end); // internal '#' preserved
v = v.slice(1); // unterminated quote: fall back to the rest
} else {
v = v.replace(/\s+#.*$/, '').trim(); // unquoted: strip trailing comment
}
return v === '' ? null : v;
};
return { raw, get };
}