Archilyzer · Source

archilyzer

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

commit c82de9a88383954098e37e75f98edbf0efde2ce4
parent ec96f82abd2838dff4e6eb61e6a9f35691d15163
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Tue, 13 Oct 2026 22:40:46 -0400

umtool: the YouTube text on the project page, with Copy; e2e media-draft-e.spec (r28 M6)

YoutubeSection shows out/youtube.txt when a build wrote it (its age, and a
note when publish.youtube changed since), else the same text composed from
the manifest without the chapters (youtube.mjs youtubePreview), with Copy and
who drafted it. Nothing when the cut has neither.

media-draft-e.spec.ts: a drafted publish.youtube previewed (the sources, no
chapters) and copied; a fast build writes out/youtube.txt with three chapters
(two short ones folded) and the moment links; the page then shows the built
text. Fixture: e2e/fixtures/youtube-fixture.mjs.

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

Diffstat:
Mumtool/components/projects/ReportProject.tsx | 4++++
Aumtool/components/projects/YoutubeSection.tsx | 53+++++++++++++++++++++++++++++++++++++++++++++++++++++
Mumtool/e2e/fixtures/make-fixture.mjs | 4++++
Aumtool/e2e/fixtures/youtube-fixture.mjs | 32++++++++++++++++++++++++++++++++
Aumtool/e2e/media-draft-e.spec.ts | 69+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
5 files changed, 162 insertions(+), 0 deletions(-)

