// What clip-editor.spec.ts edits (release 35 C2): a report video of three // clips an assistant proposed (the clip finder's `assist` on each) on one // synthetic source (vid1, its cues the fixture corpus's), the source's // reactions.json (two speakers, host and subject, their turns, two laughs, // five proposals -- two not in the cut) and its word timings (the cue text // spread evenly over each cue), and every clip's window cached in the // project's out/clips-raw (a copy of vid1's 0-9 s). Its own project: the spec // writes the manifest, montage-rulings.json, notes.json and reactions.json. // // r001 1.0-3.0 (p001) r002 4.0-6.0 (p002) r003 6.5-8.5 (p003) // unused: p004 9-12, p005 13-15 // // Synthetic, like every fixture. import { copyFileSync, mkdirSync, writeFileSync } from "node:fs"; import path from "node:path"; const write = (dir, name, doc) => { mkdirSync(dir, { recursive: true }); writeFileSync(path.join(dir, name), JSON.stringify(doc, null, 2) + "\n"); }; /** * `name`: another copy under another name (release 36: clip-look.spec.ts's * clip-look-fixture), so two specs never edit one project. * * @param {{ reports: string, manifest: Function, cachedWindow: string, cues: Array<[number, number, string]>, name?: string, title?: string }} o */ export function makeClipEditorFixture({ reports, manifest, cachedWindow, cues, name = "clip-editor-fixture", title = "The Clip Editor Fixture" }) { const dir = path.join(reports, name); const assist = (p, s, e, cs, ce, score, why) => ({ by: "assistant", proposal: p, score, why, original: { start: s, end: e, cutStart: cs, cutEnd: ce }, edits: [] }); const clip = (id, s, e, cs, ce, p, score, why, quote) => ({ type: "clip", id, video: "vid1", start: s, end: e, cutStart: cs, cutEnd: ce, quote, assist: assist(p, s, e, cs, ce, score, why) }); const doc = manifest(name, title, { siteOrigin: "https://archive.example" }, [ clip("r001", 0.5, 3.5, 1, 3, "p001", 0.8, "host laughs at the line", "This is a complete sentence."), clip("r002", 4, 6, 4, 6, "p002", 0.7, "a comment", "And this one runs on"), clip("r003", 6.5, 8.5, 6.5, 8.5, "p003", 0.6, "a short comment", "of that it finishes here."), ]); doc.render.fetchPad = 0; write(dir, "video.manifest.json", doc); const words = []; for (const [start, end, text] of cues) { const ws = text.split(/\s+/).filter(Boolean); const step = (end - start) / ws.length; ws.forEach((w, i) => words.push({ w, start: +(start + i * step).toFixed(2), end: +(start + (i + 0.8) * step).toFixed(2) })); } write(dir, "words.json", { words }); write(dir, "reactions.json", { version: 1, source: { channel: "testchan", video: "vid1", duration: 21, words: "words.json", diarization: { generatedAt: "2026-01-01T00:00:00.000Z", engine: "sherpa-onnx" } }, params: { target: 600, laughMin: 0.25, mergeGap: 6, setupMax: 20, clipMax: 75 }, proposedAt: "2026-01-01T00:00:00.000Z", speakers: [ { index: 0, role: "host", label: "Host", seconds: 9, turns: 4, how: "auto" }, { index: 1, role: "subject", label: "Subject", seconds: 12, turns: 3, how: "auto" }, ], turns: [ { start: 0, end: 2.2, speaker: 1 }, { start: 2.4, end: 3.8, speaker: 0 }, { start: 4, end: 6.2, speaker: 1 }, { start: 6.4, end: 9, speaker: 0 }, { start: 9.2, end: 15, speaker: 1 }, { start: 15.2, end: 21, speaker: 0 }, ], laughs: [ { start: 2.6, end: 3.2, score: 0.71, speaker: 0 }, { start: 7.0, end: 7.6, score: 0.44, speaker: 0 }, ], moments: [], proposals: [ { id: "p001", start: 1, end: 3, score: 0.8, moments: [], used: true, clipId: "r001", why: "host laughs at the line" }, { id: "p002", start: 4, end: 6, score: 0.7, moments: [], used: true, clipId: "r002", why: "a comment" }, { id: "p003", start: 6.5, end: 8.5, score: 0.6, moments: [], used: true, clipId: "r003", why: "a short comment" }, { id: "p004", start: 9, end: 12, score: 0.5, moments: [], used: false, clipId: null, why: "a long comment" }, { id: "p005", start: 13, end: 15, score: 0.3, moments: [], used: false, clipId: null, why: "a chuckle" }, ], }); mkdirSync(path.join(dir, "out", "clips-raw"), { recursive: true }); copyFileSync(cachedWindow, path.join(dir, "out", "clips-raw", "vid1_0.00-9.00.mp4")); return { dir }; }