// `umtool walk [--take ] [--all] [--json]`: the walk from a // terminal -- every clip in walk order with its verdict, whether it is fetched, // and which ones the walk visits -- read by walkData.mjs, the reading the bench // page and GET /api/report/walk make. The edits are `umtool window

// [--take ] --verdict …` and `umtool timeline

[--take ] move|remove|undo`. // // Plain ESM: the CLI runs under bare node. import { REPORTS_ROOT, resolveProject } from "../projects/core.mjs"; import { hms } from "umtool-report-to-video/attribution"; import { walkJson, walkOf } from "./walkData.mjs"; export const WALK_USAGE = [ "usage: umtool walk [--take ] [--all] [--json]", "", "The clip bench's walk: every clip in walk order (by source), its window, its verdict, whether a", "fetched file holds it, and (→) the ones the walk visits -- the fetched clips still needing a verdict;", "--all: every fetched clip. --take walks a take: the project's manifest with the take's patch applied", "(a draft too); its edits go to the take (`umtool window

--take …`,", "`umtool timeline

--take move|remove|undo`), never the project's manifest.", ].join("\n"); class CliError extends Error {} /** * @param {string[]} args the words after `walk` * @param {{ root?: string, out?: (s: string) => void, err?: (s: string) => void }} [opts] * @returns {Promise} */ export async function walkCommand(args, { root = REPORTS_ROOT, 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 === "--take") { if (i + 1 >= args.length) throw new CliError("--take needs a take id"); flags.set(a, args[++i]); } else if (a.startsWith("--")) flags.set(a, true); else words.push(a); } if (!words[0] || flags.has("--help")) { (flags.has("--help") ? out : err)(WALK_USAGE); return flags.has("--help") ? 0 : 2; } const r = await resolveProject(words[0], root); if (r.ambiguous) throw new CliError(`"${words[0]}" is the name of ${r.ambiguous.length} projects — pass its id`); if (!r.project) throw new CliError(`no project matches "${words[0]}"`); const project = r.project; const take = flags.has("--take") ? String(flags.get("--take")) : null; const w = await walkOf(project, { take, all: flags.has("--all") }); if (flags.has("--json")) { out(JSON.stringify(walkJson(w), null, 2)); return 0; } const what = w.take ? `take ${w.take.id} "${w.take.label}"${w.take.draft ? " (draft)" : w.take.made ? "" : " (in a recipe, not made — read only)"}` : "the cut"; out(`${project.id} · ${what} · ${w.total} clip(s) · ${hms(w.seconds)} · ${w.reviewed} reviewed · ${w.needing} need a verdict, ${w.ready} of them fetched`); if (w.note) out(` ${w.note}`); const idW = Math.max(2, ...w.clips.map((c) => c.id.length)); // The intro first: watched, not judged (Play the cut, or the Cut tab's intro editor). if (w.intro) { const words = [w.intro.title, ...w.intro.lines].filter(Boolean).map((x) => `"${x}"`).join(" / "); out(` 0 ${w.intro.id.padEnd(idW)} intro · ${w.intro.style} · ${w.intro.seconds}s${words ? ` · ${words}` : ""} (watch it in Play; umtool intro ${project.id})`); } for (const c of w.clips) { const win = `${hms(c.start)}–${hms(c.end)}`; const cut = c.cutStart != null ? ` cut ${hms(c.cutStart)}–${hms(c.cutEnd)}` : ""; out( `${c.onWalk ? "→" : " "} ${String(c.cut ?? "").padStart(3)} ${c.id.padEnd(idW)} ${win.padEnd(22)}${cut} ${c.seconds.toFixed(1).padStart(6)}s ` + `${c.verdict.padEnd(10)} ${c.fetched ? "fetched" : "NOT FETCHED"}` + // A rejection says why: "(wrong speaker)", "(irrelevant: covered in c07)"; a fact one's note is its correction. (c.rejected ? ` (${c.rejected.label}${!c.rejected.fact && c.rejected.note ? `: ${c.rejected.note}` : ""})` : "") + (c.correction ? ` note: ${c.correction}` : ""), ); } const enc = project.id.split("/").map(encodeURIComponent).join("/"); const base = w.take ? `/projects/${enc}/takes/${encodeURIComponent(w.take.id)}/walk` : `/projects/${enc}/clip/${encodeURIComponent(w.first ?? "")}`; if (w.first) out(`\nthe walk starts at ${w.first}: ${w.take ? `${base}${w.all ? "?all=1" : ""}` : base}`); else out(`\nnothing on the walk${w.all ? "" : " (every fetched clip has a verdict; --all walks them all)"}`); return 0; } catch (e) { err(`umtool walk: ${e instanceof Error ? e.message : String(e)}`); return e instanceof CliError ? 2 : 1; } }