// What clips-suggest.spec.ts reads and writes (release 36 lane D): the clip // editor's three assistant clips on vid1 (the clip editor fixture's cut, // copied under its own name so the two specs never edit one project), its // reactions.json and words.json, every window cached — and the assistant's // labels for the five proposals (clip-suggestions.json, as the editor's // `clips-suggest` task writes it), ranked so the sort reorders both lists: // // p003 (r003) 1 · p005 (unused) 2 · p001 (r001) 3 · p004 (unused) 4 · p002 (r002) 5 // // The spec posts the agent's reply itself (the editor stub cannot reach // umtool), as the clip-editor spec does. 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"); }; export const SUGGEST_PROPOSED_AT = "2026-01-01T00:00:00.000Z"; /** * @param {{ reports: string, manifest: Function, cachedWindow: string, cues: Array<[number, number, string]> }} o */ export function makeClipsSuggestFixture({ reports, manifest, cachedWindow, cues }) { const dir = path.join(reports, "clips-suggest-fixture"); 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("clips-suggest-fixture", "The Clips Suggest Fixture", { 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.5, 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 }); const proposals = [ { id: "p001", start: 1, end: 3, score: 0.8, moments: ["m001"], 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" }, ]; 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: SUGGEST_PROPOSED_AT, 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 }], moments: [{ id: "m001", t: 2.6, end: 3.2, kind: "laugh", score: 0.71, speaker: 0, text: "" }], proposals, }); const ranks = { p003: 1, p005: 2, p001: 3, p004: 4, p002: 5 }; const labels = { p001: "the complete sentence", p002: "a run-on line", p003: "how it finishes", p004: "the long comment", p005: "a quiet chuckle" }; write(dir, "clip-suggestions.json", { model: "qwen3:8b", at: "2026-01-01T01:00:00.000Z", proposedAt: SUGGEST_PROPOSED_AT, promptVersion: "clips-suggest-1", items: Object.fromEntries( proposals .map((p) => [p.id, { label: labels[p.id], why: `Why ${p.id} lands.`, rank: ranks[p.id], score: 11 - ranks[p.id] * 2, start: p.start, end: p.end }]) .sort((a, b) => a[1].rank - b[1].rank), ), }); 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 }; }