@litfamily/litclaude 1.0.43 → 1.0.45

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. package/CHANGELOG.md +80 -0
  2. package/README.md +8 -8
  3. package/README_ko-KR.md +8 -8
  4. package/bin/litclaude-ai.js +201 -5
  5. package/docs/assets/readme/badge-version.svg +1 -1
  6. package/package.json +1 -1
  7. package/plugins/litclaude/.claude-plugin/plugin.json +1 -1
  8. package/plugins/litclaude/agents/korean-prose-editor.md +2 -0
  9. package/plugins/litclaude/agents/korean-style-analyzer.md +2 -0
  10. package/plugins/litclaude/agents/librarian-researcher.md +2 -0
  11. package/plugins/litclaude/agents/lit-executor.md +2 -0
  12. package/plugins/litclaude/agents/lit-planner.md +2 -0
  13. package/plugins/litclaude/agents/lit-verifier.md +2 -0
  14. package/plugins/litclaude/agents/meaning-preservation-auditor.md +2 -0
  15. package/plugins/litclaude/agents/native-flow-reviewer.md +2 -0
  16. package/plugins/litclaude/agents/polish-orchestrator.md +2 -0
  17. package/plugins/litclaude/agents/qa-runner.md +2 -0
  18. package/plugins/litclaude/agents/quality-reviewer.md +2 -0
  19. package/plugins/litclaude/bin/litclaude-ai +1 -0
  20. package/plugins/litclaude/bin/litclaude-hook.js +31 -12
  21. package/plugins/litclaude/bin/litclaude-mcp.js +1 -1
  22. package/plugins/litclaude/commands/litgoal.md +3 -1
  23. package/plugins/litclaude/hooks/hooks.json +1 -1
  24. package/plugins/litclaude/lib/agent-file/apply.mjs +150 -0
  25. package/plugins/litclaude/lib/agent-file/attribution.mjs +62 -0
  26. package/plugins/litclaude/lib/agent-file/block.md +12 -0
  27. package/plugins/litclaude/lib/agent-file/cli.mjs +71 -0
  28. package/plugins/litclaude/lib/agent-file/managed-block.mjs +82 -0
  29. package/plugins/litclaude/lib/agent-file/project-block.md +9 -0
  30. package/plugins/litclaude/lib/canonical-runtime-commitments.mjs +6 -6
  31. package/plugins/litclaude/lib/canonical-skill-resources.mjs +51 -48
  32. package/plugins/litclaude/lib/litgoal/autoloop.mjs +57 -8
  33. package/plugins/litclaude/lib/litgoal/cli.mjs +62 -1
  34. package/plugins/litclaude/lib/litgoal/freshness.mjs +55 -0
  35. package/plugins/litclaude/lib/litgoal/ledger.mjs +1 -1
  36. package/plugins/litclaude/lib/litgoal/state.mjs +1 -1
  37. package/plugins/litclaude/lib/litgoal/unknowns.mjs +44 -0
  38. package/plugins/litclaude/lib/mark-logo.png +0 -0
  39. package/plugins/litclaude/lib/mark.mjs +392 -0
  40. package/plugins/litclaude/lib/official-build.mjs +22 -0
  41. package/plugins/litclaude/lib/output_mark.py +132 -0
  42. package/plugins/litclaude/lib/render_pages.py +16 -0
  43. package/plugins/litclaude/lib/rewind/brief.mjs +12 -2
  44. package/plugins/litclaude/lib/rewind/collect.mjs +83 -12
  45. package/plugins/litclaude/lib/rewind/next-step.mjs +21 -3
  46. package/plugins/litclaude/lib/start-work-lifecycle.mjs +6 -4
  47. package/plugins/litclaude/skills/autoconference/SKILL.md +2 -0
  48. package/plugins/litclaude/skills/autoresearch/SKILL.md +2 -0
  49. package/plugins/litclaude/skills/browser-drive/SKILL.md +2 -0
  50. package/plugins/litclaude/skills/comment-checker/SKILL.md +2 -0
  51. package/plugins/litclaude/skills/debugging/SKILL.md +2 -0
  52. package/plugins/litclaude/skills/deep-interview/SKILL.md +2 -0
  53. package/plugins/litclaude/skills/frontend-ui-ux/SKILL.md +2 -0
  54. package/plugins/litclaude/skills/lit-adhd/SKILL.md +8 -4
  55. package/plugins/litclaude/skills/lit-brainstorm/SKILL.md +2 -0
  56. package/plugins/litclaude/skills/lit-burnoff/SKILL.md +2 -0
  57. package/plugins/litclaude/skills/lit-burnoff-file/SKILL.md +2 -0
  58. package/plugins/litclaude/skills/lit-code/SKILL.md +2 -0
  59. package/plugins/litclaude/skills/lit-commit/SKILL.md +2 -0
  60. package/plugins/litclaude/skills/lit-comprehend/SKILL.md +2 -0
  61. package/plugins/litclaude/skills/lit-crucible/SKILL.md +2 -0
  62. package/plugins/litclaude/skills/lit-diagram-drawer/SKILL.md +3 -1
  63. package/plugins/litclaude/skills/lit-diagram-drawer/scripts/export.mjs +35 -1
  64. package/plugins/litclaude/skills/lit-docx/SKILL.md +2 -0
  65. package/plugins/litclaude/skills/lit-docx/scripts/convert_md_to_docx.py +4 -1
  66. package/plugins/litclaude/skills/lit-docx/scripts/convert_md_to_pdf.py +2 -0
  67. package/plugins/litclaude/skills/lit-handoff/SKILL.md +2 -0
  68. package/plugins/litclaude/skills/lit-hijack/SKILL.md +2 -0
  69. package/plugins/litclaude/skills/lit-humanizer/SKILL.md +2 -0
  70. package/plugins/litclaude/skills/lit-init/SKILL.md +14 -0
  71. package/plugins/litclaude/skills/lit-loop/SKILL.md +2 -0
  72. package/plugins/litclaude/skills/lit-plan/SKILL.md +2 -0
  73. package/plugins/litclaude/skills/lit-pptx/SKILL.md +2 -0
  74. package/plugins/litclaude/skills/lit-pptx/scripts/lib/render-adapter-pptx.js +6 -1
  75. package/plugins/litclaude/skills/lit-recap/SKILL.md +2 -0
  76. package/plugins/litclaude/skills/lit-schematic/SKILL.md +3 -1
  77. package/plugins/litclaude/skills/lit-schematic/scripts/lib/sheet.mjs +10 -0
  78. package/plugins/litclaude/skills/lit-schematic/scripts/lib/svg.mjs +4 -0
  79. package/plugins/litclaude/skills/lit-schematic/scripts/motion.mjs +5 -2
  80. package/plugins/litclaude/skills/lit-schematic/scripts/render.mjs +20 -2
  81. package/plugins/litclaude/skills/lit-scientific-visualization/SKILL.md +2 -0
  82. package/plugins/litclaude/skills/lit-team/SKILL.md +2 -0
  83. package/plugins/litclaude/skills/lit-typographic-motion/SKILL.md +2 -0
  84. package/plugins/litclaude/skills/lit-typographic-motion/engine/node/chrome.mjs +23 -2
  85. package/plugins/litclaude/skills/lit-typographic-motion/engine/node/cover-capture.mjs +14 -1
  86. package/plugins/litclaude/skills/lit-typographic-motion/engine/node/cover.mjs +48 -2
  87. package/plugins/litclaude/skills/lit-typographic-motion/engine/node/encode.mjs +8 -1
  88. package/plugins/litclaude/skills/lit-typographic-motion/engine/node/end-card.mjs +128 -0
  89. package/plugins/litclaude/skills/lit-typographic-motion/engine/node/pipeline.mjs +59 -14
  90. package/plugins/litclaude/skills/lit-typographic-motion/engine/node/stage-gate.mjs +7 -4
  91. package/plugins/litclaude/skills/lit-typographic-motion/engine/node/stage.mjs +33 -8
  92. package/plugins/litclaude/skills/lit-typographic-motion/engine/stage/init.js +13 -0
  93. package/plugins/litclaude/skills/lit-typographic-motion/references/studio.md +11 -0
  94. package/plugins/litclaude/skills/litgoal/SKILL.md +53 -1
  95. package/plugins/litclaude/skills/litresearch/SKILL.md +2 -0
  96. package/plugins/litclaude/skills/litwork/SKILL.md +2 -0
  97. package/plugins/litclaude/skills/lsp/SKILL.md +2 -0
  98. package/plugins/litclaude/skills/lsp-setup/SKILL.md +2 -0
  99. package/plugins/litclaude/skills/readme-studio/SKILL.md +3 -1
  100. package/plugins/litclaude/skills/readme-studio/templates/cover-source.json +1 -0
  101. package/plugins/litclaude/skills/readme-studio/templates/hyperframes-cover/index.html +3 -2
  102. package/plugins/litclaude/skills/readme-studio/templates/hyperframes-cover/package-lock.json +4 -4
  103. package/plugins/litclaude/skills/readme-studio/templates/remotion-cover/package-lock.json +3 -3
  104. package/plugins/litclaude/skills/readme-studio/templates/remotion-cover/package.json +2 -1
  105. package/plugins/litclaude/skills/readme-studio/templates/remotion-cover/src/index.tsx +4 -3
  106. package/plugins/litclaude/skills/refactor/SKILL.md +2 -0
  107. package/plugins/litclaude/skills/review-work/SKILL.md +2 -0
  108. package/plugins/litclaude/skills/rules/SKILL.md +2 -0
  109. package/plugins/litclaude/skills/start-work/SKILL.md +2 -0
  110. package/plugins/litclaude/skills/structural-search/SKILL.md +2 -0
  111. package/plugins/litclaude/skills/visual-qa/SKILL.md +2 -0
  112. package/plugins/litclaude/skills/wikify/SKILL.md +2 -0
  113. package/scripts/doctor.mjs +3 -1
  114. package/scripts/prepublish-test-gate.mjs +75 -22
