Archilyzer · Source

archilyzer

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

commit e2c1a9c767b9e9fe27512701f1f5d5927baec926
parent e667c9a2acde25805a1bc8ff9f8840b0f24807c9
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Mon, 19 Oct 2026 00:59:35 -0400

umtool: Highlights from a recording -- the new-project form's "highlights" seed, Create's line, and Find the clips as a job (release 35 C1, slice 3b)

The form offers the seed when the recording has its speakers (seedsFor's
`reactions`), with its target (default 600 s); creating one posts
/api/report/clips {mode: "analyze"} -- one lib/jobs.ts step running
`umtool clips analyze` -- and opens the project. Create gains the line
"Highlights from a recording". create.spec.ts drives it on a synthetic
stream; the e2e app runs the test kit's fake tagger.

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

Diffstat:
Aumtool/app/api/report/clips/route.ts | 85+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mumtool/components/NewProjectMenu.tsx | 42+++++++++++++++++++++++++++++++++++++++---
Mumtool/components/create/CreateView.tsx | 16++++++++++++++++
Mumtool/e2e/create.spec.ts | 42+++++++++++++++++++++++++++++++++++++++---
Mumtool/e2e/visual-audit.spec.ts | 2+-
Mumtool/lib/hrefs.ts | 3++-
Mumtool/lib/projects/scaffold.ts | 5+++--
Mumtool/playwright.config.ts | 4++++
8 files changed, 189 insertions(+), 10 deletions(-)

