// `umtool new --from / --seed frames` (release 30, lane P): // the draft supercut from a synthetic frame-scan sidecar in a temp tree. import { test } from "node:test"; 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, seedsFor } from "./projects/scaffold.mjs"; const SCAN = { format: "archilyzer-frame-scan", profile: "poker", source: { savedVideo: "source-media.mp4", durationSeconds: 300 }, sampling: { everySeconds: 10, from: 0, to: 300 }, derived: { tournaments: [{ key: "synthetic cup", name: "Synthetic Cup", from: 30, to: 200, series: { stack: [[30, 20000], [90, 41000], [180, 0]], playersLeft: [[30, 85]] }, facts: {} }], events: [ { t: 90, kind: "double-up", detail: "20,000 → 41,000 chips (2.1×)", source: "series" }, { t: 180, kind: "bust", detail: "out from 41,000 chips", source: "series" }, ], segments: [], flags: [], }, }; test("--seed frames: a clip per event, the stats as subtitles, the overlay block, a README checklist", async () => { const tmp = await mkdtemp(path.join(os.tmpdir(), "umtool-frames-seed-")); try { const channelsDir = path.join(tmp, "channels"); const dir = path.join(channelsDir, "synth-poker", "data", "synthstream1"); await mkdir(dir, { recursive: true }); await writeFile(path.join(dir, "frame-scan.poker.json"), JSON.stringify(SCAN)); await writeFile(path.join(dir, "transcript.cues.json"), JSON.stringify({ cues: [{ start: 66, end: 70, text: "Here we go." }, { start: 70, end: 80, text: "all in" }] })); const r = await scaffoldReportVideo({ root: path.join(tmp, "reports"), slug: "poker-cut", from: "synth-poker/synthstream1", seed: "frames", channelsDir }); assert.equal(r.seeded, 2); const doc = JSON.parse(await readFile(path.join(r.dir, "video.manifest.json"), "utf8")); assert.deepEqual(doc.timeline.map((c) => [c.id, c.channel, c.video, c.onscreen.title]), [ ["f01", "synth-poker", "synthstream1", "Doubles up"], ["f02", "synth-poker", "synthstream1", "Busts out"], ]); // Release 31: the deck on with the stats region drawing the running // numbers, so each subtitle is what happened; no --site-origin, no QR. assert.equal(doc.timeline[0].onscreen.subtitle, "20,000 → 41,000 chips (2.1×)"); assert.deepEqual(doc.render.chrome, { engine: "hyperframes", layout: "deck", deck: { qr: { show: false } }, stats: {} }); assert.equal(doc.frameScan.file, "frame-scan.poker.json"); assert.equal(doc.frameScan.overlay.length, 2); const readme = await readFile(path.join(r.dir, "README.md"), "utf8"); assert.match(readme, /Clips seeded from the frame scan/); assert.match(readme, /\d+(\.\d+)? s of clips against a 240 s budget \(--target\)/); // A budget: a shorter one leaves the lesser event out; with an archive, the QR stays. const short = await scaffoldReportVideo({ root: path.join(tmp, "reports"), slug: "poker-short", from: "synth-poker/synthstream1", seed: "frames", channelsDir, target: 50, siteOrigin: "https://archive.example" }); const sdoc = JSON.parse(await readFile(path.join(short.dir, "video.manifest.json"), "utf8")); assert.deepEqual(sdoc.timeline.map((c) => c.onscreen.title), ["Doubles up"]); assert.deepEqual(sdoc.render.chrome.deck, {}); await assert.rejects( scaffoldReportVideo({ root: path.join(tmp, "reports"), slug: "poker-x", from: "synth-poker/synthstream1", seed: "chapters", channelsDir, target: 60 }), /--target is the frames seed's length budget/, ); await assert.rejects( scaffoldReportVideo({ root: path.join(tmp, "reports"), slug: "poker-cut-2", from: "synth-poker/none", seed: "frames", channelsDir }), /no frame-scan\.poker\.json — run pnpm ops frame-scan first/, ); await assert.rejects(scaffoldReportVideo({ root: path.join(tmp, "reports"), slug: "poker-cut-3", seed: "frames", channelsDir }), /--seed frames needs --from/); } finally { 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, reactions: 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, reactions: false }); 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, reactions: false }); assert.deepEqual(await seedsFor({ channelsDir, from: "notes.md" }), { video: false, chapters: false, frames: false, reactions: false }); assert.deepEqual(await seedsFor({ channelsDir, from: null }), { video: false, chapters: false, frames: false, reactions: false }); } finally { await rm(tmp, { recursive: true, force: true }); } });