@@ -7,9 +7,16 @@ import { existsSync, readdirSync, statSync } from "node:fs";
7
7
  import path from "node:path";
8
8
  import { ENCODE_ARGS, PREVIEW } from "../core/constants.mjs";
9
9
  import { which } from "./host.mjs";
10
+ import { ffmpegMetadataArgs, tagFile } from "../../../../lib/mark.mjs";
10
11
 
11
12
  export { which };
12
13
 
14
+ /** Tag the staged deliverables (poster, still, preview) with LitClaude's generator before the gate measures them. */
15
+ export function tagStaged(dir, env = process.env) {
16
+ if (!existsSync(dir)) return;
17
+ for (const name of readdirSync(dir).filter((f) => /\.(?:png|gif|webp)$/u.test(f))) tagFile(path.join(dir, name), { env });
18
+ }
19
+
13
20
  export const findFfmpeg = (env = process.env) => (env.FFMPEG_PATH && existsSync(env.FFMPEG_PATH) ? env.FFMPEG_PATH : which("ffmpeg", env));
14
21
  export const findFfprobe = (env = process.env) => (env.FFPROBE_PATH && existsSync(env.FFPROBE_PATH) ? env.FFPROBE_PATH : which("ffprobe", env));
15
22
  export const findImg2webp = (env = process.env) => which("img2webp", env);
