commit 61698cdd51cba7edb835fb8796305e51f089b804
parent ab20ff53f622c5379e4b5c60afafbfd57548f8c9
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Wed, 4 Nov 2026 02:11:45 -0500
umtool: a read never says a link -- X draws a long link over lines ("https://" / "web.archive.org/web/2021..." / "1733/https://twitter.com/..." / "…") and speakableText's `https?://\S+` ate only "https://", so a quoted post's links were read aloud (operator, 4 Nov, p-2116651428425150687). joinSplitLinks puts a split link back on one line (its "…" line dropped), dropUrls drops every link whole (a scheme, www., a bare host.tld/path, t.co); spokenUrls finds what a read would say that is a link (a spelled-out one too) and isOnlyUrls a part that is nothing else. The build's lint WARNS of a picked take that says one (post-thread.mjs threadReadWarnings) with its fix -- posts reread --drop-urls when the links are whole parts, else a re-take -- and posts roles lists it per item
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
6 files changed, 168 insertions(+), 8 deletions(-)
diff --git a/umtool/lib/report/postThreadCli.mjs b/umtool/lib/report/postThreadCli.mjs
@@ -13,7 +13,7 @@
//
// Plain ESM: the CLI runs under bare node.
import { isNarrated, pickedTake } from "umtool-report-to-video/post-narration";
-import { partRoles, readPieces, threadLayout, threadReadErrors } from "umtool-report-to-video/post-thread";
+import { partRoles, readPieces, threadLayout, threadReadErrors, threadReadWarnings } from "umtool-report-to-video/post-thread";
import { followKnobs } from "umtool-report-to-video/read-follow";
import { readManifest } from "../projects/report.mjs";
import { withEditNotes } from "./edit-guard.mjs";
@@ -52,7 +52,7 @@ export function readListing(e, render, prev) {
words: p.parts.map((k) => String(t.parts[k]?.text ?? "")).join(" ").split(/\s+/).filter(Boolean).length,
}));
const tiles = L.tiles.filter((x) => !x.read && x.scope !== "post").map((x) => ({ scope: x.scope, mode: x.mode }));
- return { id: e.id, take: t?.file ?? null, parts: t?.parts?.length ?? 0, pieces, unread: tiles, threaded: L.on && followKnobs(e, render).on, errors: threadReadErrors(e, render, { prev, followOn: followKnobs(e, render).on }) };
+ return { id: e.id, take: t?.file ?? null, parts: t?.parts?.length ?? 0, pieces, unread: tiles, threaded: L.on && followKnobs(e, render).on, errors: threadReadErrors(e, render, { prev, followOn: followKnobs(e, render).on }), warnings: threadReadWarnings(e) };
}
/**
@@ -109,10 +109,10 @@ export async function rolesCommand(project, ids, { write = false, set = null, js
}
const rows = items.map(({ e, prev }) => readListing(e, manifest.render, prev));
if (json) {
- out(JSON.stringify({ ok: true, items: rows, refused: rows.filter((r) => r.errors.length).length }, null, 2));
+ out(JSON.stringify({ ok: true, items: rows, refused: rows.filter((r) => r.errors.length).length, warned: rows.filter((r) => r.warnings.length).length }, null, 2));
return 0;
}
- out(`${project.id}: ${rows.length} narrated item(s) read in parts, ${rows.filter((r) => r.threaded).length} threaded, ${rows.filter((r) => r.errors.length).length} refused`);
+ out(`${project.id}: ${rows.length} narrated item(s) read in parts, ${rows.filter((r) => r.threaded).length} threaded, ${rows.filter((r) => r.errors.length).length} refused, ${rows.filter((r) => r.warnings.length).length} warned`);
out(lines(rows).join("\n"));
return 0;
}
@@ -124,6 +124,7 @@ function lines(rows) {
for (const p of r.pieces) out.push(` parts ${p.parts.join(",")} ${p.role ?? "(no text on the card)"} ${p.source}${p.mode ? ` shown ${p.mode}` : ""} ${p.words} words`);
for (const u of r.unread) out.push(` not read: ${u.scope} shown ${u.mode}`);
for (const er of r.errors) out.push(` REFUSED: ${er}`);
+ for (const w of r.warnings ?? []) out.push(` WARNING: ${w}`);
}
return out;
}
diff --git a/umtool/report-to-video/lint.mjs b/umtool/report-to-video/lint.mjs
@@ -89,7 +89,7 @@ import { wordZoomTimes } from "./word-zoom.mjs";
import { postAvatarFiles, validatePostAvatars } from "./post-avatars.mjs";
import { validatePostNarrationRender } from "./post-narration.mjs";
import { validatePostCombos } from "./post-combo.mjs";
-import { validateThreadReads } from "./post-thread.mjs";
+import { validateThreadReadWarnings, validateThreadReads } from "./post-thread.mjs";
import { validateFinaleEntries } from "./finale.mjs";
import { validateThreadEntries } from "./threads.mjs";
import { validateFlipEntries } from "./flips.mjs";
@@ -410,6 +410,8 @@ export function lintManifest(manifest, {
if (!only) warnings.push(...deckClaimNotes(whole));
// Room at the clips' edges (render.room): a fetched window it can reach past.
warnings.push(...roomWindowWarnings(only ? { ...manifest, timeline: (manifest.timeline ?? []).filter((e) => e?.id === only) } : manifest));
+ // A narrated post's read that says a link aloud (post-thread.mjs threadReadWarnings), with its fix.
+ warnings.push(...validateThreadReadWarnings(only ? { ...manifest, timeline: (manifest.timeline ?? []).filter((e) => e?.id === only) } : manifest));
for (const { where, src } of imageSrcsOf(manifest, { only })) {
if (path.isAbsolute(src) || src.startsWith("~")) {
diff --git a/umtool/report-to-video/post-narration.mjs b/umtool/report-to-video/post-narration.mjs
@@ -394,10 +394,83 @@ export function speakShouts(script) {
}).join("");
}
+// ---------------------------------------------------------------------------
+// LINKS ARE NEVER SPOKEN (operator, 4 Nov: a quoted post's links were read
+// aloud -- "https://. web.archive.org slash web slash 2021032015 ..."). X
+// draws a long link over lines ("https://" / "web.archive.org/web/2021…" /
+// "1733/https://twitter.com/…" / "…"), so the old `https?://\S+` ate only its
+// first line. The link is put back together first, then dropped whole.
+// ---------------------------------------------------------------------------
+
+/** The top-level domains a bare `host.tld/…` link is recognised by (no scheme, no www.). */
+const URL_TLDS = "com|org|net|io|co|tv|gg|me|ly|be|us|uk|ca|de|fr|ru|jp|app|dev|xyz|info|live|link|news|site|online|social|art|fm|to|is|sh|so|ai|cc|ws|biz|edu|gov";
+/** A link as written: a scheme, a www., a bare host.tld/path, or X's t.co. */
+const URL_RE = new RegExp(`(?:https?:\\/\\/\\S*|\\bwww\\.[^\\s]+|\\b(?:[a-z0-9-]+\\.)+(?:${URL_TLDS})\\/\\S*|\\bt\\.co\\/\\S+)`, "gi");
+/** A line ending in a link (its last token one). */
+const ENDS_IN_LINK = /(?:https?:\/\/|\bwww\.|\b(?:[a-z0-9-]+\.)+(?:com|org|net|io|co|tv|gg|me|ly|be|app|dev|xyz)\/)\S*$/i;
+/** What a link's continuation line looks like: one token of a link's characters. */
+const LINK_TAIL = /^[\w\-./?=&%#:~+@!,;]+$/;
+/** X's "…" after a link cut short. */
+const ELLIPSIS_LINE = /^(?:…|\.{3})$/;
+
+/**
+ * A text with X's SPLIT LINKS put back on one line: "https://" and the host on
+ * the next line joined, a link's continuation lines (one token, a link's
+ * characters, with a "/" or all digits) joined onto it, and a lone "…" line
+ * after a link dropped. Pure.
+ */
+export function joinSplitLinks(text) {
+ const lines = String(text ?? "").replace(/(https?:\/\/)[ \t]*\n[ \t]*(?=\S)/gi, "$1").split("\n");
+ const out = [];
+ for (const raw of lines) {
+ const line = raw.trim();
+ const last = out.length ? out[out.length - 1] : null;
+ const linked = last !== null && ENDS_IN_LINK.test(last.trim());
+ if (linked && line && LINK_TAIL.test(line) && (line.includes("/") || /^\d+$/.test(line))) {
+ out[out.length - 1] = `${last.replace(/\s+$/, "")}${line}`;
+ continue;
+ }
+ if (linked && ELLIPSIS_LINE.test(line)) continue;
+ out.push(raw);
+ }
+ return out.join("\n");
+}
+
+/** A text with every link dropped (joinSplitLinks first). */
+export function dropUrls(text) {
+ return joinSplitLinks(text).replace(URL_RE, " ");
+}
+
+/**
+ * WHAT A READ WOULD SAY THAT IS A LINK, pure: the links (and the pieces a
+ * voice reads of one -- "https:", "web.archive.org", "1733/") in `text`, a
+ * script or a part's words. Empty: nothing a voice would say is a link.
+ */
+export function spokenUrls(text) {
+ // A voice's "slash" put back, so a spelled-out link is one again.
+ const t = joinSplitLinks(String(text ?? "")).replace(/\s+slash\s+/gi, "/");
+ const out = [];
+ for (const m of t.matchAll(URL_RE)) out.push(m[0]);
+ // A link a script already spelled out ("https://. web.archive.org slash web slash …"): its scheme, a host.
+ const rest = t.replace(URL_RE, " ");
+ for (const m of rest.matchAll(/\bhttps?:\/*|\b(?:[a-z0-9-]+\.)+(?:com|org|net|io|co|tv|gg|app|dev|xyz)\b/gi)) out.push(m[0]);
+ return out;
+}
+
+/** Whether `text` is only links (and the dots, slashes and digits a split link leaves): a part that is nothing but one. */
+export function isOnlyUrls(text) {
+ const t = joinSplitLinks(String(text ?? "")).replace(/\s+slash\s+/gi, "/");
+ if (!spokenUrls(t).length) return false;
+ return !t
+ .replace(URL_RE, " ")
+ .replace(/\bhttps?:\/*|\b(?:[a-z0-9-]+\.)+(?:com|org|net|io|co|tv|gg|app|dev|xyz)\b/gi, " ")
+ .replace(/[\d\s./:…,;!?\-]+/g, "")
+ .trim();
+}
+
export function speakableText(text) {
- const clean = String(text ?? "")
+ const clean = dropUrls(String(text ?? ""))
.replace(/^RT @[A-Za-z0-9_]+:\s*/, "")
- .replace(/https?:\/\/\S+/g, " ")
.replace(/(^|[\s(])@[A-Za-z0-9_]{1,30}\b/g, "$1")
.replace(/[\p{Extended_Pictographic}\u{1F1E6}-\u{1F1FF}\u{FE0F}\u{200D}\u{20E3}]/gu, "")
.replace(/\b(\w+)\(s\)/g, "$1s")
diff --git a/umtool/report-to-video/post-narration.test.mjs b/umtool/report-to-video/post-narration.test.mjs
@@ -7,6 +7,7 @@ import {
POST_NARRATION_DEFAULTS, draftScript, dryGainAt, isNarrated, mixPhaseAt, narrationLevelDb, narrationSchedule,
nextTakeNumber, pickedTake, speakShouts, postNarrationDisclosure, postNarrationFilters, postNarrationKnobs, readSpanSeconds, speakableText, takeFileOf,
validatePostNarration, validatePostNarrationRender, wetGainAt, narrationRateOf, partAt, partStartOnItem, readSecondsOf,
+ dropUrls, isOnlyUrls, joinSplitLinks, spokenUrls,
} from "./post-narration.mjs";
import { POST_PICTURE_MIN, mediaTimeAt, postItemFiles, postItemPlan, postItemSeconds, postLayout, ruleSeconds, validatePostItem } from "./post-item.mjs";
import { postSegmentArgs } from "./post-render.mjs";
@@ -237,6 +238,22 @@ test("SCRIPTS ARE THE POST, VERBATIM: cleaned for pronunciation only, never an e
assert.equal(draftScript("RT @someone: hello there").script, "hello there");
});
+test("LINKS ARE NEVER SPOKEN: X's link split over lines is put back together and dropped whole -- its \"…\" line too; a spelled-out link is still found", () => {
+ const q = "THIS IS THE FINDING OUT STAGE STRAWB.\n\nhttps://\nweb.archive.org/web/2021032015\n1733/https://twitter.com/someone/status/1373102987070017537\n…\n\nhttps://\nweb.archive.org/web/2021032004\n0213/https://twitter.com/other/status/1373122620334477314\n…";
+ assert.equal(joinSplitLinks(q), "THIS IS THE FINDING OUT STAGE STRAWB.\n\nhttps://web.archive.org/web/20210320151733/https://twitter.com/someone/status/1373102987070017537\n\nhttps://web.archive.org/web/20210320040213/https://twitter.com/other/status/1373122620334477314");
+ assert.equal(speakableText(q), "this is the finding out stage strawb!");
+ assert.deepEqual(spokenUrls(speakableText(q)), []);
+ // www., a bare host with a path, X's t.co: gone; "e.g." and a name with a dot are words.
+ assert.equal(dropUrls("go to www.foo.com/bar, t.co/abc or kiwifarms.net/threads/1 e.g. Mr.Obvious").replace(/\s+/g, " "), "go to or e.g. Mr.Obvious");
+ // A script that already says one (the old draft's): found, and a part that is nothing else is whole.
+ const said = "https://. web.archive.org slash web slash 2021032015. 1733/. …";
+ assert.deepEqual(spokenUrls(said), ["https://.", "web.archive.org/web/2021032015."]);
+ assert.equal(isOnlyUrls(said), true);
+ assert.equal(isOnlyUrls("read this https://x.com/a/b before you go"), false);
+ assert.equal(isOnlyUrls("no link here at all"), false);
+ assert.deepEqual(spokenUrls("I said it twice, e.g. here and there."), []);
+});
+
test("the validator: shapes, tags, takes, the pick, the cut's knobs; the build's files", () => {
assert.deepEqual(validatePostNarration(post({ narration: narr(5) })), []);
const bad = validatePostNarration(post({ narration: { script: "hi <whisper>", takes: [{ file: "/abs.wav", seconds: -1 }], pick: 3, wet: 2, short: "freeze", bogus: 1 } }));
diff --git a/umtool/report-to-video/post-thread.mjs b/umtool/report-to-video/post-thread.mjs
@@ -49,7 +49,7 @@
// bench, the writers and the lint all read the same rules from here.
import { cardText, contextText, parentsOf } from "./post-item.mjs";
-import { draftScript, isNarrated, pickedTake, scriptParts } from "./post-narration.mjs";
+import { draftScript, isNarrated, isOnlyUrls, pickedTake, scriptParts, spokenUrls } from "./post-narration.mjs";
import { normWord, scriptWordsOf } from "./word-zoom.mjs";
import { followKnobs } from "./read-follow.mjs";
@@ -479,6 +479,57 @@ export function threadGeoAt(geo, scales) {
return { C: shift(geo?.C ?? 0), blocks, tiles: tileTops };
}
+// ---------------------------------------------------------------------------
+// THE WARNINGS: what a read says that is not on its card, short of the guard.
+// ---------------------------------------------------------------------------
+
+/**
+ * WHERE A PICKED TAKE SAYS A LINK (post-narration.mjs spokenUrls), pure:
+ * `{ parts: [k…], words: [link…], whole, script }` -- the parts that say one
+ * (k from 0), what they say, and whether each of them is nothing but links
+ * (`whole`: dropping them is the fix, `posts reread … --drop-urls`; else a
+ * re-take). A take read in one go: its script (`script` true, no parts).
+ * Null when it says none.
+ */
+export function urlParts(entry) {
+ const t = pickedTake(entry);
+ if (!t) return null;
+ const parts = Array.isArray(t.parts) ? t.parts : [];
+ if (parts.length) {
+ const hit = parts.map((p, k) => ({ k, urls: spokenUrls(p?.text) })).filter((x) => x.urls.length);
+ if (!hit.length) return null;
+ return { parts: hit.map((x) => x.k), words: hit.flatMap((x) => x.urls), whole: hit.every((x) => isOnlyUrls(parts[x.k].text)), script: false };
+ }
+ const urls = spokenUrls(str(t.script).trim() ? t.script : entry?.narration?.script);
+ return urls.length ? { parts: [], words: urls, whole: false, script: true } : null;
+}
+
+/**
+ * Post item `entry`'s read WARNINGS (the build's lint says them, never
+ * refuses): a take that says a link aloud, with its fix.
+ */
+export function threadReadWarnings(entry) {
+ if (!isNarrated(entry)) return [];
+ const id = entry?.id ?? "?";
+ const out = [];
+ const u = urlParts(entry);
+ if (u) {
+ const said = [...new Set(u.words)].slice(0, 2).map((w) => `"${w.length > 40 ? `${w.slice(0, 39)}…` : w}"`).join(", ");
+ const where = u.script ? "its read says" : `part${u.parts.length === 1 ? "" : "s"} ${u.parts.map((k) => k + 1).join(", ")} of its take say${u.parts.length === 1 ? "s" : ""}`;
+ const fix = u.whole
+ ? `drop ${u.parts.length === 1 ? "it" : "them"} (umtool posts reread <p> ${id} --drop-urls)`
+ : `re-make the take on a script without it (umtool posts narrate <p> ${id} --take; a drafted script drops links)`;
+ out.push(`timeline ${id}: ${where} a link aloud (${said}) -- ${fix}`);
+ }
+ return out;
+}
+
+/** THE WARNINGS over a cut (the build's lint): every narrated post item's (threadReadWarnings). */
+export function validateThreadReadWarnings(manifest) {
+ const tl = Array.isArray(manifest?.timeline) ? manifest.timeline : [];
+ return tl.filter((e) => e?.type === "post").flatMap((e) => threadReadWarnings(e));
+}
+
/**
* THE GUARD over a cut (the build's lint): every post item's read against
* what its card shows (threadReadErrors), each with the item before it.
diff --git a/umtool/report-to-video/post-thread.test.mjs b/umtool/report-to-video/post-thread.test.mjs
@@ -10,6 +10,7 @@ import { validatePostNarrationRender } from "./post-narration.mjs";
import { followPath, followStateAt, followStateKey } from "./read-follow.mjs";
import {
THREAD_DEFAULTS, partRoles, readPieces, threadGeoAt, threadKnobs, threadLayout, threadReadErrors, threadStateAt, tileStateAt, validateThreadReads,
+ threadReadWarnings, urlParts, validateThreadReadWarnings,
} from "./post-thread.mjs";
const PARENT = "The first thing anyone notices is the noise from the street.\n\nThen the lights in the hall go out without warning.\n\nNobody had planned for any of this at all.";
@@ -220,3 +221,18 @@ test("a take read in one go (no parts): its script's paragraphs carry the roles
assert.deepEqual(plan.follow.thread.tiles.map((t) => [t.scope, t.mode]), [["parent:0", "full"], ["post", "full"]]);
assert.deepEqual(threadReadErrors(e), []);
});
+
+test("A READ NEVER SAYS A LINK: a take whose parts say one is warned, with the fix -- drop the parts that are nothing but links, else a re-take", () => {
+ const quoted = { author: "Other", handle: "other", text: `${QUOTED}\n\nhttps://\nweb.archive.org/web/2021032015\n1733/https://twitter.com/x/status/1\n…` };
+ const e = narrate(base({ quoted }), [[`${QUOTED}\n\nhttps://. web.archive.org slash web slash 2021032015. 1733/. …`], [REPLY]]);
+ const u = urlParts(e);
+ assert.deepEqual(u.parts, [1]);
+ assert.equal(u.whole, true);
+ assert.match(threadReadWarnings(e)[0], /timeline p-1: part 2 of its take says a link aloud \("https:\/\/\.", .*umtool posts reread <p> p-1 --drop-urls/);
+ // A link inside words: a re-take.
+ const mixed = narrate(base({ quoted }), [[`${QUOTED} See https://x.com/a/b for more.`], [REPLY]]);
+ assert.match(threadReadWarnings(mixed)[0], /part 1 of its take says a link aloud.*re-make the take/);
+ // None: no warning; over a cut, every narrated post item's.
+ assert.deepEqual(threadReadWarnings(narrate(base({ quoted }), [[QUOTED], [REPLY]])), []);
+ assert.equal(validateThreadReadWarnings({ timeline: [e, base({ id: "p-2" })] }).length, 1);
+});