Archilyzer · Source

archilyzer

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

commit 0dee7b7dca3540f99fe12b8f4d94883e021e50c9
parent 408664737b03e4abf81e8545f3b69a95598e39c0
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Mon,  9 Nov 2026 19:29:31 -0500

umtool: `umtool ingredient <ch>/<id> [--window a-b] [--used-in] [--json]` -- the rail's CLI twin (lane L5)

The nine stages as ✓ / a count / ! / — and their lines, then every project clip that cuts from the
recording (draft and saved versions). Either Rumble id finds it and both are printed. A take rendered
before render.json existed counts by its preview (listTakes); links never checked say so.

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

Diffstat:
Mumtool/bin/umtool.mjs | 5+++++
Aumtool/lib/ingredients/cli.mjs | 78++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mumtool/lib/ingredients/stages.mjs | 13+++++++++++--
3 files changed, 94 insertions(+), 2 deletions(-)

diff --git a/umtool/bin/umtool.mjs b/umtool/bin/umtool.mjs @@ -139,6 +139,7 @@ // repeats <project> [--match id|file|audio] · combo <project> [<item>] k=v|off the combo counter // attach <project> [<item>…|--all] a capture's media onto post items that carry none // umtool candidates <project> [ls | import <sweep.md> | add <json>] proposed clips for the Cut tab's Candidates panel +// umtool ingredient <channel>/<video> [--window <from>-<to>] [--used-in] [--json] a recording's life cycle, nine stages (/ingredients) import process from "node:process"; import { PROJECT_KINDS, @@ -1138,6 +1139,8 @@ function usage() { " 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)`, "", @@ -1252,6 +1255,8 @@ const COMMANDS = { posts: async () => process.exit(await (await import("../lib/report/postsCli.mjs")).postsCommand(argv.slice(argv.indexOf("posts") + 1))), // The candidates inbox (UI notes item 14): proposals only -- lib/report/candidatesCli.mjs. candidates: async () => process.exit(await (await import("../lib/report/candidatesCli.mjs")).candidatesCommand(argv.slice(argv.indexOf("candidates") + 1))), + // One recording's life cycle (lane L5, the ingredient rail): lib/ingredients/cli.mjs. + ingredient: async () => process.exit(await (await import("../lib/ingredients/cli.mjs")).ingredientCommand(argv.slice(argv.indexOf("ingredient") + 1))), inbox: cmdInbox, schedule: () => tsxScript("schedule"), refresh: () => tsxScript("refresh"), diff --git a/umtool/lib/ingredients/cli.mjs b/umtool/lib/ingredients/cli.mjs @@ -0,0 +1,78 @@ +// `umtool ingredient <ch>/<id> [--window a-b] [--used-in] [--json]` (lane L5): one recording's life cycle -- +// the CLI twin of /ingredients/<ch>/<id> (lib/ingredients/stages.mjs reads it; the page renders the same object). +// Either Rumble id finds the recording, and both are printed. Read-only over the corpus; the usage index it +// brings up to date lives in umtool's state dir (<REPORTS_ROOT>/.umtool/usage-index.json). +// +// Plain ESM: the CLI runs it under bare node. +import { CHANNELS_DIR, REPORTS_ROOT } from "../paths.mjs"; +import { parseWindowParam, pillGlyph, readIngredient, spanText } from "./stages.mjs"; + +export const INGREDIENT_USAGE = [ + "usage: umtool ingredient <channel>/<video> [--window <from>-<to>] [--used-in] [--json]", + " a recording's life cycle, nine stages: found, downloaded, transcribed, clock, windows, used in, checked,", + " rendered, published -- each ✓, a count, ! or —, and its line. A Rumble recording answers to its folder", + " slug or its embed id. --window: one clip window (its <from>-<to> name); the stages after it narrow to", + " the clips it plays. --used-in: every project clip that cuts from it (draft and saved versions), alone.", + " --json: the page's object. The page: /ingredients/<channel>/<video>.", +].join("\n"); + +class CliError extends Error {} + +/** + * @param {string[]} args the words after `ingredient` + * @param {{ reportsRoot?: string, channelsDir?: string, out?: (s: string) => void, err?: (s: string) => void }} [o] + * @returns {Promise<number>} + */ +export async function ingredientCommand(args, { reportsRoot = REPORTS_ROOT, channelsDir = CHANNELS_DIR, out = (s) => console.log(s), err = (s) => console.error(s) } = {}) { + try { + const words = []; + const flags = new Map(); + for (let i = 0; i < args.length; i += 1) { + const a = args[i]; + if (a === "--window") { + if (i + 1 >= args.length) throw new CliError("--window needs <from>-<to>"); + flags.set(a, args[++i]); + } else if (a === "--json" || a === "--used-in" || a === "--help") flags.set(a, true); + else if (a.startsWith("--")) throw new CliError(`unknown flag ${a}`); + else words.push(a); + } + if (flags.has("--help") || words.length !== 1) { + (flags.has("--help") ? out : err)(INGREDIENT_USAGE); + return flags.has("--help") ? 0 : 2; + } + const m = /^([^/]+)\/([^/@]+)$/.exec(words[0]); + if (!m) throw new CliError(`"${words[0]}" is not <channel>/<video>`); + const win = flags.has("--window") ? parseWindowParam(flags.get("--window")) : null; + if (flags.has("--window") && !win) throw new CliError(`--window "${flags.get("--window")}" is not <from>-<to>`); + const r = await readIngredient({ channelsDir, reportsRoot, ch: m[1], id: m[2], window: win }); + const used = r.stages.find((s) => s.key === "used"); + if (flags.has("--used-in")) { + if (flags.has("--json")) out(JSON.stringify(used.rows, null, 2)); + else if (!used.rows.length) out(used.line); + else for (const u of used.rows) out(useLine(u)); + return 0; + } + if (flags.has("--json")) { + out(JSON.stringify(r, null, 2)); + return 0; + } + out(`${r.ch}/${r.dirId}${r.siteId ? ` (the archive's id: ${r.siteId})` : ""}${r.platform ? ` · ${r.platform}` : ""}${r.title ? ` · ${r.title}` : ""}`); + if (r.focus) out(`window ${r.focus.name}${r.focus.found ? "" : " (no such window on disk)"}`); + for (const n of r.notes) out(`note: ${n}`); + for (const s of r.stages) out(`${pillGlyph(s.pill).padStart(3)} ${s.label.padEnd(12)} ${s.line}`); + if (used.rows.length) { + out(""); + for (const u of used.rows) out(useLine(u)); + } + return 0; + } catch (e) { + err(e instanceof Error ? e.message : String(e)); + return e instanceof CliError ? 2 : 1; + } +} + +const useLine = (u) => { + const play = u.cutStart != null || u.cutEnd != null ? ` (cut ${spanText(u.cutStart ?? u.start, u.cutEnd ?? u.end)})` : ""; + const where = [u.inDraft ? "draft" : null, ...u.versions.map((v) => v.id)].filter(Boolean).join(", "); + return ` ${u.project} ${u.clipId} ${spanText(u.start, u.end)}${play} [${where}]`; +}; diff --git a/umtool/lib/ingredients/stages.mjs b/umtool/lib/ingredients/stages.mjs @@ -31,6 +31,7 @@ import { archiveMomentUrl } from "umtool-report-to-video/site-links"; import { readLog } from "../research/log.mjs"; import { readQuoteCheck, rowIsCurrent } from "../report/quoteCheck.mjs"; import { readRenderRecord } from "../report/renderRecord.mjs"; +import { listTakes } from "../report/takes.mjs"; import { readLinkCheck } from "../report/linkCheck.mjs"; import { lastEndOf, readJsonHead } from "./heads.mjs"; import { loadUsageIndex, overlaps, playedOf, rowsInWindow, usesOf } from "./usedIn.mjs"; @@ -449,12 +450,18 @@ async function checkedStage({ rows, dirOf }) { async function renderedStage({ rows, dirOf }) { const out = []; + const takesOf = new Map(); for (const r of rows) { const dir = dirOf(r.project); + // A take rendered before render.json existed is known by its preview (listTakes: the file and its size). + if (!takesOf.has(r.project)) takesOf.set(r.project, new Map(((await listTakes(dir).catch(() => null))?.takes ?? []).map((t) => [t.id, t]))); for (const v of r.versions) { const rec = await readRenderRecord(path.join(dir, "takes", v.id)).catch(() => null); + const take = takesOf.get(r.project).get(v.id) ?? null; + const state = rec?.state ?? (take?.previewSize ? "done" : null); + const seconds = fin(rec?.seconds) ? rec.seconds : fin(take?.seconds) ? take.seconds : null; const cut = await readJson(path.join(dir, "takes", v.id, "out", "segments", `${r.clipId}.cut.json`)); - out.push({ project: r.project, clipId: r.clipId, version: v.id, kind: v.kind, state: rec?.state ?? null, seconds: fin(rec?.seconds) ? rec.seconds : null, endedAt: rec?.endedAt ?? rec?.finishedAt ?? null, cut: cut && typeof cut === "object" ? { from: cut.from ?? cut.start ?? null, to: cut.to ?? cut.end ?? null } : null }); + out.push({ project: r.project, clipId: r.clipId, version: v.id, kind: v.kind, label: take?.label ?? null, state, seconds, endedAt: rec?.endedAt ?? rec?.finishedAt ?? take?.builtAt ?? null, cut: cut && typeof cut === "object" ? { from: cut.from ?? cut.start ?? null, to: cut.to ?? cut.end ?? null } : null }); } if (r.inDraft) { const cut = await readJson(path.join(dir, "out", "segments", `${r.clipId}.cut.json`)); @@ -503,7 +510,9 @@ async function publishedStage({ rows, dirOf, idn }) { pill: !out.length ? pill("none") : dead.length ? pill("warn") : ok.length === out.length ? pill("ok") : ok.length ? pill("count", ok.length) : pill("none"), line: !out.length ? "Not in any cut, so no link to it" - : dead.length + : out.every((o) => o.state === null) + ? `${out.length} link${out.length === 1 ? "" : "s"} to it, never checked` + : dead.length ? `${dead.length} dead link${dead.length === 1 ? "" : "s"}: ${dead.map((d) => d.clipId).join(", ")}` : `${ok.length} of ${out.length} link${out.length === 1 ? "" : "s"} open on the site${unverified.length ? `, ${unverified.length} unverified` : ""}${out.some((o) => o.state === null || o.state === "changed") ? ", some never checked" : ""}`, links: out,