Files
PaperClipAI/packages/paperclip-runner/scripts/lib/doc-wrappers.mjs
T
DottaandClaude Opus 4.8 ab7b85878a docs(runner): strip leaked generation wrappers, sync Phase 7 counts, guard against regressions
Remove trailing generation-wrapper markup (</content>, plus </invoke> in the
tutorial) that had leaked at EOF into eleven committed Phase 7 reference,
tutorial, evidence, and OKF-journal files.

Sync the stated suite counts in the current-state docs (tutorial,
scenario-explorer reference, verification-commands reference, and OKF journal)
to the verified results: test:phase7 49, test:browser:phase7 25,
docs:validate 73 files / 28 OKF concepts / 5 indexes. Drop a brittle wall-clock
timing from the journal. The dated 7F verification evidence and log.md milestone
entry keep their point-in-time 45/19 figures on purpose.

Add a wrapper-markup guard to docs:validate (via scripts/lib/doc-wrappers.mjs)
that fails with the exact file and line when generator envelope tags reappear,
plus a node:test regression suite wired into the package test script.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-08-09 14:46:49 +00:00

22 lines
907 B
JavaScript

// Detects leaked model/tool generation-wrapper markup in documentation.
//
// When a generator writes its raw completion envelope into a file, tags such as
// a trailing `</content>` or `</invoke>` escape into the committed prose. Plain
// link and OKF validation do not notice them, so `docs:validate` scans every
// markdown file with this detector and fails on the exact file and line. Prose
// docs never legitimately contain these tags, so any match is a defect.
export const WRAPPER_MARKUP =
/<\/?(?:antml:[a-z0-9_-]+|content|invoke|parameter|function_calls|function_results)\b[^>]*>/i;
export function wrapperMarkupIn(markdown) {
const hits = [];
const lines = markdown.split("\n");
for (let index = 0; index < lines.length; index += 1) {
const match = lines[index].match(WRAPPER_MARKUP);
if (match) {
hits.push({ line: index + 1, tag: match[0] });
}
}
return hits;
}