em-dash 标记被实现了两次,使用两种不同的散文定义: FormatGate 忽略引文, DriftReminder 计数它们
import { readFileSync } from "node:fs";
const ROOT = process.env.LIFEOS_ROOT!;
const { stripNonProse, checkFormat } = await import(${ROOT}/hooks/FormatGate.hook.ts);
// DriftReminder exports nothing; lift its stripCode() out of the shipped source.
const drift = readFileSync(${ROOT}/hooks/DriftReminder.hook.ts, "utf8");
const sc = drift.match(/function stripCode((\w+): string): string {([\s\S]*?)\n}/)!;
const stripCode = new Function(sc[1], sc[2]) as (s: string) => string;
const em = (s: string) => (s.match(/—/g) ?? []).length;
// A. English response with zero em-dashes of its own, quoting a source that has three. const quoting = [ "════ LifeOS ═══════════════════════════", "", "The upstream note says this, verbatim:", "", "> Hooks are deterministic — they run before the model — and that is the point — always.", "", "So the registration order is what matters here.", "", "️ DA: done.", ].join("\n"); console.log("A. authored em-dashes: 0, quoted em-dashes: 3"); console.log(" FormatGate prose ->", em(stripNonProse(quoting)), "| checkFormat:", JSON.stringify(checkFormat(quoting, false, false))); console.log(" DriftReminder prose ->", em(stripCode(quoting)), "| breaksIn() reports this as drift");
// B. Russian: the dash is the sentence's verb slot, not a flourish. const ru = [ "════ LifeOS ═══════════════════════════", "", "Скрапинг — сбор данных со страниц. Хук — это обработчик события.", "Кириллица — не ASCII. Вывод — правило надо чинить.", "", …
内容来源: danielmiessler/LifeOS