Archilyzer · Source

archilyzer

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

commit fae9d78600ef8acf945d3eefb2bac6e76cf1555e
parent b1a2cf7b519215829d4505e017b5b4ae89562aaf
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Wed, 14 Oct 2026 03:09:03 -0400

Merge r28/integration: release 28 smoke fixes — the teaser's long lines, YouTube chapters by section

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

Diffstat:
Mcommon/lib/report/draft/tasks/teaser.test.ts | 18+++++++++++++++---
Mcommon/lib/report/draft/tasks/teaser.ts | 33+++++++++++++++++++++++++++++++--
Mumtool/report-to-video/build-video.mjs | 4+++-
Mumtool/report-to-video/youtube.mjs | 7++++++-
Mumtool/report-to-video/youtube.test.mjs | 16++++++++++++++++
5 files changed, 71 insertions(+), 7 deletions(-)

diff --git a/common/lib/report/draft/tasks/teaser.test.ts b/common/lib/report/draft/tasks/teaser.test.ts @@ -16,7 +16,7 @@ import { promisify } from "node:util"; import { jsonReply, startFakeOllama, type FakeOllama } from "../../../../testing/llm/fakeOllama.mjs"; import { createIteration, projectOf, updateIteration, writeIterationFile } from "../../iterations"; import { loadDeckChecks, type DeckChecks } from "./deckChecks"; -import { checkTeaser, claimGist, parseTeaser, teaser, teaserEvidence } from "./teaser"; +import { checkTeaser, claimGist, fitTeaserLines, parseTeaser, teaser, teaserEvidence } from "./teaser"; import type { DraftFile } from "./media"; import type { TaskDeps } from "./types"; @@ -107,8 +107,10 @@ test("teaser's checks, each alone; the build's validateTeaser is one of them", a assert.deepEqual(hard(["Synth Kitchen", "The baker's bakery", "The contest"]), [], "an apostrophe is not a quotation"); assert.match(hard(["Synth Kitchen", "The bakery", "In 2025"]).join(), /line 3: number 2025 is not in the report/); assert.match(hard(["Synth Kitchen", "The bakery", "Ask Marco"]).join(), /line 3: name “Marco” is not in the report/); - // A middle line is a title: past its row's fit the build refuses it. - assert.match(hard(["Synth Kitchen", "The bakery and the contest and the oven", "The contest"]).join(), /it would not build: .*lines\[1\]/); + // A middle line is a title: past its row's fit, code sets its end as the + // second tier; a line no split can fit (one long word) the build refuses. + assert.deepEqual(hard(["Synth Kitchen", "The bakery and the contest and the oven", "The contest"]), []); + assert.match(hard(["Synth Kitchen", "Thebakeryandthecontestandtheovenandmore", "The contest"]).join(), /it would not build: .*lines\[1\]/); // Without the build's check nothing is written. assert.match(hard(["Synth Kitchen", "The bakery", "The contest"], { ...u, deck: null as never }).join(), /not available, so the lines are not written/); assert.equal(claimGist('She says she would not sell: "I would never sell the bakery to a chain"'), "She says she would not sell"); @@ -141,3 +143,13 @@ test("teaser: the operator's lines kept (forced, the draft an alternative); a te assert.equal((await q.manifestNow()).timeline.some((e: { type: string }) => e.type === "teaser"), false, "no teaser added"); assert.equal(ol.remaining(), 0); }); + +test("teaser: a line past its role's row gets its end as the second tier; one that fits, or cannot be split, stays as written", () => { + const long = "Why can a glucose crash save a life?"; // 36: a title fits 34 + assert.deepEqual(fitTeaserLines(["Overline", long, "Kicker"]), ["Overline", { text: long, break: "life?" }, "Kicker"]); + assert.deepEqual(fitTeaserLines(["Overline", "Short title", "Kicker"]), ["Overline", "Short title", "Kicker"]); + // Roles follow position: one line is a title, two are an overline and a title. + assert.deepEqual(fitTeaserLines([long]), [{ text: long, break: "life?" }]); + assert.deepEqual(fitTeaserLines([long, long]), [long, { text: long, break: "life?" }]); + assert.deepEqual(fitTeaserLines(["Overline", "x".repeat(40), "Kicker"]), ["Overline", "x".repeat(40), "Kicker"]); +}); diff --git a/common/lib/report/draft/tasks/teaser.ts b/common/lib/report/draft/tasks/teaser.ts @@ -32,6 +32,35 @@ export const TEASER_QUOTE_RUN = 5; // The row each role fits (deck.mjs TEASER_LIMITS.fit): the prompt's rule; the // build's validator is the check. const ROLE_FIT = { overline: 64, title: 34, kicker: 56 }; +// A `break` (the line's end, drawn as the smaller second tier) fits this row. +const SUB_FIT = 66; + +export type TeaserLine = string | { text: string; break: string }; + +/** + * The lines as the card draws them: a line longer than its role's row (roles + * follow position: with three or more lines the first is the overline, the + * last the kicker, the rest titles; two are an overline and a title; one is a + * title) becomes `{ text, break }`, its end set as the second tier at the last + * word boundary where the first tier fits the role and the end fits the + * second tier's row. A line that cannot be split so stays as written, and the + * build's check refuses it. Code fits the rows; the model only writes words. + */ +export function fitTeaserLines(lines: string[]): TeaserLine[] { + const roleOf = (i: number): keyof typeof ROLE_FIT => + lines.length >= 3 ? (i === 0 ? "overline" : i === lines.length - 1 ? "kicker" : "title") : lines.length === 2 && i === 0 ? "overline" : "title"; + return lines.map((line, i) => { + const fit = ROLE_FIT[roleOf(i)]; + if (line.length <= fit) return line; + const words = line.split(/\s+/); + for (let k = words.length - 1; k >= 1; k--) { + const head = words.slice(0, k).join(" "); + const tail = words.slice(k).join(" "); + if (head.length <= fit && tail.length <= SUB_FIT) return { text: line, break: tail }; + } + return line; + }); +} export const NEW_TEASER_ID = "teaser"; export type TeaserInput = MediaTaskInput; @@ -96,7 +125,7 @@ export function quoteRunIn(line: string, quotes: readonly string[]): string | nu /** The teaser entry these lines would make. */ export const teaserEntryOf = (u: Pick<TeaserUnit, "entry" | "id">, lines: string[]): ManifestEntry => - ({ ...(u.entry ?? { type: "teaser", id: u.id }), lines }) as ManifestEntry; + ({ ...(u.entry ?? { type: "teaser", id: u.id }), lines: fitTeaserLines(lines) }) as ManifestEntry; /** Every code check of a teaser's lines: `hard` refuses them. */ export function checkTeaser(lines: string[], u: Pick<TeaserUnit, "entry" | "id" | "evidence" | "quotes" | "deck">): { hard: string[]; soft: string[] } { @@ -197,7 +226,7 @@ export const TEASER_SPEC: MediaTaskSpec<TeaserUnit, string[], TeaserInput> = { }); manifest.timeline.splice(at < 0 ? manifest.timeline.length : at + 1, 0, { type: "teaser", id: u.id } as ManifestEntry); } - return applyDraft(manifest, { entry: u.id, field: "lines", value, provenance, force }); + return applyDraft(manifest, { entry: u.id, field: "lines", value: fitTeaserLines(value as string[]), provenance, force }); }, describe: (lines) => lines.join(" / "), }; diff --git a/umtool/report-to-video/build-video.mjs b/umtool/report-to-video/build-video.mjs @@ -3966,7 +3966,9 @@ async function muxChapters(finalPath, entries, segments, D, outDir, provenance, const start = i === 0 ? 0 : starts[i] + D; const end = i === entries.length - 1 ? total : starts[i + 1] + D; const title = await chapterTitle(entries[i], i, provenance, { deck }); - chapters.push({ start, end, title }); + // `section`: the entry opens one of the cut's sections (a card) -- what + // out/youtube.txt's Chapters keep (youtube.mjs youtubeChapters). + chapters.push({ start, end, title, section: entries[i]?.type === "card" }); lines.push( "[CHAPTER]", "TIMEBASE=1/1000", diff --git a/umtool/report-to-video/youtube.mjs b/umtool/report-to-video/youtube.mjs @@ -44,11 +44,16 @@ const oneLine = (s) => String(s ?? "").replace(/\s+/g, " ").trim(); * span): `{ chapters, note }` -- `chapters` null when the block is left out, * `note` saying what was folded or why the block is left out. * - * @param {Array<{ start: number, end?: number, title: string }> | null | undefined} list + * @param {Array<{ start: number, end?: number, title: string, section?: boolean }> | null | undefined} list * @param {number | null} [total] */ export function youtubeChapters(list, total = null) { if (!Array.isArray(list) || !list.length) return { chapters: null, note: "no chapters: the build made none" }; + // The build's list has a chapter per segment (a player's navigation). A + // description's chapters are the cut's SECTIONS: when the list says which + // entries open one (`section`: a title or chapter card), every other entry + // folds into the section before it. + if (list.some((c) => c?.section === true)) list = list.filter((c, i) => i === 0 || c?.section === true); const all = list.map((c) => ({ start: Math.floor(Number(c.start)), title: oneLine(c.title) || "Chapter" })); if (all[0].start !== 0) return { chapters: null, note: `no chapters: the first starts at ${chapterStamp(all[0].start)}, not 0:00` }; const end = Number.isFinite(Number(total)) && total !== null diff --git a/umtool/report-to-video/youtube.test.mjs b/umtool/report-to-video/youtube.test.mjs @@ -89,3 +89,19 @@ test("the preview: the default cut's sources, no chapters", async () => { assert.ok(!p.text.includes("qa-long-03&t=5"), "an entry of another variant is not in the default cut"); assert.equal(youtubePreview({ timeline: [] }).text, null); }); + +test("youtubeChapters: with sections marked, the clips fold into the section that opens before them", () => { + const list = [ + { start: 0, title: "The title", section: true }, + { start: 14, title: "Size and staffing", section: true }, + { start: 32, title: "clip a", section: false }, + { start: 44, title: "clip a again", section: false }, + { start: 72, title: "Insulinoma", section: true }, + { start: 82, title: "clip b", section: false }, + { start: 110, title: "clip c", section: false }, + ]; + const r = youtubeChapters(list, 130); + assert.deepEqual(r.chapters.map((c) => c.title), ["The title", "Size and staffing", "Insulinoma"]); + // Too few sections: the block is left out rather than listing clips. + assert.equal(youtubeChapters(list.filter((c) => c.title !== "Insulinoma"), 130).chapters, null); +});