Archilyzer · Source

archilyzer

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

commit 532273d46a2b9ca3323a0bdb5947de85129f2a82
parent 51842a8d54ea6ecbaee2fde4671e9ecfdec00f13
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Fri, 16 Oct 2026 16:56:46 -0400

umtool: the new-project form seeds from the frame scan — the seed is a select (an empty timeline, the digest's chapters, the frame scan's events), each offered when the video has it (GET /api/projects/new?from=, seedsFor), and the frames seed's target seconds; what `umtool new --seed frames --target` does, in the UI

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

Diffstat:
Mumtool/app/api/projects/new/route.ts | 8++++++++
Mumtool/components/NewProjectMenu.tsx | 67++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------
Mumtool/lib/projects/scaffold.mjs | 19+++++++++++++++++++
Mumtool/lib/projects/scaffold.ts | 3+++
Mumtool/lib/scaffold-frames.test.mjs | 20+++++++++++++++++++-
5 files changed, 107 insertions(+), 10 deletions(-)

diff --git a/umtool/app/api/projects/new/route.ts b/umtool/app/api/projects/new/route.ts @@ -1,5 +1,6 @@ import { invalidateProjects } from "@/lib/projects"; import { ScaffoldError, scaffoldProject } from "@/lib/projects/scaffold"; +import { seedsFor } from "@/lib/projects/scaffold.mjs"; export const dynamic = "force-dynamic"; @@ -23,3 +24,10 @@ export async function POST(request: Request) { return Response.json({ error: e instanceof Error ? e.message : String(e) }, { status }); } } + +// GET ?from=<ref> -> { video, chapters, frames }: what the form may seed a +// video ref from (release 32 R2) -- its digest's chapters, its frame scan. +export async function GET(request: Request) { + const from = new URL(request.url).searchParams.get("from"); + return Response.json(await seedsFor({ from }), { headers: { "cache-control": "no-store" } }); +} diff --git a/umtool/components/NewProjectMenu.tsx b/umtool/components/NewProjectMenu.tsx @@ -1,6 +1,6 @@ "use client"; -import { useState } from "react"; +import { useEffect, useState } from "react"; import { useRouter } from "next/navigation"; import { Button } from "@/components/ui/button"; import { Field, Input, Select } from "@/components/ui/field"; @@ -27,6 +27,9 @@ import { useHydrated } from "@/components/ui/use-hydrated"; // [data-new-project]; the form [data-new-project-form] with [data-new-kind], // [data-new-slug], [data-new-title], [data-new-from], [data-new-origin], // [data-new-seed], [data-new-brand], [data-new-create] and [data-new-error]. +// Release 32 R2: [data-new-seed] is a select (none, the digest's chapters, the +// frame scan), each offered when the video has it (GET /api/projects/new?from=); +// the frames seed's length budget is [data-new-target], seconds. type Brand = { id: string; label: string }; type Kind = { id: string; label: string; scaffold?: { fields: string[]; brands?: Brand[] } | null }; @@ -35,7 +38,8 @@ type Report = { project: string; path: string; title: string }; const FIELD_HINT: Record<string, string> = { from: "a sweep-report .md, a viewer share URL, or <channel>/<videoId>", siteOrigin: "the archive every QR resolves to (e.g. https://jeralyzer.pages.dev)", - seed: "seed the timeline from the video's digest chapters (review each)", + 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)", brand: "a report-to-video preset: its palette and faces, the title lockup, the header mark, an end card", }; @@ -77,7 +81,10 @@ 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(false); + const [seed, setSeed] = useState<"" | "chapters" | "frames">(""); + const [target, setTarget] = useState("240"); + // 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 [brand, setBrand] = useState(""); const [busy, setBusy] = useState(false); const [error, setError] = useState<string | null>(null); @@ -87,6 +94,25 @@ export default function NewProjectMenu({ // Seeding only means something for a video ref, and the server refuses it // otherwise -- so the box is offered only when the source looks like one. const looksLikeVideo = /[?&]v=/.test(src) || /^[\w.-]+\/[\w.-]+$/.test(src.trim()); + const asksSeed = fields.includes("seed") && looksLikeVideo; + useEffect(() => { + if (!asksSeed) return setSeeds(null); + let gone = false; + const t = setTimeout(() => { + fetch(`/api/projects/new?from=${encodeURIComponent(src.trim())}`, { cache: "no-store" }) + .then((r) => (r.ok ? r.json() : null)) + .then((j) => { + if (gone || !j?.video) return; + setSeeds({ chapters: !!j.chapters, frames: !!j.frames }); + setSeed((v) => (v && !j[v] ? "" : v)); + }) + .catch(() => {}); + }, 250); + return () => { + gone = true; + clearTimeout(t); + }; + }, [asksSeed, src]); const create = async () => { if (!slug.trim()) return; @@ -96,7 +122,10 @@ export default function NewProjectMenu({ const body: Record<string, unknown> = { kind, slug, title }; if (fields.includes("from") && src.trim()) body.from = src.trim(); if (fields.includes("siteOrigin") && origin.trim()) body.siteOrigin = origin.trim(); - if (fields.includes("seed") && seed && looksLikeVideo) body.seed = "chapters"; + if (fields.includes("seed") && seed && looksLikeVideo) { + body.seed = seed; + if (seed === "frames") body.target = Number(target); + } if (fields.includes("brand") && brand) body.brand = brand; const res = await fetch("/api/projects/new", { method: "POST", @@ -234,11 +263,31 @@ export default function NewProjectMenu({ </Select> </Field> )} - {fields.includes("seed") && looksLikeVideo && ( - <label className="flex items-center gap-1.5 pb-1.5 text-[12px] text-text-2" title={FIELD_HINT.seed}> - <input type="checkbox" checked={seed} onChange={(e) => setSeed(e.target.checked)} data-new-seed /> - Seed from the digest's chapters - </label> + {asksSeed && ( + <Field label="Seed"> + <Select value={seed} onChange={(e) => setSeed(e.target.value as typeof seed)} aria-label={`seed — ${FIELD_HINT.seed}`} title={FIELD_HINT.seed} data-new-seed> + <option value="">an empty timeline</option> + <option value="chapters" disabled={seeds !== null && !seeds.chapters}> + the digest&apos;s chapters{seeds !== null && !seeds.chapters ? " (none)" : ""} + </option> + <option value="frames" disabled={seeds !== null && !seeds.frames}> + the frame scan&apos;s events{seeds !== null && !seeds.frames ? " (no scan)" : ""} + </option> + </Select> + </Field> + )} + {asksSeed && seed === "frames" && ( + <Field label="Target s"> + <Input + value={target} + onChange={(e) => setTarget(e.target.value)} + inputMode="numeric" + aria-label={`target seconds — ${FIELD_HINT.target}`} + title={FIELD_HINT.target} + 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> diff --git a/umtool/lib/projects/scaffold.mjs b/umtool/lib/projects/scaffold.mjs @@ -172,6 +172,25 @@ export async function chaptersAsClips({ channelsDir, channel, video }) { } /** + * What a video ref can be seeded from (release 32 R2: the new-project form + * offers only these): its digest's chapters (ai-digest.json) and its frame + * scan (frame-scan.poker.json, the profile framesAsClips reads). `video` false: + * `from` is not a video ref. + * + * @param {{ channelsDir?: string, from: string | null }} args + * @returns {Promise<{ video: boolean, chapters: boolean, frames: boolean }>} + */ +export async function seedsFor({ channelsDir = GLOBAL_CHANNELS_DIR(), from }) { + const src = detectFrom(from); + if (src?.kind !== "video") return { video: false, chapters: false, frames: false }; + const dir = path.join(channelsDir, src.channel, "data", src.video); + if (path.relative(channelsDir, dir).startsWith("..")) return { video: false, chapters: false, frames: false }; + const has = (name) => stat(path.join(dir, name)).then((x) => x.isFile(), () => false); + const [chapters, frames] = await Promise.all([has("ai-digest.json"), has("frame-scan.poker.json")]); + return { video: true, chapters, frames }; +} + +/** * A frame scan's events, as a draft supercut (release 30): the video's * `frame-scan.<profile>.json` (`pnpm ops frame-scan`) through framesCut — * a clip around each event, cut on the cues' sentence edges — and the scan's diff --git a/umtool/lib/projects/scaffold.ts b/umtool/lib/projects/scaffold.ts @@ -14,6 +14,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"). + target?: number | string | null; brand?: string | null; }; @@ -41,6 +43,7 @@ export async function scaffoldProject(body: NewProjectBody): Promise<{ href: str siteOrigin: body.siteOrigin || null, seed: body.seed || null, brand: body.brand || null, + ...(body.seed === "frames" && body.target !== undefined && body.target !== null && body.target !== "" ? { target: Number(body.target) } : {}), }); result = { ...r, href: `/projects/${r.id}` }; } catch (e) { diff --git a/umtool/lib/scaffold-frames.test.mjs b/umtool/lib/scaffold-frames.test.mjs @@ -6,7 +6,7 @@ import assert from "node:assert/strict"; import { mkdir, mkdtemp, readFile, rm, writeFile } from "node:fs/promises"; import os from "node:os"; import path from "node:path"; -import { scaffoldReportVideo } from "./projects/scaffold.mjs"; +import { scaffoldReportVideo, seedsFor } from "./projects/scaffold.mjs"; const SCAN = { format: "archilyzer-frame-scan", @@ -66,3 +66,21 @@ test("--seed frames: a clip per event, the stats as subtitles, the overlay block await rm(tmp, { recursive: true, force: true }); } }); + +test("seedsFor (release 32): what a video ref can be seeded from — its digest, its frame scan; not a video ref, nothing", async () => { + const tmp = await mkdtemp(path.join(os.tmpdir(), "umtool-seeds-")); + try { + const channelsDir = path.join(tmp, "channels"); + const dir = path.join(channelsDir, "synth-poker", "data", "synthstream1"); + await mkdir(dir, { recursive: true }); + assert.deepEqual(await seedsFor({ channelsDir, from: "synth-poker/synthstream1" }), { video: true, chapters: false, frames: false }); + await writeFile(path.join(dir, "frame-scan.poker.json"), JSON.stringify(SCAN)); + assert.deepEqual(await seedsFor({ channelsDir, from: "synth-poker/synthstream1" }), { video: true, chapters: false, frames: true }); + await writeFile(path.join(dir, "ai-digest.json"), "{}"); + assert.deepEqual(await seedsFor({ channelsDir, from: "https://archive.example/?v=synth-poker%2Fsynthstream1&t=5" }), { video: true, chapters: true, frames: true }); + assert.deepEqual(await seedsFor({ channelsDir, from: "notes.md" }), { video: false, chapters: false, frames: false }); + assert.deepEqual(await seedsFor({ channelsDir, from: null }), { video: false, chapters: false, frames: false }); + } finally { + await rm(tmp, { recursive: true, force: true }); + } +});