diff --git a/umtool/components/projects/ReportProject.tsx b/umtool/components/projects/ReportProject.tsx @@ -30,6 +30,7 @@ import ReportBuildChain from "./ReportBuildChain"; import SnapshotButton from "./SnapshotButton"; import DeleteProject from "./DeleteProject"; import TagCitedButton from "./TagCitedButton"; +import YoutubeSection from "./YoutubeSection"; import { RowControls, RowNotes, TimelineList } from "./TimelineEditor"; import GeneratedBanner from "@/components/notes/GeneratedBanner"; import { NotesProvider } from "@/components/notes/NotesProvider"; @@ -759,6 +760,9 @@ export default async function ReportProject({ )} </section> + {/* --- the upload's text (out/youtube.txt, or its preview) --------- */} + <YoutubeSection dir={project.dir} manifest={m as Record<string, unknown>} /> + {/* --- exports --------------------------------------------------- */} <section data-exports="" className="rounded border border-[var(--color-line)] bg-[var(--color-panel)] px-3 py-2"> <h2 className="micro mb-1">export</h2> diff --git a/umtool/components/projects/YoutubeSection.tsx b/umtool/components/projects/YoutubeSection.tsx @@ -0,0 +1,53 @@ +import { readFile, stat } from "node:fs/promises"; +import path from "node:path"; +import CopyButton from "@/components/CopyButton"; +import { fmtAgo } from "@/lib/format"; +import { youtubePreview, youtubeTextName } from "umtool-report-to-video/youtube"; + +// The upload's text (release 28 M6): what the build wrote to +// out/youtube.txt — the title, the summary, the chapters and the sources — +// or, before a build, the same text composed from the manifest without the +// chapters. Shown with Copy. Nothing when the cut has no publish.youtube and +// no built text. + +type Props = { dir: string; manifest: Record<string, unknown> }; + +export default async function YoutubeSection({ dir, manifest }: Props) { + const file = path.join(dir, "out", youtubeTextName("sourced")); + const built = await readFile(file, "utf8").catch(() => null); + const mtimeMs = built === null ? null : await stat(file).then((s) => s.mtimeMs, () => null); + const preview = youtubePreview(manifest); + const text = built ?? preview.text; + if (!text) return null; + const yt = (manifest.publish as { youtube?: { title?: string; description?: string } } | undefined)?.youtube; + // The built text starts with the title and the summary as they were then. + const head = [yt?.title?.trim(), yt?.description?.trim()].filter(Boolean).join("\n\n"); + const stale = built !== null && !!head && !built.startsWith(head); + const drafted = (manifest.drafted as Record<string, { model?: string }> | undefined)?.["publish.youtube"]; + return ( + <section + data-youtube={built !== null ? "built" : "preview"} + aria-label="YouTube text" + className="rounded border border-[var(--color-line)] bg-[var(--color-panel)] px-3 py-2" + > + <div className="mb-1 flex flex-wrap items-baseline gap-3"> + <h2 className="micro">youtube</h2> + <span className="num text-[11px] text-[var(--color-dim)]" data-youtube-status=""> + {built !== null + ? `out/${youtubeTextName("sourced")}${mtimeMs ? `, built ${fmtAgo(mtimeMs)}` : ""}${stale ? " — the title or summary has changed since: rebuild" : ""}` + : `preview — ${preview.note}`} + {drafted ? ` · drafted by ${drafted.model ?? "a model"}` : ""} + </span> + <span className="ml-auto"> + <CopyButton text={text} label="Copy" title="copy the YouTube title and description" /> + </span> + </div> + <pre + data-youtube-text="" + className="max-h-[40vh] overflow-y-auto whitespace-pre-wrap break-words font-mono text-[11px] text-[var(--color-text)]" + > + {text} + </pre> + </section> + ); +} diff --git a/umtool/e2e/fixtures/make-fixture.mjs b/umtool/e2e/fixtures/make-fixture.mjs @@ -26,6 +26,7 @@ import { makeSitesFixture } from "./sites-fixture.mjs"; import { makeIterationsFixture } from "./iterations-fixture.mjs"; import { makeDeleteFixture } from "./delete-fixture.mjs"; import { makeDraftReviewFixture } from "./draft-review-fixture.mjs"; +import { makeYoutubeFixture } from "./youtube-fixture.mjs"; const CODE = path.resolve(path.dirname(new URL(import.meta.url).pathname), "..", "..", "song"); const dest = path.resolve(process.argv[2] ?? path.join(process.cwd(), ".e2e-song")); @@ -1656,6 +1657,8 @@ for (const dir of [BENCH, BUILD, ONSCREEN, ONSCREEN_BUILD, ONSCREEN_POSTS, ONSCR // Release 28: drafted fields to review, and a final build they hold // (draft-review.spec.ts). makeDraftReviewFixture({ reports, manifest, cachedWindow: path.join(REPORT, "out", "clips-raw", "vid1_0.00-9.00.mp4") }); +// Release 28 M6: the YouTube text, previewed and built (media-draft-e.spec.ts). +makeYoutubeFixture({ reports, manifest, cachedWindow: path.join(REPORT, "out", "clips-raw", "vid1_0.00-9.00.mp4") }); // TWO MORE cached windows for vid1, and they are the regression rather than // decoration. @@ -1958,4 +1961,5 @@ console.log(` takes-fixture (writable: takes/ with 4 takes over 2 gro console.log(` narration-fixture (writable: a narrated card, voiced by the editor stub's tone)`); console.log(` narration-review-fixture (writable: two narrated cards, nothing judged)`); console.log(` draft-review-fixture (writable: drafted on-screen, narration, teaser; an alternative), draft-review-build-fixture`); +console.log(` youtube-fixture (writable: a drafted publish.youtube, built fast to out/youtube.txt)`); console.log(` ${taken} candidate files copied, 2 mix tracks synthesised`); diff --git a/umtool/e2e/fixtures/youtube-fixture.mjs b/umtool/e2e/fixtures/youtube-fixture.mjs @@ -0,0 +1,32 @@ +// What media-draft-e.spec.ts reads (release 28, M6): a cut whose +// publish.youtube was drafted, three cards long enough to make YouTube +// chapters, and two clips over the cached window the build fixtures share — +// so the project page previews the YouTube text, and a fast build writes +// out/youtube.txt with its chapters and sources. Its own, so the other specs' +// projects are never touched. Synthetic, like every fixture. +import { copyFileSync, mkdirSync, writeFileSync } from "node:fs"; +import path from "node:path"; + +const P = (task, model = "qwen3:8b") => ({ task, model, at: "2026-10-13T10:00:00.000Z", iteration: 1, attempt: 1 }); + +/** + * @param {{ reports: string, manifest: Function, cachedWindow: string }} o + * `manifest` is make-fixture's manifest(slug, title, provenance, timeline); + * `cachedWindow` the vid1 0-9 s window the build fixtures share. + */ +export function makeYoutubeFixture({ reports, manifest, cachedWindow }) { + const dir = path.join(reports, "youtube-fixture"); + mkdirSync(path.join(dir, "out", "clips-raw"), { recursive: true }); + const m = manifest("youtube-fixture", "The YouTube Fixture", { siteOrigin: "https://archive.example" }, [ + { type: "card", id: "title", style: "title", seconds: 10, heading: "The YouTube Fixture" }, + { type: "clip", id: "c01", video: "vid1", start: 3.0, end: 6.0, cite: 3, section: 0, lock: true, quote: "and because" }, + { type: "card", id: "k01", style: "chapter", seconds: 10, heading: "The county" }, + { type: "clip", id: "c02", video: "vid1", start: 9.0, end: 12.0, cite: 9, section: 0, lock: true, quote: "another whole sentence" }, + { type: "card", id: "k02", style: "chapter", seconds: 10, heading: "Then" }, + ]); + m.publish = { youtube: { title: "The county said yes", description: "Half a year on, the county said yes, and the fixture says so." } }; + m.drafted = { "publish.youtube": P("youtube") }; + writeFileSync(path.join(dir, "video.manifest.json"), JSON.stringify(m, null, 2) + "\n"); + copyFileSync(cachedWindow, path.join(dir, "out", "clips-raw", path.basename(cachedWindow))); + return { dir }; +} diff --git a/umtool/e2e/media-draft-e.spec.ts b/umtool/e2e/media-draft-e.spec.ts @@ -0,0 +1,69 @@ +import { test, expect } from "@playwright/test"; +import { existsSync, readFileSync } from "node:fs"; +import path from "node:path"; +import { fileURLToPath } from "node:url"; + +// --------------------------------------------------------------------------- +// Release 28 lane E's media drafts, as umtool shows them (M6): the project +// page's YouTube text — previewed from publish.youtube before a build (the +// sources, no chapters), copied with Copy, then as a fast build writes it to +// out/youtube.txt with the build's own chapters (YouTube's rules) and a moment +// link per cited clip. The flips, threads and youtube tasks themselves run +// over the fake LLM in common's and the MCP's suites; umtool's "Draft with" +// buttons are M9's. Fixture: e2e/fixtures/youtube-fixture.mjs. +// --------------------------------------------------------------------------- + +const HERE = path.dirname(fileURLToPath(import.meta.url)); +const FIXTURE = path.join(HERE, "..", ".e2e-song"); +const PROJECT = "reports/youtube-fixture"; +const DIR = path.join(FIXTURE, "reports", "youtube-fixture"); +const TITLE = "The county said yes"; +const SUMMARY = "Half a year on, the county said yes, and the fixture says so."; +const SOURCES = ["https://archive.example/?v=testchan%2Fvid1&t=3", "https://archive.example/?v=testchan%2Fvid1&t=9"]; + +test("the YouTube text: a preview before the build, Copy, then out/youtube.txt with chapters and sources", async ({ page, request, context }) => { + test.setTimeout(300_000); + await context.grantPermissions(["clipboard-read", "clipboard-write"]); + await page.goto(`/browse/${PROJECT}`); + const section = page.locator("[data-youtube]"); + await expect(section).toHaveAttribute("data-youtube", "preview"); + await expect(section.locator("[data-youtube-status]")).toContainText("chapters are added by the build"); + await expect(section.locator("[data-youtube-status]")).toContainText("drafted by qwen3:8b"); + const preview = await section.locator("[data-youtube-text]").textContent(); + expect(preview).toBe(`${TITLE}\n\n${SUMMARY}\n\nSources\n${SOURCES.join("\n")}\n`); + await section.getByRole("button", { name: "Copy" }).click(); + await expect(section.locator("[data-copy]")).toHaveAttribute("data-state", "done"); + expect(await page.evaluate(() => navigator.clipboard.readText())).toBe(preview); + + // A fast build (hard cuts) writes the text with the build's chapters. + const start = await request.post("/api/report/build", { data: { project: PROJECT, preset: "fast" } }); + expect(start.ok(), await start.text()).toBeTruthy(); + const { job } = (await start.json()) as { job: { id: string } }; + let done: { state: string; error: string | null } = { state: "running", error: null }; + const until = Date.now() + 240_000; + while (Date.now() < until) { + done = (await (await request.get(`/api/report/build?job=${job.id}`)).json()) as typeof done; + if (done.state !== "running") break; + await new Promise((r) => setTimeout(r, 400)); + } + expect(done.state, done.error ?? "").toBe("done"); + const file = path.join(DIR, "out", "youtube.txt"); + expect(existsSync(file)).toBe(true); + const text = readFileSync(file, "utf8"); + const [title, , summary, , chaptersHead, ...rest] = text.split("\n"); + expect([title, summary, chaptersHead]).toEqual([TITLE, SUMMARY, "Chapters"]); + // Five entries; the two under ten seconds after a chapter are folded: three + // chapters, the first at 0:00 (the title card), the clips' at 0:10 and 0:2x. + const chapters = rest.slice(0, rest.indexOf("")); + expect(chapters.length).toBe(3); + expect(chapters[0]).toBe("0:00 The YouTube Fixture"); + expect(chapters[1]).toMatch(/^0:1\d /); + expect(chapters[2]).toMatch(/^0:2\d /); + expect(text.endsWith(`\n\nSources\n${SOURCES.join("\n")}\n`)).toBe(true); + + // The page shows the built text now. + await page.reload(); + await expect(section).toHaveAttribute("data-youtube", "built"); + await expect(section.locator("[data-youtube-status]")).toContainText("out/youtube.txt, built"); + expect(await section.locator("[data-youtube-text]").textContent()).toBe(text); +});