Archilyzer · Source

archilyzer

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

commit 1e6ec0ab2f81e07417a76bb6bfd4e2fc2025b907
parent 00ba1af2a70e1fc5fc8847a09cfc02c96081e107
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Sun,  1 Nov 2026 00:38:49 -0400

umtool: the link-dead row fixes the links it knows the fix for in one press (POST /api/report/links {fix: true})

A Twitch id the site serves as v<id>, and only a link still exactly what the last check saw, rewritten through the window writer, then checked again. The UI twin of `umtool links <p> --fix`.

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

Diffstat:
Mumtool/app/api/report/links/route.ts | 24++++++++++++++++++++----
Mumtool/components/projects/report/DecisionSettle.tsx | 5+++--
Mumtool/docs/knobs.md | 5+++--
Mumtool/lib/decisions.ts | 2+-
Mumtool/lib/projects/report.mjs | 9++++++++-
Mumtool/lib/report/cut-integrity.test.mjs | 2++
6 files changed, 37 insertions(+), 10 deletions(-)

diff --git a/umtool/app/api/report/links/route.ts b/umtool/app/api/report/links/route.ts @@ -2,6 +2,8 @@ import { projectRef } from "@/lib/projects"; import { readManifest } from "@/lib/projects/report.mjs"; import { linkVerdicts, readLinkCheck, runLinkCheck } from "@/lib/report/linkCheck.mjs"; import { refuseCaller } from "@/lib/report/caller"; +import { withEditNotes } from "@/lib/report/guard"; +import { updateClip } from "@/lib/report/manifest.mjs"; export const dynamic = "force-dynamic"; @@ -13,7 +15,9 @@ export const dynamic = "force-dynamic"; // `umtool links <project>`. // // GET ?project=<id> the recorded check (out/links.json) read against the manifest as it is now -// POST { project } check now, record it, and answer the same +// POST { project, fix? } check now, record it, and answer the same; `fix`: first +// rewrite every dead link the last check knows the fix for +// (a Twitch id the site serves as v<id>) through the window writer const headers = { "cache-control": "no-store" }; async function answer(dir: string, doc: Awaited<ReturnType<typeof readLinkCheck>>) { @@ -32,15 +36,27 @@ export async function GET(request: Request) { export async function POST(request: Request) { const refused = refuseCaller(request, "/api/report/links"); if (refused) return refused; - const b = (await request.json().catch(() => null)) as { project?: unknown } | null; + const b = (await request.json().catch(() => null)) as { project?: unknown; fix?: unknown } | null; if (!b || typeof b !== "object") return Response.json({ error: "bad json" }, { status: 400, headers }); const project = await projectRef(String(b.project ?? "")); if (!project) return Response.json({ error: "no such project" }, { status: 404, headers }); - const m = await readManifest(project.dir); + let m = await readManifest(project.dir); if (!m) return Response.json({ error: "the project has no video.manifest.json" }, { status: 400, headers }); try { + const fixed: { clip: string; from: string; to: string }[] = []; + if (b.fix === true) { + const last = await readLinkCheck(project.dir); + const now = new Map(((m.timeline ?? []) as { id: string; citeUrl?: string }[]).map((e) => [e.id, e.citeUrl])); + for (const l of last?.links ?? []) { + // Only a link still exactly what the check saw: an edit since is somebody's decision. + if (l.state !== "dead" || !l.fix || now.get(l.clip) !== l.url) continue; + await withEditNotes(project, () => updateClip(project.dir, l.clip, { citeUrl: l.fix })); + fixed.push({ clip: l.clip, from: l.url, to: l.fix }); + } + if (fixed.length) m = await readManifest(project.dir); + } const doc = await runLinkCheck(project.dir, m); - return Response.json({ ok: true, ...(await answer(project.dir, doc)) }, { headers }); + return Response.json({ ok: true, fixed, ...(await answer(project.dir, doc)) }, { headers }); } catch (e) { return Response.json({ error: e instanceof Error ? e.message : String(e) }, { status: 500, headers }); } diff --git a/umtool/components/projects/report/DecisionSettle.tsx b/umtool/components/projects/report/DecisionSettle.tsx @@ -45,11 +45,12 @@ export default function DecisionSettle({ : await fetch("/api/report/links", { method: "POST", headers: { "content-type": "application/json" }, - body: JSON.stringify({ project }), + body: JSON.stringify({ project, ...(settle.fix ? { fix: true } : {}) }), }); const j = (await r.json().catch(() => ({}))) as { error?: string; verdicts?: { ok: number; dead: unknown[]; unverified: unknown[]; archive: number }; + fixed?: { clip: string }[]; notes?: string[]; left?: { label: string | null; after: string }[]; }; @@ -59,7 +60,7 @@ export default function DecisionSettle({ } if (settle.kind === "check-links" && j.verdicts) { const v = j.verdicts; - setSaid(`${v.ok} of ${v.archive} open · ${v.dead.length} dead · ${v.unverified.length} not verified`); + setSaid(`${j.fixed?.length ? `fixed ${j.fixed.map((f) => f.clip).join(", ")} · ` : ""}${v.ok} of ${v.archive} open · ${v.dead.length} dead · ${v.unverified.length} not verified`); } else if (settle.kind === "patch-markers") { const moved = j.notes?.length ?? 0; const left = j.left ?? []; diff --git a/umtool/docs/knobs.md b/umtool/docs/knobs.md @@ -83,8 +83,9 @@ it should hold is missing. A site that does not answer leaves its links **not ve recorded in `out/links.json`; the check reads it and never fetches: `link-dead` (blocking, one row per site: *12 of 124 QR links don't open on anilyzer.pages.dev (deployed 2026-10-09): …*), `links-unverified` (info: *couldn't reach …*), `links-unchecked` (info: never checked, or a link changed since). `--fix` -rewrites the dead links it knows the fix for — a Twitch id the site serves as `v<id>` — through the -window writer. A platform link (YouTube's own page) is not an archive link and is not checked. +(the row's **Fix N links (the site's v&lt;id&gt;)**) rewrites the dead links it knows the fix for — a Twitch id +the site serves as `v<id>`, and only a link still exactly what the check saw — through the window writer, +then checks again. A platform link (YouTube's own page) is not an archive link and is not checked. ## Gaps inside a clip diff --git a/umtool/lib/decisions.ts b/umtool/lib/decisions.ts @@ -88,7 +88,7 @@ export type Decision = { */ settle?: | { kind: "patch"; clip: string; patch: Record<string, unknown>; label: string } - | { kind: "check-links"; label: string } + | { kind: "check-links"; label: string; fix?: boolean } | { kind: "patch-markers"; file: string; label: string }; /** The clips a project-wide row is about (a site's dead links). */ clips?: string[]; diff --git a/umtool/lib/projects/report.mjs b/umtool/lib/projects/report.mjs @@ -1583,7 +1583,14 @@ export async function reportDecisions(ctx, summary) { ` — ${rows[0].clip}: ${rows[0].why}` + (rows.some((r) => r.fix) ? `. Every clip with a fix: \`umtool links ${id} --fix\`` : ""), "blocking", - { fix: checkFix, settle: checkSettle, clips: ids }, + { + fix: rows.some((r) => r.fix) ? `umtool links ${id} --fix` : checkFix, + // The links whose fix is known (a Twitch id the site serves as v<id>) are rewritten in one press. + settle: rows.some((r) => r.fix) + ? { kind: "check-links", fix: true, label: `Fix ${rows.filter((r) => r.fix).length} link${rows.filter((r) => r.fix).length === 1 ? "" : "s"} (the site's v<id>)` } + : checkSettle, + clips: ids, + }, ); } for (const [origin, rows] of byOrigin(v.unverified)) { diff --git a/umtool/lib/report/cut-integrity.test.mjs b/umtool/lib/report/cut-integrity.test.mjs @@ -422,6 +422,8 @@ test("checkLinks offline: every link unverified, with couldn't reach; the rows s assert.deepEqual(rows.map((d) => [d.kind, d.severity, d.target]), [["link-dead", "blocking", "site.test"]]); assert.match(rows[0].why, /^1 of 2 QR links don't open on site\.test \(deployed 2026-10-09\): q01 — q01: "290" is not a record on site\.test; the site's record is "v290"\. Every clip with a fix: `umtool links cut --fix`$/); assert.deepEqual(rows[0].clips, ["q01"]); + assert.deepEqual(rows[0].settle, { kind: "check-links", fix: true, label: "Fix 1 link (the site's v<id>)" }); + assert.equal(rows[0].fix, "umtool links cut --fix"); // A link changed since the check is unchecked, not judged by the old answer. await updateClip(p.dir, "a", { citeUrl: url("c", "v2", 10) });