Skip to content

Art and animation, written as code. Illustrations, loops, interactive web art, launch-videos and scored films in dozens of styles, identical on every render.

launch.mjs: 'new <name> [--preset clean]' scaffolds a launch spec with every product line marked TODO (renders as is, never overwrites); 'ship <name> --shapes ...' renders each shape, writes its poster frame and .srt/.vtt captions, runs verify-export --delivery (and --gate), one table, exit 1 on any failure

Alex Greenshpun4f36e855f03a
diff --git a/skills/anidoodle/engine/tools/launch.mjs b/skills/anidoodle/engine/tools/launch.mjs
new file mode 100644
index 0000000..6ba209f
--- /dev/null
+++ b/skills/anidoodle/engine/tools/launch.mjs
@@ -0,0 +1,124 @@
+// LAUNCH. The launch film's two commands: start one, and ship it in every shape.
+//
+// node tools/launch.mjs new <name> [--preset drawn|clean]
+// writes src/canvas-core/<name>.ts (a launch template spec to fill from the brief: every line
+// that must come from the product is marked TODO) and its host page src/hosts/page-<name>.ts.
+// It renders as it is (placeholder plates and UI), so the pipeline can be proved before the art.
+//
+// node tools/launch.mjs ship <name> [--shapes 16x9,1x1,4x5,9x16] [--blur auto] [--shutter 180]
+// [--poster-frame N] [--gate]
+// for each shape, from ONE timeline (launchLayout re-composes it, never a crop):
+// 1 render out/<name>-<shape>.mp4 (render.mjs; --blur/--shutter/--poster-frame pass through)
+// 2 poster out/<name>-<shape>.poster.png, the film's own legible frame (meta.poster: the end card)
+// 3 captions out/<name>-<shape>.srt and .vtt (the sidecar; captions: "burn" also burns them in)
+// 4 verify verify-export --delivery: size, frame count, duration, the score, the sync of every
+// marker, the true peak after the encode, a legible frame 0
+// 5 gate with --gate: gate.mjs (determinism, contract, dead air) on the rendered file
+// then one table. Exit 1 if any shape fails anything.
+import { spawnSync } from "node:child_process";
+import { existsSync, mkdirSync, writeFileSync } from "node:fs";
+import { resolve } from "node:path";
+import { knownFilms, requireFilm, SHAPE_NAMES } from "./names.mjs";
+import { filmMeta, writeCaptions } from "./captions.mjs";
+
+const [cmd, name, ...rest] = process.argv.slice(2);
+const arg = (k, d) => { const i = rest.indexOf(`--${k}`); return i >= 0 ? rest[i + 1] : d; };
+const die = (m) => { console.error(`launch: ${m}`); process.exit(2); };
+const USAGE = "node tools/launch.mjs new <name> [--preset drawn|clean]\n node tools/launch.mjs ship <name> [--shapes 16x9,1x1,4x5,9x16] [--blur auto] [--shutter 180] [--poster-frame N] [--gate]";
+
+const DRAWN = (n) => `// ${n}: a launch film on the template (references/workflows/launch-video-kit.md).
+// Fill every TODO from the sourced brief (references/workflows/launch-video.md, "Ground it in the real
+// product first"): the words on screen quote the brief, never memory. The plates below are STAND-INS
+// (anidoodle's stock plates) so the film renders today; replace each with a plate drawn for YOUR
+// product's subject, in the style the brief chose (references/styles.md).
+// node tools/still.mjs ${n}-9x16 --frames 0,120,330 --sheet out/${n}-9x16.jpg one look per shape, one browser
+// node tools/launch.mjs ship ${n} --shapes 16x9,1x1,9x16
+import { C } from "./launchKit";
+import { makeLaunchFilm } from "./launchTemplate";
+import { lighthouseDraw } from "./lighthouseDraw"; // TODO: your plate
+import { foxDraw } from "./foxDraw"; // TODO: your plate
+
+export const ${n} = makeLaunchFilm({
+ title: "TODO Product", // the exact product name
+ subtitle: "TODO the one line it lives by",
+ placeholder: "Ask for anything…",
+ asks: [
+ { prompt: "TODO what a user types, in their words", plate: lighthouseDraw, label: "TODO the card's byline" },
+ { prompt: "TODO the follow-up", plate: foxDraw, label: "TODO byline" },
+ ],
+ words: [[{ text: "TODO CLAIM.", style: "ink", color: C.ink }, { text: "TODO PROOF.", style: "ink", color: C.accent }]],
+ tagline: "TODO one sentence that says what it is",
+ install: ["TODO the exact install line"], // shown exactly as given, held 3 s or more
+ footer: "TODO where it lives",
+ bpm: 90, // TODO the tempo of the score composed for this brief
+ askBeats: 6, typeBeats: 4, endBeats: 8, claimBar: 4,
+ score: null, // TODO the score composed for this product (references/music/compose.md)
+});
+`;
+const CLEAN = (n) => `// ${n}: a UI-first launch film on the template, in the clean preset (a quiet canvas, one accent,
+// type as the design). Fill every TODO from the sourced brief; the UI data below is a STAND-IN:
+// replace it with your product's real screens and states (references/workflows/launch-video-kit.md).
+// node tools/launch.mjs ship ${n} --shapes 16x9,9x16
+import { makeLaunchFilm } from "./launchTemplate";
+import type { ProductUI } from "./productUI";
+
+const main: ProductUI = { // TODO your product's own UI, its before and after
+ title: "TODO", nav: ["TODO", "TODO"], action: "TODO action", command: "TODO Ask…",
+ before: { items: [{ id: "a", label: "TODO item", value: 3, tag: "TODO" }, { id: "b", label: "TODO item", value: 8 }] },
+ after: { items: [{ id: "b", label: "TODO item", value: 0, done: true, accent: true }, { id: "a", label: "TODO item", value: 0, done: true }] },
+};
+
+export const ${n} = makeLaunchFilm({
+ title: "TODO Product", preset: "clean", fps: 60,
+ asks: [
+ { kind: "ui", ui: main, prompt: "TODO what a user asks the product" },
+ { kind: "ui", ui: main, split: [{ text: "TODO the feature,", style: "ink", color: "#15161a" }, { text: "TODO in five words.", style: "ink", color: "#2f54eb" }] },
+ ],
+ words: [[{ text: "TODO CLAIM.", style: "ink", color: "#15161a" }]],
+ tagline: "TODO one sentence that says what it is",
+ install: ["TODO the exact install line"],
+ footer: "TODO where it lives",
+ bpm: 90, askBeats: 6, typeBeats: 4, endBeats: 8, claimBar: 4,
+ score: null, // TODO the score composed for this product
+});
+`;
+
+if (cmd === "new") {
+ if (!name || !/^[A-Za-z_$][\w$]*$/.test(name)) die(`'${name ?? ""}' is not a film name (a JS identifier, e.g. myLaunch)\nusage: ${USAGE}`);
+ const src = resolve(`src/canvas-core/${name}.ts`), host = resolve(`src/hosts/page-${name}.ts`), preset = arg("preset", "drawn");
+ if (!["drawn", "clean"].includes(preset)) die(`--preset is drawn or clean, got '${preset}'`);
+ if (existsSync(src) || existsSync(host) || knownFilms().includes(name)) die(`${name} already exists; pick another name (never overwritten)`);
+ writeFileSync(src, (preset === "clean" ? CLEAN : DRAWN)(name));
+ writeFileSync(host, `import { ${name} } from "../canvas-core/${name}";\nimport { mountFilm } from "./page";\n\nmountFilm(${name});\n`);
+ console.log(`new launch film: ${src}\n host: ${host}\nnext: fill the TODOs from the brief, then\n node tools/still.mjs ${name} --frames 0,120,330 --sheet out/${name}.jpg\n node tools/launch.mjs ship ${name} --shapes 16x9,9x16`);
+ process.exit(0);
+}
+if (cmd !== "ship") die(`unknown command '${cmd ?? ""}'\nusage: ${USAGE}`);
+
+const film = requireFilm(name, "launch ship", USAGE);
+const shapes = String(arg("shapes", "16x9")).split(",").map((s) => s.trim()).filter(Boolean);
+const bad = shapes.filter((s) => !SHAPE_NAMES.includes(s)); if (bad.length || !shapes.length) die(`--shapes wants ${SHAPE_NAMES.join(", ")}, got '${arg("shapes")}'`);
+const pass = ["blur", "shutter", "poster-frame", "blur-max", "blur-px"].flatMap((k) => (arg(k) !== undefined ? [`--${k}`, arg(k)] : []));
+const node = (args) => spawnSync(process.execPath, args, { stdio: "inherit" }).status === 0;
+const quiet = (args) => { const r = spawnSync(process.execPath, args, { encoding: "utf8", maxBuffer: 1 << 26 }); return { ok: r.status === 0, out: (r.stdout ?? "") + (r.stderr ?? "") }; };
+mkdirSync(resolve("out"), { recursive: true });
+const rows = [];
+for (const sh of shapes) {
+ const f = `${film}-${sh}`, mp4 = `out/${f}.mp4`, row = { shape: sh, mp4, render: false, poster: "", captions: 0, verify: "", gate: "" };
+ console.log(`\n==================== ${f} ====================`);
+ row.render = node(["tools/render.mjs", f, ...pass]);
+ if (row.render) {
+ const meta = await filmMeta(f), pf = meta.poster ?? Math.max(0, meta.durationFrames - 1), png = `out/${f}.poster.png`;
+ row.poster = quiet(["tools/still.mjs", f, "--frame", String(pf), "--out", png]).ok ? `${png} (frame ${pf})` : "FAIL";
+ row.captions = (await writeCaptions(f)).count;
+ const v = quiet(["tools/verify-export.mjs", f, "--file", mp4, "--delivery"]); console.log(v.out.split("\n").filter((l) => /FAIL|PASS (frame|true peak|decoded)|VERIFY-EXPORT/.test(l)).join("\n"));
+ row.verify = (v.out.match(/VERIFY-EXPORT: (PASS|FAIL)[^\n]*/) ?? ["", "FAIL"])[0].replace("VERIFY-EXPORT: ", "");
+ if (rest.includes("--gate")) { const g = quiet(["tools/gate.mjs", f, "--mp4", mp4]); row.gate = (g.out.match(/GATE: (PASS|FAIL)[^\n]*/) ?? [g.ok ? "PASS" : "FAIL"])[0]; if (!g.ok) console.log(g.out.split("\n").filter((l) => /FAIL/.test(l)).join("\n")); }
+ }
+ rows.push(row);
+}
+console.log(`\nSHIP ${film}`);
+for (const r of rows) console.log(` ${r.shape.padEnd(5)} ${r.render ? r.mp4 : "RENDER FAILED"}\n verify ${r.verify || "-"}${r.gate ? ` gate ${r.gate}` : ""}\n poster ${r.poster || "-"} captions ${r.captions} cues -> out/${film}-${r.shape}.srt/.vtt`);
+const ok = rows.every((r) => r.render && /^PASS/.test(r.verify) && r.poster !== "FAIL" && (!r.gate || /PASS/.test(r.gate)));
+console.log(ok ? `\nSHIP: PASS ${rows.length} shape(s)` : "\nSHIP: FAIL");
+process.exit(ok ? 0 : 1);