commit e73f98b4ba95816e997dc1d0e9f2240ee2732ed6
parent 57c00a683ab1b4b65bf6a40a0c93beb78762bf0f
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Mon, 9 Nov 2026 15:34:20 -0500
umtool: links --fix takes one undo point before it rewrites
revisions/<stamp>-auto-before-links-fix, printed (and `undo` in --json), so `umtool
timeline <p> undo` takes every rewrite back.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
2 files changed, 32 insertions(+), 2 deletions(-)
diff --git a/umtool/lib/report/linksCli.mjs b/umtool/lib/report/linksCli.mjs
@@ -13,7 +13,8 @@ import { REPORTS_ROOT, resolveProject } from "../projects/core.mjs";
import { readManifest } from "../projects/report.mjs";
import { kindMakesTakes } from "../projects/kinds.mjs";
import { withEditNotes } from "./edit-guard.mjs";
-import { updateClip } from "./manifest.mjs";
+import { AUTO_SNAPSHOT_PREFIX, updateClip } from "./manifest.mjs";
+import { createSnapshot } from "./snapshots.mjs";
import { runLinkCheck } from "./linkCheck.mjs";
export const LINKS_USAGE = [
@@ -79,7 +80,10 @@ export async function linksCommand(args, { root = REPORTS_ROOT, out = (s) => con
if (!m) throw new CliError(`${project.id} has no video.manifest.json`);
let doc = await runLinkCheck(project.dir, m, opts);
const fixed = [];
+ let undo = null;
if (flags.has("--fix")) {
+ // ONE undo point before the rewrites (revisions/<stamp>-auto-before-links-fix): `umtool timeline <p> undo` takes them all back.
+ if (doc.links.some((l) => l.state === "dead" && l.fix)) undo = await createSnapshot(project.dir, { label: `${AUTO_SNAPSHOT_PREFIX}links-fix` });
for (const l of doc.links) {
if (l.state !== "dead" || !l.fix) continue;
// A Rumble folder id (linkCheck.mjs siteIdOf): the clip names the embed id the archive serves (`siteVideo`),
@@ -101,9 +105,10 @@ export async function linksCommand(args, { root = REPORTS_ROOT, out = (s) => con
}
const dead = doc.links.filter((l) => l.state === "dead").length;
if (flags.has("--json")) {
- out(JSON.stringify({ ok: dead === 0, project: project.id, ...doc, ...(flags.has("--fix") ? { fixed } : {}) }, null, 2));
+ out(JSON.stringify({ ok: dead === 0, project: project.id, ...doc, ...(flags.has("--fix") ? { fixed, ...(undo ? { undo: undo.rel } : {}) } : {}) }, null, 2));
return dead ? 1 : 0;
}
+ if (undo) out(`undo point: ${undo.rel}`);
for (const f of fixed) out(`fixed ${f.clip}: ${f.from} -> ${f.to}${f.siteVideo ? ` (siteVideo ${f.siteVideo}: the Rumble embed id)` : ""}`);
out(`${project.id} ยท ${linksSummary(doc)}`);
out(`recorded in out/links.json (umtool check ${project.id} reads it)`);
diff --git a/umtool/lib/report/shareLine.test.mjs b/umtool/lib/report/shareLine.test.mjs
@@ -114,3 +114,28 @@ test("umtool timeline insert <rumble-ch>/<folder>: the clip carries the embed id
const y = JSON.parse(await readFile(path.join(yt.dir, "video.manifest.json"), "utf8"));
assert.equal(y.timeline[0].siteVideo, undefined, "a YouTube clip names nothing more");
});
+
+test("umtool links --fix: one undo point, then the Rumble clip names its embed id (siteVideo)", async () => {
+ const { linksCommand } = await import("./linksCli.mjs");
+ const p = project("links-rumble", [{ type: "clip", id: "n01", channel: "rc", video: "v7fn1ab", start: 100, end: 110, cite: 100 }], { channelSlug: "rc" });
+ const docs = {
+ "https://jeralyzer.example/corpus.json": { channels: [{ slug: "rc", manifests: { transcripts: "https://jeralyzer.example/data/rc/manifest.json" } }] },
+ "https://jeralyzer.example/data/rc/manifest.json": { slugToPage: { v7fn1aa: 0 } },
+ "https://jeralyzer.example/data/rc/page-0000.json": [{ id: "v7fn1aa" }],
+ };
+ const fetchImpl = async (url) => {
+ const doc = docs[String(url)];
+ return doc ? new Response(JSON.stringify(doc), { status: 200, headers: { "content-type": "application/json" } }) : new Response("no", { status: 404 });
+ };
+ const lines = [];
+ const code = await linksCommand([p.dir, "--fix"], { root: path.join(ROOT, "reports"), out: (s) => lines.push(s), err: () => {}, fetchImpl, cacheDir: null, gapMs: 0 });
+ const text = lines.join("\n");
+ assert.match(text, /fixed n01: .*v7fn1ab.* -> .*v7fn1aa.*siteVideo v7fn1aa/);
+ assert.match(text, /undo point: revisions\/.*-auto-before-links-fix\.manifest\.json/);
+ assert.equal(code, 0, text);
+ const m = JSON.parse(await readFile(path.join(p.dir, "video.manifest.json"), "utf8"));
+ assert.equal(m.timeline[0].siteVideo, "v7fn1aa");
+ const rel = /undo point: (\S+)/.exec(text)[1];
+ const before = JSON.parse(await readFile(path.join(p.dir, rel), "utf8"));
+ assert.equal(before.timeline[0].siteVideo, undefined, "the undo point is the cut before the fix");
+});