@@ -38,7 +45,7 @@ export function startMaster({ ffmpeg, width, height, fps, out, audio = null }) {
38
45
  args.push(...ENCODE_ARGS);
39
46
  // The track is prepared to the film's exact sample count, so nothing is cut to the shorter stream.
40
47
  if (audio) args.push("-map", "0:v:0", "-map", "1:a:0", "-c:a", "aac", "-b:a", "256k");
41
- args.push(out);
48
+ args.push(...ffmpegMetadataArgs(), out);
42
49
  const child = spawn(ffmpeg, args, { stdio: ["pipe", "ignore", "pipe"] });
43
50
  let stderr = "";
44
51
  child.stderr.on("data", (d) => { stderr += d.toString(); });
@@ -0,0 +1,128 @@
1
+ // LitClaude's end card: about half a second after the film's last beat, the film's own ground with "made with
2
+ // LitClaude" and the flame logo centred, in the ground's ink (lib/mark.mjs WORDMARK). No music (the track is padded with silence),
3
+ // no camera move; a short crossfade from the last frame keeps the cut under the full-frame step limit. Only the
4
+ // `on` mark setting draws it. Both render paths append it to the master after the film's own frames: the flash
5
+ // audit, the full-frame step rule and the probe see it; the content rules judge the film's frames alone, and
6
+ // END-CARD checks the card itself.
7
+ import { mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
8
+ import path from "node:path";
9
+ import { WORDMARK, markInk, markLogoDataUri, markPlan } from "../../../../lib/mark.mjs";
10
+ import { decodePng } from "./png.mjs";
11
+ import { StageBrowser } from "./stage-capture.mjs";
12
+ import { stageFonts } from "./stage-serve.mjs";
13
+
14
+ /** The card's length for this run, or null when the mark setting is not `on`. */
15
+ export function endCardPlan({ fps, env = process.env }) {
16
+ if (!markPlan({ env }).visible) return null;
17
+ const frames = Math.max(2, Math.round(WORDMARK.endCardSec * fps));
18
+ const fade = Math.min(frames - 1, Math.max(2, Math.round(WORDMARK.endCardFadeSec * fps)));
19
+ return { frames, fade, sec: frames / fps };
20
+ }
21
+
22
+ const hexRgb = (hex) => {
23
+ const m = /^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/iu.exec(String(hex ?? "").trim());
24
+ return m ? [1, 2, 3].map((i) => parseInt(m[i], 16)) : null;
25
+ };
26
+
27
+ /** The card page: the ground, the flame logo and the wordmark centred, drawn in the stage's own Pretendard. */
28
+ export function endCardHtml({ width, height, ground }) {
29
+ const g = hexRgb(ground) ?? [16, 18, 22];
30
+ const ink = markInk(g);
31
+ const size = Math.max(WORDMARK.minPx, Math.round(WORDMARK.endCardShare * Math.min(width, height)));
32
+ return `<!doctype html>
33
+ <meta charset="utf-8">
34
+ <link rel="stylesheet" href="/lit/fonts.css">
35
+ <script src="/lit/stage-kit.js"></script>
36
+ <style>
37
+ html, body { margin: 0; width: ${width}px; height: ${height}px; overflow: hidden; background: rgb(${g.join(",")}); }
38
+ p { position: absolute; inset: 0; margin: 0; display: flex; align-items: center; justify-content: center; font: ${WORDMARK.weight} ${size}px/1 "Pretendard"; letter-spacing: ${WORDMARK.tracking}em; color: rgb(${ink.join(",")}); opacity: 0.7; }
39
+ img { height: ${WORDMARK.logoScale}em; margin-right: ${WORDMARK.logoGap}em; }
40
+ </style>
41
+ <body><p><img alt="" src="${markLogoDataUri()}">${WORDMARK.text}</p>
42
+ <script>LitStage.define({ width: ${width}, height: ${height}, fps: 30, duration: 1, render() {} });</script>
43
+ </body>
44
+ `;
45
+ }
46
+
47
+ /** Render the card once in the stage's headless Chrome; returns its RGBA pixels (width x height). */
48
+ export async function renderEndCard({ out, width, height, ground, env = process.env, log = () => {} }) {
49
+ const dir = path.join(out, ".run", "end-card");
50
+ rmSync(dir, { recursive: true, force: true });
51
+ mkdirSync(dir, { recursive: true });
52
+ writeFileSync(path.join(dir, "index.html"), endCardHtml({ width, height, ground }));
53
+ const browser = await StageBrowser.open({ stageDir: dir, faces: stageFonts(env), rasters: [], width, height, seed: 1, profileDir: path.join(out, ".run", `ce${process.pid % 100000}`), env, log });
54
+ try {
55
+ await browser.step(0, 30, { paint: true });
56
+ const png = decodePng(await browser.capture());
57
+ if (png.width !== width || png.height !== height) throw new Error(`end card captured at ${png.width}x${png.height}, expected ${width}x${height}`);
58
+ const rgba = Buffer.alloc(width * height * 4);
59
+ let lo = 255;
60
+ let hi = 0;
61
+ for (let i = 0, j = 0; i < rgba.length; i += 4, j += png.channels) {
62
+ rgba[i] = png.pixels[j]; rgba[i + 1] = png.pixels[j + 1]; rgba[i + 2] = png.pixels[j + 2]; rgba[i + 3] = 255;
63
+ const l = 0.2126 * rgba[i] + 0.7152 * rgba[i + 1] + 0.0722 * rgba[i + 2];
64
+ if (l < lo) lo = l;
65
+ if (l > hi) hi = l;
66
+ }
67
+ if (hi - lo < 40) throw new Error("the end card came out flat: the wordmark was not drawn (Pretendard missing from the stage fonts?)");
68
+ return rgba;
69
+ } finally {
70
+ await browser.close();
71
+ rmSync(dir, { recursive: true, force: true });
72
+ }
73
+ }
74
+
75
+ /** Frame k of the card: a crossfade from the film's last frame over `fade` frames, then the card. A fresh buffer. */
76
+ export function endCardFrame({ last, card, k, fade }) {
77
+ const a = Math.min(1, (k + 1) / fade);
78
+ const outBuf = Buffer.alloc(card.length);
79
+ for (let i = 0; i < card.length; i += 4) {
80
+ outBuf[i] = Math.round(last[i] + (card[i] - last[i]) * a);
81
+ outBuf[i + 1] = Math.round(last[i + 1] + (card[i + 1] - last[i + 1]) * a);
82
+ outBuf[i + 2] = Math.round(last[i + 2] + (card[i + 2] - last[i + 2]) * a);
83
+ outBuf[i + 3] = 255;
84
+ }
85
+ return outBuf;
86
+ }
87
+
88
+ /**
89
+ * Pad a WAV the film was scored to with `frames` frames of silence at `fps`, so the music still ends with the
90
+ * film and the card is silent. Returns the samples added (0 for no file).
91
+ */
92
+ export function padWavSilence(file, { frames, fps }) {
93
+ if (!file) return 0;
94
+ const buf = readFileSync(file);
95
+ const rate = buf.readUInt32LE(24);
96
+ const blockAlign = buf.readUInt16LE(32);
97
+ let o = 12;
98
+ let dataAt = -1;
99
+ let dataSize = 0;
100
+ while (o + 8 <= buf.length) {
101
+ const id = buf.toString("ascii", o, o + 4);
102
+ const size = buf.readUInt32LE(o + 4);
103
+ if (id === "data") { dataAt = o; dataSize = size; }
104
+ o += 8 + size + (size % 2);
105
+ }
106
+ if (dataAt < 0 || dataAt + 8 + dataSize !== buf.length) throw new Error(`cannot pad ${file}: the data chunk is not the last chunk`);
107
+ const samples = Math.round((frames * rate) / fps);
108
+ const padded = Buffer.concat([buf, Buffer.alloc(samples * blockAlign)]);
109
+ padded.writeUInt32LE(dataSize + samples * blockAlign, dataAt + 4);
110
+ padded.writeUInt32LE(padded.length - 8, 4);
111
+ writeFileSync(file, padded);
112
+ return samples;
113
+ }
114
+
115
+ /**
116
+ * END-CARD: the card is the planned length, fades in within its planned frames and stays still after. That the
117
+ * wordmark was drawn is checked when the card is rendered (renderEndCard refuses a flat card); the small centred
118
+ * text sits below the 0.5 % luminance percentiles the frame log records, so the log cannot show it.
119
+ */
120
+ export function endCardRule({ lines, plan, fps }) {
121
+ if (!plan) return { id: "END-CARD", status: "N/A", detail: "mark setting is not on; no end card" };
122
+ const problems = [];
123
+ if (lines.length !== plan.frames) problems.push(`${lines.length} card frames, planned ${plan.frames}`);
124
+ const tail = lines.slice(plan.fade);
125
+ if (tail.length && new Set(tail.map((l) => l.rgbaSha256)).size !== 1) problems.push("the card moves after its fade");
126
+ const detail = `${lines.length} frames (${(lines.length / fps).toFixed(2)} s), ${plan.fade}-frame crossfade, "${WORDMARK.text}"`;
127
+ return problems.length ? { id: "END-CARD", status: "FAIL", detail: `${detail}: ${problems.join("; ")}` } : { id: "END-CARD", status: "PASS", detail };
128
+ }
@@ -17,7 +17,7 @@ import { loadBrief, planFromBrief, BriefError } from "./brief.mjs";
17
17
  import { openSession } from "./session.mjs";
18
18
  import { analyzeFrame, areaDownscale } from "./analysis.mjs";
19
19
  import { encodePng, rgbaToRgb, decodePng } from "./png.mjs";
20
- import { findFfmpeg, findFfprobe, findImg2webp, previewRungs, startMaster, encodePreview, probeVideo } from "./encode.mjs";
20
+ import { findFfmpeg, findFfprobe, findImg2webp, previewRungs, startMaster, encodePreview, probeVideo, tagStaged } from "./encode.mjs";
21
21
  import { checkCoverage, planFontKeys } from "./coverage.mjs";
22
22
  import { nodeStatus, checkFont, loadFontManifest, audioStatus, AUDIO_WARNING, wordTimingStatus, INSTALL_COMMAND, ENGINE_ROOT } from "./runtime.mjs";
23
23
  import { formatReport, formatPreflightReport } from "./report.mjs";
@@ -29,6 +29,7 @@ import { recordHouse } from "./house.mjs";
29
29
  import { treatmentSha } from "./done.mjs";
30
30
  import { auditMuxed } from "./sound.mjs";
31
31
  import { soundTrackFor } from "./sound-cli.mjs";
32
+ import { endCardFrame, endCardPlan, endCardRule, padWavSilence, renderEndCard } from "./end-card.mjs";
32
33
 
33
34
  export const DELIVERABLES = ["film.mp4", "preview.webp", "preview.gif", "poster.png", "reduced-motion.png"];
34
35
 
@@ -145,7 +146,8 @@ function manifestFor(plan, extra) {
145
146
  previewEncoder: extra.previewEncoder ?? null,
146
147
  audioTier: plan.audioTier ?? "text-reading-time",
147
148
  ...(plan.beatGrid ? { beatGrid: plan.beatGrid } : { bpm: plan.bpm }),
148
- durationSec: +plan.durationSec.toFixed(6),
149
+ durationSec: +(plan.durationSec + (extra.endCard?.sec ?? 0)).toFixed(6),
150
+ endCard: extra.endCard ? { frames: extra.endCard.frames, fade: extra.endCard.fade, sec: +extra.endCard.sec.toFixed(6) } : null,
149
151
  generatedAt: new Date().toISOString(),
150
152
  passRanges: extra.passRanges,
151
153
  timeline: plan.timeline,
@@ -218,8 +220,12 @@ function contrastFrames(plan) {
218
220
  return set;
219
221
  }
220
222
 
221
- /** The master render: every frame analysed, logged, audited and piped to ffmpeg. */
222
- async function renderMaster({ session, plan, out, ffmpeg, samples, shutter, audio = null }) {
223
+ /**
224
+ * The master render: every frame analysed, logged, audited and piped to ffmpeg. With an end card (`card`: its plan
225
+ * and RGBA), the card's frames follow the film's through the same analysis, flash detector, encoder and log,
226
+ * marked `endCard: true`.
227
+ */
228
+ async function renderMaster({ session, plan, out, ffmpeg, samples, shutter, audio = null, card = null }) {
223
229
  const runDir = path.join(out, ".run");
224
230
  const samplesDir = path.join(runDir, "samples");
225
231
  rmSync(samplesDir, { recursive: true, force: true });
@@ -234,8 +240,10 @@ async function renderMaster({ session, plan, out, ffmpeg, samples, shutter, audi
234
240
  const frames = [];
235
241
  const masterFlash = [];
236
242
  const t0 = Date.now();
243
+ let last = null;
237
244
  await session.render({ from: 0, to: plan.frameCount, fps: plan.fps, samples, shutter, tag: "master" }, async (meta, bytes) => {
238
245
  const n = meta.frame;
246
+ if (card && n === plan.frameCount - 1) last = Buffer.from(bytes);
239
247
  const a = analyzeFrame(bytes, meta.width, meta.height, { keepMask: keep.has(n) });
240
248
  const flash = detector.push(a.cells);
241
249
  await encoder.write(bytes);
@@ -252,6 +260,18 @@ async function renderMaster({ session, plan, out, ffmpeg, samples, shutter, audi
252
260
  writeFileSync(path.join(samplesDir, `f${n}.mask.png`), encodePng(a.mask, meta.width, meta.height, 1, { level: 1 }));
253
261
  }
254
262
  });
263
+ if (card) {
264
+ for (let k = 0; k < card.frames; k++) {
265
+ const bytes = endCardFrame({ last, card: card.rgba, k, fade: card.fade });
266
+ const a = analyzeFrame(Buffer.from(bytes), 1920, 1080);
267
+ const flash = detector.push(a.cells);
268
+ await encoder.write(bytes);
269
+ const line = { frame: plan.frameCount + k, pass: null, artifact: "master", rgbaSha256: a.rgbaSha256, inkPx: a.inkPx, luminanceP995: a.luminanceP995, textBoxes: [], elements: [], fills: [], post: null, shot: null, flash, endCard: true };
270
+ log.write(line);
271
+ frames.push(line);
272
+ masterFlash.push(flash);
273
+ }
274
+ }
255
275
  const encoded = await encoder.finish();
256
276
  await log.close();
257
277
  if (encoded.code !== 0) throw new Error(`ffmpeg master encode failed (${encoded.code}): ${encoded.stderr.slice(-400)}`);
@@ -259,7 +279,7 @@ async function renderMaster({ session, plan, out, ffmpeg, samples, shutter, audi
259
279
  }
260
280
 
261
281
  /** The preview ladder: re-render at the rung's fps, downscale, audit (looping), encode, check size. */
262
- async function renderPreview({ session, plan, out, ffmpeg, env, minGlyphPx }) {
282
+ async function renderPreview({ session, plan, out, ffmpeg, env, minGlyphPx, card = null }) {
263
283
  const runDir = path.join(out, ".run");
264
284
  const encoders = previewRungs(ffmpeg, env);
265
285
  const img2webp = findImg2webp(env);
@@ -277,13 +297,23 @@ async function renderPreview({ session, plan, out, ffmpeg, env, minGlyphPx }) {
277
297
  const count = Math.round(plan.durationSec * rung.fps);
278
298
  const cells = [];
279
299
  let i = 0;
280
- await session.render({ from: 0, to: count, fps: rung.fps, samples: SAMPLING.previewSamples, shutter: SAMPLING.masterShutter, tag: "preview" }, async (meta, bytes) => {
281
- analyzeFrame(bytes, meta.width, meta.height);
282
- const small = areaDownscale(bytes, meta.width, meta.height, rung.width, height);
300
+ let lastSmall = null;
301
+ const put = (small) => {
283
302
  cells.push(cellsFromRgba(small, rung.width, height));
284
303
  writeFileSync(path.join(dir, `${String(i).padStart(5, "0")}.png`), encodePng(rgbaToRgb(small, rung.width, height), rung.width, height, 3, { level: 1 }));
285
304
  i += 1;
305
+ };
306
+ await session.render({ from: 0, to: count, fps: rung.fps, samples: SAMPLING.previewSamples, shutter: SAMPLING.masterShutter, tag: "preview" }, async (meta, bytes) => {
307
+ analyzeFrame(bytes, meta.width, meta.height);
308
+ lastSmall = areaDownscale(bytes, meta.width, meta.height, rung.width, height);
309
+ put(lastSmall);
286
310
  });
311
+ if (card) {
312
+ const cardSmall = areaDownscale(card.rgba, 1920, 1080, rung.width, height);
313
+ const frames = Math.max(2, Math.round(card.sec * rung.fps));
314
+ const fade = Math.min(frames - 1, Math.max(1, Math.round((card.fade * rung.fps) / plan.fps)));
315
+ for (let k = 0; k < frames; k++) put(endCardFrame({ last: lastSmall, card: cardSmall, k, fade }));
316
+ }
287
317
  const records = detectSequence(cells, { loop: true });
288
318
  for (const encoder of encoders) {
289
319
  const outFile = path.join(runDir, "stage", encoder === "gif" ? "preview.gif" : "preview.webp");
@@ -361,7 +391,11 @@ function readJsonLines(file) {
361
391
  export function collectAndEvaluate({ out, previewRecords, previewFps, determinism, perf, coverage, still, exportDir = path.join(out, ".run", "stage"), extraRules = [] }) {
362
392
  const manifest = JSON.parse(readFileSync(path.join(out, "manifest.json"), "utf8"));
363
393
  const lines = readJsonLines(path.join(out, "render.jsonl"));
364
- const frames = lines.filter((l) => l.pass === null && l.artifact === "master").sort((a, b) => a.frame - b.frame);
394
+ const master = lines.filter((l) => l.pass === null && l.artifact === "master").sort((a, b) => a.frame - b.frame);
395
+ // The film's content rules judge the film's own frames; the flash audit and the full-frame step rule read every
396
+ // frame, end card included, and END-CARD checks the card.
397
+ const frames = master.filter((l) => !l.endCard);
398
+ const cardLines = master.filter((l) => l.endCard);
365
399
  const passLines = lines.filter((l) => l.pass !== null && l.pass !== undefined);
366
400
  const shotEvents = lines.filter((l) => l.type === "shot-events").flatMap((l) => l.shots);
367
401
  const stage = exportDir;
@@ -398,10 +432,11 @@ export function collectAndEvaluate({ out, previewRecords, previewFps, determinis
398
432
  const allowedHangulFonts = [...new Set(Object.values(preset.voices).flatMap((v) => [v.hangul, ...(v.weightSteps ?? [])]))]
399
433
  .map((k) => loadFontManifest().fonts[k]).filter(Boolean).map((f) => path.basename(f.path ?? f.file));
400
434
  const data = {
401
- manifest, frames, passLines, masterFlash: frames.map((f) => f.flash), previewFlash: previewRecords ? { records: previewRecords, fps: previewFps } : null,
435
+ manifest, frames, passLines, masterFlash: master.map((f) => f.flash), previewFlash: previewRecords ? { records: previewRecords, fps: previewFps } : null,
402
436
  shotEvents, exports, probe, still, contrastSamples, determinism, perf, coverage, preset, seedOf: passSeed, allowedHangulFonts,
403
437
  };
404
438
  const gate = evaluateGate(data);
439
+ if (manifest.endCard || cardLines.length) extraRules = [...extraRules, endCardRule({ lines: cardLines, plan: manifest.endCard, fps: manifest.fps })];
405
440
  if (extraRules.length) {
406
441
  gate.rules.push(...extraRules);
407
442
  gate.failed = gate.rules.filter((x) => x.status === "FAIL").map((x) => x.id);
@@ -453,6 +488,7 @@ export async function make({ briefPath, out, round = 1, stillsOnly = false, view
453
488
  let preview;
454
489
  let poster;
455
490
  let still;
491
+ let card = null;
456
492
  try {
457
493
  stillsSet = await renderStillsSet({ session, plan, treatment: prep.treatment, out, round, stillsOnly: stillsOnly || !ffmpeg, env, log });
458
494
  log(`stills: ${stillsSet.stills.files.length} files in ${path.join(out, "stills")}`);
@@ -463,10 +499,16 @@ export async function make({ briefPath, out, round = 1, stillsOnly = false, view
463
499
  return { code: EXIT.BLOCKED_NO_FFMPEG_FOR_VIDEO, message: `BLOCKED_NO_FFMPEG_FOR_VIDEO: ffmpeg is not on PATH; the stills and contact sheet are in ${path.join(out, "stills")}; install ffmpeg for the MP4, preview and poster`, plan };
464
500
  }
465
501
  sound = soundTrackFor({ treatment: prep.treatment, out, frameCount: plan.frameCount, fps: plan.fps, cutTimes: plan.shots.slice(1).map((sh) => sh.start), ffmpeg });
466
- master = await renderMaster({ session, plan, out, ffmpeg, samples, shutter, audio: sound.file });
502
+ // The track is scored to the film's own frames; the end card after it is silent.
503
+ const cardPlan = endCardPlan({ fps: plan.fps, env });
504
+ if (cardPlan) {
505
+ padWavSilence(sound.file, { frames: cardPlan.frames, fps: plan.fps });
506
+ card = { ...cardPlan, rgba: await renderEndCard({ out, width: 1920, height: 1080, ground: PRESETS[plan.presetId].palette.bg, env, log }) };
507
+ }
508
+ master = await renderMaster({ session, plan, out, ffmpeg, samples, shutter, audio: sound.file, card });
467
509
  log(`master: ${plan.frameCount} frames in ${master.seconds.toFixed(1)} s`);
468
510
  const minGlyph = Math.min(...master.frames.flatMap((f) => (f.textBoxes ?? []).map((b) => b.fontSizePx)).filter((v) => v > 0), 1000);
469
- preview = await renderPreview({ session, plan, out, ffmpeg, env, minGlyphPx: minGlyph });
511
+ preview = await renderPreview({ session, plan, out, ffmpeg, env, minGlyphPx: minGlyph, card });
470
512
  const posterShot = plan.shots.find((s) => (s.text || s.items)) ?? plan.shots[0];
471
513
  const posterFrame = Number.isInteger(prep.brief.posterFrame) ? prep.brief.posterFrame : Math.round(((posterShot.start + posterShot.end) / 2) * plan.fps);
472
514
  poster = await renderStillExport({ session, plan, frame: posterFrame, file: path.join(out, ".run", "stage", "poster.png"), samples, shutter });
@@ -477,7 +519,7 @@ export async function make({ briefPath, out, round = 1, stillsOnly = false, view
477
519
  const manifest = manifestFor(plan, {
478
520
  samples, shutter, renderer: session.renderer, chromeFlags: session.flags, previewEncoder: preview.encoder, passRanges: info.passRanges, warnings, round,
479
521
  sound: { mode: sound.mode, label: sound.label, file: sound.file ? path.relative(out, sound.file) : null },
480
- treatmentSha256: treatmentSha(out),
522
+ treatmentSha256: treatmentSha(out), endCard: card,
481
523
  });
482
524
  writeJson(path.join(out, "manifest.json"), manifest);
483
525
  } finally {
@@ -486,6 +528,7 @@ export async function make({ briefPath, out, round = 1, stillsOnly = false, view
486
528
  // The frame log needs the shot-event schedule for MO-SH-03.
487
529
  appendShotEvents(out, session.info.shotEvents);
488
530
  writeJson(path.join(out, ".run", "exports.json"), { preview: preview.attempts, poster, still, egress: session.egress, encodeArgs: master.encodeArgs, previewRung: preview.rung, previewFlash: preview.records });
531
+ tagStaged(path.join(out, ".run", "stage"), env);
489
532
  if (!runGate) {
490
533
  const stage = path.join(out, ".run", "stage");
491
534
  for (const name of readdirSync(stage).filter((f) => DELIVERABLES.includes(f))) renameSync(path.join(stage, name), path.join(out, name));
@@ -593,7 +636,9 @@ export async function partial({ mode, briefPath, out, env = process.env, log = (
593
636
  /** Audit the staged master's audio against the treatment's sound plan (exit 20 for a generated bed). */
594
637
  function typeSoundAudit({ out, treatment, plan, ffmpeg, env }) {
595
638
  const film = path.join(out, ".run", "stage", "film.mp4");
596
- return auditMuxed({ ffmpeg, ffprobe: findFfprobe(env), film, videoDurationSec: plan.frameCount / plan.fps, mode: treatment.sound.mode });
639
+ const manifestFile = path.join(out, "manifest.json");
640
+ const cardFrames = existsSync(manifestFile) ? JSON.parse(readFileSync(manifestFile, "utf8")).endCard?.frames ?? 0 : 0;
641
+ return auditMuxed({ ffmpeg, ffprobe: findFfprobe(env), film, videoDurationSec: (plan.frameCount + cardFrames) / plan.fps, mode: treatment.sound.mode });
597
642
  }
598
643
 
599
644
  function appendShotEvents(out, shotEvents) {
@@ -17,17 +17,20 @@ function flash({ masterFlash, previewFlash, fps }) {
17
17
  return r("MO-C-03", master.pass && (!preview || preview.pass) ? "PASS" : "FAIL", detail);
18
18
  }
19
19
 
20
- function floors({ probe, width, height, treatment }) {
20
+ function floors({ probe, width, height, treatment, endCardSec = 0 }) {
21
21
  if (!probe) return [r("MO-C-10/11/12", "FAIL", "no MP4 master to probe (ffprobe missing or file absent)")];
22
22
  const problems = [];
23
23
  if (probe.width !== width || probe.height !== height) problems.push(`size ${probe.width}x${probe.height}, the ${treatment.format} format is ${width}x${height}`);
24
24
  if (probe.fps < GATE.minFps) problems.push(`fps ${probe.fps}`);
25
25
  for (const [k, v] of [["pixFmt", "yuv420p"], ["colorSpace", "bt709"], ["colorRange", "tv"], ["colorTransfer", "bt709"], ["colorPrimaries", "bt709"]]) if (probe[k] !== v) problems.push(`${k} ${probe[k]}`);
26
+ // The film is held to the treatment's length; LitClaude's end card after it is measured on its own (END-CARD).
26
27
  const target = treatment.durationSec;
27
- const off = Math.abs(probe.duration - target) / target;
28
+ const film = probe.duration - endCardSec;
29
+ const card = endCardSec ? ` (+${endCardSec.toFixed(2)} s end card)` : "";
30
+ const off = Math.abs(film - target) / target;
28
31
  const length = off > STAGE_GATE.durationTolerance
29
- ? r("MO-C-12", "FAIL", `${probe.duration.toFixed(2)} s against the treatment's ${target} s (${(off * 100).toFixed(1)} % off, limit ±10 %)`)
30
- : r("MO-C-12", "PASS", `${probe.duration.toFixed(2)} s against the treatment's ${target} s`);
32
+ ? r("MO-C-12", "FAIL", `${film.toFixed(2)} s${card} against the treatment's ${target} s (${(off * 100).toFixed(1)} % off, limit ±10 %)`)
33
+ : r("MO-C-12", "PASS", `${film.toFixed(2)} s${card} against the treatment's ${target} s`);
31
34
  const detail = `${probe.width}x${probe.height} @ ${probe.fps} fps (ffprobe yuv420p/bt709/tv ${problems.length ? "N" : "Y"})`;
32
35
  return [r("MO-C-10/11", problems.length ? "FAIL" : "PASS", problems.length ? `${detail}: ${problems.join(", ")}` : detail), length];
33
36
  }
@@ -15,7 +15,7 @@ import { assetUsed } from "./assets.mjs";
15
15
  import { BLENDER } from "./blender.mjs";
16
16
  import { addToStills, writeBoard } from "./board.mjs";
17
17
  import { BlockedError } from "./chrome.mjs";
18
- import { findFfmpeg, findFfprobe, findImg2webp, previewRungs, startMaster, encodePreview, probeVideo } from "./encode.mjs";
18
+ import { findFfmpeg, findFfprobe, findImg2webp, previewRungs, startMaster, encodePreview, probeVideo, tagStaged } from "./encode.mjs";
19
19
  import { resolveViewed, asBlocked } from "./pipeline.mjs";
20
20
  import { encodePng, rgbaToRgb } from "./png.mjs";
21
21
  import { auditMuxed } from "./sound.mjs";
@@ -29,6 +29,7 @@ import { styleCss, styleScript, readStyle } from "./styles.mjs";
29
29
  import { scanStage, stageFonts } from "./stage-serve.mjs";
30
30
  import { beatCuts, stillsPlan, writeStills } from "./stills.mjs";
31
31
  import { FORMATS, loadTreatment } from "./treatment.mjs";
32
+ import { endCardFrame, endCardPlan, endCardRule, padWavSilence, renderEndCard } from "./end-card.mjs";
32
33
 
33
34
  export const DELIVERABLES = ["film.mp4", "preview.webp", "preview.gif", "poster.png", "reduced-motion.png"];
34
35
  export const DETERMINISM_SAMPLES = Object.freeze({ min: 8, max: 16 });
@@ -132,7 +133,10 @@ async function openOnRung({ label, ctx }) {
132
133
  else if (!error && !(spec.duration > 0)) error = fail("the page's duration must be a positive number of seconds");
133
134
  if (!error && state.webglMissing) error = new BlockedError(EXIT.BLOCKED_NO_WEBGL2, `BLOCKED_NO_WEBGL2: the page asked for a WebGL context and the ${ctx.rung} rung gave none`);
134
135
  if (!error && browser.prepared?.failedFaces?.length) log(`warning: faces that did not load: ${browser.prepared.failedFaces.join(", ")}`);
135
- if (error && !(ctx.rung === "gpu" && error.code === EXIT.BLOCKED_NO_WEBGL2)) {
136
+ // A 3D page usually throws when its WebGL context comes back null (three.js does), so on the GPU
137
+ // rung a missing context outranks the contract error it causes: openChecked retries on SwiftShader.
138
+ // Linux CI Chrome has no GPU, so `--use-angle=gl` gives no WebGL there.
139
+ if (error && !(ctx.rung === "gpu" && state.webglMissing)) {
136
140
  await browser.close();
137
141
  throw error;
138
142
  }
@@ -380,6 +384,10 @@ export async function renderStage({ out, round = 1, stillsOnly = false, env = pr
380
384
  const stageOut = path.join(runDir, "stage");
381
385
  mkdirSync(stageOut, { recursive: true });
382
386
  const sound = soundTrackFor({ treatment, out, stageDir, frameCount, fps, cutTimes: cuts.map((c) => c / fps), ffmpeg });
387
+ // The track is scored to the film's own frames; the end card after it is silent.
388
+ const cardPlan = endCardPlan({ fps, env });
389
+ const card = cardPlan ? { ...cardPlan, rgba: await renderEndCard({ out, width, height, ground: treatment.style ? readStyle(treatment.style).palette.ground : null, env, log }) } : null;
390
+ if (card) padWavSilence(sound.file, { frames: card.frames, fps });
383
391
  const filmPath = path.join(stageOut, "film.mp4");
384
392
  const encoder = startMaster({ ffmpeg, width, height, fps, out: filmPath, audio: sound.file });
385
393
 
@@ -410,11 +418,13 @@ export async function renderStage({ out, round = 1, stillsOnly = false, env = pr
410
418
  const inflight = [];
411
419
  const maxInflight = pool.workers.length + 1;
412
420
  let poster = null;
421
+ let lastRgba = null;
413
422
  const consume = async (entry) => {
414
423
  const a = await entry.analysis;
415
424
  await encoder.write(a.rgba);
425
+ if (card && entry.f === frameCount - 1) lastRgba = Buffer.from(a.rgba);
416
426
  const flash = detector.push(a.cells);
417
- lines.push({ frame: entry.f, artifact: "master", rgbaSha256: a.rgbaSha256, luminanceP995: a.luminanceP995, luminanceP005: a.luminanceP005, busy: a.busy, flash });
427
+ lines.push({ frame: entry.f, artifact: "master", rgbaSha256: a.rgbaSha256, luminanceP995: a.luminanceP995, luminanceP005: a.luminanceP005, busy: a.busy, flash, ...(entry.endCard ? { endCard: true } : {}) });
418
428
  if (plan.all.has(entry.f)) kept.set(entry.f, a.rgba);
419
429
  if (detFrames.includes(entry.f)) detMaster.set(entry.f, a);
420
430
  if (entry.f % previewEvery === 0) {
@@ -435,6 +445,14 @@ export async function renderStage({ out, round = 1, stillsOnly = false, env = pr
435
445
  if (f % 30 === 0) progress(out, { phase: "master", frame: f, frameCount, round });
436
446
  }
437
447
  while (inflight.length) await consume(inflight.shift());
448
+ // The end card follows the film through the same analysis, encoder, flash detector, log and preview source.
449
+ if (card) {
450
+ for (let k = 0; k < card.frames; k++) {
451
+ const rgba = endCardFrame({ last: lastRgba, card: card.rgba, k, fade: card.fade });
452
+ const png = encodePng(rgbaToRgb(rgba, width, height), width, height, 3, { level: 1 });
453
+ await consume({ f: frameCount + k, analysis: analyzeChecked(pool, png, width, height), endCard: true });
454
+ }
455
+ }
438
456
  const encoded = await encoder.finish();
439
457
  if (encoded.code !== 0) throw new Error(`ffmpeg master encode failed (${encoded.code}): ${encoded.stderr.slice(-400)}`);
440
458
  const masterSec = (Date.now() - tMaster) / 1000;
@@ -454,9 +472,14 @@ export async function renderStage({ out, round = 1, stillsOnly = false, env = pr
454
472
  const qaResult = await qaPromise;
455
473
 
456
474
  progress(out, { phase: "preview", round });
457
- const preview = buildPreview({ out, ffmpeg, env, width, height, frameCount, fps });
475
+ const cardFrames = card?.frames ?? 0;
476
+ const preview = buildPreview({ out, ffmpeg, env, width, height, frameCount: frameCount + cardFrames, fps });
477
+ tagStaged(stageOut, env);
458
478
  const probe = probeVideo(filmPath, env);
459
- const soundAudit = auditMuxed({ ffmpeg, ffprobe: findFfprobe(env), film: filmPath, videoDurationSec: frameCount / fps, mode: sound.mode });
479
+ const soundAudit = auditMuxed({ ffmpeg, ffprobe: findFfprobe(env), film: filmPath, videoDurationSec: (frameCount + cardFrames) / fps, mode: sound.mode });
480
+ // The film's content rules judge its own frames; the flash audit reads every frame, end card included.
481
+ const filmLines = lines.filter((l) => !l.endCard);
482
+ const cardRule = card ? endCardRule({ lines: lines.filter((l) => l.endCard), plan: card, fps }) : null;
460
483
  const exports = {
461
484
  film: existsSync(filmPath) ? { bytes: statSync(filmPath).size } : null,
462
485
  preview: preview.file ? { bytes: preview.bytes, kind: path.extname(preview.file).slice(1) } : null,
@@ -465,8 +488,9 @@ export async function renderStage({ out, round = 1, stillsOnly = false, env = pr
465
488
  };
466
489
  const gate = evaluateStageGate({
467
490
  masterFlash: lines.map((l) => l.flash), previewFlash: preview.records ? { records: preview.records, fps: preview.rung.fps } : null, fps,
468
- probe, width, height, treatment, exports, reducedFrame: plan.reduced, frames: lines, usesWebGL: finalState.usesWebGL, renderer: finalState.webglRenderer, rung: ctx.rung,
469
- determinism, extraRules: [...soundAudit.rules, ...(qaResult?.rules ?? []), assetUsed(treatment, scan.files)].filter(Boolean),
491
+ probe, width, height, treatment, exports, reducedFrame: plan.reduced, frames: filmLines, usesWebGL: finalState.usesWebGL, renderer: finalState.webglRenderer, rung: ctx.rung,
492
+ endCardSec: card ? card.sec : 0,
493
+ determinism, extraRules: [...soundAudit.rules, ...(qaResult?.rules ?? []), assetUsed(treatment, scan.files), cardRule].filter(Boolean),
470
494
  });
471
495
  const promoted = promote(out, gate.flashFail);
472
496
  const loc = (name) => path.join(promoted.dir, name);
@@ -476,7 +500,8 @@ export async function renderStage({ out, round = 1, stillsOnly = false, env = pr
476
500
  if (gate.pass && !promoted.withheld) recordHouse(out, { style: treatment.style, path: "stage", format: treatment.format, durationSec: treatment.durationSec });
477
501
  const totalSec = (Date.now() - t0) / 1000;
478
502
  const manifest = {
479
- schemaVersion: 1, path: "stage", renderId: id, round, treatmentSha256: treatmentSha(out), format: treatment.format, width, height, fps, durationSec: spec.duration, treatmentDurationSec: treatment.durationSec,
503
+ schemaVersion: 1, path: "stage", renderId: id, round, treatmentSha256: treatmentSha(out), format: treatment.format, width, height, fps, durationSec: +(spec.duration + (card?.sec ?? 0)).toFixed(6), treatmentDurationSec: treatment.durationSec,
504
+ endCard: card ? { frames: card.frames, fade: card.fade, sec: +card.sec.toFixed(6) } : null,
480
505
  frameCount, seed: treatment.seed, renderer: finalState.webglRenderer ?? "no WebGL", rung: ctx.rung, chromeFlags: master.flags, usesWebGL: finalState.usesWebGL,
481
506
  cuts, stills: { sha256: stills.sha256, poster: plan.poster, reduced: plan.reduced }, posterEncoding: poster,
482
507
  geometry: geometryFor(width, height),
@@ -183,6 +183,19 @@
183
183
  const born = new Map();
184
184
  const finished = new Set();
185
185
  const svgBorn = new Map();
186
+ // An animation the page script starts is paused at once on the virtual clock. Left to the sweep in
187
+ // step(), it would play on the wall clock while the page loads, and on a slow host a short one
188
+ // finished, resolved `finished` and moved its chained successor before frame 0.
189
+ const nativeAnimate = Element.prototype.animate;
190
+ Element.prototype.animate = function animate(...args) {
191
+ const a = nativeAnimate.apply(this, args);
192
+ if (!born.has(a)) {
193
+ a.pause();
194
+ born.set(a, V.ms / 1000);
195
+ a.currentTime = 0;
196
+ }
197
+ return a;
198
+ };
186
199
  const drainMicrotasks = async () => {
187
200
  for (let i = 0; i < 8; i++) await Promise.resolve();
188
201
  };
@@ -238,6 +238,17 @@ house style and later films are appended. While it exists the validator holds ne
238
238
  to the house style; a request that names another style wins for that film and does not move the house
239
239
  style. To change the house style, edit `style` in the file or delete it.
240
240
 
241
+ ## LitClaude's credit card and cover mark
242
+
243
+ When the user's LitClaude mark setting is `on` (the default), the renderer adds LitClaude's
244
+ credit after the film's last beat: about 0.5 s on the style's ground with the flame logo and "made with LitClaude" centred,
245
+ reached by a short crossfade, silent (the track is padded), with no camera move. The treatment, the beats
246
+ and the page stay as written; write no credit of your own. The film's length rule, dead air, flat-frame
247
+ and near-black rules judge the film's own frames; the flash audit and the full-frame step rule see the
248
+ card too, and `END-CARD` in the gate report checks it. The manifest records it as `endCard`, and
249
+ `durationSec` includes it. A cover loop gets a small static corner mark instead, placed clear of the
250
+ title and art boxes and recorded as `mark` in the cover manifest. `meta` and `off` draw neither.
251
+
241
252
  ## What stays free
242
253
 
243
254
  The subject, the idea, the copy, the drawing, the hero moves and the arc stay the model's, with the
@@ -206,6 +206,13 @@ Safety (the loop can never trap a session):
206
206
  fails safe and allows stopping.
207
207
  - **Escape hatches** — `LITCLAUDE_GOAL_OFF=1` (env kill switch), or
208
208
  `litclaude-ai litgoal checkpoint --status blocked` / `--status complete` to end the loop.
209
+ - **Stale passes reopen first** — before deciding, the hook re-hashes every input a passing
210
+ criterion was bound to (see Evidence Freshness); a changed or missing input turns that pass
211
+ into `stale` and the loop keeps going instead of completing.
212
+ - **User-only questions stop the loop** — when every criterion passes but open critical unknowns
213
+ remain, an open KU or UU keeps the loop running (Claude can probe it), while a set made only of
214
+ UK questions ends the session with `continue:false`, lists the questions, and moves the goal to
215
+ `needs_user_decision` instead of `complete`. Looping cannot answer a question only the user can.
209
216
 
210
217
  Prefer `--autoloop` when the user wants hands-off autonomous completion of a multi-criteria goal;
211
218
  otherwise the user-typed `/goal` proposal above remains available and they compose cleanly.
@@ -278,6 +285,48 @@ payload must fail with a controlled CLI error. A missing criterion id must fail
278
285
  with a controlled state error. Never record `pass` while a QA resource is still
279
286
  alive or while the artifact is only a dry-run claim.
280
287
 
288
+ ### Evidence Freshness
289
+
290
+ A file that existed when a check ran is not proof that the check is still current. Bind a pass
291
+ to the files it was observed on:
292
+
293
+ ```sh
294
+ litclaude-ai litgoal record-evidence --criterion criterion-1 --status pass \
295
+ --inputs dist/report.json,src/parser.mjs --reviewed docs/spec.md \
296
+ --json '{"artifact":"dist/report.json"}'
297
+ ```
298
+
299
+ `--inputs` (repeatable or comma-separated) records each file's absolute path and SHA-256 as
300
+ `role: "input"`; `--reviewed` does the same for the artifact a human review looked at
301
+ (`role: "reviewed"`), so review evidence is bound to the version that was reviewed. The runtime
302
+ owns the `inputs` field; an `inputs` key inside `--json` is refused, and so is a path that is
303
+ not a readable regular file. `status`, `checkpoint --status complete` and the autoloop Stop hook
304
+ re-hash those files: when one changed or vanished, the criterion becomes `stale` with
305
+ `staleInputs` naming each file and `changed` or `missing`, the ledger gets `evidence.stale`, and
306
+ completion is refused until fresh evidence is recorded.
307
+
308
+ ### Unknown Register
309
+
310
+ Reduce unknowns while the work runs, not only while it is planned:
311
+
312
+ ```sh
313
+ litclaude-ai litgoal unknown add --kind KK --text "<fact>" --source "<where it is stated>" --json
314
+ litclaude-ai litgoal unknown add --kind KU --text "<question>" --probe "<command or check>" --critical --json
315
+ litclaude-ai litgoal unknown resolve --id unknown-2 --evidence "<what answered it>" --json
316
+ litclaude-ai litgoal unknown list --json
317
+ ```
318
+
319
+ | Kind | Meaning | Required |
320
+ |---|---|---|
321
+ | KK | known known | `--source`; stored as `known` |
322
+ | KU | known unknown: Claude can check it | `--probe`; stays `open` |
323
+ | UK | unknown known: only the user can answer | `--probe` (usually "ask the user"); stays `open` |
324
+ | UU | unknown unknown that surfaced mid-run | `--probe`; stays `open` |
325
+
326
+ Closing an item needs `--evidence`. Any open item marked `--critical` blocks
327
+ `checkpoint --status complete` and autoloop completion. Ledger events are `unknown.added` and
328
+ `unknown.resolved`.
329
+
281
330
  ## Manual-QA Channels
282
331
 
283
332
  Manual-QA channels are required for criterion completion.
@@ -306,7 +355,8 @@ litclaude-ai litgoal checkpoint --status complete --note "<evidence summary>" --
306
355
  ```
307
356
 
308
357
  The runtime must reject `--status complete` until every criterion in
309
- `.litclaude/litgoal/goals.json` is `pass`. If completion is rejected, inspect
358
+ `.litclaude/litgoal/goals.json` is `pass` (a stale pass does not count) and no critical unknown
359
+ is open. If completion is rejected, inspect
310
360
  `criteria --json`, fix or record the pending criterion, and retry.
311
361
 
312
362
  ## Steering
@@ -371,3 +421,5 @@ Stop and surface the state when:
371
421
  or worktree cannot be cleaned up.
372
422
 
373
423
  Leftover runtime state means `blocked`, not `pass`.
424
+
425
+ <!-- LitClaude © 2026 wjgoarxiv · MIT · github.com/wjgoarxiv/litclaude · fp:182f034d168c -->
@@ -661,3 +661,5 @@ Record the stop condition: `local evidence sufficient`, `external host facts not
661
661
  needed`, or `external fact unresolved but not blocking`. This keeps litresearch
662
662
  compatible with minimum-first execution while preserving its evidence discipline
663
663
  for genuinely broad investigations.
664
+
665
+ <!-- LitClaude © 2026 wjgoarxiv · MIT · github.com/wjgoarxiv/litclaude · fp:668067cfc2cd -->
@@ -626,3 +626,5 @@ history-safety detail when the operation grows past a single commit.
626
626
  - On resume, re-read the notepad and the latest `git status` before continuing.
627
627
  Plans, handoffs, package metadata, test output, and resumed ledgers all drift
628
628
  between turns.
629
+
630
+ <!-- LitClaude © 2026 wjgoarxiv · MIT · github.com/wjgoarxiv/litclaude · fp:7ae19a889d31 -->
@@ -138,3 +138,5 @@ Record the command or tool used and the diagnostic result. Good examples:
138
138
  Diagnostics are signals, not noise. Do not suppress them. If an LSP failure is
139
139
  unrelated to the change, label it as pre-existing with the exact output and
140
140
  continue only when the task can be safely completed without hiding it.
141
+
142
+ <!-- LitClaude © 2026 wjgoarxiv · MIT · github.com/wjgoarxiv/litclaude · fp:c3341f4f5a65 -->
@@ -226,3 +226,5 @@ If Claude Code does not expose LSP tools and a server is not installed, do not
226
226
  fabricate a passing diagnostics result. Fall back to the project's own commands
227
227
  (`tsc --noEmit`, `ruff`, `cargo check`, `go test`, etc.), label the LSP gap as a
228
228
  controlled skip, and report it — consistent with the `lsp` skill's failure rules.
229
+
230
+ <!-- LitClaude © 2026 wjgoarxiv · MIT · github.com/wjgoarxiv/litclaude · fp:3dd28ec5d7f0 -->