diff --git a/umtool/app/api/report/clips/route.ts b/umtool/app/api/report/clips/route.ts @@ -0,0 +1,85 @@ +import { getJob, jobView, runningJob, startJob } from "@/lib/jobs"; +import { projectRef } from "@/lib/projects"; +import { kindMakesTakes } from "@/lib/projects/kinds.mjs"; +import { readReactions } from "yt-dlp-transcript-common/lib/clips/reactions.mjs"; +import { clipsSteps } from "@/lib/report/reactions.mjs"; + +export const dynamic = "force-dynamic"; + +// THE CLIP FINDER (release 35 C1) -- "Find the clips" (the laugh scan and the +// voices on the recording's sound, then a proposal pass) and "Re-propose" +// (the pass alone, after a role flip or a param change), as ONE job on the +// app's runner (lib/jobs.ts: one at a time, a log, the NDJSON events, +// Cancel). The job runs the CLI (`umtool clips analyze|propose`), so the +// button and a terminal do the same thing. Local (CED-mini and TitaNet on the +// CPU, nice'd), no network, no LLM. +// +// GET ?job=<id>[&since=&sinceEvent=] that job +// GET ?project=<id> the project's reactions.json summary, and the job running, if any +// POST { project, mode?: "analyze" | "propose", from?: "<channel>/<id>", target?: seconds, host?: speaker } +// ?cancel=<job> stop it +export async function GET(request: Request) { + const url = new URL(request.url); + const headers = { "cache-control": "no-store" }; + const id = url.searchParams.get("job"); + if (id) { + const job = getJob(id); + if (!job) return Response.json({ error: "no such job" }, { status: 404 }); + return Response.json(jobView(job, Number(url.searchParams.get("since") ?? 0), Number(url.searchParams.get("sinceEvent") ?? 0)), { headers }); + } + const project = await projectRef(String(url.searchParams.get("project") ?? "")); + if (!project) return Response.json({ error: "no such project" }, { status: 404 }); + const doc = await readReactions(project.dir); + const running = runningJob(); + const used = doc ? doc.proposals.filter((p) => p.used) : []; + return Response.json( + { + reactions: doc + ? { + source: doc.source, + params: doc.params, + speakers: doc.speakers, + laughs: doc.laughs.length, + laughSource: doc.laughSource ?? null, + proposals: doc.proposals.length, + used: used.length, + usedSeconds: Math.round(used.reduce((n, p) => n + (p.end - p.start), 0)), + proposedAt: doc.proposedAt ?? null, + rolesChangedAt: doc.rolesChangedAt ?? null, + } + : null, + running: running && running.project === project.id && running.kind.startsWith("clips-") ? jobView(running) : null, + }, + { headers }, + ); +} + +export async function POST(request: Request) { + const url = new URL(request.url); + const cancel = url.searchParams.get("cancel"); + if (cancel) { + const { cancelJob } = await import("@/lib/jobs"); + return Response.json({ cancelled: cancelJob(cancel) }); + } + const body = (await request.json().catch(() => null)) as Record<string, unknown> | null; + if (!body || typeof body !== "object") return Response.json({ error: "bad json" }, { status: 400 }); + const project = await projectRef(String(body.project ?? "")); + if (!project) return Response.json({ error: "no such project" }, { status: 404 }); + if (!kindMakesTakes(project.kind)) return Response.json({ error: "clips are found for a report video" }, { status: 400 }); + const running = runningJob(); + if (running) { + return Response.json({ error: `a job is already running (${running.kind})`, running: jobView(running) }, { status: 409 }); + } + const plan = clipsSteps(project, { + mode: body.mode === "propose" ? "propose" : "analyze", + ...(typeof body.from === "string" ? { from: body.from } : {}), + ...(typeof body.target === "number" ? { target: body.target } : {}), + ...(typeof body.host === "number" ? { host: body.host } : {}), + }); + try { + const job = startJob(plan.kind, plan.steps, { project: project.id }); + return Response.json({ ok: true, job: jobView(job) }, { headers: { "cache-control": "no-store" } }); + } catch (e) { + return Response.json({ error: e instanceof Error ? e.message : String(e) }, { status: 409 }); + } +} diff --git a/umtool/components/NewProjectMenu.tsx b/umtool/components/NewProjectMenu.tsx @@ -33,6 +33,10 @@ import { useHydrated } from "@/components/ui/use-hydrated"; // Release 33: with no source, [data-new-seed] offers "a phrase across channels" // ([data-new-phrase], [data-new-channels], [data-new-prefer], [data-new-exclude]). // Release 35: [data-new-max] caps the reel at N instances spread across the years. +// Release 35 C1: [data-new-seed] offers "highlights" (the clip finder, when the +// recording has its speakers: diarization.json), its target in [data-new-target] +// (seconds, default 600); creating one starts "Find the clips" (the laugh scan +// and the voices, then proposals) as a job, and opens the project. type Brand = { id: string; label: string }; type Kind = { id: string; label: string; scaffold?: { fields: string[]; brands?: Brand[] } | null }; @@ -43,6 +47,7 @@ const FIELD_HINT: Record<string, string> = { siteOrigin: "the archive every QR resolves to (e.g. https://jeralyzer.pages.dev)", seed: "seed the timeline from the video's digest chapters, or from its frame scan's events (review each)", target: "the frame-scan cut's length budget: the events ranked into this many seconds (10 to 3600)", + highlights: "the highlights' length: the proposed clips ranked into this many seconds (10 to 7200)", phrase: "a regular expression, any case — e.g. slow[ ,]+news (day|week)", channels: "the channel slugs to scan, separated by commas", prefer: "the channel to cut from where it holds a copy of the same stream (optional)", @@ -63,6 +68,7 @@ export default function NewProjectMenu({ reports, submitLabel = "Create", onCancel, + seed: initialSeed = "", }: { kinds: Kind[]; /** One kind, fixed: no kind select (Create's lines). */ @@ -78,6 +84,8 @@ export default function NewProjectMenu({ reports?: Report[]; submitLabel?: string; onCancel?: () => void; + /** The seed chosen to start with (Create's "Highlights from a recording": reactions). */ + seed?: "" | "chapters" | "frames" | "reactions"; }) { const router = useRouter(); const hydrated = useHydrated(); @@ -89,15 +97,16 @@ export default function NewProjectMenu({ const [src, setSrc] = useState(from ?? reports?.[0]?.path ?? ""); const [byHand, setByHand] = useState(!reports?.length); const [origin, setOrigin] = useState(""); - const [seed, setSeed] = useState<"" | "chapters" | "frames" | "phrase">(""); + const [seed, setSeed] = useState<"" | "chapters" | "frames" | "phrase" | "reactions">(initialSeed); const [phrase, setPhrase] = useState(""); const [channels, setChannels] = useState(""); const [prefer, setPrefer] = useState(""); const [exclude, setExclude] = useState(""); const [max, setMax] = useState(""); const [target, setTarget] = useState("240"); + const [hlTarget, setHlTarget] = useState("600"); // What the video can be seeded from (null: not asked yet, or not a video). - const [seeds, setSeeds] = useState<{ chapters: boolean; frames: boolean } | null>(null); + const [seeds, setSeeds] = useState<{ chapters: boolean; frames: boolean; reactions: boolean } | null>(null); const [brand, setBrand] = useState(""); const [busy, setBusy] = useState(false); const [error, setError] = useState<string | null>(null); @@ -118,7 +127,7 @@ export default function NewProjectMenu({ .then((r) => (r.ok ? r.json() : null)) .then((j) => { if (gone || !j?.video) return; - setSeeds({ chapters: !!j.chapters, frames: !!j.frames }); + setSeeds({ chapters: !!j.chapters, frames: !!j.frames, reactions: !!j.reactions }); setSeed((v) => (v && !j[v] ? "" : v)); }) .catch(() => {}); @@ -143,6 +152,7 @@ export default function NewProjectMenu({ } else if (fields.includes("seed") && seed && seed !== "phrase" && looksLikeVideo) { body.seed = seed; if (seed === "frames") body.target = Number(target); + if (seed === "reactions") body.target = Number(hlTarget); } if (fields.includes("brand") && brand) body.brand = brand; const res = await fetch("/api/projects/new", { @@ -153,6 +163,16 @@ export default function NewProjectMenu({ }); const j = await res.json(); if (!res.ok) throw new Error(j.error || `HTTP ${res.status}`); + // The clip finder's scans run as a job (minutes on a long stream); the + // project opens on its first proposals, from the transcript alone. + if (body.seed === "reactions" && j.id) { + await fetch("/api/report/clips", { + method: "POST", + headers: { "content-type": "application/json" }, + body: JSON.stringify({ project: j.id, mode: "analyze" }), + cache: "no-store", + }).catch(() => null); + } router.push(j.href); router.refresh(); } catch (e) { @@ -291,6 +311,9 @@ export default function NewProjectMenu({ <option value="frames" disabled={seeds !== null && !seeds.frames}> the frame scan&apos;s events{seeds !== null && !seeds.frames ? " (no scan)" : ""} </option> + <option value="reactions" disabled={seeds !== null && !seeds.reactions}> + highlights: the host&apos;s laughs and comments{seeds !== null && !seeds.reactions ? " (no speakers yet)" : ""} + </option> </Select> </Field> )} @@ -334,6 +357,19 @@ export default function NewProjectMenu({ /> </Field> )} + {asksSeed && seed === "reactions" && ( + <Field label="Target s"> + <Input + value={hlTarget} + onChange={(e) => setHlTarget(e.target.value)} + inputMode="numeric" + aria-label={`target seconds — ${FIELD_HINT.highlights}`} + title={FIELD_HINT.highlights} + data-new-target + className="num w-20" + /> + </Field> + )} <div className="flex items-center gap-2 pb-px"> <Button type="submit" variant="go" disabled={!hydrated || busy || !slug.trim()} data-new-create> {busy ? "Creating…" : submitLabel} diff --git a/umtool/components/create/CreateView.tsx b/umtool/components/create/CreateView.tsx @@ -55,6 +55,7 @@ function lines(d: CreateData): { group: string; lines: Line[] }[][] { { make: "video-article", title: "From an article", sub: "Chains a cut from the current report", action: "Choose article" }, { make: "video-board", title: "From a board", sub: "A timeline scaffolded from the pinned cites", action: "Choose board" }, { make: "video-recording", title: "From a recording", sub: "A video URL, or <channel>/<id> from the archive", action: "Choose recording" }, + { make: "video-highlights", title: "Highlights from a recording", sub: "A long stream cut to its laughs and comments · needs its speakers", action: "Choose recording" }, { make: "video-report", title: "From a sweep report", @@ -160,6 +161,21 @@ export default function CreateView({ onCancel={cancel} /> ) : null; + case "video-highlights": + return data.kinds.recording ? ( + <NewProjectMenu + kinds={[data.kinds.recording]} + kind={data.kinds.recording.id} + inline + from={from} + seed="reactions" + fromLabel="Recording" + fromHint="<channel>/<videoId> of a recording with its speakers (diarization.json)" + fromPlaceholder="channel/videoId" + submitLabel="Find the clips" + onCancel={cancel} + /> + ) : null; case "video-report": return data.kinds.report ? ( <NewProjectMenu diff --git a/umtool/e2e/create.spec.ts b/umtool/e2e/create.spec.ts @@ -3,6 +3,7 @@ import { existsSync, readFileSync, rmSync } from "node:fs"; import path from "node:path"; import { fileURLToPath } from "node:url"; import { BOARD_CASE } from "./fixtures/research-fixture.mjs"; +import { writeReactionCorpus } from "yt-dlp-transcript-common/testing/clips/reactionStream.mjs"; import * as urls from "./urls"; import { WARM_TIMEOUT, warm } from "./warm"; @@ -19,12 +20,14 @@ import { WARM_TIMEOUT, warm } from "./warm"; // video-board R2's hand-off: the plan, then the project // video-article the chain's steps, then the chain as a umtool job // video-recording /?from= (the editor's hand-off) prefilled → a project +// video-highlights the clip finder's seed on a synthetic stream → a project +// with proposed clips, then "Find the clips" as a job // video-report the sweep reports on disk → a project // song a song // // WRITES (each removed after): .umtool/research/p5-*, articles/p5-board, // p5-board/, p5-rec/, p5-rep/, reports/videos/p5-song/; a chain job on -// zeta i1, cancelled +// zeta i1, cancelled; channels/synth-reacts (a synthetic stream) and p35-hl/ // --------------------------------------------------------------------------- const HERE = path.dirname(fileURLToPath(import.meta.url)); @@ -43,6 +46,8 @@ const WRITTEN = [ "p5-rec", "p5-rep", "reports/videos/p5-song", + "channels/synth-reacts", + "p35-hl", ]; const clean = () => { for (const p of WRITTEN) rmSync(path.join(FIXTURE, p), { recursive: true, force: true }); @@ -62,8 +67,8 @@ test("the lines, grouped Research · Article · Video · Song; the policy chip l await page.goto(urls.createHref()); await expect(page.getByRole("navigation", { name: "Breadcrumb" }).locator("h1")).toHaveText("What are you making?"); await expect(page.locator("[data-make-group]")).toHaveText([/^Research/, /^Article/, /^Video/, /^Song/]); - // Nine: R5 added "A recurring report" under Article. - await expect(page.locator("[data-make-line]")).toHaveCount(9); + // Ten: R5 added "A recurring report" under Article; release 35 "Highlights from a recording" under Video. + await expect(page.locator("[data-make-line]")).toHaveCount(10); // The boards and the reports on disk are counted on their lines. await expect(line(page, "article-board")).toContainText(/ · \d+ quotes?/); await expect(line(page, "video-report")).toContainText(/ · \d+ found/); @@ -221,6 +226,37 @@ test("Video from a recording: the editor's /?from= lands here prefilled, and mak expect(manifestOf("p5-rec").provenance.channelSlug).toBe("testchan"); }); +test("Highlights from a recording: the clip finder proposes clips marked by the assistant, then finds the clips as a job", async ({ page, request }) => { + // A synthetic reaction stream with its speakers (diarization.json), no sound. + writeReactionCorpus(path.join(FIXTURE, "channels"), { channel: "synth-reacts", video: "react001" }); + await page.goto(urls.createHref({ make: "video-highlights" })); + const f = form(page, "video-highlights"); + await f.locator("[data-new-from]").fill("synth-reacts/react001"); + const seed = f.locator("[data-new-seed]"); + await expect(seed).toHaveValue("reactions"); + await expect(seed.locator("option[value=reactions]")).toBeEnabled(); + await expect(f.locator("[data-new-target]")).toHaveValue("600"); + await f.locator("[data-new-target]").fill("60"); + await f.locator("[data-new-slug]").fill("p35-hl"); + await f.getByRole("button", { name: "Find the clips" }).click(); + await page.waitForURL(/\/projects\/p35-hl$/, { timeout: 20_000 }); + const m = manifestOf("p35-hl"); + expect(m.render.transition).toBe(0); + expect(m.timeline.length).toBeGreaterThan(0); + for (const c of m.timeline) { + expect(c.assist.by).toBe("assistant"); + expect(c.cutStart).toBeGreaterThanOrEqual(c.start); + } + const reactions = () => JSON.parse(readFileSync(path.join(FIXTURE, "p35-hl", "reactions.json"), "utf8")); + expect(reactions().params.target).toBe(60); + // "Find the clips" ran as umtool's job: the CLI, with no sound on disk, proposes from the transcript. + await expect.poll(async () => (await (await request.get("/api/jobs")).json()).running, { timeout: 60_000 }).toBeNull(); + const summary = (await (await request.get("/api/report/clips?project=p35-hl")).json()).reactions; + expect(summary.speakers.map((s: { role: string }) => s.role)).toEqual(["host", "subject"]); + expect(summary.used).toBeGreaterThan(0); + expect(summary.laughSource).toBe("text"); +}); + test("Video from a sweep report: the reports on disk are offered, and one becomes a project", async ({ page }) => { await page.goto(urls.createHref({ make: "video-report" })); const f = form(page, "video-report"); diff --git a/umtool/e2e/visual-audit.spec.ts b/umtool/e2e/visual-audit.spec.ts @@ -55,7 +55,7 @@ const PAGES: [string, string][] = [ ["bench-review", urls.reviewHref("reports/media-review-fixture", { view: "list" })], ["bench-clips", urls.clipDeckHref("reports/clip-deck-fixture", { show: "all" })], ["create", urls.createHref()], - ...(["research", "article", "article-board", "recurring", "video-article", "video-board", "video-recording", "video-report", "song"] as const).map( + ...(["research", "article", "article-board", "recurring", "video-article", "video-board", "video-recording", "video-highlights", "video-report", "song"] as const).map( (make) => [`create-${make}`, urls.createHref({ make })] as [string, string], ), ["tools", urls.toolsHref()], diff --git a/umtool/lib/hrefs.ts b/umtool/lib/hrefs.ts @@ -155,10 +155,11 @@ export function articlesHref(q: ArticlesQuery = {}): string { * video-article a video from an article: the chain over an iteration * video-board a video from a board (R2's hand-off) * video-recording a video from a recording (`from` = <channel>/<id> or a share URL) + * video-highlights highlights from a long recording: the clip finder's seed (release 35) * video-report a video from a sweep report on disk * song a song */ -export const MAKES = ["research", "article", "article-board", "recurring", "video-article", "video-board", "video-recording", "video-report", "song"] as const; +export const MAKES = ["research", "article", "article-board", "recurring", "video-article", "video-board", "video-recording", "video-highlights", "video-report", "song"] as const; export type Make = (typeof MAKES)[number]; export const isMake = (v: unknown): v is Make => typeof v === "string" && (MAKES as readonly string[]).includes(v); diff --git a/umtool/lib/projects/scaffold.ts b/umtool/lib/projects/scaffold.ts @@ -15,7 +15,8 @@ export type NewProjectBody = { from?: string | null; siteOrigin?: string | null; seed?: string | null; - // The frames seed's length budget, seconds (release 32: the form's "target"). + // The frames seed's length budget, seconds (release 32: the form's "target"); + // release 35: the reactions seed's (the clip finder's target, default 600). target?: number | string | null; brand?: string | null; // The phrase seed (release 33): a regular expression, the channels to scan @@ -82,7 +83,7 @@ export async function scaffoldProject(body: NewProjectBody): Promise<{ href: str ...(body.max !== undefined && body.max !== null && body.max !== "" ? { max: Number(body.max) } : {}), } : {}), - ...(body.seed === "frames" && body.target !== undefined && body.target !== null && body.target !== "" ? { target: Number(body.target) } : {}), + ...((body.seed === "frames" || body.seed === "reactions") && body.target !== undefined && body.target !== null && body.target !== "" ? { target: Number(body.target) } : {}), }); result = { ...r, href: `/projects/${r.id}` }; } catch (e) { diff --git a/umtool/playwright.config.ts b/umtool/playwright.config.ts @@ -181,6 +181,10 @@ export default defineConfig({ // TitaNet venv -- the same command line and JSON, no python, no model. `VOICE_MATCH_PYTHON=${process.execPath} ` + `VOICE_MATCH_SCRIPT=${path.join(path.dirname(fileURLToPath(import.meta.url)), "..", "common", "testing", "audio", "fakeSpeakerEmbed.mjs")} VOICE_MATCH_MODEL=fake.onnx ` + + // The clip finder's laugh scan (release 35): the test kit's fake tagger, the same way. + `AUDIO_TAG_PYTHON=${process.execPath} ` + + `AUDIO_TAG_SCRIPT=${path.join(path.dirname(fileURLToPath(import.meta.url)), "..", "common", "testing", "audio", "fakeAudioTag.mjs")} ` + + `AUDIO_TAG_MODEL=${path.join(path.dirname(fileURLToPath(import.meta.url)), "..", "common", "testing", "audio", "fakeAudioTag.mjs")} ` + APP_SERVER, port: PORT, reuseExistingServer: false,