Archilyzer · Source

archilyzer

Archilyzer
git clone https://archilyzer.pages.dev/source/archilyzer.git
Log | Files | Refs | README | LICENSE

commit 31af39e1d4622b31e619f9ea0cb99e2dbe5ff8b2
parent b44826296784176fac168d4a3e60c2b589c521b0
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Mon,  9 Nov 2026 21:54:00 -0500

Merge lane/palette: every umtool verb a form -- a verb registry, help and cli.md generated from it, a Commands section in the jump palette with Copy as CLI, and POST /api/cli (redesign L8a; ~33 CLI-only verb groups)

umtool/lib/cli/verbs.mjs is the one machine-readable list (200 rows; a registry test fails on any dispatched verb
without one). The palette builds a form from a row, pre-filled from the page; Run goes through POST /api/cli, which
accepts only form verbs, validates against the row and builds argv on the server: path args confined to the project
(realpath), outputs bare names, no @file reference anywhere, a second press for verbs with no undo point, heavy
verbs through the durable queue. Page writes (this route, Save version, Open in draft, ingredient actions) accept only
this machine's hosts or UMTOOL_ALLOWED_HOSTS. Two reviews; both blockers (an arbitrary --out write, an @file read)
fixed with tests.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

Diffstat:
M.env.example | 5+++++
MRUNNING_IN_DOCKER.md | 16++++++++++++++++
Mdocker-compose.yml | 3+++
Mpackage.json | 2+-
Aumtool/app/api/cli/route.ts | 185+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mumtool/bin/umtool.mjs | 295+++----------------------------------------------------------------------------
Aumtool/components/shell/CommandForm.tsx | 322+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mumtool/components/shell/JumpPalette.tsx | 125++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-----
Mumtool/docs/cli.md | 277+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------
Mumtool/docs/knobs.md | 40++++++++++++++++++++++++++++++++++++++++
Aumtool/e2e/palette.spec.ts | 259+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aumtool/lib/cli/argv.mjs | 305++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aumtool/lib/cli/confine.mjs | 40++++++++++++++++++++++++++++++++++++++++
Aumtool/lib/cli/docs.mjs | 107+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aumtool/lib/cli/groups.mjs | 1021+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aumtool/lib/cli/verbs.mjs | 459+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aumtool/lib/cli/verbs.test.mjs | 311+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mumtool/lib/report/candidatesCli.mjs | 6++++--
Mumtool/lib/report/postsCli.mjs | 6++++--
Mumtool/lib/report/sameOrigin.mjs | 40+++++++++++++++++++++++++++++++++++++---
Mumtool/lib/report/sameOrigin.test.mjs | 14+++++++++++++-
Mumtool/lib/report/timelineCli.mjs | 23++++++++++++++++++-----
Mumtool/lib/report/timelineCli.test.mjs | 14++++++++++++++
23 files changed, 3534 insertions(+), 341 deletions(-)

diff --git a/.env.example b/.env.example @@ -34,6 +34,11 @@ # umtool. Private, same rules as the editor. #UMTOOL_BIND=0.0.0.0 +# The names umtool is reached by when not localhost (a LAN IP, a custom domain, +# a Tailscale name): its pages' writes are refused from any other (DNS +# rebinding). Comma-separated, no ports. RUNNING_IN_DOCKER.md, "Reaching the +# editor from another machine". +#UMTOOL_ALLOWED_HOSTS=archive-box.lan,192.168.1.20 # The published port numbers, if 8080-8083 collide with something you run. # These are the OUTSIDE ports; the ports inside the containers never change. diff --git a/RUNNING_IN_DOCKER.md b/RUNNING_IN_DOCKER.md @@ -224,6 +224,22 @@ of a YAML config file and a mandatory database. Templates are in Both attach through Caddy's `forward_auth`. The overlays set `ARCHILYZER_AUTH_MODE=forward` for you. +**umtool answers writes only to the names it knows.** Its pages' writes -- +Save version and Open in draft, an ingredient's actions, every ⌘K command +(`POST /api/cli`) -- are refused when the address the browser used is not +this machine (`localhost`, `*.localhost`, `127.x`, `::1`): a page whose DNS +name is re-pointed at the box (DNS rebinding) must not drive it. Caddy passes +the address on, so reaching umtool as `http://192.168.1.20:8083`, a custom +domain or a Tailscale name reads fine and refuses every write until you name it: + +```sh +# .env — host names or IPs, comma-separated, no ports +UMTOOL_ALLOWED_HOSTS=archive-box.lan,192.168.1.20,archive-box.tail1234.ts.net +``` + +On the host (`archilyzer service install`), set it in the unit's environment +the same way. An SSH tunnel to `127.0.0.1:8083` needs nothing. + ### The rail, and its escape hatch ``` diff --git a/docker-compose.yml b/docker-compose.yml @@ -216,6 +216,9 @@ services: environment: <<: *app-env UMTOOL_CACHE_DIR: /data/builds/umtool-cache + # The names umtool is reached by besides localhost (a LAN IP, a domain, + # a Tailscale name): its pages' writes are refused from any other. + UMTOOL_ALLOWED_HOSTS: ${UMTOOL_ALLOWED_HOSTS:-} volumes: - corpus:/data/transcripts - config:/data/config diff --git a/package.json b/package.json @@ -24,7 +24,7 @@ "wt": "node scripts/worktree.mjs", "e2e:sharded": "node scripts/run-sharded-e2e.mjs", "e2e:all": "node scripts/e2e-all.mjs", - "test:scripts": "node --test scripts/*.test.mjs umtool/report-to-video/*.test.mjs umtool/report-to-video/modules/*.test.mjs umtool/lib/*.test.mjs umtool/lib/report/*.test.mjs umtool/lib/annotations/*.test.mjs umtool/lib/articles/*.test.mjs umtool/lib/pieces/*.test.mjs umtool/lib/inbox/*.test.mjs umtool/lib/research/*.test.mjs umtool/lib/work/*.test.mjs umtool/lib/create/*.test.mjs umtool/lib/settings/*.test.mjs umtool/lib/queue/*.test.mjs umtool/lib/ingredients/*.test.mjs", + "test:scripts": "node --test scripts/*.test.mjs umtool/report-to-video/*.test.mjs umtool/report-to-video/modules/*.test.mjs umtool/lib/*.test.mjs umtool/lib/report/*.test.mjs umtool/lib/annotations/*.test.mjs umtool/lib/articles/*.test.mjs umtool/lib/pieces/*.test.mjs umtool/lib/inbox/*.test.mjs umtool/lib/research/*.test.mjs umtool/lib/work/*.test.mjs umtool/lib/create/*.test.mjs umtool/lib/settings/*.test.mjs umtool/lib/queue/*.test.mjs umtool/lib/ingredients/*.test.mjs umtool/lib/cli/*.test.mjs", "test": "pnpm -r --no-bail --no-sort --workspace-concurrency=1 run test; a=$?; pnpm run test:scripts; b=$?; [ $a -eq 0 ] && [ $b -eq 0 ]", "typecheck": "pnpm -r --no-bail --no-sort --workspace-concurrency=1 exec tsc --noEmit", "lint": "pnpm --filter export run lint", diff --git a/umtool/app/api/cli/route.ts b/umtool/app/api/cli/route.ts @@ -0,0 +1,185 @@ +import path from "node:path"; +import { getJob, jobView, runningJob, startJob } from "@/lib/jobs"; +import { buildArgv, cliLine, confirmOf, pathArgsOf } from "@/lib/cli/argv.mjs"; +import { confineToProject } from "@/lib/cli/confine.mjs"; +import { formVerbs, verbRow } from "@/lib/cli/verbs.mjs"; +import { resolveProject } from "@/lib/projects/core.mjs"; +import { resolveProjectPath } from "@/lib/projects"; +import { addStep, getStep, isQid, listSteps, logFileOf, logTail } from "@/lib/queue/store.mjs"; +import { kickQueue, queueDir, queueRunnerStatus } from "@/lib/queue/runner"; +import { UMTOOL_DIR } from "@/lib/report/driver.mjs"; +import { crossSiteRefusal } from "@/lib/report/sameOrigin.mjs"; + +export const dynamic = "force-dynamic"; + +// ⌘K COMMANDS (umtool redesign, lane palette L8a; umtool/docs/knobs.md, "⌘K commands"): +// the verb registry's forms, run. +// +// GET { verbs, context, queue }: every ui:"form" row (lib/cli/verbs.mjs: +// verb, summary, target, queue, args) and, with ?path=<the page's +// pathname + search>, what the page is about -- { project, clip, post, take } +// GET ?job=<id>[&since=N] { job }: the app job a form started (lib/jobs.ts jobView, its log from N) +// GET ?qid=<qid> { step, log }: a queued form's step and its log's last lines +// POST { verb, values, confirm? } -> 202 { job, line } | 202 { queued: { qid }, line } +// the row's args validated and built into argv HERE (lib/cli/argv.mjs); +// a row with `queue` (it renders, or holds the heavy slot) is added to the +// durable queue, any other runs as one job on the app's runner +// | 400 not a form verb, a value its schema refuses, a raw argv, a path +// outside the project | 409 a row with `confirm` sent without confirm: true +// | 403 not this app's own page, or a host that is not this machine (DNS +// rebinding: lib/report/sameOrigin.mjs, UMTOOL_ALLOWED_HOSTS) | 409 another job runs +// The same queued command asked again within 5 s is the step already there. +// +// The page never sends argv: a body that carries one is refused, and app/api/queue/route.ts +// still refuses to add a step from a page. What runs is a registry row's argv, nothing else. +const headers = { "cache-control": "no-store" }; +const umtoolCli = () => path.join(/* turbopackIgnore: true */ UMTOOL_DIR, "bin", "umtool.mjs"); + +type Row = { verb: string; summary: string; ui: string; reason?: string; queue?: boolean; timeoutMin?: number; confirm?: { what: string } | null; args: Array<{ name: string; type: string; context?: string; pass?: string }> }; + +/** A double Enter: the same command queued again this soon is the step already there. */ +const DEDUPE_MS = 5000; + +/** The project, and the selection, a page's address is about. */ +async function contextOf(raw: string | null) { + const ctx: { project: string | null; clip: string | null; post: string | null; take: string | null } = { project: null, clip: null, post: null, take: null }; + if (!raw) return ctx; + let url: URL; + try { + url = new URL(raw, "http://x"); + } catch { + return ctx; + } + const q = url.searchParams; + ctx.clip = q.get("clip"); + ctx.take = q.get("take"); + const segments = url.pathname.split("/").filter(Boolean).map((s) => { + try { + return decodeURIComponent(s); + } catch { + return s; + } + }); + let rest: string[] = []; + if (segments[0] === "projects" && segments[1] === "at") { + ctx.project = q.get("path"); + } else if (segments[0] === "projects" && segments.length > 1) { + const r = await resolveProjectPath(segments.slice(1)).catch(() => null); + if (r && "project" in r && r.project) { + ctx.project = r.project.id; + rest = (r as { rest?: string[] }).rest ?? []; + } + } + const [view, id] = rest; + if (id && view === "clip") ctx.clip = id; + if (id && view === "post") ctx.post = id; + if (id && view === "takes") ctx.take = id; + return ctx; +} + +export async function GET(request: Request) { + const url = new URL(request.url); + const jobId = url.searchParams.get("job"); + if (jobId) { + const job = getJob(jobId); + if (!job) return Response.json({ error: "no such job" }, { status: 404, headers }); + return Response.json({ job: jobView(job, Math.max(0, Number(url.searchParams.get("since") ?? 0) || 0)) }, { headers }); + } + const qid = url.searchParams.get("qid"); + if (qid !== null) { + if (!isQid(qid)) return Response.json({ error: "?qid=<qid>" }, { status: 400, headers }); + const step = (await getStep(queueDir(), qid)) as Record<string, unknown> | null; + if (!step) return Response.json({ error: "no such step" }, { status: 404, headers }); + const log = await logTail(logFileOf(queueDir(), qid), 32 * 1024); + const pick = ["qid", "label", "state", "exitCode", "error", "blockedBy", "createdAt", "startedAt", "endedAt"] as const; + return Response.json({ step: Object.fromEntries(pick.map((k) => [k, step[k] ?? null])), log: log.slice(-200), runner: queueRunnerStatus() }, { headers }); + } + return Response.json({ verbs: formVerbs(), context: await contextOf(url.searchParams.get("path")), queue: queueRunnerStatus() }, { headers }); +} + +/** Same-origin only: the browser says where a POST comes from, and one that says nothing is not a page of this app. */ +function refuseOrigin(request: Request): string | null { + const refused = crossSiteRefusal(request.headers); + if (refused) return refused; + const site = (request.headers.get("sec-fetch-site") ?? "").trim().toLowerCase(); + if (site === "same-origin" || request.headers.get("origin")) return null; + return "refused: POST /api/cli runs only from this app's own pages -- in a terminal, run the command itself"; +} + +export async function POST(request: Request) { + const refused = refuseOrigin(request); + if (refused) return Response.json({ error: refused }, { status: 403, headers }); + const body = (await request.json().catch(() => null)) as Record<string, unknown> | null; + if (!body || typeof body !== "object" || Array.isArray(body)) return Response.json({ error: "expected JSON: { verb, values }" }, { status: 400, headers }); + if ("argv" in body || "args" in body || "cmd" in body || "command" in body) { + return Response.json({ error: "a raw command line is refused: name a verb of the registry and its values ({ verb, values })" }, { status: 400, headers }); + } + const extra = Object.keys(body).filter((k) => k !== "verb" && k !== "values" && k !== "confirm"); + if (extra.length) return Response.json({ error: `unexpected ${extra.join(", ")}: the body is { verb, values, confirm? }` }, { status: 400, headers }); + const verb = typeof body.verb === "string" ? body.verb.trim() : ""; + const row = verbRow(verb) as Row | null; + if (!row) return Response.json({ error: `no verb "${verb}" in the registry (umtool/lib/cli/verbs.mjs)` }, { status: 400, headers }); + if (row.ui !== "form") return Response.json({ error: `umtool ${verb} has no form: ${row.reason}` }, { status: 400, headers }); + const values = (body.values ?? {}) as Record<string, unknown>; + const pre = buildArgv(row, values); + if (!pre.ok) return Response.json({ error: pre.error, field: pre.field ?? null }, { status: 400, headers }); + const confirmWhat = confirmOf(row, values); + if (confirmWhat && body.confirm !== true) { + return Response.json({ error: `this would ${confirmWhat}, with no undo: send it again with confirm: true`, confirm: confirmWhat }, { status: 409, headers }); + } + + // A project arg is one the CLI will find: said here, not as the job's first line. + let project: string | null = null; + let projectDir: string | null = null; + for (const a of row.args) { + const v = values[a.name]; + if (a.type !== "project" || typeof v !== "string" || !v.trim()) continue; + const r = (await resolveProject(v.trim())) as { project?: { id: string; dir: string }; ambiguous?: unknown[] }; + if (r.ambiguous) return Response.json({ error: `"${v}" is the name of ${r.ambiguous.length} projects — give its id`, field: a.name }, { status: 400, headers }); + if (!r.project) return Response.json({ error: `no project matches "${v}"`, field: a.name }, { status: 400, headers }); + if (a.name === "project") { + project = r.project.id; + projectDir = r.project.dir; + } + } + // A file a form names is a file of THE project, by its realpath; it runs as that absolute path + // (a row whose CLI joins it to the project itself: as typed). + const run: Record<string, unknown> = { ...values }; + for (const a of pathArgsOf(row, values) as Row["args"]) { + if (!projectDir) return Response.json({ error: `${a.name}: a file names a project's file -- name the project`, field: a.name }, { status: 400, headers }); + const c = await confineToProject(projectDir, String(values[a.name])); + if (!c.ok) return Response.json({ error: `${a.name}: ${c.error}`, field: a.name }, { status: 400, headers }); + if (a.pass !== "relative") run[a.name] = c.abs; + } + const built = buildArgv(row, run); + if (!built.ok) return Response.json({ error: built.error, field: built.field ?? null }, { status: 400, headers }); + const take = row.args.filter((a) => a.context === "take").map((a) => values[a.name]).find((v): v is string => typeof v === "string" && !!v.trim()) ?? null; + const line = cliLine(built.argv); + const label = `⌘K: umtool ${built.argv.join(" ")}`.slice(0, 160); + + if (row.queue) { + try { + const same = JSON.stringify(built.argv); + const recent = ((await listSteps(queueDir())) as Array<{ qid: string; argv: string[]; state: string; createdAt: string; by?: string }>).find( + (s) => (s.state === "queued" || s.state === "running") && JSON.stringify(s.argv) === same && Date.now() - Date.parse(s.createdAt) < DEDUPE_MS, + ); + if (recent) return Response.json({ ok: true, queued: { qid: recent.qid }, deduped: true, line, queue: queueRunnerStatus() }, { status: 200, headers }); + const step = (await addStep(queueDir(), { + argv: built.argv, + label, + by: "the umtool app (⌘K)", + cwd: UMTOOL_DIR, + target: project ? { project, take } : null, + ...(row.timeoutMin ? { timeoutMin: row.timeoutMin } : {}), + })) as { qid: string }; + kickQueue(); + return Response.json({ ok: true, queued: { qid: step.qid }, line, queue: queueRunnerStatus() }, { status: 202, headers }); + } catch (e) { + return Response.json({ error: e instanceof Error ? e.message : String(e) }, { status: 409, headers }); + } + } + const running = runningJob(); + if (running) return Response.json({ error: `a job is already running (${running.kind}) — run this when it is done`, running: jobView(running, running.log.length) }, { status: 409, headers }); + const job = startJob(`umtool ${verb}`, [{ cwd: UMTOOL_DIR, env: {}, label: `umtool ${built.argv.join(" ")}`.slice(0, 200), argv: [process.execPath, umtoolCli(), ...built.argv], timeoutMs: (row.timeoutMin ?? 15) * 60_000 }], { project }); + return Response.json({ ok: true, job: jobView(job), line }, { status: 202, headers }); +} diff --git a/umtool/bin/umtool.mjs b/umtool/bin/umtool.mjs @@ -859,294 +859,15 @@ async function cmdCheckSources() { console.log("# Nothing was run. Settings · system's Sources panel runs this chain through the job runner."); } -function usage() { +// `umtool help`: generated from the verb registry's prose (lib/cli/groups.mjs, lib/cli/docs.mjs). +async function usage() { + const { usageText } = await import("../lib/cli/docs.mjs"); console.log( - [ - "umtool — the project tree, from a terminal", - "", - " umtool ls [--kind K] [--template T] [--state S] [--open] [--blocking]", - " [--q TEXT] [--sort name|recent] [--json]", - " umtool show <project> [--json]", - " umtool check [<project>] [--json] exit 1 on anything blocking", - " umtool links <project> [--json] [--fix] do the clip QRs open on their sites? (corpus.json -> slugToPage", - " -> the shard's record; polite, cached; out/links.json, which check reads); exit 1 when one is dead", - " umtool cast [ls] | add <id> --name … --voice <engine:voice> [--handles a,b] | set <id> … | rm <id> | undo", - " | project <p> | audition <character> --voices a,b,c [--project <p>] [--text …] | use <p> <character> <voice>", - " [--everywhere] | reread <p> <character> the CAST: characters' stock voices across projects (cast.json), a", - " project's characters and their drift, an audition of candidate voices (scored against the real voice)", - " umtool speaker-check <project> [--clip <id> …] [--json] which of the project's named voices (speakers.json) each", - " clip is: TitaNet-small, local -> speaker-check.json; --set 'Name=<clip>,<channel>/<id>,channel:<slug>' / --remove / --list", - " umtool quote-check <project> [--clips a,b] [--pad S] [--json] | --status is each clip's quote in the seconds it plays?", - " the cut ±15 s of the source the render would use, transcribed by the editor (words on), the quote", - " found in it and in the cues: ok | moved (heard N s away: window --align) | not-found -> quote-check.json;", - " check calls moved and not-found blocking, and a take refuses them unless the clip is --quote-ruled", - " umtool check-joins <project> --take <id> [--json] [--all] [--limit <n>] every boundary of the take's master where the", - " next post item draws a post the one before showed: its join, the SSIM across it, the largest jump", - " umtool link-policy <project> [--via <site id|url>] [--direct a,b] [--clear] [--fix] [--json] the link policy", - " (provenance.linkPolicy): cite via site X, these channels direct; --fix rewrites the clips that break it", - " umtool patch-markers <project> [<file>.patch.json] [--fix] [--json] take patches whose deck markers name a", - " clip not in the cut; --fix gives each the after of the cut's marker of the same label", - " umtool decisions [--json]", - " umtool inbox [--all] [--json] the decisions, grouped and ranked as the inbox shows them", - " (--all: the hidden ones on parked/done pieces, and the quiet group)", - " umtool schedule list | show <id> [--json] the recurring reports: chip, editions, tick log (read-only;", - " a schedule is written through the editor: `pnpm ops report-schedule`)", - " umtool folders [--json]", - " umtool kinds [--json]", - " umtool link <project> <site>/<report> | --clear [--json] the manifest names its article (a top-level", - " `article`): what settles link-ambiguous; noted for the generator on a generated manifest", - " umtool window <project> <clip> [--start S] [--end E] [--lock|--lock-end|…]", - " attribution too: --title, --date YYYY-MM-DD, --cite, --cite-url, --quote", - " --repeat-of <clip> it re-plays that clip on purpose (a callback): their overlap is not flagged or trimmed", - " --correction TEXT what the REPORT got wrong here (never rendered)", - " --walk-note TEXT an editorial note from the walk (not a correction; never rendered)", - " --star / --no-star the walk's favourite: a trailer candidate (umtool trailer <p> --candidates)", - " a window edit that leaves --cite (or the citeUrl's t=) more than 5 s before the clip, or", - " after it, moves it to the clip's first second; an explicit --cite moves the QR's t= with it", - " --verdict confirmed|incorrect what the walk said; incorrect needs --correction", - " --reject <why> [--note TEXT] rejected on the walk, kept in place (`umtool timeline <p> reject`", - " takes it out, on record): not-matching|wrong-speaker (fact errors: incorrect, the note its", - " correction) or irrelevant|repeats|weak|privacy|other (rejected; other needs --note)", - " --cut-start S --cut-end E --lock-cut the cut the video renders", - " --align the cut snapped to the quote as HEARD (quote-check.json: a breath before its first word,", - " its last let ring; the extent widened to hold it; lockCut kept) -- the per-clip fix for a moved quote", - " --quote-ruled / --no-quote-ruled a person heard it and rules the quote check's verdict: a take renders it", - " --move-stamp first|nearest|<s> | --clear-stamp with --start/--end: a stamp's second (claim.at,", - " a mark's at) the new window would leave outside moves to the first second that plays, the nearest,", - " or <s>, or loses its at -- in the same write; --move-mute nearest | --clear-mute the mute mark's", - " --gap FROM-TO (repeatable) cut those source seconds out of the clip's middle: it plays", - " as ONE segment of jump cuts (gaps.mjs; inside the cut, ≥ 0.2 s, 0.5 s kept between);", - " --gap-remove S the gap holding source second S · --gaps 'A-B,C-D' the whole list ('' clears)", - " an empty value (--title '') deletes the field", - " --take <id> a take's clip (walk a take): the edit goes into takes/<id>/take.json's", - " patch, an undo point first (`umtool timeline <p> --take <id> undo`); the manifest is untouched", - " umtool walk <project> [--take <id>] [--all] [--json] the clip bench's walk: every clip in walk order,", - " its verdict, fetched or not, and (→) the ones the walk visits; --take walks a take (a draft too)", - " umtool present <project> [--take <id> | --cut] [--json] [--public] [--open] PRESENT MODE: the cut as slides,", - " navigated like a deck (/projects/<p>/present); prints its address and its slides (#<slide id> opens", - " one); --json the payload (posts with their censor data by kind, clips' spans, section/day dividers);", - " --public the payload a public page would carry (censored, no reveal data); --open opens it", - " umtool set <project> <clip> key=value … a clip's knobs (`key=` clears; umtool/docs/knobs.md):", - " claim.at (a source second: the stamp lands, the count steps) claim.hold claim.stamp", - " claim.count claim.label (the first mark's, or --mark <id>'s) · marks: mark.add=<verdict>[@<sec>]", - " mark.remove=<id> mark.verdict=<verdict> marks=<json> (≤ 8, each its own stamp and count)", - " · audio.offset (ms, + later) audio.gain (dB) audio.fadeIn audio.fadeOut", - " · hideModules=diet,streak (those modules hidden over the entry's span; any entry)", - " · shelfNote='words' (a line on the shelf over the entry's span; any entry)", - " --take <t>: the entry knobs into the take's patch, the project's manifest untouched", - " umtool intro <project> [key=value …] [--off] [--json] THE INTRO the cut opens on (render.intro): prints it,", - " what the cut opens with and each version's on/off; key=value writes it (style seconds mark sound", - " site title lines …; `key=` clears; a new one starts as boot-dark); --off takes it off;", - " --take <t> --off|--on: that version opens on no intro (its patch's render.intro: null) or the cut's", - " umtool look <project> key=value … the cut's knobs: factcheck.stamp.scale|motion|opacity|seconds,", - " factcheck.verdicts.<V>.stampLabel|label|color, deck.markers=<json>, deck.markerLayout,", - " variants=<json>, and the look's keys (transition=0.3, …)", - " umtool migrate <project> [--dry-run] [--json] move the manifest into the video modules' homes", - " (the fact-check verdicts and tally become deck.counter's series); renders the same", - " umtool variants <project> [--take <t>] [--list] [--json] make the encode ladder of a build (render.variants);", - " --list: what was made, and the build's sync report (each clip's lag, past a frame flagged)", - " umtool corrections <project> what the report got wrong + the walk's coverage", - " umtool build <project> [--preset preview|fast|final] [--only ID]", - " --run: the app's build job (UMTOOL_URL, else http://localhost:3050; --url), followed here;", - " Ctrl-C cancels it; --replace stamps a newer deliverable aside", - " 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;", - " --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|frames]", - " <folder>/<slug>, or --folder <folder>: the project in a folder of the reports tree (its id", - " <folder>/<slug>, routed /projects/<folder>/<slug>) — a spin-off beside its parent", - " --seed frames: a draft supercut from the video's frame scan (pnpm ops frame-scan) — the events", - " ranked (scoops, milestones, swings, pots, level-ups) into --target <seconds> (default 240), the", - " deck on with the stats region drawing frameScan.overlay over each clip", - " --seed phrase --phrase <regex> --channels a,b [--prefer <slug>] [--exclude <regex>]: every time", - " the phrase was said in those channels' transcripts, chronological, cut from the --prefer", - " channel's copy where it has one (a twin by date and duration); a context matching --exclude", - " is left out; the scan beside the manifest as phrase-scan.json; --max N keeps N instances", - " spread across the years in proportion (the rest: phrase-scan.json \"skippedByCap\")", - " --seed reactions --from <channel>/<id> [--target S] [--laugh-min X] [--scope FROM:TO|auto [--segment sN]] [--no-analyze]: the clip finder on a long", - " recording (needs its diarization.json): highlights proposed from the host's laughs and comments,", - " then `umtool clips analyze` (the laugh scan + voices) unless --no-analyze; --scope auto reads the", - " narrated video auto-scope finds in the speakers' turns (--segment names one, else the longest)", - " --from-posts <channel> [--channel <more>…] [--since D] [--until D] [--own] [--with-media]", - " [--replies include|only|exclude] [--order chrono|reverse] [--limit N]: a POSTS REEL -- each", - " archived post a post item (its card, its attachments), the deck on (umtool posts reel adds more)", - " [--brand archilyzer-media] render.brand: the report-to-video brand preset", - " umtool doctor [--json] exit 1 if the report pipeline is missing a tool", - " or the media root is set and not there; the roots, and a leftover old cache", - " umtool storage [<project>] where each project's out/ lives (dir, link, DANGLING)", - " umtool storage move-out|move-back <project>|--all [--dry-run]", - " umtool storage deliverables <project> --to media|local [--dry-run] clips/ + share-*/, then the switch", - " out/ to the media root (UMTOOL_MEDIA_DIR) and back; run when nothing is building", - " umtool snapshot <project> [--label L] copy the manifest into revisions/", - " umtool diff <project> <snapshot> what changed since that snapshot", - " umtool export <project> --format toc-bbcode|toc-markdown|description|chapters [--variant V] [--first TITLE]", - " umtool export <project> <clip> [--context N | --raw [--from S --to S]] [--fetch] [--take T] [--open] one clip,", - " clean, into <project>/exports/: the cut's edges, its gaps out, its mute; --context N what the cut", - " plays ± N s; --raw the whole fetched window, or a span (the full exchange), as recorded; --fetch", - " asks the editor first for what that needs; in the heavy slot; --open shows it", - " umtool check-sources [<project>…] prints the re-check chain (never-checked/old when no args)", - " umtool notes [<site>/<report>|<project>|--all] the operator's notes, as markdown (open ones)", - " umtool notes reply <id> \"<text>\" [--resolve] answer one; resolve | wontfix | reopen <id>", - " umtool modules list | apply <project> [--config F] [--dry-run | --take <id> [--at S --dur S | --full] …]", - " a module-config.json onto the cut (writers), or as a take's patch", - " umtool preset list | show <name> | save <name> --from <project> | apply <name|none> <project>", - " the look presets (preset → manifest → style → take patch)", - " umtool take <project> --id <id> --label L [--style S] [--patch F | --set p=v …] [--at S --dur S | --full]", - " one take: the manifest with a style's patch, rendered into takes/<id>/ (--rebuild, --force;", - " --from TAKE reuses that take's segments, chrome and batches; --keep-frames keeps the chrome)", - " --draft (--no-render): record the take, render nothing -- walk it, edit it, render it later", - " (`umtool take <p> --id <id> --full` renders a draft from its stored patch)", - " --priority: render mode for the take's lifetime -- every other heavy job waits for it, the", - " editor's transcription and download lanes are held; all let go at its end, failure or signal", - " --draft --from TAKE: a draft that starts from that take's patch (its timeline its own from then on)", - " umtool take <project> --id <id> --import-item <project>:<item>[,<item>…] [--after <entry>|--before <entry>]", - " [--as <id>] [--dry-run] [--json] items of ANOTHER project cloned into the take (its patch), their", - " narration and pick kept, the files they name hard-linked into this project; again: updated or unchanged", - " umtool lint <project> [--take <id>] [--variant sourced|full] [--final] [--json] the manifest lint a build runs", - " first, on the project's manifest or a take's (its patches applied), and the files its post items", - " name (a picked read, an attachment not in the project: an error) -- exit 0 clean, 1 an error", - " umtool take <project> --id <id> --promote [--anyway] make this the cut: the take's patch applied to the", - " manifest, one undo point (revisions/…-auto-before-promote-take)", - " umtool take status <project> [--id <id>] [--json] [--log] [--tail N] the take's render record (every render", - " writes takes/<id>/render.json and the full render.log): exit 0 done, 3 queued/waiting/running, 1 failed", - " umtool queue add [--after <qid>|last] [--label T] -- <umtool subcommand argv…> a step the umtool APP runs, in", - " order, one at a time (it survives the session); prints the qid. ls [--all] | status <qid> | wait <qid>", - " [--timeout S] | log <qid> | cancel <qid> | retry <qid> [--json]; status exits 0 done, 3 going, 1 failed", - " umtool jobs [--json] every running and recent take render and queue step, across projects, and the app's jobs", - " umtool takes make <project> [--recipe F | --all-styles] | styles | pick <project> <take> [--anyway]", - " | ls <project> | relabel <project> <take> <label…> | supersede <project> <take> [--by <take>] [--clear]", - " | delete <project> <take> [--dry-run] [--force] take housekeeping: a label fixed, a take folded away", - " as superseded, a take deleted -- refused while a render names it", - " umtool render-mode on [--for 90m] [--note T] | off [--force] | status [--json] render mode: a render the", - " operator waits for gets the machine (other heavy jobs wait; the editor's transcription and", - " download lanes held); `on` is a window for a chain of renders (default 2h)", - " on [--for D] [--print-token] -- <cmd …>: held while <cmd> runs (its env carries the token,", - " the hold is its pid), released when it exits -- the form for a script; --print-token prints", - " the token alone on stdout", - " umtool pool [stats] [--since 7d] | prune [--max-gb N] [--dry-run] | verify [--sample N | --all] [--json]", - " the render pool: every post, clip, chunk, sound and chrome frame a build made, by its key,", - " hard-linked into any take that needs it again (UMTOOL_RENDER_POOL=0 off; _MAX_GB its cap)", - " umtool trailer <project> --take <t> (--beats F | --beats-json J) [--intro] [--finale S] [--xfade 0.3] [--out NAME]", - " a trailer cut from the take's finished master: the master's own frames, so the deck shows the", - " whole timeline; beats are clip source seconds or master seconds ([--dry-run] the mapping only)", - " --reel <name> [--take <t>]: a beat reel's beats and settings (promo/<name>-beats.json),", - " written to takes/<t>/out/<slug>.<name>.mp4; no --take: its pinned, last-cut or latest master", - " --vertical [--layout reframe] [the vertical flags]: the reel 9:16 (umtool vertical --reel)", - " umtool vertical <project> --take <t> (--reel R | --beats F | --items a,b) [--clip full|framed|quote]", - " [--post card|stack|media] [--side split|overlay] [--hook title|section|<copy>] [--reframe] [--json]", - " a vertical short (1080x1920, -14 LUFS) of the take's items: each clip cut again in its layout,", - " each post drawn in a portrait box; --reframe recomposes the finished 16:9 master instead", - " umtool trailer-beats <project> [ls] | add <clip> [<from>-<to>] [--at N] [--label L] | add-raw <at> <dur> | set <n> <from>-<to>", - " | remove <n> | move <n> --to <m> | order | limit <s|m:ss|x|instagram|shorts|tiktok> | xfade <s> | intro on|off", - " | candidates [--add] the trailer's beats (promo/trailer-beats.json, the Trailer page's file): each", - " beat's length, the running length against the platform limit (X 2:20), beats outside their clip", - " | verdict <n> confirmed|note|clear | title T | take T | undo | reels | new-reel <name> [--from R]", - " --reel <name>: that beat reel (promo/<name>-beats.json); every write is an undo point", - " umtool tighten <project> [--json] [--all] [--no-measure] | --apply <clip>[,<clip>…] each clip to its sentence (its", - " cut's, else the whole ones in its window), each edge into its pause; before -> after; --apply writes", - " umtool ledger <project> [ls] [--scope S] [--json] | add <id> --date D --scope S --population P [--value V] --scopeBasis \"…\" [--<key> V …] | set <id> --<key> V … [--unset k,k] | rm <id>", - " a measure ledger's rows, checked against its ledgerSchema (incl. promise / promise_check, run, retro)", - " umtool measure <project> [--take <t>] [--scopes a,b] [--scale MIN-MAX] [--as-of YYYY-MM-DD] [--json]", - " the measure slice the instruments draw from: events at their cut seconds, hidden rows, totals", - " umtool rulings <project> [--json] | import [--dry-run] | set <clip> keep|cut|not-him|read-aloud [--reason R] [--match M] | clear <clip>", - " the clip deck's montage rulings (montage-rulings.json); a render leaves the ruled-out clips out", - " umtool fetch <project> [--dry-run | --wait | --status | --body] [--reason R] [--json]", - " the clip windows asked of the editor as one fetch-windows batch (one paced job per platform);", - " each run recorded in <project>/fetch-runs.json; --refetch <clipId>[,…] / --refetch-video <slug>/<id>", - " evict those clips' cached windows first (the editor's evict-clips), then fetch", - " umtool prep <project> [--clips a,b] [--wait | --status] [--json]", - " what the clip bench makes on a clip's first open (a long recording's excerpt, the waveform),", - " made before the walk: queued and run in the background, one clip at a time, in the heavy slot", - " (a small declared estimate), under nice/ionice; --wait runs it here; a write or a fetch queues it too", - " umtool prune [<project> [--take X] [--anyway] | --all] [--keep N] [--older-than 3d] [--idle-work 3d] [--yes] [--json]", - " takes' work files (segments, chrome frames, crossfade batches, encode chunks, the rail's prerail base):", - " what each holds (hard links counted by inode), which takes keep theirs and why, what freeing the rest", - " gives back; a dry run unless --yes. A take build prunes its project after; a render prunes when disk is", - " low. --idle-work D: in a project untouched for D, the newest/picked takes' work goes too", - " umtool prune [<project> | --all] --versions [--idle 3d] [--grace 7d] [--idle-work 3d] [--yes] [--json]", - " whole SUPERSEDED takes, through `takes delete`: per version line (the id, digits folded:", - " draft-# ; letters never: v6c ≠ v6d) the highest built number is kept, older ones while it is", - " younger than --grace, and any take picked, judged, rendering, a base, noted on or refused;", - " a project touched within --idle, or whose verdicts.json cannot be read, is skipped", - " umtool fallback <project> [--dry-run | --clip <id> … | --restore <clipId>] [--json]", - " stand-ins for refused montage windows: the instance's public alternate (YouTube first), on the clip", - " umtool phrases \"<phrase>\" [\"<phrase>\" …] --channels a,b [--prefer c] [--exclude RE] [--words|--regex] [--json]", - " how often each phrase was said, by year, in one pass (the phrase finder's search)", - " umtool voice-match <project> [--reference auto|rulings|recordings] [--reference-video <channel>/<id> …] [--instances F] [--dry] [--json]", - " a local speaker-similarity score per montage clip (TitaNet-small) -> <project>/voice-match.json", - " umtool clips analyze <project> [--from <channel>/<id>] [--rescan] [--no-laughs] [--no-voices] [params]", - " umtool clips propose <project> [--host N] [params] [--dry] | show <project> | segments <project>", - " the clip finder: the laugh scan + voices on the recording's sound, then clips proposed", - " (setup → reaction → tail) into the manifest (assist: by the assistant) and reactions.json;", - " params --target S --laugh-min X --merge-gap S --setup-max S --clip-max S; a clip you edited is never moved", - " umtool refresh <article> [--iteration N] [--no-fetch] [--yes] [--json]", - " re-fetch an article's scope, see what changed, update: the plan (the editor's);", - " --yes starts it, one editor job (needs WORKER_TOKEN and the editor)", - " umtool refresh --check [<article>] [--force] [--json] the daily suggestion check, now", - " umtool clip <channel>/<video>@<start>-<end> [--snap words] [--title T] [--site <id>] [--json]", - " QUICK CLIP: a basic-mode project (the footage alone), its window asked of the editor, its", - " edges snapped to the words (--snap words), rendered as a take; prints the mp4 and its share line", - " umtool share <project> [<clip>] [--take <id>] [--site <id>] [--json] a clip's share line: its platform", - " page at the moment and its archive moment (a Rumble folder id mapped to the embed id)", - " umtool timeline <project> [ls] [--json] the cut: index, id, type, video, start–end, date title", - " umtool timeline <project> insert --after <id|-> <channel>/<video>@<start>-<end> [--id ID] [--section N]", - " [--lock] [--lock-end] [--title T] [--stream-title T] [--date YYYY-MM-DD] [--quote Q] [--cite S]", - " [--cite-url U] a clip, then its attribution, in the manifest's convention (deck: onscreen.title)", - " umtool timeline <project> move <id> --to <index> | remove <id> | duplicate <id> [--at <index>]", - " umtool timeline <project> post <json|@file> | post-remove <id> | teaser <id> <patch-json|@file> | undo", - " the Cut tab's structure (POST /api/report/timeline's writers): each write snapshots the", - " manifest first (revisions/…-auto-before-<op>), is checked by the build, notes a generated cut", - " umtool timeline <project> --take <id> [ls | move <id> --to <index> | remove <id> | undo] a take's timeline:", - " the writes go into its patch (takes/<id>/take.json), each with an undo point of its own", - " umtool scenes <project> <clip> [--black-min 0.05] [--threshold 8] [--pix-th 0.10] [--pad 30 | --from S --to S] [--json]", - " scene cuts (scdet) and black spans (blackdetect) in the clip's fetched window, in SOURCE", - " seconds — for blur.from/blur.to and trims; nothing fetched (`umtool fetch` first)", - " umtool posts add <project> <archive-channel>/<postId> [--attach <clipId>] [--flag F] [--author A] [--id ID] [--thread] [--json]", - " a post entry from the corpus's posts archive, its screenshot copied into posts-media/;", - " refused when the post has no shot (`pnpm ops capture-posts` first); --thread: a reply drawn", - " with the post it answers above it (shot-thread.png, capture-posts \"thread\": true)", - " umtool posts set <project> <post> thread=on|off [hide=on|off] [attach=<clipId>|auto] [--json]", - " umtool posts reel <project> --channel <slug> [--channel …] [--since D] [--until D] [--own] [--with-media]", - " [--replies include|only|exclude] [--order chrono|reverse] [--limit N] [--after <id|->] [--dry-run] [--json]", - " POST ITEMS: each archived post an entry of the cut (its card, its attachments played), one write;", - " a re-run adds only posts not already in the cut", - " umtool posts set-item <project> <item> [hold=<s>|off] [layout=sequence|grid] [redact=on|off|auto] [media.<i>.start=<s>]", - " [media.<i>.end=<s>] [media.<i>.mute=on|off] [media.<i>.crop=x,y,w,h|off] [media.<i>.push=on|off] [--json]", - " umtool posts narrate <project> [--import | --list | <item> [--script \"…\"] [--take [--note \"…\"]] [--pick n] [--approve] [k=v …]", - " | --all --draft-scripts | --all --take | --cut k=v …] a post read aloud (its takes: the editor's tts or yours)", - " umtool posts narrate <project> <item> --take --thread [--parents 0|all] [--skip-parent <id>]… [--no-quoted]", - " [--voice-for <handle>=<voice>]… [--dry-run] [--json] a THREAD READ: its context and his words in date", - " order, each in its author's voice, parts cached, one take saved and picked (exit 0 / 1)", - " umtool posts set-item | roles | narrate | reread | fx … --in-take <take> the same edit on a TAKE of the project:", - " its manifest read as the take's, the write in takes/<take>/take.json's patch (an undo point of the take's,", - " `umtool timeline <p> --take <take> undo`), the project's manifest untouched; set-item/roles/reread/fx", - " take --take <take> for it too (narrate's --take is a new read)", - " umtool posts say <project> ls | add <word> \"<spoken>\" [--case] [--item <id>] | remove <word> | try \"<text>\" | stale", - " the PRONUNCIATION LEXICON every synthesized read applies (stale: picked reads that say it the old way)", - " umtool posts voices <project> ls | set <handle|*> <voice> | remove <handle> the voice map a thread read uses", - " umtool posts fit <project> [--all | <item> …] [--linger s] [--dry-run] narrated posts' videos cut to their best part", - " umtool posts avatar <project> [<handle> <image>|off] · avatars <project> the authors' pictures on the cards", - " umtool posts redact <project> ls | add \"<term>\" [--substring] [--note \"…\"] | remove <n> words blanked from", - " what is published (a bar on the card, left out of a synthesized read); the data never rewritten", - " umtool posts repeats <project> [--match id|file|audio] [--json] the attachments played more than once (the combo counter)", - " umtool posts combo <project> [k=v …] · <item> off|on|k=v … the combo badge's knobs (the cut's, one item's)", - " umtool posts attach <project> [<item> … | --all] [--dry-run] a capture's media onto post items that carry none", - " umtool candidates <project> [ls] [--all] [--json] | import <sweep.md> [--dry-run] | add <json|@file>", - " the candidates inbox: a sweep's or an agent's proposed clips -> <project>/candidates.json;", - " Insert into a section or a group, and Not this, are the Cut tab's Candidates panel's", - " the Posts table's writer (updatePosts); <post> is x-<postId> or the bare <postId>", - " umtool ingredient <channel>/<video> [--window <from>-<to>] [--used-in] [--json] one recording's life cycle:", - " found, downloaded, transcribed, clock, windows, used in, checked, rendered, published (/ingredients)", - "", - `reading ${REPORTS_ROOT} (set REPORTS_DIR to move it)`, - "", - "Run `check` before every build. It is what catches a manifest with no", - "siteOrigin — the defect that shipped 19 QR codes reading `undefined/?v=…`.", - ].join("\n"), + usageText({ + reportsRoot: REPORTS_ROOT, + chainSteps: CHAIN_STEP_NAMES.join(", "), + draftAllSteps: chainStepsOf("draft-all").map((s) => s.name).join(", "), + }), ); } diff --git a/umtool/components/shell/CommandForm.tsx b/umtool/components/shell/CommandForm.tsx @@ -0,0 +1,322 @@ +"use client"; + +import { useEffect, useMemo, useRef, useState } from "react"; +import { buildArgv, cliLine, confirmOf } from "@/lib/cli/argv.mjs"; +import { cn } from "@/lib/utils"; + +// --------------------------------------------------------------------------- +// ONE VERB AS A FORM (⌘K Commands, lane palette L8a): a row of the verb +// registry (lib/cli/verbs.mjs, served by GET /api/cli) drawn as its args, the +// page's project and selection filled in; the exact command line under it +// (Copy as CLI -- built by the same lib/cli/argv.mjs the server builds argv +// with); Run posts { verb, values } to /api/cli and follows what it started: +// the app job's live log, or the queued step's. A row with `confirm` (no undo: +// it deletes, evicts or kills) asks a second press, "Yes, <what it does>", +// and the server wants that confirm too. What Run started is handed up +// (onStarted), so the palette lists it under Runs after an Escape. +// --------------------------------------------------------------------------- + +export type CliArg = { name: string; type: string; required?: boolean; choices?: string[]; default?: unknown; help?: string; repeat?: boolean; context?: string }; +export type CliVerb = { verb: string; summary: string; target: string; queue: boolean; confirm?: { what: string; when?: string[]; unless?: string[] } | null; args: CliArg[] }; +export type CliContext = { project: string | null; clip: string | null; post: string | null; take: string | null }; +export type Value = string | boolean; +/** A run the palette keeps: its form's values and what it started. */ +export type CliRun = { verb: string; values: Record<string, Value>; kind: "job" | "queued"; id: string; line: string; at: number }; + +type Run = + | { kind: "job"; id: string; state: string; log: string[]; next: number; error: string | null; exitCode: number | null } + | { kind: "queued"; qid: string; state: string; log: string[]; error: string | null; exitCode: number | null; runnerUp: boolean }; + +const TEXTAREA = new Set(["pairs", "flagpairs", "list", "text", "json"]); +const TERMINAL = new Set(["done", "failed", "cancelled", "blocked"]); + +/** What the page tells the form: the project for a project arg, the selection for one that asks. */ +function initialValues(row: CliVerb, ctx: CliContext): Record<string, Value> { + const v: Record<string, Value> = {}; + for (const a of row.args) { + if (a.type === "project" && a.name === "project" && ctx.project) v[a.name] = ctx.project; + else if (a.context === "clip" && ctx.clip) v[a.name] = ctx.clip; + else if (a.context === "post" && ctx.post) v[a.name] = ctx.post; + else if (a.context === "take" && ctx.take && a.required) v[a.name] = ctx.take; + else if (a.default !== undefined) v[a.name] = typeof a.default === "boolean" ? a.default : String(a.default); + } + return v; +} + +export default function CommandForm({ + row, + ctx, + onBack, + resume = null, + onStarted, +}: { + row: CliVerb; + ctx: CliContext; + onBack: () => void; + /** A run started before (the palette's Runs): its values, and it is followed again. */ + resume?: CliRun | null; + onStarted?: (run: CliRun) => void; +}) { + const [values, setValues] = useState<Record<string, Value>>(() => (resume ? resume.values : initialValues(row, ctx))); + const [run, setRun] = useState<Run | null>(() => + resume + ? resume.kind === "job" + ? { kind: "job", id: resume.id, state: "running", log: [], next: 0, error: null, exitCode: null } + : { kind: "queued", qid: resume.id, state: "queued", log: [], error: null, exitCode: null, runnerUp: true } + : null, + ); + const [asking, setAsking] = useState<string | null>(null); + const [posting, setPosting] = useState(false); + const [refused, setRefused] = useState<string | null>(null); + const [copied, setCopied] = useState(false); + const first = useRef<HTMLElement | null>(null); + const logRef = useRef<HTMLPreElement>(null); + + useEffect(() => { + first.current?.focus(); + }, []); + + const built = useMemo(() => buildArgv(row, values), [row, values]); + const line = built.ok ? cliLine(built.argv) : null; + const going = posting || (run !== null && !TERMINAL.has(run.state)); + + // Follow what Run started. + useEffect(() => { + if (!run || TERMINAL.has(run.state)) return; + let live = true; + const t = setTimeout(async () => { + try { + if (run.kind === "job") { + const r = await fetch(`/api/cli?job=${encodeURIComponent(run.id)}&since=${run.next}`, { cache: "no-store" }); + const j = (await r.json()) as { job?: { state: string; log: string[]; next: number; error: string | null; exitCode: number | null } }; + if (!live) return; + if (!j.job) { + setRun((cur) => (cur ? { ...cur, state: "failed", error: "the app no longer knows this job (it restarted): see Settings · system" } : cur)); + return; + } + const job = j.job; + setRun((cur) => (cur && cur.kind === "job" ? { ...cur, state: job.state, log: [...cur.log, ...job.log].slice(-400), next: job.next, error: job.error, exitCode: job.exitCode } : cur)); + } else { + const r = await fetch(`/api/cli?qid=${encodeURIComponent(run.qid)}`, { cache: "no-store" }); + const j = (await r.json()) as { step?: { state: string; error: string | null; exitCode: number | null }; log?: string[]; runner?: { enabled: boolean; armed: boolean } }; + if (!live) return; + if (!j.step) { + setRun((cur) => (cur ? { ...cur, state: "failed", error: "no such step in the queue" } : cur)); + return; + } + const step = j.step; + setRun((cur) => (cur && cur.kind === "queued" ? { ...cur, state: step.state, log: j.log ?? [], error: step.error, exitCode: step.exitCode, runnerUp: !!j.runner?.armed } : cur)); + } + } catch { + /* the next turn tries again */ + } + }, 700); + return () => { + live = false; + clearTimeout(t); + }; + }, [run]); + + useEffect(() => { + const el = logRef.current; + if (el) el.scrollTop = el.scrollHeight; + }, [run?.log.length]); + + const set = (name: string, v: Value) => setValues((cur) => ({ ...cur, [name]: v })); + + const submit = async (confirmed = false) => { + if (!built.ok || going) return; + const what = confirmOf(row, values); + if (what && !confirmed) { + setAsking(what); + return; + } + setAsking(null); + setPosting(true); + setRefused(null); + try { + const r = await fetch("/api/cli", { + method: "POST", + headers: { "content-type": "application/json" }, + body: JSON.stringify({ verb: row.verb, values, ...(confirmed ? { confirm: true } : {}) }), + }); + const j = (await r.json().catch(() => ({}))) as { + error?: string; + line?: string; + confirm?: string; + job?: { id: string; state: string; log: string[]; next: number; error: string | null; exitCode: number | null }; + queued?: { qid: string }; + queue?: { armed: boolean }; + }; + if (!r.ok) { + if (j.confirm) setAsking(j.confirm); + else setRefused(j.error ?? `HTTP ${r.status}`); + } else if (j.job) { + setRun({ kind: "job", id: j.job.id, state: j.job.state, log: j.job.log, next: j.job.next, error: j.job.error, exitCode: j.job.exitCode }); + onStarted?.({ verb: row.verb, values, kind: "job", id: j.job.id, line: j.line ?? line ?? "", at: Date.now() }); + } else if (j.queued) { + setRun({ kind: "queued", qid: j.queued.qid, state: "queued", log: [], error: null, exitCode: null, runnerUp: !!j.queue?.armed }); + onStarted?.({ verb: row.verb, values, kind: "queued", id: j.queued.qid, line: j.line ?? line ?? "", at: Date.now() }); + } + } catch (e) { + setRefused(e instanceof Error ? e.message : String(e)); + } finally { + setPosting(false); + } + }; + + const copy = async () => { + if (!line) return; + try { + await navigator.clipboard.writeText(line); + setCopied(true); + setTimeout(() => setCopied(false), 1500); + } catch { + setRefused("the clipboard refused: select the line and copy it"); + } + }; + + const field = (a: CliArg, i: number) => { + const id = `cli-arg-${i}`; + const v = values[a.name]; + const ref = i === 0 ? (el: HTMLElement | null) => void (first.current = el) : undefined; + const bad = !built.ok && built.field === a.name; + const control = + a.type === "boolean" ? ( + <input id={id} ref={ref} type="checkbox" checked={v === true} onChange={(e) => set(a.name, e.target.checked)} className="h-3.5 w-3.5 accent-[var(--color-signal)]" /> + ) : a.type === "choice" ? ( + <select id={id} ref={ref} value={typeof v === "string" ? v : ""} onChange={(e) => set(a.name, e.target.value)} className="h-7 min-w-0 flex-1 rounded-[3px] border border-seam bg-panel-2 px-1.5 text-[12.5px]"> + <option value="">{a.required ? "choose…" : "—"}</option> + {(a.choices ?? []).map((c) => ( + <option key={c} value={c}> + {c} + </option> + ))} + </select> + ) : TEXTAREA.has(a.type) ? ( + <textarea + id={id} + ref={ref} + rows={a.type === "text" || a.type === "json" ? 3 : 2} + value={typeof v === "string" ? v : ""} + placeholder={a.help ?? ""} + spellCheck={false} + onChange={(e) => set(a.name, e.target.value)} + className="min-w-0 flex-1 resize-y rounded-[3px] border border-seam bg-panel-2 px-1.5 py-1 font-mono text-[12px] text-text outline-none focus:border-signal" + /> + ) : ( + <input + id={id} + ref={ref} + value={typeof v === "string" ? v : ""} + inputMode={a.type === "number" ? "decimal" : undefined} + placeholder={a.help ?? (a.type === "number" ? "a number" : "")} + spellCheck={false} + onChange={(e) => set(a.name, e.target.value)} + onKeyDown={(e) => { + if (e.key === "Enter") { + e.preventDefault(); + void submit(); + } + }} + className="h-7 min-w-0 flex-1 rounded-[3px] border border-seam bg-panel-2 px-1.5 font-mono text-[12px] text-text outline-none focus:border-signal" + /> + ); + return ( + <div key={a.name} data-cli-arg={a.name} className={cn("flex items-start gap-2 py-1", bad && "text-reject-text")}> + <label htmlFor={id} className="w-[132px] shrink-0 truncate pt-1 font-mono text-[11.5px] text-muted" title={a.help ?? a.name}> + {a.name} + {a.required && <span className="text-signal"> *</span>} + </label> + <div className="flex min-w-0 flex-1 flex-col gap-0.5"> + {control} + {a.help && a.type !== "boolean" && !TEXTAREA.has(a.type) && a.type !== "string" && a.type !== "number" && <span className="text-[11px] text-muted-2">{a.help}</span>} + {a.help && a.type === "boolean" && <span className="text-[11px] text-muted-2">{a.help}</span>} + </div> + </div> + ); + }; + + return ( + <div data-cli-form={row.verb} className="flex min-h-0 flex-1 flex-col"> + <div className="flex items-baseline gap-3 border-b border-seam px-3.5 py-2.5"> + <button type="button" data-cli-back="" onClick={onBack} className="font-mono text-[12px] text-muted hover:text-text"> + ← Commands + </button> + <span className="font-mono text-[14px] text-text">umtool {row.verb}</span> + <span className="ml-auto min-w-0 truncate text-[12px] text-muted-2">{row.summary}</span> + </div> + <form + className="min-h-0 flex-1 overflow-y-auto px-3.5 py-1.5" + onSubmit={(e) => { + e.preventDefault(); + void submit(); + }} + onKeyDown={(e) => { + if (e.key === "Enter" && (e.ctrlKey || e.metaKey)) { + e.preventDefault(); + void submit(); + } + }} + > + {row.args.length ? row.args.map(field) : <p className="py-2 text-[12.5px] text-text-2">No arguments.</p>} + </form> + <div className="border-t border-seam px-3.5 py-2"> + {line ? ( + <code data-cli-line="" className="block select-all break-all font-mono text-[11.5px] text-text-2"> + {line} + </code> + ) : ( + <p data-cli-invalid="" className="text-[12px] text-reject-text"> + {built.ok ? "" : built.error} + </p> + )} + <div className="mt-2 flex items-center gap-2"> + <button type="button" data-cli-run="" disabled={!built.ok || going} onClick={() => void submit()} className="rounded-[3px] bg-signal px-3 py-1 text-[12.5px] font-medium text-on-signal disabled:opacity-40"> + {row.queue ? "Queue it" : "Run"} + </button> + <button type="button" data-cli-copy="" disabled={!line} onClick={() => void copy()} className="rounded-[3px] border border-seam-2 px-3 py-1 text-[12.5px] text-text disabled:opacity-40"> + {copied ? "Copied" : "Copy as CLI"} + </button> + <span className="text-[11.5px] text-muted-2"> + {row.queue ? "renders: the durable queue runs it" : row.target === "draft" ? "writes the working draft (an undo point)" : row.target === "corpus" ? "not one project" : "a project's files"} + </span> + {run && ( + <span data-cli-state={run.state} className={cn("ml-auto font-mono text-[12px]", run.state === "done" ? "text-kept-text" : TERMINAL.has(run.state) ? "text-reject-text" : "text-muted")}> + {run.kind === "queued" ? `${run.qid} · ` : ""} + {run.state} + {run.exitCode !== null && run.state !== "done" ? ` (exit ${run.exitCode})` : ""} + </span> + )} + </div> + {asking && ( + <div data-cli-asking="" className="mt-2 flex flex-wrap items-center gap-2 rounded-[3px] border border-reject px-2 py-1.5"> + <span className="text-[12px] text-text">This has no undo.</span> + <button type="button" data-cli-confirm="" onClick={() => void submit(true)} className="rounded-[3px] bg-reject px-2.5 py-1 text-[12px] font-medium text-on-signal"> + Yes, {asking} + </button> + <button type="button" data-cli-cancel="" onClick={() => setAsking(null)} className="rounded-[3px] border border-seam-2 px-2.5 py-1 text-[12px] text-text"> + Not now + </button> + </div> + )} + {refused && ( + <p data-cli-refused="" className="mt-1.5 text-[12px] text-reject-text"> + {refused} + </p> + )} + {run && ( + <> + {run.kind === "queued" && !run.runnerUp && run.state === "queued" && ( + <p className="mt-1.5 text-[11.5px] text-muted-2">the queue's runner is not up in this app: the step waits (umtool queue ls)</p> + )} + {run.error && run.state !== "done" && <p className="mt-1.5 text-[12px] text-reject-text">{run.error}</p>} + <pre ref={logRef} data-cli-log="" className="mt-1.5 max-h-[22vh] overflow-auto whitespace-pre-wrap break-all rounded-[3px] bg-panel-2 px-2 py-1.5 font-mono text-[11px] leading-[1.45] text-text-2"> + {run.log.join("\n") || "…"} + </pre> + </> + )} + </div> + </div> + ); +} diff --git a/umtool/components/shell/JumpPalette.tsx b/umtool/components/shell/JumpPalette.tsx @@ -23,6 +23,7 @@ import { } from "@/lib/hrefs"; import { MODES } from "@/lib/types"; import { cn } from "@/lib/utils"; +import CommandForm, { type CliContext, type CliRun, type CliVerb } from "./CommandForm"; // --------------------------------------------------------------------------- // ⌘K: jump to any piece, place, tool or create action (plans/umtool-redesign.md, @@ -34,11 +35,24 @@ import { cn } from "@/lib/utils"; // The places, tools and create actions are fixed and listed here. The pieces // are fetched the first time it opens (GET /api/jump) and kept for the page. // The rail's "Jump to…" opens it with an event, `umtool:jump`. +// +// COMMANDS (lane palette, L8a): every umtool verb the registry offers as a +// form (lib/cli/verbs.mjs, GET /api/cli), matched on its verb and summary once +// something is typed (`>` first: commands only, all of them with nothing +// after it). Choosing one opens its form in place (CommandForm), the page's +// project and selection filled in -- GET /api/cli?path= says what the page is +// about, asked each time the palette opens (and reset first, so a quick pick never +// gets the last page's project: the form is keyed on the context and remounts when +// it arrives). What a form's Run started stays under Runs (nothing typed) for +// the page's life, so an Escape mid-run loses nothing. // --------------------------------------------------------------------------- export const JUMP_EVENT = "umtool:jump"; -type Item = { id: string; section: "Places" | "Tools" | "Create" | "Pieces"; label: string; hint: string; href: string }; +type Item = { id: string; section: "Runs" | "Places" | "Tools" | "Create" | "Pieces" | "Commands"; label: string; hint: string; href: string; verb?: string; run?: CliRun }; + +const NO_CONTEXT: CliContext = { project: null, clip: null, post: null, take: null }; +const clock = (ms: number) => new Date(ms).toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" }); type PieceRow = { id: string; title: string; href: string; kind: string; site: string | null; stage: string; lifecycle: string }; const FIXED: Item[] = [ @@ -73,6 +87,29 @@ const FIXED: Item[] = [ const words = (q: string) => q.toLowerCase().split(/\s+/).filter(Boolean); +/** Each letter of `w` in `s`, in order: "tlins" finds "timeline insert". */ +const subsequence = (w: string, s: string) => { + let i = 0; + for (const ch of s) if (ch === w[i]) i += 1; + return i === w.length; +}; + +/** How well a verb answers the words typed: 0 is not at all. */ +function commandScore(v: CliVerb, w: string[]): number { + const verb = v.verb.toLowerCase(); + const hay = `${verb} ${v.summary.toLowerCase()}`; + let score = 0; + for (const x of w) { + if (verb.startsWith(x)) score += 4; + else if (verb.split(" ").some((part) => part.startsWith(x))) score += 3; + else if (verb.includes(x)) score += 2; + else if (hay.includes(x)) score += 1; + else if (x.length >= 3 && subsequence(x, verb.replace(/[ -]/g, ""))) score += 0.5; + else return 0; + } + return score; +} + export default function JumpPalette() { const router = useRouter(); const dialog = useRef<HTMLDialogElement>(null); @@ -85,10 +122,18 @@ export default function JumpPalette() { const [error, setError] = useState<string | null>(null); // Set once the chord is listened for, so a test (or a script) can wait for it. const [ready, setReady] = useState(false); + const [verbs, setVerbs] = useState<CliVerb[] | null>(null); + const [ctx, setCtx] = useState<CliContext>(NO_CONTEXT); + const [form, setForm] = useState<CliVerb | null>(null); + const [resume, setResume] = useState<CliRun | null>(null); + const [runs, setRuns] = useState<CliRun[]>([]); const show = useCallback(() => { setQ(""); setAt(0); + setForm(null); + setResume(null); + setCtx(NO_CONTEXT); setOpen(true); }, []); @@ -139,7 +184,33 @@ export default function JumpPalette() { }; }, [open, pieces]); + // The verbs, and what this page is about, each time it opens (the page may have changed). + useEffect(() => { + if (!open) return; + let live = true; + const path = `${window.location.pathname}${window.location.search}`; + fetch(`/api/cli?path=${encodeURIComponent(path)}`, { cache: "no-store" }) + .then((r) => (r.ok ? r.json() : Promise.reject(new Error(`HTTP ${r.status}`)))) + .then((j: { verbs: CliVerb[]; context: CliContext }) => { + if (!live) return; + setVerbs(j.verbs); + setCtx(j.context); + }) + .catch(() => live && setVerbs((v) => v ?? [])); + return () => { + live = false; + }; + }, [open]); + const items = useMemo(() => { + const commandsOnly = q.trimStart().startsWith(">"); + const cw = words(commandsOnly ? q.trimStart().slice(1) : q); + const commands = (verbs ?? []) + .map((v) => ({ v, s: cw.length ? commandScore(v, cw) : 1 })) + .filter((x) => x.s > 0) + .sort((a, b) => b.s - a.s || a.v.verb.localeCompare(b.v.verb)) + .map(({ v }): Item => ({ id: `cmd:${v.verb}`, section: "Commands", label: v.verb, hint: v.summary, href: "", verb: v.verb })); + if (commandsOnly) return commands.slice(0, 80); const all: Item[] = [ ...FIXED, ...(pieces ?? []).map( @@ -153,7 +224,11 @@ export default function JumpPalette() { ), ]; const w = words(q); - if (!w.length) return all.filter((it) => it.section !== "Pieces").concat(all.filter((it) => it.section === "Pieces").slice(0, 8)); + const recent = runs.map( + (r): Item => ({ id: `run:${r.id}`, section: "Runs", label: r.verb, hint: `${r.kind === "queued" ? "queued " : ""}${r.id} · ${clock(r.at)}`, href: "", verb: r.verb, run: r }), + ); + if (!w.length) return [...recent, ...all.filter((it) => it.section !== "Pieces"), ...all.filter((it) => it.section === "Pieces").slice(0, 8)]; + const cmds = commands.slice(0, 12); const hay = (it: Item) => `${it.label} ${it.hint}`.toLowerCase(); const hits = all.filter((it) => w.every((x) => hay(it).includes(x))); // A label that starts with what was typed first, then the rest, each in @@ -162,8 +237,10 @@ export default function JumpPalette() { return [ ...hits.filter((it) => it.label.toLowerCase().startsWith(first)), ...hits.filter((it) => !it.label.toLowerCase().startsWith(first)), - ].slice(0, 60); - }, [q, pieces]); + ] + .slice(0, 60) + .concat(cmds); + }, [q, pieces, verbs, runs]); useEffect(() => { list.current?.querySelector<HTMLElement>(`[data-jump-index="${at}"]`)?.scrollIntoView({ block: "nearest" }); @@ -171,6 +248,14 @@ export default function JumpPalette() { const go = (it: Item | undefined) => { if (!it) return; + if (it.verb) { + const v = verbs?.find((x) => x.verb === it.verb); + if (v) { + setResume(it.run ?? null); + setForm(v); + } + return; + } setOpen(false); router.push(it.href); }; @@ -182,9 +267,30 @@ export default function JumpPalette() { data-ready={ready ? "" : undefined} aria-label="Jump to" onClose={() => setOpen(false)} - className="ui-dialog mx-auto mb-auto mt-[12vh] w-[min(640px,calc(100vw-32px))] rounded-[3px] border border-seam-2 bg-panel p-0 text-text shadow-2xl" + className={cn( + "ui-dialog mx-auto mb-auto mt-[12vh] rounded-[3px] border border-seam-2 bg-panel p-0 text-text shadow-2xl", + form ? "w-[min(780px,calc(100vw-32px))]" : "w-[min(640px,calc(100vw-32px))]", + )} > - {open && ( + {open && form && ( + <div className="flex h-[76vh] max-h-[76vh] flex-col"> + <CommandForm + key={`${form.verb}|${resume?.id ?? ""}|${ctx.project ?? ""}|${ctx.clip ?? ""}|${ctx.post ?? ""}|${ctx.take ?? ""}`} + row={form} + ctx={ctx} + resume={resume} + onStarted={(r) => { + setRuns((cur) => [r, ...cur.filter((x) => x.id !== r.id)].slice(0, 8)); + }} + onBack={() => { + setForm(null); + setResume(null); + setTimeout(() => input.current?.focus(), 0); + }} + /> + </div> + )} + {open && !form && ( <div className="flex max-h-[70vh] flex-col"> <div className="flex items-center gap-2 border-b border-seam px-3.5 py-2.5"> <span aria-hidden="true" className="font-mono text-muted-2"> @@ -199,7 +305,7 @@ export default function JumpPalette() { aria-controls="jump-list" aria-activedescendant={items[at] ? `jump-${at}` : undefined} aria-label="Jump to a piece, place, tool or create action" - placeholder="Jump to a piece, place, tool…" + placeholder="Jump to a piece, place, tool… or > a command" onChange={(e) => { setQ(e.target.value); setAt(0); @@ -239,7 +345,7 @@ export default function JumpPalette() { i === at && "bg-panel-2 text-text before:absolute before:inset-y-1 before:left-0 before:w-[3px] before:bg-signal before:content-['']", )} > - <span className="min-w-0 truncate">{it.label}</span> + <span className={cn("min-w-0 truncate", it.verb && "font-mono text-[12.5px]")}>{it.verb ? `umtool ${it.label}` : it.label}</span> <span className="ml-auto min-w-0 shrink truncate font-mono text-[11px] text-muted-2">{it.hint}</span> </div> </li> @@ -253,6 +359,9 @@ export default function JumpPalette() { <span> <kbd>enter</kbd> open </span> + <span> + <kbd>&gt;</kbd> commands + </span> {pieces === null && <span>reading pieces…</span>} {error && <span className="text-reject-text">{error}</span>} </div> diff --git a/umtool/docs/cli.md b/umtool/docs/cli.md @@ -12,6 +12,7 @@ It reads the **same** `lib/projects/*.mjs` the app does, so `umtool ls` and `/projects` cannot disagree about what a project is, and `umtool check` and the Inbox cannot disagree about what is wrong with one. +<!-- verbs:begin (generated by umtool/lib/cli/docs.mjs from lib/cli/verbs.mjs and groups.mjs -- edit those, not this) --> ## Commands | | | @@ -19,31 +20,39 @@ Inbox cannot disagree about what is wrong with one. | `ls [--kind --template --state --open --blocking --q --sort --json]` | the index, as text or JSON | | `show <project> [--json]` | one project: summary, the cut, per-clip status, decisions | | `check [<project>] [--json]` | **exit 1 on anything blocking** — including an `out/`, `clips/` or `share-*/` link whose drive is not there (`storage-unreachable`) | +| `links <project> [--json] [--fix]` | do the clip QRs open on their sites? `corpus.json` → the channel's manifest → `slugToPage` → the shard's record, one request at a time, shards from the cue cache; recorded in `out/links.json`, which `check` reads (`link-dead` blocking, `links-unverified`, `links-unchecked`); `--fix` rewrites a Twitch id the site serves as `v<id>`, and a Rumble folder id (the URL slug) as the embed id the site serves (the clip gets `siteVideo`); **exit 1** when a link is dead ([knobs.md](knobs.md#do-the-qr-links-open)). The same record dates each site's deploy: a cited video newer than it is `site-deploy-behind` ([knobs.md](knobs.md#the-sites-the-links-depend-on)) | +| `cast [ls] \| add <id> --name … --voice <engine:voice> [--handles a,b] [--speakers …] [--convert-engine e] [--convert-voice v] [--narrator] \| set <id> … \| rm <id> \| undo [--json]` | **THE CAST** (`<reports>/.umtool/cast.json`, [knobs.md](knobs.md#the-cast-each-characters-voice-in-every-project-and-the-voices-page)): the characters across projects and their STOCK voices, a layer under each project's voice map; one writer, an undo point a write | +| `cast project <project> [--json]` · `cast use <project> <character\|@handle> <voice> [--everywhere]` · `cast reread <project> <character> [--dry-run]` | a project's characters (each voice now, where it comes from, its stale reads), the voice for this project or everywhere, and the re-reads that asks for | +| `cast audition <character\|@handle> --voices a,b,… [--project <p>] [--text "…" \| --item <id> \| --line <n> \| --stock] [--no-score \| --score-only] [--json] [--progress ndjson]` | **AN AUDITION**: one line read by 2-6 stock voices through the editor's tts op, levelled to -20 LUFS in `<p>/narration/auditions/` (cached), scored for closeness to the character's real voice (`speakers.json`; TitaNet, local) | +| `speaker-check <project> [--clip <id> …] [--json] [--progress ndjson]` · `--set 'Name=<clip>,<channel>/<id>,channel:<slug>'` · `--remove <name>` · `--list` | which of the project's **named voices** (`speakers.json`) each clip is: TitaNet-small, local, against each voice's robust centroid → `<project>/speaker-check.json` (merged); the walk's **Speaker:** badge and **Check speaker** ([report-video.md](report-video.md#the-speaker-check-on-the-walk-which-of-several-voices)) | +| `quote-check <project> [--clips a,b] [--pad S] [--json]` · `quote-check <project> --status` | **is each clip's quote in the seconds it plays?** The cut ±15 s of the source the render would cut it from, transcribed by the editor (`pnpm ops transcribe`, words on — its transcription lane), the quote found in those words and in the cues: `ok`, `moved` (heard more than 0.5 s from where the cues have it), `not-found`; rows in `quote-check.json`, stale when the cut or the quote changes; `check` blocks on `moved`/`not-found` (`clip-quote-moved`, `clip-quote-missing`), a take refuses them, `prep --status` counts them ([knobs.md](knobs.md#the-quote-check-is-the-quote-where-the-clip-plays)) | +| `check-joins <project> --take <id> [--json] [--all] [--limit <n>]` | do a rendered take's **post joins carry on**: every boundary of its master where the next post item draws a post the one before showed, its planned join, the SSIM across it and the largest frame-to-frame step (read-only, ffmpeg) -- worst first ([report-video.md](report-video.md#thread-scenes-whole-threads-the-join-manual-threads-wide-attachments-context-media-link-visits-the-branch-map)) | +| `link-policy <project> [--via <site id \| https://…>] [--direct <slug,…>] [--clear] [--fix] [--json]` | the project's **link policy** (`provenance.linkPolicy`): cite via site X, these channels direct. With no flag, prints it and every clip whose QR breaks it; `--fix` rewrites each one that has a fix through the window writer; new clips are written by it. **Exit 1** when a clip still breaks it ([knobs.md](knobs.md#the-link-policy)) | +| `patch-markers <project> [<file>.patch.json] [--fix] [--json]` | take patches whose deck markers name a clip not in the cut (a take made with one is refused); `--fix` gives each the `after` of the cut's marker of the same label; **exit 1** when one is left ([knobs.md](knobs.md#take-patches-follow-a-removal)) | | `decisions [--json]` | the inbox | | `inbox [--all] [--json]` | the decisions grouped and ranked by piece (`a:<site>/<report>`, `p:<project>`): Your call, Review, Blocking, Notes, Open, Ready to finish, Quiet — one card per piece and kind, and how many sit hidden on parked or done pieces (`--all` lists them). Every decision, songs' and articles' included; runs `bin/inbox.ts` through tsx | +| `schedule list \| show <id> [--json]` | the recurring reports, read-only ([recurring.md](recurring.md)) | | `folders [--json]` · `kinds [--json]` | the tree, the registry | +| `link <project> <site>/<report>` · `link <project> --clear` | the manifest names the article it is the video of (settles `link-ambiguous`) | | `window <project> <clip> [--start S] [--end E] [--lock] [--lock-end] [--no-lock-end] [--note …]` | edit a window | | `window <project> <clip> --start S --end E --move-stamp first\|nearest\|<s>` · `--clear-stamp` · `--move-mute nearest` · `--clear-mute` | a window edit refused because a stamp's second (`claim.at`, a mark's `at`) or the mute mark would fall outside it, with the fix in the same write: the stamp to the first second that plays, the nearest, or `<s>`, or its `at` cleared; the mute mark to the nearest second, or cleared (never inside a gap). A refused `window` names these flags ([clip-bench.md](clip-bench.md#saving)) | | `window <project> <clip> --verdict confirmed\|incorrect [--correction T]` · `window <project> <clip> --reject <why> [--note T]` | what the walk said: `--reject` is the walk's **Reject ▾** kept in place (`not-matching`/`wrong-speaker`: incorrect, the note its correction; `irrelevant`/`repeats`/`weak`/`privacy`/`other`: rejected, the note its `rejectNote`); `umtool timeline <p> reject` takes it out ([report-video.md](report-video.md#verdict--what-the-walk-said)) | | `window <project> <clip> --walk-note T` · `--star` / `--no-star` · `--repeat-of <clip>` | what the walk said that is not a verdict: an editorial note (not a correction) and the ★ favourite, a trailer candidate (`trailer <project> --candidates [--json]` lists them as beats); a deliberate repeat ([knobs.md](knobs.md#a-clip)) | -| `tighten <project> [--json] [--all] [--no-measure]` · `tighten <project> --apply <clip>[,<clip>…]` | the Cut tab's **Propose tight windows**: each clip to its sentence (the sentences its cut touches, else the whole ones inside its window) and each edge into its pause (the build's measured silences and the gaps between the recording's timed words, ≤ 1 s, inside the cached window) — before → after with the seconds, the clips that would change (`--all`: every clip); prints only. `--apply` writes the named rows through the window writer (the token, the cite that follows the edge); a lock is kept (it is against `resolve-windows`, not a person) ([knobs.md](knobs.md#tighten-to-the-sentence-snap-to-a-pause)) | -| `links <project> [--json] [--fix]` | do the clip QRs open on their sites? `corpus.json` → the channel's manifest → `slugToPage` → the shard's record, one request at a time, shards from the cue cache; recorded in `out/links.json`, which `check` reads (`link-dead` blocking, `links-unverified`, `links-unchecked`); `--fix` rewrites a Twitch id the site serves as `v<id>`, and a Rumble folder id (the URL slug) as the embed id the site serves (the clip gets `siteVideo`); **exit 1** when a link is dead ([knobs.md](knobs.md#do-the-qr-links-open)). The same record dates each site's deploy: a cited video newer than it is `site-deploy-behind` ([knobs.md](knobs.md#the-sites-the-links-depend-on)) | -| `link-policy <project> [--via <site id \| https://…>] [--direct <slug,…>] [--clear] [--fix] [--json]` | the project's **link policy** (`provenance.linkPolicy`): cite via site X, these channels direct. With no flag, prints it and every clip whose QR breaks it; `--fix` rewrites each one that has a fix through the window writer; new clips are written by it. **Exit 1** when a clip still breaks it ([knobs.md](knobs.md#the-link-policy)) | -| `patch-markers <project> [<file>.patch.json] [--fix] [--json]` | take patches whose deck markers name a clip not in the cut (a take made with one is refused); `--fix` gives each the `after` of the cut's marker of the same label; **exit 1** when one is left ([knobs.md](knobs.md#take-patches-follow-a-removal)) | -| `quote-check <project> [--clips a,b] [--pad S] [--json]` · `quote-check <project> --status` | **is each clip's quote in the seconds it plays?** The cut ±15 s of the source the render would cut it from, transcribed by the editor (`pnpm ops transcribe`, words on — its transcription lane), the quote found in those words and in the cues: `ok`, `moved` (heard more than 0.5 s from where the cues have it), `not-found`; rows in `quote-check.json`, stale when the cut or the quote changes; `check` blocks on `moved`/`not-found` (`clip-quote-moved`, `clip-quote-missing`), a take refuses them, `prep --status` counts them ([knobs.md](knobs.md#the-quote-check-is-the-quote-where-the-clip-plays)) | | `window <project> <clip> --align` · `--quote-ruled` / `--no-quote-ruled` | the cut snapped to the quote as HEARD (0.15 s before its first word, 0.3 s after its last, the extent widened to hold it, `lockCut`); a person's ruling on the quote check (a take renders a ruled clip) | | `window <project> <clip> --take <take> …` | a **take's** clip (walk a take): the same fields, written into the take's patch (`takes/<take>/take.json`) with an undo point first; the project's manifest is untouched ([clip-bench.md](clip-bench.md#walking-a-take)) | -| `present <project> [--take <take> \| --cut] [--json] [--public] [--open] [--url <origin>]` | **present mode**: the cut as slides, navigated like a deck (`/projects/<p>/present`) — prints the address and every slide (its kind, id — a post's `<channel>/<id>`, a clip's id, `section-<n>`, `day-<YYYY-MM-DD>` — date, words and censor counts); `--json` the payload (each post's card as Play draws it and its censor data by kind, each clip's spans, the dividers); `--public` the payload a public page would carry (censored, no reveal data); `--open` opens it; `<address>#<slide id>` opens a slide ([knobs.md](knobs.md#present-mode-the-cut-as-slides-navigated-like-a-deck)) | | `walk <project> [--take <take>] [--all] [--json]` | the clip bench's **walk**: every clip in walk order with its window, verdict and whether a fetched file holds it, and (→) the ones the walk visits — fetched and needing a verdict; `--all` every fetched one; `--take` walks a take (a draft too); the bench's address to start at. The intro (`render.intro`) is listed first, watched, not judged (`intro`, `stops` in `--json`) | -| `intro <project> [key=value …] [--off] [--json]` · `intro <project> --take <take> --off\|--on` | **the intro** the cut opens on (`render.intro`): with no key, prints it as written, what the cut opens with (a `title-card`'s words resolved) and each version's on/off; `key=value` writes it through the look writer (`style` `seconds` 3.5–8 `mark` `ground` `sound` (`false` silent) `site` `title` `lines` (`a\|b`, ≤ 3) and the brand's keys; `key=` clears one; a new intro starts as `boot-dark`); `--off` takes it off the cut; `--take <t> --off` that version opens on no intro (its patch's `render.intro: null`), `--on` on the cut's again. **Exit 1** on a value the build refuses ([knobs.md](knobs.md#the-intro-played-and-edited)) | -| `link <project> <site>/<report>` · `link <project> --clear` | the manifest names the article it is the video of (settles `link-ambiguous`) | +| `present <project> [--take <take> \| --cut] [--json] [--public] [--open] [--url <origin>]` | **present mode**: the cut as slides, navigated like a deck (`/projects/<p>/present`) — prints the address and every slide (its kind, id — a post's `<channel>/<id>`, a clip's id, `section-<n>`, `day-<YYYY-MM-DD>` — date, words and censor counts); `--json` the payload (each post's card as Play draws it and its censor data by kind, each clip's spans, the dividers); `--public` the payload a public page would carry (censored, no reveal data); `--open` opens it; `<address>#<slide id>` opens a slide ([knobs.md](knobs.md#present-mode-the-cut-as-slides-navigated-like-a-deck)) | | `set <project> <clip> key=value …` | a clip's **knobs**: `claim.at` `claim.hold` `claim.stamp` `claim.count` `claim.label` (the first mark's, or `--mark <id>`'s), its **marks** `mark.add=<verdict>[@<sec>]` `mark.remove=<id>` `mark.verdict=<verdict>` `marks=<json>`, `audio.offset` `audio.gain` `audio.fadeIn` `audio.fadeOut`, its picture's **blur** `blur.on=true` `blur.caption=…` `blur.strength` `blur.from` `blur.to` (`blur.on=` clears it; [knobs.md](knobs.md#a-clips-picture-blurred)), its **effects** `fx.zoom=<json>` `fx.receipts=<json>` `fx.punch=…` `fx.quote` `fx.punchIn=<json>` `fx.speakers=<json>` (`fx=<json>` all of them, `fx=` clears them; a shot is a file in the project; [knobs.md](knobs.md#effects)); `key=` clears one ([knobs.md](knobs.md#marks)) | +| `intro <project> [key=value …] [--off] [--json]` · `intro <project> --take <take> --off\|--on` | **the intro** the cut opens on (`render.intro`): with no key, prints it as written, what the cut opens with (a `title-card`'s words resolved) and each version's on/off; `key=value` writes it through the look writer (`style` `seconds` 3.5–8 `mark` `ground` `sound` (`false` silent) `site` `title` `lines` (`a\|b`, ≤ 3) and the brand's keys; `key=` clears one; a new intro starts as `boot-dark`); `--off` takes it off the cut; `--take <t> --off` that version opens on no intro (its patch's `render.intro: null`), `--on` on the cut's again. **Exit 1** on a value the build refuses ([knobs.md](knobs.md#the-intro-played-and-edited)) | | `look <project> key=value … [--unset render.<key>]…` | the cut's **knobs**: `factcheck.stamp.*`, `factcheck.verdicts.<V>.stampLabel\|label\|color`, `deck.markers=<json>`, `deck.markerLayout`, `variants=<json>`, and the look's keys — `mode=basic\|deck` (the footage alone, [knobs.md](knobs.md#basic-output-the-footage-alone)) and `basic=<json>` (its fades) among them ([knobs.md](knobs.md)) **The deck on, legacy keys off** (`updateRenderKeys`, one write, an undo point `revisions/…auto-render-keys…` first): `chrome.layout=deck` turns the deck on (render.chrome created when the cut has none: engine hyperframes, an empty deck), `--unset render.<key>` (repeatable) drops a legacy render key -- only `rail` `chromeEngine` `railEngine` `chromeRegions` `claimSchedule` `wordmark` `title` `finale` `cut`; the deck beside the old rail is refused in the build's words unless the same command drops it; deck.* keys in the same command land after the chrome exists. Another key named: **exit 2** | | `variants <project> [--take <t>] [--list] [--json]` | **Make variants**: the encode ladder of the build (or of a take's); `--list` what was made and the build's sync report, each clip's lag (past a frame flagged) ([knobs.md](knobs.md)) | +| `corrections <project>` | what the report got wrong (the clip bench's sixth field) and the walk's coverage, as markdown for the next pass | | `build <project> [--preset preview\|fast\|final] [--only ID]` | **prints** the chain | | `build <project> --run [--url URL] [--replace] [--preset P] [--only ID] [--skip-fetch]` | **runs** it as the app's build job (POST `/api/report/build` on `--url`, else `UMTOOL_URL`, else `http://localhost:3050`), prints its log as it grows, **Ctrl-C** cancels the job (twice leaves it running); `--replace` stamps a deliverable newer than the manifest aside; exit 1 unless the job is done (release 36) | +| `chain <article> <n> [--from <step>] [--dry] [--final] [--draft-all [--model M]]` | an iteration to a video: the Iterations tab's **Make the video** (`--draft-all`: Draft everything) | | `index [--rebuild] [--prune] [--since MS] [--json]` | the cache | | `new <slug> [--from <report.md>\|<share URL>\|<channel>/<id>] [--site-origin URL] [--seed chapters\|frames [--target S]]` · `new <folder>/<slug> …` · `new <slug> --folder <folder> …` · `new <slug> --seed phrase --phrase <regex> --channels a,b [--prefer <slug>] [--exclude <regex>] [--max N]` · `new <slug> --seed reactions --from <channel>/<id> [--target S] [--laugh-min X] [--scope FROM:TO\|auto [--segment sN]] [--no-analyze]` | scaffold; `<folder>/<slug>` (or `--folder`) makes it in a folder of the reports tree — its id `<folder>/<slug>`, routed `/projects/<folder>/<slug>` (a spin-off beside its parent); a folder that is itself a project, the reserved `at`, or one past the walk's four levels is refused | +| `new <slug> --from-posts <channel> [--channel <more>…] [--since D] [--until D] [--own] [--with-media] [--replies …] [--order …] [--limit N]` | a **posts reel**: the scaffold with the deck on (no `siteOrigin`: each post's QR opens the post, `deck.qr.links: "original"`), then `posts reel` with the same filters | | `doctor [--json]` | which tools are on this machine and where the roots are; **exit 1** if the report pipeline is missing one, or `UMTOOL_MEDIA_DIR` is set and not there | | `storage [<project>] [--json]` | where each project's `out/` lives: dir, link, DANGLING, none — and a report's deliverables (`clips/`, `share-*/`) and its switch | | `storage move-out\|move-back <project>\|--all [--dry-run] [--json]` | `out/` to the media root (a link left behind) and back — copied, mirrored, verified first; run when nothing is building | @@ -53,11 +62,10 @@ Inbox cannot disagree about what is wrong with one. | `export <project> --format toc-bbcode\|toc-markdown\|description\|chapters [--variant V] [--first TITLE]` | the posting artifacts, from the build's chapter offsets. A deck with markers: `chapters` are its top-level sections (subsections left out) at the second each section's first segment starts, YouTube's rules kept (0:00 first, each ≥ 10 s, at least three; what was merged is said on stderr); the opening is titled `deck.sectionTitle.first`, or `--first TITLE`, else the first section takes 0:00 | | `export <project> <clip> [--take T] [--open] [--json]` · `--context N` · `--raw [--from S --to S]` · `--fetch` · `--progress ndjson` | **one clip, clean** (no deck) into `<project>/exports/` as `<clip>[-ctx<N>\|-raw[-<from>-<to>]]-<date>-<words>.mp4`: as the cut plays it (its edges, gaps out, its mute); `--context N` what the cut plays ± N s (1–120), as recorded; `--raw` the fetched window, or `--from/--to` a span (the full exchange), as recorded. In the heavy slot (a 600 MB estimate). `--fetch` asks the editor first (fetch-via-editor, the bench's path) for what a context or raw export needs that is not on disk; without it nothing is fetched. `--progress ndjson`: one `export` event (the app's export job reads it) ([knobs.md](knobs.md#export-one-clip)) | | `check-sources [<project>…]` | **prints** the re-check chain; with no args, the never-checked and >30 d projects | -| `corrections <project>` | what the report got wrong (the clip bench's sixth field) and the walk's coverage, as markdown for the next pass | -| `chain <article> <n> [--from <step>] [--dry] [--final] [--draft-all [--model M]]` | an iteration to a video: the Iterations tab's **Make the video** (`--draft-all`: Draft everything) | -| `refresh <article> [--iteration N] [--no-fetch] [--yes] [--json]` · `refresh --check [<article>] [--force]` | the refresh's plan, `--yes` starts it; the daily check now ([refresh.md](refresh.md)) | -| `schedule list \| show <id> [--json]` | the recurring reports, read-only ([recurring.md](recurring.md)) | | `notes …` | operator notes: list, read, reply, resolve ([notes.md](notes.md)) | +| `modules list [--json]` · `modules apply <project> [--config FILE] [--dry-run] [--json]` · `modules apply <project> [--config FILE] --take <id> [--label L] [--at S --dur S \| --full] [--quick] [--force] [--from TAKE] [--keep-frames] [--patch-out FILE]` | the **video modules** (release 39): `list` every module, its kind, slot and where its settings live; `apply` maps the project's `module-config.json` (the modules a video wants, in MODULES-DESIGN's vocabulary) into the manifest's homes (`report-to-video/modules/config-loader.mjs`) — the preset, the deck's subtitle and QR, the counter's series and each clip's marks, the stamps, the rail's markers, the chapters, the pairs, the status ledger, the intro, the finale — and lists every field with no home, by path. Without `--take` the manifest is rewritten through `replaceManifest` (a snapshot first); with `--take` it is that take's patch (`takes/<id>.modules-patch.json`, or `--patch-out`) and the take is made from it as `take` makes one, the manifest untouched. **Exit 1** when the result would not build (the build's sentences) ([knobs.md](knobs.md#look-presets)) | +| `preset list [--json]` · `preset show <name> [--json]` · `preset save <name> --from <project> [--description D] [--force]` · `preset apply <name\|none> <project> [--replace] [--json]` | the **look presets** (`umtool/presets/<name>.json`, or `UMTOOL_PRESETS_DIR`; built in: `plain-deck` `huck-deck` `ember-deck` `archive-catalog` `basic`): a render block a manifest stands on (`"preset": "<name>"`), laid under it — preset → manifest → style → take patch. `save` keeps a project's look and leaves its content out; `apply` names the preset on the cut through `updatePreset` (nothing copied in), refused when the cut over it would not build (a basic cut's chrome is not checked); `--replace` also clears the manifest's own value of every key the preset sets, after an undo point (`revisions/…-auto-before-preset-replace`), and prints what went ([knobs.md](knobs.md#look-presets)) | +| `lint <project> [--take <take>] [--variant sourced\|full] [--final] [--json]` | **the manifest lint** (`report-to-video/lint.mjs`, what a build runs before it renders a frame) from umtool: the project's manifest, or with `--take` the take's (its patches applied, written beside the project's manifest for the lint as its render's is, then removed) -- plus the **files its post items name**: a picked read, an attachment or a context post's media not in the project is an ERROR, another kept take a warning. Run it after an import and before queueing the render. `--json`: `{ok, entries, errors, warnings}`. **Exit 0 no error · 1 an error · 2 usage** | | `take <project> --id <id> --label L [--group G] [--kind similar\|different] [--summary S] [--style NAME] [--patch FILE \| --patch-json JSON \| --set path=value …] [--effect NAME] [--at S --dur S \| --full] [--quick] [--force] [--progress ndjson]` | one **take**: the manifest with a montage style's patch, then an overlay effect's (`--effect`, release 35), then the take's own, rendered into `takes/<id>/` (the Takes page's New take); `--id <id> --rebuild` makes one again from its own `take.json` ([report-video.md](report-video.md#making-takes)) | | `take <project> --id <id> --label L [--patch F \| …] --draft` (`--no-render`) · `take <project> --id <id> [--full \| --at S --dur S]` · `take <project> --id <id> --rebuild [--full \| --at S --dur S]` · `take <project> --id <id> --promote [--anyway] [--json]` | a **draft** take: recorded with nothing rendered, to be walked first; a draft named with no patch flags is rendered from its stored (walked) patch, and `--rebuild` takes a window flag; **make it the cut**: the take's patch applied to the manifest now, one undo point (`revisions/…-auto-before-promote-take`), refused (exit 1) when its timeline would replace a cut that changed since, until `--anyway` ([report-video.md](report-video.md#walking-a-take-drafts-edits-into-the-take-and-making-it-the-cut)) | | `take <project> --id <id> … --uncensored` · build-video `--uncensored` | the **uncensored cut** ([knobs.md](knobs.md#the-slur-filter-slurs-masked-in-what-is-published-off-for-the-uncensored-cut)): the same cut with the post items' slur filter off -- `render.posts.slurs.on: false` in the take's patch (a `--rebuild` keeps it; a censored take is not rebuilt uncensored, **exit 2**: make a take of its own), its label gains "(uncensored)", take.json's `slurs` records `censored` or `uncensored`. The redaction of private words and censored attachments stay on | @@ -65,8 +73,11 @@ Inbox cannot disagree about what is wrong with one. | `take <project> --id <id> --preview [--from <take>] [--at S --dur S \| --full] [--priority] [--json]` | the take's **preview**: the take as stored (a draft too, from its walked patch) composed exactly as its render is -- the same 1920×1080 layout, segments, chrome frames and sound -- with only its final picture encoded smaller and faster (`render.preview`: 1280×720, x264 veryfast, crf 26) into `takes/<id>/out/<slug>.preview.mp4`; its build, schedule and record (`render.json`, `render.log`) in `takes/<id>/out/preview/`. The full render (`preview.mp4`, `out/<slug>.mp4`, `out/sourced/`, `take.json`, `render.json`) is never touched. Reuses this take's own full render, and `--from`'s full render and preview ([report-video.md](report-video.md#fast-feedback-preview-and-changes-renders), [knobs.md](knobs.md#fast-feedback-a-preview-and-a-reel-of-the-changes)) | | `take <project> --id <id> --changes [--from <take>] [--pad 3] [--no-preview] [--priority] [--json]` | the take's **changes reel**: only what changed against `--from` (default: the take's own `from`, or the take a draft was made from) -- each added, re-read, re-picked, re-voiced, trimmed, held, fx'd, … item with a neighbour either side, rendered in one build (`takes/<id>/out/changes/`), cut to the item ± `--pad` s, a label burned in (`21:19 · p-2116831815466193102 · re-voiced`: its time in the FULL cut), joined into `takes/<id>/out/<slug>.changes.mp4`; a removed item shows as the join it leaves. `takes/<id>/changes.json` lists the pieces with their full-cut times and how exact they are (`times.basis`: `measured` -- the base's measured schedule plus the changed items' measured lengths -- or `estimate`). Preview quality unless `--no-preview`. Nothing changed: no reel, and the list says so | | `take <project> --id <id> --import-item <project>:<item>[,<item>…] [--import-item …] [--after <entry> \| --before <entry>] [--as <id>] [--dry-run] [--json]` | **items of another project into a take** (`takeImport.mjs`): each entry CLONED from the source's manifest as it is now (its card, context, knobs, narration with its takes and its pick) into the take's timeline -- one write, an undo point of the take's (`timeline <p> --take <id> undo`); the files it names (narration takes and their `take-<n>.*` sidecars, the parts' cache files, attachments, a context post's media, the picture of each author it draws that the take lacks, added to the take's `postAvatars`) **hard-linked** into this project's dir at the same path, so the render and the lint find them (copied across filesystems; the same file already there is left; ANOTHER file at the path: linked under `imports/<source>/<path>` and the clone names that). The source project and this project's manifest are only read. **Placed** `--after`/`--before` an entry of the take (several items in the order named, one after another), else by the post's date when the take's posts are in date order, else at the end. **Again**: updated in place from the source (moved only with `--after`/`--before`), `unchanged` with no write when nothing differs. `--as`: one item under another id (a second copy). `--dry-run`: the plan and the placement, nothing linked or written. `--json`: `items[] {id, action added\|updated\|unchanged\|moved, at {index, after, before}, narration {takes, pick, file}, files[], avatars[]}`, `revision`. Refused while the take renders. **Exit 0 · 1 refused (no such item, take or entry; a link out of the project) · 2 usage** | -| `lint <project> [--take <take>] [--variant sourced\|full] [--final] [--json]` | **the manifest lint** (`report-to-video/lint.mjs`, what a build runs before it renders a frame) from umtool: the project's manifest, or with `--take` the take's (its patches applied, written beside the project's manifest for the lint as its render's is, then removed) -- plus the **files its post items name**: a picked read, an attachment or a context post's media not in the project is an ERROR, another kept take a warning. Run it after an import and before queueing the render. `--json`: `{ok, entries, errors, warnings}`. **Exit 0 no error · 1 an error · 2 usage** | | `take … --priority` · `takes make … --priority` · `render-mode on [--for 90m] [--note T] [--json \| --print-token]` · `render-mode on [--for 90m] [--note T] [--print-token] -- <cmd …>` · `render-mode off [--force] [--json]` · `render-mode status [--json]` | **render mode**: a render the operator waits for gets the machine. `--priority` turns it on for the take's (or the batch's) lifetime — on at the start, off at the end, on a failure and on a signal; the Takes page's **Give renders the machine** is the same flag. While it is on, every other heavy job (e2e suites, `next build`s, the publish stages, other renders) waits at the heavy slot's door (`queue-lock: held for a render (…) — waiting`), the render runs on the floor 4000 MB and the cap 10240 MB, and the editor's transcription and download lanes are held through its ops (`lane`; only the ones not already held, and only those are released at off). `render-mode on` is a window (default 2h) for a chain of renders: every `umtool take` started in it renders in it, another command joins with the `RENDER_PRIORITY_TOKEN` it prints (`--print-token`: the token alone on stdout, the rest on stderr). **`on … -- <cmd …>` is the form for a script**: the command is spawned with the token in its environment, the hold is the command's pid, and it is released when the command exits — done, failed, or umtool signalled (the signal is passed on); umtool exits with the command's code, and inside a manual window the command joins it. A bare `on` in a script leaves the window behind (the chain trap). `off` ends it (a running take's hold only with `--force`, else it ends with the take); `status` says what holds it and releases a stale hold's lanes. A hold whose process is gone or whose window is over is no hold. Needs WORKER_TOKEN and the editor at ARCHILYZER_EDITOR_URL for the lanes; without them it still holds the door. **Exit 1** when it is already on, or a lane could not be released ([report-video.md](report-video.md#render-mode-giving-a-render-the-machine); WORKTREES.md, "Render mode") | +| `take status <project> [--id <take>] [--json] [--log] [--tail N]` | a take's **render record** (`takes/<take>/render.json`, written by every render whoever started it — a terminal, the Takes page, the queue): `state` (`running`, `waiting` at the heavy slot, `done`, `failed`, `cancelled`; `queued` or `blocked` while a queue step waits to render it), `stage` and a rough `percent`, the `error` (the first error line, not a bare "exited 1") and the log's last 40 lines (`tail`), on done the `mp4` and its measured `seconds`; `--log` prints the FULL `takes/<take>/render.log`. A "running" whose process is gone reads **failed** ("the render process is gone"); a done whose mp4 is missing or 0 bytes reads **failed**. **Exit 0 done · 3 queued, waiting or running · 1 failed, cancelled, blocked or none.** Without `--id`: every take with a record, the newest's exit ([queue and poll](#queue-and-poll-instead-of-scripting)); and its fast-feedback renders beside it, `preview` and `changes` (each one's state, mp4, seconds, log; a changes reel's piece count, its base and its list), a queued `--preview`/`--changes` step said as such -- never as the take's own render | +| `queue add [--after <qid>\|last] [--label T] [--timeout <minutes>] [--json] -- <umtool subcommand argv…>` | a **step** of the durable queue: the argv of a umtool command, one word per argument (no shell), stored under `<reports root>/.umtool-queue/` and run by the **umtool app** (its systemd unit), one step at a time, in order — so it survives the session that queued it, an app restart and a ship. Prints the qid (`q<N>`) alone on stdout. `--after` waits for that step to be **done**; when it fails or is cancelled this one is **blocked** (and so is whatever waits on it). `--timeout`: the step's limit (default 720 minutes). A step does not start while the app's own job runner is busy (a Takes-page job), and a heavy step still takes the machine's heavy slot and render mode by itself | +| `queue ls [--all] [--json]` · `queue status <qid> [--json]` · `queue wait <qid> [--timeout <s>]` · `queue log <qid> [--tail N]` · `queue cancel <qid>` · `queue retry <qid>` | the queue: `ls` the runner (is the app running it) and the steps not finished or finished in the last 24 h; `status` one step (**exit 0 done · 3 queued or running · 1 failed, blocked or cancelled**); `wait` the same after up to `<s>` seconds (default 90); `log` its FULL log (`logs/<qid>.log`; earlier attempts kept as `<qid>.<n>.log`); `cancel` a queued or blocked step at once, a running one stopped (its process group); `retry` a failed or cancelled step back in the queue with every step blocked behind it. A step that was running when the app died reads **failed** ("the step's process is gone"), its log kept — it is never re-run on its own | +| `jobs [--json]` | every running and recent **take render** across projects (their records), every queue step not finished or finished in the last 24 h, and the umtool app's own jobs (`GET /api/jobs` at `--url` / `UMTOOL_URL`, when it answers). The page is **/jobs** (the rail's *Running* links it) | | `takes make <project> [--recipe FILE] [--only ID,ID] [--force]` · `takes make <project> --all-styles [--group G] [--at S --dur S \| --full]` | a recipe's takes, one at a time (default `takes/recipe.json`); every montage style, one take each (Make all styles); **exit 1** if any failed | | `takes styles [--json]` · `takes effects <project> [--json]` · `takes pick <project> <take> [--anyway] [--pin \| --unpin] [--json]` | the montage styles; the overlay effects the cut offers (`render.chrome.fx` presets: the Takes page's **Effect** list); **Use this take** — refused (exit 1) when the project changed since the take was made, until `--anyway`; `--pin` keeps the pick when newer takes are built (each whole-cut take of the manifest is otherwise its group's pick once built), `--unpin` lets go ([report-video.md](report-video.md#takes-alternative-renders-judged-side-by-side)) | | `takes ls <project> [--json]` · `takes relabel <project> <take> <label…>` · `takes supersede <project> <take> [--by <take>]` · `takes supersede <project> <take> --clear` · `takes delete <project> <take> [--dry-run] [--force]` | **take housekeeping** (the Takes page's ✎, **Mark superseded**, **Delete take**): first the working cut's line (`Latest: draft-22 · 28:03 · +N edits since`, and the edits in words; `--json`: `working`), then the takes with latest / picked (pinned) / superseded / RENDERING; a label fixed in `take.json` (an undo point of the take's own); a take folded away as superseded (verdicts.json, nothing deleted); a take deleted. Relabel and delete are refused (**exit 1**) while the take renders or a live render is made from it ([knobs.md](knobs.md#takes-relabel-supersede-cancel-delete-fork-as-variant-compare)) | @@ -74,6 +85,7 @@ Inbox cannot disagree about what is wrong with one. | `takes cancel <project> <take> [--json]` · `takes fork <project> <take> [--name N] [--json]` · `takes compare <project> <a> <b> [--json]` | **take housekeeping, the rest**: **Cancel render** (asked of the process rendering it, which stops its render's process group, marks the take cancelled and lets render mode go; exit 1 when it has not stopped); **Fork as variant** (a project beside this one, default `v-<take>`: the take's manifest, `variant.json`, the parent's media and assets linked, the take in it); two takes **side by side** (`<take>` or `<project>:<take>`: the facts, the cut's changes A → B, the look's differences) ([knobs.md](knobs.md#takes-relabel-supersede-cancel-delete-fork-as-variant-compare)) | | `trailer <project> --take <t> (--beats FILE \| --beats-json JSON) [--intro] [--finale S] [--xfade 0.3] [--no-snap] [--out NAME] [--dry-run] [--json]` | a **trailer cut from the take's finished master**: spans of the master's own frames (the deck shows the whole timeline), clip beats in source seconds mapped by the take's build records, each clip beat's end moved forward into the next pause (through its sentence when one ends within 1 s) and its start back into the one before, so the crossfade lands in quiet, each move said (`--no-snap`: the edges as written), crossfaded, the take's encode, in the heavy slot; writes `takes/<t>/out/<slug>.trailer.mp4` and `.trailer.json`; **exit 1** on a refusal ([report-video.md](report-video.md#trailer-from-the-master)) · `--reel <name> [--take <t>]`: a **beat reel** -- its own beats file (`promo/<name>-beats.json`), crossfade, intro (one rendered for the reel when the master has none, or the reel's own) and outro card (the title, the call to action, an image, the site's name; faded in from the last beat, held to the end), written to `<slug>.<name>.mp4`; no `--take`: its pinned take, else the one it was last cut from, else the latest finished master ([report-video.md](report-video.md#beat-reels)) | | `trailer-beats <project> [ls] [--json]` · `add <clip> [<from>-<to>] [--at N] [--label L]` · `add-raw <at> <dur>` · `set <n> <from>-<to>` · `remove <n>` · `move <n> --to <m>` · `order` · `limit <s\|m:ss\|x\|instagram\|shorts\|tiktok>` · `xfade <s>` · `intro on\|off\|'<render.intro JSON>'` · `outro on\|off\|none\|'{title,text,image,seconds}'` · `candidates [--add]` · `verdict <n> confirmed\|note\|clear` · `title <text>\|none` · `take <t>\|none` · `undo` · `reels [--json]` · `new-reel <name> [--from <reel>] [--title T]` · `gap <n> add <from>-<to>\|remove <s>\|clear` · `status [--take <t>] [--json]` · `anchor [<n>…] --take <t>` · `clamp <n>` · `repoint <n> <clip>` · `history [--json]` · `--take <t>` on an edit · `--reel <name>` on any | **the trailer's beats** (`promo/trailer-beats.json`, the Trailer page's file, what `trailer --beats` reads) or another **beat reel's** (`--reel`: `promo/<name>-beats.json`): each beat's length, the running length against the platform limit (X 2:20 by default), beats outside their clip's window, the cut's order, the walk's ★ clips; the reel's own intro and its outro card (`ls`: `· outro 3.5 s`, counted in the length); every write an undo point and a history entry; a beat's gaps (two moments of one clip as one beat of jump cuts); each beat read against the take now -- what it was cut against, what changed (`status`), and the fixes ([knobs.md](knobs.md#the-trailers-beats), [reels track their source](knobs.md#reels-track-their-source)) | +| `tighten <project> [--json] [--all] [--no-measure]` · `tighten <project> --apply <clip>[,<clip>…]` | the Cut tab's **Propose tight windows**: each clip to its sentence (the sentences its cut touches, else the whole ones inside its window) and each edge into its pause (the build's measured silences and the gaps between the recording's timed words, ≤ 1 s, inside the cached window) — before → after with the seconds, the clips that would change (`--all`: every clip); prints only. `--apply` writes the named rows through the window writer (the token, the cite that follows the edge); a lock is kept (it is against `resolve-windows`, not a person) ([knobs.md](knobs.md#tighten-to-the-sentence-snap-to-a-pause)) | | `ledger <project> [ls] [--scope S] [--population P] [--json]` · `ledger <project> add <id> --date D --scope S --population P [--value V] --scopeBasis "…" [--<key> V …] [--row '{…}']` · `ledger <project> set <id> --<key> V … [--unset k,k]` · `ledger <project> rm <id>` | a **measure ledger's rows** (`ledgerSchema.kind "measure"`), the only writer of them: each row is checked against the schema -- a track, a form (and the promise forms `promise` / `promise_check`), a number in its unit or a declared regime with an event, the six adjudication fields (a new row defaults `scopeConfidence` read, `valueKind` uttered, `flags` []; `--scopeBasis` is never defaulted), the declared fields, and the instruments' own keys: `run` (a loss claim's run), `retro` (a loss told in the past with no `asOf`: off the odometer), `promise`, `kept`, `due`, `speaker` (another party's key: her rows move none of his numbers), `paidOn`, `outcome` (a `promise_outcome`'s: kept, refunded, withdrawn); the promise forms are `promise`, `promise_check`, `promise_claim`, `promise_outcome`. `rm` refuses a row an entry pins or another row names ([knobs.md](knobs.md#the-measure-slice-the-weight-instruments)) | | `measure <project> [--take <t>] [--scopes a,b] [--scale MIN-MAX] [--as-of YYYY-MM-DD] [--json]` | the **measure slice** the instruments draw from (`render.chrome.deck.measure`; the flags override it): each row in scope the cut shows at the cut second its figure is said, the hidden rows, and the totals -- the odometer's runs, NET, the goals, the diets, the promises. The take's built `schedule.json` with `--take`, else an estimate; `--json` prints the slice. Reads only ([knobs.md](knobs.md#the-measure-slice-the-weight-instruments)) | | `rulings <project> [--json]` · `rulings <project> import [--dry-run] [--json]` · `rulings <project> set <clip\|key> keep\|cut\|not-him\|read-aloud [--reason R] [--match M]` · `rulings <project> clear <clip\|key>` | a montage's **clip rulings** (`montage-rulings.json`, the clip deck's): each clip and its ruling and the next render's kept clips; the earlier rulings in the seed's `edits.json`, once; one ruling set or cleared. A render leaves out every clip ruled cut, not-him or read-aloud ([report-video.md](report-video.md#ruling-the-clips)) | @@ -83,15 +95,19 @@ Inbox cannot disagree about what is wrong with one. | `fallback <project> --dry-run [--json]` · `fallback <project> [--clip <id> …] [--json]` · `fallback <project> --restore <clipId>` | **stand-ins** (the clip deck's **Use stand-in** / **Restore**): a montage clip whose window a fetch run says the editor refused, and is not on disk, switched to its phrase-scan instance's first public alternate (YouTube, then Odysee / cornbreadman, then the rest) — recorded on the clip as `fallbackFrom`, its ruling and voice-match row moved with it; `--restore` puts it back. An older `phrase-scan.json` with no `alternates` is scanned again. **Exit 1** when a named clip has no stand-in | | `phrases "<phrase>" ["<phrase>" …] --channels a,b [--prefer c] [--exclude RE] [--words \| --regex] [--samples N] [--no-cache] [--json \| --full]` | the phrase finder's search ([tools.md](tools.md#the-phrase-finder-toolsphrases)): every phrase in one pass, each with its count once folded, by year, the preferred channel's share or Rumble's, speaker changes, sample contexts. Plain words become a tolerant pattern unless the phrase holds a regular expression's characters. `--json` the numbers, `--full` every instance; `--spec FILE --out FILE --progress` is the page's job form. **Exit 1** on a bad phrase | | `voice-match <project> [--reference auto\|rulings\|recordings] [--reference-video <channel>/<id> …] [--reference-channel <slug> …] [--instances FILE] [--span phrase\|cut] [--pad S] [--likely X --unlikely Y] [--out FILE] [--dry] [--json] [--progress ndjson]` | who is speaking, per montage clip: a local speaker-similarity score (TitaNet-small) against the host's voice → `<project>/voice-match.json` (the Cut tab's **Score the voices**); `--instances` also scores a phrase scan's instances not in the manifest; `--dry` prints the plan ([report-video.md](report-video.md#who-is-speaking-the-voice-match)) | -| `speaker-check <project> [--clip <id> …] [--json] [--progress ndjson]` · `--set 'Name=<clip>,<channel>/<id>,channel:<slug>'` · `--remove <name>` · `--list` | which of the project's **named voices** (`speakers.json`) each clip is: TitaNet-small, local, against each voice's robust centroid → `<project>/speaker-check.json` (merged); the walk's **Speaker:** badge and **Check speaker** ([report-video.md](report-video.md#the-speaker-check-on-the-walk-which-of-several-voices)) | -| `check-joins <project> --take <id> [--json] [--all] [--limit <n>]` | do a rendered take's **post joins carry on**: every boundary of its master where the next post item draws a post the one before showed, its planned join, the SSIM across it and the largest frame-to-frame step (read-only, ffmpeg) -- worst first ([report-video.md](report-video.md#thread-scenes-whole-threads-the-join-manual-threads-wide-attachments-context-media-link-visits-the-branch-map)) | | `clips analyze <project> [--from <channel>/<id>] [--rescan] [--no-laughs] [--no-voices] [params] [--words FILE] [--progress ndjson] [--json]` · `clips propose <project> [--from <channel>/<id>] [--host N] [params] [--words FILE] [--dry] [--json]` · `clips show <project> [--json]` · `clips segments <project> [--json]` | the **clip finder** on a long recording ([report-video.md](report-video.md#highlights-the-clip-finder)): `analyze` runs the laugh scan (CED-mini) and a voice centroid per speaker on the recording's sound (cached in `<project>/scans/`), then proposes; `propose` proposes again from what is there (after a role flip, a param change, new words); `show` prints the speakers, laughs and the cut. Params `--target S` (600) `--laugh-min X` (0.25) `--merge-gap S` (6) `--setup-max S` (20) `--clip-max S` (75) and the scope `--scope FROM:TO` (either side may be empty; `all` clears it) or `--from S --to S` with numbers (a `--from` that is a `<channel>/<id>` names the recording), kept in `reactions.json`; `--host N` is your word on the host, kept. `--keep-cut` proposes without touching the cut (nothing moved, removed or added; the proposals are listed). **`--scope auto`** reads the narrated video auto-scope finds in the speaker turns (`--segment sN` names one, else the longest); `segments` lists them. A chat replay beside the recording (`live_chat.cues.json`) adds chat-burst moments and the log names the chat's lag. A channel on no site gets each clip linked to its platform page (`citeUrl`). A clip you edited, ruled, locked or added is never moved. **Exit 2** with no `diarization.json` (the message names the `archilyzer diarize backfill` to run) | +| `refresh <article> [--iteration N] [--no-fetch] [--yes] [--json]` · `refresh --check [<article>] [--force]` | the refresh's plan, `--yes` starts it; the daily check now ([refresh.md](refresh.md)) | +| `clip <channel>/<video>@<start>-<end> [--snap words] [--title T] [--site <id>] [--folder F] [--json] [--progress ndjson]` | **quick clip**: a basic-mode project (`quick-clips/<slug>`, the footage alone), its window asked of the editor (fetch-windows, followed to its end; Rumble fetched whole), `--snap words` its edges snapped to the words heard (the editor's transcribe op), rendered as the take `clip` (`take <p> --id clip --full`: the heavy slot), then the mp4's path and the share line. `--json`: `{project, output, share: {platform, archive, text}, snapped?}`; `--progress ndjson`: events, the last `quick-clip` (the app's `POST /api/report/quick-clip` job). **Exit 0 · 1 failed (the editor, the render) · 2 usage** ([knobs.md](knobs.md#basic-output-the-footage-alone)) | +| `share <project> [<clip>] [--take <t>] [--site <id>] [--json]` | a clip's **share line** (the clip named, else the first): its platform page at the first second it plays and its archive moment, a Rumble folder id as the embed id the archive serves — the twin of **Copy share line** (`GET /api/report/share-line`). `--json`: `{clip, seconds, platform, archive, text}` | | `timeline <project> [ls] [--json]` · `timeline <project> insert --after <id\|-> <channel>/<video>@<start>-<end> [--id ID] [--section N] [--lock] [--lock-end] [--title T] [--stream-title T] [--date YYYY-MM-DD] [--quote Q] [--cite S] [--cite-url U]` · `timeline <project> move <id> --to <index>` · `place <id>… --before <id\|-> [--section N]` · `remove <id>` · `reject <id> <why> [--note T]` · `wrong-speaker <id> [--correction T]` · `duplicate <id>` (`--at <index>` names one of an id's twins) · `post <json\|@file>` · `post-remove <id>` · `teaser <id> <patch-json\|@file>` · `undo` | the **structure** of the cut (the Cut tab's timeline, the On-screen section's teasers and posts) through the writers `POST /api/report/timeline` runs: `ls` prints index, id, type, video, start–end, date and title (`--json` adds the token and the posts); an insert's attribution is a second write through `window`'s writer, its date checked before anything is written; it is written in the manifest's own convention — under the deck `--title` is the deck's title (`onscreen.title`, `--stream-title` the stream's), a cut whose deck titles are dates gets `--date` as one in their format, and the clip takes the section of the clip it goes after (`--section N` names another) and, from the same recording, its deck title and its citation link. `place` is Play's drag on the reel strip: the entries land before that entry (`-`: the end), their clips joining section N (default: the section of the clip they land after), every other clip keeping its own and the markers following, an emptied section refused, each place its own undo point ([knobs.md](knobs.md#the-reel-strip-zoom-and-reorder)). A removal re-anchors what named the clip (a marker to the clip before, a chapter to the next in its section; a pair, a status reference or a deck claim dropped) and prints each `re-anchored:` line; `reject` rejects the clip for `<why>` — `not-matching` or `wrong-speaker` (fact errors: `incorrect`, the note its correction) or `irrelevant`, `repeats`, `weak`, `privacy`, `other` (`rejected`, never a correction) — and removes it, on record in `removed.json` with the reason and the note; `wrong-speaker <id>` is `reject <id> wrong-speaker`; `ls` marks a clip rejected but still in the cut (`[rejected — irrelevant]`) ([report-video.md](report-video.md#verdict--what-the-walk-said)). Every write snapshots the manifest first (`revisions/…-auto-before-<op>`), is refused only for what it breaks in the build's own words (**exit 1**), and on a generated manifest leaves an `edit` note ([report-video.md](report-video.md#structural-edits)) | | `timeline <project> insert (--to-section N \| --group G) <channel>/<video>@<start>-<end> [--id ID] [--lock] [--title T] [--stream-title T] [--date YYYY-MM-DD] [--quote Q] [--cite S] [--cite-url U]` | a clip at the **end of section N**, or **after group G's last clip and one of its clips** (the run stays together): one write, the marker that followed that last clip re-anchored after the new one, so the clip lands in the section and every other clip keeps its own; the attribution as `insert --after`'s. The Candidates panel's Insert is this ([knobs.md](knobs.md#the-candidates-inbox-proposed-clips-picked-by-a-press)) | -| `candidates <project> [ls] [--all] [--json]` · `candidates <project> import <sweep.md> [--dry-run] [--json]` · `candidates <project> add <json\|@file> [--json]` | the **candidates inbox** (`<project>/candidates.json`): proposals only — `import` reads a sweep's bullets (`- [verdict] [title @ time](link) (date) "quote" — why`, under their headings; a Top N section marks what it restates; a bullet with no verdict or link is skipped and said), `add` an agent's (`{channel?, video, t, quote?, why?, verdict?, score?, section?}` or `{link, …}`); the same moment again changes nothing it holds. Insert and Not this are the Cut tab's Candidates panel's ([knobs.md](knobs.md#the-candidates-inbox-proposed-clips-picked-by-a-press)) | | `timeline <project> groups [ls] [--json]` · `groups import <file> [--skip-missing] [--drop-empty]` · `groups set <gid\|-> <id…> [--claim C]` · `groups move <gid> --to <index>` · `groups move <gid> --to after <gid>` · `groups label <gid> <claim…>` · `groups promote <gid> [--label L]` · `groups remove <gid>` · `order <file\|@file\|id…>` | **claim groups** (`groups` beside the timeline; the Cut tab's group bars): runs of clips inside one section making one claim — `ls` by section, each group's id, claim and clips (`--json` with the token); `import` a claim-groups file (`{sections: [{label, groups: [{claim, ids}]}]}`) in ONE write — the cut re-ordered to it, its groups the cut's, the markers following; a file section is the deck section of its name, else the one most of its clips are in; **exit 1** for an id the cut lacks (`--skip-missing`) or a section left with no clip (`--drop-empty` removes its marker); `set` (the clips already together), `label`, `remove` (ungroup), `move` the whole group (before the group at that index, or after one, in its section), `promote` (a level-2 marker at its first clip titled with its claim — the one group edit the render sees; `--label` when the claim is over 24); `order` the named entries in the places they hold (every clip keeping its section). A clip moved out of its group's run leaves it; moved alone into the middle of one, it joins. Every write an undo point (`undo`) ([knobs.md](knobs.md#claim-groups-runs-of-clips-that-make-one-claim)) | | `timeline <project> --take <take> [ls \| move <id> --to <index> \| remove <id> \| undo \| insert <spec> --after <id>\|-]` | a **take's** timeline (walk a take): the same structure checks, written into the take's patch, each write with an undo point of the take's own (`takes/<take>/revisions/`); `undo` takes the take's newest edit back, whichever writer made it. `insert` puts a clip (`<channel>/<video>@<start>-<end>`) into the take only (`takeEdit.mjs insertTakeEntry`) -- the app's **+ Add a clip to <take> only** on the take walk page, and Play's **+ Add a clip here** on a take with its own timeline | | `timeline <project> sections [--json]` · `section-move <id>… --to-section N [--start]` · `section-add --after <id> [--label L] [--color C]` · `section-boundary <marker> --after <id>` · `section-remove <marker>` · `section-set <marker> [--label L] [--color C]` · `split <id> <second>` · `flash-forward <id> <from>-<to> (--after <id\|-> \| --to-section N [--start]) [--move] [--quote Q] [--id ID]` | **sections as sections** (the deck's markers; the Cut tab's section bars and row menus): clips moved to a section with every marker following, a section opened, a boundary moved, relabelled, removed — no section emptied, no boundary crossed (**exit 1**) — and every take patch in step synced; **split** (each half's quote from the words, the second half's cite and QR at its second, a marker after the clip following its second half); **flash-forward** a tight copy of a span elsewhere with the clip's attribution and locks, as `repeatOf` the clip (`--move`: out of the clip) ([knobs.md](knobs.md#sections-split-and-flash-forward-editing-the-cut)) | +| `timeline <project> threads [--json]` · `timeline <project> threads --write [--conversation <id>]` | **the cut's conversations** ([report-video.md](report-video.md#thread-reads), `post-conversation.mjs`): each tree of two post items or more — its root, its items' places, whether they play as one run (one scene) or are split by other entries, a reply placed before the post it answers, an item re-reading a post its run already read (with `posts set-item <p> <item> thread.parent.<i>=context`). `--write` gathers each (or the one holding `<id>`: its root, a post, an item, a `thread.group` name) at its first item's place in TREE order (a manual thread: in DATE order) — a post after what it answers, sibling branches by date, each depth first — in ONE write (one undo point); never across a section boundary (gathered within each section, and said) | +| `timeline <project> [--take <t>] add-video <src> [--from S] [--to S] [--fit contain\|cover] [--bass dB] [--gain dB] [--enter cut\|<out>,<in>] [--hold S] [--title T] [--id ID] [--after <id>\|-] [--dry-run] [--json]` · `timeline <project> [--take <t>] set-video <id> <key>=<value>…` | **a video entry** ([report-video.md](report-video.md#a-video-entry)): a file of the project (`src`, relative; probed, its `fileSeconds` written) played FULL FRAME with its own sound, nothing drawn over it, at the end unless `--after` (`-`: the start), into the cut or the take's timeline only (`--take`, an undo point of the take's); `set-video` sets `from= to= fit= audio.bass= audio.gain= enter=cut\|<out>,<in> enter.out= enter.in= holdLast= deck=hidden\|shown title= note= src=` (`key=` clears). `--dry-run`: the entry and its place, nothing written. `--json`: `{ok, op, take?, inserted\|updated {id, at, entry}, revision?}`. **Exit 0 · 1 refused (no such file, take or entry; the build would not take it) · 2 usage** | +| `timeline <project> insert (--after <id\|-> \| --to-section N \| --group G) post:<channel>/<postId> [--id ID]` | **one post item** among the cut's entries, made as `posts reel` makes one | +| `timeline <project> insert (--after <id\|-> \| --to-section N \| --group G) post-json:<json>\|post-json:@<file> [--id ID]` | **a post item made by hand** — a post no archive holds (one kept only as a picture): `{post: "<channel>/<postId>", author, handle, date, text, media: ["posts-media/…"], parents?, quoted?, subjects?, redact?}`, its media measured, its id `p-<postId>` unless `--id`; refused in the build's words (**exit 1**). Its avatar: `posts avatar <project> <handle> <file>` | | `scenes <project> <clip> [--black-min 0.05] [--threshold 8] [--pix-th 0.10] [--pad 30 \| --from S --to S] [--json]` | the picture's **scene cuts** (ffmpeg `scdet`, score ≥ threshold) and **black spans** (`blackdetect`) in the clip's fetched window, in SOURCE seconds — for `blur.from`/`blur.to` and trims ([knobs.md](knobs.md#a-clips-picture-blurred)). The window is the one the build would cut from (the project's `out/clips-raw`, the editor's `channels/<slug>/data/<id>/clips/`, a saved source); the extent ± `--pad` inside it is scanned. Nothing is fetched: **exit 1** with no window on disk (`fetch` first) | | `posts set <project> <post> thread=on\|off [hide=on\|off] [attach=<clipId>\|auto] [crop=<px>\|off] [--json]` | the Posts table's writer (`updatePosts`, `PUT /api/report/posts`) from a terminal: `<post>` is the manifest's id (`x-<postId>`) or the bare `<postId>`; `thread=on` draws a reply with the post it answers above it (`shot-thread.png` beside its `shot`, taken by `capture-posts` `"thread": true`; its own shot while there is none), `off` removes the key.; `crop=<px>` the post's own crop of its screenshot (`shotMaxHeight`, 120–1080: its top that tall, never panned; `off` removes it) ([knobs.md](knobs.md#add-post-a-post-card-from-play-the-cut)). Refused in the build's words (a post with no `shot`, an `attach` that is not a clip) — **exit 1** | | `posts add <project> <archive-channel>/<postId> [--attach <clipId>] [--flag F] [--author A] [--id ID] [--thread] [--crop <px>] [--dry-run] [--json]` | a **post card** from the corpus's posts archive (`channels/<slug>/posts/*.jsonl`): its words, date, link and handle; id `x-<postId>` (`bsky-`, `post-`); the author an earlier post by the same handle carries in the cut, else the archive's. Its capture (`posts-media/<postId>/`: `shot.png`, `capture.json`, the post's pictures) is copied to the project's `posts-media/<slug>/<postId>/` — or used where it is, when that folder links the channel's captures; never copied through a link anywhere else. Then `upsertPost` (a post with the id is replaced, its `attachTo` kept). **Exit 1** with no screenshot, naming the `pnpm ops capture-posts` to run. `--thread`: the entry gets `thread: true` (a reply drawn with the post it answers; `shot-thread.png` is copied with the rest, and with none yet it prints the `"thread": true` capture to run). `--crop <px>`: the post's own crop (`shotMaxHeight`). A post that quotes another, reposts one or carries media is added with a `WARNING:` line (`--json`: `warnings`) — its screenshot shows them, by the post's own data. Play the cut's **Add post** runs this same write ([knobs.md](knobs.md#add-post-a-post-card-from-play-the-cut)) | @@ -104,15 +120,11 @@ Inbox cannot disagree about what is wrong with one. | `posts reread <project> <item> --pause "<word>[#<n>]=<seconds>\|@<take s>=<seconds>[,…]" [--target post\|parent:0\|quoted\|linked:0] [--dry-run] [--json]` | **pauses put in after words** of a narrated read, no TTS (`lib/report/postPause.mjs`; operator, 5 Nov: a countdown "20 10 4 0" read without a breath): the picked take cut just after each word named (half way into the quiet before the next word, at most 0.1 s past its end) and that much silence (0.05–3 s) put in -- each cut moved to the quietest 10 ms its word allows (40 ms before its timed end up to the next word, ±40 ms when they run together) when that is clearly quieter (~3 dB) than the timing's own, and each side of the silence faded over 10 ms, so a pause in normally paced speech does not click -- everything after moved on -- its words (by index), its parts (one a pause falls in grows), its length -- so word zooms, captions, slams, beeps and the read-follow stay on their words; an effect with a set `at` does not move (the plan counts them). A word is matched as a word zoom's is (case and edge punctuation aside; a phrase pauses after its last word; `#n` its n-th time in the read; `--target` counts only the words of the parts reading that piece). A derived take (`steps: [{op: "pause", pauses: [{word, w, at, seconds}]}]`) picked in ONE write. **Absolute**, like a tempo: on a take whose last step is a pause it re-cuts from the take before (the pauses it had kept, a word named again takes the new seconds, `=0` takes one away). `--in-take <t>` puts it in a take's read. No word timings (**exit 1**, naming `posts narrate <p> <item> --words`), a word not read, an occurrence not there, nothing to change: **exit 1**; a malformed spec, seconds outside 0.05–3, `--pause` with another reread form: **exit 2** | | `posts reread <project> <item> --revoice "<phrase>[#<n>]" --say "<what to say instead>" [--target <piece>] [--voice <v>\|auto] [--xfade 0.03] [--splice <from>-<to>] [--dry-run] [--json]` | **one phrase of an approved read re-voiced**, the rest untouched (`lib/report/postRevoice.mjs`; operator, 5 Nov: the countdown gabbled, and pauses cut into it "choppy"): the phrase found in the picked take's word timings as `--pause` finds a word (`#n`, `--target`; inside one part), the original cut from just before its first word to just after its last -- each cut at the quietest 10 ms within ±40 ms of the boundary, and when that is still speech within ±0.15 s (never inside the phrase as timed; a nearer quiet preferred) -- **`--say` alone synthesized by the editor's TTS** (narrate-via-editor; the engine of the root take, the voice of the part the phrase is in, `--voice` overrides; the project's lexicon, redaction and slur filter applied; kept in `narration/parts-cache/` like a thread read's parts, so asking again is free), its lead and tail of silence trimmed, loudness-matched to the speech in the 2 s either side (±6 dB) and spliced in with equal-power crossfades (`--xfade`, 0–0.2 s) at both joins, at the take's rate and layout. The length is exact: the take − the span cut + the piece. Everything after moves by the difference (its words, the part holding the span, the later parts) so zooms, captions, slams, beeps and the read-follow stay on their words; the new words are timed from the piece's speech and marked `estimated` (a later `posts narrate … --words` refines them); the part's text and the script say `--say`. A derived take (`steps: [{op: "revoice", revoice: {word, count, words, phrase, say, said, voice, engine, from, to, seconds, gain, xfade, key}}]`) picked in ONE write; re-voicing exactly the words a re-voice put in re-cuts from the take before. `--dry-run`: the span (words, seconds), each cut and its level, what is said and in which voice, the length change when the piece is cached -- no TTS. A cut still in speech is warned of (the word timings off there): `--splice 65.03-66.00` sets the cuts (either side may be left out). `--in-take <t>` puts it in a take's read. No word timings (naming `posts narrate <p> <item> --words`), the phrase not read or across two parts, a recorded read, the TTS failing: **exit 1**; no `--say`, a bad voice, crossfade or splice, `--revoice` with another reread form: **exit 2** | | `posts progress <project> [auto\|on\|off\|default] [--json]` | the cut's **progress bar** default (`render.posts.progress`, `updatePostProgressRender`; [report-video.md](report-video.md#the-progress-bar)); bare, which items draw it | -| `timeline <project> threads [--json]` · `timeline <project> threads --write [--conversation <id>]` | **the cut's conversations** ([report-video.md](report-video.md#thread-reads), `post-conversation.mjs`): each tree of two post items or more — its root, its items' places, whether they play as one run (one scene) or are split by other entries, a reply placed before the post it answers, an item re-reading a post its run already read (with `posts set-item <p> <item> thread.parent.<i>=context`). `--write` gathers each (or the one holding `<id>`: its root, a post, an item, a `thread.group` name) at its first item's place in TREE order (a manual thread: in DATE order) — a post after what it answers, sibling branches by date, each depth first — in ONE write (one undo point); never across a section boundary (gathered within each section, and said) | | `posts roles <project> [<item> …] [--write] [--set <n>=<role>,…] [--json]` | a narrated read **piece by piece** ([knobs.md](knobs.md#thread-reads-every-part-of-a-read-on-screen-while-it-is-said), [report-video.md](report-video.md#thread-reads)): the text each part of the picked take reads -- `parent:<i>`, `quoted`, `post`, `media:<i>` -- stored or inferred, what the card shows for each, and the build's guard (a part read off a post the card hides is refused). `--write` stores the inferred roles on the picked takes' parts (one write; the import stores them for every new take); `<item> --set n=role,…` sets parts' roles by hand (`off`: inferred again); a part out of range or an unknown role is refused (**exit 1**) | | `posts narrate <project> --import [--dry-run] [--json]` · `--list` · `<item> [--script "…"] [--pick <n>] [--approve\|--unapprove] [--off\|--on] [lead= tail= ramp= linger= clip=read\|full wet= lowpass= duck=on\|off short=hold\|loop attach=under\|after lufs= pace=fast\|normal]` · `<item> --take [--note "…"] [--voice v] [--engine e] [--speed s] [--script "…"]` · `<item> --derive <n> --op enhance\|convert [--engine e] [--voice v]` · `<item> --delete <n>` · `--all --draft-scripts [--force]` · `--all --take [--limit N]` · `--cut <k=v>…` | a **narrated post item** ([report-video.md](report-video.md#narrated-post-items), [knobs.md](knobs.md#a-narrated-post-item)): `--import` reads `narration/posts/index.json` (`[{id, entry, script, takes: [{file, engine, voice, seconds}], pick}]`, and a take's `take-<n>.parts.json`) into the cut in ONE write, measuring each take (length, loudness); a re-run adds only takes not there. `--take` asks the EDITOR for a new take (`POST /api/ops/tts`, its `out` the next `narration/posts/<postId>/take-<n>.<engine>-<voice>.wav`; a job, waited for; `ARCHILYZER_EDITOR_URL`, `WORKER_TOKEN`) and picks it, its `--note` kept with it; `--pick <n>` is the take's number as `--list` shows it. `--derive <n>` makes a NEW take from take n through the editor's `voice-enhance` / `voice-convert` op (a stock synthetic voice; "not installed" until the editor has the engine), the original kept; `--delete <n>` moves a take's file to the post's `.trash/`. A new script or pick takes the approval away. `--all --draft-scripts` writes every post's words as its script, VERBATIM (cleaned only to be spoken: a reply's leading @handles, links, emoji dropped -- a handle typed inside the message is kept and said "at <handle>", the lexicon first; `plan(s)` → plans, `w/` → with, `&` → and; paragraphs kept). `--cut` sets `render.postNarration` (and its read-follow: `follow=on\|off`, `follow.dim=`, `follow.ease=`; its thread reads: `thread.parent=`, `thread.quoted=`, `thread.carry=`, `thread.reveal=`, `thread.shrink=`, `thread.dim=`, `thread.seconds=`, `thread.pan=`). Refused in the build's words (**exit 1**) A `--take` whose read says a slur the cut BEEPS is word-timed by the editor's transcription before it is kept -- never waited on: with the transcription lane held (as while Orpheus runs) the take is kept as read and the timing deferred (it says so, naming `posts narrate <p> <item> --words` to run after the release; the build refuses the take until then), and a timing still queued after 5 min is deferred the same way. An excerpted item (`posts set-item … excerpt=`) reads its spans. | | `posts narrate <project> <item> --take --thread [--parents 0\|all\|none\|<n>] [--skip-parent <id\|parent:i>]… [--no-quoted] [--no-linked] [--read-seen] [--voice-for <handle>=<voice>]… [--voice v] [--engine e] [--note "…"] [--force] [--no-hold] [--dry-run] [--json]` | a **THREAD READ** as one command ([knobs.md](knobs.md#pronunciation-and-voices-the-lexicon-the-voice-map-a-thread-read), `lib/report/postThreadRead.mjs`): the post it answers (`--parents all`: every ancestor; `<n>`: parents 0..n; `none`), the post it quotes and the posts it links to, then his words, in DATE order, each in its author's voice (`--voice-for`, then the project's voice map, `posts voices`; his own: the narrator's), the redaction, the slur filter (a beep is skipped: a joined read is not word-timed) and the lexicon (`posts say`) applied. A parent or quoted post the item before already shows is not read again (`--read-seen`: it is). Each part is synthesized ONCE by the editor's tts op into `narration/parts-cache/<sha1(voice\|text)>.wav` (the transcription lane held meanwhile, only if it was not; `--no-hold`: left alone), joined (0.8 s between pieces, 0.6 between paragraphs, 0.25 inside one) into `take-<n>.<engine>-thread.wav` with `take-<n>.parts.json`, saved with its parts' roles, its lexicon and how it was asked (`read`) and PICKED — one write (one undo point). `--dry-run`: the pieces, voices and parts (cached or not), nothing asked. Already up to date (same words and voices): nothing done, **exit 0** (`--force`: again). A part not synthesized: **exit 1** (the parts made stay cached; run it again); `--json` prints `{ok: false, error}` too. A usage error: **exit 2** | | `posts say <project> [ls] [--item <id>]` · `add <word\|phrase> "<spoken>" [--case] [--item <id>] [--note "…"]` · `remove <word\|n> [--item <id>]` · `try "<text>" [--item <id>]` · `stale` `[--json]` | **THE PRONUNCIATION LEXICON** ([knobs.md](knobs.md#pronunciation-and-voices-the-lexicon-the-voice-map-a-thread-read)): `narration/lexicon.json` in the project, a word or phrase said differently in EVERY synthesized read (a script's `--take`, each piece of a thread read, the bench's re-take); the scripts and cards keep their words. Whole words, without case unless `--case`, a phrase across any spaces, regex characters literal; `--item` for one item's reads (it wins over the project's). A masked slur and a redacted word are never replaced. `add` of a word already listed changes what is said. `try` prints what a voice would be asked to say. `stale` lists every picked read that still says an entry the old way, with the command that re-reads it. A bad entry or an unknown item: **exit 2** | | `posts voices <project> [ls] \| set <handle\|*> <voice> \| remove <handle\|*> [--json]` | **THE VOICE MAP** (`narration/voices.json`): the stock voice a thread read gives each author (`*`: everyone it does not name; default `leo` on Orpheus); `ls` lists the map and every author the cut's items carry with the voice each would get. A bad handle or voice: **exit 2** | -| `cast [ls] \| add <id> --name … --voice <engine:voice> [--handles a,b] [--speakers …] [--convert-engine e] [--convert-voice v] [--narrator] \| set <id> … \| rm <id> \| undo [--json]` | **THE CAST** (`<reports>/.umtool/cast.json`, [knobs.md](knobs.md#the-cast-each-characters-voice-in-every-project-and-the-voices-page)): the characters across projects and their STOCK voices, a layer under each project's voice map; one writer, an undo point a write | -| `cast project <project> [--json]` · `cast use <project> <character\|@handle> <voice> [--everywhere]` · `cast reread <project> <character> [--dry-run]` | a project's characters (each voice now, where it comes from, its stale reads), the voice for this project or everywhere, and the re-reads that asks for | -| `cast audition <character\|@handle> --voices a,b,… [--project <p>] [--text "…" \| --item <id> \| --line <n> \| --stock] [--no-score \| --score-only] [--json] [--progress ndjson]` | **AN AUDITION**: one line read by 2-6 stock voices through the editor's tts op, levelled to -20 LUFS in `<p>/narration/auditions/` (cached), scored for closeness to the character's real voice (`speakers.json`; TitaNet, local) | | `posts narrate <project> <item> --recording <file> [--as <character>] [--no-clean] [--no-convert] [--label l]` | **a recording made a character's read**: kept (recorded), cleaned (voice-enhance), converted (voice-convert) to the character's STOCK voice, each a new take, the last picked | | `posts fx <project> <item> add caption --match "…" --text "…" [--target post\|quoted\|parent:<i>] [--occurrence n] [--at s] [--lead s] [--hold s] [--place below\|above\|side]` · `add clock [--rewind auto\|on\|off] [--off]` · `set <n> [--text …] [--place …] [--rewind …]` | a post item's **caption** ([report-video.md](report-video.md#a-caption), [knobs.md](knobs.md#a-caption-a-chip-explaining-a-phrase-as-it-is-read)): a chip explaining a phrase (any script: CJK drawn), up as it is read -- `--at`, else the take's word timings, else the reading estimate -- held `--hold` s, by the phrase and never over a word read while it is up; it waits for a word zoom. Its **clock** ([knobs.md](knobs.md#the-clock-each-posts-own-time-on-its-card-run-between-items)): the post's own time on the card, run from the clock item before it (forward; a REWIND when earlier: `--rewind`), `--off` not on this item. Through `updatePostFx`, refused in the build's words (**exit 1**); a zoom's knob on a caption, or a caption's on a zoom (**exit 1**) | | `posts clock <project> [on\|off\|default] [--zone <IANA zone>] [--json]` | the cut's **clock** default (`render.posts.clock`, `updatePostClock`); bare, which items show it and their times | @@ -127,19 +139,220 @@ Inbox cannot disagree about what is wrong with one. | `posts repeats <project> [--match id\|file\|audio] [--json]` | the **combo counter**'s repeats ([report-video.md](report-video.md#the-combo-counter)): every attachment the cut's post items play more than once -- the same X media id (the capture's url), else the same file (the capture's sha256 when its bytes agree, else hashed; cached by path, size and mtime), else (`--match audio`) the same sound (fpcalc, else a coarse ffmpeg hash) -- its posts in the cut's ORDER with their dates, the tier that matched and the badge each draws (`×2` from the second use, `(×n)` counted but not drawn); a post whose CAPTURE holds the same file but whose entry carries no attachment is listed too, `NOT ATTACHED`, with the `posts attach` that brings it in. Reads only | | `posts attach <project> [<item> … \| --all] [--dry-run] [--json]` | a post item with **no attachment whose capture holds one** (captured after it went in -- `posts repeats` marks them `NOT ATTACHED`): the capture's media (its own channel's `posts-media/<postId>/`, else any channel the cut's posts come from) copied into the project's `posts-media/<slug>/<postId>/` and measured, set as the entry's `media` as `posts reel` would have made it -- nothing else of the entry changes (its paraphrases, narration, knobs kept); an item that has an attachment is never touched. ONE write (one undo point: `timeline <p> undo`), refused whole in the build's words | | `posts combo <project> [on=on\|off] [label=L] [position=top-right\|top-left\|bottom-right\|bottom-left\|center] [color=#rrggbb] [scale=0.4-2.5] [sfx=off\|hit\|coin] [minCount=2-20] [match=id\|file\|audio] [--json]` · `posts combo <project> <item> off\|on\|auto\|label=…\|position=…\|color=…\|scale=…\|sfx=… [--json]` | the **combo badge's knobs** ([knobs.md](knobs.md#the-combo-counter)): the cut's (`render.posts.combo`, `updatePostComboRender`; no knobs prints them; `k=` the default again) or one post item's (`combo`, `updatePostCombo`): `off` draws no badge on it -- it still counts -- `on`/`auto` the cut's again. Refused in the build's words (**exit 1**) | -| `new <slug> --from-posts <channel> [--channel <more>…] [--since D] [--until D] [--own] [--with-media] [--replies …] [--order …] [--limit N]` | a **posts reel**: the scaffold with the deck on (no `siteOrigin`: each post's QR opens the post, `deck.qr.links: "original"`), then `posts reel` with the same filters | -| `timeline <project> [--take <t>] add-video <src> [--from S] [--to S] [--fit contain\|cover] [--bass dB] [--gain dB] [--enter cut\|<out>,<in>] [--hold S] [--title T] [--id ID] [--after <id>\|-] [--dry-run] [--json]` · `timeline <project> [--take <t>] set-video <id> <key>=<value>…` | **a video entry** ([report-video.md](report-video.md#a-video-entry)): a file of the project (`src`, relative; probed, its `fileSeconds` written) played FULL FRAME with its own sound, nothing drawn over it, at the end unless `--after` (`-`: the start), into the cut or the take's timeline only (`--take`, an undo point of the take's); `set-video` sets `from= to= fit= audio.bass= audio.gain= enter=cut\|<out>,<in> enter.out= enter.in= holdLast= deck=hidden\|shown title= note= src=` (`key=` clears). `--dry-run`: the entry and its place, nothing written. `--json`: `{ok, op, take?, inserted\|updated {id, at, entry}, revision?}`. **Exit 0 · 1 refused (no such file, take or entry; the build would not take it) · 2 usage** | -| `timeline <project> insert (--after <id\|-> \| --to-section N \| --group G) post:<channel>/<postId> [--id ID]` | **one post item** among the cut's entries, made as `posts reel` makes one | -| `timeline <project> insert (--after <id\|-> \| --to-section N \| --group G) post-json:<json>\|post-json:@<file> [--id ID]` | **a post item made by hand** — a post no archive holds (one kept only as a picture): `{post: "<channel>/<postId>", author, handle, date, text, media: ["posts-media/…"], parents?, quoted?, subjects?, redact?}`, its media measured, its id `p-<postId>` unless `--id`; refused in the build's words (**exit 1**). Its avatar: `posts avatar <project> <handle> <file>` | -| `modules list [--json]` · `modules apply <project> [--config FILE] [--dry-run] [--json]` · `modules apply <project> [--config FILE] --take <id> [--label L] [--at S --dur S \| --full] [--quick] [--force] [--from TAKE] [--keep-frames] [--patch-out FILE]` | the **video modules** (release 39): `list` every module, its kind, slot and where its settings live; `apply` maps the project's `module-config.json` (the modules a video wants, in MODULES-DESIGN's vocabulary) into the manifest's homes (`report-to-video/modules/config-loader.mjs`) — the preset, the deck's subtitle and QR, the counter's series and each clip's marks, the stamps, the rail's markers, the chapters, the pairs, the status ledger, the intro, the finale — and lists every field with no home, by path. Without `--take` the manifest is rewritten through `replaceManifest` (a snapshot first); with `--take` it is that take's patch (`takes/<id>.modules-patch.json`, or `--patch-out`) and the take is made from it as `take` makes one, the manifest untouched. **Exit 1** when the result would not build (the build's sentences) ([knobs.md](knobs.md#look-presets)) | -| `preset list [--json]` · `preset show <name> [--json]` · `preset save <name> --from <project> [--description D] [--force]` · `preset apply <name\|none> <project> [--replace] [--json]` | the **look presets** (`umtool/presets/<name>.json`, or `UMTOOL_PRESETS_DIR`; built in: `plain-deck` `huck-deck` `ember-deck` `archive-catalog` `basic`): a render block a manifest stands on (`"preset": "<name>"`), laid under it — preset → manifest → style → take patch. `save` keeps a project's look and leaves its content out; `apply` names the preset on the cut through `updatePreset` (nothing copied in), refused when the cut over it would not build (a basic cut's chrome is not checked); `--replace` also clears the manifest's own value of every key the preset sets, after an undo point (`revisions/…-auto-before-preset-replace`), and prints what went ([knobs.md](knobs.md#look-presets)) | -| `clip <channel>/<video>@<start>-<end> [--snap words] [--title T] [--site <id>] [--folder F] [--json] [--progress ndjson]` | **quick clip**: a basic-mode project (`quick-clips/<slug>`, the footage alone), its window asked of the editor (fetch-windows, followed to its end; Rumble fetched whole), `--snap words` its edges snapped to the words heard (the editor's transcribe op), rendered as the take `clip` (`take <p> --id clip --full`: the heavy slot), then the mp4's path and the share line. `--json`: `{project, output, share: {platform, archive, text}, snapped?}`; `--progress ndjson`: events, the last `quick-clip` (the app's `POST /api/report/quick-clip` job). **Exit 0 · 1 failed (the editor, the render) · 2 usage** ([knobs.md](knobs.md#basic-output-the-footage-alone)) | -| `share <project> [<clip>] [--take <t>] [--site <id>] [--json]` | a clip's **share line** (the clip named, else the first): its platform page at the first second it plays and its archive moment, a Rumble folder id as the embed id the archive serves — the twin of **Copy share line** (`GET /api/report/share-line`). `--json`: `{clip, seconds, platform, archive, text}` | +| `candidates <project> [ls] [--all] [--json]` · `candidates <project> import <sweep.md> [--dry-run] [--json]` · `candidates <project> add <json\|@file> [--json]` | the **candidates inbox** (`<project>/candidates.json`): proposals only — `import` reads a sweep's bullets (`- [verdict] [title @ time](link) (date) "quote" — why`, under their headings; a Top N section marks what it restates; a bullet with no verdict or link is skipped and said), `add` an agent's (`{channel?, video, t, quote?, why?, verdict?, score?, section?}` or `{link, …}`); the same moment again changes nothing it holds. Insert and Not this are the Cut tab's Candidates panel's ([knobs.md](knobs.md#the-candidates-inbox-proposed-clips-picked-by-a-press)) | | `ingredient <channel>/<video> [--window <from>-<to>] [--used-in] [--json]` | **one recording's life cycle**, the twin of `/ingredients/<channel>/<video>` ([knobs.md](knobs.md#an-ingredients-life-cycle-the-rail)): nine stages — found, downloaded, transcribed, clock, windows, used in, checked, rendered, published — each **✓**, a count, **!** or **—**, and its line, then every project clip that cuts from it (the draft and each saved version, from the usage index `<REPORTS_ROOT>/.umtool/usage-index.json`). A Rumble recording answers to its folder slug or its embed id; both are printed. `--window`: one clip window, the stages after it narrowed to the clips it plays. `--used-in`: the clips alone. `--json`: the page's object. Read-only over the corpus. **Exit 0 · 1 failed · 2 usage** | -| `take status <project> [--id <take>] [--json] [--log] [--tail N]` | a take's **render record** (`takes/<take>/render.json`, written by every render whoever started it — a terminal, the Takes page, the queue): `state` (`running`, `waiting` at the heavy slot, `done`, `failed`, `cancelled`; `queued` or `blocked` while a queue step waits to render it), `stage` and a rough `percent`, the `error` (the first error line, not a bare "exited 1") and the log's last 40 lines (`tail`), on done the `mp4` and its measured `seconds`; `--log` prints the FULL `takes/<take>/render.log`. A "running" whose process is gone reads **failed** ("the render process is gone"); a done whose mp4 is missing or 0 bytes reads **failed**. **Exit 0 done · 3 queued, waiting or running · 1 failed, cancelled, blocked or none.** Without `--id`: every take with a record, the newest's exit ([queue and poll](#queue-and-poll-instead-of-scripting)); and its fast-feedback renders beside it, `preview` and `changes` (each one's state, mp4, seconds, log; a changes reel's piece count, its base and its list), a queued `--preview`/`--changes` step said as such -- never as the take's own render | -| `queue add [--after <qid>\|last] [--label T] [--timeout <minutes>] [--json] -- <umtool subcommand argv…>` | a **step** of the durable queue: the argv of a umtool command, one word per argument (no shell), stored under `<reports root>/.umtool-queue/` and run by the **umtool app** (its systemd unit), one step at a time, in order — so it survives the session that queued it, an app restart and a ship. Prints the qid (`q<N>`) alone on stdout. `--after` waits for that step to be **done**; when it fails or is cancelled this one is **blocked** (and so is whatever waits on it). `--timeout`: the step's limit (default 720 minutes). A step does not start while the app's own job runner is busy (a Takes-page job), and a heavy step still takes the machine's heavy slot and render mode by itself | -| `queue ls [--all] [--json]` · `queue status <qid> [--json]` · `queue wait <qid> [--timeout <s>]` · `queue log <qid> [--tail N]` · `queue cancel <qid>` · `queue retry <qid>` | the queue: `ls` the runner (is the app running it) and the steps not finished or finished in the last 24 h; `status` one step (**exit 0 done · 3 queued or running · 1 failed, blocked or cancelled**); `wait` the same after up to `<s>` seconds (default 90); `log` its FULL log (`logs/<qid>.log`; earlier attempts kept as `<qid>.<n>.log`); `cancel` a queued or blocked step at once, a running one stopped (its process group); `retry` a failed or cancelled step back in the queue with every step blocked behind it. A step that was running when the app died reads **failed** ("the step's process is gone"), its log kept — it is never re-run on its own | -| `jobs [--json]` | every running and recent **take render** across projects (their records), every queue step not finished or finished in the last 24 h, and the umtool app's own jobs (`GET /api/jobs` at `--url` / `UMTOOL_URL`, when it answers). The page is **/jobs** (the rail's *Running* links it) | + +### Every verb + +Every verb `umtool` dispatches, a sub-verb its own row (`umtool/lib/cli/verbs.mjs`, the registry the ⌘K palette's +**Commands** are built from). **form**: the palette offers it as a form (its arguments below, the page's project +and selection filled in; **Copy as CLI**; Run is `POST /api/cli`, which runs only these). **queued**: Run adds it to +the durable queue (it renders, or holds the heavy slot). Otherwise why it has none. *draft*: it writes the working +draft (the project's manifest); *project*: a project's other files, or reads; *corpus*: no one project. + +| Verb | What it does | ⌘K | +|---|---|---| +| `ls [--kind KIND] [--template TEMPLATE] [--state STATE] [--open] [--blocking] [--q Q] [--sort recent\|name]` | every project, as text | form · *corpus* | +| `show <project>` | one project: summary, the cut, per-clip status, decisions | form · *project* | +| `check [<project>] [--all-severities]` | what blocks a build (exit 1 on anything blocking) | form · *project* | +| `links <project> [--fix]` | do the clip QRs open on their sites (out/links.json) | form · *project* | +| `cast ls` | the characters' voices across projects | form · *corpus* | +| `cast add <id> --name NAME --voice VOICE [--handles HANDLES] [--speakers SPEAKERS] [--convert-engine openvoice\|seed-vc] [--convert-voice CONVERT-VOICE] [--note NOTE] [--narrator]` | a character: name, stock voice, handles | form · *corpus* | +| `cast set <id> [--name NAME] [--voice VOICE] [--handles HANDLES] [--speakers SPEAKERS] [--convert-engine openvoice\|seed-vc] [--convert-voice CONVERT-VOICE] [--note NOTE] [--add-handle ADD-HANDLE] [--remove-handle REMOVE-HANDLE] [--no-convert] [--narrator] [--no-narrator]` | change a character | form · *corpus* | +| `cast rm <id>` | a character out of the cast (an undo point) | form · *corpus* | +| `cast undo` | the cast as it was before its last write | form · *corpus* | +| `cast project <project>` | the project's characters, their voices and drift | form · *project* | +| `cast audition <character> --voices VOICES [--project PROJECT] [--text TEXT] [--item ITEM] [--line N] [--stock] [--no-score] [--score-only]` | one line read by 2-6 candidate voices, scored against the real voice | form · queued · *project* | +| `cast use <project> <character> <voice> [--everywhere]` | the voice a character reads in, here or everywhere | form · *draft* | +| `cast reread <project> <character> [--dry-run]` | the items that say a character in another voice, read again | form · queued · *project* | +| `speaker-check <project> [--clip CLIP…] [--list] [--set SET] [--remove REMOVE]` | which named voice each clip is (speaker-check.json) | form · queued · *project* | +| `quote-check <project> [--clips CLIPS] [--pad N] [--status]` | is each clip's quote in the seconds it plays | form · queued · *project* | +| `check-joins <project> --take TAKE [--all] [--limit N]` | do a rendered take's post joins carry on | form · queued · *project* | +| `link-policy <project> [--via VIA] [--direct DIRECT] [--clear] [--fix]` | cite via site X, these channels direct | form · *draft* | +| `patch-markers <project> [<file>] [--fix]` | take patches whose deck markers name a clip not in the cut | form · *draft* | +| `decisions` | every decision waiting, by project | form · *corpus* | +| `inbox [--all]` | the decisions grouped and ranked as the Inbox shows them | form · *corpus* | +| `schedule list` | the recurring reports | form · *corpus* | +| `schedule show <id>` | one recurring report: chip, editions, tick log | form · *corpus* | +| `folders` | the reports tree's folders | form · *corpus* | +| `kinds` | the project kinds the registry knows | form · *corpus* | +| `link <project> [<article>] [--clear]` | the manifest names the article it is the video of | form · *draft* | +| `window <project> <clip> [--start N] [--end N] [--lock] [--lock-end] [--no-lock-end] [--cut-start N] [--cut-end N] [--lock-cut] [--align] [--title TITLE] [--date DATE] [--cite N] [--cite-url CITE-URL] [--quote QUOTE] [--repeat-of REPEAT-OF] [--verdict confirmed\|incorrect] [--correction CORRECTION] [--reject not-matching\|wrong-speaker\|irrelevant\|repeats\|weak\|privacy\|other] [--note NOTE] [--walk-note WALK-NOTE] [--star] [--no-star] [--quote-ruled] [--no-quote-ruled] [--move-stamp MOVE-STAMP] [--clear-stamp] [--move-mute nearest] [--clear-mute] [--gap GAP…] [--gap-remove N] [--gaps GAPS] [--take TAKE]` | a clip's window, cut, attribution and verdict | form · *draft* | +| `walk <project> [--take TAKE] [--all]` | the clip bench's walk: clips in walk order, verdicts, fetched | form · *project* | +| `present <project> [--take TAKE] [--cut] [--public]` | present mode's address and slides | form · *project* | +| `set <project> <clip> key=value… [--mark MARK] [--take TAKE]` | a clip's knobs: claim, marks, audio, blur, fx … | form · *draft* | +| `intro <project> [key=value…] [--off] [--take TAKE] [--on]` | the intro the cut opens on (render.intro) | form · *draft* | +| `look <project> key=value… [--unset UNSET…]` | the cut's knobs: mode, deck, fact-check stamps, variants … | form · *draft* | +| `migrate <project> [--dry-run]` | the manifest's settings into the video modules' homes | form · *draft* | +| `variants <project> [--take TAKE] [--list]` | make the encode ladder of a build | form · queued · *project* | +| `corrections <project>` | what the report got wrong, as markdown | form · *project* | +| `build <project> [--preset preview\|fast\|final] [--only ONLY] [--dry]` | the build's chain, printed (the Cut tab's Build runs it) | form · *project* | +| `chain <article> <n> [--from FROM] [--dry] [--final] [--site-origin SITE-ORIGIN] [--draft-all] [--model MODEL] [--deck]` | an article iteration's pipeline to a video | form · queued · *corpus* | +| `index [--rebuild] [--prune] [--since N]` | the project index (the cache) | form · *corpus* | +| `new <slug> [--folder FOLDER] [--from FROM] [--site-origin SITE-ORIGIN] [--seed chapters\|frames\|phrase\|reactions] [--target N] [--phrase PHRASE] [--channels CHANNELS] [--prefer PREFER] [--exclude EXCLUDE] [--max N] [--from-posts FROM-POSTS] [--brand BRAND]` | a new project (scaffold) | form · *corpus* | +| `doctor` | the tools and the roots on this machine | form · *corpus* | +| `storage status [<project>]` | where each project's out/ lives | form · *corpus* | +| `storage move-out` | out/ to the media root, a link left | none: moves a project's out/ between drives: a terminal's, run when nothing builds (the page cannot see a hand-run writer) | +| `storage move-back` | out/ back into the project | none: moves a project's out/ between drives: a terminal's, run when nothing builds | +| `storage deliverables` | clips/ and share-*/ to the media root and back | none: moves deliverables between drives, then the switch: a terminal's, run when nothing builds | +| `snapshot <project> [--label LABEL]` | copy the manifest into revisions/ | form · *project* | +| `diff <project> <snapshot>` | what changed since a snapshot | form · *project* | +| `export <project> [<clip>] [--format toc-bbcode\|toc-markdown\|description\|chapters] [--variant VARIANT] [--first FIRST] [--context N] [--raw] [--from N] [--to N] [--fetch] [--take TAKE]` | the posting artifacts, or one clip clean into exports/ | form · queued · *project* | +| `check-sources [<projects>…]` | the re-check chain, printed | form · *corpus* | +| `notes [<target>] [--all] [--resolved] [--all-status]` | the operator's notes, as markdown | form · *corpus* | +| `notes reply <id> <text> [--resolve]` | answer a note | form · *corpus* | +| `notes resolve <id>` | a note resolved | form · *corpus* | +| `notes wontfix <id>` | a note closed as won't fix | form · *corpus* | +| `notes reopen <id>` | a note open again | form · *corpus* | +| `notes source <target> [--draft DRAFT] [--generator GENERATOR] [--how HOW]` | the source a target's notes name (the draft to edit) | form · *corpus* | +| `modules list` | the video modules | form · *corpus* | +| `modules apply <project> [--config CONFIG] [--dry-run] [--take TAKE] [--label LABEL] [--at N] [--dur N] [--full] [--quick] [--force] [--from FROM]` | a module-config.json onto the cut, or as a take's patch | form · queued · *draft* | +| `preset list` | the look presets | form · *corpus* | +| `preset show <name>` | one look preset | form · *corpus* | +| `preset save <name> --from FROM [--description DESCRIPTION] [--force]` | a project's look as a preset | form · *corpus* | +| `preset apply <name> <project> [--replace]` | a preset under the cut (none: off it) | form · *draft* | +| `take <project> --id ID [--label LABEL] [--group GROUP] [--kind similar\|different] [--summary SUMMARY] [--style STYLE] [--patch PATCH] [--patch-json JSON] [--set SET…] [--effect EFFECT] [--at N] [--dur N] [--full] [--quick] [--force] [--from FROM] [--keep-frames] [--priority] [--uncensored] [--draft] [--rebuild] [--preview] [--changes] [--pad N] [--no-preview] [--promote] [--anyway] [--import-item IMPORT-ITEM…] [--after AFTER] [--before BEFORE] [--as AS] [--dry-run]` | one take: rendered, drafted, previewed or promoted | form · queued · *project* | +| `lint <project> [--take TAKE] [--variant sourced\|full] [--final]` | the manifest lint a build runs first | form · *project* | +| `take status <project> [--id ID] [--log] [--tail N]` | a take's render record | form · *project* | +| `queue add` | a step of the durable queue: a umtool command's argv | none: takes a raw argv -- a page never sends one (app/api/queue/route.ts); a form's Run on a heavy verb queues the step itself | +| `queue ls [--all]` | the queue's steps and its runner | form · *corpus* | +| `queue status <qid>` | one step: state, exit code, error, log | form · *corpus* | +| `queue wait` | wait for a step to finish | none: blocks a terminal until a step ends: a form's Run follows its own step | +| `queue log <qid> [--tail N]` | a step's full log | form · *corpus* | +| `queue cancel <qid>` | a step cancelled (a running one stopped) | form · *corpus* | +| `queue retry <qid>` | a failed or cancelled step back in the queue | form · *corpus* | +| `jobs` | every running and recent render, step and app job | form · *corpus* | +| `takes make <project> [--recipe RECIPE] [--only ONLY] [--force] [--all-styles] [--group GROUP] [--at N] [--dur N] [--full] [--quick] [--priority]` | a recipe's takes, or one per montage style | form · queued · *project* | +| `takes styles` | the montage styles | form · *corpus* | +| `takes pick <project> <take> [--anyway] [--pin] [--unpin]` | use this take: its manifest over the project's | form · *project* | +| `takes effects <project>` | the overlay effects this cut offers | form · *project* | +| `takes ls <project>` | the working cut, then each take | form · *project* | +| `takes relabel <project> <take> <label>` | a take's label | form · *project* | +| `takes supersede <project> <take> [--by BY] [--clear]` | a take folded away in the list (or back) | form · *project* | +| `takes save <project> [--label LABEL] [--force]` | the working draft frozen as the next version (v<N>) | form · *project* | +| `takes open <project> <take>` | a saved version into the draft (the draft saved first) | form · *draft* | +| `takes freeze <project> [<takes>…] [--all] [--apply]` | legacy takes given a frozen base (a dry run unless --apply) | form · *project* | +| `takes delete` | a take's directory, whole | none: deletes a take's directory whole, past undo: the Takes panel's Delete asks first; a terminal's --dry-run shows what goes | +| `takes cancel <project> <take>` | stop a take's render | form · *project* | +| `takes fork <project> <take> [--name NAME]` | the take as a variant project beside this one | form · *project* | +| `takes compare <project> <a> <b>` | two takes side by side | form · *project* | +| `render-mode on [--for FOR] [--note NOTE]` | render mode: a render gets the machine, for a window | form · *corpus* | +| `render-mode off [--force]` | render mode off | form · *corpus* | +| `render-mode status` | is render mode on, for what, until when | form · *corpus* | +| `pool stats [--since SINCE]` | the render pool: what it holds | form · *corpus* | +| `pool prune [--max-gb N] [--dry-run]` | the render pool pruned to its cap | form · *corpus* | +| `pool verify [--sample N] [--all]` | the render pool's files checked | form · queued · *corpus* | +| `trailer <project> [--take TAKE] [--reel REEL] [--beats BEATS] [--beats-json JSON] [--intro] [--finale N] [--xfade N] [--no-snap] [--out OUT] [--dry-run] [--candidates] [--vertical] [--layout reframe]` | a trailer or beat reel cut from a take's master | form · queued · *project* | +| `vertical <project> --take TAKE [--reel REEL] [--beats BEATS] [--items ITEMS] [--clip full\|framed\|quote] [--post card\|stack\|media] [--side split\|overlay] [--hook HOOK] [--captions l\|xl] [--lines 1\|2] [--loudness N] [--max N] [--name NAME] [--reframe] [--dry-run] [--intro] [--no-intro] [--no-outro]` | a vertical short (1080x1920) of a take's items | form · queued · *project* | +| `trailer-beats <project> ls [--reel REEL]` | a reel's beats against its limit | form · *project* | +| `trailer-beats <project> add <clip> [<span>] [--at N] [--label LABEL] [--take TAKE] [--reel REEL]` | a clip beat | form · *project* | +| `trailer-beats <project> add-raw <at> <dur> [--at N] [--label LABEL] [--reel REEL]` | a beat of master seconds | form · *project* | +| `trailer-beats <project> set <n> <span> [--label LABEL] [--reel REEL]` | beat n's source seconds | form · *project* | +| `trailer-beats <project> gap <n> add\|remove\|clear [<value>] [--reel REEL]` | seconds cut out of beat n's middle | form · *project* | +| `trailer-beats <project> remove <n> [--reel REEL]` | a beat out | form · *project* | +| `trailer-beats <project> move <n> --to N [--reel REEL]` | a beat to another place | form · *project* | +| `trailer-beats <project> order [--reel REEL]` | the beats in the cut's order | form · *project* | +| `trailer-beats <project> limit <limit> [--reel REEL]` | the running length's limit | form · *project* | +| `trailer-beats <project> xfade <seconds> [--reel REEL]` | the crossfade's seconds | form · *project* | +| `trailer-beats <project> intro <value> [--reel REEL]` | the reel's intro | form · *project* | +| `trailer-beats <project> outro <value> [--reel REEL]` | the card the reel ends on | form · *project* | +| `trailer-beats <project> candidates [--add] [--reel REEL]` | the walk's ★ clips not yet beats | form · *project* | +| `trailer-beats <project> verdict <n> confirmed\|note\|clear [--reel REEL]` | the walk's word on beat n | form · *project* | +| `trailer-beats <project> title <text> [--reel REEL]` | the reel's name | form · *project* | +| `trailer-beats <project> take <take> [--reel REEL]` | the take the reel is cut from | form · *project* | +| `trailer-beats <project> undo [--reel REEL]` | the reel as it was before its last write | form · *project* | +| `trailer-beats <project> status [--take TAKE] [--reel REEL]` | each beat against the take the reel plays now | form · *project* | +| `trailer-beats <project> anchor [<beats>…] --take TAKE [--reel REEL]` | beats anchored to a take's master | form · *project* | +| `trailer-beats <project> clamp <n> [--take TAKE] [--reel REEL]` | a clipped beat pulled inside its clip | form · *project* | +| `trailer-beats <project> repoint <n> <clip> [--take TAKE] [--reel REEL]` | an orphan beat's seconds on another clip | form · *project* | +| `trailer-beats <project> history [--reel REEL]` | every write to the reel | form · *project* | +| `trailer-beats <project> reels [--reel REEL]` | the project's reels | form · *project* | +| `trailer-beats <project> new-reel <name> [--from FROM] [--title TITLE] [--reel REEL]` | a new reel, empty or a copy | form · *project* | +| `tighten <project> [--all] [--no-measure] [--apply APPLY]` | each clip to its sentence, each edge into its pause | form · *draft* | +| `ledger <project> ls [--scope SCOPE] [--population POPULATION]` | a measure ledger's rows | form · *project* | +| `ledger <project> add <id> [--key value…] [--date DATE] [--scope SCOPE] [--population POPULATION] [--value VALUE] [--scopeBasis SCOPEBASIS] [--row JSON]` | a ledger row, checked against its schema | form · *draft* | +| `ledger <project> set <id> --key value… [--unset UNSET]` | a ledger row's keys | form · *draft* | +| `ledger <project> rm <id>` | a ledger row removed (refused while something names it) | form · *draft* | +| `measure <project> [--take TAKE] [--scopes SCOPES] [--scale SCALE] [--as-of AS-OF]` | the measure slice the instruments draw from | form · *project* | +| `rulings <project> show` | each montage clip and its ruling | form · *project* | +| `rulings <project> import [--dry-run]` | the earlier rulings in the seed's edits.json | form · *draft* | +| `rulings <project> set <clip> keep\|cut\|not-him\|read-aloud [--reason REASON] [--match MATCH]` | a montage clip's ruling | form · *draft* | +| `rulings <project> clear <clip>` | a montage clip's ruling cleared | form · *draft* | +| `fetch <project> [--dry-run] [--wait] [--status] [--body] [--reason REASON] [--refetch REFETCH] [--refetch-video REFETCH-VIDEO] [--take TAKE]` | the clip windows, asked of the editor | form · *project* | +| `prep <project> [--clips CLIPS] [--wait] [--status] [--take TAKE]` | the bench's excerpts and waveforms, before the walk | form · queued · *project* | +| `prune [<project>] [--all] [--take TAKE] [--anyway] [--keep N] [--older-than OLDER-THAN] [--idle-work IDLE-WORK] [--versions] [--idle IDLE] [--grace GRACE] [--yes]` | takes' work files freed by policy (a dry run unless --yes) | form · *project* | +| `fallback <project> [--dry-run] [--clip CLIP…] [--restore RESTORE]` | stand-ins for refused montage windows | form · *draft* | +| `phrases <phrases>… --channels CHANNELS [--prefer PREFER] [--exclude EXCLUDE] [--words] [--regex] [--samples N] [--no-cache] [--full]` | how often each phrase was said, by year | form · *corpus* | +| `voice-match <project> [--reference auto\|rulings\|recordings] [--reference-video REFERENCE-VIDEO…] [--reference-channel REFERENCE-CHANNEL…] [--instances INSTANCES] [--span phrase\|cut] [--pad N] [--likely N] [--unlikely N] [--dry]` | a speaker-similarity score per montage clip | form · queued · *project* | +| `clips analyze <project> [--from FROM] [--rescan] [--no-laughs] [--no-voices] [--target N] [--laugh-min N] [--merge-gap N] [--setup-max N] [--clip-max N] [--words WORDS] [--keep-cut] [--scope SCOPE] [--segment SEGMENT]` | the clip finder's scans on a long recording, then proposals | form · queued · *draft* | +| `clips propose <project> [--from FROM] [--host N] [--target N] [--laugh-min N] [--merge-gap N] [--setup-max N] [--clip-max N] [--words WORDS] [--keep-cut] [--dry]` | the clip finder's proposals again, from what is there | form · *draft* | +| `clips show <project>` | the speakers, the laughs, what is in the cut | form · *project* | +| `clips segments <project>` | the narrated-video spans auto-scope finds | form · *project* | +| `refresh [<article>] [--iteration N] [--no-fetch] [--yes] [--check] [--force]` | re-fetch an article's scope: the plan, and --yes starts it | form · *corpus* | +| `clip <spec> [--snap words] [--title TITLE] [--site SITE] [--folder FOLDER]` | quick clip: one moment to a basic-mode mp4 and its share line | form · queued · *corpus* | +| `share <project> [<clip>] [--take TAKE] [--site SITE]` | a clip's share line | form · *project* | +| `timeline <project> ls [--take TAKE]` | the cut: index, id, type, video, start–end | form · *project* | +| `timeline <project> insert <spec> [--after AFTER] [--to-section N] [--group GROUP] [--id ID] [--section N] [--lock] [--lock-end] [--title TITLE] [--stream-title STREAM-TITLE] [--date DATE] [--quote QUOTE] [--cite N] [--cite-url CITE-URL] [--take TAKE]` | a clip (or a post item) into the cut | form · *draft* | +| `timeline <project> move <id> --to N [--take TAKE]` | an entry to an index | form · *draft* | +| `timeline <project> place <ids>… --before BEFORE [--section N]` | entries before another (Play's drag) | form · *draft* | +| `timeline <project> remove <id> [--at N] [--take TAKE]` | an entry out of the cut | form · *draft* | +| `timeline <project> duplicate <id> [--at N]` | an entry twice | form · *draft* | +| `timeline <project> reject <id> not-matching\|wrong-speaker\|irrelevant\|repeats\|weak\|privacy\|other [--note NOTE]` | an entry rejected and removed, on the record | form · *draft* | +| `timeline <project> wrong-speaker <id> [--correction CORRECTION]` | an entry removed: the wrong speaker | form · *draft* | +| `timeline <project> post <post>` | a post added, or the one with its id replaced | form · *draft* | +| `timeline <project> post-remove <id>` | a post out of the cut | form · *draft* | +| `timeline <project> teaser <id> <patch>` | a teaser's lines, beat, dip, tail | form · *draft* | +| `timeline <project> undo [--take TAKE]` | the newest automatic snapshot back | form · *draft* | +| `timeline <project> sections` | the deck's sections and their clips | form · *project* | +| `timeline <project> section-move <ids>… --to-section N [--start]` | clips to the end (or start) of section N | form · *draft* | +| `timeline <project> section-add --after AFTER [--label LABEL] [--color COLOR] [--level 1\|2]` | a new section after a clip | form · *draft* | +| `timeline <project> section-boundary <marker> --after AFTER` | a section boundary dragged | form · *draft* | +| `timeline <project> section-remove <marker>` | a section's marker removed | form · *draft* | +| `timeline <project> section-set <marker> [--label LABEL] [--color COLOR] [--level 1\|2]` | a section's label, colour or level | form · *draft* | +| `timeline <project> split <id> <second>` | a clip in two at a source second | form · *draft* | +| `timeline <project> flash-forward <id> <span> [--after AFTER] [--to-section N] [--start] [--move] [--quote QUOTE] [--id ID]` | a tight copy of a span elsewhere, as a repeat | form · *draft* | +| `timeline <project> order <order>…` | the cut's order in one write | form · *draft* | +| `timeline <project> threads [--write] [--conversation CONVERSATION]` | the cut's conversations (and --write gathers them) | form · *draft* | +| `timeline <project> groups` | the claim groups, by section | form · *project* | +| `timeline <project> groups import <file> [--skip-missing] [--drop-empty]` | a claim-groups file in one write | form · *draft* | +| `timeline <project> groups set <gid> <ids>… [--claim CLAIM]` | a group is these clips | form · *draft* | +| `timeline <project> groups label <gid> <claim>` | a group's claim | form · *draft* | +| `timeline <project> groups remove <gid>` | a group dissolved (its clips stay) | form · *draft* | +| `timeline <project> groups move <gid> --to TO` | a whole group to another place | form · *draft* | +| `timeline <project> groups promote <gid> [--label LABEL]` | a group opens a subsection | form · *draft* | +| `timeline <project> add-video <src> [--from N] [--to N] [--fit contain\|cover] [--bass N] [--gain N] [--enter ENTER] [--hold N] [--title TITLE] [--id ID] [--after AFTER] [--dry-run] [--take TAKE]` | a video entry: a project file full frame | form · *draft* | +| `timeline <project> set-video <id> key=value… [--take TAKE]` | a video entry's knobs | form · *draft* | +| `scenes <project> <clip> [--black-min N] [--threshold N] [--pix-th N] [--pad N] [--from N] [--to N]` | scene cuts and black spans in a clip's fetched window | form · *project* | +| `posts add <project> <post> [--attach ATTACH] [--flag FLAG] [--author AUTHOR] [--id ID] [--thread] [--crop N] [--dry-run]` | a post card from the posts archive | form · *draft* | +| `posts set <project> <post> key=value…` | the Posts table's writer: thread, hide, attach, crop | form · *draft* | +| `posts reel <project> --channel CHANNEL… [--since SINCE] [--until UNTIL] [--own] [--with-media] [--replies include\|only\|exclude] [--order chrono\|reverse] [--limit N] [--after AFTER] [--dry-run]` | post items from posts channels, in one write | form · *draft* | +| `posts set-item <project> <item> key=value… [--in-take IN-TAKE]` | a post item's knobs | form · *draft* | +| `posts narrate <project> [<item>] [key=value…] [--script SCRIPT] [--take] [--note NOTE] [--voice VOICE] [--engine ENGINE] [--speed N] [--pick N] [--approve] [--unapprove] [--off] [--on] [--thread] [--parents PARENTS] [--words] [--import] [--list] [--all] [--draft-scripts] [--limit N] [--force] [--recording RECORDING] [--as AS] [--dry-run] [--in-take IN-TAKE]` | a post item's narration: script, takes, pick, approve, mix | form · queued · *draft* | +| `posts say <project> ls\|add\|remove\|try\|stale [<word>] [<spoken>] [--case] [--item ITEM] [--note NOTE]` | the pronunciation lexicon | form · *draft* | +| `posts voices <project> ls\|set\|remove [<handle>] [<voice>]` | the voice map a thread read uses | form · *draft* | +| `posts fit <project> [<items>…] [--all] [--linger N] [--dry-run]` | narrated posts' videos cut to their best part | form · queued · *draft* | +| `posts fx <project> <item> ls\|add\|set\|remove [<what>] [--key value…] [--in-take IN-TAKE]` | a post item's word zooms, captions, clock, slams | form · *draft* | +| `posts clock <project> [on\|off\|default] [--zone ZONE]` | the cut's clock default | form · *draft* | +| `posts progress <project> [auto\|on\|off\|default]` | the cut's progress bar default | form · *draft* | +| `posts avatar <project> [<handle>] [<image>]` | an author's picture on the cards | form · *draft* | +| `posts avatars <project> [--dry-run]` | the authors' pictures from the archive | form · *draft* | +| `posts redact <project> ls\|add\|remove [<value>] [--substring] [--note NOTE]` | words blanked from what is published | form · *draft* | +| `posts slurs <project> ls\|on\|off\|level\|visual\|voice\|add\|except\|remove\|edges [<value>] [--off]` | the slur filter | form · *draft* | +| `posts context <project> [--dry-run]` | each post item's context from its capture | form · *draft* | +| `posts repeats <project> [--match id\|file\|audio]` | the attachments played more than once | form · *project* | +| `posts combo <project> [<item>] [key=value…]` | the combo badge's knobs (the cut's, or one item's) | form · *draft* | +| `posts attach <project> [<items>…] [--all] [--dry-run]` | a capture's media onto post items that carry none | form · *draft* | +| `posts scenes <project> [on\|off]` | the media scenes (and the cut's on/off) | form · *draft* | +| `posts picture-reply <project> [key=value…] [--in-take IN-TAKE]` | the cut's picture-only rule | form · *draft* | +| `posts roles <project> [<items>…] [--write] [--set SET] [--in-take IN-TAKE]` | a read's pieces, stored or inferred | form · *draft* | +| `posts reread <project> <item> [--without WITHOUT] [--drop-parts DROP-PARTS] [--drop-urls] [--tempo-for TEMPO-FOR] [--tempo N] [--parts PARTS] [--stretch atempo\|rubberband] [--yell-caps] [--yell-gain N] [--yell-style raise\|shout\|loud] [--pause PAUSE] [--target TARGET] [--revoice REVOICE] [--say SAY] [--voice VOICE] [--xfade N] [--splice SPLICE] [--dry-run] [--in-take IN-TAKE]` | a read re-joined, re-timed, paused or a phrase re-voiced | form · queued · *draft* | +| `posts yell <project> [<items>…] [--all] [--yell-gain N] [--yell-style raise\|shout\|loud] [--dry-run]` | the caps he wrote, yelled in the read | form · queued · *draft* | +| `candidates <project> ls [--all]` | the proposed clips waiting on the Candidates panel | form · *project* | +| `candidates <project> import <file> [--dry-run]` | a sweep's bullets as candidates | form · *project* | +| `candidates <project> add <proposal>` | an agent's proposal(s) as candidates | form · *project* | +| `ingredient <recording> [--window WINDOW] [--used-in]` | one recording's (or clip window's) life cycle: found to published | form · *corpus* | +| `help` | every command | none: prints the command list: the palette's Commands are the same list | +<!-- verbs:end --> A project argument is an exact id, a directory, or a **unique** basename. Two projects answering to one name is reported, never resolved by picking one. diff --git a/umtool/docs/knobs.md b/umtool/docs/knobs.md @@ -1739,6 +1739,46 @@ The files: `<out>/<slug>.<name>.mp4` and `<out>/variants.json`; `<out>` is the p `preview.mp4`); a take with only its `preview.mp4` is encoded from that (`--source`). A flagged clip is fixed with its `audio.offset` (the sign: a clip whose sound is early, a negative lag, needs a positive offset), then a build. +## ⌘K commands (every verb a form) + +The other way round: every `umtool` verb the registry (`umtool/lib/cli/verbs.mjs`) marks `ui: "form"` is a form in +the ⌘K palette, so a verb with no button of its own still has a UI path. + +| What | In umtool | From a terminal | Over HTTP | +|---|---|---|---| +| the verbs | ⌘K, type (`>` first: commands only); each row `umtool <verb>` and what it does | `umtool help`; [cli.md](cli.md), "Every verb" | `GET /api/cli` (`verbs`) | +| one verb's form | choose it: its arguments, the page's project (and the clip, post or take its address names) filled in | the line under the form, **Copy as CLI** | — | +| run it | **Run** (a verb that renders: **Queue it**, the durable queue): its state and live log under the form | that line | `POST /api/cli {verb, values}` from the app's own page only; `GET /api/cli?job=<id>` / `?qid=<qid>` | + +The server builds the argv from the row's schema (`lib/cli/argv.mjs`, the same function the Copy as CLI line comes +from) and refuses a verb with no form (`ui: "none"`, its reason in cli.md), a value its schema refuses, a page of +another site, and a body carrying a raw argv -- `app/api/queue/route.ts` still never adds a step from a page. A new +verb gets its row there (`verbs.test.mjs` fails, naming it, until it has one) and its help lines in +`lib/cli/groups.mjs`; `node umtool/lib/cli/docs.mjs` rewrites cli.md's generated section. + +What a form may name, and what it asks first: + +- **Files.** An output (`trailer --out`, a take's `--id`, a reel, `--name`) is a bare name, never a directory or + `..`; the CLI writes it where it writes its own. An input file (`take --patch`, `trailer --beats`, `modules apply + --config`, `candidates import`, `timeline groups import`, `posts narrate --recording`, …) is a file of the + project, relative to its directory: the server runs it only when its realpath (symlinks followed) is inside the + project's, as that absolute path (`lib/cli/confine.mjs`). `@file`, and a key=value whose value is `@…`, `/…`, + `~/…` or climbs out with `..`, are a terminal's; `new --from` takes a share URL or `<channel>/<id>`, never a + report.md. `vertical --out` and `voice-match --out` (any path) are terminal-only. +- **No undo.** A verb that deletes, evicts or kills (`prune --yes`, `pool prune`, `index --prune`, `takes freeze + --apply`, `takes make --force`, `take --force`, `queue cancel`, `takes cancel`, `render-mode off --force`, `notes + resolve`/`wontfix`, `notes reply --resolve`, `ledger rm`, `fetch --refetch`, `refresh --yes`, `speaker-check + --remove`, `preset save --force`) asks a second press, **Yes, <what it does>**; `POST /api/cli` wants + `confirm: true` and answers 409 without it. +- **This machine only.** A write from a page (`POST /api/cli`, and the draft's **Save version** / **Open in + draft**: `lib/report/sameOrigin.mjs`) is refused when its Host, its X-Forwarded-Host or its Origin is not this + machine -- `localhost`, `*.localhost`, `127.x`, `::1` -- so a page whose DNS name is re-pointed at 127.0.0.1 (DNS + rebinding) cannot drive it. `UMTOOL_ALLOWED_HOSTS=name,name` (host names, no ports) adds the names a proxy in front + of umtool serves it as. `POST /api/cli` also refuses a request with no Origin and no `Sec-Fetch-Site` (a terminal + runs the command itself). +- **Runs.** What a form started stays under **Runs** in the palette (nothing typed) for the page's life: an Escape + mid-run loses nothing. The same queued command sent twice within 5 s is the one step. + ## Reading them back `umtool show <p>` prints a **knobs** block — each clip's claim knobs, audio and blur (which clip stamps), the stamp's diff --git a/umtool/e2e/palette.spec.ts b/umtool/e2e/palette.spec.ts @@ -0,0 +1,259 @@ +import { test, expect, type Page } from "@playwright/test"; +import { readFileSync, writeFileSync } from "node:fs"; +import path from "node:path"; +import { fileURLToPath } from "node:url"; +import * as urls from "./urls"; + +// --------------------------------------------------------------------------- +// ⌘K COMMANDS (umtool redesign, lane palette L8a): the verb registry's forms in +// the palette. ⌘K on a project's page, "look" -> the `umtool look` form, the +// project filled in from the page -> mode=basic -> Copy as CLI is the exact +// line -> Run: the job's log, done, and the manifest changed. On a clip bench +// the clip is filled in too. POST /api/cli refuses a ui:"none" verb (absent +// from the palette), a raw argv, a value its schema refuses and a request no +// page of this app made; a verb that renders goes through the durable queue. +// Fixture: e2e/fixtures/basic-mode-fixture.mjs (basic-fixture, a deck cut); +// the spec puts its manifest back. E2E_PALETTE_SHOTS=<dir>: screenshots there (1366x768). +// --------------------------------------------------------------------------- + +const HERE = path.dirname(fileURLToPath(import.meta.url)); +const PROJECT = "reports/basic-fixture"; +const MANIFEST = path.join(HERE, "..", ".e2e-song", "reports", "basic-fixture", "video.manifest.json"); +const SHOTS = process.env.E2E_PALETTE_SHOTS ?? ""; +const original = readFileSync(MANIFEST, "utf8"); +const manifest = () => JSON.parse(readFileSync(MANIFEST, "utf8")); +const shot = async (page: Page, name: string) => { + if (SHOTS) await page.screenshot({ path: path.join(SHOTS, `${name}.png`) }); +}; +const palette = (page: Page) => page.locator("dialog[data-jump]"); +const open = async (page: Page) => { + await expect(page.locator("dialog[data-jump][data-ready]")).toBeAttached({ timeout: 60_000 }); + await page.keyboard.press("Control+k"); + await expect(palette(page)).toBeVisible(); +}; + +test.beforeEach(() => writeFileSync(MANIFEST, original)); +test.afterAll(() => writeFileSync(MANIFEST, original)); + +test("⌘K → look → its form, the project from the page → Copy as CLI → Run: the manifest changed", async ({ page, context }) => { + test.setTimeout(180_000); + await context.grantPermissions(["clipboard-read", "clipboard-write"]); + await page.setViewportSize({ width: 1366, height: 768 }); + await page.goto(urls.section(PROJECT, "build")); + await open(page); + + // Typed words find the verb among the places; > is commands only. + await page.keyboard.type("look"); + const row = palette(page).locator("[data-jump-item='cmd:look']"); + await expect(row).toBeVisible({ timeout: 30_000 }); + await expect(row).toContainText("umtool look"); + // A verb with no form is not offered. + await page.locator("[data-jump-input]").fill(">help"); + await expect(palette(page).locator("[data-jump-item='cmd:help']")).toHaveCount(0); + await page.locator("[data-jump-input]").fill(">teaser"); + await expect(palette(page).locator("[data-jump-item='cmd:timeline teaser']")).toBeVisible(); + await page.locator("[data-jump-input]").fill(">look"); + await expect(palette(page).locator("[role=option][aria-selected=true]")).toHaveAttribute("data-jump-item", "cmd:look"); + await page.keyboard.press("Enter"); + + const form = palette(page).locator("[data-cli-form='look']"); + await expect(form).toBeVisible(); + await expect(form.locator("[data-cli-arg='project'] input")).toHaveValue(PROJECT); + // Required settings missing: no line, no Run. + await expect(form.locator("[data-cli-invalid]")).toContainText("settings is required"); + await expect(form.locator("[data-cli-run]")).toBeDisabled(); + await form.locator("[data-cli-arg='settings'] textarea").fill("mode=basic"); + const line = `node umtool/bin/umtool.mjs look ${PROJECT} mode=basic`; + await expect(form.locator("[data-cli-line]")).toHaveText(line); + await form.locator("[data-cli-copy]").click(); + await expect(form.locator("[data-cli-copy]")).toHaveText("Copied"); + expect(await page.evaluate(() => navigator.clipboard.readText())).toBe(line); + const box = await palette(page).boundingBox(); + expect(box!.y + box!.height, "the form fits 1366×768").toBeLessThanOrEqual(768); + await shot(page, "palette-form"); + + expect(manifest().render.mode ?? "deck").not.toBe("basic"); + await form.locator("[data-cli-run]").click(); + await expect(form.locator("[data-cli-state]")).toHaveAttribute("data-cli-state", "done", { timeout: 90_000 }); + await expect(form.locator("[data-cli-log]")).toContainText(`look ${PROJECT} mode=basic`); + expect(manifest().render.mode).toBe("basic"); + await shot(page, "palette-run-done"); + + // Back to the list. + await form.locator("[data-cli-back]").click(); + await expect(palette(page).locator("[data-jump-input]")).toBeFocused(); +}); + +test("on a clip bench the clip is filled in; a refused value says why", async ({ page }) => { + test.setTimeout(120_000); + await page.setViewportSize({ width: 1366, height: 768 }); + await page.goto(urls.clipBenchHref(PROJECT, "c01")); + await open(page); + await page.keyboard.type(">window"); + await expect(palette(page).locator("[role=option][aria-selected=true]")).toHaveAttribute("data-jump-item", "cmd:window", { timeout: 30_000 }); + await page.keyboard.press("Enter"); + const form = palette(page).locator("[data-cli-form='window']"); + await expect(form.locator("[data-cli-arg='project'] input")).toHaveValue(PROJECT); + await expect(form.locator("[data-cli-arg='clip'] input")).toHaveValue("c01"); + await form.locator("[data-cli-arg='--title'] input").fill("A palette title"); + await expect(form.locator("[data-cli-line]")).toHaveText(`node umtool/bin/umtool.mjs window ${PROJECT} c01 --title 'A palette title'`); + await form.locator("[data-cli-arg='--start'] input").fill("soon"); + await expect(form.locator("[data-cli-invalid]")).toContainText("--start: a number"); + await shot(page, "palette-clip-form"); +}); + +test("POST /api/cli runs only registry form verbs, from this app's pages, with values its schema allows", async ({ page }) => { + test.setTimeout(120_000); + await page.goto(urls.homeHref()); + const origin = new URL(page.url()).origin; + const post = (data: unknown, headers: Record<string, string> = { origin }) => page.request.post("/api/cli", { data, headers }); + const said = async (r: Awaited<ReturnType<typeof post>>) => ((await r.json()) as { error?: string }).error ?? ""; + + // The list the palette is built from: forms only. + const list = (await (await page.request.get("/api/cli")).json()) as { verbs: Array<{ verb: string }> }; + const verbs = list.verbs.map((v) => v.verb); + expect(verbs).toContain("look"); + expect(verbs).toContain("timeline insert"); + expect(verbs).not.toContain("help"); + expect(verbs).not.toContain("queue add"); + expect(verbs).not.toContain("takes delete"); + + // A ui:"none" verb. + let r = await post({ verb: "queue add", values: {} }); + expect(r.status()).toBe(400); + expect(await said(r)).toContain("has no form"); + // A raw argv, in any spelling. + for (const body of [{ argv: ["look", PROJECT, "mode=basic"] }, { verb: "look", argv: ["--json"] }, { verb: "look", values: {}, cmd: "rm -rf /" }]) { + r = await post(body); + expect(r.status(), JSON.stringify(body)).toBe(400); + } + // A value its schema refuses, an arg it does not have, a project there is not. + r = await post({ verb: "look", values: { project: PROJECT, settings: "--unset render.rail" } }); + expect(r.status()).toBe(400); + r = await post({ verb: "look", values: { project: PROJECT, settings: "mode=basic", "--json": true } }); + expect(r.status()).toBe(400); + expect(await said(r)).toContain('takes no "--json"'); + r = await post({ verb: "show", values: { project: "reports/no-such-project" } }); + expect(r.status()).toBe(400); + expect(await said(r)).toContain("no project matches"); + // Not a page of this app: another site, and no page at all. + r = await post({ verb: "show", values: { project: PROJECT } }, { origin: "https://evil.example" }); + expect(r.status()).toBe(403); + r = await post({ verb: "show", values: { project: PROJECT } }, {}); + expect(r.status()).toBe(403); + expect(manifest().render.mode ?? "deck", "nothing refused wrote").not.toBe("basic"); + + // A read, as one job: its log is the command's output. + r = await post({ verb: "show", values: { project: PROJECT } }); + expect(r.status()).toBe(202); + const { job, line } = (await r.json()) as { job: { id: string }; line: string }; + expect(line).toBe(`node umtool/bin/umtool.mjs show ${PROJECT}`); + await expect + .poll(async () => ((await (await page.request.get(`/api/cli?job=${job.id}`)).json()) as { job: { state: string } }).job.state, { timeout: 60_000 }) + .toBe("done"); + const shown = (await (await page.request.get(`/api/cli?job=${job.id}`)).json()) as { job: { log: string[] } }; + expect(shown.job.log.join("\n")).toContain("The Basic Fixture"); + + // A verb that renders (or holds the heavy slot) is a step of the durable queue; the same one asked + // again at once (a double Enter) is that step. + r = await post({ verb: "prep", values: { project: PROJECT, "--status": true } }); + expect(r.status()).toBe(202); + const { queued } = (await r.json()) as { queued: { qid: string } }; + expect(queued.qid).toMatch(/^q\d+$/); + const again = await post({ verb: "prep", values: { project: PROJECT, "--status": true } }); + expect(again.status()).toBe(200); + expect(((await again.json()) as { queued: { qid: string }; deduped: boolean })).toMatchObject({ queued: { qid: queued.qid }, deduped: true }); + await expect + .poll(async () => ((await (await page.request.get(`/api/cli?qid=${queued.qid}`)).json()) as { step: { state: string } }).step.state, { timeout: 90_000 }) + .toBe("done"); +}); + +test("POST /api/cli: files stay in the project, @file is a terminal's, no-undo verbs want confirm, and a rebound host is refused", async ({ page }) => { + test.setTimeout(120_000); + await page.goto(urls.homeHref()); + const origin = new URL(page.url()).origin; + const post = (data: unknown, headers: Record<string, string> = { origin }) => page.request.post("/api/cli", { data, headers }); + const said = async (r: Awaited<ReturnType<typeof post>>) => ((await r.json()) as { error?: string }).error ?? ""; + + // An output is a bare name; an input a file of the project, by its realpath; @file is refused. + let r = await post({ verb: "trailer", values: { project: PROJECT, "--take": "t1", "--out": "../../escape.mp4" } }); + expect(r.status()).toBe(400); + expect(await said(r)).toContain("bare name"); + for (const patch of ["../../../../etc/passwd", "/etc/passwd"]) { + r = await post({ verb: "take", values: { project: PROJECT, "--id": "t1", "--patch": patch, "--draft": true } }); + expect(r.status(), patch).toBe(400); + expect(await said(r)).toMatch(/not a file of the project|no such file in the project/); + expect(await said(r)).not.toContain("root:"); + } + r = await post({ verb: "candidates add", values: { project: PROJECT, proposal: "@/etc/passwd" } }); + expect(r.status()).toBe(400); + expect(await said(r)).toContain("terminal only"); + r = await post({ verb: "posts set-item", values: { project: PROJECT, item: "c01", settings: "parent.0=@/etc/passwd" } }); + expect(r.status()).toBe(400); + + // No undo: 409 until confirmed. + r = await post({ verb: "prune", values: { project: PROJECT, "--yes": true } }); + expect(r.status()).toBe(409); + expect(((await r.json()) as { confirm?: string }).confirm).toContain("delete"); + r = await post({ verb: "prune", values: { project: PROJECT, "--yes": true }, confirm: true }); + expect(r.status()).toBe(202); + const { job } = (await r.json()) as { job: { id: string } }; + await expect.poll(async () => ((await (await page.request.get(`/api/cli?job=${job.id}`)).json()) as { job: { state: string } }).job.state, { timeout: 60_000 }).not.toBe("running"); + + // DNS rebinding: a name that is not this machine, as the forwarded host or the origin. + const port = new URL(origin).port; + r = await post({ verb: "show", values: { project: PROJECT } }, { origin, "x-forwarded-host": `rebind.example:${port}` }); + expect(r.status()).toBe(403); + r = await post({ verb: "show", values: { project: PROJECT } }, { origin: `http://rebind.example:${port}`, "x-forwarded-host": `rebind.example:${port}` }); + expect(r.status()).toBe(403); + expect(await said(r)).toContain("UMTOOL_ALLOWED_HOSTS"); +}); + +test("a no-undo verb asks a second press; a run outlives Escape (Runs); a client-side move leaves no stale project", async ({ page }) => { + test.setTimeout(180_000); + await page.setViewportSize({ width: 1366, height: 768 }); + await page.goto(urls.section(PROJECT, "build")); + await open(page); + await page.keyboard.type(">prune"); + await expect(palette(page).locator("[role=option][aria-selected=true]")).toHaveAttribute("data-jump-item", "cmd:prune", { timeout: 30_000 }); + await page.keyboard.press("Enter"); + const form = palette(page).locator("[data-cli-form='prune']"); + await expect(form.locator("[data-cli-arg='project'] input")).toHaveValue(PROJECT); + await form.locator("[data-cli-arg='--yes'] input").check(); + await form.locator("[data-cli-run]").click(); + const confirm = form.locator("[data-cli-confirm]"); + await expect(confirm).toContainText("Yes, delete those work files"); + await expect(form.locator("[data-cli-state]")).toHaveCount(0); + await shot(page, "palette-confirm"); + await confirm.click(); + await expect(form.locator("[data-cli-state]")).toHaveAttribute("data-cli-state", /done|failed/, { timeout: 90_000 }); + + // A read started, then Escape: it is under Runs, and opens on its log. + await form.locator("[data-cli-back]").click(); + await page.locator("[data-jump-input]").fill(">show"); + await expect(palette(page).locator("[role=option][aria-selected=true]")).toHaveAttribute("data-jump-item", "cmd:show"); + await page.keyboard.press("Enter"); + const show = palette(page).locator("[data-cli-form='show']"); + await show.locator("[data-cli-run]").click(); + await page.keyboard.press("Escape"); + await expect(palette(page)).toBeHidden(); + await page.keyboard.press("Control+k"); + const runs = palette(page).locator("[data-jump-item^='run:job-']"); + await expect(runs).toHaveCount(2); + await expect(runs.first()).toContainText("umtool show"); + await runs.first().click(); + await expect(show.locator("[data-cli-state]")).toHaveAttribute("data-cli-state", "done", { timeout: 60_000 }); + await expect(show.locator("[data-cli-log]")).toContainText("The Basic Fixture"); + + // A jump to the Inbox (a client-side move: the palette stays mounted), then a form at once: no project. + await show.locator("[data-cli-back]").click(); + await page.locator("[data-jump-input]").fill("inbox"); + await expect(palette(page).locator("[role=option][aria-selected=true]")).toHaveAttribute("data-jump-item", "inbox"); + await page.keyboard.press("Enter"); + await expect(page).toHaveURL(/\/$/); + await page.keyboard.press("Control+k"); + await page.keyboard.type(">look"); + await expect(palette(page).locator("[role=option][aria-selected=true]")).toHaveAttribute("data-jump-item", "cmd:look"); + await page.keyboard.press("Enter"); + await expect(palette(page).locator("[data-cli-form='look'] [data-cli-arg='project'] input")).toHaveValue(""); +}); diff --git a/umtool/lib/cli/argv.mjs b/umtool/lib/cli/argv.mjs @@ -0,0 +1,305 @@ +// A VERB ROW'S FORM, AS ARGV (lane palette, L8a): the one function that turns +// a row of the registry (lib/cli/verbs.mjs) and a form's values into the +// words `umtool` is run with -- on the server by POST /api/cli (which never +// takes argv from a page), and in the palette for its "Copy as CLI" line, so +// the line copied is the command that runs. +// +// Pure, no imports: the route, the page and node --test read it alike. + +/** How the copied line names the CLI: from the repository's root. */ +export const CLI_PREFIX = "node umtool/bin/umtool.mjs"; + +const STRING_MAX = 2000; +const TEXT_MAX = 50_000; +const LIST_MAX = 200; +const PAIR_KEY = /^[A-Za-z_*][\w.*[\]<>-]*$/; +const FLAG_KEY = /^[A-Za-z][\w-]*$/; +const NUMBER = /^-?(\d+\.?\d*|\.\d+)$/; +/** A bare file or id name: no directory, no `..`, no leading dot (`--out`, a take's id, a reel's name). */ +const BARE = /^[A-Za-z0-9_][\w.+-]*$/; +/** A `..` segment, a home or an absolute path inside a value: a page may not name a path outside the project. */ +const ESCAPES = /(^|[\\/])\.\.([\\/]|$)|^~[\\/]|^[\\/]/; +/** An `@file` reference anywhere in a value -- `@x`, `post-json:@x`, `a=@x`, `a,@x` (review, L8a): a CLI reads it. */ +const AT_REF = /(^|[:=,;])\s*['"]?@/; +/** A timeline entry's id (`timeline order`: an id, never a file the CLI would read from its cwd). */ +const ENTRY_ID = /^[A-Za-z0-9_][\w:-]*$/; +/** A share URL or a <channel>/<id> (`new --from` from a page: never a file). */ +const REF = /^(https?:\/\/\S+|[a-z0-9][a-z0-9_-]*\/[A-Za-z0-9_-]+)$/; + +const isFlag = (a) => a.name.startsWith("--"); +const isRun = (a) => a.type === "list" || a.type === "pairs" || a.type === "flagpairs"; + +/** A list-shaped value: an array, or lines of a textarea. */ +function linesOf(v) { + if (Array.isArray(v)) return v.map((x) => String(x).trim()).filter(Boolean); + if (typeof v === "string") return v.split(/\r?\n/).map((x) => x.trim()).filter(Boolean); + return null; +} + +/** Whether a form value is empty (left out of argv). */ +function absent(a, v) { + if (v === undefined || v === null || v === false) return true; + if (a.type === "boolean" && (v === "false" || v === "off" || v === "")) return true; + if (typeof v === "string") return a.type === "text" ? v.trim() === "" : v.trim() === ""; + if (Array.isArray(v)) return v.length === 0 || (isRun(a) && linesOf(v).length === 0); + return false; +} + +class FormError extends Error { + constructor(message, field) { + super(message); + this.field = field; + } +} + +/** One word of argv from a plain value: no NUL, bounded, and never read as a flag. */ +function word(a, raw, { what = a.name, max = STRING_MAX, strictAt = atStrict(a) } = {}) { + const s = String(raw); + if (s.includes("\0")) throw new FormError(`${what}: a NUL byte`, a.name); + if (s.length > max) throw new FormError(`${what}: longer than ${max} characters`, a.name); + // `-` alone is a value (`--after -`); a negative number is a value; anything else that starts with a + // dash would be read as a flag by umtool's parsers. + if (/^-./.test(s) && !NUMBER.test(s.trim())) throw new FormError(`${what}: a value may not start with "-" (it would be read as a flag)`, a.name); + // `@file` reads a file wherever it is: a terminal's, never a form's (paste what the file holds) -- at the start, + // or inside a value a CLI splits (`post-json:@…`, `a=@…`, `a,@…`). + if (strictAt && !a.allowAt && AT_REF.test(s)) throw new FormError(`${what}: @file reads a file -- from a terminal only; paste what it holds`, a.name); + return s; +} + +/** + * Whether an arg's values are checked for `@file` anywhere: a positional (the CLIs that read `@file` read it from + * a positional or a key=value), a list's items, a row's `atFile` arg. A flag's words and a positional's free prose + * (`text`, not atFile) are a person's words ("@grok said …"); `allowAt` is a handle (`@grok`) or a lexicon word. + */ +function atStrict(a) { + if (a.allowAt) return false; + if (a.atFile) return true; + if (a.type === "list" || a.type === "pairs") return true; + return !isFlag(a) && a.type !== "text"; +} + +/** A timeline entry's id: no dot, no slash -- never a file name. */ +function entryId(a, raw) { + const s = word(a, String(raw).trim()); + if (!ENTRY_ID.test(s)) throw new FormError(`${a.name}: "${s}" is not an entry's id`, a.name); + return s; +} + +/** A bare name: one word, no directory. */ +function bare(a, raw, what = a.name) { + const s = word(a, String(raw).trim(), { what }); + if (!BARE.test(s) || s.includes("..")) throw new FormError(`${what}: a bare name (letters, digits, . _ - +; no directory, no leading dot)`, a.name); + return s; +} + +/** A key=value value from a page: never `@file`, never a path out of the project. */ +function pairValue(a, value, what) { + const v = value.trim().replace(/^['"]/, ""); + if (AT_REF.test(v)) throw new FormError(`${what}: @file reads a file -- from a terminal only; paste what it holds`, a.name); + if (ESCAPES.test(v)) throw new FormError(`${what}: a path outside the project (.., ~ or /) -- from a terminal only`, a.name); + return value; +} + +/** One key=value word. */ +function pairWord(a, line) { + const at = line.indexOf("="); + const key = at > 0 ? line.slice(0, at).trim() : ""; + if (!PAIR_KEY.test(key)) throw new FormError(`${a.name}: "${line}" is not key=value`, a.name); + return word(a, `${key}=${pairValue(a, line.slice(at + 1), key)}`, { max: TEXT_MAX }); +} + +/** A share URL or a <channel>/<id>: never a file. */ +function refWord(a, raw) { + const s = word(a, raw); + if (!REF.test(s)) throw new FormError(`${a.name}: a share URL or <channel>/<id> (a file only from a terminal)`, a.name); + return s; +} + +/** The words one arg's value makes, flag included. */ +function wordsOf(a, v) { + const flag = isFlag(a) ? [a.name] : []; + switch (a.type) { + case "boolean": { + if (v === true || v === "true" || v === "on") return flag; + throw new FormError(`${a.name}: on or off`, a.name); + } + case "number": { + const s = String(v).trim(); + if (!NUMBER.test(s) || !Number.isFinite(Number(s))) throw new FormError(`${a.name}: a number`, a.name); + return [...flag, s]; + } + case "choice": { + const s = String(v).trim(); + if (!(a.choices ?? []).includes(s)) throw new FormError(`${a.name}: one of ${(a.choices ?? []).join(", ")}`, a.name); + return [...flag, s]; + } + case "json": { + const s = String(v); + try { + JSON.parse(s); + } catch { + throw new FormError(`${a.name}: not JSON`, a.name); + } + return [...flag, word(a, s, { max: TEXT_MAX })]; + } + case "text": + return [...flag, word(a, String(v), { max: TEXT_MAX })]; + case "project": + case "string": + return [...flag, word(a, String(v).trim())]; + case "name": + if (a.literals?.includes(String(v).trim())) return [...flag, String(v).trim()]; + return [...flag, bare(a, v)]; + case "path": { + // A file of the project, relative to its directory. The SERVER confines it (realpath inside the + // project: app/api/cli/route.ts) and runs it as the absolute path it found; here it is one word. + const s = word(a, String(v).trim()); + if (a.literals?.includes(s)) return [...flag, s]; + if (s.startsWith("@")) throw new FormError(`${a.name}: a file of the project, by its path (no @)`, a.name); + return [...flag, s]; + } + case "ref": + return [...flag, refWord(a, String(v).trim())]; + case "list": + case "pairs": + case "flagpairs": { + const lines = linesOf(v); + if (!lines) throw new FormError(`${a.name}: one value per line`, a.name); + if (lines.length > LIST_MAX) throw new FormError(`${a.name}: more than ${LIST_MAX} values`, a.name); + const out = []; + for (const line of lines) { + if (a.type === "list") { + const w = a.item === "id" ? entryId(a, line) : a.item === "name" ? bare(a, line) : a.item === "pair" ? pairWord(a, line) : a.item === "ref" ? refWord(a, line) : word(a, line); + out.push(...(isFlag(a) ? [a.name, w] : [w])); + continue; + } + const at = line.indexOf("="); + const key = at > 0 ? line.slice(0, at).trim() : ""; + if (a.type === "pairs") { + out.push(pairWord(a, line)); + } else { + if (!FLAG_KEY.test(key)) throw new FormError(`${a.name}: "${line}" is not key=value`, a.name); + out.push(`--${key}`, word(a, pairValue(a, line.slice(at + 1).trim(), `--${key}`), { what: `--${key}`, max: TEXT_MAX })); + } + } + return out; + } + default: + throw new FormError(`${a.name}: an arg of unknown type ${a.type}`, a.name); + } +} + +/** + * A row and a form's values to argv (the words after `umtool`). + * + * @param {{ verb: string, args: Array<Record<string, any>>, shape?: string }} row + * @param {Record<string, unknown>} values name -> string | number | boolean | string[] + * @returns {{ ok: true, argv: string[] } | { ok: false, error: string, field?: string }} + */ +export function buildArgv(row, values = {}) { + try { + if (!values || typeof values !== "object" || Array.isArray(values)) throw new FormError("the values are an object of name: value"); + const args = row.args ?? []; + const known = new Set(args.map((a) => a.name)); + for (const k of Object.keys(values)) if (!known.has(k)) throw new FormError(`umtool ${row.verb} takes no "${k}"`, k); + for (const k of Object.keys(values)) { + const v = values[k]; + const ok = v === null || ["string", "number", "boolean"].includes(typeof v) || (Array.isArray(v) && v.every((x) => typeof x === "string")); + if (!ok) throw new FormError(`${k}: a string, a number, on/off or a list of strings`, k); + } + const given = (a) => !absent(a, values[a.name]); + for (const a of args) if (a.required && !given(a)) throw new FormError(`${a.name} is required`, a.name); + + // An empty optional positional before a given one would shift every word after it. + const positionals = args.filter((a) => !isFlag(a)); + const plain = positionals.filter((a) => a.type !== "pairs"); + for (let i = 0; i < plain.length; i += 1) { + if (!given(plain[i]) && plain.slice(i + 1).some(given)) { + throw new FormError(`${plain[i].name} is needed before ${plain.slice(i + 1).find(given).name}`, plain[i].name); + } + } + + const argv = []; + const placed = new Set(); + const shape = (row.shape ?? row.verb).split(/\s+/).filter(Boolean); + for (const t of shape) { + const m = /^<(.+)>$/.exec(t); + if (!m) { + argv.push(t); + continue; + } + const a = positionals.find((x) => x.name === m[1]); + if (!a) throw new FormError(`the shape of ${row.verb} names <${m[1]}>, which is not one of its args`); + placed.add(a.name); + if (given(a)) argv.push(...wordsOf(a, values[a.name])); + } + for (const a of positionals) if (!placed.has(a.name) && given(a)) argv.push(...wordsOf(a, values[a.name])); + for (const a of args) if (isFlag(a) && given(a)) argv.push(...wordsOf(a, values[a.name])); + return { ok: true, argv }; + } catch (e) { + if (e instanceof FormError) return { ok: false, error: e.message, ...(e.field ? { field: e.field } : {}) }; + throw e; + } +} + +/** A word as a POSIX shell reads it back. */ +export function shellQuote(s) { + const v = String(s); + if (v !== "" && /^[\w@%+=:,./-]+$/.test(v)) return v; + return `'${v.replace(/'/g, `'\\''`)}'`; +} + +/** The line to paste into a terminal at the repository's root. */ +export const cliLine = (argv) => [CLI_PREFIX, ...argv.map(shellQuote)].join(" "); + +/** The row's arguments as a usage line reads them: `<project> <clip> [--start N] [--lock]`. */ +export function synopsis(row) { + const args = row.args ?? []; + const meta = (a) => + a.type === "choice" ? (a.choices ?? []).join("|") : a.type === "number" ? "N" : a.type === "json" ? "JSON" : a.name.replace(/^--/, "").toUpperCase(); + const one = (a) => { + if (a.type === "pairs") return a.required ? "key=value…" : "[key=value…]"; + if (a.type === "flagpairs") return a.required ? "--key value…" : "[--key value…]"; + if (!isFlag(a)) { + const w = a.type === "choice" ? (a.choices ?? []).join("|") : `<${a.name}>`; + const s = a.type === "list" ? `${w}…` : w; + return a.required ? s : `[${s}]`; + } + const s = a.type === "boolean" ? a.name : `${a.name} ${meta(a)}${a.type === "list" ? "…" : ""}`; + return a.required ? s : `[${s}]`; + }; + const positionals = args.filter((a) => !isFlag(a)); + const placed = new Set(); + const head = (row.shape ?? row.verb).split(/\s+/).filter(Boolean).map((t) => { + const m = /^<(.+)>$/.exec(t); + const a = m && positionals.find((x) => x.name === m[1]); + if (!a) return t; + placed.add(a.name); + return one(a); + }); + return [...head, ...positionals.filter((a) => !placed.has(a.name)).map(one), ...args.filter(isFlag).map(one)].join(" "); +} + +/** + * Whether these values make the row do something with no undo (a row's `confirm`): the sentence to + * confirm with, or null. `confirm: { what, when?: [arg names, any of them given], unless?: [arg names] }`; + * no `when`: always. + * @returns {string | null} + */ +export function confirmOf(row, values = {}) { + const c = row.confirm; + if (!c) return null; + const args = row.args ?? []; + const given = (name) => { + const a = args.find((x) => x.name === name); + return !!a && !absent(a, values?.[name]); + }; + if (c.unless?.some(given)) return null; + if (c.when && !c.when.some(given)) return null; + return c.what; +} + +/** The row's path args a page gave: the server confines each. */ +export function pathArgsOf(row, values = {}) { + return (row.args ?? []).filter((a) => a.type === "path" && !absent(a, values?.[a.name]) && !a.literals?.includes(String(values[a.name]).trim())); +} diff --git a/umtool/lib/cli/confine.mjs b/umtool/lib/cli/confine.mjs @@ -0,0 +1,40 @@ +// A PATH A PAGE NAMED, KEPT INSIDE THE PROJECT (lane palette L8a, review): +// POST /api/cli runs a registry row's `path` arg (lib/cli/verbs.mjs) only +// when it is a file of the project the form names -- relative to the +// project's directory, its REALPATH (every symlink followed, the project's +// own too) inside the project's realpath. What runs is that absolute path, so +// the CLI's own resolution (most of them path.resolve() from their cwd) cannot +// put it anywhere else; a row whose CLI takes it relative to the project +// (`pass: "relative"`) gets the path as typed, checked the same way. +// +// The refusal names the arg and never what the file holds. +import { realpath, stat } from "node:fs/promises"; +import path from "node:path"; + +/** + * @param {string} projectDir + * @param {string} value what the form gave + * @returns {Promise<{ ok: true, abs: string } | { ok: false, error: string }>} + */ +export async function confineToProject(projectDir, value) { + const v = String(value ?? "").trim(); + if (!v) return { ok: false, error: "no file named" }; + if (v.includes("\0")) return { ok: false, error: "a NUL byte" }; + let root; + try { + root = await realpath(/* turbopackIgnore: true */ projectDir); + } catch { + return { ok: false, error: "the project's directory is not there" }; + } + const wanted = path.resolve(/* turbopackIgnore: true */ projectDir, v); + let real; + try { + real = await realpath(/* turbopackIgnore: true */ wanted); + } catch { + return { ok: false, error: `${v}: no such file in the project` }; + } + if (real !== root && !real.startsWith(root + path.sep)) return { ok: false, error: `${v}: not a file of the project (a form may only name files inside it)` }; + const st = await stat(/* turbopackIgnore: true */ real).catch(() => null); + if (!st?.isFile()) return { ok: false, error: `${v}: not a file` }; + return { ok: true, abs: real }; +} diff --git a/umtool/lib/cli/docs.mjs b/umtool/lib/cli/docs.mjs @@ -0,0 +1,107 @@ +// `umtool help` AND docs/cli.md's COMMANDS, GENERATED (lane palette, L8a) +// from the registry: the verb rows (verbs.mjs) and their prose (groups.mjs). +// +// node umtool/lib/cli/docs.mjs rewrite docs/cli.md's generated section +// node umtool/lib/cli/docs.mjs --check exit 1 when it is stale (verbs.test.mjs says the same) +// +// The section stands between the two markers below -- the Commands table (each +// command's rows, as groups.mjs gives them) and "Every verb" (every row of the +// registry, its arguments and whether ⌘K offers it as a form). Everything else +// in cli.md is hand-written and left as it is. +import { readFileSync, writeFileSync } from "node:fs"; +import { fileURLToPath } from "node:url"; + +import { GROUPS } from "./groups.mjs"; +import { VERBS, commandOf } from "./verbs.mjs"; +import { synopsis } from "./argv.mjs"; + +export const DOCS_BEGIN = "<!-- verbs:begin (generated by umtool/lib/cli/docs.mjs from lib/cli/verbs.mjs and groups.mjs -- edit those, not this) -->"; +export const DOCS_END = "<!-- verbs:end -->"; + +/** docs/cli.md, beside this checkout's umtool. */ +export const CLI_MD = fileURLToPath(new URL("../../docs/cli.md", import.meta.url)); + +/** + * What `umtool help` prints. + * @param {{ reportsRoot: string, chainSteps?: string, draftAllSteps?: string }} fill + */ +export function usageText({ reportsRoot, chainSteps = "", draftAllSteps = "" }) { + const lines = GROUPS.flatMap((g) => g.usage).map((l) => l.replace("{chainSteps}", chainSteps).replace("{draftAllSteps}", draftAllSteps)); + return [ + "umtool — the project tree, from a terminal", + "", + ...lines, + "", + `reading ${reportsRoot} (set REPORTS_DIR to move it)`, + "", + "Run `check` before every build. It is what catches a manifest with no", + "siteOrigin — the defect that shipped 19 QR codes reading `undefined/?v=…`.", + "", + "Every verb, its arguments and its ⌘K form: umtool/docs/cli.md (\"Every verb\").", + ].join("\n"); +} + +const code = (s) => `\`${String(s).replace(/\|/g, "\\|")}\``; +const cell = (s) => String(s).replace(/\|/g, "\\|").replace(/\n/g, " "); + +/** The generated section, markers included. */ +export function verbsMarkdown() { + const out = [DOCS_BEGIN, "## Commands", "", "| | |", "|---|---|"]; + for (const g of GROUPS) for (const [syntax, text] of g.docs) out.push(`| ${syntax} | ${text} |`); + out.push( + "", + "### Every verb", + "", + "Every verb `umtool` dispatches, a sub-verb its own row (`umtool/lib/cli/verbs.mjs`, the registry the ⌘K palette's", + "**Commands** are built from). **form**: the palette offers it as a form (its arguments below, the page's project", + "and selection filled in; **Copy as CLI**; Run is `POST /api/cli`, which runs only these). **queued**: Run adds it to", + "the durable queue (it renders, or holds the heavy slot). Otherwise why it has none. *draft*: it writes the working", + "draft (the project's manifest); *project*: a project's other files, or reads; *corpus*: no one project.", + "", + "| Verb | What it does | ⌘K |", + "|---|---|---|", + ); + for (const r of VERBS) { + const ui = r.ui === "form" ? `form${r.queue ? " · queued" : ""} · *${r.target}*` : `none: ${cell(r.reason)}`; + out.push(`| ${code(r.ui === "form" ? synopsis(r) : r.verb)} | ${cell(r.summary)} | ${ui} |`); + } + out.push(DOCS_END); + return out.join("\n"); +} + +/** + * cli.md with its section replaced: between the markers when they are there, + * else from `## Commands` to the end of its table (the first run). + */ +export function withVerbsSection(text) { + const md = verbsMarkdown(); + const a = text.indexOf(DOCS_BEGIN); + const b = text.indexOf(DOCS_END); + if (a >= 0 && b > a) return text.slice(0, a) + md + text.slice(b + DOCS_END.length); + const lines = text.split("\n"); + const h = lines.indexOf("## Commands"); + if (h < 0) throw new Error("cli.md has neither the markers nor a `## Commands` heading"); + let end = h + 1; + for (let i = h + 1; i < lines.length && !lines[i].startsWith("## "); i += 1) if (lines[i].startsWith("|")) end = i; + return [...lines.slice(0, h), md, ...lines.slice(end + 1)].join("\n"); +} + +/** The top-level commands the registry has rows for. */ +export const registryCommands = () => [...new Set(VERBS.map((r) => commandOf(r.verb)))]; + +if (process.argv[1] && fileURLToPath(import.meta.url) === process.argv[1]) { + const text = readFileSync(/* turbopackIgnore: true */ CLI_MD, "utf8"); + const next = withVerbsSection(text); + if (process.argv.includes("--check")) { + if (next !== text) { + console.error("umtool/docs/cli.md is stale: run `node umtool/lib/cli/docs.mjs` and commit it"); + process.exit(1); + } + console.log("umtool/docs/cli.md is current"); + } else if (next !== text) { + writeFileSync(/* turbopackIgnore: true */ CLI_MD, next); + console.log("umtool/docs/cli.md rewritten"); + } else { + console.log("umtool/docs/cli.md is current"); + } +} diff --git a/umtool/lib/cli/groups.mjs b/umtool/lib/cli/groups.mjs @@ -0,0 +1,1021 @@ +// THE REGISTRY'S PROSE (lane palette, L8a): per top-level command, the lines +// `umtool help` prints for it and the rows docs/cli.md's Commands table gives +// it -- written ONCE here, so the help and the page are generated from the same +// place as the verb rows (verbs.mjs) the ⌘K palette's forms are built from. +// +// `usage`: the help lines, as `umtool help` prints them (two spaces, then +// `umtool <cmd>` padded to the column; a continuation line indented to it). +// `{chainSteps}` and `{draftAllSteps}` are filled in when it prints (lib/cli/docs.mjs). +// `docs`: [syntax cell, text cell] pairs, the Commands table's markdown as it stands. +// +// A command appears in the order `umtool help` lists it; one may appear twice +// (take: its renders, then the lint, then its promote and status). Edit the +// prose here, then `node umtool/lib/cli/docs.mjs` rewrites docs/cli.md's +// generated section (the test in verbs.test.mjs fails while it is stale). +// +// Plain data, no imports. + +/** @type {Array<{ cmd: string, usage: string[], docs: Array<[string, string]> }>} */ +export const GROUPS = [ + { + cmd: "ls", + usage: [ + " umtool ls [--kind K] [--template T] [--state S] [--open] [--blocking]", + " [--q TEXT] [--sort name|recent] [--json]", + ], + docs: [ + ["`ls [--kind --template --state --open --blocking --q --sort --json]`", + "the index, as text or JSON"], + ], + }, + { + cmd: "show", + usage: [ + " umtool show <project> [--json]", + ], + docs: [ + ["`show <project> [--json]`", + "one project: summary, the cut, per-clip status, decisions"], + ], + }, + { + cmd: "check", + usage: [ + " umtool check [<project>] [--json] exit 1 on anything blocking", + ], + docs: [ + ["`check [<project>] [--json]`", + "**exit 1 on anything blocking** — including an `out/`, `clips/` or `share-*/` link whose drive is not there (`storage-unreachable`)"], + ], + }, + { + cmd: "links", + usage: [ + " umtool links <project> [--json] [--fix] do the clip QRs open on their sites? (corpus.json -> slugToPage", + " -> the shard's record; polite, cached; out/links.json, which check reads); exit 1 when one is dead", + ], + docs: [ + ["`links <project> [--json] [--fix]`", + "do the clip QRs open on their sites? `corpus.json` → the channel's manifest → `slugToPage` → the shard's record, one request at a time, shards from the cue cache; recorded in `out/links.json`, which `check` reads (`link-dead` blocking, `links-unverified`, `links-unchecked`); `--fix` rewrites a Twitch id the site serves as `v<id>`, and a Rumble folder id (the URL slug) as the embed id the site serves (the clip gets `siteVideo`); **exit 1** when a link is dead ([knobs.md](knobs.md#do-the-qr-links-open)). The same record dates each site's deploy: a cited video newer than it is `site-deploy-behind` ([knobs.md](knobs.md#the-sites-the-links-depend-on))"], + ], + }, + { + cmd: "cast", + usage: [ + " umtool cast [ls] | add <id> --name … --voice <engine:voice> [--handles a,b] | set <id> … | rm <id> | undo", + " | project <p> | audition <character> --voices a,b,c [--project <p>] [--text …] | use <p> <character> <voice>", + " [--everywhere] | reread <p> <character> the CAST: characters' stock voices across projects (cast.json), a", + " project's characters and their drift, an audition of candidate voices (scored against the real voice)", + ], + docs: [ + ["`cast [ls] \\| add <id> --name … --voice <engine:voice> [--handles a,b] [--speakers …] [--convert-engine e] [--convert-voice v] [--narrator] \\| set <id> … \\| rm <id> \\| undo [--json]`", + "**THE CAST** (`<reports>/.umtool/cast.json`, [knobs.md](knobs.md#the-cast-each-characters-voice-in-every-project-and-the-voices-page)): the characters across projects and their STOCK voices, a layer under each project's voice map; one writer, an undo point a write"], + ["`cast project <project> [--json]` · `cast use <project> <character\\|@handle> <voice> [--everywhere]` · `cast reread <project> <character> [--dry-run]`", + "a project's characters (each voice now, where it comes from, its stale reads), the voice for this project or everywhere, and the re-reads that asks for"], + ["`cast audition <character\\|@handle> --voices a,b,… [--project <p>] [--text \"…\" \\| --item <id> \\| --line <n> \\| --stock] [--no-score \\| --score-only] [--json] [--progress ndjson]`", + "**AN AUDITION**: one line read by 2-6 stock voices through the editor's tts op, levelled to -20 LUFS in `<p>/narration/auditions/` (cached), scored for closeness to the character's real voice (`speakers.json`; TitaNet, local)"], + ], + }, + { + cmd: "speaker-check", + usage: [ + " umtool speaker-check <project> [--clip <id> …] [--json] which of the project's named voices (speakers.json) each", + " clip is: TitaNet-small, local -> speaker-check.json; --set 'Name=<clip>,<channel>/<id>,channel:<slug>' / --remove / --list", + ], + docs: [ + ["`speaker-check <project> [--clip <id> …] [--json] [--progress ndjson]` · `--set 'Name=<clip>,<channel>/<id>,channel:<slug>'` · `--remove <name>` · `--list`", + "which of the project's **named voices** (`speakers.json`) each clip is: TitaNet-small, local, against each voice's robust centroid → `<project>/speaker-check.json` (merged); the walk's **Speaker:** badge and **Check speaker** ([report-video.md](report-video.md#the-speaker-check-on-the-walk-which-of-several-voices))"], + ], + }, + { + cmd: "quote-check", + usage: [ + " umtool quote-check <project> [--clips a,b] [--pad S] [--json] | --status is each clip's quote in the seconds it plays?", + " the cut ±15 s of the source the render would use, transcribed by the editor (words on), the quote", + " found in it and in the cues: ok | moved (heard N s away: window --align) | not-found -> quote-check.json;", + " check calls moved and not-found blocking, and a take refuses them unless the clip is --quote-ruled", + ], + docs: [ + ["`quote-check <project> [--clips a,b] [--pad S] [--json]` · `quote-check <project> --status`", + "**is each clip's quote in the seconds it plays?** The cut ±15 s of the source the render would cut it from, transcribed by the editor (`pnpm ops transcribe`, words on — its transcription lane), the quote found in those words and in the cues: `ok`, `moved` (heard more than 0.5 s from where the cues have it), `not-found`; rows in `quote-check.json`, stale when the cut or the quote changes; `check` blocks on `moved`/`not-found` (`clip-quote-moved`, `clip-quote-missing`), a take refuses them, `prep --status` counts them ([knobs.md](knobs.md#the-quote-check-is-the-quote-where-the-clip-plays))"], + ], + }, + { + cmd: "check-joins", + usage: [ + " umtool check-joins <project> --take <id> [--json] [--all] [--limit <n>] every boundary of the take's master where the", + " next post item draws a post the one before showed: its join, the SSIM across it, the largest jump", + ], + docs: [ + ["`check-joins <project> --take <id> [--json] [--all] [--limit <n>]`", + "do a rendered take's **post joins carry on**: every boundary of its master where the next post item draws a post the one before showed, its planned join, the SSIM across it and the largest frame-to-frame step (read-only, ffmpeg) -- worst first ([report-video.md](report-video.md#thread-scenes-whole-threads-the-join-manual-threads-wide-attachments-context-media-link-visits-the-branch-map))"], + ], + }, + { + cmd: "link-policy", + usage: [ + " umtool link-policy <project> [--via <site id|url>] [--direct a,b] [--clear] [--fix] [--json] the link policy", + " (provenance.linkPolicy): cite via site X, these channels direct; --fix rewrites the clips that break it", + ], + docs: [ + ["`link-policy <project> [--via <site id \\| https://…>] [--direct <slug,…>] [--clear] [--fix] [--json]`", + "the project's **link policy** (`provenance.linkPolicy`): cite via site X, these channels direct. With no flag, prints it and every clip whose QR breaks it; `--fix` rewrites each one that has a fix through the window writer; new clips are written by it. **Exit 1** when a clip still breaks it ([knobs.md](knobs.md#the-link-policy))"], + ], + }, + { + cmd: "patch-markers", + usage: [ + " umtool patch-markers <project> [<file>.patch.json] [--fix] [--json] take patches whose deck markers name a", + " clip not in the cut; --fix gives each the after of the cut's marker of the same label", + ], + docs: [ + ["`patch-markers <project> [<file>.patch.json] [--fix] [--json]`", + "take patches whose deck markers name a clip not in the cut (a take made with one is refused); `--fix` gives each the `after` of the cut's marker of the same label; **exit 1** when one is left ([knobs.md](knobs.md#take-patches-follow-a-removal))"], + ], + }, + { + cmd: "decisions", + usage: [ + " umtool decisions [--json]", + ], + docs: [ + ["`decisions [--json]`", + "the inbox"], + ], + }, + { + cmd: "inbox", + usage: [ + " umtool inbox [--all] [--json] the decisions, grouped and ranked as the inbox shows them", + " (--all: the hidden ones on parked/done pieces, and the quiet group)", + ], + docs: [ + ["`inbox [--all] [--json]`", + "the decisions grouped and ranked by piece (`a:<site>/<report>`, `p:<project>`): Your call, Review, Blocking, Notes, Open, Ready to finish, Quiet — one card per piece and kind, and how many sit hidden on parked or done pieces (`--all` lists them). Every decision, songs' and articles' included; runs `bin/inbox.ts` through tsx"], + ], + }, + { + cmd: "schedule", + usage: [ + " umtool schedule list | show <id> [--json] the recurring reports: chip, editions, tick log (read-only;", + " a schedule is written through the editor: `pnpm ops report-schedule`)", + ], + docs: [ + ["`schedule list \\| show <id> [--json]`", + "the recurring reports, read-only ([recurring.md](recurring.md))"], + ], + }, + { + cmd: "folders", + usage: [ + " umtool folders [--json]", + ], + docs: [ + ["`folders [--json]` · `kinds [--json]`", + "the tree, the registry"], + ], + }, + { + cmd: "kinds", + usage: [ + " umtool kinds [--json]", + ], + docs: [ + ], + }, + { + cmd: "link", + usage: [ + " umtool link <project> <site>/<report> | --clear [--json] the manifest names its article (a top-level", + " `article`): what settles link-ambiguous; noted for the generator on a generated manifest", + ], + docs: [ + ["`link <project> <site>/<report>` · `link <project> --clear`", + "the manifest names the article it is the video of (settles `link-ambiguous`)"], + ], + }, + { + cmd: "window", + usage: [ + " umtool window <project> <clip> [--start S] [--end E] [--lock|--lock-end|…]", + " attribution too: --title, --date YYYY-MM-DD, --cite, --cite-url, --quote", + " --repeat-of <clip> it re-plays that clip on purpose (a callback): their overlap is not flagged or trimmed", + " --correction TEXT what the REPORT got wrong here (never rendered)", + " --walk-note TEXT an editorial note from the walk (not a correction; never rendered)", + " --star / --no-star the walk's favourite: a trailer candidate (umtool trailer <p> --candidates)", + " a window edit that leaves --cite (or the citeUrl's t=) more than 5 s before the clip, or", + " after it, moves it to the clip's first second; an explicit --cite moves the QR's t= with it", + " --verdict confirmed|incorrect what the walk said; incorrect needs --correction", + " --reject <why> [--note TEXT] rejected on the walk, kept in place (`umtool timeline <p> reject`", + " takes it out, on record): not-matching|wrong-speaker (fact errors: incorrect, the note its", + " correction) or irrelevant|repeats|weak|privacy|other (rejected; other needs --note)", + " --cut-start S --cut-end E --lock-cut the cut the video renders", + " --align the cut snapped to the quote as HEARD (quote-check.json: a breath before its first word,", + " its last let ring; the extent widened to hold it; lockCut kept) -- the per-clip fix for a moved quote", + " --quote-ruled / --no-quote-ruled a person heard it and rules the quote check's verdict: a take renders it", + " --move-stamp first|nearest|<s> | --clear-stamp with --start/--end: a stamp's second (claim.at,", + " a mark's at) the new window would leave outside moves to the first second that plays, the nearest,", + " or <s>, or loses its at -- in the same write; --move-mute nearest | --clear-mute the mute mark's", + " --gap FROM-TO (repeatable) cut those source seconds out of the clip's middle: it plays", + " as ONE segment of jump cuts (gaps.mjs; inside the cut, ≥ 0.2 s, 0.5 s kept between);", + " --gap-remove S the gap holding source second S · --gaps 'A-B,C-D' the whole list ('' clears)", + " an empty value (--title '') deletes the field", + " --take <id> a take's clip (walk a take): the edit goes into takes/<id>/take.json's", + " patch, an undo point first (`umtool timeline <p> --take <id> undo`); the manifest is untouched", + ], + docs: [ + ["`window <project> <clip> [--start S] [--end E] [--lock] [--lock-end] [--no-lock-end] [--note …]`", + "edit a window"], + ["`window <project> <clip> --start S --end E --move-stamp first\\|nearest\\|<s>` · `--clear-stamp` · `--move-mute nearest` · `--clear-mute`", + "a window edit refused because a stamp's second (`claim.at`, a mark's `at`) or the mute mark would fall outside it, with the fix in the same write: the stamp to the first second that plays, the nearest, or `<s>`, or its `at` cleared; the mute mark to the nearest second, or cleared (never inside a gap). A refused `window` names these flags ([clip-bench.md](clip-bench.md#saving))"], + ["`window <project> <clip> --verdict confirmed\\|incorrect [--correction T]` · `window <project> <clip> --reject <why> [--note T]`", + "what the walk said: `--reject` is the walk's **Reject ▾** kept in place (`not-matching`/`wrong-speaker`: incorrect, the note its correction; `irrelevant`/`repeats`/`weak`/`privacy`/`other`: rejected, the note its `rejectNote`); `umtool timeline <p> reject` takes it out ([report-video.md](report-video.md#verdict--what-the-walk-said))"], + ["`window <project> <clip> --walk-note T` · `--star` / `--no-star` · `--repeat-of <clip>`", + "what the walk said that is not a verdict: an editorial note (not a correction) and the ★ favourite, a trailer candidate (`trailer <project> --candidates [--json]` lists them as beats); a deliberate repeat ([knobs.md](knobs.md#a-clip))"], + ["`window <project> <clip> --align` · `--quote-ruled` / `--no-quote-ruled`", + "the cut snapped to the quote as HEARD (0.15 s before its first word, 0.3 s after its last, the extent widened to hold it, `lockCut`); a person's ruling on the quote check (a take renders a ruled clip)"], + ["`window <project> <clip> --take <take> …`", + "a **take's** clip (walk a take): the same fields, written into the take's patch (`takes/<take>/take.json`) with an undo point first; the project's manifest is untouched ([clip-bench.md](clip-bench.md#walking-a-take))"], + ], + }, + { + cmd: "walk", + usage: [ + " umtool walk <project> [--take <id>] [--all] [--json] the clip bench's walk: every clip in walk order,", + " its verdict, fetched or not, and (→) the ones the walk visits; --take walks a take (a draft too)", + ], + docs: [ + ["`walk <project> [--take <take>] [--all] [--json]`", + "the clip bench's **walk**: every clip in walk order with its window, verdict and whether a fetched file holds it, and (→) the ones the walk visits — fetched and needing a verdict; `--all` every fetched one; `--take` walks a take (a draft too); the bench's address to start at. The intro (`render.intro`) is listed first, watched, not judged (`intro`, `stops` in `--json`)"], + ], + }, + { + cmd: "present", + usage: [ + " umtool present <project> [--take <id> | --cut] [--json] [--public] [--open] PRESENT MODE: the cut as slides,", + " navigated like a deck (/projects/<p>/present); prints its address and its slides (#<slide id> opens", + " one); --json the payload (posts with their censor data by kind, clips' spans, section/day dividers);", + " --public the payload a public page would carry (censored, no reveal data); --open opens it", + ], + docs: [ + ["`present <project> [--take <take> \\| --cut] [--json] [--public] [--open] [--url <origin>]`", + "**present mode**: the cut as slides, navigated like a deck (`/projects/<p>/present`) — prints the address and every slide (its kind, id — a post's `<channel>/<id>`, a clip's id, `section-<n>`, `day-<YYYY-MM-DD>` — date, words and censor counts); `--json` the payload (each post's card as Play draws it and its censor data by kind, each clip's spans, the dividers); `--public` the payload a public page would carry (censored, no reveal data); `--open` opens it; `<address>#<slide id>` opens a slide ([knobs.md](knobs.md#present-mode-the-cut-as-slides-navigated-like-a-deck))"], + ], + }, + { + cmd: "set", + usage: [ + " umtool set <project> <clip> key=value … a clip's knobs (`key=` clears; umtool/docs/knobs.md):", + " claim.at (a source second: the stamp lands, the count steps) claim.hold claim.stamp", + " claim.count claim.label (the first mark's, or --mark <id>'s) · marks: mark.add=<verdict>[@<sec>]", + " mark.remove=<id> mark.verdict=<verdict> marks=<json> (≤ 8, each its own stamp and count)", + " · audio.offset (ms, + later) audio.gain (dB) audio.fadeIn audio.fadeOut", + " · hideModules=diet,streak (those modules hidden over the entry's span; any entry)", + " · shelfNote='words' (a line on the shelf over the entry's span; any entry)", + " --take <t>: the entry knobs into the take's patch, the project's manifest untouched", + ], + docs: [ + ["`set <project> <clip> key=value …`", + "a clip's **knobs**: `claim.at` `claim.hold` `claim.stamp` `claim.count` `claim.label` (the first mark's, or `--mark <id>`'s), its **marks** `mark.add=<verdict>[@<sec>]` `mark.remove=<id>` `mark.verdict=<verdict>` `marks=<json>`, `audio.offset` `audio.gain` `audio.fadeIn` `audio.fadeOut`, its picture's **blur** `blur.on=true` `blur.caption=…` `blur.strength` `blur.from` `blur.to` (`blur.on=` clears it; [knobs.md](knobs.md#a-clips-picture-blurred)), its **effects** `fx.zoom=<json>` `fx.receipts=<json>` `fx.punch=…` `fx.quote` `fx.punchIn=<json>` `fx.speakers=<json>` (`fx=<json>` all of them, `fx=` clears them; a shot is a file in the project; [knobs.md](knobs.md#effects)); `key=` clears one ([knobs.md](knobs.md#marks))"], + ], + }, + { + cmd: "intro", + usage: [ + " umtool intro <project> [key=value …] [--off] [--json] THE INTRO the cut opens on (render.intro): prints it,", + " what the cut opens with and each version's on/off; key=value writes it (style seconds mark sound", + " site title lines …; `key=` clears; a new one starts as boot-dark); --off takes it off;", + " --take <t> --off|--on: that version opens on no intro (its patch's render.intro: null) or the cut's", + ], + docs: [ + ["`intro <project> [key=value …] [--off] [--json]` · `intro <project> --take <take> --off\\|--on`", + "**the intro** the cut opens on (`render.intro`): with no key, prints it as written, what the cut opens with (a `title-card`'s words resolved) and each version's on/off; `key=value` writes it through the look writer (`style` `seconds` 3.5–8 `mark` `ground` `sound` (`false` silent) `site` `title` `lines` (`a\\|b`, ≤ 3) and the brand's keys; `key=` clears one; a new intro starts as `boot-dark`); `--off` takes it off the cut; `--take <t> --off` that version opens on no intro (its patch's `render.intro: null`), `--on` on the cut's again. **Exit 1** on a value the build refuses ([knobs.md](knobs.md#the-intro-played-and-edited))"], + ], + }, + { + cmd: "look", + usage: [ + " umtool look <project> key=value … the cut's knobs: factcheck.stamp.scale|motion|opacity|seconds,", + " factcheck.verdicts.<V>.stampLabel|label|color, deck.markers=<json>, deck.markerLayout,", + " variants=<json>, and the look's keys (transition=0.3, …)", + ], + docs: [ + ["`look <project> key=value … [--unset render.<key>]…`", + "the cut's **knobs**: `factcheck.stamp.*`, `factcheck.verdicts.<V>.stampLabel\\|label\\|color`, `deck.markers=<json>`, `deck.markerLayout`, `variants=<json>`, and the look's keys — `mode=basic\\|deck` (the footage alone, [knobs.md](knobs.md#basic-output-the-footage-alone)) and `basic=<json>` (its fades) among them ([knobs.md](knobs.md)) **The deck on, legacy keys off** (`updateRenderKeys`, one write, an undo point `revisions/…auto-render-keys…` first): `chrome.layout=deck` turns the deck on (render.chrome created when the cut has none: engine hyperframes, an empty deck), `--unset render.<key>` (repeatable) drops a legacy render key -- only `rail` `chromeEngine` `railEngine` `chromeRegions` `claimSchedule` `wordmark` `title` `finale` `cut`; the deck beside the old rail is refused in the build's words unless the same command drops it; deck.* keys in the same command land after the chrome exists. Another key named: **exit 2**"], + ], + }, + { + cmd: "migrate", + usage: [ + " umtool migrate <project> [--dry-run] [--json] move the manifest into the video modules' homes", + " (the fact-check verdicts and tally become deck.counter's series); renders the same", + ], + docs: [ + ], + }, + { + cmd: "variants", + usage: [ + " umtool variants <project> [--take <t>] [--list] [--json] make the encode ladder of a build (render.variants);", + " --list: what was made, and the build's sync report (each clip's lag, past a frame flagged)", + ], + docs: [ + ["`variants <project> [--take <t>] [--list] [--json]`", + "**Make variants**: the encode ladder of the build (or of a take's); `--list` what was made and the build's sync report, each clip's lag (past a frame flagged) ([knobs.md](knobs.md))"], + ], + }, + { + cmd: "corrections", + usage: [ + " umtool corrections <project> what the report got wrong + the walk's coverage", + ], + docs: [ + ["`corrections <project>`", + "what the report got wrong (the clip bench's sixth field) and the walk's coverage, as markdown for the next pass"], + ], + }, + { + cmd: "build", + usage: [ + " umtool build <project> [--preset preview|fast|final] [--only ID]", + " --run: the app's build job (UMTOOL_URL, else http://localhost:3050; --url), followed here;", + " Ctrl-C cancels it; --replace stamps a newer deliverable aside", + ], + docs: [ + ["`build <project> [--preset preview\\|fast\\|final] [--only ID]`", + "**prints** the chain"], + ["`build <project> --run [--url URL] [--replace] [--preset P] [--only ID] [--skip-fetch]`", + "**runs** it as the app's build job (POST `/api/report/build` on `--url`, else `UMTOOL_URL`, else `http://localhost:3050`), prints its log as it grows, **Ctrl-C** cancels the job (twice leaves it running); `--replace` stamps a deliverable newer than the manifest aside; exit 1 unless the job is done (release 36)"], + ], + }, + { + cmd: "chain", + usage: [ + " 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: {chainSteps}", + " (resumes at the first step not done; --dry prints it; the project is <root>/<article>/i<n>/)", + " --draft-all (Draft everything): {draftAllSteps} —", + " 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", + ], + docs: [ + ["`chain <article> <n> [--from <step>] [--dry] [--final] [--draft-all [--model M]]`", + "an iteration to a video: the Iterations tab's **Make the video** (`--draft-all`: Draft everything)"], + ], + }, + { + cmd: "index", + usage: [ + " umtool index [--rebuild] [--prune] [--since MS] [--json]", + ], + docs: [ + ["`index [--rebuild] [--prune] [--since MS] [--json]`", + "the cache"], + ], + }, + { + cmd: "new", + usage: [ + " umtool new <slug> [--from <report.md>|<share URL>|<channel>/<id>] [--site-origin URL] [--seed chapters|frames]", + " <folder>/<slug>, or --folder <folder>: the project in a folder of the reports tree (its id", + " <folder>/<slug>, routed /projects/<folder>/<slug>) — a spin-off beside its parent", + " --seed frames: a draft supercut from the video's frame scan (pnpm ops frame-scan) — the events", + " ranked (scoops, milestones, swings, pots, level-ups) into --target <seconds> (default 240), the", + " deck on with the stats region drawing frameScan.overlay over each clip", + " --seed phrase --phrase <regex> --channels a,b [--prefer <slug>] [--exclude <regex>]: every time", + " the phrase was said in those channels' transcripts, chronological, cut from the --prefer", + " channel's copy where it has one (a twin by date and duration); a context matching --exclude", + " is left out; the scan beside the manifest as phrase-scan.json; --max N keeps N instances", + " spread across the years in proportion (the rest: phrase-scan.json \"skippedByCap\")", + " --seed reactions --from <channel>/<id> [--target S] [--laugh-min X] [--scope FROM:TO|auto [--segment sN]] [--no-analyze]: the clip finder on a long", + " recording (needs its diarization.json): highlights proposed from the host's laughs and comments,", + " then `umtool clips analyze` (the laugh scan + voices) unless --no-analyze; --scope auto reads the", + " narrated video auto-scope finds in the speakers' turns (--segment names one, else the longest)", + " --from-posts <channel> [--channel <more>…] [--since D] [--until D] [--own] [--with-media]", + " [--replies include|only|exclude] [--order chrono|reverse] [--limit N]: a POSTS REEL -- each", + " archived post a post item (its card, its attachments), the deck on (umtool posts reel adds more)", + " [--brand archilyzer-media] render.brand: the report-to-video brand preset", + ], + docs: [ + ["`new <slug> [--from <report.md>\\|<share URL>\\|<channel>/<id>] [--site-origin URL] [--seed chapters\\|frames [--target S]]` · `new <folder>/<slug> …` · `new <slug> --folder <folder> …` · `new <slug> --seed phrase --phrase <regex> --channels a,b [--prefer <slug>] [--exclude <regex>] [--max N]` · `new <slug> --seed reactions --from <channel>/<id> [--target S] [--laugh-min X] [--scope FROM:TO\\|auto [--segment sN]] [--no-analyze]`", + "scaffold; `<folder>/<slug>` (or `--folder`) makes it in a folder of the reports tree — its id `<folder>/<slug>`, routed `/projects/<folder>/<slug>` (a spin-off beside its parent); a folder that is itself a project, the reserved `at`, or one past the walk's four levels is refused"], + ["`new <slug> --from-posts <channel> [--channel <more>…] [--since D] [--until D] [--own] [--with-media] [--replies …] [--order …] [--limit N]`", + "a **posts reel**: the scaffold with the deck on (no `siteOrigin`: each post's QR opens the post, `deck.qr.links: \"original\"`), then `posts reel` with the same filters"], + ], + }, + { + cmd: "doctor", + usage: [ + " umtool doctor [--json] exit 1 if the report pipeline is missing a tool", + " or the media root is set and not there; the roots, and a leftover old cache", + ], + docs: [ + ["`doctor [--json]`", + "which tools are on this machine and where the roots are; **exit 1** if the report pipeline is missing one, or `UMTOOL_MEDIA_DIR` is set and not there"], + ], + }, + { + cmd: "storage", + usage: [ + " umtool storage [<project>] where each project's out/ lives (dir, link, DANGLING)", + " umtool storage move-out|move-back <project>|--all [--dry-run]", + " umtool storage deliverables <project> --to media|local [--dry-run] clips/ + share-*/, then the switch", + " out/ to the media root (UMTOOL_MEDIA_DIR) and back; run when nothing is building", + ], + docs: [ + ["`storage [<project>] [--json]`", + "where each project's `out/` lives: dir, link, DANGLING, none — and a report's deliverables (`clips/`, `share-*/`) and its switch"], + ["`storage move-out\\|move-back <project>\\|--all [--dry-run] [--json]`", + "`out/` to the media root (a link left behind) and back — copied, mirrored, verified first; run when nothing is building"], + ["`storage deliverables <project> --to media\\|local [--dry-run] [--json]`", + "`clips/` and every `share-*/` to the media root and back, then `storage.deliverables` in the manifest; refused while a build step, a cut or a share batch (by `--project` id, name or directory, as the app starts them) or the report's own scripts run in the project — a hand-run command that is none of these is not seen; **exit 1** on any failure (the switch is then left as it was)"], + ], + }, + { + cmd: "snapshot", + usage: [ + " umtool snapshot <project> [--label L] copy the manifest into revisions/", + ], + docs: [ + ["`snapshot <project> [--label L]`", + "copy the manifest into `revisions/`"], + ], + }, + { + cmd: "diff", + usage: [ + " umtool diff <project> <snapshot> what changed since that snapshot", + ], + docs: [ + ["`diff <project> <snapshot>`", + "added / removed / moved / window / retyped, by entry id"], + ], + }, + { + cmd: "export", + usage: [ + " umtool export <project> --format toc-bbcode|toc-markdown|description|chapters [--variant V] [--first TITLE]", + " umtool export <project> <clip> [--context N | --raw [--from S --to S]] [--fetch] [--take T] [--open] one clip,", + " clean, into <project>/exports/: the cut's edges, its gaps out, its mute; --context N what the cut", + " plays ± N s; --raw the whole fetched window, or a span (the full exchange), as recorded; --fetch", + " asks the editor first for what that needs; in the heavy slot; --open shows it", + ], + docs: [ + ["`export <project> --format toc-bbcode\\|toc-markdown\\|description\\|chapters [--variant V] [--first TITLE]`", + "the posting artifacts, from the build's chapter offsets. A deck with markers: `chapters` are its top-level sections (subsections left out) at the second each section's first segment starts, YouTube's rules kept (0:00 first, each ≥ 10 s, at least three; what was merged is said on stderr); the opening is titled `deck.sectionTitle.first`, or `--first TITLE`, else the first section takes 0:00"], + ["`export <project> <clip> [--take T] [--open] [--json]` · `--context N` · `--raw [--from S --to S]` · `--fetch` · `--progress ndjson`", + "**one clip, clean** (no deck) into `<project>/exports/` as `<clip>[-ctx<N>\\|-raw[-<from>-<to>]]-<date>-<words>.mp4`: as the cut plays it (its edges, gaps out, its mute); `--context N` what the cut plays ± N s (1–120), as recorded; `--raw` the fetched window, or `--from/--to` a span (the full exchange), as recorded. In the heavy slot (a 600 MB estimate). `--fetch` asks the editor first (fetch-via-editor, the bench's path) for what a context or raw export needs that is not on disk; without it nothing is fetched. `--progress ndjson`: one `export` event (the app's export job reads it) ([knobs.md](knobs.md#export-one-clip))"], + ], + }, + { + cmd: "check-sources", + usage: [ + " umtool check-sources [<project>…] prints the re-check chain (never-checked/old when no args)", + ], + docs: [ + ["`check-sources [<project>…]`", + "**prints** the re-check chain; with no args, the never-checked and >30 d projects"], + ], + }, + { + cmd: "notes", + usage: [ + " umtool notes [<site>/<report>|<project>|--all] the operator's notes, as markdown (open ones)", + " umtool notes reply <id> \"<text>\" [--resolve] answer one; resolve | wontfix | reopen <id>", + ], + docs: [ + ["`notes …`", + "operator notes: list, read, reply, resolve ([notes.md](notes.md))"], + ], + }, + { + cmd: "modules", + usage: [ + " umtool modules list | apply <project> [--config F] [--dry-run | --take <id> [--at S --dur S | --full] …]", + " a module-config.json onto the cut (writers), or as a take's patch", + ], + docs: [ + ["`modules list [--json]` · `modules apply <project> [--config FILE] [--dry-run] [--json]` · `modules apply <project> [--config FILE] --take <id> [--label L] [--at S --dur S \\| --full] [--quick] [--force] [--from TAKE] [--keep-frames] [--patch-out FILE]`", + "the **video modules** (release 39): `list` every module, its kind, slot and where its settings live; `apply` maps the project's `module-config.json` (the modules a video wants, in MODULES-DESIGN's vocabulary) into the manifest's homes (`report-to-video/modules/config-loader.mjs`) — the preset, the deck's subtitle and QR, the counter's series and each clip's marks, the stamps, the rail's markers, the chapters, the pairs, the status ledger, the intro, the finale — and lists every field with no home, by path. Without `--take` the manifest is rewritten through `replaceManifest` (a snapshot first); with `--take` it is that take's patch (`takes/<id>.modules-patch.json`, or `--patch-out`) and the take is made from it as `take` makes one, the manifest untouched. **Exit 1** when the result would not build (the build's sentences) ([knobs.md](knobs.md#look-presets))"], + ], + }, + { + cmd: "preset", + usage: [ + " umtool preset list | show <name> | save <name> --from <project> | apply <name|none> <project>", + " the look presets (preset → manifest → style → take patch)", + ], + docs: [ + ["`preset list [--json]` · `preset show <name> [--json]` · `preset save <name> --from <project> [--description D] [--force]` · `preset apply <name\\|none> <project> [--replace] [--json]`", + "the **look presets** (`umtool/presets/<name>.json`, or `UMTOOL_PRESETS_DIR`; built in: `plain-deck` `huck-deck` `ember-deck` `archive-catalog` `basic`): a render block a manifest stands on (`\"preset\": \"<name>\"`), laid under it — preset → manifest → style → take patch. `save` keeps a project's look and leaves its content out; `apply` names the preset on the cut through `updatePreset` (nothing copied in), refused when the cut over it would not build (a basic cut's chrome is not checked); `--replace` also clears the manifest's own value of every key the preset sets, after an undo point (`revisions/…-auto-before-preset-replace`), and prints what went ([knobs.md](knobs.md#look-presets))"], + ], + }, + { + cmd: "take", + usage: [ + " umtool take <project> --id <id> --label L [--style S] [--patch F | --set p=v …] [--at S --dur S | --full]", + " one take: the manifest with a style's patch, rendered into takes/<id>/ (--rebuild, --force;", + " --from TAKE reuses that take's segments, chrome and batches; --keep-frames keeps the chrome)", + " --draft (--no-render): record the take, render nothing -- walk it, edit it, render it later", + " (`umtool take <p> --id <id> --full` renders a draft from its stored patch)", + " --priority: render mode for the take's lifetime -- every other heavy job waits for it, the", + " editor's transcription and download lanes are held; all let go at its end, failure or signal", + " --draft --from TAKE: a draft that starts from that take's patch (its timeline its own from then on)", + " umtool take <project> --id <id> --import-item <project>:<item>[,<item>…] [--after <entry>|--before <entry>]", + " [--as <id>] [--dry-run] [--json] items of ANOTHER project cloned into the take (its patch), their", + " narration and pick kept, the files they name hard-linked into this project; again: updated or unchanged", + ], + docs: [ + ], + }, + { + cmd: "lint", + usage: [ + " umtool lint <project> [--take <id>] [--variant sourced|full] [--final] [--json] the manifest lint a build runs", + " first, on the project's manifest or a take's (its patches applied), and the files its post items", + " name (a picked read, an attachment not in the project: an error) -- exit 0 clean, 1 an error", + ], + docs: [ + ["`lint <project> [--take <take>] [--variant sourced\\|full] [--final] [--json]`", + "**the manifest lint** (`report-to-video/lint.mjs`, what a build runs before it renders a frame) from umtool: the project's manifest, or with `--take` the take's (its patches applied, written beside the project's manifest for the lint as its render's is, then removed) -- plus the **files its post items name**: a picked read, an attachment or a context post's media not in the project is an ERROR, another kept take a warning. Run it after an import and before queueing the render. `--json`: `{ok, entries, errors, warnings}`. **Exit 0 no error · 1 an error · 2 usage**"], + ], + }, + { + cmd: "take", + usage: [ + " umtool take <project> --id <id> --promote [--anyway] make this the cut: the take's patch applied to the", + " manifest, one undo point (revisions/…-auto-before-promote-take)", + " umtool take status <project> [--id <id>] [--json] [--log] [--tail N] the take's render record (every render", + " writes takes/<id>/render.json and the full render.log): exit 0 done, 3 queued/waiting/running, 1 failed", + ], + docs: [ + ["`take <project> --id <id> --label L [--group G] [--kind similar\\|different] [--summary S] [--style NAME] [--patch FILE \\| --patch-json JSON \\| --set path=value …] [--effect NAME] [--at S --dur S \\| --full] [--quick] [--force] [--progress ndjson]`", + "one **take**: the manifest with a montage style's patch, then an overlay effect's (`--effect`, release 35), then the take's own, rendered into `takes/<id>/` (the Takes page's New take); `--id <id> --rebuild` makes one again from its own `take.json` ([report-video.md](report-video.md#making-takes))"], + ["`take <project> --id <id> --label L [--patch F \\| …] --draft` (`--no-render`) · `take <project> --id <id> [--full \\| --at S --dur S]` · `take <project> --id <id> --rebuild [--full \\| --at S --dur S]` · `take <project> --id <id> --promote [--anyway] [--json]`", + "a **draft** take: recorded with nothing rendered, to be walked first; a draft named with no patch flags is rendered from its stored (walked) patch, and `--rebuild` takes a window flag; **make it the cut**: the take's patch applied to the manifest now, one undo point (`revisions/…-auto-before-promote-take`), refused (exit 1) when its timeline would replace a cut that changed since, until `--anyway` ([report-video.md](report-video.md#walking-a-take-drafts-edits-into-the-take-and-making-it-the-cut))"], + ["`take <project> --id <id> … --uncensored` · build-video `--uncensored`", + "the **uncensored cut** ([knobs.md](knobs.md#the-slur-filter-slurs-masked-in-what-is-published-off-for-the-uncensored-cut)): the same cut with the post items' slur filter off -- `render.posts.slurs.on: false` in the take's patch (a `--rebuild` keeps it; a censored take is not rebuilt uncensored, **exit 2**: make a take of its own), its label gains \"(uncensored)\", take.json's `slurs` records `censored` or `uncensored`. The redaction of private words and censored attachments stay on"], + ["`take <project> --id <id> --draft --from <take> [--label L] [--patch F \\| --patch-json J \\| --set p=v …]`", + "a **draft made from another take**: that take's style and patch (a `--patch` merged over it), its label \"<that label> (from <take>)\" unless `--label`, nothing rendered; its timeline is its own from then on, and its render's `--from` (segments reused) is a separate flag of the render ([take-scoped edits](#edit-a-take-not-the-project-items-from-other-projects-and-take-scoped-edits))"], + ["`take <project> --id <id> --preview [--from <take>] [--at S --dur S \\| --full] [--priority] [--json]`", + "the take's **preview**: the take as stored (a draft too, from its walked patch) composed exactly as its render is -- the same 1920×1080 layout, segments, chrome frames and sound -- with only its final picture encoded smaller and faster (`render.preview`: 1280×720, x264 veryfast, crf 26) into `takes/<id>/out/<slug>.preview.mp4`; its build, schedule and record (`render.json`, `render.log`) in `takes/<id>/out/preview/`. The full render (`preview.mp4`, `out/<slug>.mp4`, `out/sourced/`, `take.json`, `render.json`) is never touched. Reuses this take's own full render, and `--from`'s full render and preview ([report-video.md](report-video.md#fast-feedback-preview-and-changes-renders), [knobs.md](knobs.md#fast-feedback-a-preview-and-a-reel-of-the-changes))"], + ["`take <project> --id <id> --changes [--from <take>] [--pad 3] [--no-preview] [--priority] [--json]`", + "the take's **changes reel**: only what changed against `--from` (default: the take's own `from`, or the take a draft was made from) -- each added, re-read, re-picked, re-voiced, trimmed, held, fx'd, … item with a neighbour either side, rendered in one build (`takes/<id>/out/changes/`), cut to the item ± `--pad` s, a label burned in (`21:19 · p-2116831815466193102 · re-voiced`: its time in the FULL cut), joined into `takes/<id>/out/<slug>.changes.mp4`; a removed item shows as the join it leaves. `takes/<id>/changes.json` lists the pieces with their full-cut times and how exact they are (`times.basis`: `measured` -- the base's measured schedule plus the changed items' measured lengths -- or `estimate`). Preview quality unless `--no-preview`. Nothing changed: no reel, and the list says so"], + ["`take <project> --id <id> --import-item <project>:<item>[,<item>…] [--import-item …] [--after <entry> \\| --before <entry>] [--as <id>] [--dry-run] [--json]`", + "**items of another project into a take** (`takeImport.mjs`): each entry CLONED from the source's manifest as it is now (its card, context, knobs, narration with its takes and its pick) into the take's timeline -- one write, an undo point of the take's (`timeline <p> --take <id> undo`); the files it names (narration takes and their `take-<n>.*` sidecars, the parts' cache files, attachments, a context post's media, the picture of each author it draws that the take lacks, added to the take's `postAvatars`) **hard-linked** into this project's dir at the same path, so the render and the lint find them (copied across filesystems; the same file already there is left; ANOTHER file at the path: linked under `imports/<source>/<path>` and the clone names that). The source project and this project's manifest are only read. **Placed** `--after`/`--before` an entry of the take (several items in the order named, one after another), else by the post's date when the take's posts are in date order, else at the end. **Again**: updated in place from the source (moved only with `--after`/`--before`), `unchanged` with no write when nothing differs. `--as`: one item under another id (a second copy). `--dry-run`: the plan and the placement, nothing linked or written. `--json`: `items[] {id, action added\\|updated\\|unchanged\\|moved, at {index, after, before}, narration {takes, pick, file}, files[], avatars[]}`, `revision`. Refused while the take renders. **Exit 0 · 1 refused (no such item, take or entry; a link out of the project) · 2 usage**"], + ["`take … --priority` · `takes make … --priority` · `render-mode on [--for 90m] [--note T] [--json \\| --print-token]` · `render-mode on [--for 90m] [--note T] [--print-token] -- <cmd …>` · `render-mode off [--force] [--json]` · `render-mode status [--json]`", + "**render mode**: a render the operator waits for gets the machine. `--priority` turns it on for the take's (or the batch's) lifetime — on at the start, off at the end, on a failure and on a signal; the Takes page's **Give renders the machine** is the same flag. While it is on, every other heavy job (e2e suites, `next build`s, the publish stages, other renders) waits at the heavy slot's door (`queue-lock: held for a render (…) — waiting`), the render runs on the floor 4000 MB and the cap 10240 MB, and the editor's transcription and download lanes are held through its ops (`lane`; only the ones not already held, and only those are released at off). `render-mode on` is a window (default 2h) for a chain of renders: every `umtool take` started in it renders in it, another command joins with the `RENDER_PRIORITY_TOKEN` it prints (`--print-token`: the token alone on stdout, the rest on stderr). **`on … -- <cmd …>` is the form for a script**: the command is spawned with the token in its environment, the hold is the command's pid, and it is released when the command exits — done, failed, or umtool signalled (the signal is passed on); umtool exits with the command's code, and inside a manual window the command joins it. A bare `on` in a script leaves the window behind (the chain trap). `off` ends it (a running take's hold only with `--force`, else it ends with the take); `status` says what holds it and releases a stale hold's lanes. A hold whose process is gone or whose window is over is no hold. Needs WORKER_TOKEN and the editor at ARCHILYZER_EDITOR_URL for the lanes; without them it still holds the door. **Exit 1** when it is already on, or a lane could not be released ([report-video.md](report-video.md#render-mode-giving-a-render-the-machine); WORKTREES.md, \"Render mode\")"], + ["`take status <project> [--id <take>] [--json] [--log] [--tail N]`", + "a take's **render record** (`takes/<take>/render.json`, written by every render whoever started it — a terminal, the Takes page, the queue): `state` (`running`, `waiting` at the heavy slot, `done`, `failed`, `cancelled`; `queued` or `blocked` while a queue step waits to render it), `stage` and a rough `percent`, the `error` (the first error line, not a bare \"exited 1\") and the log's last 40 lines (`tail`), on done the `mp4` and its measured `seconds`; `--log` prints the FULL `takes/<take>/render.log`. A \"running\" whose process is gone reads **failed** (\"the render process is gone\"); a done whose mp4 is missing or 0 bytes reads **failed**. **Exit 0 done · 3 queued, waiting or running · 1 failed, cancelled, blocked or none.** Without `--id`: every take with a record, the newest's exit ([queue and poll](#queue-and-poll-instead-of-scripting)); and its fast-feedback renders beside it, `preview` and `changes` (each one's state, mp4, seconds, log; a changes reel's piece count, its base and its list), a queued `--preview`/`--changes` step said as such -- never as the take's own render"], + ], + }, + { + cmd: "queue", + usage: [ + " umtool queue add [--after <qid>|last] [--label T] -- <umtool subcommand argv…> a step the umtool APP runs, in", + " order, one at a time (it survives the session); prints the qid. ls [--all] | status <qid> | wait <qid>", + " [--timeout S] | log <qid> | cancel <qid> | retry <qid> [--json]; status exits 0 done, 3 going, 1 failed", + ], + docs: [ + ["`queue add [--after <qid>\\|last] [--label T] [--timeout <minutes>] [--json] -- <umtool subcommand argv…>`", + "a **step** of the durable queue: the argv of a umtool command, one word per argument (no shell), stored under `<reports root>/.umtool-queue/` and run by the **umtool app** (its systemd unit), one step at a time, in order — so it survives the session that queued it, an app restart and a ship. Prints the qid (`q<N>`) alone on stdout. `--after` waits for that step to be **done**; when it fails or is cancelled this one is **blocked** (and so is whatever waits on it). `--timeout`: the step's limit (default 720 minutes). A step does not start while the app's own job runner is busy (a Takes-page job), and a heavy step still takes the machine's heavy slot and render mode by itself"], + ["`queue ls [--all] [--json]` · `queue status <qid> [--json]` · `queue wait <qid> [--timeout <s>]` · `queue log <qid> [--tail N]` · `queue cancel <qid>` · `queue retry <qid>`", + "the queue: `ls` the runner (is the app running it) and the steps not finished or finished in the last 24 h; `status` one step (**exit 0 done · 3 queued or running · 1 failed, blocked or cancelled**); `wait` the same after up to `<s>` seconds (default 90); `log` its FULL log (`logs/<qid>.log`; earlier attempts kept as `<qid>.<n>.log`); `cancel` a queued or blocked step at once, a running one stopped (its process group); `retry` a failed or cancelled step back in the queue with every step blocked behind it. A step that was running when the app died reads **failed** (\"the step's process is gone\"), its log kept — it is never re-run on its own"], + ], + }, + { + cmd: "jobs", + usage: [ + " umtool jobs [--json] every running and recent take render and queue step, across projects, and the app's jobs", + ], + docs: [ + ["`jobs [--json]`", + "every running and recent **take render** across projects (their records), every queue step not finished or finished in the last 24 h, and the umtool app's own jobs (`GET /api/jobs` at `--url` / `UMTOOL_URL`, when it answers). The page is **/jobs** (the rail's *Running* links it)"], + ], + }, + { + cmd: "takes", + usage: [ + " umtool takes make <project> [--recipe F | --all-styles] | styles | pick <project> <take> [--anyway]", + " | ls <project> | relabel <project> <take> <label…> | supersede <project> <take> [--by <take>] [--clear]", + " | delete <project> <take> [--dry-run] [--force] take housekeeping: a label fixed, a take folded away", + " as superseded, a take deleted -- refused while a render names it", + ], + docs: [ + ["`takes make <project> [--recipe FILE] [--only ID,ID] [--force]` · `takes make <project> --all-styles [--group G] [--at S --dur S \\| --full]`", + "a recipe's takes, one at a time (default `takes/recipe.json`); every montage style, one take each (Make all styles); **exit 1** if any failed"], + ["`takes styles [--json]` · `takes effects <project> [--json]` · `takes pick <project> <take> [--anyway] [--pin \\| --unpin] [--json]`", + "the montage styles; the overlay effects the cut offers (`render.chrome.fx` presets: the Takes page's **Effect** list); **Use this take** — refused (exit 1) when the project changed since the take was made, until `--anyway`; `--pin` keeps the pick when newer takes are built (each whole-cut take of the manifest is otherwise its group's pick once built), `--unpin` lets go ([report-video.md](report-video.md#takes-alternative-renders-judged-side-by-side))"], + ["`takes ls <project> [--json]` · `takes relabel <project> <take> <label…>` · `takes supersede <project> <take> [--by <take>]` · `takes supersede <project> <take> --clear` · `takes delete <project> <take> [--dry-run] [--force]`", + "**take housekeeping** (the Takes page's ✎, **Mark superseded**, **Delete take**): first the working cut's line (`Latest: draft-22 · 28:03 · +N edits since`, and the edits in words; `--json`: `working`), then the takes with latest / picked (pinned) / superseded / RENDERING; a label fixed in `take.json` (an undo point of the take's own); a take folded away as superseded (verdicts.json, nothing deleted); a take deleted. Relabel and delete are refused (**exit 1**) while the take renders or a live render is made from it ([knobs.md](knobs.md#takes-relabel-supersede-cancel-delete-fork-as-variant-compare))"], + ["`takes save <project> [--label L] [--force] [--json]` · `takes open <project> <take> [--json]` · `takes freeze <project> [<take>… \\| --all] [--apply] [--json]`", + "**the working draft and its saved versions** (Play's **Save version** and **Open in draft**): `save` freezes the draft (`video.manifest.json`) as the next `v<N>` — `takes/v<N>/base.manifest.json` byte for byte, `take.json` `version: true` — and names it the draft's parent (`takes/draft.json`); nothing is saved when the draft has no edits since its parent, unless `--force`. `open` copies a version into the draft — the draft saved first as the next `v<N>` when it has edits since its parent — with one undo point (`umtool timeline <p> undo` puts the draft and its parent back); a legacy take with its own timeline opens by its patch over the draft (as `take --promote`), another legacy take as the manifest it was rendered from (as `takes pick`). Neither touches the pick or its pin. `freeze` gives legacy takes a frozen base (the manifest each was rendered from, else the draft now) — a dry run unless `--apply`, each take's difference from how it resolves today said. Version ids are `v1`, `v2`, … — one above every `v<N>` directory under `takes/`, never reused ([knobs.md](knobs.md#the-working-draft-and-saved-versions))"], + ["`takes cancel <project> <take> [--json]` · `takes fork <project> <take> [--name N] [--json]` · `takes compare <project> <a> <b> [--json]`", + "**take housekeeping, the rest**: **Cancel render** (asked of the process rendering it, which stops its render's process group, marks the take cancelled and lets render mode go; exit 1 when it has not stopped); **Fork as variant** (a project beside this one, default `v-<take>`: the take's manifest, `variant.json`, the parent's media and assets linked, the take in it); two takes **side by side** (`<take>` or `<project>:<take>`: the facts, the cut's changes A → B, the look's differences) ([knobs.md](knobs.md#takes-relabel-supersede-cancel-delete-fork-as-variant-compare))"], + ], + }, + { + cmd: "render-mode", + usage: [ + " umtool render-mode on [--for 90m] [--note T] | off [--force] | status [--json] render mode: a render the", + " operator waits for gets the machine (other heavy jobs wait; the editor's transcription and", + " download lanes held); `on` is a window for a chain of renders (default 2h)", + " on [--for D] [--print-token] -- <cmd …>: held while <cmd> runs (its env carries the token,", + " the hold is its pid), released when it exits -- the form for a script; --print-token prints", + " the token alone on stdout", + ], + docs: [ + ], + }, + { + cmd: "pool", + usage: [ + " umtool pool [stats] [--since 7d] | prune [--max-gb N] [--dry-run] | verify [--sample N | --all] [--json]", + " the render pool: every post, clip, chunk, sound and chrome frame a build made, by its key,", + " hard-linked into any take that needs it again (UMTOOL_RENDER_POOL=0 off; _MAX_GB its cap)", + ], + docs: [ + ], + }, + { + cmd: "trailer", + usage: [ + " umtool trailer <project> --take <t> (--beats F | --beats-json J) [--intro] [--finale S] [--xfade 0.3] [--out NAME]", + " a trailer cut from the take's finished master: the master's own frames, so the deck shows the", + " whole timeline; beats are clip source seconds or master seconds ([--dry-run] the mapping only)", + " --reel <name> [--take <t>]: a beat reel's beats and settings (promo/<name>-beats.json),", + " written to takes/<t>/out/<slug>.<name>.mp4; no --take: its pinned, last-cut or latest master", + " --vertical [--layout reframe] [the vertical flags]: the reel 9:16 (umtool vertical --reel)", + ], + docs: [ + ["`trailer <project> --take <t> (--beats FILE \\| --beats-json JSON) [--intro] [--finale S] [--xfade 0.3] [--no-snap] [--out NAME] [--dry-run] [--json]`", + "a **trailer cut from the take's finished master**: spans of the master's own frames (the deck shows the whole timeline), clip beats in source seconds mapped by the take's build records, each clip beat's end moved forward into the next pause (through its sentence when one ends within 1 s) and its start back into the one before, so the crossfade lands in quiet, each move said (`--no-snap`: the edges as written), crossfaded, the take's encode, in the heavy slot; writes `takes/<t>/out/<slug>.trailer.mp4` and `.trailer.json`; **exit 1** on a refusal ([report-video.md](report-video.md#trailer-from-the-master)) · `--reel <name> [--take <t>]`: a **beat reel** -- its own beats file (`promo/<name>-beats.json`), crossfade, intro (one rendered for the reel when the master has none, or the reel's own) and outro card (the title, the call to action, an image, the site's name; faded in from the last beat, held to the end), written to `<slug>.<name>.mp4`; no `--take`: its pinned take, else the one it was last cut from, else the latest finished master ([report-video.md](report-video.md#beat-reels))"], + ], + }, + { + cmd: "vertical", + usage: [ + " umtool vertical <project> --take <t> (--reel R | --beats F | --items a,b) [--clip full|framed|quote]", + " [--post card|stack|media] [--side split|overlay] [--hook title|section|<copy>] [--reframe] [--json]", + " a vertical short (1080x1920, -14 LUFS) of the take's items: each clip cut again in its layout,", + " each post drawn in a portrait box; --reframe recomposes the finished 16:9 master instead", + ], + docs: [ + ], + }, + { + cmd: "trailer-beats", + usage: [ + " umtool trailer-beats <project> [ls] | add <clip> [<from>-<to>] [--at N] [--label L] | add-raw <at> <dur> | set <n> <from>-<to>", + " | remove <n> | move <n> --to <m> | order | limit <s|m:ss|x|instagram|shorts|tiktok> | xfade <s> | intro on|off", + " | candidates [--add] the trailer's beats (promo/trailer-beats.json, the Trailer page's file): each", + " beat's length, the running length against the platform limit (X 2:20), beats outside their clip", + " | verdict <n> confirmed|note|clear | title T | take T | undo | reels | new-reel <name> [--from R]", + " --reel <name>: that beat reel (promo/<name>-beats.json); every write is an undo point", + ], + docs: [ + ["`trailer-beats <project> [ls] [--json]` · `add <clip> [<from>-<to>] [--at N] [--label L]` · `add-raw <at> <dur>` · `set <n> <from>-<to>` · `remove <n>` · `move <n> --to <m>` · `order` · `limit <s\\|m:ss\\|x\\|instagram\\|shorts\\|tiktok>` · `xfade <s>` · `intro on\\|off\\|'<render.intro JSON>'` · `outro on\\|off\\|none\\|'{title,text,image,seconds}'` · `candidates [--add]` · `verdict <n> confirmed\\|note\\|clear` · `title <text>\\|none` · `take <t>\\|none` · `undo` · `reels [--json]` · `new-reel <name> [--from <reel>] [--title T]` · `gap <n> add <from>-<to>\\|remove <s>\\|clear` · `status [--take <t>] [--json]` · `anchor [<n>…] --take <t>` · `clamp <n>` · `repoint <n> <clip>` · `history [--json]` · `--take <t>` on an edit · `--reel <name>` on any", + "**the trailer's beats** (`promo/trailer-beats.json`, the Trailer page's file, what `trailer --beats` reads) or another **beat reel's** (`--reel`: `promo/<name>-beats.json`): each beat's length, the running length against the platform limit (X 2:20 by default), beats outside their clip's window, the cut's order, the walk's ★ clips; the reel's own intro and its outro card (`ls`: `· outro 3.5 s`, counted in the length); every write an undo point and a history entry; a beat's gaps (two moments of one clip as one beat of jump cuts); each beat read against the take now -- what it was cut against, what changed (`status`), and the fixes ([knobs.md](knobs.md#the-trailers-beats), [reels track their source](knobs.md#reels-track-their-source))"], + ], + }, + { + cmd: "tighten", + usage: [ + " umtool tighten <project> [--json] [--all] [--no-measure] | --apply <clip>[,<clip>…] each clip to its sentence (its", + " cut's, else the whole ones in its window), each edge into its pause; before -> after; --apply writes", + ], + docs: [ + ["`tighten <project> [--json] [--all] [--no-measure]` · `tighten <project> --apply <clip>[,<clip>…]`", + "the Cut tab's **Propose tight windows**: each clip to its sentence (the sentences its cut touches, else the whole ones inside its window) and each edge into its pause (the build's measured silences and the gaps between the recording's timed words, ≤ 1 s, inside the cached window) — before → after with the seconds, the clips that would change (`--all`: every clip); prints only. `--apply` writes the named rows through the window writer (the token, the cite that follows the edge); a lock is kept (it is against `resolve-windows`, not a person) ([knobs.md](knobs.md#tighten-to-the-sentence-snap-to-a-pause))"], + ], + }, + { + cmd: "ledger", + usage: [ + " umtool ledger <project> [ls] [--scope S] [--json] | add <id> --date D --scope S --population P [--value V] --scopeBasis \"…\" [--<key> V …] | set <id> --<key> V … [--unset k,k] | rm <id>", + " a measure ledger's rows, checked against its ledgerSchema (incl. promise / promise_check, run, retro)", + ], + docs: [ + ["`ledger <project> [ls] [--scope S] [--population P] [--json]` · `ledger <project> add <id> --date D --scope S --population P [--value V] --scopeBasis \"…\" [--<key> V …] [--row '{…}']` · `ledger <project> set <id> --<key> V … [--unset k,k]` · `ledger <project> rm <id>`", + "a **measure ledger's rows** (`ledgerSchema.kind \"measure\"`), the only writer of them: each row is checked against the schema -- a track, a form (and the promise forms `promise` / `promise_check`), a number in its unit or a declared regime with an event, the six adjudication fields (a new row defaults `scopeConfidence` read, `valueKind` uttered, `flags` []; `--scopeBasis` is never defaulted), the declared fields, and the instruments' own keys: `run` (a loss claim's run), `retro` (a loss told in the past with no `asOf`: off the odometer), `promise`, `kept`, `due`, `speaker` (another party's key: her rows move none of his numbers), `paidOn`, `outcome` (a `promise_outcome`'s: kept, refunded, withdrawn); the promise forms are `promise`, `promise_check`, `promise_claim`, `promise_outcome`. `rm` refuses a row an entry pins or another row names ([knobs.md](knobs.md#the-measure-slice-the-weight-instruments))"], + ], + }, + { + cmd: "measure", + usage: [ + " umtool measure <project> [--take <t>] [--scopes a,b] [--scale MIN-MAX] [--as-of YYYY-MM-DD] [--json]", + " the measure slice the instruments draw from: events at their cut seconds, hidden rows, totals", + ], + docs: [ + ["`measure <project> [--take <t>] [--scopes a,b] [--scale MIN-MAX] [--as-of YYYY-MM-DD] [--json]`", + "the **measure slice** the instruments draw from (`render.chrome.deck.measure`; the flags override it): each row in scope the cut shows at the cut second its figure is said, the hidden rows, and the totals -- the odometer's runs, NET, the goals, the diets, the promises. The take's built `schedule.json` with `--take`, else an estimate; `--json` prints the slice. Reads only ([knobs.md](knobs.md#the-measure-slice-the-weight-instruments))"], + ], + }, + { + cmd: "rulings", + usage: [ + " umtool rulings <project> [--json] | import [--dry-run] | set <clip> keep|cut|not-him|read-aloud [--reason R] [--match M] | clear <clip>", + " the clip deck's montage rulings (montage-rulings.json); a render leaves the ruled-out clips out", + ], + docs: [ + ["`rulings <project> [--json]` · `rulings <project> import [--dry-run] [--json]` · `rulings <project> set <clip\\|key> keep\\|cut\\|not-him\\|read-aloud [--reason R] [--match M]` · `rulings <project> clear <clip\\|key>`", + "a montage's **clip rulings** (`montage-rulings.json`, the clip deck's): each clip and its ruling and the next render's kept clips; the earlier rulings in the seed's `edits.json`, once; one ruling set or cleared. A render leaves out every clip ruled cut, not-him or read-aloud ([report-video.md](report-video.md#ruling-the-clips))"], + ], + }, + { + cmd: "fetch", + usage: [ + " umtool fetch <project> [--dry-run | --wait | --status | --body] [--reason R] [--json]", + " the clip windows asked of the editor as one fetch-windows batch (one paced job per platform);", + " each run recorded in <project>/fetch-runs.json; --refetch <clipId>[,…] / --refetch-video <slug>/<id>", + " evict those clips' cached windows first (the editor's evict-clips), then fetch", + ], + docs: [ + ["`fetch <project> --body` · `fetch <project> --dry-run [--json]` · `fetch <project> [--wait] [--json]` · `fetch <project> --status [--json]` · `… [--reason R]` · `… --refetch <clipId>[,…]` · `… --refetch-video <slug>/<id>` · `… --take <take>`", + "**Fetch windows** (the Cut tab's and the clip deck's button): every clip's window asked of the editor as ONE fetch-windows batch — `--body` prints the body and asks nobody; `--dry-run` the editor's plan (groups per platform, cached, in flight, unresolved); no flag starts it (one paced job per platform queue), `--wait` follows the jobs to their end and names each window a job failed; `--status` follows the last run's jobs once. Clips the montage rulings leave out are not asked for. `--refetch <clipId>[,<clipId>…]` evicts the cached windows that OVERLAP those clips' fetch spans first (the editor's `evict-clips` `{slug, id, covering}`, one job per video, waited for), then fetches as usual — for windows known bad (cut from a corrupt saved video); `--refetch-video <slug>/<id>` does it for every window the project asks of that video; with `--dry-run` the eviction is a dry run too and names what it would remove. `--take <take>` asks for a TAKE's clips instead — its manifest as its walk reads it (the project's now with the take's patches; a draft's too, nothing rendered), so a clip only the take has is fetched; the run is recorded with `take`, and `--status --take` follows the take's last run (the cut's never reads a take's). Every run is recorded in `<project>/fetch-runs.json` (a refetch's evictions under `refetch`). Needs WORKER_TOKEN (else the editor's env files) and the editor at ARCHILYZER_EDITOR_URL. **Exit 1** when a job failed or the editor refused ([report-video.md](report-video.md#fetching-the-windows-and-stand-ins))"], + ], + }, + { + cmd: "prep", + usage: [ + " umtool prep <project> [--clips a,b] [--wait | --status] [--json]", + " what the clip bench makes on a clip's first open (a long recording's excerpt, the waveform),", + " made before the walk: queued and run in the background, one clip at a time, in the heavy slot", + " (a small declared estimate), under nice/ionice; --wait runs it here; a write or a fetch queues it too", + ], + docs: [ + ["`prep <project> [--clips a,b] [--json]` · `prep <project> [--clips a,b] --wait` · `prep <project> --status [--json]` · `… --take <take>`", + "**Prepare clips for the walk** (the Cut tab's): what the clip bench makes on a clip's first open — a long recording's excerpt, the waveform — made ahead ([clip-bench.md](clip-bench.md#prepared-before-you-open-it)). No flag queues it and returns (a runner starts in the background, its log `out/bench-excerpts/prep.log`); `--wait` runs it here to the end; `--status` prints ready / to prepare / failed / not fetched and the runner. One clip at a time, each in the heavy slot (estimate 400 MB), under `nice -n 19` and `ionice -c3`; a prepared clip is skipped. A fetch that lands and a write that moves or adds a clip queue it too (`UMTOOL_BENCH_PREP=0` turns that off). `--take <take>`: a TAKE's clips (the take's walk page has the same button) — its manifest as its walk reads it, a draft's too — with its own status, queue, runner and log under `out/bench-excerpts/takes/<take>/`, so a take's clip that carries the cut's id with other bounds never shares the cut's state; a save on the take's walk queues it. The plan does not depend on the directory it is run from. **Exit 1** when a clip failed (`--wait`)"], + ], + }, + { + cmd: "prune", + usage: [ + " umtool prune [<project> [--take X] [--anyway] | --all] [--keep N] [--older-than 3d] [--idle-work 3d] [--yes] [--json]", + " takes' work files (segments, chrome frames, crossfade batches, encode chunks, the rail's prerail base):", + " what each holds (hard links counted by inode), which takes keep theirs and why, what freeing the rest", + " gives back; a dry run unless --yes. A take build prunes its project after; a render prunes when disk is", + " low. --idle-work D: in a project untouched for D, the newest/picked takes' work goes too", + " umtool prune [<project> | --all] --versions [--idle 3d] [--grace 7d] [--idle-work 3d] [--yes] [--json]", + " whole SUPERSEDED takes, through `takes delete`: per version line (the id, digits folded:", + " draft-# ; letters never: v6c ≠ v6d) the highest built number is kept, older ones while it is", + " younger than --grace, and any take picked, judged, rendering, a base, noted on or refused;", + " a project touched within --idle, or whose verdicts.json cannot be read, is skipped", + ], + docs: [ + ["`prune <project> [--take X[,Y]] [--anyway] [--keep N] [--older-than 3d] [--yes] [--json]` · `prune --all [--keep N] [--older-than 3d] [--yes] [--json]`", + "**the takes' work files** (the Takes page's **Free work files**): per take its work — segments, chrome frames, crossfade batches, encode chunks, raw clip copies, `work-from-*` — counted by inode (a file hard-linked into two takes is counted once and freed only when both let it go), what freeing it gives back, or why it is kept: a running build or the take one builds from (never freed), the picked or current take, a pin in `takes/prune.json`, the newest `--keep` (2) of its group, anything modified within `--older-than` (3d), the `--from` bases of those. A dry run unless `--yes`; `--take X --anyway` frees a take the policy keeps. Renders, previews, take.json and manifests are never touched. **Exit 1** when a path could not be removed ([report-video.md](report-video.md#a-takes-work-files-and-pruning-them))"], + ], + }, + { + cmd: "fallback", + usage: [ + " umtool fallback <project> [--dry-run | --clip <id> … | --restore <clipId>] [--json]", + " stand-ins for refused montage windows: the instance's public alternate (YouTube first), on the clip", + ], + docs: [ + ["`fallback <project> --dry-run [--json]` · `fallback <project> [--clip <id> …] [--json]` · `fallback <project> --restore <clipId>`", + "**stand-ins** (the clip deck's **Use stand-in** / **Restore**): a montage clip whose window a fetch run says the editor refused, and is not on disk, switched to its phrase-scan instance's first public alternate (YouTube, then Odysee / cornbreadman, then the rest) — recorded on the clip as `fallbackFrom`, its ruling and voice-match row moved with it; `--restore` puts it back. An older `phrase-scan.json` with no `alternates` is scanned again. **Exit 1** when a named clip has no stand-in"], + ], + }, + { + cmd: "phrases", + usage: [ + " umtool phrases \"<phrase>\" [\"<phrase>\" …] --channels a,b [--prefer c] [--exclude RE] [--words|--regex] [--json]", + " how often each phrase was said, by year, in one pass (the phrase finder's search)", + ], + docs: [ + ["`phrases \"<phrase>\" [\"<phrase>\" …] --channels a,b [--prefer c] [--exclude RE] [--words \\| --regex] [--samples N] [--no-cache] [--json \\| --full]`", + "the phrase finder's search ([tools.md](tools.md#the-phrase-finder-toolsphrases)): every phrase in one pass, each with its count once folded, by year, the preferred channel's share or Rumble's, speaker changes, sample contexts. Plain words become a tolerant pattern unless the phrase holds a regular expression's characters. `--json` the numbers, `--full` every instance; `--spec FILE --out FILE --progress` is the page's job form. **Exit 1** on a bad phrase"], + ], + }, + { + cmd: "voice-match", + usage: [ + " umtool voice-match <project> [--reference auto|rulings|recordings] [--reference-video <channel>/<id> …] [--instances F] [--dry] [--json]", + " a local speaker-similarity score per montage clip (TitaNet-small) -> <project>/voice-match.json", + ], + docs: [ + ["`voice-match <project> [--reference auto\\|rulings\\|recordings] [--reference-video <channel>/<id> …] [--reference-channel <slug> …] [--instances FILE] [--span phrase\\|cut] [--pad S] [--likely X --unlikely Y] [--out FILE] [--dry] [--json] [--progress ndjson]`", + "who is speaking, per montage clip: a local speaker-similarity score (TitaNet-small) against the host's voice → `<project>/voice-match.json` (the Cut tab's **Score the voices**); `--instances` also scores a phrase scan's instances not in the manifest; `--dry` prints the plan ([report-video.md](report-video.md#who-is-speaking-the-voice-match))"], + ], + }, + { + cmd: "clips", + usage: [ + " umtool clips analyze <project> [--from <channel>/<id>] [--rescan] [--no-laughs] [--no-voices] [params]", + " umtool clips propose <project> [--host N] [params] [--dry] | show <project> | segments <project>", + " the clip finder: the laugh scan + voices on the recording's sound, then clips proposed", + " (setup → reaction → tail) into the manifest (assist: by the assistant) and reactions.json;", + " params --target S --laugh-min X --merge-gap S --setup-max S --clip-max S; a clip you edited is never moved", + ], + docs: [ + ["`clips analyze <project> [--from <channel>/<id>] [--rescan] [--no-laughs] [--no-voices] [params] [--words FILE] [--progress ndjson] [--json]` · `clips propose <project> [--from <channel>/<id>] [--host N] [params] [--words FILE] [--dry] [--json]` · `clips show <project> [--json]` · `clips segments <project> [--json]`", + "the **clip finder** on a long recording ([report-video.md](report-video.md#highlights-the-clip-finder)): `analyze` runs the laugh scan (CED-mini) and a voice centroid per speaker on the recording's sound (cached in `<project>/scans/`), then proposes; `propose` proposes again from what is there (after a role flip, a param change, new words); `show` prints the speakers, laughs and the cut. Params `--target S` (600) `--laugh-min X` (0.25) `--merge-gap S` (6) `--setup-max S` (20) `--clip-max S` (75) and the scope `--scope FROM:TO` (either side may be empty; `all` clears it) or `--from S --to S` with numbers (a `--from` that is a `<channel>/<id>` names the recording), kept in `reactions.json`; `--host N` is your word on the host, kept. `--keep-cut` proposes without touching the cut (nothing moved, removed or added; the proposals are listed). **`--scope auto`** reads the narrated video auto-scope finds in the speaker turns (`--segment sN` names one, else the longest); `segments` lists them. A chat replay beside the recording (`live_chat.cues.json`) adds chat-burst moments and the log names the chat's lag. A channel on no site gets each clip linked to its platform page (`citeUrl`). A clip you edited, ruled, locked or added is never moved. **Exit 2** with no `diarization.json` (the message names the `archilyzer diarize backfill` to run)"], + ], + }, + { + cmd: "refresh", + usage: [ + " umtool refresh <article> [--iteration N] [--no-fetch] [--yes] [--json]", + " re-fetch an article's scope, see what changed, update: the plan (the editor's);", + " --yes starts it, one editor job (needs WORKER_TOKEN and the editor)", + " umtool refresh --check [<article>] [--force] [--json] the daily suggestion check, now", + ], + docs: [ + ["`refresh <article> [--iteration N] [--no-fetch] [--yes] [--json]` · `refresh --check [<article>] [--force]`", + "the refresh's plan, `--yes` starts it; the daily check now ([refresh.md](refresh.md))"], + ], + }, + { + cmd: "clip", + usage: [ + " umtool clip <channel>/<video>@<start>-<end> [--snap words] [--title T] [--site <id>] [--json]", + " QUICK CLIP: a basic-mode project (the footage alone), its window asked of the editor, its", + " edges snapped to the words (--snap words), rendered as a take; prints the mp4 and its share line", + ], + docs: [ + ["`clip <channel>/<video>@<start>-<end> [--snap words] [--title T] [--site <id>] [--folder F] [--json] [--progress ndjson]`", + "**quick clip**: a basic-mode project (`quick-clips/<slug>`, the footage alone), its window asked of the editor (fetch-windows, followed to its end; Rumble fetched whole), `--snap words` its edges snapped to the words heard (the editor's transcribe op), rendered as the take `clip` (`take <p> --id clip --full`: the heavy slot), then the mp4's path and the share line. `--json`: `{project, output, share: {platform, archive, text}, snapped?}`; `--progress ndjson`: events, the last `quick-clip` (the app's `POST /api/report/quick-clip` job). **Exit 0 · 1 failed (the editor, the render) · 2 usage** ([knobs.md](knobs.md#basic-output-the-footage-alone))"], + ], + }, + { + cmd: "share", + usage: [ + " umtool share <project> [<clip>] [--take <id>] [--site <id>] [--json] a clip's share line: its platform", + " page at the moment and its archive moment (a Rumble folder id mapped to the embed id)", + ], + docs: [ + ["`share <project> [<clip>] [--take <t>] [--site <id>] [--json]`", + "a clip's **share line** (the clip named, else the first): its platform page at the first second it plays and its archive moment, a Rumble folder id as the embed id the archive serves — the twin of **Copy share line** (`GET /api/report/share-line`). `--json`: `{clip, seconds, platform, archive, text}`"], + ], + }, + { + cmd: "timeline", + usage: [ + " umtool timeline <project> [ls] [--json] the cut: index, id, type, video, start–end, date title", + " umtool timeline <project> insert --after <id|-> <channel>/<video>@<start>-<end> [--id ID] [--section N]", + " [--lock] [--lock-end] [--title T] [--stream-title T] [--date YYYY-MM-DD] [--quote Q] [--cite S]", + " [--cite-url U] a clip, then its attribution, in the manifest's convention (deck: onscreen.title)", + " umtool timeline <project> move <id> --to <index> | remove <id> | duplicate <id> [--at <index>]", + " umtool timeline <project> post <json|@file> | post-remove <id> | teaser <id> <patch-json|@file> | undo", + " the Cut tab's structure (POST /api/report/timeline's writers): each write snapshots the", + " manifest first (revisions/…-auto-before-<op>), is checked by the build, notes a generated cut", + " umtool timeline <project> --take <id> [ls | move <id> --to <index> | remove <id> | undo] a take's timeline:", + " the writes go into its patch (takes/<id>/take.json), each with an undo point of its own", + ], + docs: [ + ["`timeline <project> [ls] [--json]` · `timeline <project> insert --after <id\\|-> <channel>/<video>@<start>-<end> [--id ID] [--section N] [--lock] [--lock-end] [--title T] [--stream-title T] [--date YYYY-MM-DD] [--quote Q] [--cite S] [--cite-url U]` · `timeline <project> move <id> --to <index>` · `place <id>… --before <id\\|-> [--section N]` · `remove <id>` · `reject <id> <why> [--note T]` · `wrong-speaker <id> [--correction T]` · `duplicate <id>` (`--at <index>` names one of an id's twins) · `post <json\\|@file>` · `post-remove <id>` · `teaser <id> <patch-json\\|@file>` · `undo`", + "the **structure** of the cut (the Cut tab's timeline, the On-screen section's teasers and posts) through the writers `POST /api/report/timeline` runs: `ls` prints index, id, type, video, start–end, date and title (`--json` adds the token and the posts); an insert's attribution is a second write through `window`'s writer, its date checked before anything is written; it is written in the manifest's own convention — under the deck `--title` is the deck's title (`onscreen.title`, `--stream-title` the stream's), a cut whose deck titles are dates gets `--date` as one in their format, and the clip takes the section of the clip it goes after (`--section N` names another) and, from the same recording, its deck title and its citation link. `place` is Play's drag on the reel strip: the entries land before that entry (`-`: the end), their clips joining section N (default: the section of the clip they land after), every other clip keeping its own and the markers following, an emptied section refused, each place its own undo point ([knobs.md](knobs.md#the-reel-strip-zoom-and-reorder)). A removal re-anchors what named the clip (a marker to the clip before, a chapter to the next in its section; a pair, a status reference or a deck claim dropped) and prints each `re-anchored:` line; `reject` rejects the clip for `<why>` — `not-matching` or `wrong-speaker` (fact errors: `incorrect`, the note its correction) or `irrelevant`, `repeats`, `weak`, `privacy`, `other` (`rejected`, never a correction) — and removes it, on record in `removed.json` with the reason and the note; `wrong-speaker <id>` is `reject <id> wrong-speaker`; `ls` marks a clip rejected but still in the cut (`[rejected — irrelevant]`) ([report-video.md](report-video.md#verdict--what-the-walk-said)). Every write snapshots the manifest first (`revisions/…-auto-before-<op>`), is refused only for what it breaks in the build's own words (**exit 1**), and on a generated manifest leaves an `edit` note ([report-video.md](report-video.md#structural-edits))"], + ["`timeline <project> insert (--to-section N \\| --group G) <channel>/<video>@<start>-<end> [--id ID] [--lock] [--title T] [--stream-title T] [--date YYYY-MM-DD] [--quote Q] [--cite S] [--cite-url U]`", + "a clip at the **end of section N**, or **after group G's last clip and one of its clips** (the run stays together): one write, the marker that followed that last clip re-anchored after the new one, so the clip lands in the section and every other clip keeps its own; the attribution as `insert --after`'s. The Candidates panel's Insert is this ([knobs.md](knobs.md#the-candidates-inbox-proposed-clips-picked-by-a-press))"], + ["`timeline <project> groups [ls] [--json]` · `groups import <file> [--skip-missing] [--drop-empty]` · `groups set <gid\\|-> <id…> [--claim C]` · `groups move <gid> --to <index>` · `groups move <gid> --to after <gid>` · `groups label <gid> <claim…>` · `groups promote <gid> [--label L]` · `groups remove <gid>` · `order <file\\|@file\\|id…>`", + "**claim groups** (`groups` beside the timeline; the Cut tab's group bars): runs of clips inside one section making one claim — `ls` by section, each group's id, claim and clips (`--json` with the token); `import` a claim-groups file (`{sections: [{label, groups: [{claim, ids}]}]}`) in ONE write — the cut re-ordered to it, its groups the cut's, the markers following; a file section is the deck section of its name, else the one most of its clips are in; **exit 1** for an id the cut lacks (`--skip-missing`) or a section left with no clip (`--drop-empty` removes its marker); `set` (the clips already together), `label`, `remove` (ungroup), `move` the whole group (before the group at that index, or after one, in its section), `promote` (a level-2 marker at its first clip titled with its claim — the one group edit the render sees; `--label` when the claim is over 24); `order` the named entries in the places they hold (every clip keeping its section). A clip moved out of its group's run leaves it; moved alone into the middle of one, it joins. Every write an undo point (`undo`) ([knobs.md](knobs.md#claim-groups-runs-of-clips-that-make-one-claim))"], + ["`timeline <project> --take <take> [ls \\| move <id> --to <index> \\| remove <id> \\| undo \\| insert <spec> --after <id>\\|-]`", + "a **take's** timeline (walk a take): the same structure checks, written into the take's patch, each write with an undo point of the take's own (`takes/<take>/revisions/`); `undo` takes the take's newest edit back, whichever writer made it. `insert` puts a clip (`<channel>/<video>@<start>-<end>`) into the take only (`takeEdit.mjs insertTakeEntry`) -- the app's **+ Add a clip to <take> only** on the take walk page, and Play's **+ Add a clip here** on a take with its own timeline"], + ["`timeline <project> sections [--json]` · `section-move <id>… --to-section N [--start]` · `section-add --after <id> [--label L] [--color C]` · `section-boundary <marker> --after <id>` · `section-remove <marker>` · `section-set <marker> [--label L] [--color C]` · `split <id> <second>` · `flash-forward <id> <from>-<to> (--after <id\\|-> \\| --to-section N [--start]) [--move] [--quote Q] [--id ID]`", + "**sections as sections** (the deck's markers; the Cut tab's section bars and row menus): clips moved to a section with every marker following, a section opened, a boundary moved, relabelled, removed — no section emptied, no boundary crossed (**exit 1**) — and every take patch in step synced; **split** (each half's quote from the words, the second half's cite and QR at its second, a marker after the clip following its second half); **flash-forward** a tight copy of a span elsewhere with the clip's attribution and locks, as `repeatOf` the clip (`--move`: out of the clip) ([knobs.md](knobs.md#sections-split-and-flash-forward-editing-the-cut))"], + ["`timeline <project> threads [--json]` · `timeline <project> threads --write [--conversation <id>]`", + "**the cut's conversations** ([report-video.md](report-video.md#thread-reads), `post-conversation.mjs`): each tree of two post items or more — its root, its items' places, whether they play as one run (one scene) or are split by other entries, a reply placed before the post it answers, an item re-reading a post its run already read (with `posts set-item <p> <item> thread.parent.<i>=context`). `--write` gathers each (or the one holding `<id>`: its root, a post, an item, a `thread.group` name) at its first item's place in TREE order (a manual thread: in DATE order) — a post after what it answers, sibling branches by date, each depth first — in ONE write (one undo point); never across a section boundary (gathered within each section, and said)"], + ["`timeline <project> [--take <t>] add-video <src> [--from S] [--to S] [--fit contain\\|cover] [--bass dB] [--gain dB] [--enter cut\\|<out>,<in>] [--hold S] [--title T] [--id ID] [--after <id>\\|-] [--dry-run] [--json]` · `timeline <project> [--take <t>] set-video <id> <key>=<value>…`", + "**a video entry** ([report-video.md](report-video.md#a-video-entry)): a file of the project (`src`, relative; probed, its `fileSeconds` written) played FULL FRAME with its own sound, nothing drawn over it, at the end unless `--after` (`-`: the start), into the cut or the take's timeline only (`--take`, an undo point of the take's); `set-video` sets `from= to= fit= audio.bass= audio.gain= enter=cut\\|<out>,<in> enter.out= enter.in= holdLast= deck=hidden\\|shown title= note= src=` (`key=` clears). `--dry-run`: the entry and its place, nothing written. `--json`: `{ok, op, take?, inserted\\|updated {id, at, entry}, revision?}`. **Exit 0 · 1 refused (no such file, take or entry; the build would not take it) · 2 usage**"], + ["`timeline <project> insert (--after <id\\|-> \\| --to-section N \\| --group G) post:<channel>/<postId> [--id ID]`", + "**one post item** among the cut's entries, made as `posts reel` makes one"], + ["`timeline <project> insert (--after <id\\|-> \\| --to-section N \\| --group G) post-json:<json>\\|post-json:@<file> [--id ID]`", + "**a post item made by hand** — a post no archive holds (one kept only as a picture): `{post: \"<channel>/<postId>\", author, handle, date, text, media: [\"posts-media/…\"], parents?, quoted?, subjects?, redact?}`, its media measured, its id `p-<postId>` unless `--id`; refused in the build's words (**exit 1**). Its avatar: `posts avatar <project> <handle> <file>`"], + ], + }, + { + cmd: "scenes", + usage: [ + " umtool scenes <project> <clip> [--black-min 0.05] [--threshold 8] [--pix-th 0.10] [--pad 30 | --from S --to S] [--json]", + " scene cuts (scdet) and black spans (blackdetect) in the clip's fetched window, in SOURCE", + " seconds — for blur.from/blur.to and trims; nothing fetched (`umtool fetch` first)", + ], + docs: [ + ["`scenes <project> <clip> [--black-min 0.05] [--threshold 8] [--pix-th 0.10] [--pad 30 \\| --from S --to S] [--json]`", + "the picture's **scene cuts** (ffmpeg `scdet`, score ≥ threshold) and **black spans** (`blackdetect`) in the clip's fetched window, in SOURCE seconds — for `blur.from`/`blur.to` and trims ([knobs.md](knobs.md#a-clips-picture-blurred)). The window is the one the build would cut from (the project's `out/clips-raw`, the editor's `channels/<slug>/data/<id>/clips/`, a saved source); the extent ± `--pad` inside it is scanned. Nothing is fetched: **exit 1** with no window on disk (`fetch` first)"], + ], + }, + { + cmd: "posts", + usage: [ + " umtool posts add <project> <archive-channel>/<postId> [--attach <clipId>] [--flag F] [--author A] [--id ID] [--thread] [--json]", + " a post entry from the corpus's posts archive, its screenshot copied into posts-media/;", + " refused when the post has no shot (`pnpm ops capture-posts` first); --thread: a reply drawn", + " with the post it answers above it (shot-thread.png, capture-posts \"thread\": true)", + " umtool posts set <project> <post> thread=on|off [hide=on|off] [attach=<clipId>|auto] [--json]", + " the Posts table's writer (updatePosts); <post> is x-<postId> or the bare <postId>", + " umtool posts reel <project> --channel <slug> [--channel …] [--since D] [--until D] [--own] [--with-media]", + " [--replies include|only|exclude] [--order chrono|reverse] [--limit N] [--after <id|->] [--dry-run] [--json]", + " POST ITEMS: each archived post an entry of the cut (its card, its attachments played), one write;", + " a re-run adds only posts not already in the cut", + " umtool posts set-item <project> <item> [hold=<s>|off] [layout=sequence|grid] [redact=on|off|auto] [media.<i>.start=<s>]", + " [media.<i>.end=<s>] [media.<i>.mute=on|off] [media.<i>.crop=x,y,w,h|off] [media.<i>.push=on|off] [--json]", + " umtool posts narrate <project> [--import | --list | <item> [--script \"…\"] [--take [--note \"…\"]] [--pick n] [--approve] [k=v …]", + " | --all --draft-scripts | --all --take | --cut k=v …] a post read aloud (its takes: the editor's tts or yours)", + " umtool posts narrate <project> <item> --take --thread [--parents 0|all] [--skip-parent <id>]… [--no-quoted]", + " [--voice-for <handle>=<voice>]… [--dry-run] [--json] a THREAD READ: its context and his words in date", + " order, each in its author's voice, parts cached, one take saved and picked (exit 0 / 1)", + " umtool posts set-item | roles | narrate | reread | fx … --in-take <take> the same edit on a TAKE of the project:", + " its manifest read as the take's, the write in takes/<take>/take.json's patch (an undo point of the take's,", + " `umtool timeline <p> --take <take> undo`), the project's manifest untouched; set-item/roles/reread/fx", + " take --take <take> for it too (narrate's --take is a new read)", + " umtool posts say <project> ls | add <word> \"<spoken>\" [--case] [--item <id>] | remove <word> | try \"<text>\" | stale", + " the PRONUNCIATION LEXICON every synthesized read applies (stale: picked reads that say it the old way)", + " umtool posts voices <project> ls | set <handle|*> <voice> | remove <handle> the voice map a thread read uses", + " umtool posts fit <project> [--all | <item> …] [--linger s] [--dry-run] narrated posts' videos cut to their best part", + " umtool posts avatar <project> [<handle> <image>|off] · avatars <project> the authors' pictures on the cards", + " umtool posts redact <project> ls | add \"<term>\" [--substring] [--note \"…\"] | remove <n> words blanked from", + " what is published (a bar on the card, left out of a synthesized read); the data never rewritten", + " umtool posts repeats <project> [--match id|file|audio] [--json] the attachments played more than once (the combo counter)", + " umtool posts combo <project> [k=v …] · <item> off|on|k=v … the combo badge's knobs (the cut's, one item's)", + " umtool posts attach <project> [<item> … | --all] [--dry-run] a capture's media onto post items that carry none", + ], + docs: [ + ["`posts set <project> <post> thread=on\\|off [hide=on\\|off] [attach=<clipId>\\|auto] [crop=<px>\\|off] [--json]`", + "the Posts table's writer (`updatePosts`, `PUT /api/report/posts`) from a terminal: `<post>` is the manifest's id (`x-<postId>`) or the bare `<postId>`; `thread=on` draws a reply with the post it answers above it (`shot-thread.png` beside its `shot`, taken by `capture-posts` `\"thread\": true`; its own shot while there is none), `off` removes the key.; `crop=<px>` the post's own crop of its screenshot (`shotMaxHeight`, 120–1080: its top that tall, never panned; `off` removes it) ([knobs.md](knobs.md#add-post-a-post-card-from-play-the-cut)). Refused in the build's words (a post with no `shot`, an `attach` that is not a clip) — **exit 1**"], + ["`posts add <project> <archive-channel>/<postId> [--attach <clipId>] [--flag F] [--author A] [--id ID] [--thread] [--crop <px>] [--dry-run] [--json]`", + "a **post card** from the corpus's posts archive (`channels/<slug>/posts/*.jsonl`): its words, date, link and handle; id `x-<postId>` (`bsky-`, `post-`); the author an earlier post by the same handle carries in the cut, else the archive's. Its capture (`posts-media/<postId>/`: `shot.png`, `capture.json`, the post's pictures) is copied to the project's `posts-media/<slug>/<postId>/` — or used where it is, when that folder links the channel's captures; never copied through a link anywhere else. Then `upsertPost` (a post with the id is replaced, its `attachTo` kept). **Exit 1** with no screenshot, naming the `pnpm ops capture-posts` to run. `--thread`: the entry gets `thread: true` (a reply drawn with the post it answers; `shot-thread.png` is copied with the rest, and with none yet it prints the `\"thread\": true` capture to run). `--crop <px>`: the post's own crop (`shotMaxHeight`). A post that quotes another, reposts one or carries media is added with a `WARNING:` line (`--json`: `warnings`) — its screenshot shows them, by the post's own data. Play the cut's **Add post** runs this same write ([knobs.md](knobs.md#add-post-a-post-card-from-play-the-cut))"], + ["`posts reel <project> --channel <slug> [--channel <slug> …] [--since YYYY-MM-DD] [--until YYYY-MM-DD] [--own] [--with-media] [--replies include\\|only\\|exclude] [--order chrono\\|reverse] [--limit N] [--after <id\\|->] [--dry-run] [--json]`", + "**POST ITEMS** ([report-video.md](report-video.md#post-items-a-post-as-an-entry-of-the-cut)): each archived post an entry of the cut -- its card drawn from the archive row (snapshotted), its attachments copied into `posts-media/` and played in it. The channels are read as one archive, merged in time order, de-duplicated by post id (`--channel ObviousRises-x --channel ObviousRises-x-replies`); `--own` the accounts' own posts (their config's `socialHandle`, no reposts); `--with-media` only posts whose capture holds an attachment; `--replies` keeps, keeps only or drops replies (a reply carries the posts it answers from the archive, else the capture's thread shot, else a \"Replying to\" line; the quoted post and the parent the archive lacks come from the capture's `context`, as `posts context` fills them). A post the cut already plays (by its id, a repost's original, a repost of it) is skipped, so a **re-run adds only what is new**; the rest goes in in ONE write (one undo point: `timeline <p> undo`), at the end unless `--after`"], + ["`posts set-item <project> <item> [hold=<s>\\|off] [layout=sequence\\|grid] [redact=on\\|off\\|auto] [fit=read[:<linger>]] [media.<i>.start=<s>] [media.<i>.end=<s>] [media.<i>.trim=off] [media.<i>.mute=on\\|off] [media.<i>.crop=x,y,w,h\\|off] [media.<i>.push=on\\|off] [media.<i>.enter=post\\|item] [media.<i>.blur=on\\|off] [media.<i>.blur.strength=1–10] [media.<i>.blur.label=\"…\"\\|off] [media.<i>.blur.boxes=x,y,w,h;…\\|off] [quoted.paraphrase=\"…\"\\|off] [parent.<i>.paraphrase=\"…\"\\|off] [follow=on\\|off\\|auto] [follow.dim=<0.2-1>] [follow.ease=<s>] [thread.parent[.<i>]=auto\\|full\\|excerpt\\|context\\|carry\\|hidden] [thread.quoted=…] [thread.carry=auto\\|on\\|off] [thread.reveal=on\\|off] [thread.shrink=<0.3-1>] [thread.dim=<0.15-1>] [thread.seconds=<s>] [thread.pan=<s>] [thread=auto] [thread.group=<name>\\|off] [thread.map=auto\\|on\\|off\\|map\\|label\\|both] [panel=auto\\|side\\|top\\|bottom] [media.add=<file>] [media.<i>=off] [parent.<i>=<json ref>\\|@<file>\\|off] [parent.<i>.media=<file>[,…]\\|off] [link.add=<json ref>] [link.<i>=<json ref>\\|off] [link.<i>.media=<file>\\|off] [link.<i>.transcript=\"…\"\\|off] [pictureOnly=on\\|off\\|auto] [parent.<i>.pictureOnly=on\\|off\\|auto] [quoted.pictureOnly=on\\|off\\|auto] [--json]`", + "a **post item's knobs** (the post bench's writer, `updatePostItem`; [knobs.md](knobs.md#a-post-item-a-post-as-an-entry-of-the-cut)): `<item>` is its id or the post's id; refused in the build's words. `quoted.paraphrase` / `parent.<i>.paraphrase`: your retelling of a long context post (≤ 600 characters), drawn in place of its words with a \"paraphrased\" label (its text kept); `off` or empty clears it. `follow=`: its read-follow ([knobs.md](knobs.md#read-follow-the-block-being-read-lit-the-card-panned-to-it)) -- `off`, `on`, `auto` (the cut's); `follow.dim=` / `follow.ease=` over the cut's. `thread.*`: its THREAD READ ([knobs.md](knobs.md#thread-reads-every-part-of-a-read-on-screen-while-it-is-said)) -- what each context post is on screen (`thread.parent.<i>` one parent, nearest first), the shrink, dim and their seconds, the pan's; `thread=auto` the cut's; a setting that would narrate a post the card hides is refused (**exit 1**). `media.<i>.blur…` CENSORS the attachment in the render (a real blur of the whole frame or of its boxes, labelled \"Censored\"; the file untouched; merged key by key, `blur=off` keeps the settings). THREAD SCENES ([knobs.md](knobs.md#thread-scenes-the-join-whole-threads-manual-threads-wide-attachments-context-media-link-visits-the-branch-map)): `parent.<i>=` an ancestor added / replaced / dropped (a whole-thread read), `parent.<i>.media=` its attachments, `media.add=` / `media.<i>=off` an attachment from a project file (measured), `link.add=` a post its words link to (a link visit) with its picture and transcript, `thread.group=` a manual thread, `thread.map=` the branch map, `panel=` where its attachments sit; `media.<i>.enter=` when its own attachment comes in -- with his own post's read (`post`, the default: a parent or a quote read first shows none of it) or with the item (`item`). `pictureOnly=` a PICTURE-ONLY post ([knobs.md](knobs.md#picture-only-posts-a-reply-that-is-its-picture)): its attachment drawn in its own card where its words would be, never in the slot, a context post that is one given its own beat before the read -- `auto` (a post of only @mentions and links with an attachment), `on`, `off`; `parent.<i>.pictureOnly=` / `quoted.pictureOnly=` for those"], + ["`posts set-item \\| roles \\| narrate \\| reread \\| fx <project> … --in-take <take>` (set-item, roles, reread, fx: `--take <take>` too)", + "**a take-scoped edit** (`takeScope.mjs`): the same command, on a TAKE of the project -- its manifest read as the take's (the project's now with the take's patches), every write landing in `takes/<take>/take.json`'s patch with an undo point of the take's own (`timeline <p> --take <take> undo`). The project's manifest, and any project the take's items were imported from, are untouched; a new read (`narrate --take`, `--thread`, `reread`) lands in the project's `narration/` under a take number no file or entry has. A writer not routed to the take refuses and writes nothing. `--json`: the command's own object plus `take {id, edits, revisions, undo}`. narrate's own `--take` is \"make a new read\": `narrate … --take <a take's id>` is refused (exit 2) naming `--in-take`. **Exit 1** when the take is not there or is rendering ([take-scoped edits](#edit-a-take-not-the-project-items-from-other-projects-and-take-scoped-edits))"], + ["`posts reread <project> <item> [--without parent:0\\|parent:1\\|quoted[,…]] [--drop-parts 3,4] [--drop-urls] [--dry-run] [--json]`", + "a narrated read **re-joined without a piece**, no TTS ([knobs.md](knobs.md#thread-reads-every-part-of-a-read-on-screen-while-it-is-said), [report-video.md](report-video.md#thread-reads)): the picked take's kept parts cut out of its own file (ffmpeg) and joined with the read's pauses, measured, added as a derived take (`steps: [{op: \"rejoin\", drop}]`, its parts re-timed with their roles, its word timings moved, its slurs state kept) and picked — ONE write (one undo point). `--without` drops the parts that read the post it answers (`parent:0`), its parent (`parent:1`) or the quoted post; `--drop-parts` by number; `--drop-urls` the parts that are nothing but a link. Nothing to drop, every part dropped or a take read in one go: **exit 1**. `posts set-item … thread.parent.<i>=context\\|hidden` (or `thread.quoted=…`) on a piece the take reads runs it first (`--no-reread`: refused, as before)"], + ["`posts reread <project> <item> --tempo-for \"4-16=1.35,21-25=1.3\" \\| --tempo <x> --parts <runs> [--stretch atempo\\|rubberband] [--dry-run] [--json]`", + "a narrated read's **parts re-timed**, no TTS ([knobs.md](knobs.md#thread-reads-every-part-of-a-read-on-screen-while-it-is-said), [report-video.md](report-video.md#a-long-read-sped-up-and-its-caps-yelled)): the parts named time-stretched (1–1.6, pitch kept), the rest untouched, joined with the read's pauses (each stretched part padded and trimmed to its length, sample-exact), its words scaled with their part, a derived take (`steps: [{op: \"tempo\", tempo, params: {stretch}}]`) picked in ONE write. A tempo is absolute: on a re-timed take it re-cuts from the take before. `posts set-item <p> <item> narration.tempo=\"4-16=1.35\"` runs the same. A part outside the take, a tempo outside 1–1.6, nothing changed: **exit 1**"], + ["`posts reread <project> <item> --yell-caps [--yell-gain 5.5] [--yell-style raise\\|shout\\|loud] [--dry-run] [--json]` · `posts yell <project> --all \\| <item …> [--yell-gain …] [--yell-style …] [--dry-run] [--json]`", + "a narrated read's **caps yelled**, no TTS ([report-video.md](report-video.md#a-long-read-sped-up-and-its-caps-yelled), `lib/report/postYell.mjs`): his ALL-CAPS words found in the take's word timings and raised (the lift measured, its loudness within 1 LU), acronyms and masked slurs left flat, a derived take (`steps: [{op: \"yell\", spans, params}]`) picked (one undo point per item). No word timings: **exit 1** naming `posts narrate --words`; `posts yell --dry-run` lists every item's caps, the flat ones and why, and which need word timings"], + ["`posts reread <project> <item> --pause \"<word>[#<n>]=<seconds>\\|@<take s>=<seconds>[,…]\" [--target post\\|parent:0\\|quoted\\|linked:0] [--dry-run] [--json]`", + "**pauses put in after words** of a narrated read, no TTS (`lib/report/postPause.mjs`; operator, 5 Nov: a countdown \"20 10 4 0\" read without a breath): the picked take cut just after each word named (half way into the quiet before the next word, at most 0.1 s past its end) and that much silence (0.05–3 s) put in -- each cut moved to the quietest 10 ms its word allows (40 ms before its timed end up to the next word, ±40 ms when they run together) when that is clearly quieter (~3 dB) than the timing's own, and each side of the silence faded over 10 ms, so a pause in normally paced speech does not click -- everything after moved on -- its words (by index), its parts (one a pause falls in grows), its length -- so word zooms, captions, slams, beeps and the read-follow stay on their words; an effect with a set `at` does not move (the plan counts them). A word is matched as a word zoom's is (case and edge punctuation aside; a phrase pauses after its last word; `#n` its n-th time in the read; `--target` counts only the words of the parts reading that piece). A derived take (`steps: [{op: \"pause\", pauses: [{word, w, at, seconds}]}]`) picked in ONE write. **Absolute**, like a tempo: on a take whose last step is a pause it re-cuts from the take before (the pauses it had kept, a word named again takes the new seconds, `=0` takes one away). `--in-take <t>` puts it in a take's read. No word timings (**exit 1**, naming `posts narrate <p> <item> --words`), a word not read, an occurrence not there, nothing to change: **exit 1**; a malformed spec, seconds outside 0.05–3, `--pause` with another reread form: **exit 2**"], + ["`posts reread <project> <item> --revoice \"<phrase>[#<n>]\" --say \"<what to say instead>\" [--target <piece>] [--voice <v>\\|auto] [--xfade 0.03] [--splice <from>-<to>] [--dry-run] [--json]`", + "**one phrase of an approved read re-voiced**, the rest untouched (`lib/report/postRevoice.mjs`; operator, 5 Nov: the countdown gabbled, and pauses cut into it \"choppy\"): the phrase found in the picked take's word timings as `--pause` finds a word (`#n`, `--target`; inside one part), the original cut from just before its first word to just after its last -- each cut at the quietest 10 ms within ±40 ms of the boundary, and when that is still speech within ±0.15 s (never inside the phrase as timed; a nearer quiet preferred) -- **`--say` alone synthesized by the editor's TTS** (narrate-via-editor; the engine of the root take, the voice of the part the phrase is in, `--voice` overrides; the project's lexicon, redaction and slur filter applied; kept in `narration/parts-cache/` like a thread read's parts, so asking again is free), its lead and tail of silence trimmed, loudness-matched to the speech in the 2 s either side (±6 dB) and spliced in with equal-power crossfades (`--xfade`, 0–0.2 s) at both joins, at the take's rate and layout. The length is exact: the take − the span cut + the piece. Everything after moves by the difference (its words, the part holding the span, the later parts) so zooms, captions, slams, beeps and the read-follow stay on their words; the new words are timed from the piece's speech and marked `estimated` (a later `posts narrate … --words` refines them); the part's text and the script say `--say`. A derived take (`steps: [{op: \"revoice\", revoice: {word, count, words, phrase, say, said, voice, engine, from, to, seconds, gain, xfade, key}}]`) picked in ONE write; re-voicing exactly the words a re-voice put in re-cuts from the take before. `--dry-run`: the span (words, seconds), each cut and its level, what is said and in which voice, the length change when the piece is cached -- no TTS. A cut still in speech is warned of (the word timings off there): `--splice 65.03-66.00` sets the cuts (either side may be left out). `--in-take <t>` puts it in a take's read. No word timings (naming `posts narrate <p> <item> --words`), the phrase not read or across two parts, a recorded read, the TTS failing: **exit 1**; no `--say`, a bad voice, crossfade or splice, `--revoice` with another reread form: **exit 2**"], + ["`posts progress <project> [auto\\|on\\|off\\|default] [--json]`", + "the cut's **progress bar** default (`render.posts.progress`, `updatePostProgressRender`; [report-video.md](report-video.md#the-progress-bar)); bare, which items draw it"], + ["`posts roles <project> [<item> …] [--write] [--set <n>=<role>,…] [--json]`", + "a narrated read **piece by piece** ([knobs.md](knobs.md#thread-reads-every-part-of-a-read-on-screen-while-it-is-said), [report-video.md](report-video.md#thread-reads)): the text each part of the picked take reads -- `parent:<i>`, `quoted`, `post`, `media:<i>` -- stored or inferred, what the card shows for each, and the build's guard (a part read off a post the card hides is refused). `--write` stores the inferred roles on the picked takes' parts (one write; the import stores them for every new take); `<item> --set n=role,…` sets parts' roles by hand (`off`: inferred again); a part out of range or an unknown role is refused (**exit 1**)"], + ["`posts narrate <project> --import [--dry-run] [--json]` · `--list` · `<item> [--script \"…\"] [--pick <n>] [--approve\\|--unapprove] [--off\\|--on] [lead= tail= ramp= linger= clip=read\\|full wet= lowpass= duck=on\\|off short=hold\\|loop attach=under\\|after lufs= pace=fast\\|normal]` · `<item> --take [--note \"…\"] [--voice v] [--engine e] [--speed s] [--script \"…\"]` · `<item> --derive <n> --op enhance\\|convert [--engine e] [--voice v]` · `<item> --delete <n>` · `--all --draft-scripts [--force]` · `--all --take [--limit N]` · `--cut <k=v>…`", + "a **narrated post item** ([report-video.md](report-video.md#narrated-post-items), [knobs.md](knobs.md#a-narrated-post-item)): `--import` reads `narration/posts/index.json` (`[{id, entry, script, takes: [{file, engine, voice, seconds}], pick}]`, and a take's `take-<n>.parts.json`) into the cut in ONE write, measuring each take (length, loudness); a re-run adds only takes not there. `--take` asks the EDITOR for a new take (`POST /api/ops/tts`, its `out` the next `narration/posts/<postId>/take-<n>.<engine>-<voice>.wav`; a job, waited for; `ARCHILYZER_EDITOR_URL`, `WORKER_TOKEN`) and picks it, its `--note` kept with it; `--pick <n>` is the take's number as `--list` shows it. `--derive <n>` makes a NEW take from take n through the editor's `voice-enhance` / `voice-convert` op (a stock synthetic voice; \"not installed\" until the editor has the engine), the original kept; `--delete <n>` moves a take's file to the post's `.trash/`. A new script or pick takes the approval away. `--all --draft-scripts` writes every post's words as its script, VERBATIM (cleaned only to be spoken: a reply's leading @handles, links, emoji dropped -- a handle typed inside the message is kept and said \"at <handle>\", the lexicon first; `plan(s)` → plans, `w/` → with, `&` → and; paragraphs kept). `--cut` sets `render.postNarration` (and its read-follow: `follow=on\\|off`, `follow.dim=`, `follow.ease=`; its thread reads: `thread.parent=`, `thread.quoted=`, `thread.carry=`, `thread.reveal=`, `thread.shrink=`, `thread.dim=`, `thread.seconds=`, `thread.pan=`). Refused in the build's words (**exit 1**) A `--take` whose read says a slur the cut BEEPS is word-timed by the editor's transcription before it is kept -- never waited on: with the transcription lane held (as while Orpheus runs) the take is kept as read and the timing deferred (it says so, naming `posts narrate <p> <item> --words` to run after the release; the build refuses the take until then), and a timing still queued after 5 min is deferred the same way. An excerpted item (`posts set-item … excerpt=`) reads its spans."], + ["`posts narrate <project> <item> --take --thread [--parents 0\\|all\\|none\\|<n>] [--skip-parent <id\\|parent:i>]… [--no-quoted] [--no-linked] [--read-seen] [--voice-for <handle>=<voice>]… [--voice v] [--engine e] [--note \"…\"] [--force] [--no-hold] [--dry-run] [--json]`", + "a **THREAD READ** as one command ([knobs.md](knobs.md#pronunciation-and-voices-the-lexicon-the-voice-map-a-thread-read), `lib/report/postThreadRead.mjs`): the post it answers (`--parents all`: every ancestor; `<n>`: parents 0..n; `none`), the post it quotes and the posts it links to, then his words, in DATE order, each in its author's voice (`--voice-for`, then the project's voice map, `posts voices`; his own: the narrator's), the redaction, the slur filter (a beep is skipped: a joined read is not word-timed) and the lexicon (`posts say`) applied. A parent or quoted post the item before already shows is not read again (`--read-seen`: it is). Each part is synthesized ONCE by the editor's tts op into `narration/parts-cache/<sha1(voice\\|text)>.wav` (the transcription lane held meanwhile, only if it was not; `--no-hold`: left alone), joined (0.8 s between pieces, 0.6 between paragraphs, 0.25 inside one) into `take-<n>.<engine>-thread.wav` with `take-<n>.parts.json`, saved with its parts' roles, its lexicon and how it was asked (`read`) and PICKED — one write (one undo point). `--dry-run`: the pieces, voices and parts (cached or not), nothing asked. Already up to date (same words and voices): nothing done, **exit 0** (`--force`: again). A part not synthesized: **exit 1** (the parts made stay cached; run it again); `--json` prints `{ok: false, error}` too. A usage error: **exit 2**"], + ["`posts say <project> [ls] [--item <id>]` · `add <word\\|phrase> \"<spoken>\" [--case] [--item <id>] [--note \"…\"]` · `remove <word\\|n> [--item <id>]` · `try \"<text>\" [--item <id>]` · `stale` `[--json]`", + "**THE PRONUNCIATION LEXICON** ([knobs.md](knobs.md#pronunciation-and-voices-the-lexicon-the-voice-map-a-thread-read)): `narration/lexicon.json` in the project, a word or phrase said differently in EVERY synthesized read (a script's `--take`, each piece of a thread read, the bench's re-take); the scripts and cards keep their words. Whole words, without case unless `--case`, a phrase across any spaces, regex characters literal; `--item` for one item's reads (it wins over the project's). A masked slur and a redacted word are never replaced. `add` of a word already listed changes what is said. `try` prints what a voice would be asked to say. `stale` lists every picked read that still says an entry the old way, with the command that re-reads it. A bad entry or an unknown item: **exit 2**"], + ["`posts voices <project> [ls] \\| set <handle\\|*> <voice> \\| remove <handle\\|*> [--json]`", + "**THE VOICE MAP** (`narration/voices.json`): the stock voice a thread read gives each author (`*`: everyone it does not name; default `leo` on Orpheus); `ls` lists the map and every author the cut's items carry with the voice each would get. A bad handle or voice: **exit 2**"], + ["`posts narrate <project> <item> --recording <file> [--as <character>] [--no-clean] [--no-convert] [--label l]`", + "**a recording made a character's read**: kept (recorded), cleaned (voice-enhance), converted (voice-convert) to the character's STOCK voice, each a new take, the last picked"], + ["`posts fx <project> <item> add caption --match \"…\" --text \"…\" [--target post\\|quoted\\|parent:<i>] [--occurrence n] [--at s] [--lead s] [--hold s] [--place below\\|above\\|side]` · `add clock [--rewind auto\\|on\\|off] [--off]` · `set <n> [--text …] [--place …] [--rewind …]`", + "a post item's **caption** ([report-video.md](report-video.md#a-caption), [knobs.md](knobs.md#a-caption-a-chip-explaining-a-phrase-as-it-is-read)): a chip explaining a phrase (any script: CJK drawn), up as it is read -- `--at`, else the take's word timings, else the reading estimate -- held `--hold` s, by the phrase and never over a word read while it is up; it waits for a word zoom. Its **clock** ([knobs.md](knobs.md#the-clock-each-posts-own-time-on-its-card-run-between-items)): the post's own time on the card, run from the clock item before it (forward; a REWIND when earlier: `--rewind`), `--off` not on this item. Through `updatePostFx`, refused in the build's words (**exit 1**); a zoom's knob on a caption, or a caption's on a zoom (**exit 1**)"], + ["`posts clock <project> [on\\|off\\|default] [--zone <IANA zone>] [--json]`", + "the cut's **clock** default (`render.posts.clock`, `updatePostClock`); bare, which items show it and their times"], + ["`posts fx <project> <item> add slam --text \"不動心\" [--match \"…\" \\| --at s] [--whole \\| --per-glyph] [--gap s] [--hold s] [--from-scale x] [--color #rrggbb] [--outline #rrggbb] [--outline-width px] [--place over-match\\|center] [--size px] [--face jp\\|sc\\|tc\\|kr] [--sfx trailer-hit\\|off] [--volume x] [--swell \\| --no-swell] [--bar \"…\" [--bar-style dark\\|gold\\|plain]]` · `set <n> [those flags; --bar off clears it]`", + "a post item's **slam** ([report-video.md](report-video.md#a-slam), [knobs.md](knobs.md#a-slam-a-trailer-style-title-slam-over-a-word-as-it-is-read)): a corny trailer title slam -- each glyph huge, shrinking onto the card just above the matched words' line and HITTING (a flash, dust, the frame's punch, a trailer hit's boom: the teaser's generator, `trailer-hits.mjs`), gold with a black outline; the hits spread evenly over the words' spoken span (`--gap` spaces them, `--at` moves the first), held `--hold` s; `--bar` lands the glyphs on a translation bar (rising in at the first hit, faded with them); a caption up with it waits for it. Through `updatePostFx`, refused in the build's words (**exit 1**); a slam's knob on another effect, or another's on a slam (**exit 2**)"], + ["`posts fx <project> <item> [ls]` · `add word-zoom --match \"…\" [--target post\\|quoted\\|parent:<i>] [--occurrence n] [--at s] [--scale s] [--hold s] [--lead s] [--ease out\\|inOut\\|snap] [--highlight #rrggbb\\|off]` · `set <n> [those flags; default clears one]` · `remove <n>` · `posts narrate <project> <item> --words [--worker <id>]`", + "a post item's **word zoom** ([report-video.md](report-video.md#a-word-zoom), [knobs.md](knobs.md#a-word-zoom-a-post-items-card-pushed-in-on-a-word-as-it-is-read)): the card pushed in on a word as it is read, a highlight under it, then back out -- through `updatePostFx`, refused in the build's words (a match not in the words, a knob out of bounds; **exit 1**). Its time is `--at`, else the word's start in the picked take's word timings; `ls` prints each zoom's time and where it came from. An un-narrated post's `add` fills `at` with the reading estimate. `--words` asks the EDITOR's transcribe op (`words: true`, a job per take or per part file; `ARCHILYZER_EDITOR_URL`, `WORKER_TOKEN`) and keeps the words heard, aligned to the script, on the take (`takes[i].words`)"], + ["`posts fit <project> [--all \\| <item> …] [--linger <s>] [--dry-run] [--json]` · `posts set-item <project> <item> fit=read[:<linger>]`", + "narrated posts' video attachments cut to their **best part** for the read (lead + take + tail + linger): a scored scan of the sound (loudness, its peaks), the speech (a transcript) and the scene cuts, the start snapped to a pause or a cut, recorded with why (`narration.window`) -- ONE write; each post's old and new length printed. A video no longer than the read is left as it is"], + ["`posts avatar <project> [<handle> <image-file> \\| <handle> off] [--json]` · `posts avatars <project> [--dry-run] [--json]`", + "the **authors' pictures** (`postAvatars`): `avatar` copies a picture into `posts-media/_avatars/` for every card that draws that handle (manual; never replaced by the archive's), `off` clears it, no handle lists them; `avatars` copies the archive's (the channels' `posts-media/_avatars/avatars.json`, capture-posts') for every author the cut's cards draw unblurred that it has none of. A blurred author never shows one"], + ["`posts redact <project> ls \\| add \"<term>\" [--substring] [--note \"…\"] \\| remove <n> [--json]`", + "**REDACTED WORDS** ([knobs.md](knobs.md#redacted-words-blanked-from-what-is-published)): the project's list (`render.posts.redact`, `updatePostRedact`) of words or phrases blanked from everything the cut publishes -- a solid bar on the rendered card, left out of a synthesized read, a post's chapter line and an attachment's captions; matched without case, as whole words (`--substring`: inside words too), a phrase across any spaces or punctuation. The posts' words and the scripts are never rewritten. `ls` numbers the terms as `remove` takes them, and counts the corpus's (`transcripts/redactions.json`) and the posts marked up in the cut's channels (`posts-markup.json`). A term already listed is refused (**exit 1**)"], + ["`posts slurs <project> [ls] \\| on \\| off \\| level strong\\|all \\| visual blackout\\|placeholder \\| voice skip\\|beep\\|placeholder \\| add <word> \\| except <word> \\| remove <word> \\| edges <word> [--off] [--json]`", + "**THE SLUR FILTER** ([knobs.md](knobs.md#the-slur-filter-slurs-masked-in-what-is-published-off-for-the-uncensored-cut)): `render.posts.slurs` (`updatePostSlurs`, one undo point each), on by default -- the slurs of the shipped list (`report-to-video/slurs.json`; `level strong`: only the strong ones) and the project's own (`add`; `except` never masks one) masked in everything the cut publishes: a dark pill with its mask (`visual placeholder`, the default, \"f*****\") or a bar (`blackout`) on the card; said and beeped by the take's word timings (`voice beep`, the default), left out of a synthesized read (`skip`), or its stand-in said (`placeholder`). `edges <word>` EDGE-masks that slur (its word, id or a form names it; `render.posts.slurs.edges`): every form first letter, stars, last letter, in the case written (\"n***a\", \"f****t\"), `--off` back to the first letter; a word naming no slur is refused (**exit 2**). `ls` counts what the cut masks per slur and per post -- masks only, never the word -- and names each narrated post whose take says one with no word timings (a censored build refuses it; `posts narrate <p> <item> --words`). `off` is the uncensored cut (the redaction stays). A word already on a list, or on neither for `remove`, is refused (**exit 1**); an unknown verb or value (**exit 2**)"], + ["`posts context <project> [--dry-run] [--json]`", + "every **post item's context from its capture** (`postContext.mjs`): the post it quotes and the post it answers, as its page showed them (`capture.json`'s `context`, read by the editor's `capture-posts` -- `\"contextOnly\": true` reads it alone), filled where the archive row lacks them -- `quoted` where the entry has none (or a named one with no words, the same post), `parents` where it has none (a thread shot stays on the entry; the card draws the parents). An x.com/twitter.com **status link** in its words (or its row's links) is a quote: the post it names, from any channel's archive, fills `quoted` (`via: \"link\"`) when it has none; the row's `threadId` is snapshotted as the item's `conversation` (the thread walk reads it). What the archive gave is never replaced. ONE write for every entry (`setPostItemsContext`: one undo point, refused whole in the build's words); a re-run with nothing new writes nothing. A post whose capture read no context is listed with the call that reads it (`pnpm ops capture-posts --json '{\"slug\":…,\"ids\":[…],\"contextOnly\":true}' --wait`). The card's blur of other authors is unchanged ([report-video.md](report-video.md#post-items-a-post-as-an-entry-of-the-cut))"], + ["`posts picture-reply <project> [on=on\\|off] [image=<s>] [min=<s>] [max=<s>] [maxSound=<s>] [--in-take <take>] [--json]`", + "the cut's **PICTURE-ONLY RULE** ([knobs.md](knobs.md#picture-only-posts-a-reply-that-is-its-picture)): `render.posts.pictureReply` (`updatePostPictureReplyRender`, one undo point) -- `on` the rule at all; a beat's length: an image `image` s (2), a GIF's or a silent video's own length clamped to `min`–`max` (1.5–4 s), a video with its sound its whole length up to `maxSound` (8 s). `k=` the default again; none: the rule as it stands. `--in-take` writes it into a take's patch. Refused in the build's words (**exit 1**)"], + ["`posts repeats <project> [--match id\\|file\\|audio] [--json]`", + "the **combo counter**'s repeats ([report-video.md](report-video.md#the-combo-counter)): every attachment the cut's post items play more than once -- the same X media id (the capture's url), else the same file (the capture's sha256 when its bytes agree, else hashed; cached by path, size and mtime), else (`--match audio`) the same sound (fpcalc, else a coarse ffmpeg hash) -- its posts in the cut's ORDER with their dates, the tier that matched and the badge each draws (`×2` from the second use, `(×n)` counted but not drawn); a post whose CAPTURE holds the same file but whose entry carries no attachment is listed too, `NOT ATTACHED`, with the `posts attach` that brings it in. Reads only"], + ["`posts attach <project> [<item> … \\| --all] [--dry-run] [--json]`", + "a post item with **no attachment whose capture holds one** (captured after it went in -- `posts repeats` marks them `NOT ATTACHED`): the capture's media (its own channel's `posts-media/<postId>/`, else any channel the cut's posts come from) copied into the project's `posts-media/<slug>/<postId>/` and measured, set as the entry's `media` as `posts reel` would have made it -- nothing else of the entry changes (its paraphrases, narration, knobs kept); an item that has an attachment is never touched. ONE write (one undo point: `timeline <p> undo`), refused whole in the build's words"], + ["`posts combo <project> [on=on\\|off] [label=L] [position=top-right\\|top-left\\|bottom-right\\|bottom-left\\|center] [color=#rrggbb] [scale=0.4-2.5] [sfx=off\\|hit\\|coin] [minCount=2-20] [match=id\\|file\\|audio] [--json]` · `posts combo <project> <item> off\\|on\\|auto\\|label=…\\|position=…\\|color=…\\|scale=…\\|sfx=… [--json]`", + "the **combo badge's knobs** ([knobs.md](knobs.md#the-combo-counter)): the cut's (`render.posts.combo`, `updatePostComboRender`; no knobs prints them; `k=` the default again) or one post item's (`combo`, `updatePostCombo`): `off` draws no badge on it -- it still counts -- `on`/`auto` the cut's again. Refused in the build's words (**exit 1**)"], + ], + }, + { + cmd: "candidates", + usage: [ + " umtool candidates <project> [ls] [--all] [--json] | import <sweep.md> [--dry-run] | add <json|@file>", + " the candidates inbox: a sweep's or an agent's proposed clips -> <project>/candidates.json;", + " Insert into a section or a group, and Not this, are the Cut tab's Candidates panel's", + ], + docs: [ + ["`candidates <project> [ls] [--all] [--json]` · `candidates <project> import <sweep.md> [--dry-run] [--json]` · `candidates <project> add <json\\|@file> [--json]`", + "the **candidates inbox** (`<project>/candidates.json`): proposals only — `import` reads a sweep's bullets (`- [verdict] [title @ time](link) (date) \"quote\" — why`, under their headings; a Top N section marks what it restates; a bullet with no verdict or link is skipped and said), `add` an agent's (`{channel?, video, t, quote?, why?, verdict?, score?, section?}` or `{link, …}`); the same moment again changes nothing it holds. Insert and Not this are the Cut tab's Candidates panel's ([knobs.md](knobs.md#the-candidates-inbox-proposed-clips-picked-by-a-press))"], + ], + }, + { + cmd: "ingredient", + usage: [ + " umtool ingredient <channel>/<video> [--window <from>-<to>] [--used-in] [--json] one recording's life cycle:", + " found, downloaded, transcribed, clock, windows, used in, checked, rendered, published (/ingredients)", + ], + docs: [ + ["`ingredient <channel>/<video> [--window <from>-<to>] [--used-in] [--json]`", + "**one recording's life cycle**, the twin of `/ingredients/<channel>/<video>` ([knobs.md](knobs.md#an-ingredients-life-cycle-the-rail)): nine stages — found, downloaded, transcribed, clock, windows, used in, checked, rendered, published — each **✓**, a count, **!** or **—**, and its line, then every project clip that cuts from it (the draft and each saved version, from the usage index `<REPORTS_ROOT>/.umtool/usage-index.json`). A Rumble recording answers to its folder slug or its embed id; both are printed. `--window`: one clip window, the stages after it narrowed to the clips it plays. `--used-in`: the clips alone. `--json`: the page's object. Read-only over the corpus. **Exit 0 · 1 failed · 2 usage**"], + ], + }, +]; diff --git a/umtool/lib/cli/verbs.mjs b/umtool/lib/cli/verbs.mjs @@ -0,0 +1,459 @@ +// THE VERB REGISTRY (umtool redesign, lane palette L8a): every verb +// `umtool` dispatches, one row each -- a sub-verb (`timeline insert`, +// `takes pick`, `posts add`) its own row -- machine-readable, so the ⌘K +// palette builds a FORM from a row, POST /api/cli runs only what a row +// allows, and `umtool help` and docs/cli.md are generated (lib/cli/docs.mjs) +// from here and from the prose beside it (lib/cli/groups.mjs). +// +// { verb, summary, target, ui, reason?, args, shape?, queue?, timeoutMin? } +// +// verb the words that name it, as typed: "timeline insert" +// summary one line, what it does (the palette's hint) +// target "draft" it writes the working draft: the project's manifest (and the files beside it +// a write keeps in step), each write an undo point +// "project" it reads a project, or writes what is not its draft (takes, renders, records) +// "corpus" it is not about one project +// ui "form" the palette offers it as a form; POST /api/cli runs it +// "none" it has no form, and `reason` says why (required) +// args what the form asks, in argv order (below) +// shape where the verb's words and positionals go when they interleave: +// "timeline <project> insert" -- a `<name>` is that positional arg. Absent: the verb's +// words, then every positional in order. Positionals the shape leaves out follow it. +// queue true: it renders (or holds the heavy slot) -- POST /api/cli adds it to the durable +// queue (lib/queue/store.mjs), never the app's one-job runner +// timeoutMin a job's (or a queued step's) time limit, minutes (default 15 for a job, the queue's 12 h) +// confirm { what, when?, unless? }: it does something with no undo point (deletes, evicts, kills): +// the form asks a second press ("Yes, <what>") and POST /api/cli wants `confirm: true`; +// `when` the arg names that make it so (any given), `unless` those that make it a dry run +// +// An arg: { name, type, required?, choices?, default?, help?, repeat?, context? } +// name "--flag" is a flag; anything else is a positional +// type project a project id (positional; the palette fills it from the page) +// string one word or line text a longer one (a textarea) +// number a finite number boolean a flag present or not +// choice one of `choices` json a string that parses as JSON +// pairs key=value lines, each one argv word (a positional run) +// flagpairs key=value lines, each `--key value` +// list several values: a positional run, or (`repeat`) the flag once per value +// (`item: "id"` each an entry id; `item: "name"` each a bare name; `item: "pair"` each key=value; `item: "ref"` each a ref) +// name a bare name: no directory, no `..`, no leading dot (`--out`, a take's id, a reel) +// path a file of the project, relative to its directory: POST /api/cli runs it only when +// its realpath is inside the project's, as that absolute path (`pass: "relative"`: as typed) +// ref a share URL or <channel>/<id>, never a file (`new --from`) +// literals values a name or path arg also takes as words ("none", "off") +// atFile the CLI reads `@file` here: a form may not (the file could be anywhere). Every positional, list item +// and key=value is refused an `@file` reference anywhere in it (`post-json:@x`, `a,@x`); `allowAt` +// exempts a handle (`@grok`) or a lexicon word; a flag's words and free prose (`text`) are a person's. +// context "clip" | "post" | "take": filled from the page's selection (its URL: /clip/<id>, +// /post/<id>, /takes/<id>, ?clip=, ?take=) +// +// A NEW VERB (or sub-verb) is a new row here, ui "form" with its args or ui "none" with its +// reason -- verbs.test.mjs fails, naming the verb, until it has one -- and its help lines in +// groups.mjs; then `node umtool/lib/cli/docs.mjs` rewrites docs/cli.md. +// +// Plain data and pure helpers: no imports, so the route, the tests and the docs read one table. + +// ---- the args ----------------------------------------------------------------- + +const project = (o = {}) => ({ name: "project", type: "project", required: true, help: "an id, a directory or a unique name", ...o }); +/** A positional: required unless said. */ +const arg = (name, o = {}) => ({ name, type: "string", required: true, ...o }); +/** A valued flag. */ +const opt = (name, o = {}) => ({ name, type: "string", ...o }); +const bool = (name, help) => ({ name, type: "boolean", ...(help ? { help } : {}) }); +const num = (name, o = {}) => ({ name, type: "number", ...o }); +const pick = (name, choices, o = {}) => ({ name, type: "choice", choices, ...o }); +const pairs = (o = {}) => ({ name: "settings", type: "pairs", required: true, help: "key=value, one per line (`key=` clears one)", ...o }); +const many = (name, o = {}) => ({ name, type: "list", ...o }); +const clip = (o = {}) => arg("clip", { context: "clip", help: "the clip's id", ...o }); +const item = (o = {}) => arg("item", { context: "post", help: "the post item's id (or its post's)", ...o }); +const takeOpt = (o = {}) => opt("--take", { type: "name", context: "take", help: "a take of the project: the edit lands in its patch", ...o }); +const takeArg = (o = {}) => arg("take", { type: "name", context: "take", help: "the take's id", ...o }); +const inTake = () => opt("--in-take", { type: "name", context: "take", help: "a take of the project: the edit lands in its patch" }); +const name = (n, o = {}) => ({ name: n, type: "name", ...(n.startsWith("--") ? {} : { required: true }), ...o }); +const file = (n, o = {}) => ({ name: n, type: "path", ...(n.startsWith("--") ? {} : { required: true }), help: "a file of the project, relative to its directory", ...o }); +const dry = () => bool("--dry-run", "say what it would do; change nothing"); +const reel = () => opt("--reel", { type: "name", help: "that beat reel (promo/<name>-beats.json); default the trailer" }); +const window_ = () => [num("--at", { help: "the window's start, s" }), num("--dur", { help: "the window's length, s" }), bool("--full", "the whole cut")]; + +// ---- the rows ------------------------------------------------------------------- + +const form = (verb, target, summary, args, extra = {}) => ({ verb, summary, target, ui: "form", args, ...extra }); +const none = (verb, target, summary, reason, extra = {}) => ({ verb, summary, target, ui: "none", reason, args: [], ...extra }); + +/** The heavy verbs' default time limit in the queue is its own (12 h); a job's is 15 min unless a row says. */ +const Q = { queue: true }; + +const REJECT_WHYS = ["not-matching", "wrong-speaker", "irrelevant", "repeats", "weak", "privacy", "other"]; + +/** @type {ReadonlyArray<Record<string, any>>} */ +export const VERBS = Object.freeze([ + // ---- the tree ---- + form("ls", "corpus", "every project, as text", [ + opt("--kind"), opt("--template"), opt("--state"), bool("--open", "only projects with something open"), bool("--blocking", "only projects with something blocking"), + opt("--q", { help: "words the project's text holds" }), pick("--sort", ["recent", "name"]), + ]), + form("show", "project", "one project: summary, the cut, per-clip status, decisions", [project()]), + form("check", "project", "what blocks a build (exit 1 on anything blocking)", [project({ required: false, help: "one project; none: every project" }), bool("--all-severities", "the info rows too")]), + form("links", "project", "do the clip QRs open on their sites (out/links.json)", [project(), bool("--fix", "rewrite the dead links it knows the fix for")], { timeoutMin: 30 }), + + // ---- the cast ---- + form("cast ls", "corpus", "the characters' voices across projects", [], { shape: "cast ls" }), + form("cast add", "corpus", "a character: name, stock voice, handles", [ + arg("id"), opt("--name", { required: true }), opt("--voice", { required: true, help: "engine:voice" }), opt("--handles", { help: "a,b" }), opt("--speakers", { help: "Name,…" }), + pick("--convert-engine", ["openvoice", "seed-vc"]), opt("--convert-voice", { help: "engine:voice" }), opt("--note"), bool("--narrator", "the recordings' default character"), + ]), + form("cast set", "corpus", "change a character", [ + arg("id"), opt("--name"), opt("--voice", { help: "engine:voice" }), opt("--handles"), opt("--speakers"), pick("--convert-engine", ["openvoice", "seed-vc"]), opt("--convert-voice"), + opt("--note"), opt("--add-handle"), opt("--remove-handle"), bool("--no-convert"), bool("--narrator"), bool("--no-narrator"), + ]), + form("cast rm", "corpus", "a character out of the cast (an undo point)", [arg("id")]), + form("cast undo", "corpus", "the cast as it was before its last write", []), + form("cast project", "project", "the project's characters, their voices and drift", [project()]), + form("cast audition", "project", "one line read by 2-6 candidate voices, scored against the real voice", [ + arg("character", { allowAt: true, help: "a character id or @handle" }), opt("--voices", { required: true, help: "engine:voice,engine:voice,…" }), project({ name: "--project", required: false }), + opt("--text", { type: "text" }), opt("--item"), num("--line"), bool("--stock"), bool("--no-score"), bool("--score-only"), + ], Q), + form("cast use", "draft", "the voice a character reads in, here or everywhere", [project(), arg("character", { allowAt: true }), arg("voice", { help: "engine:voice" }), bool("--everywhere", "the cast's voice, not this project's")], { shape: "cast use <project> <character> <voice>" }), + form("cast reread", "project", "the items that say a character in another voice, read again", [project(), arg("character", { allowAt: true }), dry()], Q), + + form("speaker-check", "project", "which named voice each clip is (speaker-check.json)", [ + project(), many("--clip", { repeat: true, help: "clip ids, one per line (none: every clip)" }), bool("--list", "list the named voices"), + opt("--set", { help: "Name=<clip>,<channel>/<id>,channel:<slug>" }), opt("--remove", { help: "a voice's name" }), + ], { ...Q, confirm: { what: "remove that named voice from speakers.json", when: ["--remove"] } }), + form("quote-check", "project", "is each clip's quote in the seconds it plays", [project(), opt("--clips", { help: "a,b (none: every clip)" }), num("--pad"), bool("--status", "the rows as they stand")], Q), + form("check-joins", "project", "do a rendered take's post joins carry on", [project(), takeOpt({ required: true, help: "the rendered take" }), bool("--all", "every post-to-post boundary"), num("--limit")], Q), + form("link-policy", "draft", "cite via site X, these channels direct", [ + project(), opt("--via", { help: "a site id or its https address" }), opt("--direct", { help: "channel slugs, a,b" }), bool("--clear"), bool("--fix", "rewrite the clips that break it"), + ]), + form("patch-markers", "draft", "take patches whose deck markers name a clip not in the cut", [project(), arg("file", { required: false, help: "<file>.patch.json (none: every patch)" }), bool("--fix")]), + form("decisions", "corpus", "every decision waiting, by project", []), + form("inbox", "corpus", "the decisions grouped and ranked as the Inbox shows them", [bool("--all", "the hidden ones and the quiet group too")]), + form("schedule list", "corpus", "the recurring reports", []), + form("schedule show", "corpus", "one recurring report: chip, editions, tick log", [arg("id")]), + form("folders", "corpus", "the reports tree's folders", []), + form("kinds", "corpus", "the project kinds the registry knows", []), + form("link", "draft", "the manifest names the article it is the video of", [project(), arg("article", { required: false, help: "<site>/<report>" }), bool("--clear")]), + + // ---- a clip ---- + form("window", "draft", "a clip's window, cut, attribution and verdict", [ + project(), clip(), + num("--start", { help: "the extent's start, source s" }), num("--end"), bool("--lock"), bool("--lock-end"), bool("--no-lock-end"), + num("--cut-start", { help: "the cut the video renders, source s" }), num("--cut-end"), bool("--lock-cut"), bool("--align", "the cut snapped to the quote as heard"), + opt("--title"), opt("--date", { help: "YYYY-MM-DD" }), num("--cite"), opt("--cite-url"), opt("--quote", { type: "text" }), opt("--repeat-of"), + pick("--verdict", ["confirmed", "incorrect"]), opt("--correction", { type: "text", help: "what the report got wrong (incorrect needs one)" }), + pick("--reject", REJECT_WHYS), opt("--note", { type: "text" }), opt("--walk-note", { type: "text" }), bool("--star"), bool("--no-star"), + bool("--quote-ruled"), bool("--no-quote-ruled"), opt("--move-stamp", { help: "first | nearest | <s>" }), bool("--clear-stamp"), pick("--move-mute", ["nearest"]), bool("--clear-mute"), + many("--gap", { repeat: true, help: "FROM-TO source seconds, one per line" }), num("--gap-remove"), opt("--gaps", { help: "A-B,C-D (the whole list)" }), + takeOpt(), + ]), + form("walk", "project", "the clip bench's walk: clips in walk order, verdicts, fetched", [project(), takeOpt({ help: "walk a take (a draft too)" }), bool("--all", "every fetched clip")]), + form("present", "project", "present mode's address and slides", [project(), takeOpt({ help: "that take's cut (default the latest)" }), bool("--cut", "the manifest alone"), bool("--public", "as a public page would carry it")]), + form("set", "draft", "a clip's knobs: claim, marks, audio, blur, fx …", [project(), clip(), pairs({ help: "key=value, one per line (claim.at=190.2, audio.gain=-3, `key=` clears)" }), opt("--mark", { help: "the mark the claim.* keys set" }), takeOpt()]), + form("intro", "draft", "the intro the cut opens on (render.intro)", [project(), pairs({ required: false, help: "key=value, one per line (style=boot-dark, seconds=4); none: print it" }), bool("--off", "take the intro off"), takeOpt({ help: "a version: --off opens it on no intro, --on on the cut's" }), bool("--on")]), + form("look", "draft", "the cut's knobs: mode, deck, fact-check stamps, variants …", [project(), pairs({ help: "key=value, one per line (mode=basic, deck.markerLayout=stagger)" }), many("--unset", { repeat: true, help: "render.<key>, a legacy key dropped" })]), + form("migrate", "draft", "the manifest's settings into the video modules' homes", [project(), dry()]), + form("variants", "project", "make the encode ladder of a build", [project(), takeOpt({ help: "a take's build" }), bool("--list", "what was made, and the sync report")], Q), + form("corrections", "project", "what the report got wrong, as markdown", [project()]), + form("build", "project", "the build's chain, printed (the Cut tab's Build runs it)", [project(), pick("--preset", ["preview", "fast", "final"]), opt("--only", { help: "one clip id" }), bool("--dry")]), + form("chain", "corpus", "an article iteration's pipeline to a video", [ + arg("article"), num("n", { required: true, help: "the iteration" }), opt("--from", { help: "the step to start at" }), bool("--dry", "print it"), bool("--final"), + opt("--site-origin"), bool("--draft-all", "Draft everything"), opt("--model"), bool("--deck"), + ], Q), + form("index", "corpus", "the project index (the cache)", [bool("--rebuild"), bool("--prune"), num("--since", { help: "ms" })], { confirm: { what: "prune the index's rows of projects no longer on disk", when: ["--prune"] } }), + form("new", "corpus", "a new project (scaffold)", [ + arg("slug", { help: "<slug> or <folder>/<slug>" }), opt("--folder"), opt("--from", { type: "ref", help: "a share URL or <channel>/<id> (a report.md: from a terminal)" }), opt("--site-origin"), + pick("--seed", ["chapters", "frames", "phrase", "reactions"]), num("--target", { help: "s" }), opt("--phrase", { help: "a regex (--seed phrase)" }), opt("--channels", { help: "a,b" }), + opt("--prefer"), opt("--exclude"), num("--max"), opt("--from-posts", { type: "name", help: "a posts channel: a posts reel" }), name("--brand"), + ], { timeoutMin: 30 }), + form("doctor", "corpus", "the tools and the roots on this machine", []), + form("storage status", "corpus", "where each project's out/ lives", [project({ required: false })]), + none("storage move-out", "project", "out/ to the media root, a link left", "moves a project's out/ between drives: a terminal's, run when nothing builds (the page cannot see a hand-run writer)"), + none("storage move-back", "project", "out/ back into the project", "moves a project's out/ between drives: a terminal's, run when nothing builds"), + none("storage deliverables", "project", "clips/ and share-*/ to the media root and back", "moves deliverables between drives, then the switch: a terminal's, run when nothing builds"), + form("snapshot", "project", "copy the manifest into revisions/", [project(), opt("--label")]), + form("diff", "project", "what changed since a snapshot", [project(), arg("snapshot", { help: "its path under revisions/" })]), + form("export", "project", "the posting artifacts, or one clip clean into exports/", [ + project(), clip({ required: false, help: "one clip (none: --format)" }), pick("--format", ["toc-bbcode", "toc-markdown", "description", "chapters"]), opt("--variant"), opt("--first"), + num("--context", { help: "± s, as recorded" }), bool("--raw", "the fetched window as recorded"), num("--from"), num("--to"), bool("--fetch", "ask the editor first for what is not on disk"), takeOpt(), + ], Q), + form("check-sources", "corpus", "the re-check chain, printed", [many("projects", { help: "one per line (none: the never-checked and > 30 d)" })]), + + // ---- notes ---- + form("notes", "corpus", "the operator's notes, as markdown", [arg("target", { required: false, help: "<site>/<report> or a project" }), bool("--all"), bool("--resolved"), bool("--all-status")]), + form("notes reply", "corpus", "answer a note", [arg("id"), arg("text", { type: "text" }), bool("--resolve")], { confirm: { what: "answer the note and resolve it", when: ["--resolve"] } }), + form("notes resolve", "corpus", "a note resolved", [arg("id")], { confirm: { what: "resolve the operator's note" } }), + form("notes wontfix", "corpus", "a note closed as won't fix", [arg("id")], { confirm: { what: "close the operator's note as won't fix" } }), + form("notes reopen", "corpus", "a note open again", [arg("id")]), + form("notes source", "corpus", "the source a target's notes name (the draft to edit)", [arg("target", { help: "<site>/<report>" }), opt("--draft"), opt("--generator"), opt("--how")]), + + // ---- modules, presets ---- + form("modules list", "corpus", "the video modules", []), + form("modules apply", "draft", "a module-config.json onto the cut, or as a take's patch", [ + project(), file("--config"), dry(), takeOpt({ help: "made as that take (rendered) instead" }), opt("--label"), ...window_(), bool("--quick"), bool("--force"), name("--from"), + ], Q), + form("preset list", "corpus", "the look presets", []), + form("preset show", "corpus", "one look preset", [name("name")]), + form("preset save", "corpus", "a project's look as a preset", [name("name"), project({ name: "--from" }), opt("--description"), bool("--force")], { confirm: { what: "overwrite the preset of that name", when: ["--force"] } }), + form("preset apply", "draft", "a preset under the cut (none: off it)", [name("name", { help: "a preset, or none" }), project(), bool("--replace", "clear the manifest's own values of its keys")]), + + // ---- takes ---- + form("take", "project", "one take: rendered, drafted, previewed or promoted", [ + project(), name("--id", { required: true, context: "take", help: "the take's id" }), opt("--label"), opt("--group"), pick("--kind", ["similar", "different"]), opt("--summary"), + opt("--style"), file("--patch", { help: "a patch file of the project" }), opt("--patch-json", { type: "json" }), many("--set", { repeat: true, item: "pair", help: "path=value, one per line" }), opt("--effect"), + ...window_(), bool("--quick"), bool("--force", "make it again over the take there"), name("--from", { help: "a take whose built parts it reuses" }), bool("--keep-frames"), bool("--priority", "render mode for its lifetime"), bool("--uncensored"), + bool("--draft", "record it, render nothing"), bool("--rebuild"), bool("--preview"), bool("--changes"), num("--pad"), bool("--no-preview"), + bool("--promote", "make this take the cut"), bool("--anyway"), + many("--import-item", { repeat: true, help: "<project>:<item>[,<item>…], one per line" }), opt("--after"), opt("--before"), opt("--as"), dry(), + ], { ...Q, confirm: { what: "make the take again over the one there", when: ["--force"] } }), + form("lint", "project", "the manifest lint a build runs first", [project(), takeOpt({ help: "a take's manifest" }), pick("--variant", ["sourced", "full"]), bool("--final")]), + form("take status", "project", "a take's render record", [project(), name("--id", { context: "take" }), bool("--log"), num("--tail")]), + none("queue add", "corpus", "a step of the durable queue: a umtool command's argv", "takes a raw argv -- a page never sends one (app/api/queue/route.ts); a form's Run on a heavy verb queues the step itself"), + form("queue ls", "corpus", "the queue's steps and its runner", [bool("--all")]), + form("queue status", "corpus", "one step: state, exit code, error, log", [arg("qid")]), + none("queue wait", "corpus", "wait for a step to finish", "blocks a terminal until a step ends: a form's Run follows its own step"), + form("queue log", "corpus", "a step's full log", [arg("qid"), num("--tail")]), + form("queue cancel", "corpus", "a step cancelled (a running one stopped)", [arg("qid")], { confirm: { what: "cancel the step (a running one is killed)" } }), + form("queue retry", "corpus", "a failed or cancelled step back in the queue", [arg("qid")]), + form("jobs", "corpus", "every running and recent render, step and app job", []), + form("takes make", "project", "a recipe's takes, or one per montage style", [ + project(), file("--recipe"), opt("--only", { help: "ID,ID" }), bool("--force", "make again the takes that exist"), bool("--all-styles"), opt("--group"), ...window_(), bool("--quick"), bool("--priority"), + ], { ...Q, confirm: { what: "render again over the takes that exist", when: ["--force"] } }), + form("takes styles", "corpus", "the montage styles", []), + form("takes pick", "project", "use this take: its manifest over the project's", [project(), takeArg(), bool("--anyway"), bool("--pin"), bool("--unpin")]), + form("takes effects", "project", "the overlay effects this cut offers", [project()]), + form("takes ls", "project", "the working cut, then each take", [project()]), + form("takes relabel", "project", "a take's label", [project(), takeArg(), arg("label")]), + form("takes supersede", "project", "a take folded away in the list (or back)", [project(), takeArg(), name("--by"), bool("--clear")]), + form("takes save", "project", "the working draft frozen as the next version (v<N>)", [project(), opt("--label"), bool("--force", "save even with no edits since its parent")]), + form("takes open", "draft", "a saved version into the draft (the draft saved first)", [project(), takeArg({ help: "the version (or take) to open" })]), + form("takes freeze", "project", "legacy takes given a frozen base (a dry run unless --apply)", [project(), many("takes", { item: "name", help: "take ids, one per line (none: --all)" }), bool("--all"), bool("--apply", "write them (else a dry run)")], { confirm: { what: "write each legacy take's frozen base (how it resolves can change)", when: ["--apply"] } }), + none("takes delete", "project", "a take's directory, whole", "deletes a take's directory whole, past undo: the Takes panel's Delete asks first; a terminal's --dry-run shows what goes"), + form("takes cancel", "project", "stop a take's render", [project(), takeArg()], { confirm: { what: "stop the take's render (killed, marked cancelled)" } }), + form("takes fork", "project", "the take as a variant project beside this one", [project(), takeArg(), name("--name")]), + form("takes compare", "project", "two takes side by side", [project(), arg("a", { help: "<take> or <project>:<take>" }), arg("b")]), + form("render-mode on", "corpus", "render mode: a render gets the machine, for a window", [opt("--for", { help: "90m, 2h (default 2h)" }), opt("--note")]), + form("render-mode off", "corpus", "render mode off", [bool("--force", "even while a render holds it")], { confirm: { what: "take render mode from the render that holds it", when: ["--force"] } }), + form("render-mode status", "corpus", "is render mode on, for what, until when", []), + form("pool stats", "corpus", "the render pool: what it holds", [opt("--since", { help: "7d" })], { shape: "pool stats" }), + form("pool prune", "corpus", "the render pool pruned to its cap", [num("--max-gb"), dry()], { confirm: { what: "delete render pool files past the cap", unless: ["--dry-run"] } }), + form("pool verify", "corpus", "the render pool's files checked", [num("--sample"), bool("--all")], Q), + form("trailer", "project", "a trailer or beat reel cut from a take's master", [ + project(), takeOpt({ help: "the take whose master it is cut from" }), reel(), file("--beats", { help: "a beats file of the project" }), opt("--beats-json", { type: "json" }), + bool("--intro"), num("--finale", { help: "s" }), num("--xfade"), bool("--no-snap"), name("--out", { help: "a file name, written in the take's out/" }), dry(), bool("--candidates", "the walk's ★ clips as beats (prints)"), bool("--vertical"), pick("--layout", ["reframe"]), + ], Q), + form("vertical", "project", "a vertical short (1080x1920) of a take's items", [ + project(), takeOpt({ required: true, help: "the take" }), reel(), file("--beats", { help: "a beats file of the project" }), opt("--items", { help: "id,id" }), pick("--clip", ["full", "framed", "quote"]), pick("--post", ["card", "stack", "media"]), + pick("--side", ["split", "overlay"]), opt("--hook", { help: "title | section | a line of the cut's own copy" }), pick("--captions", ["l", "xl"]), pick("--lines", ["1", "2"]), num("--loudness"), num("--max"), + name("--name"), bool("--reframe", "recompose the finished 16:9 master"), dry(), bool("--intro"), bool("--no-intro"), bool("--no-outro"), + ], Q), + + // ---- the trailer's beats ---- + ...trailerBeats(), + + form("tighten", "draft", "each clip to its sentence, each edge into its pause", [project(), bool("--all", "every clip"), bool("--no-measure", "the words alone"), opt("--apply", { help: "clip,clip: write those rows" })]), + form("ledger ls", "project", "a measure ledger's rows", [project(), opt("--scope"), opt("--population")], { shape: "ledger <project> ls" }), + form("ledger add", "draft", "a ledger row, checked against its schema", [ + project(), arg("id"), opt("--date"), opt("--scope"), opt("--population"), opt("--value"), opt("--scopeBasis", { type: "text" }), opt("--row", { type: "json" }), + { name: "more", type: "flagpairs", help: "any other key=value, one per line (each --key value)" }, + ], { shape: "ledger <project> add <id>" }), + form("ledger set", "draft", "a ledger row's keys", [project(), arg("id"), { name: "keys", type: "flagpairs", required: true, help: "key=value, one per line (each --key value; null clears)" }, opt("--unset", { help: "k,k" })], { shape: "ledger <project> set <id>" }), + form("ledger rm", "draft", "a ledger row removed (refused while something names it)", [project(), arg("id")], { shape: "ledger <project> rm <id>", confirm: { what: "remove the ledger row" } }), + form("measure", "project", "the measure slice the instruments draw from", [project(), takeOpt({ help: "that take's built seconds" }), opt("--scopes", { help: "a,b" }), opt("--scale", { help: "MIN-MAX" }), opt("--as-of", { help: "YYYY-MM-DD" })]), + form("rulings show", "project", "each montage clip and its ruling", [project()], { shape: "rulings <project> show" }), + form("rulings import", "draft", "the earlier rulings in the seed's edits.json", [project(), dry()], { shape: "rulings <project> import" }), + form("rulings set", "draft", "a montage clip's ruling", [project(), clip({ help: "the clip or its moment key" }), pick("ruling", ["keep", "cut", "not-him", "read-aloud"], { required: true }), opt("--reason"), opt("--match")], { shape: "rulings <project> set <clip> <ruling>" }), + form("rulings clear", "draft", "a montage clip's ruling cleared", [project(), clip()], { shape: "rulings <project> clear <clip>" }), + form("fetch", "project", "the clip windows, asked of the editor", [ + project(), dry(), bool("--wait", "follow the editor's jobs"), bool("--status", "the last run's jobs"), bool("--body", "print the request body"), opt("--reason"), + opt("--refetch", { help: "clipId,clipId: evict those windows first" }), opt("--refetch-video", { help: "<slug>/<id>" }), takeOpt({ help: "a take's clips" }), + ], { timeoutMin: 60, confirm: { what: "evict those cached windows, then fetch them again", when: ["--refetch", "--refetch-video"], unless: ["--dry-run"] } }), + form("prep", "project", "the bench's excerpts and waveforms, before the walk", [project(), opt("--clips", { help: "a,b" }), bool("--wait", "here, until done"), bool("--status"), takeOpt()], Q), + form("prune", "project", "takes' work files freed by policy (a dry run unless --yes)", [ + project({ required: false, help: "one project (none: --all)" }), bool("--all"), opt("--take", { help: "X[,Y]" }), bool("--anyway"), num("--keep"), opt("--older-than", { help: "3d" }), opt("--idle-work", { help: "3d" }), + bool("--versions", "whole superseded takes"), opt("--idle"), opt("--grace"), bool("--yes", "free them (else a dry run)"), + ], { confirm: { what: "delete those work files (--versions: whole superseded takes)", when: ["--yes"] } }), + form("fallback", "draft", "stand-ins for refused montage windows", [project(), dry(), many("--clip", { repeat: true, help: "clip ids, one per line (none: every candidate)" }), opt("--restore", { help: "a switched clip's id" })]), + form("phrases", "corpus", "how often each phrase was said, by year", [ + many("phrases", { required: true, help: "one phrase per line" }), opt("--channels", { required: true, help: "a,b" }), opt("--prefer"), opt("--exclude", { help: "a regex" }), + bool("--words"), bool("--regex"), num("--samples"), bool("--no-cache"), bool("--full"), + ], { timeoutMin: 30 }), + form("voice-match", "project", "a speaker-similarity score per montage clip", [ + project(), pick("--reference", ["auto", "rulings", "recordings"]), many("--reference-video", { repeat: true, item: "ref", help: "<channel>/<id>, one per line" }), many("--reference-channel", { repeat: true, item: "name" }), + file("--instances"), pick("--span", ["phrase", "cut"]), num("--pad"), num("--likely"), num("--unlikely"), bool("--dry"), + ], Q), + form("clips analyze", "draft", "the clip finder's scans on a long recording, then proposals", [project(), opt("--from", { type: "ref", help: "<channel>/<id>" }), bool("--rescan"), bool("--no-laughs"), bool("--no-voices"), ...clipParams(), file("--words"), bool("--keep-cut"), opt("--scope"), opt("--segment")], Q), + form("clips propose", "draft", "the clip finder's proposals again, from what is there", [project(), opt("--from", { type: "ref", help: "<channel>/<id>" }), num("--host"), ...clipParams(), file("--words"), bool("--keep-cut"), bool("--dry")]), + form("clips show", "project", "the speakers, the laughs, what is in the cut", [project()]), + form("clips segments", "project", "the narrated-video spans auto-scope finds", [project()]), + form("refresh", "corpus", "re-fetch an article's scope: the plan, and --yes starts it", [arg("article", { required: false }), num("--iteration"), bool("--no-fetch"), bool("--yes", "start it"), bool("--check", "the daily suggestion check, now"), bool("--force")], { confirm: { what: "start the refresh: an editor job that fetches the article's scope again", when: ["--yes"] } }), + form("clip", "corpus", "quick clip: one moment to a basic-mode mp4 and its share line", [arg("spec", { help: "<channel>/<video>@<start>-<end>" }), pick("--snap", ["words"]), opt("--title"), name("--site"), name("--folder")], Q), + form("share", "project", "a clip's share line", [project(), clip({ required: false, help: "the clip (none: the first)" }), takeOpt({ help: "the take's cut" }), name("--site")]), + + // ---- the cut's structure ---- + ...timeline(), + + form("scenes", "project", "scene cuts and black spans in a clip's fetched window", [project(), clip(), num("--black-min"), num("--threshold"), num("--pix-th"), num("--pad"), num("--from"), num("--to")]), + + // ---- posts ---- + ...posts(), + + form("candidates ls", "project", "the proposed clips waiting on the Candidates panel", [project(), bool("--all", "the inserted and set aside too")], { shape: "candidates <project> ls" }), + form("candidates import", "project", "a sweep's bullets as candidates", [project(), file("file", { help: "a sweep's markdown, a file of the project" }), dry()], { shape: "candidates <project> import <file>" }), + form("candidates add", "project", "an agent's proposal(s) as candidates", [project(), arg("proposal", { type: "text", atFile: true, help: "JSON (@file: from a terminal)" })], { shape: "candidates <project> add <proposal>" }), + form("ingredient", "corpus", "one recording's (or clip window's) life cycle: found to published", [ + arg("recording", { type: "ref", help: "<channel>/<video> (a Rumble folder slug or its embed id)" }), opt("--window", { help: "<from>-<to>: one clip window" }), bool("--used-in", "every project clip that cuts from it, alone"), + ]), + none("help", "corpus", "every command", "prints the command list: the palette's Commands are the same list"), +]); + +function clipParams() { + return [num("--target", { help: "the cut's length, s" }), num("--laugh-min"), num("--merge-gap"), num("--setup-max"), num("--clip-max")]; +} + +function trailerBeats() { + const tb = (sub, summary, args, extra = {}) => + form(`trailer-beats ${sub}`, "project", summary, [project(), ...args, reel()], { shape: `trailer-beats <project> ${sub}`, ...extra }); + const n = (o = {}) => num("n", { required: true, help: "the beat's number", ...o }); + return [ + tb("ls", "a reel's beats against its limit", []), + tb("add", "a clip beat", [clip(), arg("span", { required: false, help: "<from>-<to> source s (none: the whole cut)" }), num("--at", { help: "its place" }), opt("--label"), takeOpt({ help: "the take it is anchored to" })]), + tb("add-raw", "a beat of master seconds", [num("at", { required: true }), num("dur", { required: true }), num("--at", { help: "its place" }), opt("--label")]), + tb("set", "beat n's source seconds", [n(), arg("span", { help: "<from>-<to>" }), opt("--label")]), + tb("gap", "seconds cut out of beat n's middle", [n(), pick("op", ["add", "remove", "clear"], { required: true }), arg("value", { required: false, help: "<from>-<to> (add), a second (remove)" })]), + tb("remove", "a beat out", [n()]), + tb("move", "a beat to another place", [n(), num("--to", { required: true })]), + tb("order", "the beats in the cut's order", []), + tb("limit", "the running length's limit", [arg("limit", { help: "s, m:ss, x, instagram, shorts, tiktok" })]), + tb("xfade", "the crossfade's seconds", [num("seconds", { required: true })]), + tb("intro", "the reel's intro", [arg("value", { help: "on | off | a render.intro JSON" })]), + tb("outro", "the card the reel ends on", [arg("value", { help: "on | off | none | a JSON card" })]), + tb("candidates", "the walk's ★ clips not yet beats", [bool("--add", "add them all")]), + tb("verdict", "the walk's word on beat n", [n(), pick("verdict", ["confirmed", "note", "clear"], { required: true })]), + tb("title", "the reel's name", [arg("text", { help: "a title, or none" })]), + tb("take", "the take the reel is cut from", [name("take", { context: "take", help: "a take, or none" })]), + tb("undo", "the reel as it was before its last write", []), + tb("status", "each beat against the take the reel plays now", [takeOpt({ help: "against that take" })]), + tb("anchor", "beats anchored to a take's master", [many("beats", { help: "beat numbers, one per line (none: all)" }), takeOpt({ required: true })]), + tb("clamp", "a clipped beat pulled inside its clip", [n(), takeOpt()]), + tb("repoint", "an orphan beat's seconds on another clip", [n(), clip(), takeOpt()]), + tb("history", "every write to the reel", []), + tb("reels", "the project's reels", []), + tb("new-reel", "a new reel, empty or a copy", [name("name"), name("--from", { help: "a reel to copy" }), opt("--title")]), + ]; +} + +function timeline() { + const tl = (sub, target, summary, args, extra = {}) => + form(`timeline ${sub}`, target, summary, [project(), ...args], { shape: `timeline <project> ${sub}`, ...extra }); + const id = (o = {}) => arg("id", { context: "clip", help: "the entry's id", ...o }); + const gid = () => arg("gid", { help: "the group's id" }); + const marker = () => arg("marker", { help: "the section's marker" }); + const ids = (o = {}) => many("ids", { required: true, help: "entry ids, one per line", ...o }); + return [ + tl("ls", "project", "the cut: index, id, type, video, start–end", [takeOpt({ help: "a take's timeline" })]), + tl("insert", "draft", "a clip (or a post item) into the cut", [ + arg("spec", { help: "<channel>/<video>@<start>-<end>, post:<channel>/<postId> or post-json:<json>" }), opt("--after", { help: "an entry id, or - (the start)" }), + num("--to-section"), opt("--group"), opt("--id"), num("--section"), bool("--lock"), bool("--lock-end"), opt("--title"), opt("--stream-title"), opt("--date", { help: "YYYY-MM-DD" }), + opt("--quote", { type: "text" }), num("--cite"), opt("--cite-url"), takeOpt(), + ]), + tl("move", "draft", "an entry to an index", [id(), num("--to", { required: true, help: "its place after the move (0 first)" }), takeOpt()]), + tl("place", "draft", "entries before another (Play's drag)", [ids(), opt("--before", { required: true, help: "an entry id, or - (the end)" }), num("--section")]), + tl("remove", "draft", "an entry out of the cut", [id(), num("--at", { help: "which of an id's twins" }), takeOpt()]), + tl("duplicate", "draft", "an entry twice", [id(), num("--at")]), + tl("reject", "draft", "an entry rejected and removed, on the record", [id(), pick("why", REJECT_WHYS, { required: true }), opt("--note", { type: "text" })]), + tl("wrong-speaker", "draft", "an entry removed: the wrong speaker", [id(), opt("--correction", { type: "text" })]), + tl("post", "draft", "a post added, or the one with its id replaced", [arg("post", { type: "text", atFile: true, help: "JSON (@file: from a terminal)" })]), + tl("post-remove", "draft", "a post out of the cut", [arg("id", { context: "post" })]), + tl("teaser", "draft", "a teaser's lines, beat, dip, tail", [id(), arg("patch", { type: "text", atFile: true, help: "a JSON patch (@file: from a terminal)" })]), + tl("undo", "draft", "the newest automatic snapshot back", [takeOpt({ help: "a take's own undo" })]), + tl("sections", "project", "the deck's sections and their clips", []), + tl("section-move", "draft", "clips to the end (or start) of section N", [ids(), num("--to-section", { required: true }), bool("--start")]), + tl("section-add", "draft", "a new section after a clip", [opt("--after", { required: true }), opt("--label"), opt("--color"), pick("--level", ["1", "2"])]), + tl("section-boundary", "draft", "a section boundary dragged", [marker(), opt("--after", { required: true })]), + tl("section-remove", "draft", "a section's marker removed", [marker()]), + tl("section-set", "draft", "a section's label, colour or level", [marker(), opt("--label"), opt("--color"), pick("--level", ["1", "2"])]), + tl("split", "draft", "a clip in two at a source second", [id(), num("second", { required: true })]), + tl("flash-forward", "draft", "a tight copy of a span elsewhere, as a repeat", [id(), arg("span", { help: "<from>-<to>" }), opt("--after"), num("--to-section"), bool("--start"), bool("--move", "the span leaves the clip"), opt("--quote"), opt("--id")]), + tl("order", "draft", "the cut's order in one write", [many("order", { required: true, item: "id", help: "entry ids in order, one per line" })]), + tl("threads", "draft", "the cut's conversations (and --write gathers them)", [bool("--write"), opt("--conversation")]), + tl("groups", "project", "the claim groups, by section", []), + tl("groups import", "draft", "a claim-groups file in one write", [file("file", { help: "a claim-groups file of the project" }), bool("--skip-missing"), bool("--drop-empty")]), + tl("groups set", "draft", "a group is these clips", [arg("gid", { help: "a group id, or - (a new one)" }), ids(), opt("--claim")]), + tl("groups label", "draft", "a group's claim", [gid(), arg("claim", { type: "text" })]), + tl("groups remove", "draft", "a group dissolved (its clips stay)", [gid()]), + tl("groups move", "draft", "a whole group to another place", [gid(), opt("--to", { required: true, help: "<index>, or after <gid>" })]), + tl("groups promote", "draft", "a group opens a subsection", [gid(), opt("--label")]), + tl("add-video", "draft", "a video entry: a project file full frame", [ + file("src", { pass: "relative", help: "a video file of the project, relative to its directory" }), num("--from"), num("--to"), pick("--fit", ["contain", "cover"]), num("--bass"), num("--gain"), opt("--enter", { help: "cut | <out>,<in>" }), + num("--hold"), opt("--title"), opt("--id"), opt("--after"), dry(), takeOpt(), + ]), + tl("set-video", "draft", "a video entry's knobs", [id(), pairs({ help: "from= to= fit= audio.gain= …, one per line" }), takeOpt()]), + ]; +} + +function posts() { + const p = (sub, target, summary, args, extra = {}) => form(`posts ${sub}`, target, summary, [project(), ...args], extra); + const items = () => many("items", { help: "post item ids, one per line" }); + return [ + p("add", "draft", "a post card from the posts archive", [arg("post", { help: "<archive-channel>/<postId>" }), opt("--attach", { help: "a clip id" }), opt("--flag"), opt("--author"), opt("--id"), bool("--thread"), num("--crop"), dry()]), + p("set", "draft", "the Posts table's writer: thread, hide, attach, crop", [arg("post", { context: "post", help: "x-<postId> or the bare id" }), pairs({ help: "thread=on, hide=off, attach=<clip>|auto, crop=<px>|off" })]), + p("reel", "draft", "post items from posts channels, in one write", [ + many("--channel", { repeat: true, required: true, item: "name", help: "posts channels, one per line" }), opt("--since"), opt("--until"), bool("--own"), bool("--with-media"), + pick("--replies", ["include", "only", "exclude"]), pick("--order", ["chrono", "reverse"]), num("--limit"), opt("--after"), dry(), + ]), + p("set-item", "draft", "a post item's knobs", [item(), pairs({ help: "hold=4, layout=grid, media.0.start=2 …" }), inTake()]), + p("narrate", "draft", "a post item's narration: script, takes, pick, approve, mix", [ + item({ required: false, help: "the post item (none: --list, --import, --all or --cut)" }), opt("--script", { type: "text" }), bool("--take", "a new read (the editor's tts)"), opt("--note"), + opt("--voice"), opt("--engine"), num("--speed"), num("--pick"), bool("--approve"), bool("--unapprove"), bool("--off"), bool("--on"), + bool("--thread", "with --take: a thread read"), opt("--parents"), bool("--words", "the picked take's word timings"), bool("--import"), bool("--list"), bool("--all"), bool("--draft-scripts"), + num("--limit"), bool("--force"), file("--recording", { help: "a person's recording (a file of the project) made the read" }), opt("--as"), dry(), + pairs({ required: false, help: "the mix: lead= tail= linger= rate= …, one per line" }), inTake(), + ], Q), + p("say", "draft", "the pronunciation lexicon", [pick("op", ["ls", "add", "remove", "try", "stale"], { required: true }), arg("word", { required: false, allowAt: true, help: "the word or phrase (try: the text)" }), arg("spoken", { required: false }), bool("--case"), opt("--item"), opt("--note")], { shape: "posts say <project> <op>" }), + p("voices", "draft", "the voice map a thread read uses", [pick("op", ["ls", "set", "remove"], { required: true }), arg("handle", { required: false, help: "a handle, or *" }), arg("voice", { required: false })], { shape: "posts voices <project> <op>" }), + p("fit", "draft", "narrated posts' videos cut to their best part", [items(), bool("--all"), num("--linger"), dry()], Q), + p("fx", "draft", "a post item's word zooms, captions, clock, slams", [ + item(), pick("op", ["ls", "add", "set", "remove"], { required: true }), arg("what", { required: false, help: "add: word-zoom | caption | clock | slam; set/remove: n" }), + { name: "flags", type: "flagpairs", help: "match=…, text=…, at=…, one per line (each --key value)" }, inTake(), + ], { shape: "posts fx <project> <item> <op>" }), + p("clock", "draft", "the cut's clock default", [pick("mode", ["on", "off", "default"]), opt("--zone", { help: "an IANA zone" })]), + p("progress", "draft", "the cut's progress bar default", [pick("mode", ["auto", "on", "off", "default"])]), + p("avatar", "draft", "an author's picture on the cards", [arg("handle", { required: false, allowAt: true }), file("image", { required: false, literals: ["off"], help: "a picture file of the project, or off" })]), + p("avatars", "draft", "the authors' pictures from the archive", [dry()]), + p("redact", "draft", "words blanked from what is published", [pick("op", ["ls", "add", "remove"], { required: true }), arg("value", { required: false, help: "the term (add), its n (remove)" }), bool("--substring"), opt("--note")], { shape: "posts redact <project> <op>" }), + p("slurs", "draft", "the slur filter", [pick("op", ["ls", "on", "off", "level", "visual", "voice", "add", "except", "remove", "edges"], { required: true }), arg("value", { required: false }), bool("--off")], { shape: "posts slurs <project> <op>" }), + p("context", "draft", "each post item's context from its capture", [dry()]), + p("repeats", "project", "the attachments played more than once", [pick("--match", ["id", "file", "audio"])]), + p("combo", "draft", "the combo badge's knobs (the cut's, or one item's)", [arg("item", { required: false, context: "post" }), pairs({ required: false, help: "on=on, label=COMBO … (an item: off | on | auto first)" })]), + p("attach", "draft", "a capture's media onto post items that carry none", [items(), bool("--all"), dry()]), + p("scenes", "draft", "the media scenes (and the cut's on/off)", [pick("mode", ["on", "off"])]), + p("picture-reply", "draft", "the cut's picture-only rule", [pairs({ required: false, help: "on=on, image=2, min=1.5 …" }), inTake()]), + p("roles", "draft", "a read's pieces, stored or inferred", [items(), bool("--write"), opt("--set", { help: "<n>=<role>,…" }), inTake()]), + p("reread", "draft", "a read re-joined, re-timed, paused or a phrase re-voiced", [ + item(), opt("--without", { help: "parent:0,quoted …" }), opt("--drop-parts"), bool("--drop-urls"), opt("--tempo-for"), num("--tempo"), opt("--parts"), pick("--stretch", ["atempo", "rubberband"]), + bool("--yell-caps"), num("--yell-gain"), pick("--yell-style", ["raise", "shout", "loud"]), opt("--pause"), opt("--target"), opt("--revoice"), opt("--say"), opt("--voice"), num("--xfade"), opt("--splice"), dry(), inTake(), + ], Q), + p("yell", "draft", "the caps he wrote, yelled in the read", [items(), bool("--all"), num("--yell-gain"), pick("--yell-style", ["raise", "shout", "loud"]), dry()], Q), + ]; +} + +// ---- reading the table ------------------------------------------------------------ + +/** The row for a verb, or null. */ +export const verbRow = (verb) => VERBS.find((r) => r.verb === verb) ?? null; + +/** The rows the palette offers (ui "form"), as the page needs them: no prose. */ +export function formVerbs() { + return VERBS.filter((r) => r.ui === "form").map((r) => ({ + verb: r.verb, + summary: r.summary, + target: r.target, + queue: !!r.queue, + confirm: r.confirm ?? null, + args: r.args, + })); +} + +/** The top-level command a row belongs to: its first word. */ +export const commandOf = (verb) => String(verb).split(" ")[0]; diff --git a/umtool/lib/cli/verbs.test.mjs b/umtool/lib/cli/verbs.test.mjs @@ -0,0 +1,311 @@ +// The verb registry (lib/cli/verbs.mjs) names every verb umtool dispatches, +// each row is a form or says why it is not, and `umtool help` and +// docs/cli.md are what it generates. +import { test } from "node:test"; +import assert from "node:assert/strict"; +import { mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync, symlinkSync, writeFileSync } from "node:fs"; +import os from "node:os"; +import path from "node:path"; +import { fileURLToPath } from "node:url"; + +import { VERBS, formVerbs, verbRow, commandOf } from "./verbs.mjs"; +import { GROUPS } from "./groups.mjs"; +import { CLI_MD, DOCS_BEGIN, DOCS_END, usageText, withVerbsSection } from "./docs.mjs"; +import { buildArgv, cliLine, confirmOf, pathArgsOf, shellQuote, synopsis } from "./argv.mjs"; +import { confineToProject } from "./confine.mjs"; + +const UMTOOL = fileURLToPath(new URL("../../", import.meta.url)); +const read = (rel) => readFileSync(`${UMTOOL}${rel}`, "utf8"); +const ADD = "add a row to umtool/lib/cli/verbs.mjs: form(verb, target, summary, args) with its args, or none(verb, target, summary, reason) with why it has no form"; + +/** The top-level commands bin/umtool.mjs dispatches: its COMMANDS table's keys. */ +function dispatched() { + const src = read("bin/umtool.mjs"); + const a = src.indexOf("const COMMANDS = {"); + const b = src.indexOf("\n};", a); + assert.ok(a >= 0 && b > a, "bin/umtool.mjs has its COMMANDS table"); + return [...src.slice(a, b).matchAll(/^ {2}("?)([a-z][a-z-]*)\1:/gm)].map((m) => m[2]); +} + +// Where each command's sub-verbs are dispatched, and the pattern that names one. A sub-verb added to one of +// these files without a row fails "every sub-verb …" below, naming it. +const SUBVERBS = [ + { cmd: "takes", file: "lib/report/takeCli.mjs", re: /\bsub === "([a-z][a-z-]*)"/g }, + { cmd: "timeline", file: "lib/report/timelineCli.mjs", re: /\bverb === "([a-z][a-z-]*)"|case "([a-z][a-z -]*)":/g }, + { cmd: "posts", file: "lib/report/postsCli.mjs", re: /\bverb === "([a-z][a-z-]*)"/g }, + { cmd: "trailer-beats", file: "lib/report/trailerBeatsCli.mjs", re: /\bverb === "([a-z][a-z-]*)"|case "([a-z][a-z-]*)":/g }, + { cmd: "cast", file: "lib/report/castCli.mjs", re: /\bsub === "([a-z][a-z-]*)"/g, ignore: ["help", "remove"] }, + { cmd: "queue", file: "lib/queue/cli.mjs", re: /\bsub === "([a-z][a-z-]*)"/g }, + { cmd: "notes", file: "lib/annotations/cli.mjs", re: /\bverb === "([a-z][a-z-]*)"/g, ignore: ["help"] }, + { cmd: "rulings", file: "lib/report/rulingsCli.mjs", re: /\bverb === "([a-z][a-z-]*)"/g }, + { cmd: "ledger", file: "lib/report/ledgerCli.mjs", re: /\bverb === "([a-z][a-z-]*)"/g }, + { cmd: "candidates", file: "lib/report/candidatesCli.mjs", re: /\bverb === "([a-z][a-z-]*)"/g }, + { cmd: "clips", file: "lib/report/reactions.mjs", re: /\bsub === "([a-z][a-z-]*)"/g, ignore: ["help"] }, + { cmd: "pool", file: "lib/report/poolCli.mjs", re: /\bsub === "([a-z][a-z-]*)"/g }, + { cmd: "render-mode", file: "lib/report/renderMode.mjs", re: /\bsub === "([a-z][a-z-]*)"/g }, + { cmd: "schedule", file: "bin/schedule.ts", re: /\bsub === "([a-z][a-z-]*)"/g }, + { cmd: "storage", file: "bin/umtool.mjs", re: /\bsub === "([a-z][a-z-]*)"/g, within: ["async function cmdStorage()", "async function cmdStorageDeliverables"] }, +]; + +/** The sub-verbs a file dispatches for a command. */ +function subverbsOf({ file, re, ignore = [], within }) { + let src = read(file); + if (within) src = src.slice(src.indexOf(within[0]), src.indexOf(within[1])); + const names = new Set(); + for (const m of src.matchAll(re)) names.add((m[1] ?? m[2]).trim()); + return [...names].filter((n) => !ignore.includes(n)); +} + +test("every command bin/umtool.mjs dispatches has a row (and its help lines in groups.mjs)", () => { + const verbs = new Set(VERBS.map((r) => commandOf(r.verb))); + const groups = new Set(GROUPS.map((g) => g.cmd)); + for (const cmd of dispatched()) { + assert.ok(verbs.has(cmd), `\`umtool ${cmd}\` is dispatched (bin/umtool.mjs COMMANDS) but has no row -- ${ADD}`); + if (cmd !== "help") assert.ok(groups.has(cmd), `\`umtool ${cmd}\` has no help lines -- add a group to umtool/lib/cli/groups.mjs`); + } + const all = new Set(dispatched()); + for (const r of VERBS) assert.ok(all.has(commandOf(r.verb)), `the row \`${r.verb}\` names a command bin/umtool.mjs does not dispatch`); + for (const g of GROUPS) assert.ok(all.has(g.cmd), `groups.mjs's \`${g.cmd}\` is not a command bin/umtool.mjs dispatches`); +}); + +test("every sub-verb the CLI modules dispatch has a row", () => { + const have = new Set(VERBS.map((r) => r.verb)); + for (const s of SUBVERBS) { + const subs = subverbsOf(s); + assert.ok(subs.length, `${s.file} still dispatches ${s.cmd}'s sub-verbs the way verbs.test.mjs reads them`); + for (const sub of subs) { + const verb = `${s.cmd} ${sub}`; + // A group's bare name ("timeline groups") is its listing. + assert.ok(have.has(verb), `\`umtool ${verb}\` is dispatched (${s.file}) but has no row -- ${ADD}`); + } + } + for (const v of ["modules list", "modules apply", "preset list", "preset show", "preset save", "preset apply", "render-mode off", "take status", "takes save", "takes open", "takes freeze"]) { + assert.ok(have.has(v), `\`umtool ${v}\` has no row -- ${ADD}`); + } +}); + +test("every row is a form or says why it is not, and its args make sense", () => { + const TYPES = new Set(["project", "string", "text", "number", "boolean", "choice", "json", "pairs", "flagpairs", "list", "name", "path", "ref"]); + const seen = new Set(); + for (const r of VERBS) { + assert.ok(!seen.has(r.verb), `\`${r.verb}\` has two rows`); + seen.add(r.verb); + assert.ok(r.summary?.trim(), `\`${r.verb}\` has a summary`); + assert.ok(["draft", "project", "corpus"].includes(r.target), `\`${r.verb}\`'s target is draft, project or corpus`); + assert.ok(r.ui === "form" || r.ui === "none", `\`${r.verb}\`'s ui is "form" or "none"`); + if (r.ui === "none") { + assert.ok(r.reason?.trim(), `\`${r.verb}\` has no form: say why (reason)`); + continue; + } + const names = new Set(); + for (const a of r.args) { + assert.ok(!names.has(a.name), `\`${r.verb}\`: ${a.name} twice`); + names.add(a.name); + assert.ok(TYPES.has(a.type), `\`${r.verb}\`: ${a.name}'s type ${a.type}`); + if (a.type === "choice") assert.ok(a.choices?.length, `\`${r.verb}\`: ${a.name} names its choices`); + if (a.type === "boolean" || a.type === "flagpairs") assert.ok(a.name.startsWith("--") || a.type === "flagpairs", `\`${r.verb}\`: a boolean is a flag`); + } + for (const t of (r.shape ?? r.verb).split(" ")) { + const m = /^<(.+)>$/.exec(t); + if (m) assert.ok(r.args.some((a) => a.name === m[1] && !a.name.startsWith("--")), `\`${r.verb}\`'s shape names <${m[1]}>, a positional it has`); + } + // The shape's words are the verb's own, in order. + const words = (r.shape ?? r.verb).split(" ").filter((t) => !t.startsWith("<")); + assert.deepEqual(words, r.verb.split(" "), `\`${r.verb}\`'s shape keeps its words in order`); + } + assert.ok(formVerbs().every((r) => !("usage" in r) && !("reason" in r)), "the page's list carries no prose"); + assert.equal(formVerbs().length, VERBS.filter((r) => r.ui === "form").length); +}); + +test("cli.md's generated section is current (node umtool/lib/cli/docs.mjs rewrites it)", () => { + const text = readFileSync(CLI_MD, "utf8"); + assert.ok(text.includes(DOCS_BEGIN) && text.includes(DOCS_END), "the markers are in cli.md"); + assert.equal(withVerbsSection(text), text, "umtool/docs/cli.md is stale: run `node umtool/lib/cli/docs.mjs`"); + // Every row is in it, and the hand-written sections around it stay. + for (const r of VERBS) assert.ok(text.includes(r.ui === "form" ? synopsis(r).replace(/\|/g, "\\|") : `\`${r.verb}\``), `cli.md lists \`${r.verb}\``); + assert.ok(text.includes("## Environment") && text.includes("## `check` is the one to run before every build")); +}); + +test("umtool help is generated from the groups, with its fills", () => { + const help = usageText({ reportsRoot: "/r", chainSteps: "current, windows", draftAllSteps: "a, b" }); + assert.match(help, /^umtool — the project tree, from a terminal\n\n {2}umtool ls /); + assert.match(help, /one step a process: current, windows/); + assert.match(help, /\(Draft everything\): a, b —/); + assert.match(help, /reading \/r {2}\(set REPORTS_DIR to move it\)/); + assert.ok(!help.includes("{chainSteps}")); + for (const g of GROUPS) for (const l of g.usage) assert.ok(/^ {2}umtool [a-z-]+ |^ {19}/.test(l), `${g.cmd}: "${l.slice(0, 40)}…" is a usage line`); +}); + +test("buildArgv: a row and a form's values to the words umtool is run with", () => { + const look = verbRow("look"); + assert.deepEqual(buildArgv(look, { project: "reports/basic-fixture", settings: "mode=basic\n\n deck.markerLayout=stagger " }), { + ok: true, + argv: ["look", "reports/basic-fixture", "mode=basic", "deck.markerLayout=stagger"], + }); + // The shape puts the project before the sub-verb; flags after the positionals. + const insert = verbRow("timeline insert"); + assert.deepEqual(buildArgv(insert, { project: "p", spec: "yt/abc@1-5", "--after": "-", "--lock": true, "--section": 2 }).argv, [ + "timeline", "p", "insert", "yt/abc@1-5", "--after", "-", "--section", "2", "--lock", + ]); + // A repeated flag, flag pairs. + assert.deepEqual(buildArgv(verbRow("look"), { project: "p", settings: ["a=1"], "--unset": ["render.rail", "render.title"] }).argv, [ + "look", "p", "a=1", "--unset", "render.rail", "--unset", "render.title", + ]); + assert.deepEqual(buildArgv(verbRow("ledger set"), { project: "p", id: "r1", keys: "value=12\nflags=a|b" }).argv, ["ledger", "p", "set", "r1", "--value", "12", "--flags", "a|b"]); + // A false boolean and an empty string are left out. + assert.deepEqual(buildArgv(verbRow("show"), { project: "p" }).argv, ["show", "p"]); + assert.deepEqual(buildArgv(verbRow("check"), { project: "", "--all-severities": false }).argv, ["check"]); +}); + +test("buildArgv refuses what a form may not send", () => { + const look = verbRow("look"); + const no = (values, re, row = look) => { + const r = buildArgv(row, values); + assert.equal(r.ok, false, JSON.stringify(values)); + assert.match(r.error, re); + }; + no({ project: "p" }, /settings is required/); + no({ project: "p", settings: "mode=basic", argv: ["rm", "-rf"] }, /takes no "argv"/); + no({ project: "--all", settings: "mode=basic" }, /may not start with "-"/); + no({ project: "p", settings: "--json" }, /not key=value/); + no({ project: "p", settings: "mode" }, /not key=value/); + no({ project: "p", settings: "a=\0" }, /NUL/); + no({ project: "p", settings: { a: 1 } }, /a string, a number/); + no({ project: "p", clip: "c1", "--start": "soon" }, /a number/, verbRow("window")); + no({ project: "p", clip: "c1", "--verdict": "maybe" }, /one of confirmed, incorrect/, verbRow("window")); + no({ project: "p", "--patch-json": "{nope", "--id": "t" }, /not JSON/, verbRow("take")); +}); + +test("an empty optional positional before a given one is refused (it would shift the words)", () => { + const row = { verb: "x", args: [{ name: "a", type: "string" }, { name: "b", type: "string" }] }; + const r = buildArgv(row, { b: "2" }); + assert.equal(r.ok, false); + assert.match(r.error, /a is needed before b/); + // Negative numbers are values, not flags. + assert.deepEqual(buildArgv(verbRow("window"), { project: "p", clip: "c1", "--start": "-0.5" }).argv, ["window", "p", "c1", "--start", "-0.5"]); +}); + +test("cliLine: the exact line to paste, quoted for a shell", () => { + assert.equal(cliLine(["look", "reports/basic-fixture", "mode=basic"]), "node umtool/bin/umtool.mjs look reports/basic-fixture mode=basic"); + assert.equal(shellQuote("it's here"), `'it'\\''s here'`); + assert.equal(shellQuote(""), "''"); + assert.equal(shellQuote('deck.markers=[{"after":"c01"}]'), `'deck.markers=[{"after":"c01"}]'`); + assert.equal(synopsis(verbRow("timeline move")), "timeline <project> move <id> --to N [--take TAKE]"); +}); + +test("a form's flags are flags the CLI still parses (a renamed flag fails here)", () => { + // Best effort: every `--flag` of a form row is a string literal somewhere in the CLI's parsers. A `--no-x` is + // the negation idiom of `--x` (bin/umtool.mjs window); ledger takes any `--<key>` of its schema. + const files = [ + ...readdirSync(`${UMTOOL}lib/report`).filter((f) => f.endsWith(".mjs") && !f.includes(".test.")).map((f) => `lib/report/${f}`), + "bin/umtool.mjs", "bin/schedule.ts", "bin/refresh.ts", "bin/inbox.ts", "lib/queue/cli.mjs", "lib/annotations/cli.mjs", "lib/phrase-finder/cli.mjs", "lib/ingredients/cli.mjs", + ]; + const src = files.map(read).join("\n"); + const GENERIC = new Set(["ledger"]); + const lost = []; + for (const r of VERBS) { + if (GENERIC.has(commandOf(r.verb))) continue; + for (const a of r.args) { + if (!a.name.startsWith("--")) continue; + const lit = (n) => src.includes(`"${n}"`) || src.includes(`'${n}'`); + const neg = a.name.startsWith("--no-") && lit(`--${a.name.slice(5)}`) && src.includes("`--no-${"); + if (!lit(a.name) && !neg) lost.push(`${r.verb} ${a.name}`); + } + } + assert.deepEqual(lost, [], "a form names a flag no CLI parser does: rename it in umtool/lib/cli/verbs.mjs"); +}); + +test("no form writes or reads a file a page names freely: outputs are bare names, inputs are project files", () => { + for (const r of VERBS.filter((x) => x.ui === "form")) { + for (const a of r.args) { + if (["--out", "--name", "--id", "--from", "--by", "--reel", "--folder", "--site"].includes(a.name) && a.type !== "project") { + assert.ok(["name", "ref", "string", "number"].includes(a.type), `${r.verb} ${a.name}: ${a.type}`); + } + if (a.name === "--out") assert.equal(a.type, "name", `${r.verb} --out is a bare name, never a path`); + if (a.type === "path") assert.ok(r.args.some((x) => x.name === "project" && x.type === "project"), `${r.verb}: a path arg needs the project it is inside`); + if (/@file/.test(a.help ?? "")) assert.ok(a.atFile, `${r.verb} ${a.name} names @file: it refuses it from a form`); + } + } + for (const v of ["vertical", "voice-match"]) assert.ok(!verbRow(v).args.some((a) => a.name === "--out"), `${v}: --out (a path) is a terminal's`); + for (const [v, n] of [["take", "--patch"], ["trailer", "--beats"], ["modules apply", "--config"], ["candidates import", "file"], ["timeline groups import", "file"], ["posts narrate", "--recording"], ["takes make", "--recipe"]]) { + assert.equal(verbRow(v).args.find((a) => a.name === n)?.type, "path", `${v} ${n} is a project file`); + } +}); + +test("names, paths, refs and @file: what a page may not send", () => { + const no = (row, values, re) => { + const r = buildArgv(row, values); + assert.equal(r.ok, false, JSON.stringify(values)); + assert.match(r.error, re); + }; + const trailer = verbRow("trailer"); + for (const out of ["../x.mp4", "a/b.mp4", ".hidden", "/etc/x", "..", "x\\y"]) no(trailer, { project: "p", "--out": out }, /bare name|start with "-"/); + assert.deepEqual(buildArgv(trailer, { project: "p", "--out": "teaser-2.mp4" }).argv, ["trailer", "p", "--out", "teaser-2.mp4"]); + no(verbRow("take"), { project: "p", "--id": "../../evil" }, /bare name/); + no(verbRow("take"), { project: "p", "--id": "t", "--patch": "@/etc/passwd" }, /no @/); + no(verbRow("candidates add"), { project: "p", proposal: "@/etc/passwd" }, /terminal only/); + no(verbRow("timeline teaser"), { project: "p", id: "t1", patch: "@x.json" }, /terminal only/); + for (const o of ["/etc/passwd", "package.json", "@ids.txt", "../x"]) no(verbRow("timeline order"), { project: "p", order: o }, /not an entry's id|start with "-"|terminal only/); + assert.deepEqual(buildArgv(verbRow("timeline order"), { project: "p", order: "c01\nx-1987\nt:2" }).argv, ["timeline", "p", "order", "c01", "x-1987", "t:2"]); + // An @file reference anywhere a CLI splits a value (review): post-json:@…, a=@…, a,@…. + for (const spec of ["post-json:@/etc/passwd", "post-json: @x.json", "@x", "post:@x"]) no(verbRow("timeline insert"), { project: "p", spec, "--after": "-" }, /terminal only/); + for (const settings of ["a=b,@/etc/passwd", "deck.markers=@m.json", "x=1;@y", "chat='@f'"]) no(verbRow("look"), { project: "p", settings }, /terminal only/); + no(verbRow("posts set-item"), { project: "p", item: "i1", settings: 'link.add= @/etc/passwd' }, /terminal only/); + no(verbRow("timeline set-video"), { project: "p", id: "v1", settings: "src=@x" }, /terminal only/); + // A person's words keep their @: a flag's value, free prose, a handle, a lexicon word, a pause at a take second. + assert.ok(buildArgv(verbRow("timeline insert"), { project: "p", spec: "yt/abc@1-5", "--quote": "@grok said, @x", "--title": "@sam" }).ok, "<channel>/<video>@<start>-<end> is not a file"); + assert.ok(buildArgv(verbRow("notes reply"), { id: "n1", text: "@operator: done" }).ok); + assert.ok(buildArgv(verbRow("posts say"), { project: "p", op: "add", word: "@grok", spoken: "At grok" }).ok); + assert.ok(buildArgv(verbRow("posts reread"), { project: "p", item: "i1", "--pause": "@12.5=0.4" }).ok); + for (const v of ["@/etc/passwd", "/etc/passwd", "../../x", "~/x", "a/../../b", "'@x'"]) no(verbRow("posts set-item"), { project: "p", item: "i1", settings: `parent.0=${v}` }, /terminal only|outside the project/); + no(verbRow("take"), { project: "p", "--id": "t", "--set": "render.x=@f" }, /terminal only/); + no(verbRow("ledger add"), { project: "p", id: "r", more: "src=../../etc" }, /outside the project/); + for (const from of ["./report.md", "/home/x/report.md", "../r.md", "report.md"]) no(verbRow("new"), { slug: "s", "--from": from }, /share URL or <channel>\/<id>/); + assert.deepEqual(buildArgv(verbRow("new"), { slug: "s", "--from": "https://example.com/s/abc" }).argv.slice(-2), ["--from", "https://example.com/s/abc"]); + assert.deepEqual(buildArgv(verbRow("new"), { slug: "s", "--from": "thequartering/abc_123" }).argv.slice(-2), ["--from", "thequartering/abc_123"]); + // A handle is not a file: cast's <character|@handle> stays a value. + assert.ok(buildArgv(verbRow("cast use"), { project: "p", character: "@grok", voice: "kokoro:am_michael" }).ok); + // "false" from a form is off. + assert.deepEqual(buildArgv(verbRow("check"), { "--all-severities": "false" }).argv, ["check"]); + // The path args the server confines, literals aside. + assert.deepEqual(pathArgsOf(verbRow("posts avatar"), { project: "p", handle: "h", image: "off" }), []); + assert.deepEqual(pathArgsOf(verbRow("posts avatar"), { project: "p", handle: "h", image: "pics/a.png" }).map((a) => a.name), ["image"]); +}); + +test("confirm: a row that deletes, evicts or kills asks, when its args make it so", () => { + assert.match(String(confirmOf(verbRow("prune"), { project: "p", "--yes": true })), /delete/); + assert.equal(confirmOf(verbRow("prune"), { project: "p" }), null, "a dry run"); + assert.match(String(confirmOf(verbRow("pool prune"), {})), /delete/); + assert.equal(confirmOf(verbRow("pool prune"), { "--dry-run": true }), null); + assert.match(String(confirmOf(verbRow("fetch"), { project: "p", "--refetch": "c1" })), /evict/); + assert.equal(confirmOf(verbRow("fetch"), { project: "p", "--refetch": "c1", "--dry-run": true }), null); + assert.equal(confirmOf(verbRow("fetch"), { project: "p" }), null); + for (const v of ["queue cancel", "notes resolve", "notes wontfix", "takes cancel", "ledger rm"]) assert.ok(confirmOf(verbRow(v), {}), v); + for (const [v, a] of [["index", "--prune"], ["takes freeze", "--apply"], ["render-mode off", "--force"], ["refresh", "--yes"], ["takes make", "--force"]]) { + assert.equal(confirmOf(verbRow(v), {}), null, `${v} bare`); + assert.ok(confirmOf(verbRow(v), { [a]: true }), `${v} ${a}`); + } + assert.ok(formVerbs().find((r) => r.verb === "prune")?.confirm, "the page knows to ask"); +}); + +test("confineToProject: a file of the project by its realpath, symlinks followed", async () => { + const tmp = mkdtempSync(path.join(os.tmpdir(), "umtool-confine-")); + try { + const proj = path.join(tmp, "proj"); + mkdirSync(path.join(proj, "promo"), { recursive: true }); + writeFileSync(path.join(proj, "promo", "beats.json"), "[]"); + writeFileSync(path.join(tmp, "secret.txt"), "the secret"); + symlinkSync(path.join(tmp, "secret.txt"), path.join(proj, "leak.txt")); + symlinkSync(proj, path.join(tmp, "alias")); + const ok = await confineToProject(proj, "promo/beats.json"); + assert.deepEqual(ok, { ok: true, abs: path.join(proj, "promo", "beats.json") }); + assert.equal((await confineToProject(path.join(tmp, "alias"), "promo/beats.json")).ok, true, "a project reached through a link"); + for (const bad of ["../secret.txt", path.join(tmp, "secret.txt"), "leak.txt", "promo", "nope.json", "promo/../../secret.txt"]) { + const r = await confineToProject(proj, bad); + assert.equal(r.ok, false, bad); + assert.ok(!String(r.error).includes("the secret"), "never what the file holds"); + } + } finally { + rmSync(tmp, { recursive: true, force: true }); + } +}); diff --git a/umtool/lib/report/candidatesCli.mjs b/umtool/lib/report/candidatesCli.mjs @@ -86,12 +86,14 @@ export async function candidatesCommand(args, { root = REPORTS_ROOT, out = (s) = if (verb === "add") { if (!arg) throw new CliError("add needs a JSON proposal (or @file)"); - const raw = arg.startsWith("@") ? await readFile(path.resolve(arg.slice(1)), "utf8") : arg; + const fromFile = arg.startsWith("@"); + const raw = fromFile ? await readFile(path.resolve(arg.slice(1)), "utf8") : arg; let v; try { v = JSON.parse(raw); } catch (e) { - throw new CliError(`add: not JSON (${e instanceof Error ? e.message : e})`); + // A file's words are never quoted back (JSON.parse's message carries its head): its name only. + throw new CliError(fromFile ? `add: ${path.basename(arg.slice(1))} is not JSON` : `add: not JSON (${e instanceof Error ? e.message : e})`); } const list = (Array.isArray(v) ? v : Array.isArray(v?.candidates) ? v.candidates : [v]).map((p) => normalizeProposal(p)); const res = await addCandidates(project.dir, list, { by }); diff --git a/umtool/lib/report/postsCli.mjs b/umtool/lib/report/postsCli.mjs @@ -910,10 +910,12 @@ const REF_KEYS = ["id", "author", "handle", "badge", "date", "text", "url", "med /** A context post given on the command line: JSON, or `@<file>.json`. Its `media` may name project files. */ const refArg = (raw, k) => { let j; + const file = raw.trim().startsWith("@") ? raw.trim().slice(1) : null; try { - j = JSON.parse(raw.trim().startsWith("@") ? readFileSyncText(raw.trim().slice(1)) : raw); + j = JSON.parse(file ? readFileSyncText(file) : raw); } catch (e) { - throw new CliError(`${k}= takes a post as JSON ({"id","handle","author","date","text"}) or @<file>.json -- ${e.message}`); + // A file's words are never quoted back (JSON.parse's message carries its head): its name only. + throw new CliError(`${k}= takes a post as JSON ({"id","handle","author","date","text"}) or @<file>.json -- ${file ? `${path.basename(file)} is not JSON` : e.message}`); } if (!j || typeof j !== "object" || Array.isArray(j)) throw new CliError(`${k}= takes a post as a JSON object`); const bad = Object.keys(j).filter((x) => !REF_KEYS.includes(x)); diff --git a/umtool/lib/report/sameOrigin.mjs b/umtool/lib/report/sameOrigin.mjs @@ -6,11 +6,44 @@ // // Plain ESM so `node --test` reads it. +// DNS REBINDING (lane palette review): a page on evil.example whose name is re-pointed at 127.0.0.1 is +// "same-origin" with itself and sends `Host: evil.example:3050`. So the host the request names -- Host, and +// X-Forwarded-Host when a proxy (or the page) sets one -- and the Origin's host must each be THIS machine +// (localhost, *.localhost, 127.x, ::1) or a name listed in UMTOOL_ALLOWED_HOSTS (comma-separated host names, +// no ports: the names a proxy in front of umtool serves it as; docs/knobs.md, "⌘K commands"). + +const LOOPBACK = new Set(["localhost", "127.0.0.1", "::1", "::ffff:127.0.0.1"]); + +/** A Host-header value's name, without its port or brackets, lower case. */ +export function hostNameOf(value) { + const v = String(value ?? "").trim().toLowerCase(); + if (v.startsWith("[")) return v.slice(1, v.indexOf("]") > 0 ? v.indexOf("]") : undefined); + return v.split(":")[0]; +} + +/** Whether a host name is this machine, or one the operator lists. */ +export function hostAllowed(name, env = process.env) { + const h = hostNameOf(name); + if (!h) return false; + if (LOOPBACK.has(h) || h.endsWith(".localhost") || /^127(\.\d{1,3}){3}$/.test(h)) return true; + const listed = String(env.UMTOOL_ALLOWED_HOSTS ?? "").split(",").map((x) => hostNameOf(x)).filter(Boolean); + return listed.includes(h); +} + +const notHere = (h) => `refused: a request to ${hostNameOf(h)} -- umtool answers as localhost, or a name in UMTOOL_ALLOWED_HOSTS`; + /** - * The sentence to refuse with, or null for a same-origin (or non-browser) request. + * The sentence to refuse with, or null for a same-origin (or non-browser) request to a host that is + * this machine (or listed). * @param {{ get(name: string): string | null }} headers + * @param {Record<string, string | undefined>} [env] */ -export function crossSiteRefusal(headers) { +export function crossSiteRefusal(headers, env = process.env) { + for (const k of ["host", "x-forwarded-host"]) { + for (const h of String(headers.get(k) ?? "").split(",").map((x) => x.trim()).filter(Boolean)) { + if (!hostAllowed(h, env)) return notHere(h); + } + } const site = (headers.get("sec-fetch-site") ?? "").trim().toLowerCase(); if (site && site !== "same-origin" && site !== "none") return `refused: a ${site} request may not write here`; const origin = (headers.get("origin") ?? "").trim(); @@ -23,5 +56,6 @@ export function crossSiteRefusal(headers) { } catch { return "refused: the request's origin does not parse"; } - return host && from !== host ? `refused: a request from ${from} may not write to ${host}` : null; + if (host && from !== host) return `refused: a request from ${from} may not write to ${host}`; + return hostAllowed(from, env) ? null : notHere(from); } diff --git a/umtool/lib/report/sameOrigin.test.mjs b/umtool/lib/report/sameOrigin.test.mjs @@ -13,5 +13,17 @@ test("crossSiteRefusal: same-origin and non-browser requests pass; another site, assert.match(String(crossSiteRefusal(h({ "sec-fetch-site": "same-site", origin: "http://localhost:3001", host: "localhost:3050" }))), /same-site/); assert.match(String(crossSiteRefusal(h({ origin: "https://evil.example", host: "localhost:3050" }))), /evil\.example/); assert.match(String(crossSiteRefusal(h({ origin: "null", host: "localhost:3050" }))), /opaque/); - assert.equal(crossSiteRefusal(h({ origin: "https://umtool.lan", host: "127.0.0.1:3050", "x-forwarded-host": "umtool.lan" })), null, "behind the proxy"); + assert.equal(crossSiteRefusal(h({ origin: "https://umtool.lan", host: "127.0.0.1:3050", "x-forwarded-host": "umtool.lan" }), { UMTOOL_ALLOWED_HOSTS: "umtool.lan" }), null, "behind the proxy, its name listed"); +}); + +test("crossSiteRefusal: DNS rebinding -- a host that is not this machine, or listed, is refused, Origin or not", () => { + const env = {}; + assert.match(String(crossSiteRefusal(h({ host: "evil.example:3050", origin: "http://evil.example:3050", "sec-fetch-site": "same-origin" }), env)), /evil\.example/); + assert.match(String(crossSiteRefusal(h({ host: "evil.example:3050" }), env)), /evil\.example/, "no Origin: the Host alone"); + assert.match(String(crossSiteRefusal(h({ host: "localhost:3050", "x-forwarded-host": "evil.example:3050", origin: "http://evil.example:3050" }), env)), /evil\.example/, "a forwarded host is checked too"); + assert.match(String(crossSiteRefusal(h({ origin: "https://umtool.lan", host: "127.0.0.1:3050", "x-forwarded-host": "umtool.lan" }), env)), /umtool\.lan/, "a proxy's name, unlisted"); + for (const host of ["localhost:3050", "127.0.0.1:3050", "[::1]:3050", "umtool.localhost:3050"]) { + assert.equal(crossSiteRefusal(h({ host, origin: `http://${host}`, "sec-fetch-site": "same-origin" }), env), null, host); + } + assert.equal(crossSiteRefusal(h({ host: "box.lan:3050", origin: "http://box.lan:3050" }), { UMTOOL_ALLOWED_HOSTS: "other, BOX.lan" }), null, "listed, any case, ports aside"); }); diff --git a/umtool/lib/report/timelineCli.mjs b/umtool/lib/report/timelineCli.mjs @@ -238,11 +238,13 @@ async function handPostItem(project, manifest, raw, { id = null } = {}) { async function jsonArg(raw, what) { if (raw === undefined || raw === "") throw new CliError(`${what} needs a JSON value (or @file)`); - const text = raw.startsWith("@") ? await readFile(path.resolve(raw.slice(1)), "utf8") : raw; + const fromFile = raw.startsWith("@"); + const text = fromFile ? await readFile(path.resolve(raw.slice(1)), "utf8") : raw; try { return JSON.parse(text); } catch (e) { - throw new CliError(`${what}: not JSON (${e instanceof Error ? e.message : e})`); + // A file's words are never quoted back (JSON.parse's message carries its head): its name only. + throw new CliError(fromFile ? `${what}: ${path.basename(raw.slice(1))} is not JSON` : `${what}: not JSON (${e instanceof Error ? e.message : e})`); } } @@ -776,20 +778,31 @@ export async function timelineCommand(args, { root = REPORTS_ROOT, out = (s) => case "order": { if (!rest.length) throw new CliError("order needs the ids in their new order, or a file of them (@file)"); let text = rest.join(" "); + let fromFile = null; if (rest.length === 1) { const f = rest[0].startsWith("@") ? rest[0].slice(1) : rest[0]; const file = path.resolve(f); const read = await readFile(file, "utf8").catch(() => null); - if (read !== null) text = read; + if (read !== null) { + text = read; + fromFile = path.basename(file); + } else if (rest[0].startsWith("@")) throw new CliError(`cannot read ${file}`); } let ids; try { ids = parseOrderText(text); } catch (e) { - throw new CliError(`order: ${e instanceof Error ? e.message : e}`); + // A file's words are never quoted back: its name only. + throw new CliError(fromFile ? `order: ${fromFile} is not an order (ids, a JSON list, {order} or a claim-groups file)` : `order: ${e instanceof Error ? e.message : e}`); + } + try { + ({ result, editNotes } = await write((token) => orderEntries(project.dir, ids, { token }))); + } catch (e) { + // From a file, what it held is not echoed (it could be any file): its name and its count. + if (!fromFile) throw e; + throw new CliError(`order: ${fromFile} (${ids.length} id${ids.length === 1 ? "" : "s"}) is not an order of this cut's entries`); } - ({ result, editNotes } = await write((token) => orderEntries(project.dir, ids, { token }))); break; } case "groups": { diff --git a/umtool/lib/report/timelineCli.test.mjs b/umtool/lib/report/timelineCli.test.mjs @@ -213,3 +213,17 @@ test("teaser, post and post-remove (JSON or @file); a generated manifest gets it const notes = JSON.parse(await readFile(path.join(dir, "notes.json"), "utf8")); assert.ok(notes.notes.length > 0); }); + +test("a file read with @ that is not JSON (or an order file that is not an order) is named, never quoted (L8a review)", async () => { + await project("leak"); + const secret = path.join(ROOT, "secret.txt"); + await writeFile(secret, "root:x:0:0:THE-SECRET-HEAD\n"); + for (const args of [["leak", "post", `@${secret}`], ["leak", "teaser", "t1", `@${secret}`], ["leak", "insert", "--after", "-", `post-json:@${secret}`], ["leak", "order", `@${secret}`], ["leak", "order", secret]]) { + const { lines, run } = runner(); + const code = await run(...args); + assert.notEqual(code, 0, args.join(" ")); + const said = lines.join("\n"); + assert.ok(!said.includes("THE-SECRET") && !said.includes("root:x"), `${args.join(" ")} quoted the file: ${said}`); + assert.match(said, /secret\.txt/, args.join(" ")); + } +});