Skip to content

A local video studio for your coding agent. Describe a video in one sentence: your agent directs, your machine renders. Claude Code, Codex, Cursor, Devin and more. No API keys, no uploads.

showtime 0.3.5

Favio Vázquezc05558f15b25
diff --git a/.claude-plugin/marketplace.json b/.claude-plugin/marketplace.json
index 48c4510..df11311 100644
--- a/.claude-plugin/marketplace.json
+++ b/.claude-plugin/marketplace.json
@@ -5,14 +5,14 @@
},
"metadata": {
"description": "showtime: a local video studio for your coding agent",
- "version": "0.3.4"
+ "version": "0.3.5"
},
"plugins": [
{
"name": "showtime",
"source": "./",
"description": "A local video studio for your coding agent. Describe a video. Your agent directs. Your machine renders. Motion graphics, voice-over, music, footage editing, captions and platform-ready exports, with no cloud AI services or API keys.",
- "version": "0.3.4",
+ "version": "0.3.5",
"author": {
"name": "Favio Vazquez"
},
diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.json
index 7ce870f..09005a3 100644
--- a/.claude-plugin/plugin.json
+++ b/.claude-plugin/plugin.json
@@ -1,6 +1,6 @@
{
"name": "showtime",
- "version": "0.3.4",
+ "version": "0.3.5",
"description": "A local video studio for your coding agent. Describe a video. Your agent directs. Your machine renders. Motion graphics rendered frame-exactly, voice-over, music and sound design, footage editing from transcripts, captions and platform-ready exports. Everything runs on your machine.",
"author": {
"name": "Favio Vazquez"
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3f352bd..93f2d61 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,59 @@ All notable changes to showtime. Each entry says what changed and why, so this f
`skills/showtime/lib/st/__init__.py` and `python3 scripts/check_release.py` keeps the plugin manifests, the registry files and
`setup/package.json` in sync with it.
+## 0.3.5 (2026-10-03)
+
+Fixes found by running showtime in a locked-down agent sandbox (no writable HOME, no local `listen()`, egress only
+through an HTTP proxy, `.env` files unreadable), plus a Windows race the push CI caught.
+
+- **onnxruntime's telemetry was on, while PRIVACY.md says showtime has none.** The onnxruntime that Kokoro,
+ alignment, stem separation, rembg and faster-whisper load on Linux (1.30) carries Microsoft's telemetry client and
+ starts it at import; where HOME is read-only it logged "Failed to persist telemetry device ID" and wrote a
+ `:memory:.ses` session file into the current folder. Every showtime process and its children now get
+ `ORT_DISABLE_TELEMETRY=1` (set by `st` itself and by the launcher, unless already set), and
+ `onnxruntime.disable_telemetry_events()` is called before each model loads. PRIVACY.md says which libraries'
+ telemetry showtime turns off and how.
+- **Site capture turned its private-address guard off for a site whose name did not resolve.** 0.3.3 made
+ `hostIsPrivate` fail closed, but `site capture` still used it to decide whether a page's assets may come from
+ private addresses, so a public site that does not resolve locally (the normal case on a proxy-only network) let
+ them. Only a `file:` page or a page on a known private host allows that now (`privateAssetsAllowed` in `capture.mjs`).
+- **Node downloads ignored HTTPS_PROXY.** Node's `fetch` and `http(s).request` use the proxy variables only with
+ `NODE_USE_ENV_PROXY=1`, so on a proxy-only network the Python side downloaded and the Node side (icon fetches, site
+ capture's assets) did not. When a proxy variable is set, the launcher gives Node children `NODE_USE_ENV_PROXY=1` and
+ adds `localhost,127.0.0.1,::1` to `NO_PROXY`/`no_proxy` (keeping your entries), so the preview and studio servers'
+ local requests stay local. Node reads the flag from 22.21 (24.5 for `http.request`); `showtime doctor` warns when a
+ proxy is set and Node is older.
+- **Voice could not start when both the showtime home and `$TMPDIR` had long paths, and setup still said it was
+ done.** espeak-ng cannot read a data folder whose path is over about 140 bytes, so showtime copies its data to a
+ short folder first; in sandboxes where the home and `$TMPDIR` are both long (seen at 175-185 bytes) there was none.
+ The copy now falls back to `/tmp/showtime-espeak-<uid>` on macOS and Linux (0700, used only when it is the current
+ user's own); when even that fails, the hint names the path length and the fix. `showtime setup` now runs doctor's
+ espeak-ng self-test, so it fails instead of reporting success with voice broken.
+- **`retime --from-voice` left catalog music at full level under the voice.** Placing the voice ducks music that
+ has no duck, but only `file`, `lib` and `compose` tracks; a `catalog` track (what `audio cut-plan` writes) was
+ skipped. Catalog music now ducks too.
+- **`voice ipa`'s "no lexicon.json" hint read as a flag `voice script` does not have.** It now says that `--project`
+ is `voice ipa`'s flag and that `voice script` reads the `lexicon.json` next to its script, plus any `--lexicon FILE`.
+- **Setup and doctor said "`showtime` is not on PATH yet" when it was.** A skill's own `bin/showtime` on PATH (a
+ plugin's or a checkout's) now counts, not only the `~/.showtime/bin` command.
+- **`brand capture` took the wrong lines from a README that starts with HTML.** On showtime's own README (no H1) the
+ title was a shell comment in a code block and the tagline a bare video URL. The title is now the first H1 outside
+ code (markdown, setext or a multi-line HTML `<h1>`) and the tagline its lead paragraph, skipping URL-only lines,
+ images, badges, comments and captions; prompts to type are no longer listed as install commands, and brand.md for an
+ adopted kit never prints `None`.
+- **`check` reported caption words at their karaoke state.** A caption word sampled while its card faded in, or
+ dimmed before it was spoken, was measured at that opacity (#e9b949 on #17120e came out at 2.98:1 instead of
+ 10.18:1). Caption words are judged at the caption's own opacity, and any text measured at partial opacity is named
+ with it (`#e9b949 at 45% opacity (shows as #765d29) on #17120e`). Real low contrast still fails.
+- **A finished background run on Windows could show as "lost", with no id or command.** Windows refuses to open a
+ file another process is replacing, so `status` and the run's supervisor could collide on `run.json`; the
+ supervisor's failed read then rewrote the file with only its new fields. Reads and replaces now retry for up to 2 s,
+ and a failed read never rewrites the file.
+- **Tests in a sandbox that refuses `listen()` skip instead of failing.** `tests/_listen.py` (`LISTEN_BLOCKED`,
+ `needs_listen`, `skip_if_listen_refused()`, `SHOWTIME_TEST_NO_LISTEN=1` to simulate) is used by every test that
+ serves something; the keelson fixture tests skip when `.env` files are unreadable; test_delight runs alone under `-j`
+ (pty devices).
+
## 0.3.4 (2026-10-02)
- **Frame 0 of a page with CSS animations could show where the animation had got to in real time.**
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 5fe8434..5a21531 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -80,7 +80,9 @@ Longest files start first (timings of the previous run, kept in `~/.showtime/cac
failing file's output is printed in full at the end. A new test
must use temp folders, free ports (port 0) and atomic writes into `~/.showtime/cache`
(`common.part_path` + `os.replace`, `common.cache_lock`); a file that truly cannot share the machine goes
-in `SERIAL` in `run_all.py`, with the reason. `--shard I/N` runs one of N weight-balanced parts of the
+in `SERIAL` in `run_all.py`, with the reason. A test that serves something (its own HTTP server, or
+showtime's: render, check, snap, export, preview) uses `tests/_listen.py`, so it skips in a sandbox that
+refuses `listen()` (`SHOWTIME_TEST_NO_LISTEN=1` simulates one). `--shard I/N` runs one of N weight-balanced parts of the
files (CI splits the fast suite into three jobs per OS this way); the split uses only the file names and
`SHARD_WEIGHTS` in `run_all.py`, so give a new heavy test file a weight there.
diff --git a/PRIVACY.md b/PRIVACY.md
index cb69dba..a9bb837 100644
--- a/PRIVACY.md
+++ b/PRIVACY.md
@@ -3,6 +3,11 @@
showtime is open-source software that runs on your own computer. It has no account, no telemetry and no
server of its own, and it does not collect, store or send your data anywhere.
+Some libraries showtime uses have telemetry of their own, and showtime turns it off for every process it
+starts: onnxruntime (the voice, alignment and background-removal models; `ORT_DISABLE_TELEMETRY=1`, plus
+`onnxruntime.disable_telemetry_events()` before each model loads) and the Hugging Face hub client
+(`HF_HUB_DISABLE_TELEMETRY=1`). It sets these only when they are unset.
+
Your prompts are handled by the coding agent you use (Claude Code, Codex, Cursor, Devin or another), under that
agent's own privacy policy.
diff --git a/gemini-extension.json b/gemini-extension.json
index 271e637..a728d4d 100644
--- a/gemini-extension.json
+++ b/gemini-extension.json
@@ -1,6 +1,6 @@
{
"name": "showtime",
- "version": "0.3.4",
+ "version": "0.3.5",
"description": "A local video studio for your coding agent. Describe a video. Your agent directs. Your machine renders. Motion graphics, voice-over, music, footage editing, captions and platform-ready exports, with no cloud AI services or API keys.",
"mcpServers": {
"showtime": {
diff --git a/packages/npm/package.json b/packages/npm/package.json
index dc2645c..c6f4381 100644
--- a/packages/npm/package.json
+++ b/packages/npm/package.json
@@ -1,6 +1,6 @@
{
"name": "@faviovazquez/showtime-mcp",
- "version": "0.3.4",
+ "version": "0.3.5",
"mcpName": "io.github.FavioVazquez/showtime",
"description": "A local video studio for your coding agent: showtime's MCP server and command line. Describe a video. Your agent directs. Your machine renders.",
"license": "MIT",
diff --git a/plugin.json b/plugin.json
index c9b1740..0a09fe9 100644
--- a/plugin.json
+++ b/plugin.json
@@ -1,7 +1,7 @@
{
"$schema": "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json",
"name": "showtime",
- "version": "0.3.4",
+ "version": "0.3.5",
"description": "A local video studio for your coding agent. Describe a video. Your agent directs. Your machine renders. Motion graphics, voice-over, music, footage editing, captions and platform-ready exports, with no cloud AI services or API keys.",
"author": {
"name": "Favio Vazquez",
diff --git a/server.json b/server.json
index 33ac7c4..d928cb7 100644
--- a/server.json
+++ b/server.json
@@ -3,7 +3,7 @@
"name": "io.github.FavioVazquez/showtime",
"title": "showtime",
"description": "Local video studio for your coding agent: scenes, voice, music and captions, on your machine.",
- "version": "0.3.4",
+ "version": "0.3.5",
"websiteUrl": "https://faviovazquez.github.io/showtime/",
"repository": {
"url": "https://github.com/FavioVazquez/showtime",
@@ -26,7 +26,7 @@
"registryType": "npm",
"registryBaseUrl": "https://registry.npmjs.org",
"identifier": "@faviovazquez/showtime-mcp",
- "version": "0.3.4",
+ "version": "0.3.5",
"runtimeHint": "npx",
"transport": {
"type": "stdio"
diff --git a/skills/showtime/lib/st/__init__.py b/skills/showtime/lib/st/__init__.py
index f8403e5..557d350 100644
--- a/skills/showtime/lib/st/__init__.py
+++ b/skills/showtime/lib/st/__init__.py
@@ -5,4 +5,11 @@ launcher, installer and doctor import (st.platform, st.common, st.ff,
st.doctor) are stdlib-only and Python 3.8+ compatible; everything else runs
inside the showtime virtualenv (~/.showtime/venv, Python 3.12).
"""
-__version__ = "0.3.4"
+import os
+
+__version__ = "0.3.5"
+
+# onnxruntime (Kokoro, alignment, stem separation, rembg) ships Microsoft's telemetry client on Linux
+# and starts it at import; this turns it off for every process that imports st, and for its children.
+# The launcher sets it too (build_env), for the Node and tool processes that never import st.
+os.environ.setdefault("ORT_DISABLE_TELEMETRY", "1")
diff --git a/skills/showtime/lib/st/assets/cutout.py b/skills/showtime/lib/st/assets/cutout.py
index ef73c17..52bf02c 100644
--- a/skills/showtime/lib/st/assets/cutout.py
+++ b/skills/showtime/lib/st/assets/cutout.py
@@ -25,7 +25,7 @@ import time
from pathlib import Path
from typing import Any, Dict, Optional
-from ..common import ShowtimeError, debug, log, paths, skill_dir
+from ..common import ShowtimeError, debug, log, ort_telemetry_off, paths, skill_dir
from ..platform import IS_MAC
REMBG_SPEC = "rembg==2.0.85"
@@ -126,7 +126,9 @@ def _rembg_cut(src: Path, dst: Path, model: str, mask_only: bool = False) -> Dic
from PIL import Image
warnings.filterwarnings("ignore", category=UserWarning, module=r"numba.*")
+ import onnxruntime # type: ignore
from rembg import new_session, remove # type: ignore
+ ort_telemetry_off(onnxruntime)
if model not in REMBG_MODELS:
raise ShowtimeError("unknown rembg model %r" % model, hint="models: " + ", ".join(REMBG_MODELS))
diff --git a/skills/showtime/lib/st/brand/capture.py b/skills/showtime/lib/st/brand/capture.py
index d80f3a7..5880453 100644
--- a/skills/showtime/lib/st/brand/capture.py
+++ b/skills/showtime/lib/st/brand/capture.py
@@ -86,6 +86,61 @@ def _split_comment(line: str) -> Tuple[str, Optional[str]]:
return line.strip(), None
+def _masked(md: str) -> str:
+ """The README with its fenced code blanked (same line count): a `# comment` in a shell block is not a heading."""
+ out: List[str] = []
+ in_code = False
+ for line in md.splitlines():
+ if line.strip().startswith(("```", "~~~")):
+ in_code = not in_code
+ out.append("")
+ else:
+ out.append("" if in_code else line)
+ return "\n".join(out)
+
+
+def _plain(text: str) -> str:
+ """Markdown/HTML as it reads: images, badges, comments and fine print (<sub>, <small>) dropped, links kept
+ as their words, tags and emphasis removed."""
+ t = re.sub(r"<!--.*?-->|<(sub|sup|small)\b[^>]*>.*?</\1\s*>", " ", text, flags=re.S | re.I)
+ t = re.sub(r"<[^>]*>|!\[[^\]]*\]\([^)]*\)", " ", t)
+ t = re.sub(r"\[([^\]]*)\]\([^)]*\)", r"\1", t)
+ return re.sub(r"\s+", " ", re.sub(r"[`*_]", "", t)).strip()
+
+
+def readme_title(md: str) -> Optional[Tuple[str, int, int]]:
+ """The README's first H1 outside code (`# name`, `name` over `===`, or an HTML <h1>, which can span lines):
+ (text, first line, last line). A deeper heading is never the title."""
+ masked = _masked(md)
+ found = []
+ for rx in (r"^#[ \t]+(.+?)(?:[ \t]+#+)?[ \t]*$",r"^(\S[^\n]*)\n=+[ \t]*$", r"<h1\b[^>]*>(.*?)</h1\s*>"):
+ found += [(m.start(), m.end(), m.group(1)) for m in re.finditer(rx, masked, re.M | re.S | re.I)]
+ for start, end, inner in sorted(found):
+ text = _plain(inner)
+ if text:
+ return text, masked.count("\n", 0, start) + 1, masked.count("\n", 0, end) + 1
+ return None
+
+
+def readme_lead(md: str, after: int = 0) -> Optional[Tuple[str, int]]:
+ """The first plain paragraph below line `after`: (text, line). Lines that are only a URL, and paragraphs
+ that are only images, badges or fine print, are skipped; so are lists, quotes, tables, code and headings."""
+ para: List[Tuple[str, int]] = []
+ for i, line in enumerate(_masked(md).splitlines() + [""], 1):
+ s = line.strip()
+ if i <= after or re.match(r"^<?https?://\S+>?$", s):
+ continue
+ if s and not s.startswith("#"):
+ para.append((s, i))
+ continue
+ text = _plain("\n".join(x for x, _ in para))
+ first = next(((x, n) for x, n in para if _plain(x)), None)
+ para = []
+ if first and len(text) >= 20 and not re.match(r"^(>|\||[-*+]\s|\d+[.)]\s|\[!\w+\])", first[0]):
+ return text, first[1]
+ return None
+
+
def readme_copy(root: Path, name: str) -> Dict[str, Any]:
"""The product's own words from its README, each with file:line: the title, the one-line tagline,
the install command, the usage commands and the feature bullets. Verbatim, never rephrased."""
@@ -94,35 +149,13 @@ def readme_copy(root: Path, name: str) -> Dict[str, Any]:
return {}
rel = p.name if p else "README"
out: Dict[str, Any] = {"source": rel}
- lines = md.splitlines()
- for i, line in enumerate(lines, 1):
- m = re.match(r"^#\s+(.+)$", line)
- if m:
- out["title"] = {"text": re.sub(r"[`*_]|!\[.*?\]\(.*?\)|\[([^\]]*)\]\([^)]*\)", r"\1", m.group(1)).strip(),
- "source": "%s:%d" % (rel, i)}
- break
- # tagline: the first plain paragraph (not a badge row, a list, a quote or code)
- in_code = False
- para: List[Tuple[str, int]] = []
- for i, line in enumerate(lines + [""], 1):
- s = line.strip()
- if s.startswith("```"):
- in_code = not in_code
- continue
- if in_code:
- continue
- if not s:
- if para:
- text = " ".join(x for x, _ in para)
- if len(text) >= 20 and not text.startswith(("#", "!", "[!", "<", "|", "-", "*", ">")):
- out["tagline"] = {"text": re.sub(r"[`*_]", "", text), "source": "%s:%d" % (rel, para[0][1])}
- break
- para = []
- continue
- if s.startswith("#"):
- para = []
- continue
- para.append((s, i))
+ title = readme_title(md)
+ if title:
+ out["title"] = {"text": title[0], "source": "%s:%d" % (rel, title[1])}
+ # tagline: the title's lead paragraph (the first plain one when there is no H1)
+ lead = readme_lead(md, title[2] if title else 0)
+ if lead:
+ out["tagline"] = {"text": lead[0], "source": "%s:%d" % (rel, lead[1])}
installs: List[Dict[str, Any]] = []
commands: List[Dict[str, Any]] = []
features: List[Dict[str, Any]] = []
@@ -132,8 +165,9 @@ def readme_copy(root: Path, name: str) -> Dict[str, Any]:
for line, ln in _code_lines(body, start):
cmd, comment = _split_comment(line.lstrip("$ ").rstrip())
item = {"command": cmd, "comment": comment, "line": line.strip(), "source": "%s:%d" % (rel, ln)}
+ # in an install section any line counts, but a shell comment or a sentence (a prompt to type) does not
if INSTALL_RX.match(cmd) or re.search(r"install|getting started|setup|quick ?start", h) and len(installs) < 3 \
- and not (tool and cmd.lower().startswith(tool + " ")):
+ and not (tool and cmd.lower().startswith(tool + " ")) and not re.match(r"^#|^[A-Z]\S*\s.*[.!?]$", cmd):
if not any(x["command"] == cmd for x in installs):
installs.append(item)
elif tool and re.search(r"(^|[\s|/])%s(\s|$)" % re.escape(tool), cmd.lower()):
@@ -488,7 +522,7 @@ def storyboard_md(kit: Dict[str, Any], base_md: str) -> str:
if wm:
parts = " + ".join("\"%s\" in %s%s" % (r["text"], r.get("role") or "ink",
" %s" % r["color"] if r.get("color") else "") for r in wm.get("runs") or [])
- L.append("- **Wordmark**: %s (%s). Set the name this way on the end card." % (parts, wm.get("source")))
+ L.append("- **Wordmark**: %s%s. Set the name this way on the end card." % (parts, _src(wm)))
if pal:
L.append("- **Ground and accent**: bg `%s`, ink `%s`, accent `%s`%s. One ground for the film, the accent on the "
"key word, the prompt and the result line only." % (pal.get("bg", "?"), pal.get("ink", "?"), pal.get("accent", "?"),
@@ -498,9 +532,9 @@ def storyboard_md(kit: Dict[str, Any], base_md: str) -> str:
"" if contrast(pal["bg"], pal["accent"]) >= 4.5 else
" (below 4.5:1: `brand apply` deepens it for text, keeping the hue)"))
code = kit.get("code")
- if code:
- L.append("- **Terminal / code look**: `%s` text on `%s` (%s). The product window uses it." % (
- code.get("fg"), code.get("bg"), code.get("source")))
+ if code and code.get("fg") and code.get("bg"):
+ L.append("- **Terminal / code look**: `%s` text on `%s`%s. The product window uses it." % (
+ code["fg"], code["bg"], _src(code)))
fonts = kit.get("fonts") or {}
if not fonts:
L.append("- **Type**: the product uses a system font stack; the film uses the template's Geist + Geist Mono "
diff --git a/skills/showtime/lib/st/brand/draft.py b/skills/showtime/lib/st/brand/draft.py
index a6fc488..56c2114 100644
--- a/skills/showtime/lib/st/brand/draft.py
+++ b/skills/showtime/lib/st/brand/draft.py
@@ -289,19 +289,12 @@ def _readme(root: Path) -> Tuple[Optional[str], Optional[str], str]:
for name in ("README.md", "readme.md", "README.markdown", "README.rst", "README.txt", "README"):
p = root / name
if p.is_file():
+ from .capture import readme_lead, readme_title
txt = _read(p)
- title = None
- m = re.search(r"^#\s+(.+)$", txt, re.M)
- if m:
- title = re.sub(r"[`*_\[\]<>]|!\[.*?\]\(.*?\)|\(.*?\)", "", m.group(1)).strip() or None
- tagline = None
- for para in re.split(r"\n\s*\n", txt):
- s = para.strip()
- if not s or s.startswith(("#", "!", "[!", "<", "```", "|", "-", "*", ">")) or len(s) < 25:
- continue
- tagline = re.sub(r"\s+", " ", re.sub(r"[`*_]|\[([^\]]+)\]\([^)]*\)", r"\1", s))[:200]
- break
- return title, tagline, txt[:20000]
+ # the first H1 outside code and its lead paragraph (URL-only lines, images and badges skipped)
+ head = readme_title(txt)
+ lead = readme_lead(txt, head[2] if head else 0)
+ return head[0] if head else None, lead[0][:200] if lead else None, txt[:20000]
return None, None, ""
@@ -606,11 +599,17 @@ def relativize(kit: Dict[str, Any], dest_dir: Path) -> Dict[str, Any]:
def brand_md(kit: Dict[str, Any], json_name: str = "brand.json") -> str:
pal = palette(kit)
+ src = kit.get("source") or {}
+ if kit.get("adopted_from"):
+ # the repo's own brand.json has no draft fields (source, drafted, voice, how a font was found)
+ made = "The repo's own kit, adopted from `%s`." % kit["adopted_from"]
+ else:
+ made = "Draft made by `showtime brand init`%s%s." % (
+ " from %s `%s`" % (src.get("kind") or "source", src["path"]) if src.get("path") else "",
+ " on %s" % str(kit["drafted"])[:10] if kit.get("drafted") else "")
L = ["# Brand kit: %s" % kit.get("name"), "",
- "Draft made by `showtime brand init` from %s `%s` on %s. **Everything here is inferred**: state it as "
- "assumptions (quick mode) or show it on the look board (studio), and edit %s to correct it (this file is "
- "the human summary)." % (
- (kit.get("source") or {}).get("kind"), (kit.get("source") or {}).get("path"), (kit.get("drafted") or "")[:10], json_name), ""]
+ "%s **Everything here is inferred**: state it as assumptions (quick mode) or show it on the look board "
+ "(studio), and edit %s to correct it (this file is the human summary)." % (made, json_name), ""]
if kit.get("tagline"):
L += ["Tagline: %s" % kit["tagline"], ""]
L += ["## Logo", ""]
@@ -624,11 +623,17 @@ def brand_md(kit: Dict[str, Any], json_name: str = "brand.json") -> str:
L += ["", "## Fonts", ""]
for slot, f in (kit.get("fonts") or {}).items():
st = "installed" if f.get("installed") else ("install: `%s`" % f["install"] if f.get("install") else f.get("note") or "")
- L.append("- %s: **%s** (%s; %s) %s" % (slot, f.get("family"), f.get("how"), f.get("license") or "license unknown", st))
+ L.append(("- %s: **%s** (%s) %s" % (slot, f.get("family"), "; ".join(
+ x for x in (f.get("how"), f.get("license") or "license unknown") if x), st)).rstrip())
if not kit.get("fonts"):
L.append("- none found: the theme fonts will be used")
v = kit.get("voice") or {}
- L += ["", "## Voice", "", "- `%s` at speed %s (%s)" % (v.get("id"), v.get("speed"), v.get("note", ""))]
+ L += ["", "## Voice", ""]
+ if v.get("id"):
+ L.append("- `%s`%s%s" % (v["id"], " at speed %s" % v["speed"] if v.get("speed") else "",
+ " (%s)" % v["note"] if v.get("note") else ""))
+ else:
+ L.append("- none set: showtime's default voice (audition with `showtime voice list` and `showtime voice say`)")
L += ["", "## Pronunciations", ""]
if kit.get("pronunciations"):
for w, say in kit["pronunciations"].items():
diff --git a/skills/showtime/lib/st/cli_core.py b/skills/showtime/lib/st/cli_core.py
index 10d93b4..e96f0a4 100644
--- a/skills/showtime/lib/st/cli_core.py
+++ b/skills/showtime/lib/st/cli_core.py
@@ -1493,7 +1493,9 @@ def _voice_tracks(spec: Dict[str, Any], voice: Dict[str, Any], rep: Dict[str, An
% ", ".join(str(t.get("file") or t.get("id")) for t in others[:3]))
ducked = 0
for t in kept:
- if isinstance(t, dict) and t.get("kind", "music") == "music" and "duck" not in t and (t.get("file") or t.get("lib") or t.get("compose")):
+ # every music source of a mix (audio/mix.py); synth, keystrokes and typewriter are effects
+ if isinstance(t, dict) and t.get("kind", "music") == "music" and "duck" not in t and \
+ any(t.get(k) for k in ("file", "lib", "catalog", "compose")):
t["duck"] = {"under": "voice"}
ducked += 1
rep["changes"].append("voice: %d line(s) placed on their scenes (%s)%s" % (
diff --git a/skills/showtime/lib/st/cli_voice.py b/skills/showtime/lib/st/cli_voice.py
index fd14248..43c4968 100644
--- a/skills/showtime/lib/st/cli_voice.py
+++ b/skills/showtime/lib/st/cli_voice.py
@@ -203,8 +203,9 @@ def register(sub: argparse._SubParsersAction) -> None:
p = s.add_parser("ipa", help="show phonemes for text (for pronunciation fixes)", formatter_class=_F,
description="Print the IPA espeak-ng produces per word, and what the lexicon overrides; the\n"
"phrase line is what the voice reads, overrides included. Copy a line into\n"
- "lexicon.json and edit it to fix a pronunciation. The project's lexicon.json is found\n"
- "like `voice script` finds it (see --project).",
+ "lexicon.json and edit it to fix a pronunciation. The lexicon.json read is the one in\n"
+ "the current folder (or its one sub-folder that has one), or in --project; `voice\n"
+ "script` reads the one next to its script or one folder up.",
epilog="Examples:\n showtime voice ipa \"Showtime runs on Kubernetes\"\n"
" showtime voice ipa \"Te presentamos Showtime\" --lang es")
p.add_argument("text", help="words to phonemize (inline [word](/ipa/) and [word](respelling) work too)")
@@ -527,8 +528,9 @@ def cmd_ipa(args: argparse.Namespace) -> int:
fix = (" lexicon -> %s" % r["lexicon"]) if r["lexicon"] else ""
print("%-18s %-28s%s%s" % (r["word"], r["espeak"], fix, extra))
print("\nphrase: %s%s" % (whole, " (with the lexicon)" if any(r["lexicon"] for r in rows) else ""))
- print("lexicon: %s" % (", ".join(used) if used else "built-in only (no lexicon.json in %s; pass --project or "
- "--lexicon)" % pdir), file=sys.stderr)
+ print("lexicon: %s" % (", ".join(used) if used else "built-in only (no lexicon.json in %s; `voice ipa --project DIR` "
+ "reads DIR's, --lexicon FILE adds one; `voice script` reads the lexicon.json next to its "
+ "script or one folder up)" % pdir), file=sys.stderr)
print("lexicon entry format: {\"%s\": \"%s\"}" % (rows[0]["word"], rows[0]["lexicon"] or rows[0]["espeak"]),
file=sys.stderr)
return 0
diff --git a/skills/showtime/lib/st/common.py b/skills/showtime/lib/st/common.py
index 56998c0..8119159 100644
--- a/skills/showtime/lib/st/common.py
+++ b/skills/showtime/lib/st/common.py
@@ -8,7 +8,7 @@ before the virtualenv exists). Provides:
- process: run() with argument lists only, RunError with a stderr tail
- json: read_json(), write_json() (atomic), print_json()
- output: slugify(), timestamp(), output_dir()
-- misc: ShowtimeError, sha256_file(), human_size(), ensure_dir()
+- misc: ShowtimeError, sha256_file(), human_size(), ensure_dir(), ort_telemetry_off()
- ux: use_color(), paint(), Progress (n/N, rate, ETA), estimate(),
fmt_duration(), extra_installed(), require_extra(), debug_enabled()
"""
@@ -38,7 +38,7 @@ __all__ = [
"get_logger", "run", "read_json", "write_json", "print_json", "slugify",
"timestamp", "output_dir", "sha256_file", "human_size", "which", "portable_path", "resolve_portable",
"use_color", "paint", "Progress", "estimate", "fmt_duration", "extra_info", "extra_installed",
- "require_extra", "debug_enabled",
+ "require_extra", "debug_enabled", "ort_telemetry_off",
]
@@ -175,6 +175,18 @@ def which(name: str) -> Optional[str]:
return plat.which(name, [home() / "bin"])
+def ort_telemetry_off(rt: Any) -> None:
+ """Turn off onnxruntime's telemetry events (rt: the imported onnxruntime module) before a session is
+ made. A second guard behind ORT_DISABLE_TELEMETRY=1 (st/__init__.py, launcher.build_env), for a
+ process that started onnxruntime without it; builds without the call are left as they are."""
+ off = getattr(rt, "disable_telemetry_events", None)
+ if off is not None:
+ try:
+ off()
+ except Exception: # noqa: BLE001 - never stop a voice or a cutout over this
+ pass
+
+
# --------------------------------------------------------------------------
# Logging (stderr; stdout stays clean for JSON output)
# --------------------------------------------------------------------------
diff --git a/skills/showtime/lib/st/doctor.py b/skills/showtime/lib/st/doctor.py
index 531cd36..a7e4118 100644
--- a/skills/showtime/lib/st/doctor.py
+++ b/skills/showtime/lib/st/doctor.py
@@ -194,6 +194,15 @@ class Live:
self._write("showtime doctor: still %s, %s so far\n" % (what, fmt_duration(el)))
+PROXY_VARS = ("HTTPS_PROXY", "https_proxy", "HTTP_PROXY", "http_proxy")
+
+
+def node_ignores_proxy(ver: Tuple[int, ...]) -> bool:
+ """True for a Node.js that ignores NODE_USE_ENV_PROXY in fetch and http.request (before 22.21, and 23.x-24.4)."""
+ v = tuple(ver) + (0, 0)
+ return v[:2] < (22, 21) or (23, 0) <= v[:2] < (24, 5)
+
+
class Doctor:
def __init__(self, args: argparse.Namespace) -> None:
self.args = args
@@ -529,6 +538,11 @@ class Doctor:
self.add("node", FAIL, "Node.js %s at %s is too old" % (vs, node), "install Node.js 24 or 22 LTS (20+)")
else:
self.add("node", PASS, "v%s at %s" % (vs, node))
+ if node_ignores_proxy(ver) and any(os.environ.get(k) for k in PROXY_VARS):
+ # the launcher sets NODE_USE_ENV_PROXY=1, which Node reads only from 22.21 (24.5 for http.request)
+ self.add("node proxy", WARN, "a proxy is set, but Node.js %s does not use HTTPS_PROXY/HTTP_PROXY: "
+ "icon and site-capture downloads from Node will fail on a proxy-only network" % vs,
+ "install Node.js 24 or 22 LTS (22.21 or later)")
pkg = self.p["setup"] / "package.json"
nm = self.p["node_modules"]
try:
@@ -687,12 +701,7 @@ class Doctor:
("system %s" % esp) if esp else "not checked (the voice module or the venv is missing)",
"" if esp else "run `showtime setup`")
return
- code = ("import json\nfrom st.common import ShowtimeError\n"
- "try:\n from st.voice.espeak import resolve\n lib, data, src = resolve()\n"
- " print(json.dumps({'ok': True, 'lib': lib, 'data': data, 'source': src}))\n"
- "except ShowtimeError as e:\n"
- " print(json.dumps({'ok': False, 'error': e.message if hasattr(e, 'message') else str(e),"
- " 'hint': getattr(e, 'hint', None)}))\n")
+ code = "import json\nfrom st.voice.espeak import check\nprint(json.dumps(check()))\n"
env = dict(os.environ)
env["PYTHONPATH"] = str(self.p["skill"] / "lib")
try:
diff --git a/skills/showtime/lib/st/footage/separate.py b/skills/showtime/lib/st/footage/separate.py
index 56c8352..56d28a8 100644
--- a/skills/showtime/lib/st/footage/separate.py
+++ b/skills/showtime/lib/st/footage/separate.py
@@ -16,7 +16,7 @@ import time
from pathlib import Path
from typing import Any, Dict, List, Optional, Sequence, Tuple
-from ..common import ShowtimeError, debug, info
+from ..common import ShowtimeError, debug, info, ort_telemetry_off
from .. import platform as plat
from . import util as U
@@ -135,6 +135,7 @@ def _istft(spec, n_fft: int, hop: int, window, length: int):
def _session(model: Path, threads: int):
import onnxruntime as ort
+ ort_telemetry_off(ort)
so = ort.SessionOptions()
so.intra_op_num_threads = max(1, threads)
so.inter_op_num_threads = 1
diff --git a/skills/showtime/lib/st/footage/transcribe.py b/skills/showtime/lib/st/footage/transcribe.py
index 44d1ba1..c299de9 100644
--- a/skills/showtime/lib/st/footage/transcribe.py
+++ b/skills/showtime/lib/st/footage/transcribe.py
@@ -34,7 +34,7 @@ from pathlib import Path
from typing import Any, Dict, List, Optional, Sequence, Tuple
from .. import platform as plat
-from ..common import ShowtimeError, debug, info, paths, read_json, warn, write_json
+from ..common import ShowtimeError, debug, info, ort_telemetry_off, paths, read_json, warn, write_json
from . import TRANSCRIPT_VERSION
from . import util as U
from .asr_models import PARAKEET_V3_LANGS
@@ -222,7 +222,9 @@ def _whisper_model(name: str, threads: int):
key = "w:%s:%d" % (name, threads)
if key not in _MODEL_CACHE:
d = _ensure_whisper(name)
+ import onnxruntime # faster-whisper's VAD is an onnxruntime session
from faster_whisper import WhisperModel
+ ort_telemetry_off(onnxruntime)
device = os.environ.get("SHOWTIME_ASR_DEVICE", "cpu")
compute = os.environ.get("SHOWTIME_ASR_COMPUTE", "int8" if device == "cpu" else "float16")
t0 = _announce_load("whisper", name)
diff --git a/skills/showtime/lib/st/launcher.py b/skills/showtime/lib/st/launcher.py
index 1d00787..76f7b79 100644
--- a/skills/showtime/lib/st/launcher.py
+++ b/skills/showtime/lib/st/launcher.py
@@ -15,7 +15,9 @@ Environment exported to every child process:
SHOWTIME_HOME, SHOWTIME_SKILL, SHOWTIME_PYTHON (venv python), SHOWTIME_NODE_MODULES,
PATH (~/.showtime/bin and the venv's bin first), PYTHONPATH (+SKILL/lib),
HF_HOME (~/.showtime/models/hf), PLAYWRIGHT_BROWSERS_PATH (~/.showtime/browsers),
- NODE_PATH, SUPERTONIC_CACHE_DIR, U2NET_HOME, PYTHONUTF8=1, and the saved plugin
+ NODE_PATH, SUPERTONIC_CACHE_DIR, U2NET_HOME, PYTHONUTF8=1, HF_HUB_DISABLE_TELEMETRY=1 and
+ ORT_DISABLE_TELEMETRY=1 (unless set), NODE_USE_ENV_PROXY=1 and loopback NO_PROXY entries when a
+ proxy is set (node_proxy_env), and the saved plugin
settings (SHOWTIME_VOICE, SHOWTIME_LANG, SHOWTIME_OPEN_BROWSER, SHOWTIME_MAX_WORKERS,
SHOWTIME_THREADS, SHOWTIME_SOUND) unless those are already set; see settings_file().
@@ -324,6 +326,32 @@ def cache_redirects(home: Path, env: dict) -> dict:
return out
+LOOPBACK = ("localhost", "127.0.0.1", "::1")
+
+
+def node_proxy_env(env: dict) -> dict:
+ """What a proxy needs on the Node side ({} when no HTTPS_PROXY / HTTP_PROXY is set). Python's downloads
+ follow those variables by themselves; Node's fetch and http(s).request ignore them unless
+ NODE_USE_ENV_PROXY=1 (Node 24+ and 22.21+; http(s).request from 24.5), so behind a proxy-only network
+ (an agent sandbox's egress proxy) every Node download failed. With it on, Node sends loopback requests
+ (the preview and studio servers, a captured local site) to the proxy too unless NO_PROXY names them:
+ they are added to NO_PROXY and no_proxy (Node and Python read the lowercase one first), keeping what is
+ there. NODE_USE_ENV_PROXY already set (0 turns it off) is left alone."""
+ if not any(env.get(v) for v in ("HTTPS_PROXY", "https_proxy", "HTTP_PROXY", "http_proxy")):
+ return {}
+ if env.get("NODE_USE_ENV_PROXY", "1") != "1":
+ return {}
+ out = {} if env.get("NODE_USE_ENV_PROXY") else {"NODE_USE_ENV_PROXY": "1"}
+ names = ("NO_PROXY",) if plat.IS_WINDOWS else ("no_proxy", "NO_PROXY") # Windows: one, case-insensitive
+ have = [n for n in names if env.get(n)]
+ for n in names:
+ parts = [p.strip() for p in (env.get(n) or (env[have[0]] if have else "")).split(",") if p.strip()]
+ add = [h for h in LOOPBACK if h not in [p.lower() for p in parts]]
+ if add or n not in have:
+ out[n] = ",".join(parts + add)
+ return out
+
+
def build_env(home: Path) -> dict:
env = dict(os.environ)
venv = home / "venv"
@@ -367,12 +395,14 @@ def build_env(home: Path) -> dict:
if ours.is_file():
env.setdefault("IMAGEIO_FFMPEG_EXE", str(ours))
env.setdefault("HF_HUB_DISABLE_TELEMETRY", "1")
+ env.setdefault("ORT_DISABLE_TELEMETRY", "1") # onnxruntime's own telemetry client (st/__init__.py)
env.setdefault("HF_HUB_DISABLE_SYMLINKS_WARNING", "1")
env.setdefault("PLAYWRIGHT_BROWSERS_PATH", str(home / "browsers"))
env.setdefault("SUPERTONIC_CACHE_DIR", str(home / "models" / "supertonic3"))
env.setdefault("U2NET_HOME", str(home / "models" / "u2net"))
env.setdefault("PYTHONUTF8", "1")
env.setdefault("PYTHONIOENCODING", "utf-8")
+ env.update(node_proxy_env(env))
return env
diff --git a/skills/showtime/lib/st/runs.py b/skills/showtime/lib/st/runs.py
index 3a3efe0..fce3254 100644
--- a/skills/showtime/lib/st/runs.py
+++ b/skills/showtime/lib/st/runs.py
@@ -71,11 +71,22 @@ def display(argv: List[str]) -> str:
# --------------------------------------------------------------------------- run records
+# Windows refuses to open a file another process is replacing (and to replace one another process has
+# open), so a reader and the supervisor can collide for a few milliseconds: retry before giving up.
+RETRY_S = 2.0
+
+
def load(run_dir: Path) -> Optional[Dict[str, Any]]:
- try:
- data = json.loads((Path(run_dir) / "run.json").read_text(encoding="utf-8"))
- except (OSError, ValueError):
- return None
+ f = Path(run_dir) / "run.json"
+ t_end = time.time() + RETRY_S
+ while True:
+ try:
+ data = json.loads(f.read_text(encoding="utf-8"))
+ break
+ except (OSError, ValueError):
+ if not f.exists() or time.time() > t_end:
+ return None
+ time.sleep(0.05)
if not isinstance(data, dict):
return None
data["dir"] = str(run_dir)
@@ -87,11 +98,25 @@ def save(run_dir: Path, data: Dict[str, Any]) -> None:
body = {k: v for k, v in data.items() if k not in ("dir", "log")}
tmp = Path(run_dir) / (".run.json.%d.tmp" % os.getpid())
tmp.write_text(json.dumps(body, indent=2) + "\n", encoding="utf-8")
- os.replace(str(tmp), str(Path(run_dir) / "run.json"))
+ t_end = time.time() + RETRY_S
+ while True:
+ try:
+ os.replace(str(tmp), str(Path(run_dir) / "run.json"))
+ return
+ except PermissionError:
+ if time.time() > t_end:
+ raise
+ time.sleep(0.05)
def update(run_dir: Path, **fields: Any) -> Dict[str, Any]:
- data = load(run_dir) or {}
+ data = load(run_dir)
+ if data is None:
+ if (Path(run_dir) / "run.json").exists():
+ # unreadable even after retrying: writing only `fields` would drop the run's id, command and
+ # folder, and `status` would then call it lost
+ raise OSError("cannot read %s" % (Path(run_dir) / "run.json"))
+ data = {}
data.update(fields)
save(run_dir, data)
return data
diff --git a/skills/showtime/lib/st/shim.py b/skills/showtime/lib/st/shim.py
index 3a97b14..bbb8a8a 100644
--- a/skills/showtime/lib/st/shim.py
+++ b/skills/showtime/lib/st/shim.py
@@ -487,10 +487,23 @@ def on_path(home: Path) -> bool:
return False
+def launcher_on_path(home: Path) -> bool:
+ """True when `showtime` on the user's PATH is a showtime launcher: this home's, or a skill's own bin/showtime
+ (a plugin or a checkout put on PATH)."""
+ import shutil
+ if on_path(home):
+ return True
+ found = shutil.which("showtime", path=user_path() or None)
+ try:
+ return bool(found) and valid_skill(Path(found).resolve().parent.parent)
+ except OSError:
+ return False
+
+
def path_hint(home: Path) -> List[str]:
"""Lines telling the user how to call `showtime` from anywhere (empty when it already works)."""
home = Path(home)
- if on_path(home):
+ if launcher_on_path(home):
return []
shim = shim_path(home)
if os.name == "nt":
diff --git a/skills/showtime/lib/st/voice/align.py b/skills/showtime/lib/st/voice/align.py
index fb84cd0..462e9e8 100644
--- a/skills/showtime/lib/st/voice/align.py
+++ b/skills/showtime/lib/st/voice/align.py
@@ -28,7 +28,7 @@ from typing import Any, Dict, List, Optional, Sequence, Tuple, Union
import numpy as np
-from ..common import ShowtimeError, debug, info, warn
+from ..common import ShowtimeError, debug, info, ort_telemetry_off, warn
from . import audio_io as aio
from . import models
from .textnorm import Token, base_lang, en_number, normalize_tokens, plain_text, tokenize
@@ -142,6 +142,7 @@ def _w2v_session(allow_download: bool = True):
return None, None
import json
import onnxruntime as rt
+ ort_telemetry_off(rt)
so = rt.SessionOptions()
so.log_severity_level = 3
thr = os.environ.get("SHOWTIME_THREADS")
diff --git a/skills/showtime/lib/st/voice/engines/kokoro.py b/skills/showtime/lib/st/voice/engines/kokoro.py
index dd11f24..bee6bcc 100644
--- a/skills/showtime/lib/st/voice/engines/kokoro.py
+++ b/skills/showtime/lib/st/voice/engines/kokoro.py
@@ -22,7 +22,7 @@ from typing import Any, Dict, List, Optional, Tuple
import numpy as np
-from ...common import ShowtimeError, debug
+from ...common import ShowtimeError, debug, ort_telemetry_off
from .. import espeak, models
from ..textnorm import Token
from ..voices import VoiceSpec
@@ -98,6 +98,7 @@ class KokoroEngine(Engine):
f = models.kokoro_files()
import onnxruntime as rt
from kokoro_onnx import Kokoro
+ ort_telemetry_off(rt)
so = rt.SessionOptions()
n = _threads()
if n:
diff --git a/skills/showtime/lib/st/voice/engines/supertonic.py b/skills/showtime/lib/st/voice/engines/supertonic.py
index 5796f14..54778db 100644
--- a/skills/showtime/lib/st/voice/engines/supertonic.py
+++ b/skills/showtime/lib/st/voice/engines/supertonic.py
@@ -18,7 +18,7 @@ from typing import List, Tuple
import numpy as np
-from ...common import ShowtimeError, paths
+from ...common import ShowtimeError, ort_telemetry_off, paths
from ..textnorm import Token
from ..voices import VoiceSpec
from .base import Engine, EngineResult, check_speed
@@ -61,7 +61,9 @@ class SupertonicEngine(Engine):
ok, why = self.available()
if not ok:
raise ShowtimeError("Supertonic is not ready: " + why, hint="run `showtime setup --with supertonic`")
+ import onnxruntime
from supertonic import TTS
+ ort_telemetry_off(onnxruntime)
thr = os.environ.get("SHOWTIME_THREADS")
self._tts = TTS(model="supertonic-3", model_dir=self.model_dir(), auto_download=False,
intra_op_num_threads=int(thr) if thr and thr.isdigit() else None)
diff --git a/skills/showtime/lib/st/voice/espeak.py b/skills/showtime/lib/st/voice/espeak.py
index ee62fd2..32e9b49 100644
--- a/skills/showtime/lib/st/voice/espeak.py
+++ b/skills/showtime/lib/st/voice/espeak.py
@@ -16,7 +16,9 @@ Resolution order (first candidate whose probe succeeds wins):
3. a system espeak-ng (Homebrew / MacPorts / apt / the Windows installer)
4. the copy bundled in the `espeakng-loader` wheel (all platforms)
A data directory whose path is too long (or non-ASCII on Windows) is copied
-once to a short location first.
+once to a short location first: <home>/cache, %ProgramData% on Windows,
+$TMPDIR, then /tmp/showtime-espeak-<uid> (a 0700 folder of this user) on
+macOS and Linux.
"""
from __future__ import annotations
@@ -25,6 +27,7 @@ import json
import os
import re
import shutil
+import stat
import subprocess
import sys
import tempfile
@@ -36,6 +39,7 @@ from .. import platform as plat
from ..common import ShowtimeError, debug, home, warn
MAX_DATA_PATH = 140 # espeak-ng keeps ~160 bytes incl. "/phontab" etc.
+SHORT_ROOT = "/tmp" # last resort when $SHOWTIME_HOME and $TMPDIR are both long (POSIX)
_lock = threading.RLock()
_ready: Optional[Tuple[str, str, str]] = None # (lib, data, source)
@@ -142,22 +146,59 @@ def _needs_short_copy(data: str) -> bool:
return False
-def _short_copy(data: str) -> Optional[str]:
- """Copy espeak-ng-data to a short (ASCII) path; returns the new path."""
+def _private_dir(d: Path) -> bool:
+ """Make d (in a shared folder such as /tmp) or accept it only as this user's own 0700 directory."""
+ try:
+ os.mkdir(str(d), 0o700)
+ except FileExistsError:
+ pass
+ except OSError as e:
+ debug("could not create %s: %s" % (d, e))
+ return False
+ try:
+ st = os.lstat(str(d))
+ except OSError:
+ return False
+ if not stat.S_ISDIR(st.st_mode) or st.st_uid != os.getuid() or st.st_mode & 0o077:
+ debug("not using %s: not a private directory of this user" % d)
+ return False
+ return True
+
+
+def _shared_short() -> Optional[Path]:
+ """/tmp/showtime-espeak-<uid>/espeak-ng-data (None on Windows: %ProgramData% is short there)."""
+ if plat.os_name() == "windows":
+ return None
+ return Path(SHORT_ROOT) / ("showtime-espeak-%d" % os.getuid()) / "espeak-ng-data"
+
+
+def _short_candidates() -> List[Path]:
cands = [home() / "cache" / "espeak-ng-data"]
if plat.os_name() == "windows":
pd = os.environ.get("ProgramData") or os.environ.get("PUBLIC")
if pd:
cands.append(Path(pd) / "showtime" / "espeak-ng-data")
cands.append(Path(tempfile.gettempdir()) / "showtime-espeak-ng-data")
- for c in cands:
+ shared = _shared_short()
+ return cands + ([shared] if shared else [])
+
+
+def _short_copy(data: str) -> Optional[str]:
+ """Copy espeak-ng-data to a short (ASCII) path; returns the new path."""
+ shared = _shared_short()
+ for c in _short_candidates():
if _needs_short_copy(str(c)):
continue
+ if c == shared and not _private_dir(c.parent):
+ continue
try:
if not (c / "phontab").is_file():
- tmp = c.with_name(c.name + ".part")
+ tmp = c.with_name("%s.part-%d" % (c.name, os.getpid())) # several homes can share this folder
shutil.rmtree(str(tmp), ignore_errors=True)
shutil.copytree(data, str(tmp))
+ if (c / "phontab").is_file(): # another process finished first
+ shutil.rmtree(str(tmp), ignore_errors=True)
+ return str(c)
shutil.rmtree(str(c), ignore_errors=True)
os.replace(str(tmp), str(c))
return str(c)
@@ -307,12 +348,14 @@ def resolve(refresh: bool = False) -> Tuple[str, str, str]:
cache = json.loads(cf.read_text(encoding="utf-8"))
except (OSError, ValueError):
cache = {}
- errors = []
+ errors, too_long = [], []
for lib, data, source in candidates():
if _needs_short_copy(data):
short = _short_copy(data)
if not short:
errors.append("%s: data path too long and could not be copied: %s" % (source, data))
+ if len(os.fsencode(data)) > MAX_DATA_PATH: # (else: non-ASCII on Windows)
+ too_long.append(data)
continue
data = short
fp = _fingerprint(lib, data)
@@ -335,12 +378,31 @@ def resolve(refresh: bool = False) -> Tuple[str, str, str]:
return _ready
warn("espeak-ng %s (%s) failed its self-test: %s" % (source, lib, msg))
errors.append("%s (%s): %s" % (source, lib, msg))
+ if too_long:
+ # re-running setup cannot help: the folders are long, not missing
+ shared = _shared_short()
+ hint = ("espeak-ng cannot read a data folder whose path is longer than %d bytes (this one is %d), and "
+ "no shorter folder to copy it to was usable (SHOWTIME_HOME and TMPDIR are long too%s): point "
+ "SHOWTIME_HOME or TMPDIR at a shorter path, or set SHOWTIME_ESPEAK_LIB and SHOWTIME_ESPEAK_DATA "
+ "to an espeak-ng whose data folder has a short path"
+ % (MAX_DATA_PATH, len(os.fsencode(too_long[0])),
+ ", and %s is not writable or not this user's 0700 folder" % shared.parent if shared else ""))
+ else:
+ hint = ("re-run `showtime setup` (it installs espeakng-loader), or install espeak-ng "
+ "(macOS: brew install espeak-ng; Debian/Ubuntu: sudo apt install espeak-ng; "
+ "Windows: the espeak-ng .msi) or set SHOWTIME_ESPEAK_LIB and SHOWTIME_ESPEAK_DATA")
raise ShowtimeError(
"no working espeak-ng found (Kokoro needs it to turn text into phonemes)" +
- ("\n " + "\n ".join(errors) if errors else ""),
- hint="re-run `showtime setup` (it installs espeakng-loader), or install espeak-ng "
- "(macOS: brew install espeak-ng; Debian/Ubuntu: sudo apt install espeak-ng; "
- "Windows: the espeak-ng .msi) or set SHOWTIME_ESPEAK_LIB and SHOWTIME_ESPEAK_DATA")
+ ("\n " + "\n ".join(errors) if errors else ""), hint=hint)
+
+
+def check(refresh: bool = False) -> Dict[str, object]:
+ """resolve() as JSON-ready data, for doctor and setup (which run it in the venv's Python)."""
+ try:
+ lib, data, source = resolve(refresh=refresh)
+ except ShowtimeError as e:
+ return {"ok": False, "error": e.message, "hint": e.hint}
+ return {"ok": True, "lib": lib, "data": data, "source": source}
_configured = False
diff --git a/skills/showtime/references/voice.md b/skills/showtime/references/voice.md
index 8ca4933..78583d8 100644
--- a/skills/showtime/references/voice.md
+++ b/skills/showtime/references/voice.md
@@ -197,7 +197,7 @@ Kokoro's word times come straight from the model's phoneme durations. The wavefo
## Pronunciation fixes
-1. Run `showtime voice ipa "Kubernetes kubectl" [--lang es]` to see what espeak-ng says for each word. It reads the project's `lexicon.json` like `voice script` does (the current folder, or its one sub-folder with a `lexicon.json`; else `--project <dir>`), shows which lexicon it used, and its `phrase:` line is what the voice reads with the lexicon and inline fixes applied.
+1. Run `showtime voice ipa "Kubernetes kubectl" [--lang es]` to see what espeak-ng says for each word. It reads the `lexicon.json` in the current folder, or its one sub-folder with a `lexicon.json`, or `--project <dir>` (`voice script` has no `--project`: it reads the `lexicon.json` next to its script or one folder up, plus any `--lexicon FILE`), shows which lexicon it used, and its `phrase:` line is what the voice reads with the lexicon and inline fixes applied.
2. Add an entry to `lexicon.json` next to the script or project, or under `"pronunciations"` in `brand.json`:
```json
@@ -286,7 +286,7 @@ Tips:
## Platform notes and troubleshooting
- **espeak-ng.** showtime uses a system espeak-ng when one is found (Homebrew or MacPorts on macOS, `apt install espeak-ng` on Linux, the `.msi` on Windows). Otherwise it uses the copy inside the `espeakng-loader` wheel, which exists for macOS arm64/x64, Linux x64/arm64 and Windows x64/arm64. Each candidate is tested once in a child process, because a broken espeak kills its process.
- - A data path over ~140 bytes, or a non-ASCII path on Windows, is copied once to a short folder. This avoids a known espeak-ng path-buffer bug.
+ - A data path over ~140 bytes, or a non-ASCII path on Windows, is copied once to a short folder: `<home>/cache`, `%ProgramData%` on Windows, `$TMPDIR`, then `/tmp/showtime-espeak-<uid>` (your own 0700 folder) on macOS and Linux. This avoids a known espeak-ng path-buffer bug. `showtime setup` runs the same self-test as `showtime doctor`, so it fails when no candidate works.
- To force a choice, set `SHOWTIME_ESPEAK=bundled|system`, or give exact paths with `SHOWTIME_ESPEAK_LIB` and `SHOWTIME_ESPEAK_DATA`.
| Symptom | Fix |
diff --git a/skills/showtime/scripts/check.mjs b/skills/showtime/scripts/check.mjs
index 9382d74..c355b4a 100644
--- a/skills/showtime/scripts/check.mjs
+++ b/skills/showtime/scripts/check.mjs
@@ -598,7 +598,7 @@ async function main() {
// hiding the text changed nothing here: the glyphs are pixels of a canvas, image or
// transition layer, so their contrast cannot be measured this way
if (moved[i] !== null && moved[i] < 1.5) { unmeasured.add(l.bid); return; }
- const alpha = l.opacity * l.color[3];
+ const alpha = (l.readOpacity ?? l.opacity) * l.color[3];
const fgMed = blend(l.color.slice(0, 3), alpha, s.median);
const ratio = contrast(fgMed, s.median);
const worst = Math.min(ratio, contrast(blend(l.color.slice(0, 3), alpha, s.p10), s.p10), contrast(blend(l.color.slice(0, 3), alpha, s.p90), s.p90));
@@ -610,7 +610,7 @@ async function main() {
const tw = inTx(st);
const settled = Math.round(alpha * 20) / 20 - (l.blurred ? 1 : 0) - (tw ? 0.5 : 0) - (l.entering ? 0.4 : 0);
const prev = contrastWorst.get(l.lid);
- if (!prev || settled > prev.settled || (settled === prev.settled && ratio < prev.ratio)) contrastWorst.set(l.lid, { settled, entering: !!l.entering, bid: l.bid, ratio, worst, need, t: st, tx: tw, fg: hex(l.color.slice(0, 3)), bg: hex(s.median), sel: l.sel, text: blockSeen.get(l.bid) ? blockSeen.get(l.bid).text : '', own: l.own || '', outlined: l.outlined, size: eff, decor: l.decor });
+ if (!prev || settled > prev.settled || (settled === prev.settled && ratio < prev.ratio)) contrastWorst.set(l.lid, { settled, entering: !!l.entering, bid: l.bid, ratio, worst, need, t: st, tx: tw, fg: hex(l.color.slice(0, 3)), alpha, shown: hex(fgMed), bg: hex(s.median), sel: l.sel, text: blockSeen.get(l.bid) ? blockSeen.get(l.bid).text : '', own: l.own || '', outlined: l.outlined, size: eff, decor: l.decor });
});
}
// fonts actually used to paint text (CDP asks the renderer, so fallbacks are visible)
@@ -658,12 +658,16 @@ async function main() {
else cur.n++;
}
const refPal = referencePalette(proj.dir);
+ // the colour as measured: text drawn at partial opacity (its own, an ancestor's or an rgba colour) is
+ // named with that opacity and the colour it shows as, so the pair and the ratio agree
+ const faded = (v) => v.alpha < 0.98;
+ const fgOf = (v) => (faded(v) ? `${v.fg} at ${Math.round(v.alpha * 100)}% opacity (shows as ${v.shown})` : v.fg);
for (const [, v] of perBlock) {
if (v.ratio >= v.need) continue;
// the job's style reference uses this very pair (reference-style.css, `showtime new --job`): large text
// at WCAG's large-text 3:1 is the look the user asked for, so a note, not an error
if (refPal.length && v.ratio >= 3 && v.size >= 0.04 * H && !v.tx && !v.entering && nearAny(v.fg, refPal) && nearAny(v.bg, refPal)) {
- add('info', 'low_contrast', `contrast ${v.ratio.toFixed(2)}:1 for "${snip(v.text)}" at ${fmtTime(v.t)}: ${v.fg} on ${v.bg}, the style reference's own pair (large text, >= 3:1)`,
+ add('info', 'low_contrast', `contrast ${v.ratio.toFixed(2)}:1 for "${snip(v.text)}" at ${fmtTime(v.t)}: ${fgOf(v)} on ${v.bg}, the style reference's own pair (large text, >= 3:1)`,
{ t: v.t, selector: v.sel, ratio: +v.ratio.toFixed(2), reference: true });
continue;
}
@@ -674,11 +678,11 @@ async function main() {
const sev = v.tx || v.outlined || v.decor || v.entering ? 'info' : v.size >= 0.01 * H ? 'error' : 'warning';
// name the failing span when it is only part of the line (a line number, a diff gutter, one token)
const what = v.own && v.own !== v.text && v.own.length < v.text.length ? `"${snip(v.own, 30)}" in "${snip(v.text)}"` : `"${snip(v.text)}"`;
- add(sev, 'low_contrast', `contrast ${v.ratio.toFixed(2)}:1 (needs ${v.need}:1) for ${what} at ${fmtTime(v.t)}: ${v.fg} on ${v.bg}${v.outlined ? ' (has an outline/shadow)' : ''}${v.tx ? txNote(v.tx) : ''}${v.entering ? ' (measured only while its entrance animation runs; check the settled frame with showtime snap --at)' : ''}`,
- { t: v.t, selector: v.sel, ratio: +v.ratio.toFixed(2), fix: v.ratio < v.need ? `use a ${srgbLum(hexToRgb(v.bg)) < 0.18 ? 'lighter' : 'darker'} text colour, or put a scrim/plate behind the text` : '' });
+ add(sev, 'low_contrast', `contrast ${v.ratio.toFixed(2)}:1 (needs ${v.need}:1) for ${what} at ${fmtTime(v.t)}: ${fgOf(v)} on ${v.bg}${v.outlined ? ' (has an outline/shadow)' : ''}${v.tx ? txNote(v.tx) : ''}${v.entering ? ' (measured only while its entrance animation runs; check the settled frame with showtime snap --at)' : ''}`,
+ { t: v.t, selector: v.sel, ratio: +v.ratio.toFixed(2), fix: v.ratio < v.need ? `${faded(v) && contrast(hexToRgb(v.fg), hexToRgb(v.bg)) >= v.need ? 'draw it at full opacity, ' : ''}use a ${srgbLum(hexToRgb(v.bg)) < 0.18 ? 'lighter' : 'darker'} text colour, or put a scrim/plate behind the text` : '' });
}
if (unmeasured.size) add('info', 'contrast_unmeasured', `contrast of ${unmeasured.size} text block(s) could not be measured (drawn on a canvas, image or transition layer at the sampled times)`);
- report.contrast = [...perBlock.values()].map((v) => ({ text: snip(v.text, 50), ratio: +v.ratio.toFixed(2), worst: +v.worst.toFixed(2), need: v.need, t: v.t, fg: v.fg, bg: v.bg }));
+ report.contrast = [...perBlock.values()].map((v) => ({ text: snip(v.text, 50), ratio: +v.ratio.toFixed(2), worst: +v.worst.toFixed(2), need: v.need, t: v.t, fg: v.fg, bg: v.bg, ...(faded(v) ? { opacity: +v.alpha.toFixed(2) } : {}) }));
for (const v of canvasContrast.values()) {
report.contrast.push({ text: snip(v.text, 50), ratio: +v.ratio.toFixed(2), need: v.need, t: v.t, fg: v.fg, bg: v.bg, source: 'canvas' });
if (v.ratio >= v.need) continue;
diff --git a/skills/showtime/scripts/lib/audit.mjs b/skills/showtime/scripts/lib/audit.mjs
index 1f55d74..f8dd3a1 100644
--- a/skills/showtime/scripts/lib/audit.mjs
+++ b/skills/showtime/scripts/lib/audit.mjs
@@ -5,7 +5,8 @@
* Text layout snapshot at the current seek position.
* o: { width, height, full: boolean, labelGapEm?: number (SVG labels closer than this are crowded, default 0.15) }
* -> { blocks: [{bid, text, len, rect, opacity, fontSize, scale, decor, sel, clipped, offCanvas, onCanvas, caption, moving}],
- * leaves: [{lid, bid, rect, color:[r,g,b,a], opacity, fontSize, scale, decor, weight, outlined, sel}] (full only),
+ * leaves: [{lid, bid, rect, color:[r,g,b,a], opacity, readOpacity, fontSize, scale, decor, weight, outlined, sel}] (full only),
+ * readOpacity = the opacity contrast is judged at (a caption word's: without its card fade or karaoke dim),
* scale = on-screen size / CSS size (transforms such as a camera push or a scaled mockup),
* decor = inside [data-st-decor] (UI mockups, thumbnails: detail, not copy the viewer must read)
* overlaps: [[bidA, bidB, frac]] (full only), heavy: n (full only),
@@ -276,8 +277,11 @@ export function textSnapshot(o) {
// SVG <text> is painted with `fill`, not `color`
const svgFill = typeof SVGElement !== 'undefined' && leaf.el instanceof SVGElement && s.fill && s.fill !== 'none' && !/url\(/.test(s.fill) ? s.fill : null;
const color = rgba(svgFill || (s.webkitTextFillColor && s.webkitTextFillColor !== s.color && !/rgba\(0, 0, 0, 0\)/.test(s.webkitTextFillColor) ? s.webkitTextFillColor : s.color));
+ // a caption-karaoke word: its card's fade in/out and the dim of a word not yet said are timing states,
+ // so its contrast is judged at the caption's own opacity (the word as it reads when it is spoken)
+ const cap = leaf.el.closest && leaf.el.closest('.st-cap[data-caption]');
leaves.push({ lid: idOf(leaf.el, 'data-st-lid'), bid, own: (leaf.el.textContent || '').replace(/\s+/g, ' ').trim().slice(0, 60), rect: { x: leaf.box.x, y: leaf.box.y, w: leaf.box.r - leaf.box.x, h: leaf.box.b - leaf.box.y },
- color, opacity: op, fontSize: fs, scale: scaleOf(leaf.el), decor: blk.decor, weight: parseInt(s.fontWeight, 10) || 400, outlined, clipText, sel: sel(leaf.el), chars: leaf.chars, blurred: blurred(leaf.el),
+ color, opacity: op, readOpacity: cap ? opacity(cap) : op, fontSize: fs, scale: scaleOf(leaf.el), decor: blk.decor, weight: parseInt(s.fontWeight, 10) || 400, outlined, clipText, sel: sel(leaf.el), chars: leaf.chars, blurred: blurred(leaf.el),
entering: animatingOf(leaf.el), portal: !!(leaf.el.closest && leaf.el.closest('[data-st-portal-word],[data-portal]')),
family: s.fontFamily, style: s.fontStyle });
}
diff --git a/skills/showtime/scripts/lib/capture.mjs b/skills/showtime/scripts/lib/capture.mjs
index 12f83c4..323981b 100644
--- a/skills/showtime/scripts/lib/capture.mjs
+++ b/skills/showtime/scripts/lib/capture.mjs
@@ -358,6 +358,19 @@ export async function hostIsPrivate(hostname) {
return (await hostPrivacy(hostname)) !== 'public';
}
+/**
+ * May a capture of `pageUrl` download its assets from private addresses? Only for a file: page or a page
+ * that is itself on a private host (a local dev server's assets live there too). Never for an 'unknown'
+ * host: on a proxy-only network a public site's name does not resolve here, and hostIsPrivate (which
+ * fails closed: true) used for this opposite decision turned the downloader's SSRF guard off for it.
+ */
+export async function privateAssetsAllowed(pageUrl) {
+ if (/^file:/i.test(String(pageUrl))) return true;
+ let host;
+ try { host = new URL(pageUrl).hostname || 'localhost'; } catch { return false; }
+ return (await hostPrivacy(host)) === 'private';
+}
+
/**
* True when a proxy is configured for `url` (HTTP_PROXY/http_proxy for http:, HTTPS_PROXY/https_proxy
* for https:) and NO_PROXY/no_proxy does not bypass it for this host. Behind an explicit proxy with no
diff --git a/skills/showtime/scripts/site.mjs b/skills/showtime/scripts/site.mjs
index 423561e..f0b1c09 100644
--- a/skills/showtime/scripts/site.mjs
+++ b/skills/showtime/scripts/site.mjs
@@ -15,7 +15,7 @@ import { launchBrowser } from './lib/chrome.mjs';
import { parseCli, runMain, UserError, info, warn, c, jobDir, freshPath, fmtBytes, fmtDuration, printHelp, Progress } from './lib/cli.mjs';
import {
aspectViewport, newCaptureContext, installConsent, waitConsent, cleanupOverlays, robustGoto, detectBotWall,
- blockedMarkdown, lazyScroll, scrollMetrics, neutralizeFixed, safeDownload, hostIsPrivate, isTracker,
+ blockedMarkdown, lazyScroll, scrollMetrics, neutralizeFixed, safeDownload, privateAssetsAllowed, isTracker,
canonicalAssetUrl, contactSheet, slug, relPath, sleep, serveStatic, landingProblem,
} from './lib/capture.mjs';
import { extractPage } from './lib/extract.mjs';
@@ -220,7 +220,7 @@ async function captureRun(o, tgt) {
const shotOpts = (file) => (fmt === 'jpg' ? { path: file, type: 'jpeg', quality: 92 } : { path: file, type: 'png' });
const warnings = [];
const phase = (n, total, label) => info(c.dim(` [${n}/${total}] ${label}`));
- const allowPrivate = /^file:/.test(url) || await hostIsPrivate(new URL(url).hostname || 'localhost');
+ const allowPrivate = await privateAssetsAllowed(url); // never for a host DNS cannot place ('unknown')
info(`${c.bold('site capture')} ${url}`);
info(c.dim(` output ${out}`));
diff --git a/skills/showtime/setup/package.json b/skills/showtime/setup/package.json
index 3e63c7e..ae7c0ee 100644
--- a/skills/showtime/setup/package.json
+++ b/skills/showtime/setup/package.json
@@ -1,6 +1,6 @@
{
"name": "showtime-runtime",
- "version": "0.3.4",
+ "version": "0.3.5",
"private": true,
"description": "Node dependencies for showtime (installed by setup.py into ~/.showtime/node). Versions are pinned exactly. Icon sets are not installed here: they are fetched per icon on first use (manifest.json \"icon_packs\").",
"license": "MIT",
diff --git a/skills/showtime/setup/setup.py b/skills/showtime/setup/setup.py
index 8937624..761bcaa 100755
--- a/skills/showtime/setup/setup.py
+++ b/skills/showtime/setup/setup.py
@@ -1073,6 +1073,18 @@ class Installer:
return "fail", "imports failing: " + "; ".join("%s (%s)" % kv for kv in bad.items())
return "ok", detail + "; python %s" % self.venv_version()
+ def step_espeak(self) -> Tuple[str, str]:
+ """The espeak-ng self-test doctor runs (st.voice.espeak.check): Kokoro cannot speak without it."""
+ code = "import json\nfrom st.voice.espeak import check\nprint(json.dumps(check(refresh=True)))\n"
+ cp = run([str(self.vpy), "-c", code], env=dict(self.env_common, PYTHONPATH=str(LIB_DIR)), timeout=300)
+ try:
+ res = json.loads(cp.stdout.strip().splitlines()[-1])
+ except (ValueError, IndexError):
+ return "fail", "the self-test did not run:\n" + tail(cp.stdout)
+ if not res.get("ok"):
+ return "fail", "%s\nfix: %s" % (res.get("error"), res.get("hint"))
+ return "ok", "%s (%s), self-test passed" % (res.get("source"), res.get("lib"))
+
def venv_version(self) -> str:
cp = run([str(self.vpy), "-c", "import platform; print(platform.python_version())"])
return cp.stdout.strip()
@@ -1390,6 +1402,8 @@ class Installer:
ffmpeg_ok = self.report.rows[-1]["status"] != "fail"
if "python" not in self.skip:
self.timed("python", self.step_python)
+ if self.report.rows[-1]["status"] != "fail":
+ self.timed("espeak-ng", self.step_espeak)
if not ffmpeg_ok:
self.timed("imageio-ffmpeg", self.step_imageio_fallback)
if "node" not in self.skip:
diff --git a/skills/showtime/tests/_listen.py b/skills/showtime/tests/_listen.py
new file mode 100644
index 0000000..8eb2e0b
--- /dev/null
+++ b/skills/showtime/tests/_listen.py
@@ -0,0 +1,58 @@
+"""Whether a test may listen on a local port. Stdlib only.
+
+Some agent sandboxes refuse listen() (bind fails with EPERM, or node prints `listen EPERM`). A test that
+serves fixtures over HTTP, or starts showtime's own server (preview, render, check, snap, export, site
+capture --serve), skips there instead of failing, so run_all.py reports only real failures.
+
+ from _listen import LISTEN_BLOCKED, needs_listen, skip_if_listen_refused
+
+ @needs_listen # a class or a test that serves something
+ class T(unittest.TestCase): ...
+ need_listen() # inside a helper that is about to bind (raises SkipTest)
+ skip_if_listen_refused(cp) # after a subprocess: its server was refused -> SkipTest
+
+SHOWTIME_TEST_NO_LISTEN=1 simulates such a sandbox (test_run_all checks the skips with it).
+"""
+from __future__ import annotations
+
+import os
+import re
+import socket
+import unittest
+from typing import Optional
+
+
+def _probe() -> Optional[str]:
+ if os.environ.get("SHOWTIME_TEST_NO_LISTEN"):
+ return "local servers are off (SHOWTIME_TEST_NO_LISTEN)"
+ s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ try:
+ s.bind(("127.0.0.1", 0))
+ s.listen(1)
+ except PermissionError as e: # EPERM / EACCES: the sandbox forbids it (EADDRINUSE and co. are real errors)
+ return "this sandbox does not allow listening on a local port (%s)" % e
+ finally:
+ s.close()
+ return None
+
+
+# why local servers cannot run here, or None when they can (checked once, at import)
+LISTEN_BLOCKED: Optional[str] = _probe()
+
+needs_listen = unittest.skipIf(LISTEN_BLOCKED, LISTEN_BLOCKED or "")
+
+REFUSED_RX = re.compile(r"\blisten (EPERM|EACCES)\b|PermissionError: \[Errno (1|13)\]")
+
+
+def need_listen() -> None:
+ if LISTEN_BLOCKED:
+ raise unittest.SkipTest(LISTEN_BLOCKED)
+
+
+def skip_if_listen_refused(cp) -> None:
+ """A subprocess (showtime render/check/snap/export, a node host) failed because its local server was
+ refused: skip, as for a test that binds one itself."""
+ out = "%s\n%s" % (getattr(cp, "stdout", "") or "", getattr(cp, "stderr", "") or "")
+ if getattr(cp, "returncode", 0) != 0 and REFUSED_RX.search(out):
+ raise unittest.SkipTest("this sandbox does not allow listening on a local port (%s)"
+ % REFUSED_RX.search(out).group(0))
diff --git a/skills/showtime/tests/run_all.py b/skills/showtime/tests/run_all.py
index a17d6b8..6bd5bf7 100755
--- a/skills/showtime/tests/run_all.py
+++ b/skills/showtime/tests/run_all.py
@@ -81,6 +81,8 @@ PART_RUNNER = TESTS_DIR / "_part.py"
SERIAL: dict = {
"test_export.py": "its HTML player checks watch playback in real time (frames drawn, picture against the "
"sound clock); on a 4-core CI runner another file's Chrome starves them",
+ "test_delight.py": "its real `showtime --help` runs on a pseudo-terminal, and a sandbox with few pty devices "
+ "ran out of them (\"out of pty devices\") while other files held theirs; about a second alone",
}
MAX_AUTO_JOBS = 8
diff --git a/skills/showtime/tests/test_bench_round.py b/skills/showtime/tests/test_bench_round.py
index d054a8f..c0ad5b2 100644
--- a/skills/showtime/tests/test_bench_round.py
+++ b/skills/showtime/tests/test_bench_round.py
@@ -110,6 +110,14 @@ class NewTasks(unittest.TestCase):
@unittest.skipUnless(HAVE, "benchmarks/ not present")
class KeelsonFixture(unittest.TestCase):
def setUp(self):
+ # examples/.env and .env.example are the fixture (t9 copies them into the workspace and gives them to the
+ # judges as facts, so they keep their names); some agent sandboxes refuse to read any .env* file
+ ex = BENCH / "fixtures" / "keelson" / "examples"
+ for f in (ex / ".env", ex / ".env.example"):
+ try:
+ f.read_bytes()
+ except OSError as e:
+ self.skipTest("this sandbox does not let tests read %s (%s)" % (f.name, e.strerror or e))
self.tmp = Path(tempfile.mkdtemp(prefix="keelson-"))
shutil.copytree(BENCH / "fixtures" / "keelson", self.tmp / "k")
self.env = dict(os.environ, PYTHONDONTWRITEBYTECODE="1", PYTHONPATH=str(self.tmp / "k"))
diff --git a/skills/showtime/tests/test_brand_first.py b/skills/showtime/tests/test_brand_first.py
index c8e5ad6..eb2616f 100644
--- a/skills/showtime/tests/test_brand_first.py
+++ b/skills/showtime/tests/test_brand_first.py
@@ -116,6 +116,63 @@ file10.txt</pre></section>
"""
+# a README that leads with HTML: a hero image, a bare video URL, a caption in <sub>, a badge row; an H1 in HTML
+# over two lines; a prompt in the quick start; a `# comment` in a shell block far down
+TRAPS = """<p align="center">
+ <img alt="lumen: a lamp over a table of photos" src="assets/hero.svg" width="100%">
+</p>
+
+https://github.com/user-attachments/assets/1132aa71-7fe5-4345-a925-790d80462fda
+
+<p align="center"><sub>The 1.0 demo: 30 seconds (<a href="docs/demo.md">about the demo</a>).</sub></p>
+
+<p align="center">
+ <a href="LICENSE"><img alt="license: MIT" src="assets/badges/license.svg" height="24"></a>
+ [![build](https://img.shields.io/badge/build-passing-green)](https://ci.example.com/lumen)
+</p>
+
+<h1 align="center">
+ <img alt="" src="assets/mark.svg" width="48"><br>lumen
+</h1>
+
+<h3 align="center">Contact sheets from any folder of photos.<br>Local, private, fast.</h3>
+
+## Quick start
+
+```text
+/plugin marketplace add example/lumen
+/plugin install lumen@lumen
+```
+
+Then ask:
+
+```text
+Make a contact sheet of my holiday photos.
+```
+
+## Other agents
+
+```bash
+npx skills add example/lumen
+/plugin marketplace add example/lumen-mirror
+```
+
+## Requirements
+
+```bash
+# Node.js: the installer from nodejs.org (macOS), or on Linux fnm (distribution packages are often older):
+curl -fsSL https://fnm.vercel.app/install | bash
+```
+"""
+
+# the repo's own brand.json, adopted as it is: no "source", "drafted", "voice" or font "how"
+OWN_KIT = {"schema": 1, "status": "confirmed", "name": "lumen", "tagline": "Contact sheets, locally.",
+ "colors": [{"role": "bg", "hex": "#17120e"}, {"role": "ink", "hex": "#f5ebdc"},
+ {"role": "accent", "hex": "#e9b949"}],
+ "palette": {"bg": "#17120e", "ink": "#f5ebdc", "accent": "#e9b949"},
+ "fonts": {"display": {"family": "Fraunces", "license": "OFL-1.1"}, "body": {"family": "Inter"}}}
+
+
def make_repo(root: Path) -> Path:
(root / "site").mkdir(parents=True)
(root / ".git").mkdir()
@@ -174,6 +231,33 @@ class BrandFirstTests(unittest.TestCase):
wm = cap.html_wordmark(repo / "site" / "index.html")
self.assertEqual([(r["text"], r["role"]) for r in wm["runs"]], [("tidy", "ink"), ("line", "accent")])
+ def test_01b_readme_traps(self):
+ from st.brand import capture as cap
+ repo = self.tmp / "traps"
+ repo.mkdir()
+ (repo / "README.md").write_text(TRAPS, encoding="utf-8")
+ c = cap.readme_copy(repo, "lumen")
+ # the H1 (HTML, over two lines), never a `# comment` in a code block
+ self.assertEqual(c["title"], {"text": "lumen", "source": "README.md:14"})
+ # its lead: past the URL-only line, the caption in <sub> and the badges
+ self.assertEqual(c["tagline"], {"text": "Contact sheets from any folder of photos. Local, private, fast.",
+ "source": "README.md:18"})
+ self.assertEqual(c["install"]["command"], "/plugin marketplace add example/lumen") # the one shown first
+ self.assertEqual(c["install"]["source"], "README.md:23")
+ others = [x["command"] for x in c.get("install_other") or []]
+ self.assertNotIn("Make a contact sheet of my holiday photos.", others) # a prompt, not a command
+ # no H1 at all: no title (a deeper heading is never one), the lead is the first plain paragraph
+ (repo / "README.md").write_text(re.sub(r"<h1.*?</h1>\n", "", TRAPS, flags=re.S), encoding="utf-8")
+ c = cap.readme_copy(repo, "lumen")
+ self.assertNotIn("title", c)
+ self.assertEqual(c["tagline"]["text"], "Contact sheets from any folder of photos. Local, private, fast.")
+ # the repo's own kit adopted, without the fields a draft has: brand.md never prints None
+ (repo / "brand.json").write_text(json.dumps(OWN_KIT), encoding="utf-8")
+ showtime("brand", "capture", repo, "-o", self.tmp / "traps-out", "--no-site", "--no-font-lookup", cwd=self.tmp)
+ md = (self.tmp / "traps-out" / "brand.md").read_text(encoding="utf-8")
+ self.assertNotIn("None", md)
+ self.assertIn("brand.json", md.split("\n")[2]) # says where the kit was adopted from
+
def test_02_capture_repo_records_in_job_and_new_launch_applies(self):
base = self.tmp / "ws2"
repo = make_repo(base)
diff --git a/skills/showtime/tests/test_capture.py b/skills/showtime/tests/test_capture.py
index ad94ef0..bd5d1b0 100644
--- a/skills/showtime/tests/test_capture.py
+++ b/skills/showtime/tests/test_capture.py
@@ -22,6 +22,7 @@ import _isolate # noqa: F401 (run from a scratch folder: never write into the
import http.server
import json
import os
+import re
import shutil
import socket
import struct
@@ -35,6 +36,8 @@ import urllib.request
import zlib
from pathlib import Path
+from _listen import LISTEN_BLOCKED, needs_listen, skip_if_listen_refused
+
TESTS_DIR = Path(__file__).resolve().parent
SKILL = TESTS_DIR.parent
LAUNCHER = SKILL / "lib" / "st" / "launcher.py"
@@ -53,6 +56,7 @@ def showtime(*args, check=True, timeout=240, cwd=None):
cp = subprocess.run([sys.executable, str(LAUNCHER)] + [str(a) for a in args], env=ENV, cwd=cwd,
stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding="utf-8",
errors="replace", timeout=timeout)
+ skip_if_listen_refused(cp)
if check and cp.returncode != 0:
raise AssertionError("showtime %s failed (rc=%d):\n%s\n%s" % (
" ".join(map(str, args)), cp.returncode, cp.stdout[-3000:], cp.stderr[-3000:]))
@@ -113,6 +117,8 @@ def network_ok() -> bool:
NET = network_ok()
SITE = TMP / "site"
+SERVER = None
+BASE = ""
def setUpModule():
@@ -124,20 +130,24 @@ def setUpModule():
png(SITE / "listing" / "a.png", 64, 64, 4) # a folder without index.html
handler = lambda *a, **k: Handler(*a, directory=str(SITE), **k) # noqa: E731
global SERVER, BASE
+ if LISTEN_BLOCKED: # T1Site, T1bServe and T2Demo skip; the rest runs without a server
+ return
SERVER = http.server.ThreadingHTTPServer(("127.0.0.1", 0), handler)
threading.Thread(target=SERVER.serve_forever, daemon=True).start()
BASE = "http://127.0.0.1:%d/" % SERVER.server_address[1]
def tearDownModule():
- SERVER.shutdown()
- SERVER.server_close()
+ if SERVER is not None:
+ SERVER.shutdown()
+ SERVER.server_close()
if not os.environ.get("SHOWTIME_KEEP_TEST_OUTPUT"):
shutil.rmtree(TMP, ignore_errors=True)
else:
print("kept test output in", TMP)
+@needs_listen
class T1Site(unittest.TestCase):
def test_capture_local(self):
out = TMP / "cap"
@@ -215,6 +225,7 @@ def port_open(url: str) -> bool:
return False
+@needs_listen
class T1bServe(unittest.TestCase):
"""--serve DIR and the wrong-page guard (audit B1)."""
@@ -497,7 +508,40 @@ console.log(JSON.stringify(R));
self.assertNotEqual(r["withProxy"], "unresolved-host",
"a configured proxy must bypass the unresolved-host short-circuit")
+ def test_unknown_page_host_never_allows_private_assets(self):
+ """site capture turned the asset downloader's private-address guard off with
+ `allowPrivate = ... || await hostIsPrivate(host)`: since hostIsPrivate fails closed, a public site
+ whose name does not resolve here (a proxy-only network) counted as private. Only a file: page or a
+ page on a known private host may fetch private assets, and no script may use hostIsPrivate to allow
+ anything."""
+ js = r"""
+import { privateAssetsAllowed } from %s;
+const R = {};
+R.unknown = await privateAssetsAllowed('https://' + %s + '/');
+R.publicIp = await privateAssetsAllowed('https://1.2.3.4/');
+R.loopback = await privateAssetsAllowed('http://127.0.0.1:8080/');
+R.localhost = await privateAssetsAllowed('http://localhost:3000/');
+R.file = await privateAssetsAllowed('file:///tmp/site/index.html');
+R.bad = await privateAssetsAllowed('not a url');
+console.log(JSON.stringify(R));
+""" % (json.dumps((SKILL / "scripts" / "lib" / "capture.mjs").as_uri()), json.dumps(self.UNRESOLVABLE))
+ r = self._run(js)
+ self.assertEqual(r, {"unknown": False, "publicIp": False, "loopback": True, "localhost": True,
+ "file": True, "bad": False})
+ # the capture itself decides with it, and nothing else turns "not known public" into a permission
+ site = (SKILL / "scripts" / "site.mjs").read_text(encoding="utf-8")
+ m = re.search(r"const allowPrivate = ([^\n]+)", site)
+ self.assertTrue(m, "site.mjs no longer computes allowPrivate: update this test")
+ self.assertIn("privateAssetsAllowed(url)", m.group(1))
+ for f in sorted((SKILL / "scripts").rglob("*.mjs")) + sorted((SKILL / "mcp").rglob("*.mjs")):
+ if "node_modules" in f.parts or f.name == "capture.mjs":
+ continue
+ self.assertNotIn("hostIsPrivate", f.read_text(encoding="utf-8"),
+ "%s: hostIsPrivate fails closed (true for an unknown host); allow with "
+ "hostPrivacy(...) === 'private' or privateAssetsAllowed" % f.relative_to(SKILL))
+
+@needs_listen
class T2Demo(unittest.TestCase):
def test_demo_and_autozoom(self):
out = TMP / "demo"
diff --git a/skills/showtime/tests/test_downloads.py b/skills/showtime/tests/test_downloads.py
index 72c3782..b206412 100644
--- a/skills/showtime/tests/test_downloads.py
+++ b/skills/showtime/tests/test_downloads.py
@@ -25,6 +25,8 @@ import threading
import unittest
from pathlib import Path
+from _listen import need_listen
+
TESTS_DIR = Path(__file__).resolve().parent
SKILL = TESTS_DIR.parent
sys.path.insert(0, str(SKILL / "lib"))
@@ -93,6 +95,7 @@ def fixture_server(files, codes=None):
_Handler.files = dict(files)
_Handler.hits = []
_Handler.codes = dict(codes or {})
+ need_listen()
srv = http.server.ThreadingHTTPServer(("127.0.0.1", 0), _Handler)
t = threading.Thread(target=srv.serve_forever, daemon=True)
t.start()
diff --git a/skills/showtime/tests/test_export.py b/skills/showtime/tests/test_export.py
index da7ddd7..db9accf 100644
--- a/skills/showtime/tests/test_export.py
+++ b/skills/showtime/tests/test_export.py
@@ -51,6 +51,8 @@ import time
import unittest
from pathlib import Path
+from _listen import needs_listen
+
TESTS_DIR = Path(__file__).resolve().parent
SKILL = TESTS_DIR.parent
LAUNCHER = SKILL / "lib" / "st" / "launcher.py"
@@ -401,6 +403,7 @@ def serve(folder):
return srv
+@needs_listen
class ExportTest(unittest.TestCase):
@classmethod
def setUpClass(cls):
diff --git a/skills/showtime/tests/test_foundation.py b/skills/showtime/tests/test_foundation.py
index 3dbb7dc..0269347 100644
--- a/skills/showtime/tests/test_foundation.py
+++ b/skills/showtime/tests/test_foundation.py
@@ -765,6 +765,22 @@ class TestRetimeVoiceAndData(TempDirCase):
self.assertIn("voice script", cp.stderr)
self.assertEqual(common.read_json(d / "showtime.json")["duration"], 10.0) # errors write nothing
+ def test_from_voice_ducks_catalog_music(self):
+ """Music from the catalog (what `audio cut-plan` writes) ducks under the voice like file, lib and compose
+ music; effects and music that already has a duck are left alone."""
+ d = self._project("vo3")
+ common.write_json(d / "audio" / "mix.json", {"duration": 10.0, "tracks": [
+ {"id": "music", "kind": "music", "catalog": "buckley-with-these-hands", "fit": True},
+ {"kind": "music", "catalog": {"use": "explainer", "pick": 0}},
+ {"kind": "music", "lib": "x/y", "duck": {"under": "vo-hook", "depth_db": 6}},
+ {"kind": "sfx", "synth": {"type": "impact"}, "at": 3.5}]})
+ tl = self._timeline(d / "voice", [("hook", 1.6, 0.35), ("demo", 3.0, 0.6)])
+ rep = json.loads(showtime("retime", d, "--from-voice", tl, "--json").stdout)
+ self.assertTrue(any("music ducks under the voice" in c for c in rep["changes"]), rep["changes"])
+ tracks = [t for t in common.read_json(d / "audio" / "mix.json")["tracks"] if t.get("kind") != "voice"]
+ self.assertEqual([t.get("duck") for t in tracks],
+ [{"under": "voice"}, {"under": "voice"}, {"under": "vo-hook", "depth_db": 6}, None])
+
def test_stretch_warning_and_quiet_poster(self):
d = self._project("st1")
cp = showtime("retime", d, "-d", "20", "--json")
diff --git a/skills/showtime/tests/test_motion.py b/skills/showtime/tests/test_motion.py
index e27350b..daa151e 100644
--- a/skills/showtime/tests/test_motion.py
+++ b/skills/showtime/tests/test_motion.py
@@ -27,6 +27,8 @@ import time
import unittest
from pathlib import Path
+from _listen import need_listen, skip_if_listen_refused
+
TESTS_DIR = Path(__file__).resolve().parent
SKILL = TESTS_DIR.parent
LAUNCHER = SKILL / "lib" / "st" / "launcher.py"
@@ -46,6 +48,7 @@ def showtime(*args, check=True, timeout=600):
cp = subprocess.run([sys.executable, str(LAUNCHER)] + [str(a) for a in args], env=ENV,
stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding="utf-8",
errors="replace", timeout=timeout)
+ skip_if_listen_refused(cp) # render, snap and check serve the project on a local port
if check and cp.returncode != 0:
raise AssertionError("showtime %s failed (rc=%d):\n%s\n%s" % (
" ".join(map(str, args)), cp.returncode, cp.stdout[-3000:], cp.stderr[-3000:]))
@@ -480,6 +483,7 @@ class MotionTests(unittest.TestCase):
drv.write_text(PROBE_JS % {"skill": json.dumps(str(SKILL)), "proj": json.dumps(str(proj)), "t": 3.8, "js": json.dumps(js)},
encoding="utf-8")
cp = subprocess.run([node_exe(), str(drv)], env=ENV, stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding="utf-8", timeout=180)
+ skip_if_listen_refused(cp)
self.assertEqual(cp.returncode, 0, cp.stderr[-2000:])
g = json.loads(json.loads(cp.stdout.strip().splitlines()[-1]))
self.assertAlmostEqual(g["negTop"], g["zero"], delta=1.0)
@@ -514,6 +518,7 @@ class MotionTests(unittest.TestCase):
drv.write_text(PROBE_JS % {"skill": json.dumps(str(SKILL)), "proj": json.dumps(str(proj)), "t": 2.5, "js": json.dumps(js)},
encoding="utf-8")
cp = subprocess.run([node_exe(), str(drv)], env=ENV, stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding="utf-8", timeout=180)
+ skip_if_listen_refused(cp)
self.assertEqual(cp.returncode, 0, cp.stderr[-2000:])
g = json.loads(json.loads(cp.stdout.strip().splitlines()[-1]))
m = re.search(r"translateY\((-?[\d.]+)px\)", g["page"])
@@ -697,6 +702,7 @@ class AssetsTests(unittest.TestCase):
def log_message(self, *a):
pass
+ need_listen()
srv = http.server.ThreadingHTTPServer(("127.0.0.1", 0), Quiet)
threading.Thread(target=srv.serve_forever, daemon=True).start()
old_paths = media.paths
diff --git a/skills/showtime/tests/test_music.py b/skills/showtime/tests/test_music.py
index dd640c8..8aa0c82 100644
--- a/skills/showtime/tests/test_music.py
+++ b/skills/showtime/tests/test_music.py
@@ -46,6 +46,8 @@ import unittest
import zipfile
from pathlib import Path
+from _listen import need_listen
+
TESTS_DIR = Path(__file__).resolve().parent
SKILL = TESTS_DIR.parent
LAUNCHER = SKILL / "lib" / "st" / "launcher.py"
@@ -74,6 +76,7 @@ class _Handler(http.server.SimpleHTTPRequestHandler):
@contextlib.contextmanager
def serve(folder: Path):
+ need_listen()
handler = lambda *a, **k: _Handler(*a, directory=str(folder), **k) # noqa: E731
srv = http.server.ThreadingHTTPServer(("127.0.0.1", 0), handler)
th = threading.Thread(target=srv.serve_forever, daemon=True)
diff --git a/skills/showtime/tests/test_portable.py b/skills/showtime/tests/test_portable.py
index 77c6fd3..d7ceb01 100644
--- a/skills/showtime/tests/test_portable.py
+++ b/skills/showtime/tests/test_portable.py
@@ -35,6 +35,8 @@ import time
import unittest
from pathlib import Path
+from _listen import LISTEN_BLOCKED
+
TESTS_DIR = Path(__file__).resolve().parent
SKILL = TESTS_DIR.parent
REPO = SKILL.parent.parent
@@ -78,6 +80,8 @@ def launcher(*args, env=None, cwd=None, timeout=120):
def closed_port() -> int:
+ if LISTEN_BLOCKED:
+ return 9 # a sandbox that refuses bind(): the discard port, which nothing serves (test_music uses it too)
s = socket.socket()
s.bind(("127.0.0.1", 0))
port = s.getsockname()[1]
@@ -349,6 +353,17 @@ class TestShim(Tmp):
self.assertTrue(any("ln -sf" in x for x in lines), lines)
os.environ["PATH"] = "%s:/usr/bin:/bin" % (home / "bin")
self.assertEqual(shim.path_hint(home), [], "already on PATH: nothing to say")
+ # the skill's own launcher on PATH (a plugin's bin/, a checkout) works too: no "not on PATH yet"
+ os.environ["PATH"] = os.pathsep.join([str(SKILL / "bin"), "/usr/bin", "/bin"])
+ self.assertEqual(shim.path_hint(home), [], "the skill's bin/showtime is on PATH")
+ # another program called showtime is not showtime
+ other = self.tmp / "other-bin"
+ other.mkdir()
+ fake = other / ("showtime.cmd" if os.name == "nt" else "showtime")
+ fake.write_text("@echo off\n" if os.name == "nt" else "#!/bin/sh\n", encoding="utf-8")
+ fake.chmod(0o755)
+ os.environ["PATH"] = os.pathsep.join([str(other), "/usr/bin", "/bin"])
+ self.assertTrue(any("not on PATH yet" in x for x in shim.path_hint(home)))
finally:
os.environ.clear()
os.environ.update(old)
@@ -595,9 +610,134 @@ class TestHome(Tmp):
os.environ.update(old)
+# ============================================================================ the environment children get
+
+PROXY_VARS = ("HTTPS_PROXY", "https_proxy", "HTTP_PROXY", "http_proxy", "NO_PROXY", "no_proxy", "NODE_USE_ENV_PROXY")
+PRINT_ENV = ("import json, os; print(json.dumps({k: os.environ.get(k) for k in "
+ "('ORT_DISABLE_TELEMETRY', 'NODE_USE_ENV_PROXY', 'NO_PROXY', 'no_proxy')}))")
+
+
+class TestChildEnv(Tmp):
+ """What showtime's child processes inherit: onnxruntime's telemetry off (its Linux wheels start
+ Microsoft's telemetry client at import), and, behind a proxy, Node told to use it (Node's fetch and
+ http(s).request ignore HTTPS_PROXY unless NODE_USE_ENV_PROXY=1) without sending loopback to it."""
+
+ def child_env(self, *, node=False, **extra):
+ """The environment a child of the launcher sees (build_env in a fresh process, as main() runs it)."""
+ env = {k: v for k, v in clean_env(SHOWTIME_HOME=self.tmp / "home", SHOWTIME_SETTINGS=self.tmp / "s.json").items()
+ if k not in PROXY_VARS and k != "ORT_DISABLE_TELEMETRY"}
+ env.update(extra)
+ if node:
+ exe = shutil.which("node")
+ if not exe:
+ self.skipTest("node not found")
+ child = repr([exe, "-e", "const e = process.env; console.log(JSON.stringify(Object.fromEntries("
+ "['ORT_DISABLE_TELEMETRY', 'NODE_USE_ENV_PROXY', 'NO_PROXY', 'no_proxy'].map((k) => [k, e[k] ?? null]))))"])
+ else:
+ child = repr([sys.executable, "-c", PRINT_ENV])
+ code = ("import subprocess, sys; sys.path.insert(0, %r); from st import launcher as L; "
+ "sys.exit(subprocess.run(%s, env=L.build_env(L.showtime_home())).returncode)" % (str(SKILL / "lib"), child))
+ cp = run([sys.executable, "-c", code], env=env, cwd=self.tmp)
+ self.assertEqual(cp.returncode, 0, cp.stderr)
+ return json.loads(cp.stdout.strip().splitlines()[-1])
+
+ def test_onnxruntime_telemetry_off_in_children(self):
+ self.assertEqual(self.child_env()["ORT_DISABLE_TELEMETRY"], "1", "a child of the launcher")
+ self.assertEqual(self.child_env(node=True)["ORT_DISABLE_TELEMETRY"], "1", "a Node child of the launcher")
+ self.assertEqual(self.child_env(ORT_DISABLE_TELEMETRY="0")["ORT_DISABLE_TELEMETRY"], "0", "a set value wins")
+ # a process that imports st without the launcher (the venv python a test or host runs) and its children
+ env = {k: v for k, v in clean_env().items() if k != "ORT_DISABLE_TELEMETRY"}
+ code = "import subprocess, sys; sys.path.insert(0, %r); import st; subprocess.run([sys.executable, '-c', %r])" % (
+ str(SKILL / "lib"), PRINT_ENV)
+ cp = run([sys.executable, "-c", code], env=env, cwd=self.tmp)
+ self.assertEqual(cp.returncode, 0, cp.stderr)
+ self.assertEqual(json.loads(cp.stdout.strip().splitlines()[-1])["ORT_DISABLE_TELEMETRY"], "1", "import st")
+ # the second guard at session creation: called when the build has it, harmless when it does not
+ from st.common import ort_telemetry_off
+ calls = []
+ ort_telemetry_off(type("Rt", (), {"disable_telemetry_events": staticmethod(lambda: calls.append(1))}))
+ ort_telemetry_off(object())
+ self.assertEqual(calls, [1])
+
+ def test_node_children_use_the_proxy_when_one_is_set(self):
+ r = self.child_env(node=True)
+ self.assertIsNone(r["NODE_USE_ENV_PROXY"], "no proxy: Node's networking stays as it is")
+ self.assertIsNone(r["NO_PROXY"])
+ r = self.child_env(node=True, HTTPS_PROXY="http://proxy.example:3128")
+ self.assertEqual(r["NODE_USE_ENV_PROXY"], "1")
+ no_proxy = r["NO_PROXY"].split(",")
+ for h in ("localhost", "127.0.0.1", "::1"):
+ self.assertIn(h, no_proxy, "loopback (preview, studio, a captured local site) must not go to the proxy")
+ if not IS_WIN:
+ self.assertEqual(r["no_proxy"], r["NO_PROXY"], "Node reads no_proxy first: both carry the list")
+ r = self.child_env(node=True, http_proxy="http://proxy.example:3128", no_proxy="corp.example,localhost")
+ self.assertEqual(r["NODE_USE_ENV_PROXY"], "1", "lowercase proxy variables count too")
+ self.assertEqual(r["no_proxy" if not IS_WIN else "NO_PROXY"].split(",")[:2], ["corp.example", "localhost"],
+ "the user's own entries are kept, first")
+ r = self.child_env(node=True, HTTPS_PROXY="http://proxy.example:3128", NODE_USE_ENV_PROXY="0")
+ self.assertEqual(r["NODE_USE_ENV_PROXY"], "0", "a set value wins")
+
+ def test_node_really_routes_through_the_proxy(self):
+ """With the launcher's environment, Node's fetch reaches a remote name through HTTPS_PROXY/HTTP_PROXY
+ and a loopback address directly. Needs a Node with NODE_USE_ENV_PROXY (24+, 22.21+)."""
+ exe = shutil.which("node")
+ if not exe:
+ self.skipTest("node not found")
+ ver = tuple(int(x) for x in re.findall(r"\d+", run([exe, "--version"]).stdout)[:2])
+ if not (ver >= (24, 0) or (22, 21) <= ver < (23, 0)):
+ self.skipTest("Node %s has no NODE_USE_ENV_PROXY" % ".".join(map(str, ver)))
+ import http.server
+ import threading
+ seen = []
+
+ class H(http.server.BaseHTTPRequestHandler):
+ def _answer(self):
+ seen.append((self.server.name, self.command, self.path))
+ self.send_response(200 if self.server.name == "target" else 502)
+ self.send_header("Content-Length", "0")
+ self.end_headers()
+ do_GET = do_CONNECT = _answer
+
+ def log_message(self, *a):
+ pass
+
+ servers = []
+ for name in ("proxy", "target"):
+ s = http.server.ThreadingHTTPServer(("127.0.0.1", 0), H)
+ s.name = name
+ threading.Thread(target=s.serve_forever, daemon=True).start()
+ servers.append(s)
+ proxy, target = ("http://127.0.0.1:%d" % s.server_address[1] for s in servers)
+ try:
+ js = ("const go = (u) => fetch(u).then((r) => r.status, (e) => 'error');"
+ "Promise.all([go('http://remote.invalid/x'), go(process.argv[1] + '/y')])"
+ ".then((r) => console.log(JSON.stringify(r)));")
+ code = ("import subprocess, sys; sys.path.insert(0, %r); from st import launcher as L; "
+ "sys.exit(subprocess.run([%r, '-e', %r, %r], env=L.build_env(L.showtime_home())).returncode)"
+ % (str(SKILL / "lib"), exe, js, target))
+ env = {k: v for k, v in clean_env(SHOWTIME_HOME=self.tmp / "home").items() if k not in PROXY_VARS}
+ env["HTTP_PROXY"] = proxy
+ cp = run([sys.executable, "-c", code], env=env, cwd=self.tmp)
+ self.assertEqual(cp.returncode, 0, cp.stderr)
+ self.assertEqual(json.loads(cp.stdout.strip().splitlines()[-1])[1], 200, "loopback goes direct")
+ self.assertTrue(any(n == "proxy" and "remote.invalid" in p for n, _, p in seen), seen)
+ self.assertFalse(any(n == "proxy" and "127.0.0.1" in p for n, _, p in seen), seen)
+ finally:
+ for s in servers:
+ s.shutdown()
+ s.server_close()
+
+
# ============================================================================ doctor in a sandbox
class TestDoctorSandbox(Tmp):
+ def test_node_proxy_versions(self):
+ """doctor warns when a proxy is set and Node ignores NODE_USE_ENV_PROXY (before 22.21, 23.x-24.4)."""
+ from st.doctor import node_ignores_proxy
+ for ver, ignores in (((20, 11, 1), True), ((22, 20, 0), True), ((22, 21, 0), False), ((23, 9, 0), True),
+ ((24, 4, 1), True), ((24, 5, 0), False), ((25, 1, 0), False)):
+ self.assertEqual(node_ignores_proxy(ver), ignores, ver)
+
def doctor(self, env, cwd=None):
cp = launcher("doctor", "--quick", "--json", env=env, cwd=cwd or self.tmp, timeout=300)
self.assertIn(cp.returncode, (0, 1), cp.stderr)
diff --git a/skills/showtime/tests/test_preview_server.py b/skills/showtime/tests/test_preview_server.py
index 6f171ff..fe14411 100644
--- a/skills/showtime/tests/test_preview_server.py
+++ b/skills/showtime/tests/test_preview_server.py
@@ -24,6 +24,8 @@ import urllib.parse
import urllib.request
from pathlib import Path
+from _listen import needs_listen
+
TESTS_DIR = Path(__file__).resolve().parent
SKILL = TESTS_DIR.parent
LAUNCHER = SKILL / "lib" / "st" / "launcher.py"
@@ -77,6 +79,7 @@ process.stdin.on('end', async () => { await keyed.close(); await keyed2.close();
"""
+@needs_listen
class TestPreviewKey(unittest.TestCase):
@classmethod
def setUpClass(cls):
diff --git a/skills/showtime/tests/test_render.py b/skills/showtime/tests/test_render.py
index 1b23fad..1d66d0b 100644
--- a/skills/showtime/tests/test_render.py
+++ b/skills/showtime/tests/test_render.py
@@ -792,6 +792,47 @@ Film.start({ look: 'paper', fonts: ['650 1em "Inter Variable"'], scenes: functio
self.assertTrue([x for x in f if x["code"] == "sparse_frame" and x["severity"] == "info"], f)
self.assertGreaterEqual(rep["design"]["flat_share"], 0.75)
+ def test_14d_contrast_of_caption_words_and_faded_text(self):
+ """A caption word is judged at its colours, not at a karaoke state: sampled while its card fades in
+ and the word is still upcoming (dimmed in the minimal style), the accent #e9b949 on #17120e is
+ 10.18:1, not the 2.98:1 of a 45% opacity. A caption accent that is really low still fails, and plain
+ text faded to 45% fails with its opacity named, so the colours and the ratio in the message agree."""
+ proj = self.tmp / "capcontrast"
+ write(proj / "showtime.json", json.dumps({"width": 1280, "height": 720, "fps": 30, "duration": 4}))
+ # one card, on screen 1.90-3.60 s: at the 2.00 s sample it is fading in and "Claude" is upcoming
+ write(proj / "words.json", json.dumps([{"text": "Works", "start": 1.95, "end": 2.1}, {"text": "in", "start": 2.1, "end": 2.2},
+ {"text": "Claude", "start": 2.2, "end": 2.5, "emph": True}, {"text": "Code.", "start": 2.5, "end": 2.8}]))
+ page = ("<!doctype html><html><head><script src=\"/_st/stage.js\"></script>"
+ "<link rel=\"stylesheet\" href=\"/_lib/@fontsource-variable/inter/index.css\">"
+ "<script type=\"module\" src=\"/_st/components/index.js\"></script>"
+ "<style>body{margin:0;background:#17120e;font-family:'Inter Variable'}.s{position:absolute;inset:0;background:#17120e}"
+ ".st-cap{--cap-ink:#f5ebdc;--cap-accent:%s;--cap-outline:#17120e}"
+ "p{position:absolute;left:60px;top:60px;margin:0;font-size:40px;color:#e9b949;opacity:%s}</style></head><body>"
+ "<section class=\"s\" data-start=\"0\" data-dur=\"4\"><p>Faded note</p>"
+ "<div data-st=\"caption-karaoke\" data-src=\"words.json\" data-style=\"minimal\" data-emphasis=\"free\"></div>"
+ "</section></body></html>")
+
+ def run(accent, note_opacity):
+ write(proj / "index.html", page % (accent, note_opacity))
+ rep = json.loads(showtime("check", proj, "--json", "--no-determinism", "--no-timeline", "--samples", "1", check=False).stdout)
+ low = [f for f in rep["findings"] if f["code"] == "low_contrast"]
+ cap = next(c for c in rep["contrast"] if c["text"].startswith("Works in"))
+ return low, cap
+ low, cap = run("#e9b949", "1")
+ self.assertFalse(low, low)
+ self.assertAlmostEqual(cap["ratio"], 10.18, delta=0.05)
+ self.assertEqual((cap["fg"], cap["bg"]), ("#e9b949", "#17120e"))
+ # a caption accent that is low against the ground is still reported
+ low, cap = run("#4a3a20", "1")
+ self.assertTrue([f for f in low if '"Claude"' in f["message"]], low)
+ self.assertLess(cap["ratio"], 2)
+ # plain text at 45% opacity: still an error, and the message says what was measured
+ low, _ = run("#e9b949", "0.45")
+ faded = [f for f in low if "Faded note" in f["message"]]
+ self.assertTrue(faded and faded[0]["severity"] == "error", low)
+ self.assertIn("#e9b949 at 45% opacity", faded[0]["message"])
+ self.assertAlmostEqual(faded[0]["ratio"], 2.98, delta=0.05)
+
def test_15_server_hint_for_static_site(self):
"""`showtime server` on a folder without showtime.json points at `site capture --serve`."""
site = self.tmp / "static-site"
diff --git a/skills/showtime/tests/test_run_all.py b/skills/showtime/tests/test_run_all.py
index 4a170d6..553679e 100644
--- a/skills/showtime/tests/test_run_all.py
+++ b/skills/showtime/tests/test_run_all.py
@@ -646,6 +646,51 @@ class TestRunAllPlanning(unittest.TestCase):
self.assertIn("A.c", note)
self.assertIn("A.b", note)
+ def test_pty_file_runs_alone(self):
+ # test_delight opens a pseudo-terminal: a sandbox with few pty devices ran out of them under -j
+ self.assertIn("test_delight.py", self.ra.SERIAL)
+ cp = subprocess.run([sys.executable, str(TESTS_DIR / "run_all.py"), "--fast", "--list", "-j", "8", "-k", "delight"],
+ capture_output=True, text=True, timeout=60)
+ self.assertIn("test_delight.py (serial: ", cp.stdout)
+
+
+class TestListenGuard(unittest.TestCase):
+ """tests/_listen.py: a sandbox that refuses listen() makes the tests that serve something skip, not fail."""
+
+ def load(self):
+ spec = importlib.util.spec_from_file_location("st_listen_t", str(TESTS_DIR / "_listen.py"))
+ mod = importlib.util.module_from_spec(spec) # type: ignore[arg-type]
+ spec.loader.exec_module(mod) # type: ignore[union-attr]
+ return mod
+
+ def test_a_refused_bind_is_detected(self):
+ import socket
+ from unittest import mock
+ env = {k: v for k, v in os.environ.items() if k != "SHOWTIME_TEST_NO_LISTEN"}
+ refused = PermissionError(1, "Operation not permitted")
+ with mock.patch.dict(os.environ, env, clear=True), mock.patch.object(socket.socket, "bind", side_effect=refused):
+ L = self.load()
+ self.assertIn("does not allow listening", L.LISTEN_BLOCKED)
+ with self.assertRaises(unittest.SkipTest):
+ L.need_listen()
+ with mock.patch.dict(os.environ, {"SHOWTIME_TEST_NO_LISTEN": "1"}):
+ self.assertIn("SHOWTIME_TEST_NO_LISTEN", self.load().LISTEN_BLOCKED)
+
+ def test_a_server_refused_in_a_subprocess_skips(self):
+ L = self.load()
+ node = subprocess.CompletedProcess([], 1, "", "Error: listen EPERM: operation not permitted 127.0.0.1\n")
+ with self.assertRaises(unittest.SkipTest):
+ L.skip_if_listen_refused(node)
+ L.skip_if_listen_refused(subprocess.CompletedProcess([], 1, "", "Error: render failed\n")) # a real failure
+ L.skip_if_listen_refused(subprocess.CompletedProcess([], 0, "listen EPERM in a log line", ""))
+
+ def test_server_tests_skip_where_listen_is_refused(self):
+ env = dict(os.environ, SHOWTIME_TEST_NO_LISTEN="1")
+ cp = subprocess.run([sys.executable, str(TESTS_DIR / "test_preview_server.py"), "--fast"], env=env,
+ capture_output=True, text=True, timeout=120)
+ self.assertEqual(cp.returncode, 0, cp.stderr[-2000:])
+ self.assertRegex(cp.stderr, r"OK \(skipped=\d+\)")
+
if __name__ == "__main__":
argv = [a for a in sys.argv if a != "--fast"]
diff --git a/skills/showtime/tests/test_variety.py b/skills/showtime/tests/test_variety.py
index cb4b001..537a04c 100644
--- a/skills/showtime/tests/test_variety.py
+++ b/skills/showtime/tests/test_variety.py
@@ -33,6 +33,8 @@ import unittest
import warnings
from pathlib import Path
+from _listen import needs_listen
+
TESTS_DIR = Path(__file__).resolve().parent
SKILL = TESTS_DIR.parent
LAUNCHER = SKILL / "lib" / "st" / "launcher.py"
@@ -412,6 +414,7 @@ class TestReference(HistoryCase):
self.assertTrue((job / "references" / "pattern-reel-2" / "reference.md").is_file())
self.assertIn("pattern-reel-2", showtime("reference", "list", job).stdout)
+ @needs_listen
def test_url_direct_file_and_page(self):
root = TMP / "served"
root.mkdir(exist_ok=True)
diff --git a/skills/showtime/tests/test_voice.py b/skills/showtime/tests/test_voice.py
index cbb00c8..3cb8aeb 100644
--- a/skills/showtime/tests/test_voice.py
+++ b/skills/showtime/tests/test_voice.py
@@ -487,6 +487,96 @@ import shutil; shutil.rmtree(other, ignore_errors=True); shutil.rmtree(tmp, igno
self.assertTrue(d["other_kept"])
self.assertTrue(d["list_gone"])
+ @unittest.skipIf(plat.IS_WINDOWS, "the /tmp fallback is POSIX only (%ProgramData% is short on Windows)")
+ def test_10_espeak_long_home_and_tmpdir(self):
+ """A data path over espeak-ng's limit with $SHOWTIME_HOME and $TMPDIR both long is copied to
+ /tmp/showtime-espeak-<uid> (this user's 0700 folder; anyone else's is refused); when no short folder
+ works, the hint names the path length, not `showtime setup`."""
+ short = Path(tempfile.mkdtemp(prefix="st-esp-"))
+ self.addCleanup(shutil.rmtree, str(short), True)
+ out = py(r"""
+import json, os, sys, tempfile
+from pathlib import Path
+lib, base, short = sys.argv[1], Path(sys.argv[2]), Path(sys.argv[3])
+sys.path.insert(0, lib)
+for d in ("home", "tmp", "data/espeak-ng-data"):
+ (base / d).mkdir(parents=True, exist_ok=True)
+(base / "data/espeak-ng-data/phontab").write_bytes(b"x")
+os.environ.update(SHOWTIME_HOME=str(base / "home"), TMPDIR=str(base / "tmp"))
+tempfile.tempdir = None
+from st.common import ShowtimeError
+from st.voice import espeak as E
+data = str(base / "data/espeak-ng-data")
+E.SHORT_ROOT = str(short / "ok")
+os.mkdir(E.SHORT_ROOT)
+got = E._short_copy(data)
+mode = oct(os.stat(str(Path(got).parent)).st_mode & 0o777) if got else None
+E.SHORT_ROOT = str(short / "loose")
+os.makedirs(os.path.join(E.SHORT_ROOT, "showtime-espeak-%d" % os.getuid()))
+os.chmod(os.path.join(E.SHORT_ROOT, "showtime-espeak-%d" % os.getuid()), 0o777)
+loose = E._short_copy(data)
+os.environ.update(SHOWTIME_ESPEAK_LIB=str(base / "libespeak-ng.so"), SHOWTIME_ESPEAK_DATA=data)
+try:
+ E.resolve(refresh=True)
+ err = None
+except ShowtimeError as e:
+ err = {"message": e.message, "hint": e.hint}
+print(json.dumps({"home": len(os.fsencode(str(base / "home"))), "tmp": len(os.fsencode(tempfile.gettempdir())),
+ "got": got, "mode": mode, "loose": loose, "err": err, "check": E.check()}))
+""", SKILL / "lib", self.tmp / ("long-" + "l" * 150), short)
+ d = json.loads(out.strip().splitlines()[-1])
+ self.assertGreater(d["home"], 160)
+ self.assertGreater(d["tmp"], 160)
+ self.assertEqual(d["got"], str(short / "ok" / ("showtime-espeak-%d" % os.getuid()) / "espeak-ng-data"))
+ self.assertTrue((Path(d["got"]) / "phontab").is_file())
+ self.assertEqual(d["mode"], "0o700")
+ self.assertIsNone(d["loose"], "a folder others can write to is not used")
+ self.assertIn("data path too long", d["err"]["message"])
+ self.assertIn("longer than 140 bytes", d["err"]["hint"])
+ self.assertIn("SHOWTIME_HOME or TMPDIR", d["err"]["hint"])
+ self.assertNotIn("showtime setup", d["err"]["hint"])
+ self.assertEqual(d["check"], {"ok": False, "error": d["err"]["message"], "hint": d["err"]["hint"]},
+ "doctor and setup show this hint")
+
+ def test_11_setup_runs_the_espeak_self_test(self):
+ """Setup does not report success while voice cannot work: it runs doctor's espeak-ng self-test."""
+ from st import lazy
+ su = lazy._setup()
+ home = self.tmp / "setup-espeak"
+ inst = su.Installer(su.parse_args(["--home", str(home)]))
+ inst.vpy = Path(PY)
+ data = home / "espeak-ng-data"
+ data.mkdir(parents=True, exist_ok=True)
+ (data / "phontab").write_bytes(b"x")
+ inst.env_common.update(SHOWTIME_ESPEAK_LIB=str(home / "no-such-libespeak-ng"), SHOWTIME_ESPEAK_DATA=str(data))
+ status, detail = inst.step_espeak()
+ self.assertEqual(status, "fail", detail)
+ self.assertIn("no working espeak-ng", detail)
+ self.assertIn("fix: ", detail)
+ if PY != VPY:
+ self.skipTest("no showtime venv: the passing self-test needs phonemizer")
+ for k in ("SHOWTIME_ESPEAK_LIB", "SHOWTIME_ESPEAK_DATA"):
+ inst.env_common.pop(k)
+ status, detail = inst.step_espeak()
+ self.assertEqual(status, "ok", detail)
+ self.assertIn("self-test passed", detail)
+
+ def test_12_ipa_lexicon_hint_names_real_flags(self):
+ """With no lexicon.json, `voice ipa` says which command reads which lexicon, with flags that exist."""
+ import re
+ empty = self.tmp / "ipa-empty"
+ empty.mkdir(exist_ok=True)
+ cp = subprocess.run([sys.executable, str(LAUNCHER), "voice", "ipa", "hello"], env=ENV, cwd=str(empty),
+ stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding="utf-8", timeout=120)
+ self.assertEqual(cp.returncode, 0, cp.stderr)
+ hint = next(ln for ln in cp.stderr.splitlines() if ln.startswith("lexicon: "))
+ named = re.findall(r"`voice (\w+) (--[\w-]+)", hint)
+ self.assertTrue(named, hint)
+ for sub, flag in named:
+ self.assertIn(flag, st("voice", sub, "--help").stdout, "%s: `voice %s` has no %s" % (hint, sub, flag))
+ self.assertIn("`voice script` reads the lexicon.json next to its script", hint)
+
+
if __name__ == "__main__":
argv = [a for a in sys.argv if a != "--fast"]
t0 = time.time()