commit fe30313e52b41eb06b30eaf1feb39c3c60b83651
parent 458fbbf518bdae09c1ec17e6e52c33ff58d4934e
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Thu, 15 Oct 2026 07:13:06 -0400
umtool: Draft everything's deck option — a `deck` step before the flips (chain body `deck`, `umtool chain --deck`, "with the deck" beside the button) adds the minimal on-screen deck (`deckChrome`, now the On-screen switch's too) through the manifest writer (`addDeckChrome`: an auto-before-deck snapshot, then validateChrome) only when the cut has no render.chrome; its line says "deck added" or "deck already there"; off, the chain is as it was. Tests: the plan (chain.test), the step over a temp store (chain-draft.test), and flips and threads drafted on a converted cut given the deck over the fake ollama (common deckOption.test)
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
13 files changed, 357 insertions(+), 40 deletions(-)
diff --git a/common/lib/report/draft/tasks/deckOption.test.ts b/common/lib/report/draft/tasks/deckOption.test.ts
@@ -0,0 +1,149 @@
+// Draft everything's deck option (release 29 G1), the common side: a cut the
+// converter made has no deck, so flips and threads have nothing to draw on
+// (draftPrecheck skips them, the tasks refuse). umtool's deck step adds the
+// minimal deck through its manifest writer (manifest.mjs addDeckChrome, with
+// chain-draft.mjs deckChrome — loaded from the checkout, as deckChecks loads
+// report-to-video); then the flips and the threads draft on that cut over the
+// fake ollama, with the synthetic corpus's upload dates.
+
+import { after, before, test } from "node:test";
+import assert from "node:assert/strict";
+import { mkdir, mkdtemp, readdir, readFile, rm, writeFile } from "node:fs/promises";
+import os from "node:os";
+import path from "node:path";
+import { jsonReply, startFakeOllama, type FakeOllama } from "../../../../testing/llm/fakeOllama.mjs";
+import { recordOf } from "../../../../testing/draft/corpus.mjs";
+import { createIteration, projectOf, updateIteration, writeIterationFile } from "../../iterations";
+import { flips } from "./flips";
+import { threads } from "./threads";
+import type { TaskDeps } from "./types";
+
+const DRAFT = new URL("../../../../testing/draft/", import.meta.url);
+const UMTOOL = new URL("../../../../../umtool/lib/report/", import.meta.url);
+const kit = async (rel: string) => JSON.parse(await readFile(new URL(rel, DRAFT), "utf8"));
+
+type DeckStep = {
+ addDeckChrome: (dir: string, chrome: Record<string, unknown>) => Promise<{ added: boolean }>;
+ deckChrome: () => Record<string, unknown>;
+ draftPrecheck: (task: string, manifest: unknown) => string | null;
+};
+
+let tmp: string;
+let ol: FakeOllama;
+let umtool: DeckStep;
+before(async () => {
+ tmp = await mkdtemp(path.join(os.tmpdir(), "deck-option-"));
+ ol = await startFakeOllama();
+ const manifest = await import(new URL("manifest.mjs", UMTOOL).href);
+ const chainDraft = await import(new URL("chain-draft.mjs", UMTOOL).href);
+ umtool = { addDeckChrome: manifest.addDeckChrome, deckChrome: chainDraft.deckChrome, draftPrecheck: chainDraft.draftPrecheck };
+});
+after(async () => {
+ await ol.close();
+ await rm(tmp, { recursive: true, force: true });
+});
+
+const corpus = {
+ source: "fake",
+ tools: [],
+ call: async (name: string, args: Record<string, unknown> = {}) => {
+ if (name !== "get_video_metadata") return "";
+ const r = recordOf(String(args.channel), String(args.video_id));
+ if (!r) throw new Error("video not found");
+ const { cues: _c, ...meta } = r;
+ return JSON.stringify(meta);
+ },
+};
+
+let caseN = 0;
+// The kit's basic report and the cut the converter makes of it (no render.chrome).
+async function convertedCut() {
+ caseN++;
+ const paths = { articlesDir: path.join(tmp, `reports-${caseN}`), exportIndexDir: path.join(tmp, `idx-${caseN}`) };
+ const projectsRoot = path.join(tmp, `projects-${caseN}`);
+ await mkdir(paths.articlesDir, { recursive: true });
+ await createIteration("synth-basic", { kind: "sweep", model: "qwen3:8b", question: "q", scope: { channels: ["synth-kitchen"] } }, paths);
+ const report = await kit("reports/basic.report.json");
+ await writeIterationFile("synth-basic", 1, "report.json", report, paths);
+ const dir = projectOf(projectsRoot, "synth-basic", 1);
+ await mkdir(dir, { recursive: true });
+ const manifest = await kit("manifests/basic.video.manifest.json");
+ assert.equal(manifest.render.chrome, undefined, "the converter's cut has no deck");
+ await writeFile(path.join(dir, "video.manifest.json"), `${JSON.stringify(manifest, null, 2)}\n`);
+ await writeFile(path.join(dir, "report.json"), JSON.stringify(report));
+ await updateIteration("synth-basic", 1, { status: "done", projectDir: dir }, paths);
+ const deps: TaskDeps = {
+ llm: { ollama: { baseUrl: ol.url } },
+ corpus,
+ cuesOf: async () => null,
+ paths,
+ log: () => {},
+ now: () => new Date("2026-10-15T12:00:00.000Z"),
+ };
+ const input = { article: "synth-basic", n: 1, model: "qwen3:8b", projectsRoot };
+ const manifestNow = async () => JSON.parse(await readFile(path.join(dir, "video.manifest.json"), "utf8"));
+ return { dir, deps, input, manifestNow };
+}
+
+test("a converted cut: no deck, the flips refused; the deck step adds the minimal deck (a snapshot first), then the flips draft", async () => {
+ const p = await convertedCut();
+ assert.match(umtool.draftPrecheck("flips", await p.manifestNow()) ?? "", /no on-screen deck/);
+ const refused = await flips(p.input, p.deps);
+ assert.equal(refused.status, "failed");
+
+ const r = await umtool.addDeckChrome(p.dir, umtool.deckChrome());
+ assert.equal(r.added, true);
+ const m = await p.manifestNow();
+ assert.deepEqual(m.render.chrome, { engine: "hyperframes", layout: "deck", deck: {} });
+ assert.equal(umtool.draftPrecheck("flips", m), null);
+ assert.ok((await readdir(path.join(p.dir, "revisions"))).some((f) => f.includes("auto-before-deck")), "the cut before the deck is kept");
+
+ ol.push(jsonReply({ pairs: [{ topic: "The bakery", then: "c01", now: "c04" }] }));
+ const res = await flips(p.input, p.deps);
+ assert.equal(res.status, "done", res.summary);
+ const after = await p.manifestNow();
+ assert.equal(after.render.chrome.flips.pairs.length, 1);
+ assert.equal(after.render.chrome.flips.pairs[0].then.entry, "c01");
+ assert.equal(after.render.chrome.flips.pairs[0].now.entry, "c04");
+ assert.equal(after.drafted["render.chrome.flips"].task, "flips");
+});
+
+test("the deck step on a cut with a deck leaves it as it is; the threads draft on a converted cut given the deck", async () => {
+ const p = await convertedCut();
+ assert.equal((await umtool.addDeckChrome(p.dir, umtool.deckChrome())).added, true);
+ const once = await readFile(path.join(p.dir, "video.manifest.json"), "utf8");
+ assert.equal((await umtool.addDeckChrome(p.dir, umtool.deckChrome())).added, false);
+ assert.equal(await readFile(path.join(p.dir, "video.manifest.json"), "utf8"), once, "byte for byte");
+
+ ol.push(
+ jsonReply({
+ threads: [
+ { id: "bakery", label: "The bakery" },
+ { id: "contest", label: "The contest" },
+ ],
+ clips: [
+ { clip: "c01", thread: "bakery" },
+ { clip: "c02", thread: "bakery" },
+ { clip: "c03", thread: "bakery" },
+ { clip: "c04", thread: "contest" },
+ { clip: "c05", thread: "contest" },
+ { clip: "c06", thread: "contest" },
+ ],
+ }),
+ );
+ const res = await threads(p.input, p.deps);
+ assert.equal(res.status, "done", res.summary);
+ const m = await p.manifestNow();
+ assert.deepEqual(m.render.chrome.threads.list.map((t: { id: string }) => t.id), ["bakery", "contest"]);
+ assert.equal(m.timeline.find((e: { id: string }) => e.id === "c05").thread, "contest");
+});
+
+test("a cut whose deck the operator set is never touched by the deck step", async () => {
+ const p = await convertedCut();
+ const m = await p.manifestNow();
+ m.render.chrome = { engine: "hyperframes", layout: "deck", deck: { height: 200 } };
+ await writeFile(path.join(p.dir, "video.manifest.json"), `${JSON.stringify(m, null, 2)}\n`);
+ const before = await readFile(path.join(p.dir, "video.manifest.json"), "utf8");
+ assert.equal((await umtool.addDeckChrome(p.dir, umtool.deckChrome())).added, false);
+ assert.equal(await readFile(path.join(p.dir, "video.manifest.json"), "utf8"), before);
+});
diff --git a/umtool/app/api/articles/chain/route.ts b/umtool/app/api/articles/chain/route.ts
@@ -12,13 +12,15 @@ export const dynamic = "force-dynamic";
// iteration's `steps`, so a start resumes at the first step not done, or at
// `from`. The projects root is the editor's policy's (generation.projectsRoot).
//
-// GET ?article=<id>&n=<n>[&mode=draft-all] -> { chain } the steps, where it resumes, its job
-// POST { article, n, from?, draftAll?, model? } -> { ok, job } started
+// GET ?article=<id>&n=<n>[&mode=draft-all][&deck=1] -> { chain } the steps, where it resumes, its job
+// POST { article, n, from?, draftAll?, model?, deck? } -> { ok, job } started
// POST { cancel: <jobId> } -> { cancelled }
//
// `draftAll` is Draft everything (release 28 M9): the chain with its
// generation steps — each a report-draft job on `model` (else the task's
// route) — and the fast build; a job of its own kind, resumed as the chain is.
+// `deck` (release 29 G1, Draft everything's option, off by default) adds the
+// deck step before the flips: the minimal on-screen deck on a cut with none.
function parse(article: unknown, n: unknown): { article: string; n: number } | string {
const a = String(article ?? "");
const k = Number(n);
@@ -27,11 +29,11 @@ function parse(article: unknown, n: unknown): { article: string; n: number } | s
return { article: a, n: k };
}
-async function chainOf(article: string, n: number, mode: ChainMode = "video") {
+async function chainOf(article: string, n: number, mode: ChainMode = "video", deck = false) {
const its = await readArticleIterations(article);
const it = its.iterations.find((r) => r.n === n);
if (!it) return null;
- return chainViewOf(article, it, mode);
+ return chainViewOf(article, it, mode, { deck });
}
const modeOf = (v: unknown): ChainMode => (v === "draft-all" || v === true ? "draft-all" : "video");
@@ -41,7 +43,7 @@ export async function GET(request: Request) {
const p = parse(url.searchParams.get("article"), url.searchParams.get("n"));
if (typeof p === "string") return Response.json({ error: p }, { status: 400 });
try {
- const chain = await chainOf(p.article, p.n, modeOf(url.searchParams.get("mode")));
+ const chain = await chainOf(p.article, p.n, modeOf(url.searchParams.get("mode")), url.searchParams.get("deck") === "1");
if (!chain) return Response.json({ error: `no iteration i${p.n}` }, { status: 404 });
return Response.json({ chain }, { headers: { "cache-control": "no-store" } });
} catch (err) {
@@ -50,7 +52,7 @@ export async function GET(request: Request) {
}
export async function POST(request: Request) {
- const body = (await request.json().catch(() => ({}))) as { article?: unknown; n?: unknown; from?: unknown; cancel?: unknown; draftAll?: unknown; model?: unknown };
+ const body = (await request.json().catch(() => ({}))) as { article?: unknown; n?: unknown; from?: unknown; cancel?: unknown; draftAll?: unknown; model?: unknown; deck?: unknown };
if (body.cancel !== undefined) {
const id = String(body.cancel);
if (!getJob(id)) return Response.json({ error: "no such job" }, { status: 404 });
@@ -69,10 +71,12 @@ export async function POST(request: Request) {
const mode = modeOf(body.draftAll === true);
const model = typeof body.model === "string" && body.model.trim() ? body.model.trim() : undefined;
if (model && mode !== "draft-all") return Response.json({ error: "a model is Draft everything's (draftAll): the model its drafts run on" }, { status: 400 });
- const plan = planChain({ articlesDir: ARTICLES_DIR, article: p.article, n: p.n, from, mode, ...(model ? { model } : {}), ...(projectsRoot ? { projectsRoot } : {}) });
+ const deck = body.deck === true;
+ if (deck && mode !== "draft-all") return Response.json({ error: "the deck is Draft everything's option (draftAll)" }, { status: 400 });
+ const plan = planChain({ articlesDir: ARTICLES_DIR, article: p.article, n: p.n, from, mode, ...(deck ? { deck } : {}), ...(model ? { model } : {}), ...(projectsRoot ? { projectsRoot } : {}) });
if (plan.steps.length === 0) return Response.json({ error: `every step of ${mode === "draft-all" ? "Draft everything" : "the chain"} is done — pick a step to run from` }, { status: 400 });
const job = startJob(chainKind(p.article, p.n, mode), plan.steps);
- return Response.json({ ok: true, job: { id: job.id }, chain: await chainOf(p.article, p.n, mode) });
+ return Response.json({ ok: true, job: { id: job.id }, chain: await chainOf(p.article, p.n, mode, deck) });
} catch (err) {
return Response.json({ error: (err as Error).message }, { status: 400 });
}
diff --git a/umtool/bin/umtool.mjs b/umtool/bin/umtool.mjs
@@ -26,10 +26,11 @@
// umtool corrections <project> what the report got wrong, as markdown for the next pass
// umtool build <project> [--preset preview|fast|final] [--only ID] [--dry]
// umtool chain <article> <n> [--from <step>] [--dry] [--final] [--projects-root DIR] [--site-origin URL]
-// [--draft-all [--model M]]
+// [--draft-all [--model M] [--deck]]
// an iteration's pipeline: current, windows, prepare, posts, manifest,
// voices, video, podcast, attach, dedupe (resumes at the first step not done);
-// --draft-all is Draft everything: the drafts between manifest and the fast build
+// --draft-all is Draft everything: the drafts between manifest and the fast build;
+// --deck adds the on-screen deck to a cut with none before the flips
// umtool index [--rebuild] [--prune] [--since MS] [--json]
// umtool new <slug> [--kind report-video] [--from <report.md>|<share URL>|<channel>/<id>]
// [--site-origin URL] [--seed chapters] [--brand archilyzer-media]
@@ -683,11 +684,12 @@ function usage() {
" an empty value (--title '') deletes the field",
" umtool corrections <project> what the report got wrong + the walk's coverage",
" umtool build <project> [--preset preview|fast|final] [--only ID]",
- " umtool chain <article> <n> [--from <step>] [--dry] [--final] [--projects-root DIR] [--site-origin URL] [--draft-all [--model M]]",
+ " umtool chain <article> <n> [--from <step>] [--dry] [--final] [--projects-root DIR] [--site-origin URL] [--draft-all [--model M] [--deck]]",
` an article iteration's pipeline, one step a process: ${CHAIN_STEP_NAMES.join(", ")}`,
" (resumes at the first step not done; --dry prints it; the project is <root>/<article>/i<n>/)",
` --draft-all (Draft everything): ${chainStepsOf("draft-all").map((s) => s.name).join(", ")} —`,
- " each draft a report-draft job on --model (else its route); a draft that fails does not stop it",
+ " each draft a report-draft job on --model (else its route); a draft that fails does not stop it;",
+ " --deck adds a step before the flips: the minimal on-screen deck on a cut with none",
" umtool index [--rebuild] [--prune] [--since MS] [--json]",
" umtool new <slug> [--from <report.md>|<share URL>|<channel>/<id>] [--site-origin URL] [--seed chapters]",
" [--brand archilyzer-media] render.brand: the report-to-video brand preset",
@@ -970,11 +972,13 @@ async function cmdChain() {
const article = positional[0];
const n = Number(positional[1]);
if (!article || !Number.isInteger(n) || n < 1) {
- die("usage: umtool chain <article> <n> [--from <step>] [--dry] [--final] [--projects-root DIR] [--site-origin URL] [--draft-all [--model M]]");
+ die("usage: umtool chain <article> <n> [--from <step>] [--dry] [--final] [--projects-root DIR] [--site-origin URL] [--draft-all [--model M] [--deck]]");
}
const draftAll = has("--draft-all");
if (val("--model") && !draftAll) die("--model is Draft everything's (--draft-all): the model its drafts run on");
if (draftAll && has("--final")) die("--draft-all builds the fast cut: a final build refuses drafts nobody has reviewed");
+ const deck = has("--deck");
+ if (deck && !draftAll) die("--deck is Draft everything's option (--draft-all): the deck the flips and threads draw on");
let plan;
try {
plan = planChain({
@@ -985,13 +989,13 @@ async function cmdChain() {
...(val("--projects-root") ? { projectsRoot: path.resolve(val("--projects-root")) } : {}),
...(val("--site-origin") ? { siteOrigin: val("--site-origin") } : {}),
final: has("--final"),
- ...(draftAll ? { mode: "draft-all", ...(val("--model") ? { model: val("--model") } : {}) } : {}),
+ ...(draftAll ? { mode: "draft-all", ...(val("--model") ? { model: val("--model") } : {}), ...(deck ? { deck: true } : {}) } : {}),
});
} catch (err) {
die(err.message);
}
const { start, steps } = plan;
- const again = `umtool chain ${article} ${n}${draftAll ? " --draft-all" : ""}`;
+ const again = `umtool chain ${article} ${n}${draftAll ? ` --draft-all${deck ? " --deck" : ""}` : ""}`;
if (json && has("--dry")) return out({ article, n, start, steps });
if (steps.length === 0) {
console.log(`${article} i${n}: every step of the ${draftAll ? "Draft everything chain" : "chain"} is done (--from <step> runs one again)`);
diff --git a/umtool/components/articles/ChainPanel.tsx b/umtool/components/articles/ChainPanel.tsx
@@ -18,6 +18,7 @@ export default function ChainPanel({
label,
mode = "video",
model,
+ deck = false,
autoStart = false,
}: {
article: string;
@@ -25,6 +26,8 @@ export default function ChainPanel({
label: string;
mode?: ChainMode;
model?: string;
+ /** Draft everything with its deck step (release 29 G1). */
+ deck?: boolean;
autoStart?: boolean;
}) {
const draftAll = mode === "draft-all";
@@ -35,7 +38,7 @@ export default function ChainPanel({
const [sending, setSending] = useState(false);
const load = useCallback(async () => {
- const r = await fetch(`/api/articles/chain?article=${encodeURIComponent(article)}&n=${n}${draftAll ? "&mode=draft-all" : ""}`, { cache: "no-store" });
+ const r = await fetch(`/api/articles/chain?article=${encodeURIComponent(article)}&n=${n}${draftAll ? `&mode=draft-all${deck ? "&deck=1" : ""}` : ""}`, { cache: "no-store" });
const b = await r.json();
if (!r.ok) {
setError(b.error ?? `HTTP ${r.status}`);
@@ -43,7 +46,7 @@ export default function ChainPanel({
}
setChain(b.chain);
return b.chain as ChainView;
- }, [article, n, draftAll]);
+ }, [article, n, draftAll, deck]);
const running = chain?.job?.state === "running";
useEffect(() => {
@@ -61,7 +64,7 @@ export default function ChainPanel({
try {
const r = await fetch("/api/articles/chain", {
method: "POST",
- body: JSON.stringify({ article, n, ...(from ? { from } : {}), ...(draftAll ? { draftAll: true, ...(model ? { model } : {}) } : {}) }),
+ body: JSON.stringify({ article, n, ...(from ? { from } : {}), ...(draftAll ? { draftAll: true, ...(model ? { model } : {}), ...(deck ? { deck: true } : {}) } : {}) }),
});
const b = await r.json();
if (!r.ok) throw new Error(b.error ?? `HTTP ${r.status}`);
@@ -72,7 +75,7 @@ export default function ChainPanel({
} finally {
setSending(false);
}
- }, [article, n, from, draftAll, model, load]);
+ }, [article, n, from, draftAll, model, deck, load]);
useEffect(() => {
if (!autoStart || started.current) return;
@@ -109,7 +112,8 @@ export default function ChainPanel({
>
{draftAll && (
<p className="text-[11.5px] text-muted">
- {model ? <span className="font-mono">{model}</span> : "each task's route"} · a draft that fails does not stop the chain · the build is the fast one · review the drafts before a final build
+ {model ? <span className="font-mono">{model}</span> : "each task's route"}
+ {deck ? " · with the deck" : ""} · a draft that fails does not stop the chain · the build is the fast one · review the drafts before a final build
</p>
)}
{chain && (
diff --git a/umtool/components/projects/MediaDrafts.tsx b/umtool/components/projects/MediaDrafts.tsx
@@ -438,6 +438,11 @@ export default function MediaDrafts({
const [only, setOnly] = useState<string | null>(null);
const [allModel, setAllModel] = useState("");
const [allRun, setAllRun] = useState(0);
+ // Draft everything's deck option (release 29 G1, off by default): ticked,
+ // the chain adds the minimal deck to a cut with none before the flips. The
+ // run keeps the value it was started with.
+ const [allDeck, setAllDeck] = useState(false);
+ const [runDeck, setRunDeck] = useState(false);
const allModels = modelsFor(policy, "onscreen");
useEffect(() => {
if (!allModel && allModels.route) setAllModel(allModels.route);
@@ -521,12 +526,19 @@ export default function MediaDrafts({
</option>
))}
</select>
+ <label className="flex items-center gap-1 text-[12px] text-muted" title="Adds the on-screen deck to a cut with none, so the flips and threads are drafted too">
+ <input type="checkbox" data-draft-everything-deck="" checked={allDeck} onChange={(e) => setAllDeck(e.target.checked)} disabled={!policy} />
+ with the deck
+ </label>
<button
type="button"
data-draft-everything=""
className={buttonVariants({ variant: "outline", size: "md" })}
disabled={!policy}
- onClick={() => setAllRun((k) => k + 1)}
+ onClick={() => {
+ setRunDeck(allDeck);
+ setAllRun((k) => k + 1);
+ }}
>
Draft everything
</button>
@@ -551,7 +563,7 @@ export default function MediaDrafts({
</p>
)
)}
- {link.ok && allRun > 0 && <ChainPanel key={allRun} article={link.article} n={link.n} label={`i${link.n}`} mode="draft-all" model={allModel} autoStart />}
+ {link.ok && allRun > 0 && <ChainPanel key={allRun} article={link.article} n={link.n} label={`i${link.n}`} mode="draft-all" model={allModel} deck={runDeck} autoStart />}
<div className="flex flex-wrap gap-1.5" role="group" aria-label="Sections">
<button type="button" data-media-chip="all" aria-pressed={only === null} onClick={() => setOnly(null)} className={chipClass(only === null)}>
All <span className="font-mono text-[11px] text-meter">{total}</span>
diff --git a/umtool/components/projects/OnscreenSection.tsx b/umtool/components/projects/OnscreenSection.tsx
@@ -11,6 +11,7 @@ import { badgeVariants } from "@/components/ui/badge";
import { buttonVariants } from "@/components/ui/button";
import { backdropTransform, footageAt } from "@/lib/report/footage-move.mjs";
import { VERDICTS } from "umtool-report-to-video/factcheck";
+import { deckChrome } from "@/lib/report/chain-draft.mjs";
// ---------------------------------------------------------------------------
// ON-SCREEN: the persistent panel under the footage of a report cut.
@@ -1050,7 +1051,7 @@ export default function OnscreenSection({
return;
}
setSwitching(on);
- const ok = await putChrome(on ? { engine: "hyperframes", layout: "deck", deck: {} } : null);
+ const ok = await putChrome(on ? deckChrome() : null);
if (!ok) {
setSwitching(null);
return;
diff --git a/umtool/lib/articles/generation.ts b/umtool/lib/articles/generation.ts
@@ -362,6 +362,8 @@ function projectIdOfDir(dir: string | null): string | null {
export type ChainMode = "video" | "draft-all";
export type ChainView = {
mode: ChainMode;
+ /** Draft everything with its deck step (release 29 G1). */
+ deck: boolean;
steps: { name: string; label: string; status: string; optional: boolean; detail: string | null }[];
/** Where a start resumes: the first step not done, or null (all done). */
resumeAt: string | null;
@@ -488,19 +490,25 @@ export function projectsRootOf(gen: GenerationSettings): string {
return gen.projectsRoot ? expandHome(gen.projectsRoot) : DEFAULT_PROJECTS_ROOT;
}
-export function chainViewOf(article: string, it: IterationRow, mode: ChainMode = "video"): ChainView {
+/**
+ * An iteration's chain as umtool shows it. `deck` (Draft everything's option,
+ * release 29 G1) lists the deck step; so does an iteration that recorded one.
+ */
+export function chainViewOf(article: string, it: IterationRow, mode: ChainMode = "video", { deck = false }: { deck?: boolean } = {}): ChainView {
const done = new Set(doneSteps({ steps: it.steps }));
const byTask = new Map(it.steps.map((s) => [s.task, s]));
const job: Job | undefined = recentJobs(30).find((j) => j.kind === chainKind(article, it.n, mode));
- const defs = chainStepsOf(mode) as { name: string; label: string; optional?: boolean }[];
+ const withDeck = mode === "draft-all" && (deck || byTask.has("chain:deck"));
+ const defs = chainStepsOf(mode, { deck: withDeck }) as { name: string; label: string; optional?: boolean }[];
return {
mode,
+ deck: withDeck,
steps: defs.map((s) => {
const rec = byTask.get(`chain:${s.name}`);
return { name: s.name, label: s.label, status: rec?.status ?? "pending", optional: s.optional === true, detail: rec?.detail ?? null };
}),
// chain.mjs's JSDoc types `done` by its default ([]), so it is cast.
- resumeAt: (chainStart as (o: { done: string[]; mode: string }) => string | null)({ done: [...done], mode }),
+ resumeAt: (chainStart as (o: { done: string[]; mode: string; deck: boolean }) => string | null)({ done: [...done], mode, deck: withDeck }),
job: job
? {
id: job.id,
diff --git a/umtool/lib/report/chain-draft.mjs b/umtool/lib/report/chain-draft.mjs
@@ -5,6 +5,22 @@
import { flipsOn, threadsOn } from "yt-dlp-transcript-common/lib/report/panels.mjs";
+/**
+ * The minimal on-screen deck: every deck setting its default (deck.mjs
+ * DECK_DEFAULTS). What the On-screen section's switch turns on and what
+ * Draft everything's deck step (release 29 G1) adds to a cut with none --
+ * one constructor, a fresh object each call.
+ *
+ * @returns {{ engine: "hyperframes", layout: "deck", deck: Record<string, never> }}
+ */
+export function deckChrome() {
+ return { engine: "hyperframes", layout: "deck", deck: {} };
+}
+
+/** A deck step's line: what it did. */
+export const deckStepDetail = (added) =>
+ added ? "deck added: render.chrome with every setting its default (a snapshot of the cut before it is in revisions/)" : "deck already there: the cut's render.chrome is kept as it is";
+
/** The audit file each task writes beside the manifest (narrate's kept its old name). */
export const draftFileOf = (task) => (task === "narrate" ? "narration-draft.json" : `${task}-draft.json`);
diff --git a/umtool/lib/report/chain-draft.test.mjs b/umtool/lib/report/chain-draft.test.mjs
@@ -12,12 +12,12 @@ import assert from "node:assert/strict";
import test, { after, before } from "node:test";
import { spawn } from "node:child_process";
import http from "node:http";
-import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
+import { mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync, writeFileSync } from "node:fs";
import os from "node:os";
import path from "node:path";
import { fileURLToPath } from "node:url";
import { CHAIN_RUN, REPO_ROOT } from "./chain.mjs";
-import { draftOutcome, draftPrecheck, draftFileOf } from "./chain-draft.mjs";
+import { deckChrome, deckStepDetail, draftOutcome, draftPrecheck, draftFileOf } from "./chain-draft.mjs";
const HERE = path.dirname(fileURLToPath(import.meta.url));
const KIT = path.join(HERE, "..", "..", "..", "common", "testing", "draft");
@@ -218,7 +218,31 @@ test("a cancel of the chain cancels the editor's job, and the step is recorded c
assert.equal(recorded("draft-flips").status, "cancelled");
});
+test("the deck step (release 29 G1): the minimal deck on a cut with none, a snapshot first; a cut with one is left as it is", async () => {
+ const file = path.join(PROJECT, "video.manifest.json");
+ put(file, baseManifest);
+ assert.match(draftPrecheck("flips", json(file)), /no on-screen deck/);
+ const asked = requests.length;
+ const r = await (await step("deck")).done;
+ assert.equal(r.code, 0, r.out);
+ assert.equal(requests.length, asked, "no model, no editor");
+ assert.equal(recorded("deck").status, "done");
+ assert.equal(recorded("deck").detail, deckStepDetail(true));
+ const m = json(file);
+ assert.deepEqual(m.render.chrome, deckChrome());
+ assert.deepEqual({ ...m, render: { ...m.render, chrome: undefined } }, { ...baseManifest, render: { ...baseManifest.render, chrome: undefined } }, "nothing else changed");
+ assert.ok(readdirSync(path.join(PROJECT, "revisions")).some((f) => f.includes("auto-before-deck")));
+ assert.equal(draftPrecheck("flips", m), null);
+ const before = readFileSync(file, "utf8");
+ const again = await (await step("deck")).done;
+ assert.equal(again.code, 0, again.out);
+ assert.equal(recorded("deck").detail, "deck already there: the cut's render.chrome is kept as it is");
+ assert.equal(readFileSync(file, "utf8"), before);
+ put(file, baseManifest);
+});
+
test("draftPrecheck and draftOutcome, pure", () => {
+ assert.notEqual(deckChrome(), deckChrome(), "a fresh object each call");
assert.equal(draftPrecheck("cut", {}), null);
assert.match(draftPrecheck("threads", { render: {} }), /no on-screen deck/);
assert.equal(draftPrecheck("threads", { render: { chrome: {} } }), null);
diff --git a/umtool/lib/report/chain-run.mjs b/umtool/lib/report/chain-run.mjs
@@ -21,6 +21,10 @@
// chain cancels the job. The step is OPTIONAL: refused or failed, it is
// recorded failed and the process exits 0 so the chain goes on; with nothing
// to draft (every field already written) it is recorded skipped.
+//
+// The deck step (`deck`, release 29 G1, Draft everything's option) asks no
+// model: it adds the minimal on-screen deck through umtool's manifest writer
+// (manifest.mjs addDeckChrome: a snapshot first) when the cut has none.
import { spawn } from "node:child_process";
import { copyFile, mkdir, readFile, rename, stat, writeFile } from "node:fs/promises";
@@ -46,7 +50,8 @@ import { toManifestMain } from "yt-dlp-transcript-common/bin/reports-convert";
import { attachVideoMain } from "yt-dlp-transcript-common/bin/reports-attach-video";
import { checkMain } from "yt-dlp-transcript-common/bin/reports-check";
import { ALL_CHAIN_STEP_NAMES, CHAIN_WINDOW_PAD, REPO_ROOT, chainStepDef, configuredProjectsRoot, chainTask, chainWindows, originFromSweep } from "./chain.mjs";
-import { draftFileOf, draftOutcome, draftPrecheck } from "./chain-draft.mjs";
+import { deckChrome, deckStepDetail, draftFileOf, draftOutcome, draftPrecheck } from "./chain-draft.mjs";
+import { addDeckChrome } from "./manifest.mjs";
import { PIPELINE_DIR } from "./driver.mjs";
import { dedupeMedia, seedFromParent } from "./iterations.mjs";
@@ -365,6 +370,15 @@ async function youtubeText(ctx) {
return code === 0 ? "; out/youtube.txt written" : `; out/youtube.txt not written (build-video --chapters-only ended ${code})`;
}
+// The deck option (release 29 G1): the minimal deck on a cut with none, so
+// flips and threads have a panel to draw on; a cut with a deck is untouched.
+STEPS.deck = async (ctx) => {
+ const file = path.join(ctx.project, "video.manifest.json");
+ if (!(await exists(file))) throw new StepFailed(`no video manifest at ${file}: run the chain's manifest step first`);
+ const r = await addDeckChrome(ctx.project, deckChrome());
+ return deckStepDetail(r.added);
+};
+
for (const name of ["cut", "onscreen", "teaser", "flips", "threads", "narrate"]) {
STEPS[`draft-${name}`] = (ctx) => draftStep(ctx, name);
}
diff --git a/umtool/lib/report/chain.mjs b/umtool/lib/report/chain.mjs
@@ -39,6 +39,15 @@
// A resume counts an optional step that ran (done, skipped or failed) as
// finished. The default chain ("make the video") has no optional step.
//
+// THE DECK OPTION (release 29 G1, off by default): Draft everything with
+// `deck` has one more step, `deck`, before draft-flips — no model: it writes
+// the minimal on-screen deck (`render.chrome`, ./chain-draft.mjs deckChrome)
+// through umtool's manifest writer (an `auto-before-deck` snapshot first),
+// ONLY when the cut has no `render.chrome`, so flips and threads have a deck
+// to draw on; a cut with one is left as it is. Without the option the chain
+// is exactly the one above (a step with `option` is in a chain only when its
+// option is on).
+//
// Each step is ONE PROCESS — `node --import tsx chain-run.mjs step <id> <n>
// <step>` — so lib/jobs.ts runs the chain as a job like any other (detached
// process group, cancel, per-step timeout), and `umtool chain` runs the same
@@ -71,6 +80,7 @@ export const CHAIN_STEPS = [
{ name: "draft-cut", label: "draft the cut: which clips, in what order", timeoutMs: DRAFT_TIMEOUT, modes: DRAFT_ONLY, optional: true, draft: "cut" },
{ name: "draft-onscreen", label: "draft the on-screen titles", timeoutMs: DRAFT_TIMEOUT, modes: DRAFT_ONLY, optional: true, draft: "onscreen" },
{ name: "draft-teaser", label: "draft the teaser", timeoutMs: DRAFT_TIMEOUT, modes: DRAFT_ONLY, optional: true, draft: "teaser" },
+ { name: "deck", label: "add the on-screen deck when the cut has none", timeoutMs: 5 * 60_000, modes: DRAFT_ONLY, optional: true, option: "deck" },
{ name: "draft-flips", label: "draft the flips (THEN/NOW pairs)", timeoutMs: DRAFT_TIMEOUT, modes: DRAFT_ONLY, optional: true, draft: "flips" },
{ name: "draft-threads", label: "draft the threads", timeoutMs: DRAFT_TIMEOUT, modes: DRAFT_ONLY, optional: true, draft: "threads" },
{ name: "draft-narrate", label: "draft the narration", timeoutMs: DRAFT_TIMEOUT, modes: DRAFT_ONLY, optional: true, draft: "narrate" },
@@ -85,10 +95,19 @@ export const CHAIN_STEPS = [
/** The chains: "video" (make the video, the default) and "draft-all" (Draft everything). */
export const CHAIN_MODES = ["video", "draft-all"];
-/** A chain's steps, in order. */
-export function chainStepsOf(mode = "video") {
+/** The chains' options: `deck` (Draft everything's deck step, release 29 G1). Each is off by default. */
+export const CHAIN_OPTIONS = ["deck"];
+
+/**
+ * A chain's steps, in order. A step with an `option` is in it only when that
+ * option is on (`{ deck: true }`); with none on, the chain is as it always was.
+ *
+ * @param {string} [mode]
+ * @param {{ deck?: boolean }} [options]
+ */
+export function chainStepsOf(mode = "video", options = {}) {
if (!CHAIN_MODES.includes(mode)) throw new Error(`no chain "${mode}" (${CHAIN_MODES.join(", ")})`);
- return CHAIN_STEPS.filter((s) => s.modes.includes(mode));
+ return CHAIN_STEPS.filter((s) => s.modes.includes(mode) && (!s.option || options?.[s.option] === true));
}
/** Every step's name, either chain's (what the executor runs). */
@@ -150,8 +169,8 @@ export function chainProject(projectsRoot, article, n) {
* has not recorded finished (`done`: the step names recorded finished,
* doneSteps), else nothing (the whole chain is done: null).
*/
-export function chainStart({ from = null, done = [], mode = "video" } = {}) {
- const names = chainStepsOf(mode).map((s) => s.name);
+export function chainStart({ from = null, done = [], mode = "video", deck = false } = {}) {
+ const names = chainStepsOf(mode, { deck }).map((s) => s.name);
if (from !== null && from !== undefined) {
if (!names.includes(from)) throw new Error(`--from must be one of ${names.join(", ")}`);
return from;
@@ -193,16 +212,18 @@ export function readIterationRecord(articlesDir, article, n) {
* (chainStart) to the end. No secret rides in a step: the executor reads the
* editor's URL and token itself (jobView shows a step's env to the browser).
* `mode` "draft-all" is Draft everything: its build is the fast one whatever
- * `final` says, and `model` rides on the draft steps (else each task's route).
+ * `final` says, and `model` rides on the draft steps (else each task's route);
+ * `deck` adds its deck step (G1).
*
- * @param {{ article: string, n: number, projectsRoot?: string, start?: string | null, siteOrigin?: string, final?: boolean, node?: string, mode?: string, model?: string }} o
+ * @param {{ article: string, n: number, projectsRoot?: string, start?: string | null, siteOrigin?: string, final?: boolean, node?: string, mode?: string, model?: string, deck?: boolean }} o
* @returns {import("../trim").Step[]}
*/
export function chainSteps(o) {
const projectsRoot = o.projectsRoot ?? configuredProjectsRoot();
chainProject(projectsRoot, o.article, o.n);
const mode = o.mode ?? "video";
- const defs = chainStepsOf(mode);
+ if (o.deck === true && mode !== "draft-all") throw new Error("the deck is Draft everything's option (draft-all)");
+ const defs = chainStepsOf(mode, { deck: o.deck === true });
const start = o.start === undefined ? defs[0].name : o.start;
if (start === null) return [];
const at = defs.findIndex((s) => s.name === start);
@@ -233,25 +254,28 @@ export function chainSteps(o) {
* iteration not done, or an unknown `from`. `steps` is empty when every step
* is done.
*
- * @param {{ articlesDir: string, article: string, n: number, from?: string | null, projectsRoot?: string, siteOrigin?: string, final?: boolean, mode?: string, model?: string }} o
+ * @param {{ articlesDir: string, article: string, n: number, from?: string | null, projectsRoot?: string, siteOrigin?: string, final?: boolean, mode?: string, model?: string, deck?: boolean }} o
*/
export function planChain(o) {
const record = readIterationRecord(o.articlesDir, o.article, o.n);
if (!record) throw new Error(`"${o.article}" has no iteration i${o.n} under ${o.articlesDir}`);
if (record.status !== "done") throw new Error(`${o.article} i${o.n} is ${record.status}: the chain runs over a done iteration`);
const mode = o.mode ?? "video";
- const start = chainStart({ from: o.from ?? null, done: doneSteps(record), mode });
+ const deck = o.deck === true;
+ if (deck && mode !== "draft-all") throw new Error("the deck is Draft everything's option (draft-all)");
+ const start = chainStart({ from: o.from ?? null, done: doneSteps(record), mode, deck });
const steps = chainSteps({
article: o.article,
n: o.n,
start,
mode,
+ ...(deck ? { deck } : {}),
...(o.model ? { model: o.model } : {}),
...(o.projectsRoot ? { projectsRoot: o.projectsRoot } : {}),
...(o.siteOrigin ? { siteOrigin: o.siteOrigin } : {}),
final: o.final === true,
});
- return { record, start, steps, mode };
+ return { record, start, steps, mode, deck };
}
const floor2 = (x) => Math.floor(x * 100 + 1e-6) / 100;
diff --git a/umtool/lib/report/chain.test.mjs b/umtool/lib/report/chain.test.mjs
@@ -22,6 +22,7 @@ import {
chainSteps,
chainWindows,
chainStepsOf,
+ CHAIN_OPTIONS,
DRAFT_STEP_TASKS,
doneSteps,
originFromSweep,
@@ -53,6 +54,35 @@ test("the steps, in order, each one process of the executor under tsx, from the
assert.equal(chainProject("/p", "a", 2), path.join("/p", "a", "i2"));
});
+test("the deck option (release 29 G1): a step before the flips, off by default — without it the chain is as it was", () => {
+ assert.deepEqual(CHAIN_OPTIONS, ["deck"]);
+ const plain = chainStepsOf("draft-all").map((s) => s.name);
+ assert.ok(!plain.includes("deck"));
+ const withDeck = chainStepsOf("draft-all", { deck: true }).map((s) => s.name);
+ assert.deepEqual(withDeck.filter((n) => n !== "deck"), plain);
+ assert.equal(withDeck.indexOf("deck"), withDeck.indexOf("draft-flips") - 1);
+ assert.equal(withDeck.indexOf("deck"), withDeck.indexOf("draft-teaser") + 1);
+ // Not the video chain's; an option the chain is not asked for adds nothing.
+ assert.deepEqual(chainStepsOf("video", { deck: true }).map((s) => s.name), CHAIN_STEP_NAMES);
+ assert.deepEqual(chainStepsOf("draft-all", { deck: false }).map((s) => s.name), plain);
+ // The step asks no model: no --model on it, and the labels count it.
+ const steps = chainSteps({ article: "art", n: 2, projectsRoot: "/p", node: "node", mode: "draft-all", model: "qwen3:8b", deck: true });
+ const deck = steps.find((s) => s.argv[7] === "deck");
+ assert.ok(deck && !deck.argv.includes("--model"));
+ assert.equal(steps.length, withDeck.length);
+ assert.match(deck.label, new RegExp(`^${withDeck.indexOf("deck") + 1}/${withDeck.length} add the on-screen deck`));
+ assert.deepEqual(
+ chainSteps({ article: "art", n: 2, projectsRoot: "/p", node: "node", mode: "draft-all" }).map((s) => s.argv[7]),
+ plain,
+ );
+ assert.throws(() => chainSteps({ article: "art", n: 2, projectsRoot: "/p", deck: true }), /the deck is Draft everything's option/);
+ // Resume: a chain that ran to the threads without the deck starts again at the deck with it.
+ const ran = ["current", "windows", "prepare", "posts", "manifest", "draft-cut", "draft-onscreen", "draft-teaser", "draft-flips", "draft-threads"];
+ assert.equal(chainStart({ done: ran, mode: "draft-all", deck: true }), "deck");
+ assert.equal(chainStart({ done: ran, mode: "draft-all" }), "draft-narrate");
+ assert.ok(doneSteps({ steps: [{ task: "chain:deck", status: "failed" }] }).includes("deck"), "optional: a failed deck step is passed");
+});
+
test("resume: the first step not recorded done; --from names one; all done is nothing", () => {
const it = {
steps: [
diff --git a/umtool/lib/report/manifest.mjs b/umtool/lib/report/manifest.mjs
@@ -629,6 +629,33 @@ export async function updateChrome(dir, chrome, { token = null } = {}) {
});
}
+/**
+ * Put `chrome` (the minimal deck) on a cut that has NO `render.chrome`, and
+ * leave a cut that has one as it is (release 29 G1: Draft everything's deck
+ * step). A structural change -- the cut gains a panel -- so the file as it
+ * still is goes to revisions/ first (`auto-before-deck`), as every structural
+ * write does; then validateChrome, then the write. `{ added: false }` writes
+ * nothing.
+ *
+ * @param {string} dir
+ * @param {Record<string, unknown>} chrome
+ * @returns {Promise<{ added: boolean, token: string | null, snapshot?: unknown }>}
+ */
+export async function addDeckChrome(dir, chrome) {
+ return withManifestLock(async () => {
+ const manifest = JSON.parse(await readFile(manifestFile(dir), "utf8"));
+ const render = manifest.render ?? {};
+ if (render.chrome !== undefined && render.chrome !== null) return { added: false, token: await manifestToken(dir) };
+ const { chrome: _none, ...rest } = render;
+ const errors = validateChrome(chrome, rest);
+ if (errors.length) throw new ChromeRefused(errors);
+ manifest.render = { ...render, chrome };
+ const snapshot = await autoSnapshot(dir, "deck");
+ const token = await writeManifestAtomic(dir, manifest);
+ return { added: true, token, snapshot };
+ });
+}
+
/** validateChrome's sentences, thrown whole so a route can return each one. */
export class ChromeRefused extends Error {
/** @param {string[]} errors */