// THE VIDEO KNOBS FROM A TERMINAL (plans/video-knobs-ui.md): every knob a // person sets in umtool, an agent sets here -- through the SAME writers // (lib/report/manifest.mjs) and the same generated-manifest guard // (edit-guard.mjs), each write carrying the token read from the file just // before it, so a write here beside an open page is refused rather than lost. // // umtool set key=value … claim.at claim.hold claim.stamp claim.count claim.label claim.eventDate // (a clip's first mark, or --mark 's) // marks= mark.add=[@] mark.remove= // mark.verdict= (plans/clip-marks.md) // audio.offset audio.gain audio.fadeIn audio.fadeOut // blur.on blur.caption blur.strength blur.from blur.to // (`blur.on=` clears the whole blur; report-to-video clip-blur.mjs) // fx= fx.zoom fx.receipts fx.punch fx.quote fx.punchIn fx.speakers // (the clip's effects; `fx=` clears them all; report-to-video fx.mjs) // umtool set channelTitle=… what the header calls the clip's channel (`channelTitle=` clears) // umtool look key=value … factcheck.stamp., factcheck.verdicts.., factcheck.tally., // channelNames.= (the cut's name for a channel; `=` clears), // deck.markers=, deck.markerLayout=…, deck.claims=, variants=, // and the look's keys (transition=0.3, …) // umtool variants [--take ] [--list] [--json] make the encode ladder (or list it) // // `key=` (nothing after the =) clears the key: the default again. A value is // read as JSON when it parses (2, true, [..], {..}), else as text. // // Plain ESM: the CLI runs under bare node. import { spawn } from "node:child_process"; import { REPORTS_ROOT, resolveProject } from "../projects/core.mjs"; import { readManifest } from "../projects/report.mjs"; import { withEditNotes } from "./edit-guard.mjs"; import { FX_ENTRY_FIELDS, LEGACY_RENDER_KEYS, LOOK_KEYS, manifestToken, updateClaimKnobs, updateChrome, updateClip, updateDeckKeys, updateFactcheck, updateMarks, updateRender, updateRenderKeys, updateVariants, } from "./manifest.mjs"; import { CLAIM_KNOBS, STAMP_KNOB_DEFAULTS, VARIANTS_DEFAULT, rawMarksOf, stampingEntryId, variantsOf } from "./knobs.mjs"; import { variantsSteps } from "./driver.mjs"; import { buildFileOf, outDirOf, variantsState } from "./variantsView.mjs"; import { parseGapSpec } from "umtool-report-to-video/gaps"; export const AUDIO_KNOBS = Object.freeze(["offset", "gain", "fadeIn", "fadeOut"]); export const BLUR_KNOBS = Object.freeze(["on", "caption", "strength", "from", "to"]); const MARK_KEYS = ["marks", "mark.add", "mark.remove", "mark.verdict"]; /** The walk's verdict, set like a knob: verdict=confirmed|incorrect|rejected|, reason=…, rejectNote=…, correction=… (`key=` clears). */ const REVIEW_KEYS = ["verdict", "reason", "rejectNote", "correction"]; /** The clip's effects (report-to-video fx.mjs): `fx=` whole (`fx=` clears it), `fx.=` one field. */ const FX_KEYS = ["fx", ...FX_ENTRY_FIELDS.map((k) => `fx.${k}`)]; /** Seconds taken out of the clip's middle (gaps.mjs): the whole list, one added, one removed. */ const GAP_KEYS = ["gaps", "gap.add", "gap.remove", "gap.mark", "gap.why", "gap.reason", "gap.corner"]; /** A gap's own settings (`gapEdit` on the window writer): its mark, why, reason and corner. */ const GAP_OWN_SET_KEYS = ["gap.mark", "gap.why", "gap.reason", "gap.corner"]; /** The mark at this clip's gaps' joins (common gapCue.mjs): its own settings over the project's render.gapCue. */ export const GAP_CUE_SET_KEYS = Object.freeze(["gapCue", "gapCue.mark", "gapCue.min", "gapCue.corner", "gapCue.label", "gapCue.place", "gapCue.border"]); export const VERTICAL_SET_KEYS = Object.freeze(["vertical", "vertical.crop", "vertical.layout", "vertical.aspect", "vertical.crops"]); export const SIDE_SET_KEYS = Object.freeze(["side", "side.item", "side.post", "side.from", "side.to", "side.place"]); /** The clip kit (lane clip-kit; report-to-video clip-kit.mjs): a clip's code in a per-clip build, its batch file name. */ export const KIT_SET_KEYS = Object.freeze(["qr", "qr.corner", "qr.links", "name", "promo", "promo.lead", "promo.fade", "promo.hold", "zooms", "coldOpen", "coldOpen.from", "coldOpen.to", "censor", "censor.boxes", "censor.style", "censor.strength", "censor.from", "censor.to"]); const SET_KEYS = [ "claim", ...CLAIM_KNOBS.map((k) => `claim.${k}`), ...MARK_KEYS, ...AUDIO_KNOBS.map((k) => `audio.${k}`), ...BLUR_KNOBS.map((k) => `blur.${k}`), "layout", ...REVIEW_KEYS, ...FX_KEYS, ...GAP_KEYS, ...GAP_CUE_SET_KEYS, "chat", "hideModules", "shelfNote", "chapter", "channelTitle", // The vertical format (lane vertical): the clip's 9:16 crop and layout, and its side post. ...VERTICAL_SET_KEYS, ...SIDE_SET_KEYS, // The clip kit (lane clip-kit): its code and its name in a batch of shorts. ...KIT_SET_KEYS, ]; export const SET_USAGE = [ "usage: umtool set key=value … [--mark ] [--take ] [--json]", ` keys: ${SET_KEYS.join(" ")}`, " claim.at is a SOURCE second inside the clip's window: the stamp lands and the count steps there", " (read from the last clip carrying the claim); claim.hold s (0.5–10); claim.stamp true|false;", " claim.count 1–99; claim.label ≤ 20 chars; claim.eventDate YYYY-MM-DD, the day the event it counts", " happened when not the clip's (a deck claim's window dates it so: render.chrome.deck.claims).", " The claim.* keys set the clip's first mark, or --mark 's. `claim=` (or claim=none) takes the clip's claim", " pin off -- every mark it carries, as marks= does -- on the DRAFT; a version's clip is opened in the draft first", " (umtool takes open

), so claim= with --take is refused.", " Marks (a clip may carry up to 8, each its own stamp and count): mark.add=[@] adds one", " (the verdict by name or by this cut's label, e.g. Episodes@190.2; a JSON object for its knobs too);", " mark.remove=; mark.verdict= (the first mark's, or --mark 's; every clip carrying", " the id); marks='[{\"id\":\"c1\",\"verdict\":\"CORROBORATED\",\"at\":190.2},…]' sets them all (`marks=` none).", " A teaser takes marks too (a post shown as a text card that counts): its is seconds from the", " card's start (mark.add=CENTER@2.15), and the deck stays up over it so the count is seen to step.", " verdict=confirmed|incorrect|rejected, or a reject reason as shorthand (the walk's; lib/report/rejectReasons.mjs):", " not-matching|wrong-speaker are FACT errors -- incorrect (+ reason=wrong-speaker, which needs no correction);", " irrelevant|repeats|weak|privacy|other are CUT reasons -- rejected + reason, rejectNote= (other needs one),", " never a correction; correction=; `verdict=` clears it.", " audio.offset ms (-2000…2000, + = sound later),", " audio.gain dB (-20…20), audio.fadeIn / audio.fadeOut s (0–5).", " blur.on=true blurs the clip's picture at the encode (the sound untouched; `blur.on=` clears the whole blur);", " blur.caption=\"…\" (≤ 120 chars, drawn on the blurred picture; default \"Original footage uncensored, blurred", " here for TOS\"); blur.strength 2–15 (% of the picture's height; default 5); blur.from / blur.to: source", " seconds inside the clip's window, to blur only that span. render.blur=off (umtool look, or a take's", " --set) renders every clip unblurred: the uncensored variant. layout=finale|clip (the deck's finale", " layout for this clip; clip is the default). `key=` clears it (the default).", " The clip's effects (drawn once render.chrome.fx turns the effect on; docs/knobs.md \"Effects\"):", " fx.zoom='{\"shot\":\"shots/x.png\",\"focus\":[0.1,0.2,0.9,0.4],\"at\":5.9,\"hold\":4}' (shot: a file in the project;", " focus: left, top, right, bottom fractions of it; at: seconds into the clip it pushes in; hold 0.5–10 s on the", " detail, absent: to the clip's end); fx.receipts='[{\"shot\":\"shots/a.png\",\"mark\":[0,0.4,1,0.5]}]' (1–4);", " fx.punch=\"the words\"; fx.quote=false; fx.punchIn='[231.4]' (source seconds);", " fx.speakers='[{\"at\":231,\"who\":1}]'; fx='{…}' sets them all, `fx=` clears every one, `fx.=` that one.", " chat=on shows the clip's live chat (its video's live_chat.cues.json, for the clip's source span) in a column", " beside the footage; chat=off, or `chat=` (the default), does not. A video with no chat draws nothing and the", " build log says so. The column's look: umtool look

chat.position=left (docs/knobs.md \"Live chat\").", " hideModules=diet,streak hides those modules over this entry's span, each with its own fade (text in the", " footage no dodge can know of; any entry, a post item too): goals peak promise diet streak; `hideModules=` none.", " shelfNote='Weighed in on camera' puts one line (≤ 80 characters) on the shelf (render.chrome.deck.shelf, its", " `note` slot) over this entry's span, coming and going with it; any entry; `shelfNote=` none.", " chapter='The weigh-in' names this entry in the chapter list (out/chapters, youtube.txt) in place of its on-screen", " title or the line derived from its record: one line, ≤ 100 characters; any entry; `chapter=` none.", " channelTitle='Synth Channel' is what the header, the deck's source line and the chapter list call this clip's", " channel, over the cut's name for it (umtool look

channelNames.=…) and the record's uploader name:", " one line, ≤ 60 characters, no control character; `channelTitle=` the cut's / the record's again.", " --take : the entry knobs (not claim.* or marks) land in takes//take.json's patch, an undo point first", " (`umtool timeline

--take undo`); the project's manifest is untouched.", " vertical.crop='[x,y,w,h]' (fractions of the source: the 9:16 box a vertical render cuts; vertical.aspect the", " source's w/h when not 16:9); vertical.layout=full|framed|quote (this clip's layout in a vertical cut), or", " twocrop with vertical.crops='[[x,y,w,h],[x,y,w,h]]' (the stacked vertical deck's two crops, the top one first).", " side.item= | side.post='{\"author\",\"handle\",\"date\",\"text\",…}' -- a post shown BESIDE the", " clip while it plays, never read, the clip's sound running; side.from / side.to seconds into the clip;", " side.place=split|overlay (vertical) | right|left (16:9). `side=` removes it (docs/knobs.md \"Vertical\").", " qr=false: no code on this clip; qr.corner=br|bl|tr|tl (a short: tr|tl) and qr.links=cite|moment|channel over", " the cut's (render.qr, render.vertical.qr); `qr=` the cut's again. name=: its files in a batch of", " shorts (umtool shorts) are called that, not its title's slug; `name=` the title's again.", " promo=false: a per-clip build of this clip ends without the channel promo (render.promo); promo.lead /", " promo.fade / promo.hold (seconds) its own timing over the cut's; `promo=` the cut's again.", " zooms='[{\"at\":231.4,\"scale\":1.3,\"focus\":[0.7,0.35],\"hold\":1.5}]' pushes a short's or a desktop clip's", " picture in at those source seconds (or \"box\":[x,y,w,h] to fill the frame with); `zooms=` none.", " coldOpen.from=… coldOpen.to=… (source seconds of its cut, 1-4 s): a short or a desktop clip plays that payoff", " first, then cuts to the clip's start; `coldOpen=` none.", " censor.boxes='[[x,y,w,h]]' hides those parts of its picture (fractions of the source; a box may be", " {\"box\":[…],\"from\":s,\"to\":s}); censor.style=blur|black|pixelate, censor.strength=1-10, censor.from/to;", " censor=false: none, not even its recording's (`umtool censor` sets a recording's); `censor=` its recording's.", " gap.add=12.3-15.1 cuts those source seconds out of the clip's middle (one segment of jump cuts; inside", " the cut, ≥ 0.2 s, 0.5 s kept between); gap.remove= the gap holding it; gaps=12.3-15.1,20-20.6 (or", " a JSON list of {from,to}) the whole list, `gaps=` none. The same as `umtool window --gap/--gap-remove/--gaps`.", " gap.mark=:on|off|default marks (or not) the join of the gap holding , over the clip's and the", " project's; gap.why=:dead-air|idle|other|default says what it was cut for (its mark says \"dead air\",", " \"idle\"); gap.reason=: says them instead (`:` drops them); gap.corner=:tl|tr|bl|br|default", " stands its mark in that corner (its seconds never move).", " gapCue.mark=true|false gapCue.min= gapCue.corner=auto|tl|tr|bl|br gapCue.label='» {s}' the mark at this", " clip's gaps' joins, over the project's (umtool look

gapCue='{\"mark\":true}'); `gapCue=` clears them.", " gapCue.place=footage|deck: over the footage at its corner, or in the deck's band at the end of the source line.", " gapCue.border=accent|'#rrggbb': the mark's border, the deck's accent (the default) or that colour.", ].join("\n"); export const LOOK_USAGE = [ "usage: umtool look key=value … [--unset render.]… [--take ] [--json]", " --take : the deck.* keys given are set on THAT TAKE (its patch, an undo point of its own:", " umtool timeline

--take undo); the project's manifest is untouched. deck.* keys only", " chrome.layout=deck: the deck on (render.chrome created when the cut has none: engine hyperframes, an empty deck)", " --unset render.: drop a legacy render key (rail chromeEngine railEngine chromeRegions claimSchedule wordmark", " title finale cut) -- with chrome.layout=deck in ONE write (the deck refuses the old rail beside it), an undo point first", " factcheck.stamp.scale (0.5–2) .motion (slam|pop|fade|none) .opacity (0.3–1) .seconds .show .position", " factcheck.verdicts..stampLabel | .tallyLabel | .label | .color", " factcheck.tally.showAt (always|first: a cell hidden until its first count lands, then popped in;", " factcheck.tally.showAt.=first for one cell) .show .position (right|left)", " deck.markers='[{\"after\":\"c01\",\"label\":\"Arrival\",\"align\":\"left\"}]' deck.markerLayout=stagger|truncate", " at most 32 markers; \"level\":2 a subsection of the section before it (a shorter tick in its colour, a quieter label,", " \"Section › Sub\" in the section title); the cut's first marker is a section", " deck.=: any of the deck's own keys (deck.finale='{…}', deck.pip='{…}', …), checked by the build's rules;", " deck..=… sets one field and keeps the rest (deck.subtitle.lines=2: the source's title on a line of its own)", " deck.pip.color=section: the rail coloured by section (marker to marker, each marker's color; deck.pip.sectionColor0 before", " the first); a marker's label is optional (none: a tick); deck.rail.labels=false draws no marker's words", " deck.sectionTitle=true | deck.sectionTitle='{\"first\":\"Who she is\"}': the current section's name (its marker's label)", " on one quiet line under the rail; .size .opacity .fade .color (auto|section|#hex|palette key); false or `=` is off", " pair= | pair.=…, chapter= | chapter.=…, status= | status.=…, chat= | chat.=…: the story modules", " (render.chrome.pair / .chapter / .status, docs/knobs.md \"Modules\"), checked by the build's rules", " channelNames.='Synth Channel': every clip of that channel is called that on screen in this cut (the deck's", " source line, the header, the chapter list, a short's end card), over the record's uploader name; a clip's own", " channelTitle still wins (umtool set). ≤ 60 characters, one line. `channelNames.=` clears one, `channelNames=`", " all; channelNames='{\"\":\"…\"}' merges. A slug no clip of the cut is from is written and warned about.", " variants='[{\"name\":\"master\"},{\"name\":\"720p\",\"height\":720,\"crf\":23},{\"name\":\"fit24\",\"maxMiB\":24}]'", ` the look: ${LOOK_KEYS.join(", ")} (a JSON value each)`, " `key=` clears it (the default).", ].join("\n"); class CliError extends Error {} /** `chat=on|off|true|false` into true|false; `chat=` (null) clears it. */ export function chatFlag(value) { if (value === null || value === undefined) return null; if (value === true || value === "on") return true; if (value === false || value === "off") return false; throw new CliError(`chat=${JSON.stringify(value)}: on or off (\`chat=\` clears it)`); } /** `a=b` words into [key, value]: JSON when it parses, else the text; `a=` is null (clear). */ export function parseAssignments(words) { return words.map((w) => { const i = w.indexOf("="); if (i <= 0) throw new CliError(`not key=value: ${w}`); const key = w.slice(0, i); const raw = w.slice(i + 1); if (raw === "") return [key, null]; try { return [key, JSON.parse(raw)]; } catch { return [key, raw]; } }); } async function projectOf(arg, root) { if (!arg) throw new CliError("which project?"); const r = await resolveProject(arg, root); if (r.ambiguous) throw new CliError(`"${arg}" is the name of ${r.ambiguous.length} projects — pass its id`); if (!r.project) throw new CliError(`no project matches "${arg}"`); return r.project; } const splitArgs = (args) => { const words = []; const flags = new Map(); for (let i = 0; i < args.length; i += 1) { const a = args[i]; if (a === "--take" || a === "--mark") { flags.set(a, args[i + 1] ?? ""); i += 1; } else if (a === "--unset") { // Repeatable: every legacy render key named (`--unset render.rail --unset render.title`). flags.set(a, [...(flags.get(a) ?? []), args[i + 1] ?? ""]); i += 1; } else if (a.startsWith("--")) flags.set(a, true); else words.push(a); } return { words, flags }; }; const noted = (editNotes) => !editNotes ? "" : editNotes.errors.length ? ` edit NOT noted (${editNotes.errors.join("; ")}) — ${editNotes.generatedBy} will overwrite it on the next rebuild` : ` edit noted for ${editNotes.generatedBy} — port it into the generator's inputs`; /** * `umtool set key=value …` * @param {string[]} args the words after `set` * @returns {Promise} */ export async function setCommand(args, { root = REPORTS_ROOT, out = (s) => console.log(s), err = (s) => console.error(s) } = {}) { const { words, flags } = splitArgs(args); const json = flags.has("--json"); try { const [projectArg, clipId, ...rest] = words; if (!projectArg || !clipId || !rest.length || flags.has("--help")) { err(SET_USAGE); return 2; } const project = await projectOf(projectArg, root); const markFlag = flags.get("--mark"); const mark = typeof markFlag === "string" && markFlag ? markFlag : null; if (flags.has("--mark") && !mark) throw new CliError("--mark needs a mark id"); const claim = {}; const audio = {}; /** @type {Record} */ const blur = {}; /** @type {Record[]} the marks changes, in the order given */ const markChanges = []; /** @type {Record} */ const entryPatch = {}; let claimOff = false; for (const [key, value] of parseAssignments(rest)) { if (!SET_KEYS.includes(key)) throw new CliError(`${key} is not a clip knob (${SET_KEYS.join(", ")})`); if (key === "layout") { entryPatch.layout = value; continue; } if (VERTICAL_SET_KEYS.includes(key) || SIDE_SET_KEYS.includes(key)) { // A post's id names a post item whatever it parses as; the rest as given (the writer checks them). entryPatch[key] = key === "side.item" && value !== null ? String(value) : value; continue; } if (KIT_SET_KEYS.includes(key)) { // A name is words whatever it parses as; the rest as given (clip-kit.mjs checks them in the writer). entryPatch[key] = key === "name" && value !== null ? String(value) : value; continue; } if (key === "shelfNote") { // A note on the shelf over this entry's span (deck.mjs parseShelfNote checks it); words whatever they parse as. entryPatch.shelfNote = value === null || value === undefined ? null : String(value); continue; } if (key === "channelTitle") { // What the header calls the clip's channel (manifest.mjs patchClipEntry checks it); words whatever they parse as. entryPatch.channelTitle = value === null || value === undefined ? null : String(value); continue; } if (key === "chapter") { // The entry's name in the chapter list (manifest.mjs parseEntryChapter checks it); words whatever they parse as. entryPatch.chapter = value === null || value === undefined ? null : String(value); continue; } if (key === "hideModules") { // The modules hidden over this entry's span (deck.mjs parseHideModules checks the ids); `hideModules=` none. entryPatch.hideModules = value === null || value === undefined ? null : value; continue; } if (key === "chat") { // The live-chat column beside this clip (report-to-video chat.mjs): on|off|true|false; `chat=` clears it. entryPatch.chat = chatFlag(value); continue; } if (FX_KEYS.includes(key)) { // The punch is words whatever they parse as (`fx.punch=2020`). entryPatch[key] = key === "fx.punch" && value !== null ? String(value) : value; continue; } if (REVIEW_KEYS.includes(key)) { entryPatch[key] = value === null || value === undefined ? "" : String(value); continue; } if (GAP_KEYS.includes(key)) { if (key === "gap.add") (entryPatch.gapAdd ??= []).push(String(value ?? "")); else if (GAP_OWN_SET_KEYS.includes(key)) (entryPatch.gapEdit ??= []).push(gapEditOf(key, value)); else if (key === "gap.remove") entryPatch.gapRemove = Number(value); else if (value === null || (Array.isArray(value) && !value.length)) entryPatch.gaps = []; else if (Array.isArray(value)) entryPatch.gaps = value; else { const list = String(value).split(",").map((s) => s.trim()).filter(Boolean).map(parseGapSpec); if (list.some((g) => !g)) throw new CliError(`gaps=${value}: a comma-separated list of FROM-TO in source seconds, or a JSON list of {from,to}`); entryPatch.gaps = list; } continue; } if (GAP_CUE_SET_KEYS.includes(key)) { if (key === "gapCue") { if (value !== null && !(value && typeof value === "object")) throw new CliError("gapCue= clears the clip's own; gapCue='{\"mark\":true}' sets them"); entryPatch.gapCue = value; } else { const k = key.slice("gapCue.".length); entryPatch.gapCue = { ...(entryPatch.gapCue && typeof entryPatch.gapCue === "object" ? entryPatch.gapCue : {}), [k]: (k === "label" || k === "border") && value !== null ? String(value) : value }; } continue; } if (key === "claim") { // The clip's claim pin, off (owed 6 Nov: there was no way to take one off but a hand edit). Only clearing: // a claim is added as a mark (mark.add=[@]), its id and verdict edited in the On-screen table. if (value !== null && !(typeof value === "string" && /^\s*none\s*$/i.test(value))) { throw new CliError(`claim=${typeof value === "string" ? value : JSON.stringify(value)}: claim= (or claim=none) takes the clip's claim off; to add one, mark.add=[@]`); } claimOff = true; markChanges.push({ set: null }); continue; } if (MARK_KEYS.includes(key)) { markChanges.push(markChangeOf(key, value, mark)); continue; } const [group, k] = key.split("."); if (group === "blur") blurAssign(blur, k, value); else (group === "claim" ? claim : audio)[k] = value; } if (Object.keys(audio).length) entryPatch.audio = audio; const takeFlag = flags.get("--take"); const take = typeof takeFlag === "string" && takeFlag ? takeFlag : null; if (flags.has("--take") && !take) throw new CliError("--take needs a take id"); // A version is frozen (L3): its clip's claim comes off in the draft, after Open in draft brings the version there. if (take && claimOff) { throw new CliError( `claim= --take ${take}: a version's clips are not edited in place -- open it in the draft first (umtool takes open ${project.id} ${take}), then \`umtool set ${project.id} ${clipId} claim=\``, ); } if (take && (markChanges.length || Object.keys(claim).length)) throw new CliError("--take sets a take's entry knobs; claim.* and marks are the project's (set them without --take)"); // `blur.on=` (or false): no blur at all, whatever else was given. if (Object.keys(blur).length) entryPatch.blur = "on" in blur && (blur.on === null || blur.on === false) ? null : blur; const results = {}; let notes = null; for (const change of markChanges) { const token = await manifestToken(project.dir); const { result, editNotes } = await withEditNotes(project, () => updateMarks(project.dir, clipId, change, { token })); results.marks = result.marks; results.stampsOnByMark = result.stampsOn; if (result.added) (results.added ??= []).push(result.added); notes = editNotes ?? notes; } if (Object.keys(claim).length) { const token = await manifestToken(project.dir); const { result, editNotes } = await withEditNotes(project, () => updateClaimKnobs(project.dir, clipId, claim, { token, mark })); results.claim = result.claim; results.stamps = result.stamps; results.stampsOn = result.stampsOn; notes = editNotes; } if (Object.keys(entryPatch).length) { // A take's entry (--take): through the take's writer (takeEdit.mjs updateTakeClip -- the same rules, an undo // point of the take's first), never the project's manifest; no edit notes (the patch is not the generated manifest). const { result, editNotes } = take ? { result: await (await import("./takeEdit.mjs")).updateTakeClip(project.dir, take, clipId, entryPatch), editNotes: null } : await withEditNotes(project, async () => updateClip(project.dir, clipId, entryPatch, { token: await manifestToken(project.dir), edit: "trim" })); if (take) results.take = { id: take, undo: result.revision?.rel ? `takes/${take}/${result.revision.rel}` : null }; if ("hideModules" in entryPatch) results.hideModules = result.entry.hideModules ?? null; if ("shelfNote" in entryPatch) results.shelfNote = result.entry.shelfNote ?? null; if ("chapter" in entryPatch) results.chapter = result.entry.chapter ?? null; if ("channelTitle" in entryPatch) results.channelTitle = result.entry.channelTitle ?? null; if ("audio" in entryPatch) results.audio = result.entry.audio ?? null; if ("blur" in entryPatch) results.blur = result.entry.blur ?? null; if ("layout" in entryPatch) results.layout = result.entry.layout ?? "clip"; if ("chat" in entryPatch) results.chat = result.entry.chat ?? null; if (VERTICAL_SET_KEYS.some((k) => k in entryPatch)) results.vertical = result.entry.vertical ?? null; if (SIDE_SET_KEYS.some((k) => k in entryPatch)) results.side = result.entry.side ?? null; if (["qr", "qr.corner", "qr.links"].some((k) => k in entryPatch)) results.qr = result.entry.qr ?? null; if ("name" in entryPatch) results.name = result.entry.name ?? null; if (["promo", "promo.lead", "promo.fade", "promo.hold"].some((k) => k in entryPatch)) results.promo = result.entry.promo ?? null; if ("zooms" in entryPatch) results.zooms = result.entry.zooms ?? null; if (Object.keys(entryPatch).some((k) => k === "censor" || k.startsWith("censor."))) results.censor = result.entry.censor ?? null; if (["coldOpen", "coldOpen.from", "coldOpen.to"].some((k) => k in entryPatch)) results.coldOpen = result.entry.coldOpen ?? null; if (FX_KEYS.some((k) => k in entryPatch)) results.fx = result.entry.fx ?? null; if ("gapCue" in entryPatch) results.gapCue = result.entry.gapCue ?? null; if ("gaps" in entryPatch || "gapAdd" in entryPatch || "gapRemove" in entryPatch || "gapEdit" in entryPatch) { results.gaps = result.entry.gaps ?? []; } if (REVIEW_KEYS.some((k) => k in entryPatch)) { results.review = { verdict: result.entry.verdict ?? null, reason: result.entry.reason ?? null, ...(result.entry.rejectNote ? { rejectNote: result.entry.rejectNote } : {}), correction: result.entry.correction ?? null, }; } notes = editNotes ?? notes; } if (json) { out(JSON.stringify({ ok: true, clip: clipId, ...results, editNotes: notes }, null, 2)); return 0; } if (results.marks) { out(`${clipId}: ${results.marks.length ? `marks ${results.marks.map((m) => markLine(m, results.stampsOnByMark?.[m.id], clipId)).join(" | ")}` : claimOff ? "no claim (its pin taken off)" : "no marks"}`); if (results.added) out(` added ${results.added.join(", ")}`); } if (results.claim) { out(`${clipId}: claim ${JSON.stringify(results.claim)}`); if (!results.stamps) out(` NOTE: ${results.claim.id} stamps on ${results.stampsOn} (the last clip carrying it) — these knobs are read there, not here`); } if ("audio" in results) out(`${clipId}: audio ${results.audio ? JSON.stringify(results.audio) : "as recorded"}`); if ("blur" in results) out(`${clipId}: blur ${results.blur ? JSON.stringify(results.blur) : "none (the picture as recorded)"}`); if ("layout" in results) out(`${clipId}: layout ${results.layout}`); if ("hideModules" in results) out(`${clipId}${results.take ? ` (take ${results.take.id})` : ""}: hideModules ${results.hideModules ? `${results.hideModules.join(", ")} (hidden over its span)` : "none"}`); if ("shelfNote" in results) out(`${clipId}${results.take ? ` (take ${results.take.id})` : ""}: shelfNote ${results.shelfNote ? JSON.stringify(results.shelfNote) + " (on the shelf over its span)" : "none"}`); if ("chapter" in results) out(`${clipId}${results.take ? ` (take ${results.take.id})` : ""}: chapter ${results.chapter ? JSON.stringify(results.chapter) + " (its name in the chapter list)" : "none (named by its on-screen title, else its record)"}`); if ("channelTitle" in results) out(`${clipId}${results.take ? ` (take ${results.take.id})` : ""}: channelTitle ${results.channelTitle ? JSON.stringify(results.channelTitle) + " (its channel's name on screen)" : "none (the cut's name for its channel, else the record's)"}`); if (results.take?.undo) out(` undo point: ${results.take.undo} (umtool timeline ${project.id} --take ${results.take.id} undo)`); if ("chat" in results) out(`${clipId}: chat ${results.chat === true ? "on (its video's live_chat.cues.json beside the footage; the build says if there is none)" : results.chat === false ? "off" : "default (off)"}`); if ("fx" in results) out(`${clipId}: fx ${results.fx ? JSON.stringify(results.fx) : "none"}`); if ("vertical" in results) out(`${clipId}: vertical ${results.vertical ? JSON.stringify(results.vertical) : "the cut's (the centred crop)"}`); if ("side" in results) out(`${clipId}: side ${results.side ? JSON.stringify({ ...results.side, ...(results.side.post ? { post: `@${results.side.post.handle ?? results.side.post.author}` } : {}) }) : "none"}`); if ("qr" in results) out(`${clipId}: qr ${results.qr === false ? "none on this clip" : results.qr ? JSON.stringify(results.qr) : "the cut's"}`); if ("censor" in results) out(`${clipId}: censor ${results.censor === false ? "none (not even its recording's)" : results.censor ? JSON.stringify(results.censor) : "its recording's (render.censor)"}`); if ("coldOpen" in results) out(`${clipId}: cold open ${results.coldOpen ? `${results.coldOpen.from}–${results.coldOpen.to} s, played first` : "none"}`); if ("zooms" in results) out(`${clipId}: zooms ${results.zooms ? results.zooms.map((z) => `${z.at} s ×${z.scale ?? (z.box ? "box" : 1.3)}`).join(", ") : "none"}`); if ("promo" in results) out(`${clipId}: promo ${results.promo === false ? "none (it ends without the card)" : results.promo ? JSON.stringify(results.promo) : "the cut's"}`); if ("name" in results) out(`${clipId}: name ${results.name ? JSON.stringify(results.name) : "its title's slug"}`); if ("gaps" in results) { const own = (g) => [typeof g.mark === "boolean" ? `mark ${g.mark ? "on" : "off"}` : "", g.why ?? "", g.reason ? `"${g.reason}"` : "", g.corner ? `at ${g.corner}` : ""].filter(Boolean).join(", "); out(`${clipId}: ${results.gaps.length ? `gaps ${results.gaps.map((g) => `${g.from}–${g.to}${own(g) ? ` (${own(g)})` : ""}`).join(", ")}` : "no gaps (the cut plays whole)"}`); } if ("gapCue" in results) out(`${clipId}: gapCue ${results.gapCue ? JSON.stringify(results.gapCue) : "the project's (render.gapCue)"}`); if (results.review) { const r = results.review; out(`${clipId}: ${r.verdict ?? "not reviewed"}${r.reason ? ` (${r.reason}${r.rejectNote ? `: ${r.rejectNote}` : ""})` : ""}${r.correction ? ` — ${r.correction}` : ""}`); if (r.reason === "wrong-speaker" || r.verdict === "rejected") { out(` still in the cut: umtool timeline reject ${clipId} ${r.reason} takes it out, on the record`); } } const n = noted(notes); if (n) out(n); return 0; } catch (e) { err(e instanceof Error ? e.message : String(e)); return e instanceof CliError ? 2 : 1; } } const isObj = (v) => !!v && typeof v === "object" && !Array.isArray(v); /** * `gap.mark=:on|off|default`, `gap.why=:dead-air|idle|other|default`, * `gap.reason=:` (`:` drops it) and `gap.corner=:tl|tr|bl|br|default` * as a window writer's `gapEdit`. * * @param {string} key * @param {unknown} value */ export function gapEditOf(key, value) { const field = key.slice("gap.".length); const choices = { mark: "on|off|default", why: "dead-air|idle|other|default", reason: "", corner: "tl|tr|bl|br|default" }[field] ?? ""; const m = String(value ?? "").match(/^\s*(\d+(?:\.\d+)?)\s*:(.*)$/); if (!m) throw new CliError(`${key}=${value ?? ""}: :${choices}`); const at = Number(m[1]); // The reason is words, whatever they are: the writer checks them (gaps.mjs). if (field === "reason") return { at, reason: m[2].trim() ? m[2].trim() : null }; const word = m[2].trim().toLowerCase(); let v; if (word === "default") v = null; else if (field === "mark" && (word === "on" || word === "off")) v = word === "on"; else if (field === "why" && ["dead-air", "idle", "other"].includes(word)) v = word; else if (field === "corner" && ["tl", "tr", "bl", "br"].includes(word)) v = word; else throw new CliError(`${key}=${value}: ${word || "nothing"} is not one of ${choices}`); return { at, [field]: v }; } /** * One `blur.*` assignment into the blur patch: a caption is text whatever it * parses as (`blur.caption=2025` is the words "2025"); `blur.on=true` turns it * on; the numbers as given (the writer refuses what the build would). */ export function blurAssign(blur, k, value) { if (k === "caption" && value !== null) blur.caption = String(value); else blur[k] = value; return blur; } /** * One `mark.*` / `marks` assignment as an updateMarks change: `mark.add=Episodes@190.2` * (or a JSON object), `mark.remove=`, `mark.verdict=` (for --mark's * id, else the clip's first mark), `marks=` (`marks=` none). */ export function markChangeOf(key, value, mark = null) { switch (key) { case "marks": if (value !== null && !Array.isArray(value)) throw new CliError("marks= takes a JSON list of marks, or nothing for none"); return { set: value }; case "mark.add": { if (isObj(value)) return { add: value }; if (typeof value !== "string" || !value.trim()) throw new CliError("mark.add= takes [@], or a JSON object"); const [verdict, at, ...more] = value.split("@"); if (more.length) throw new CliError(`mark.add=${value}: one @ (the source second)`); if (at === undefined || at === "") return { add: { verdict: verdict.trim() } }; const s = Number(at); if (!Number.isFinite(s)) throw new CliError(`mark.add=${value}: ${at} is not a source second`); return { add: { verdict: verdict.trim(), at: s } }; } case "mark.remove": if (value === null) throw new CliError("mark.remove= takes the mark's id"); return { remove: String(value) }; case "mark.verdict": if (value === null) throw new CliError("mark.verdict= takes a verdict (its name or this cut's label)"); return { mark, verdict: String(value) }; default: throw new CliError(`${key} is not a marks key`); } } /** One mark for a line: `id VERDICT at=… (stamps on x)`. */ function markLine(m, stampsOn, clipId) { const knobs = CLAIM_KNOBS.filter((k) => m[k] !== undefined).map((k) => `${k}=${JSON.stringify(m[k])}`); const where = stampsOn && stampsOn !== clipId ? ` (stamps on ${stampsOn})` : ""; return [m.id, m.verdict, ...knobs].join(" ") + where; } /** Set (or with null, remove) `a.b.c` in a copy of `obj`, pruning objects left empty. */ function setPath(obj, keys, value) { const root = structuredClone(isObj(obj) ? obj : {}); const stack = [root]; let at = root; for (const k of keys.slice(0, -1)) { if (!isObj(at[k])) at[k] = {}; at = at[k]; stack.push(at); } const last = keys[keys.length - 1]; if (value === null) delete at[last]; else at[last] = value; for (let i = keys.length - 1; i > 0; i -= 1) { if (Object.keys(stack[i]).length) break; delete stack[i - 1][keys[i - 1]]; } return root; } /** * `umtool look key=value …` * @param {string[]} args the words after `look` * @returns {Promise} */ export async function lookCommand(args, { root = REPORTS_ROOT, out = (s) => console.log(s), err = (s) => console.error(s) } = {}) { const { words, flags } = splitArgs(args); const json = flags.has("--json"); try { const [projectArg, ...rest] = words; if (!projectArg || (!rest.length && !flags.has("--unset")) || flags.has("--help")) { err(LOOK_USAGE); return 2; } const project = await projectOf(projectArg, root); const pairs = parseAssignments(rest); // A TAKE'S DECK KEYS (`--take `, 12 Nov: `deck.goals.baseMaxDays` for one take): the same write over the take's // manifest, landing in its patch with an undo point of the take's own (takeScope.mjs) -- the project's manifest // untouched. The deck's keys only: the other knobs here are the project's. if (flags.has("--take")) { const take = typeof flags.get("--take") === "string" && flags.get("--take") ? String(flags.get("--take")) : null; if (!take) throw new CliError("--take needs a take id"); const other = pairs.filter(([k]) => !k.startsWith("deck.")); if (other.length || flags.has("--unset")) { throw new CliError(`--take sets a take's deck keys (deck.=…); ${other.length ? other.map(([k]) => k).join(", ") : "--unset"} is the project's (set it without --take)`); } const { isTakeId, takesDirOf, TAKE_FILE } = await import("./takes.mjs"); if (!isTakeId(take)) throw new CliError(`"${take}" is not a take id (lower-case letters, digits, dashes)`); const { stat } = await import("node:fs/promises"); const { default: nodePath } = await import("node:path"); if (!(await stat(nodePath.join(takesDirOf(project.dir), take, TAKE_FILE)).catch(() => null))) { err(`${project.id} has no take ${take} (no takes/${take}/${TAKE_FILE})`); return 1; } const busy = await (await import("./takeImport.mjs")).takeRenderingNow(project.dir, take); if (busy) { err(`not edited: ${busy}`); return 1; } const { withTakeScope } = await import("./takeScope.mjs"); const lines = []; const code = await withTakeScope(project.dir, take, () => lookCommand([projectArg, ...rest, ...(json ? ["--json"] : [])], { root, out: (l) => lines.push(l), err })); if (json && code === 0) { for (const l of lines) { let doc = null; try { doc = JSON.parse(l); } catch { /* a line of prose */ } out(doc && typeof doc === "object" ? JSON.stringify({ ...doc, take: { id: take, undo: `umtool timeline ${project.id} --take ${take} undo` } }, null, 2) : l); } } else { for (const l of lines) out(l); if (code === 0) out(`take ${take}: written to its patch (undo: umtool timeline ${project.id} --take ${take} undo)`); } return code; } // THE DECK ON, LEGACY KEYS OFF (updateRenderKeys): `chrome.layout=deck` (render.chrome created when the cut has // none) and `--unset render.`, in one write with an undo point -- before any deck.* key, which needs the chrome. const chromeOn = pairs.filter(([k]) => k === "chrome.layout" || k === "chrome.engine"); const unsetArgs = flags.get("--unset") ?? []; if (chromeOn.length || unsetArgs.length) { const unset = unsetArgs.map((u) => { const m = /^render\.([A-Za-z]+)$/.exec(String(u)); if (!m) throw new CliError(`--unset takes render. (one of ${LEGACY_RENDER_KEYS.map((k) => `render.${k}`).join(", ")}): not "${u}"`); if (!LEGACY_RENDER_KEYS.includes(m[1])) throw new CliError(`--unset takes the legacy render keys only (${LEGACY_RENDER_KEYS.join(", ")}): not ${m[1]}`); return m[1]; }); const chrome = chromeOn.length ? Object.fromEntries(chromeOn.map(([k, v]) => [k.slice("chrome.".length), v])) : null; const token = await manifestToken(project.dir); const { result, editNotes } = await withEditNotes(project, () => updateRenderKeys(project.dir, { unset, chrome }, { token })); const msg = [ ...(result.unset.length ? [`unset ${result.unset.map((k) => `render.${k}`).join(", ")}`] : []), ...(result.absent.length ? [`(not set: ${result.absent.map((k) => `render.${k}`).join(", ")})`] : []), ...(chrome ? [`chrome.layout: ${result.chrome?.layout}${result.created ? " (render.chrome created: engine hyperframes, an empty deck)" : ""}`] : []), ...(result.snapshot?.rel ? [`undo point: ${result.snapshot.rel}`] : []), ]; if (json && !pairs.some(([k]) => k !== "chrome.layout" && k !== "chrome.engine")) { out(JSON.stringify({ ok: true, ...result, editNotes }, null, 2)); return 0; } if (!json) out(msg.join("; ")); const left = rest.filter((w) => !/^chrome\.(layout|engine)=/.test(w)); if (!left.length) return 0; return lookCommand([projectArg, ...left, ...(json ? ["--json"] : [])], { root, out, err }); } const fc = pairs.filter(([k]) => k.startsWith("factcheck.")); const deck = pairs.filter(([k]) => k.startsWith("deck.")); const variants = pairs.filter(([k]) => k === "variants"); const look = pairs.filter(([k]) => LOOK_KEYS.includes(k)); // The cut's name for ONE channel (render.channelNames., lane channel-title): merged into the look's // channelNames patch -- words whatever they parse as, `=` clears that slug. const chanNames = pairs.filter(([k]) => k.startsWith("channelNames.")); for (const [k, v] of chanNames) { const slug = k.slice("channelNames.".length); if (!slug) throw new CliError("channelNames.=: name the channel's slug"); const at = look.findIndex(([x]) => x === "channelNames"); const cur = at >= 0 && look[at][1] && typeof look[at][1] === "object" ? look[at][1] : {}; const next = { ...cur, [slug]: v === null || v === undefined ? null : String(v) }; if (at >= 0) look[at] = ["channelNames", next]; else look.push(["channelNames", next]); } // The story modules (release 39): `pair=`, `pair.style=…`, likewise chapter and status. const STORY = ["pair", "chapter", "status", "chat"]; const isStory = (k) => STORY.includes(k.split(".")[0]); const story = pairs.filter(([k]) => isStory(k)); const unknown = pairs.filter(([k]) => !k.startsWith("factcheck.") && !k.startsWith("deck.") && !k.startsWith("channelNames.") && k !== "variants" && !LOOK_KEYS.includes(k) && !isStory(k)); if (unknown.length) throw new CliError(`not a knob here: ${unknown.map(([k]) => k).join(", ")}\n\n${LOOK_USAGE}`); for (const [k] of deck) if (k.split(".").some((p) => !p)) throw new CliError(`${k}: name one of the deck's own keys (deck.=, or deck..=…)`); const done = {}; let notes = null; const write = async (fn) => { const token = await manifestToken(project.dir); const { result, editNotes } = await withEditNotes(project, () => fn(token)); notes = editNotes ?? notes; return result; }; if (fc.length) { const m = await readManifest(project.dir); let next = m?.render?.chrome?.factcheck ?? {}; for (const [k, v] of fc) next = setPath(next, k.split(".").slice(1), v); const r = await write((token) => updateFactcheck(project.dir, Object.keys(next).length ? next : null, { token })); done.factcheck = r.factcheck; } if (deck.length) { // `deck..=…` sets one field of a deck key's object // (deck.subtitle.lines=2), keeping the rest of what it holds. const current = deck.some(([k]) => k.split(".").length > 2) ? (await readManifest(project.dir))?.render?.chrome?.deck ?? {} : {}; const patch = {}; for (const [k, v] of deck) { const [, top, ...rest] = k.split("."); if (!rest.length) patch[top] = v; else { const next = setPath(patch[top] !== undefined ? patch[top] : current[top], rest, v); patch[top] = Object.keys(next).length ? next : null; } } const r = await write((token) => updateDeckKeys(project.dir, patch, { token })); for (const k of Object.keys(patch)) done[`deck.${k}`] = r.deck[k] ?? null; } if (story.length) { const m = await readManifest(project.dir); let chrome = m?.render?.chrome ?? {}; for (const [k, v] of story) chrome = setPath(chrome, k.split("."), v); const r = await write((token) => updateChrome(project.dir, chrome, { token })); for (const k of new Set(story.map(([k]) => k.split(".")[0]))) done[k] = r.chrome?.[k] ?? null; } if (variants.length) { const r = await write((token) => updateVariants(project.dir, variants[0][1], { token })); done.variants = r.variants; } let warnings = []; if (look.length) { const r = await write((token) => updateRender(project.dir, Object.fromEntries(look), { token })); done.look = r.look; warnings = r.warnings ?? []; } if (json) out(JSON.stringify({ ok: true, ...done, ...(warnings.length ? { warnings } : {}), editNotes: notes }, null, 2)); else { for (const [k, v] of Object.entries(done)) out(`${k}: ${v === null || v === undefined ? "(default)" : JSON.stringify(v)}`); for (const w of warnings) out(`WARN ${w}`); const n = noted(notes); if (n) out(n); } return 0; } catch (e) { err(e instanceof Error ? (e.errors ? e.errors.join("\n") : e.message) : String(e)); return e instanceof CliError ? 2 : 1; } } const mib = (b) => (typeof b === "number" ? `${(b / 1048576).toFixed(1)} MiB` : "–"); function printState(s, out) { out(`${s.take ? `take ${s.take}` : "the project's build"}: ${s.built ? `${mib(s.built.size)}, built ${new Date(s.built.mtimeMs).toISOString()}` : "NOT BUILT"}`); out(`ladder (${s.ladderIsDefault ? "default" : "render.variants"}): ${s.ladder.map((v) => v.name).join(", ")}`); if (s.made) { out(`made ${s.made.at ?? ""}${s.stale ? " (from an OLDER build — make them again)" : ""}`); for (const m of s.made.items) out(` ${m.name.padEnd(10)} ${m.width ?? "?"}x${m.height ?? "?"} ${mib(m.bytes).padStart(10)} ${m.kbps ?? "?"} kb/s${m.exists ? "" : " GONE"}`); } if (s.sync) { const bad = s.sync.items.filter((x) => x.flagged); out(`sync (${s.sync.items.length} clips, one frame = ${s.sync.frameMs} ms): ${bad.length ? `${bad.length} past a frame` : "every clip within a frame"}`); for (const x of bad) out(` ${x.id.padEnd(10)} ${x.lagMs > 0 ? "+" : ""}${Math.round(x.lagMs)} ms → umtool set ${x.id} audio.offset=…`); } else out("sync: no report (the build writes sourced/sync.json)"); } /** * `umtool variants [--take ] [--list] [--json]` * @param {string[]} args the words after `variants` * @returns {Promise} */ export async function variantsCommand(args, { root = REPORTS_ROOT, out = (s) => console.log(s), err = (s) => console.error(s), env = process.env } = {}) { const { words, flags } = splitArgs(args); const json = flags.has("--json"); try { const [projectArg] = words; if (!projectArg || flags.has("--help")) { err("usage: umtool variants [--take ] [--list] [--json] make the encode ladder of a build (--list: what was made, and the sync report)"); return 2; } const project = await projectOf(projectArg, root); const manifest = await readManifest(project.dir); if (!manifest) throw new CliError("no manifest"); const take = typeof flags.get("--take") === "string" && flags.get("--take") ? String(flags.get("--take")) : null; const before = await variantsState(project, manifest, take); if (!flags.has("--list")) { if (!before.built) throw new CliError(take ? `take ${take} has no build to make variants of` : "this cut has not been built yet — build it first"); if (before.built.from === "preview") (json ? err : out)(`take ${take}: no out/${before.slug}.mp4 -- making the variants of its preview.mp4`); const src = before.built.from === "preview" ? (await buildFileOf(project, before.slug, take))?.abs ?? null : null; const [step] = variantsSteps(project, outDirOf(project, take), env, { source: src }); const log = json ? (s) => err(s) : out; log(`$ ${step.argv.join(" ")}`); const code = await new Promise((resolve) => { const child = spawn(process.execPath, step.argv.slice(1), { cwd: step.cwd, stdio: ["ignore", json ? "pipe" : "inherit", "inherit"] }); if (json) child.stdout?.on("data", (b) => err(String(b).trimEnd())); child.on("error", () => resolve(1)); child.on("exit", (c, sig) => resolve(sig ? 1 : (c ?? 1))); }); if (code !== 0) { err(`the encoder exited ${code}`); return 1; } } const s = await variantsState(project, manifest, take); if (json) out(JSON.stringify(s, null, 2)); else printState(s, out); return 0; } catch (e) { err(e instanceof Error ? e.message : String(e)); return e instanceof CliError ? 2 : 1; } } /** * The knobs a manifest sets, for `umtool show`: per clip (claim knobs, audio), * the fact-check's stamp, the deck's markers, the ladder. * @param {Record} manifest */ export function knobsOf(manifest) { const timeline = Array.isArray(manifest?.timeline) ? manifest.timeline : []; const clips = []; for (const e of timeline) { if (!isObj(e)) continue; // The first mark is `claim…` (as before marks); two or more are `marks` too. const all = rawMarksOf(e).filter(isObj); const first = all[0] ?? null; const claim = first ? Object.fromEntries(CLAIM_KNOBS.filter((k) => first[k] !== undefined).map((k) => [k, first[k]])) : null; const audio = isObj(e.audio) ? e.audio : null; const blur = isObj(e.blur) ? e.blur : null; if ((claim && Object.keys(claim).length) || audio || blur || first || typeof e.layout === "string") { clips.push({ id: e.id, ...(e.variant ? { variant: e.variant } : {}), ...(first ? { claimId: first.id, verdict: first.verdict, stamps: stampingEntryId(manifest, first.id) === e.id } : {}), ...(claim && Object.keys(claim).length ? { claim } : {}), ...(all.length > 1 ? { marks: all.map((m) => ({ ...m, stampsOn: stampingEntryId(manifest, m.id) })) } : {}), ...(audio ? { audio } : {}), ...(blur ? { blur } : {}), ...(typeof e.layout === "string" ? { layout: e.layout } : {}), }); } } const fc = manifest?.render?.chrome?.factcheck; const stamp = isObj(fc?.stamp) ? Object.fromEntries(Object.entries(fc.stamp).filter(([k]) => k in STAMP_KNOB_DEFAULTS)) : {}; const stampLabels = isObj(fc?.verdicts) ? Object.fromEntries(Object.entries(fc.verdicts).filter(([, v]) => isObj(v) && typeof v.stampLabel === "string").map(([k, v]) => [k, v.stampLabel])) : {}; const deck = manifest?.render?.chrome?.deck; return { clips, stamp, stampLabels, markers: Array.isArray(deck?.markers) ? deck.markers : [], markerLayout: deck?.markerLayout ?? null, // The deck's claim checks (report-to-video claims.mjs), as written. claims: Array.isArray(deck?.claims) ? deck.claims : [], variants: variantsOf(manifest?.render), variantsDefault: !Array.isArray(manifest?.render?.variants), // render.blur "off": the uncensored variant (every clip's blur not drawn). blurOff: manifest?.render?.blur === "off", // The cut's names for its channels (render.channelNames), as written. channelNames: isObj(manifest?.render?.channelNames) ? manifest.render.channelNames : {}, }; } /** `umtool show`'s knobs block, as lines. */ export function knobsLines(manifest) { const k = knobsOf(manifest); const lines = []; for (const c of k.clips) { const bits = []; if (c.marks) bits.push(`marks ${c.marks.map((m) => markLine(m, m.stampsOn, c.id) + (m.stampsOn === c.id ? " (stamps here)" : "")).join(" | ")}`); else { if (c.claimId) bits.push(`claim ${c.claimId} ${c.verdict}${c.stamps ? " (stamps here)" : ""}`); if (c.claim) bits.push(Object.entries(c.claim).map(([a, b]) => `${a}=${JSON.stringify(b)}`).join(" ")); } if (c.layout) bits.push(`layout ${c.layout}`); if (c.audio) bits.push(`audio ${Object.entries(c.audio).map(([a, b]) => `${a}=${b}`).join(" ")}`); if (c.blur) bits.push(`blur ${Object.entries(c.blur).filter(([a]) => a !== "on").map(([a, b]) => `${a}=${JSON.stringify(b)}`).join(" ") || "on"}${k.blurOff ? " (not drawn: render.blur off)" : ""}`); lines.push(` ${String(c.id).padEnd(8)} ${bits.join(" · ")}`); } if (Object.keys(k.stamp).length) lines.push(` stamp ${Object.entries(k.stamp).map(([a, b]) => `${a}=${b}`).join(" ")}`); if (Object.keys(k.stampLabels).length) lines.push(` stamp word ${Object.entries(k.stampLabels).map(([a, b]) => `${a}=${b}`).join(" ")}`); if (k.markers.length) lines.push(` markers ${k.markers.map((m) => `${m.after}:${m.label ? `"${m.label}"` : "(tick)"}${m.color ? `[${m.color}]` : ""}${m.align ? `(${m.align})` : ""}${m.level === 2 ? "(sub)" : ""}`).join(" ")}${k.markerLayout ? ` · layout ${k.markerLayout}` : ""}`); for (const c of k.claims) { if (!isObj(c)) continue; if (c.kind === "count") { const window = isObj(c.window) ? `${c.window.from}..${c.window.to}` : "?"; lines.push(` claim count ${c.at}@${c.t} ${c.said} · ${window} · ${c.tally}${c.per ? ` per ${c.per}` : ""}${isObj(c.claim) ? ` · ${c.claim.op} ${c.claim.value}` : ""}`); } else if (c.kind === "goalpost" && Array.isArray(c.steps)) { lines.push(` claim goalpost${c.label ? ` "${c.label}"` : ""} ${c.steps.map((st) => `${st.at}@${st.t} ${st.said} ${st.from ?? "(clip date)"}+${Array.isArray(st.due) ? st.due.join("..") : "?"}`).join(" → ")}`); } } lines.push(` variants ${k.variants.map((v) => v.name).join(", ")}${k.variantsDefault ? " (default)" : ""}`); if (k.blurOff) lines.push(" blur off (render.blur: the uncensored variant — no clip is blurred)"); if (Object.keys(k.channelNames).length) lines.push(` channels ${Object.entries(k.channelNames).map(([a, b]) => `${a}=${JSON.stringify(b)}`).join(" ")}`); return lines; } export { VARIANTS_DEFAULT };