// A TAKE'S OWN ITEMS (take-items.spec.ts; umtool/docs/cli.md, "Edit a take, not // the project"): items of another project imported into a take, edited in the // take only. Two projects, written by that spec alone: // // take-items-fixture the take's project: two post items (p-1, p-3) and a // DRAFT take `t1` with no patch of its own yet // take-items-src-fixture the source: a narrated post item p-2 whose take // (narration/posts/2/take-1.orpheus-thread.wav, a 2 s // tone; its parts meta beside it) and attachment // (posts-media/takeitems-x/2/2_1.png) are files of // this project only, and a second take for the pick // // Synthetic, like every fixture. import { mkdirSync, writeFileSync } from "node:fs"; import { createHash } from "node:crypto"; import { spawnSync } from "node:child_process"; import path from "node:path"; const ff = (args) => { const r = spawnSync("ffmpeg", ["-v", "error", "-y", ...args]); if (r.status !== 0) throw new Error(`ffmpeg ${args.join(" ")}: ${String(r.stderr)}`); }; /** @param {{ reports: string, deckManifest: Function }} o */ export function makeTakeItemsFixture({ reports, deckManifest }) { const base = (id, date, text, o = {}) => ({ type: "post", id: `p-${id}`, post: `takeitems-x/${id}`, platform: "x", author: "Take Subject", handle: "takesubject", date, text, url: `https://x.com/takesubject/status/${id}`, engagement: { likes: 2 }, subjects: ["takesubject"], ...o, }); // The source: p-2, narrated (two takes, the first picked), with a picture. const src = path.join(reports, "take-items-src-fixture"); const takes = path.join(src, "narration", "posts", "2"); mkdirSync(takes, { recursive: true }); for (const [n, hz] of [[1, 262], [2, 330]]) { ff(["-f", "lavfi", "-i", `sine=frequency=${hz}:sample_rate=24000:duration=2`, "-ac", "1", "-c:a", "pcm_s16le", path.join(takes, `take-${n}.orpheus-thread.wav`)]); } writeFileSync(path.join(takes, "take-1.parts.json"), JSON.stringify([{ n: 1, para: 100, text: "The imported words.", start: 0, seconds: 2 }])); mkdirSync(path.join(src, "posts-media", "takeitems-x", "2"), { recursive: true }); ff(["-f", "lavfi", "-i", "color=c=teal:size=320x180", "-frames:v", "1", path.join(src, "posts-media", "takeitems-x", "2", "2_1.png")]); const take = (n) => ({ file: `narration/posts/2/take-${n}.orpheus-thread.wav`, engine: "orpheus", voice: "zac", seconds: 2, script: "The imported words.", at: "2026-11-04T00:00:00.000Z" }); const sm = deckManifest("take-items-src-fixture", "The Take Items Source", [ base("2", "2026-11-02T10:00:00.000Z", "The imported words.", { media: [{ src: "posts-media/takeitems-x/2/2_1.png", kind: "image", width: 320, height: 180 }], narration: { script: "The imported words.", takes: [take(1), take(2)], pick: 0 }, }), ]); mkdirSync(src, { recursive: true }); writeFileSync(path.join(src, "video.manifest.json"), JSON.stringify(sm, null, 2) + "\n"); // The take's project: p-1 and p-3, and the draft take t1 (no patch: the project's timeline until its first edit). const dir = path.join(reports, "take-items-fixture"); mkdirSync(dir, { recursive: true }); const m = deckManifest("take-items-fixture", "The Take Items Fixture", [ base("1", "2026-11-01T10:00:00.000Z", "The first post of the cut."), base("3", "2026-11-03T10:00:00.000Z", "The last post of the cut."), ]); const text = JSON.stringify(m, null, 2) + "\n"; writeFileSync(path.join(dir, "video.manifest.json"), text); const tdir = path.join(dir, "takes", "t1"); mkdirSync(tdir, { recursive: true }); writeFileSync(path.join(tdir, "take.json"), JSON.stringify({ id: "t1", group: "takes", order: 1, label: "Take one — with an imported post", kind: "different", summary: "", changes: [], preview: "preview.mp4", seconds: null, builtAt: null, style: null, patch: null, window: null, draft: true, draftedAt: "2026-11-04T00:00:00.000Z", baseHash: createHash("sha256").update(text).digest("hex"), }, null, 2) + "\n"); return { dir, src }; }