@litfamily/litclaude 1.0.43 → 1.0.44
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.
- package/CHANGELOG.md +43 -0
- package/README.md +8 -8
- package/README_ko-KR.md +8 -8
- package/bin/litclaude-ai.js +30 -3
- package/docs/assets/readme/badge-version.svg +1 -1
- package/package.json +1 -1
- package/plugins/litclaude/.claude-plugin/plugin.json +1 -1
- package/plugins/litclaude/agents/korean-prose-editor.md +2 -0
- package/plugins/litclaude/agents/korean-style-analyzer.md +2 -0
- package/plugins/litclaude/agents/librarian-researcher.md +2 -0
- package/plugins/litclaude/agents/lit-executor.md +2 -0
- package/plugins/litclaude/agents/lit-planner.md +2 -0
- package/plugins/litclaude/agents/lit-verifier.md +2 -0
- package/plugins/litclaude/agents/meaning-preservation-auditor.md +2 -0
- package/plugins/litclaude/agents/native-flow-reviewer.md +2 -0
- package/plugins/litclaude/agents/polish-orchestrator.md +2 -0
- package/plugins/litclaude/agents/qa-runner.md +2 -0
- package/plugins/litclaude/agents/quality-reviewer.md +2 -0
- package/plugins/litclaude/bin/litclaude-hook.js +10 -5
- package/plugins/litclaude/bin/litclaude-mcp.js +1 -1
- package/plugins/litclaude/commands/litgoal.md +3 -1
- package/plugins/litclaude/lib/canonical-runtime-commitments.mjs +6 -6
- package/plugins/litclaude/lib/canonical-skill-resources.mjs +47 -44
- package/plugins/litclaude/lib/litgoal/autoloop.mjs +57 -8
- package/plugins/litclaude/lib/litgoal/cli.mjs +62 -1
- package/plugins/litclaude/lib/litgoal/freshness.mjs +55 -0
- package/plugins/litclaude/lib/litgoal/ledger.mjs +1 -1
- package/plugins/litclaude/lib/litgoal/state.mjs +1 -1
- package/plugins/litclaude/lib/litgoal/unknowns.mjs +44 -0
- package/plugins/litclaude/lib/mark-logo.png +0 -0
- package/plugins/litclaude/lib/mark.mjs +375 -0
- package/plugins/litclaude/lib/official-build.mjs +22 -0
- package/plugins/litclaude/lib/output_mark.py +132 -0
- package/plugins/litclaude/lib/render_pages.py +16 -0
- package/plugins/litclaude/lib/rewind/collect.mjs +58 -5
- package/plugins/litclaude/lib/start-work-lifecycle.mjs +2 -2
- package/plugins/litclaude/skills/autoconference/SKILL.md +2 -0
- package/plugins/litclaude/skills/autoresearch/SKILL.md +2 -0
- package/plugins/litclaude/skills/browser-drive/SKILL.md +2 -0
- package/plugins/litclaude/skills/comment-checker/SKILL.md +2 -0
- package/plugins/litclaude/skills/debugging/SKILL.md +2 -0
- package/plugins/litclaude/skills/deep-interview/SKILL.md +2 -0
- package/plugins/litclaude/skills/frontend-ui-ux/SKILL.md +2 -0
- package/plugins/litclaude/skills/lit-adhd/SKILL.md +3 -0
- package/plugins/litclaude/skills/lit-brainstorm/SKILL.md +2 -0
- package/plugins/litclaude/skills/lit-burnoff/SKILL.md +2 -0
- package/plugins/litclaude/skills/lit-burnoff-file/SKILL.md +2 -0
- package/plugins/litclaude/skills/lit-code/SKILL.md +2 -0
- package/plugins/litclaude/skills/lit-commit/SKILL.md +2 -0
- package/plugins/litclaude/skills/lit-comprehend/SKILL.md +2 -0
- package/plugins/litclaude/skills/lit-crucible/SKILL.md +2 -0
- package/plugins/litclaude/skills/lit-diagram-drawer/SKILL.md +3 -1
- package/plugins/litclaude/skills/lit-diagram-drawer/scripts/export.mjs +35 -1
- package/plugins/litclaude/skills/lit-docx/SKILL.md +2 -0
- package/plugins/litclaude/skills/lit-docx/scripts/convert_md_to_docx.py +4 -1
- package/plugins/litclaude/skills/lit-docx/scripts/convert_md_to_pdf.py +2 -0
- package/plugins/litclaude/skills/lit-handoff/SKILL.md +2 -0
- package/plugins/litclaude/skills/lit-hijack/SKILL.md +2 -0
- package/plugins/litclaude/skills/lit-humanizer/SKILL.md +2 -0
- package/plugins/litclaude/skills/lit-init/SKILL.md +2 -0
- package/plugins/litclaude/skills/lit-loop/SKILL.md +2 -0
- package/plugins/litclaude/skills/lit-plan/SKILL.md +2 -0
- package/plugins/litclaude/skills/lit-pptx/SKILL.md +2 -0
- package/plugins/litclaude/skills/lit-pptx/scripts/lib/render-adapter-pptx.js +6 -1
- package/plugins/litclaude/skills/lit-recap/SKILL.md +2 -0
- package/plugins/litclaude/skills/lit-schematic/SKILL.md +3 -1
- package/plugins/litclaude/skills/lit-schematic/scripts/lib/sheet.mjs +10 -0
- package/plugins/litclaude/skills/lit-schematic/scripts/lib/svg.mjs +4 -0
- package/plugins/litclaude/skills/lit-schematic/scripts/motion.mjs +5 -2
- package/plugins/litclaude/skills/lit-schematic/scripts/render.mjs +20 -2
- package/plugins/litclaude/skills/lit-scientific-visualization/SKILL.md +2 -0
- package/plugins/litclaude/skills/lit-team/SKILL.md +2 -0
- package/plugins/litclaude/skills/lit-typographic-motion/SKILL.md +2 -0
- package/plugins/litclaude/skills/lit-typographic-motion/engine/node/chrome.mjs +23 -2
- package/plugins/litclaude/skills/lit-typographic-motion/engine/node/cover-capture.mjs +14 -1
- package/plugins/litclaude/skills/lit-typographic-motion/engine/node/cover.mjs +48 -2
- package/plugins/litclaude/skills/lit-typographic-motion/engine/node/encode.mjs +8 -1
- package/plugins/litclaude/skills/lit-typographic-motion/engine/node/end-card.mjs +128 -0
- package/plugins/litclaude/skills/lit-typographic-motion/engine/node/pipeline.mjs +59 -14
- package/plugins/litclaude/skills/lit-typographic-motion/engine/node/stage-gate.mjs +7 -4
- package/plugins/litclaude/skills/lit-typographic-motion/engine/node/stage.mjs +29 -7
- package/plugins/litclaude/skills/lit-typographic-motion/references/studio.md +11 -0
- package/plugins/litclaude/skills/litgoal/SKILL.md +53 -1
- package/plugins/litclaude/skills/litresearch/SKILL.md +2 -0
- package/plugins/litclaude/skills/litwork/SKILL.md +2 -0
- package/plugins/litclaude/skills/lsp/SKILL.md +2 -0
- package/plugins/litclaude/skills/lsp-setup/SKILL.md +2 -0
- package/plugins/litclaude/skills/readme-studio/SKILL.md +3 -1
- package/plugins/litclaude/skills/readme-studio/templates/cover-source.json +1 -0
- package/plugins/litclaude/skills/readme-studio/templates/hyperframes-cover/index.html +3 -2
- package/plugins/litclaude/skills/readme-studio/templates/remotion-cover/package-lock.json +3 -3
- package/plugins/litclaude/skills/readme-studio/templates/remotion-cover/package.json +2 -1
- package/plugins/litclaude/skills/readme-studio/templates/remotion-cover/src/index.tsx +4 -3
- package/plugins/litclaude/skills/refactor/SKILL.md +2 -0
- package/plugins/litclaude/skills/review-work/SKILL.md +2 -0
- package/plugins/litclaude/skills/rules/SKILL.md +2 -0
- package/plugins/litclaude/skills/start-work/SKILL.md +2 -0
- package/plugins/litclaude/skills/structural-search/SKILL.md +2 -0
- package/plugins/litclaude/skills/visual-qa/SKILL.md +2 -0
- package/plugins/litclaude/skills/wikify/SKILL.md +2 -0
- package/scripts/doctor.mjs +3 -1
- package/scripts/prepublish-test-gate.mjs +75 -22
|
@@ -17,11 +17,23 @@ import { basename, join, resolve } from "node:path";
|
|
|
17
17
|
import { pathToFileURL } from "node:url";
|
|
18
18
|
import { findPretendard } from "./lib/fonts.mjs";
|
|
19
19
|
import { inkGrid, missingInk, pngInfo, withDpi } from "./lib/png.mjs";
|
|
20
|
+
import { tagFile } from "../../../lib/mark.mjs";
|
|
20
21
|
|
|
21
22
|
export const CHROME_FLAGS = Object.freeze([
|
|
22
23
|
"--headless=new", "--use-mock-keychain", "--password-store=basic", "--no-first-run",
|
|
23
24
|
"--no-default-browser-check", "--disable-gpu", "--hide-scrollbars", "--disable-extensions",
|
|
24
25
|
]);
|
|
26
|
+
// On POSIX Chrome runs in its own process group behind a shell that execs it (so it keeps the
|
|
27
|
+
// shell's PID) after starting a watcher. The watcher polls this process and Chrome, and when either
|
|
28
|
+
// is gone it kills the group, so a render killed mid-run never leaves Chrome alive under PID 1.
|
|
29
|
+
const TETHER = [
|
|
30
|
+
'parent=$1; group=$$; shift',
|
|
31
|
+
'( trap "" TERM INT HUP',
|
|
32
|
+
' while kill -0 "$parent" 2>/dev/null && kill -0 "$group" 2>/dev/null; do sleep 0.1; done',
|
|
33
|
+
' kill -TERM -"$group" 2>/dev/null; sleep 0.2; kill -KILL -"$group" 2>/dev/null',
|
|
34
|
+
') </dev/null >/dev/null 2>&1 &',
|
|
35
|
+
'exec "$@"',
|
|
36
|
+
].join("\n");
|
|
25
37
|
const PX_PER_MM = 96 / 25.4;
|
|
26
38
|
const MAX_SIDE = 16000;
|
|
27
39
|
// Headless Chrome returns a screenshot larger than about 100 million pixels with only its first
|
|
@@ -84,7 +96,10 @@ function runChrome(chrome, args, html, work) {
|
|
|
84
96
|
writeFileSync(file, html);
|
|
85
97
|
const profile = mkdtempSync(join(work, "profile-"));
|
|
86
98
|
try {
|
|
87
|
-
const
|
|
99
|
+
const argv = [...CHROME_FLAGS, `--user-data-dir=${profile}`, ...args, pathToFileURL(file).href];
|
|
100
|
+
const result = process.platform === "win32"
|
|
101
|
+
? spawnSync(chrome, argv, { encoding: "utf8", timeout: 180_000 })
|
|
102
|
+
: spawnSync("/bin/sh", ["-c", TETHER, "litclaude-chrome", String(process.pid), chrome, ...argv], { encoding: "utf8", timeout: 180_000, detached: true });
|
|
88
103
|
if (result.error) throw new Error(`RENDER_FAILED ${result.error.message}`);
|
|
89
104
|
if (result.status !== 0) throw new Error(`RENDER_FAILED chrome exited ${result.status}: ${(result.stderr || "").split("\n").slice(-3).join(" ")}`);
|
|
90
105
|
} finally {
|
|
@@ -93,7 +108,8 @@ function runChrome(chrome, args, html, work) {
|
|
|
93
108
|
}
|
|
94
109
|
|
|
95
110
|
// `verify: false` skips the reference render, for film frames far below the size that can fail.
|
|
96
|
-
|
|
111
|
+
// `tag: false` leaves the generator tag off, for working frames that never leave the run.
|
|
112
|
+
export function renderPng({ chrome, svg, out, dpi = 600, crop = null, verify = true, tag = true }) {
|
|
97
113
|
const size = svgSize(svg);
|
|
98
114
|
let source = svg;
|
|
99
115
|
let widthMm = size.width;
|
|
@@ -130,6 +146,7 @@ export function renderPng({ chrome, svg, out, dpi = 600, crop = null, verify = t
|
|
|
130
146
|
}
|
|
131
147
|
const png = withDpi(readFileSync(raw), used);
|
|
132
148
|
writeFileSync(out, png);
|
|
149
|
+
if (tag) tagFile(out);
|
|
133
150
|
return { out, ...pngInfo(png), requestedDpi: dpi };
|
|
134
151
|
} finally {
|
|
135
152
|
rmSync(work, { recursive: true, force: true });
|
|
@@ -141,6 +158,7 @@ export function renderPdf({ chrome, svg, out }) {
|
|
|
141
158
|
const work = mkdtempSync(join(tmpdir(), "lit-schematic-render-"));
|
|
142
159
|
try {
|
|
143
160
|
runChrome(chrome, ["--no-pdf-header-footer", `--print-to-pdf=${resolve(out)}`], page({ svg, widthMm: size.width, heightMm: size.height }), work);
|
|
161
|
+
tagFile(out);
|
|
144
162
|
return { out, widthMm: size.width, heightMm: size.height };
|
|
145
163
|
} finally {
|
|
146
164
|
rmSync(work, { recursive: true, force: true });
|
|
@@ -102,3 +102,5 @@ always remains visible; protected structured or audit artifacts retain their sch
|
|
|
102
102
|
- Do not treat a green unit test as proof that a produced figure is visually correct.
|
|
103
103
|
- Do not use the source-checkout placeholder `<skill-path>` literally; resolve the installed vendor source root.
|
|
104
104
|
- Do not make optional dependency absence fail all of LitClaude; report the affected capability as DEGRADED.
|
|
105
|
+
|
|
106
|
+
<!-- LitClaude © 2026 wjgoarxiv · MIT · github.com/wjgoarxiv/litclaude · fp:df87d26bdbf3 -->
|
|
@@ -179,3 +179,5 @@ an unrecorded cleanup item, and the next session will not know the team ever exi
|
|
|
179
179
|
|
|
180
180
|
If fewer than two genuinely distinct slices exist, say so and use a single subagent. Splitting
|
|
181
181
|
work that does not divide is slower than not splitting it.
|
|
182
|
+
|
|
183
|
+
<!-- LitClaude © 2026 wjgoarxiv · MIT · github.com/wjgoarxiv/litclaude · fp:2353642f72ff -->
|
|
@@ -147,3 +147,5 @@ Never raise a gate number, never weaken the flash audit, never ship a withheld e
|
|
|
147
147
|
- Quoting song lyrics or other text the user does not own as the film's content.
|
|
148
148
|
|
|
149
149
|
Every reference is named at its step above. Type engine credit: portions adapted from mexicat/pdoom-video (MIT), commit `ca251e3`; see `engine/NOTICE`.
|
|
150
|
+
|
|
151
|
+
<!-- LitClaude © 2026 wjgoarxiv · MIT · github.com/wjgoarxiv/litclaude · fp:10c6f3985f09 -->
|
|
@@ -162,13 +162,33 @@ export function launchArgs(profileDir, flags) {
|
|
|
162
162
|
];
|
|
163
163
|
}
|
|
164
164
|
|
|
165
|
+
// Chrome is tied to this process on POSIX: a shell becomes the leader of a new process group,
|
|
166
|
+
// starts a watcher that leaves the group's descriptors and signals alone, and then execs Chrome,
|
|
167
|
+
// so Chrome keeps the shell's PID. The watcher polls this process and Chrome; once either is gone
|
|
168
|
+
// it sends TERM, then KILL, to the whole group. A launcher killed mid-run, even by SIGKILL, so
|
|
169
|
+
// never leaves Chrome or its helpers alive under PID 1.
|
|
170
|
+
const TETHER = [
|
|
171
|
+
'parent=$1; group=$$; shift',
|
|
172
|
+
'( trap "" TERM INT HUP',
|
|
173
|
+
' while kill -0 "$parent" 2>/dev/null && kill -0 "$group" 2>/dev/null; do sleep 0.1; done',
|
|
174
|
+
' kill -TERM -"$group" 2>/dev/null; sleep 0.2; kill -KILL -"$group" 2>/dev/null',
|
|
175
|
+
') </dev/null >/dev/null 2>&1 3>&- 4>&- &',
|
|
176
|
+
'exec "$@"',
|
|
177
|
+
].join("\n");
|
|
178
|
+
|
|
179
|
+
/** `spawn` for Chrome: tethered in its own process group on POSIX, a plain child on Windows. */
|
|
180
|
+
function spawnTethered(chrome, args, options) {
|
|
181
|
+
if (process.platform === "win32") return spawn(chrome, args, options);
|
|
182
|
+
return spawn("/bin/sh", ["-c", TETHER, "litclaude-chrome", String(process.pid), chrome, ...args], { ...options, detached: true });
|
|
183
|
+
}
|
|
184
|
+
|
|
165
185
|
export class ChromeSession {
|
|
166
186
|
static async launch({ chrome, flags, profileDir, routes, timeoutMs = 30000 }) {
|
|
167
187
|
mkdirSync(profileDir, { recursive: true });
|
|
168
188
|
const args = launchArgs(profileDir, flags);
|
|
169
189
|
let child;
|
|
170
190
|
try {
|
|
171
|
-
child =
|
|
191
|
+
child = spawnTethered(chrome, args, { stdio: ["ignore", "ignore", "pipe", "pipe", "pipe"] });
|
|
172
192
|
} catch (error) {
|
|
173
193
|
throw new BlockedError(EXIT.BLOCKED_NO_CHROME, `BLOCKED_NO_CHROME: Chrome failed to launch: ${error.message}`);
|
|
174
194
|
}
|
|
@@ -266,7 +286,8 @@ export class ChromeSession {
|
|
|
266
286
|
|
|
267
287
|
kill() {
|
|
268
288
|
try {
|
|
269
|
-
this.child.kill("SIGKILL");
|
|
289
|
+
if (process.platform === "win32") this.child.kill("SIGKILL");
|
|
290
|
+
else process.kill(-this.child.pid, "SIGKILL");
|
|
270
291
|
} catch {
|
|
271
292
|
// already gone
|
|
272
293
|
}
|
|
@@ -127,10 +127,23 @@ export class CoverBrowser {
|
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
+
/**
|
|
131
|
+
* LitClaude's visible mark as a fixed overlay outside the page's own tree, the same on every frame so the loop
|
|
132
|
+
* stays seamless. `mark` is { x, y, w, h, fontSize, ink, opacity, text, weight, tracking } in page pixels; with
|
|
133
|
+
* `measure: true` it is laid out hidden and its rendered width is returned. Mask captures hide it.
|
|
134
|
+
*/
|
|
135
|
+
async setMark(mark, { measure = false } = {}) {
|
|
136
|
+
this.mark = mark;
|
|
137
|
+
const css = { position: "fixed", left: `${measure ? -9999 : mark.x}px`, top: `${measure ? -9999 : mark.y}px`, height: `${mark.h}px`, display: "flex", alignItems: "center", justifyContent: "flex-end", whiteSpace: "nowrap", pointerEvents: "none", zIndex: "2147483647", font: `${mark.weight} ${mark.fontSize}px/1 Pretendard, sans-serif`, letterSpacing: `${mark.tracking}em`, color: `rgb(${mark.ink.join(",")})`, opacity: String(mark.opacity), visibility: measure ? "hidden" : "visible" };
|
|
138
|
+
if (!measure) css.width = `${mark.w}px`;
|
|
139
|
+
return this.evaluate(`(async () => { let d = document.getElementById("__litclaude_mark"); if (!d) { d = document.createElement("div"); d.id = "__litclaude_mark"; document.documentElement.appendChild(d); } d.textContent = ""; const logo = ${JSON.stringify(mark.logo ?? null)}; if (logo) { const i = new Image(); i.src = logo.src; Object.assign(i.style, { height: logo.scale + "em", marginRight: logo.gap + "em", display: "block" }); d.appendChild(i); await i.decode(); } d.appendChild(document.createTextNode(${JSON.stringify(mark.text)})); d.removeAttribute("style"); Object.assign(d.style, ${JSON.stringify(css)}); if (document.fonts) await document.fonts.ready; return d.getBoundingClientRect().width; })()`);
|
|
140
|
+
}
|
|
141
|
+
|
|
130
142
|
/** Draw loop time t (and the mask variant) and wait for the frame to settle. */
|
|
131
143
|
async frame(t, { mask = false } = {}) {
|
|
132
144
|
try {
|
|
133
|
-
|
|
145
|
+
const markToggle = this.mark ? `const m = document.getElementById("__litclaude_mark"); if (m) m.style.visibility = ${mask ? '"hidden"' : '"visible"'};` : "";
|
|
146
|
+
await this.evaluate(`(async () => { await window.renderFrame(${t}, ${JSON.stringify({ mask })}); ${markToggle} if (document.fonts) await document.fonts.ready; return true; })()`);
|
|
134
147
|
} catch (error) {
|
|
135
148
|
await this.check(`at t = ${t.toFixed(4)}`);
|
|
136
149
|
throw new BlockedError(EXIT.STAGE_CONTRACT_ERROR, `STAGE_CONTRACT_ERROR: renderFrame(${t.toFixed(4)}${mask ? ", { mask: true }" : ""}) threw: ${error.message}`);
|
|
@@ -23,6 +23,8 @@ import { lumaGrid } from "./cover-image.mjs";
|
|
|
23
23
|
import { renderSheet } from "./cover-sheet.mjs";
|
|
24
24
|
import { loadCoverTreatment } from "./cover-treatment.mjs";
|
|
25
25
|
import { findFfmpeg, findImg2webp, which } from "./encode.mjs";
|
|
26
|
+
import { WORDMARK, findClearSpot, markLogoDataUri, markPlan, tagFile } from "../../../../lib/mark.mjs";
|
|
27
|
+
import { decodePng } from "./png.mjs";
|
|
26
28
|
import { asBlocked } from "./pipeline.mjs";
|
|
27
29
|
import { encodePng, rgbaToRgb } from "./png.mjs";
|
|
28
30
|
import { rasterInfo, scanStage, stageFonts } from "./stage-serve.mjs";
|
|
@@ -182,6 +184,33 @@ function readRaster(file, env) {
|
|
|
182
184
|
}
|
|
183
185
|
}
|
|
184
186
|
|
|
187
|
+
/**
|
|
188
|
+
* Place LitClaude's visible corner mark (mark setting `on`) on a cover: sized from the output's short side, put at
|
|
189
|
+
* the clear spot nearest the bottom-right of frame 0, outside the title box and every art check box, in the
|
|
190
|
+
* ground's own ink. Returns the overlay spec in page pixels, or null with a notice when no clear spot exists.
|
|
191
|
+
*/
|
|
192
|
+
async function placeCoverMark(browser, { treatment, assets, notices }) {
|
|
193
|
+
const [pw] = treatment.page;
|
|
194
|
+
const [w] = treatment.out;
|
|
195
|
+
const toPage = pw / w;
|
|
196
|
+
const fontSize = Math.max(WORDMARK.minPx, WORDMARK.cornerShare * Math.min(...treatment.out)) * toPage;
|
|
197
|
+
const h = Math.ceil(fontSize * 1.4);
|
|
198
|
+
const base = { fontSize, h, ink: [0, 0, 0], opacity: WORDMARK.cornerOpacity, text: WORDMARK.text, weight: WORDMARK.weight, tracking: WORDMARK.tracking, logo: { src: markLogoDataUri(), scale: WORDMARK.logoScale, gap: WORDMARK.logoGap } };
|
|
199
|
+
const textW = Math.ceil(await browser.setMark(base, { measure: true }));
|
|
200
|
+
await browser.frame(0);
|
|
201
|
+
const image = decodePng(await browser.capture());
|
|
202
|
+
const k = image.width / pw;
|
|
203
|
+
const frac = ([x, y, bw, bh]) => [x * image.width, y * image.height, (x + bw) * image.width, (y + bh) * image.height];
|
|
204
|
+
const exclude = [frac(treatment.title.box), ...assets.filter((a) => a.checkBox ?? a.box).map((a) => frac(a.checkBox ?? a.box))];
|
|
205
|
+
const spot = findClearSpot(image, { boxW: textW * k, boxH: h * k, inset: WORDMARK.insetShare * Math.min(image.width, image.height), pad: 0.6 * fontSize * k, exclude });
|
|
206
|
+
if (!spot) {
|
|
207
|
+
notices.push("the LitClaude mark found no clear spot in the bottom quarter outside the title and art boxes; this cover carries the invisible tag only");
|
|
208
|
+
browser.mark = null;
|
|
209
|
+
return null;
|
|
210
|
+
}
|
|
211
|
+
return { ...base, x: spot.x / k, y: spot.y / k, w: textW, ink: spot.ink };
|
|
212
|
+
}
|
|
213
|
+
|
|
185
214
|
/** Everything a cover round checks before the first capture: treatment, page, scan, assets, fonts. */
|
|
186
215
|
function prepare({ out, env, log }) {
|
|
187
216
|
const treatment = asBlocked(() => loadCoverTreatment(out));
|
|
@@ -215,6 +244,7 @@ export async function renderCover({ out, round = 1, env = process.env, log = ()
|
|
|
215
244
|
const order = seekOrder(times.length, treatment.seed || 20261020);
|
|
216
245
|
let rung = treatment.recipe === "hero-3d" ? "gpu" : "software";
|
|
217
246
|
const notices = [];
|
|
247
|
+
let coverMark = null;
|
|
218
248
|
try {
|
|
219
249
|
const open = (label) => CoverBrowser.open({ stageDir, faces, width: pw, height: ph, scale: COVER.captureScale, profileDir: path.join(runDir, `chrome-${label}`), rung, env, log });
|
|
220
250
|
let a;
|
|
@@ -229,6 +259,17 @@ export async function renderCover({ out, round = 1, env = process.env, log = ()
|
|
|
229
259
|
a = await open("master");
|
|
230
260
|
}
|
|
231
261
|
try {
|
|
262
|
+
// The mark is placed from frame 0 in a browser of its own, so the capture passes start from the same page
|
|
263
|
+
// state as without it (a page that keeps state between frames is still caught by the seek check).
|
|
264
|
+
if (markPlan({ env }).visible) {
|
|
265
|
+
const m = await open("mark");
|
|
266
|
+
try {
|
|
267
|
+
coverMark = await placeCoverMark(m, { treatment, assets, notices });
|
|
268
|
+
} finally {
|
|
269
|
+
await m.close();
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
if (coverMark) await a.setMark(coverMark);
|
|
232
273
|
master = await capturePass({ browser: a, pool, times, dir: dirs.frames, prefix: "f", width: w, height: h });
|
|
233
274
|
await capturePass({ browser: a, pool, times, dir: dirs.masks, prefix: "m", mask: true, width: w, height: h });
|
|
234
275
|
} finally {
|
|
@@ -236,13 +277,15 @@ export async function renderCover({ out, round = 1, env = process.env, log = ()
|
|
|
236
277
|
}
|
|
237
278
|
const b = await open("replay");
|
|
238
279
|
try {
|
|
239
|
-
|
|
280
|
+
if (coverMark) await b.setMark(coverMark);
|
|
281
|
+
replay =await capturePass({ browser: b, pool, times, dir: dirs.frames2, prefix: "f", width: w, height: h });
|
|
240
282
|
} finally {
|
|
241
283
|
await b.close();
|
|
242
284
|
}
|
|
243
285
|
const c = await open("seek");
|
|
244
286
|
try {
|
|
245
|
-
|
|
287
|
+
if (coverMark) await c.setMark(coverMark);
|
|
288
|
+
sought =await capturePass({ browser: c, pool, times: order.map((i) => times[i]), dir: dirs.seek, prefix: "s", width: w, height: h });
|
|
246
289
|
} finally {
|
|
247
290
|
await c.close();
|
|
248
291
|
}
|
|
@@ -271,6 +314,7 @@ export async function renderCover({ out, round = 1, env = process.env, log = ()
|
|
|
271
314
|
const files = pngFrames(dirs.frames, "f");
|
|
272
315
|
const flash = flashAudit(files, treatment.fps);
|
|
273
316
|
const encoded = encodeCover({ files, fps: treatment.fps, encode: treatment.encode, out, env });
|
|
317
|
+
tagFile(encoded.file, { env });
|
|
274
318
|
for (const stale of COVER_OUTPUTS.filter((f) => path.join(out, f) !== encoded.file)) rmSync(path.join(out, stale), { force: true });
|
|
275
319
|
const planned = times.length * ms;
|
|
276
320
|
const wanted = new Set([0, ...Array.from({ length: SHEET_TILES }, (_, k) => (k / SHEET_TILES) * planned)]);
|
|
@@ -302,6 +346,7 @@ export async function renderCover({ out, round = 1, env = process.env, log = ()
|
|
|
302
346
|
});
|
|
303
347
|
const indexed = stills.finish(sheetFile);
|
|
304
348
|
writeFileSync(path.join(out, "poster.png"), readFileSync(path.join(stills.dir, "poster.png")));
|
|
349
|
+
tagFile(path.join(out, "poster.png"), { env });
|
|
305
350
|
const report = `${formatCoverReport(gate, { strict: true })}${notices.map((n) => `warning: ${n}\n`).join("")}`;
|
|
306
351
|
writeFileSync(path.join(out, "gate-report.txt"), report);
|
|
307
352
|
const manifest = {
|
|
@@ -309,6 +354,7 @@ export async function renderCover({ out, round = 1, env = process.env, log = ()
|
|
|
309
354
|
treatmentSha256: sha256(readFileSync(path.join(out, "treatment.json"))), stillsSha256: indexed.sha256,
|
|
310
355
|
page: treatment.page, size: treatment.out, scale: COVER.captureScale, rung, warnings: notices, fps: treatment.fps, frames: times.length, frameMs: ms,
|
|
311
356
|
encoder: encoded.encoder, encode: treatment.encode, file: path.basename(encoded.file), bytes: statSync(encoded.file).size, captureSec,
|
|
357
|
+
mark: coverMark ? { text: coverMark.text, x: +coverMark.x.toFixed(1), y: +coverMark.y.toFixed(1), w: coverMark.w, fontSize: +coverMark.fontSize.toFixed(2), ink: coverMark.ink } : null,
|
|
312
358
|
gate: { pass: gate.pass, target: gate.target, medianD: gate.medianD, movingFrac: gate.movingFrac, longestStillSec: gate.longestStillSec, spike: gate.spike, seamLocal: gate.seamLocal, gates: gate.gates },
|
|
313
359
|
};
|
|
314
360
|
writeJson(path.join(out, "manifest.json"), manifest);
|
|
@@ -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
|
-
/**
|
|
222
|
-
|
|
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
|
-
|
|
281
|
-
|
|
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
|
|
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:
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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", `${
|
|
30
|
-
: r("MO-C-12", "PASS", `${
|
|
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
|
}
|