Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

remotion: cover the verdict and the shell scripts, count every composition

dee19532130774a
diff --git a/store/agents/remotion/toolchain/test_scripts.py b/store/agents/remotion/toolchain/test_scripts.py
new file mode 100644
index 000000000..29c2650ca
--- /dev/null
+++ b/store/agents/remotion/toolchain/test_scripts.py
@@ -0,0 +1,240 @@
+"""setup.sh, doctor.sh, init-workspace.sh and the two wrappers ($REMOTION, viewer.sh), run for real
+against a scratch install whose PATH holds only stub commands (node, npm, python3, git) and the few
+coreutils the scripts use, so every ok / warn / miss line is reached without a network, npm or
+Remotion on the machine:
+
+ python3 -m unittest toolchain/test_scripts.py
+"""
+import os, shutil, subprocess, tempfile, unittest
+from pathlib import Path
+
+PACKAGE = Path(__file__).resolve().parent.parent
+# A bash line tracer (BASH_ENV sourcing a DEBUG trap that appends to SHCOV_OUT) is passed through when set.
+TRACER = {k: os.environ[k] for k in ("BASH_ENV", "SHCOV_OUT") if k in os.environ}
+BASH = "/bin/bash"
+COREUTILS = ("dirname", "cat", "mkdir", "rm", "ls", "tr", "ln")
+VERSIONS = dict(line.split("=", 1) for line in (PACKAGE / "VERSIONS").read_text().split())
+COMMIT = VERSIONS["SKILLS_COMMIT"]
+
+# node as the scripts use it: -e is the version check (NODE_OK), -p reads a package version, -v.
+NODE = """case "$1" in
+ -e) exit "${NODE_OK:-0}" ;;
+ -p) case "$2" in *remotion/package.json*) echo 4.0.525 ;; *react/package.json*) echo 19.3.0 ;; esac ;;
+ -v) echo v22.1.0 ;;
+ *) exit "${NODE_CODE:-0}" ;;
+esac"""
+# git as setup.sh uses it: the checkout lays out the skills (unless GIT_EMPTY), a fetch can fail.
+GIT = """[ "$1" = fetch ] && exit "${GIT_FETCH:-0}"
+if [ "$1" = checkout ] && [ -z "$GIT_EMPTY" ]; then
+ mkdir -p skills/remotion-best-practices skills/remotion-captions
+ echo skill > skills/remotion-best-practices/SKILL.md
+fi
+exit 0"""
+
+
+class Sandbox:
+ """An install dir linking the package's scripts, a bin/ of stubs as the whole PATH, and a log of
+ every stub call."""
+
+ def __init__(self, test: unittest.TestCase):
+ tmp = tempfile.TemporaryDirectory()
+ test.addCleanup(tmp.cleanup)
+ self.root = Path(tmp.name)
+ self.install = self.root / "install"
+ (self.install / "toolchain").mkdir(parents=True)
+ # Linked, not copied, so a line tracer maps back to the source. Never chmod or write these.
+ for name in ("setup.sh", "doctor.sh", "init-workspace.sh", "remotion"):
+ (self.install / "toolchain" / name).symlink_to(PACKAGE / "toolchain" / name)
+ (self.install / "viewer.sh").symlink_to(PACKAGE / "viewer.sh")
+ shutil.copy(PACKAGE / "VERSIONS", self.install / "VERSIONS")
+ self.bin = self.root / "bin"
+ self.bin.mkdir()
+ self.calls = self.root / "calls.log"
+ self.calls.touch()
+ for name in COREUTILS:
+ real = next(p for p in (Path("/bin") / name, Path("/usr/bin") / name) if p.exists())
+ (self.bin / name).symlink_to(real)
+
+ def stub(self, name: str, body: str = "", where: Path | None = None) -> Path:
+ path = (where or self.bin) / name
+ path.parent.mkdir(parents=True, exist_ok=True)
+ path.unlink(missing_ok=True) # never write through a link to a real binary
+ path.write_text(f'#!/bin/bash\necho "{name} $*" >> "$CALLS"\n{body}\n')
+ path.chmod(0o755)
+ return path
+
+ def tools(self, *names: str) -> "Sandbox":
+ bodies = {"node": NODE, "git": GIT, "npm": 'exit "${NPM_CODE:-0}"', "python3": '[ "$1" = --version ] && echo "Python 3.12.1"; exit "${PY_CODE:-0}"'}
+ for name in names:
+ self.stub(name, bodies[name])
+ return self
+
+ def skills(self, commit: str | None = COMMIT) -> None:
+ skill = self.install / "upstream" / "skills" / "remotion-best-practices" / "SKILL.md"
+ skill.parent.mkdir(parents=True, exist_ok=True)
+ skill.write_text("skill")
+ if commit is not None:
+ (self.install / "upstream" / ".harness-commit").write_text(commit + "\n")
+
+ def run(self, script: str, *args: str, cwd: Path | None = None, **env: str) -> subprocess.CompletedProcess:
+ return subprocess.run([BASH, str(self.install / script), *args], cwd=cwd or self.install,
+ env={"PATH": str(self.bin), "CALLS": str(self.calls), **TRACER, **env},
+ capture_output=True, text=True, timeout=60)
+
+ def logged(self) -> list[str]:
+ return self.calls.read_text().splitlines()
+
+
+class Setup(unittest.TestCase):
+ def sandbox(self) -> Sandbox:
+ box = Sandbox(self).tools("node", "npm", "python3", "git")
+ box.stub("remotion", 'exit "${BROWSER_CODE:-0}"', where=box.install / "node_modules" / ".bin")
+ return box
+
+ def test_a_first_install(self):
+ box = self.sandbox()
+ r = box.run("toolchain/setup.sh")
+ self.assertEqual(r.returncode, 0, r.stderr)
+ self.assertEqual(r.stdout.splitlines(), [
+ " npm ci (remotion 4.0.525, a few minutes the first time)",
+ "ok remotion 4.0.525 · react 19.3.0",
+ " remotion browser ensure (the headless Chrome renders use)",
+ "ok headless browser",
+ f" fetching remotion-dev/skills @ {COMMIT}",
+ "ok skills: remotion-best-practices remotion-captions ",
+ ])
+ self.assertIn("npm ci --silent --no-audit --no-fund", box.logged())
+ self.assertIn("remotion browser ensure", box.logged())
+ git = [c for c in box.logged() if c.startswith("git ")]
+ self.assertEqual(git, ["git init -q", "git remote add origin https://github.com/remotion-dev/skills.git",
+ f"git fetch -q --depth 1 origin {COMMIT}", "git checkout -q FETCH_HEAD"])
+ self.assertEqual((box.install / "upstream" / ".harness-commit").read_text(), COMMIT + "\n")
+
+ def test_skills_at_the_pinned_commit_are_kept_and_no_browser_is_a_warning(self):
+ box = self.sandbox()
+ box.skills()
+ r = box.run("toolchain/setup.sh", BROWSER_CODE="1")
+ self.assertEqual(r.returncode, 0, r.stderr)
+ self.assertIn("warn no headless browser yet — renders will fetch it on first use", r.stdout.splitlines())
+ self.assertEqual(r.stdout.splitlines()[-1], "ok skills: remotion-best-practices ")
+ self.assertFalse(any(c.startswith("git ") for c in box.logged()))
+
+ def test_skills_at_another_commit_are_fetched_again(self):
+ box = self.sandbox()
+ box.skills("0000000")
+ (box.install / "upstream" / "stale.txt").write_text("old")
+ r = box.run("toolchain/setup.sh")
+ self.assertEqual(r.returncode, 0, r.stderr)
+ self.assertIn(f" fetching remotion-dev/skills @ {COMMIT}", r.stdout.splitlines())
+ self.assertFalse((box.install / "upstream" / "stale.txt").exists())
+
+ def test_a_fetch_without_the_skill_is_a_miss(self):
+ r = self.sandbox().run("toolchain/setup.sh", GIT_EMPTY="1")
+ self.assertEqual(r.returncode, 1)
+ self.assertEqual(r.stdout.splitlines()[-1], "miss upstream/skills/remotion-best-practices/SKILL.md")
+
+ def test_failures_stop_setup(self):
+ for env in ({"NPM_CODE": "1"}, {"GIT_FETCH": "128"}):
+ with self.subTest(**env):
+ r = self.sandbox().run("toolchain/setup.sh", **env)
+ self.assertNotEqual(r.returncode, 0)
+ self.assertFalse(r.stdout.splitlines()[-1].startswith("ok skills"))
+
+ def test_missing_tools_are_misses(self):
+ cases = (((), {}, "miss node >= 18 on PATH"),
+ (("node",), {"NODE_OK": "1"}, "miss node >= 18 on PATH"),
+ (("node",), {}, "miss npm on PATH"),
+ (("node", "npm"), {}, "miss python3 (the verdict)"))
+ for tools, env, line in cases:
+ with self.subTest(line=line, tools=tools):
+ box = Sandbox(self).tools(*tools)
+ r = box.run("toolchain/setup.sh", **env)
+ self.assertEqual((r.returncode, r.stdout.strip()), (1, line))
+
+
+class Doctor(unittest.TestCase):
+ def test_ready(self):
+ box = Sandbox(self).tools("node", "python3")
+ box.stub("remotion", where=box.install / "node_modules" / ".bin")
+ box.skills()
+ r = box.run("toolchain/doctor.sh")
+ self.assertEqual(r.returncode, 0, r.stderr)
+ self.assertEqual(r.stdout.splitlines(), [
+ "ok remotion 4.0.525",
+ f"ok skills @ {COMMIT}",
+ "ok $REMOTION (render progress for the pane) · node v22.1.0",
+ "ok Python 3.12.1",
+ ])
+
+ def test_nothing_installed(self):
+ box = Sandbox(self).tools("node")
+ r = box.run("toolchain/doctor.sh", NODE_OK="1")
+ self.assertEqual(r.returncode, 1)
+ self.assertEqual(r.stdout.splitlines(), [
+ "miss node_modules — run toolchain/setup.sh",
+ "miss upstream skills — run toolchain/setup.sh",
+ "miss node >= 18 or an executable toolchain/remotion",
+ "miss python3",
+ ])
+
+ def test_no_executable_wrapper_and_no_commit_file(self):
+ box = Sandbox(self).tools("node", "python3")
+ box.stub("remotion", where=box.install / "node_modules" / ".bin")
+ box.skills(commit=None)
+ (box.install / "toolchain" / "remotion").unlink()
+ r = box.run("toolchain/doctor.sh")
+ self.assertEqual(r.returncode, 1)
+ self.assertEqual(r.stdout.splitlines()[1:3], ["ok skills @ ", "miss node >= 18 or an executable toolchain/remotion"])
+
+
+class InitWorkspace(unittest.TestCase):
+ def test_links_the_shared_node_modules_and_seeds_the_verdict(self):
+ box = Sandbox(self).tools("python3")
+ ws = box.root / "ws"
+ ws.mkdir()
+ r = box.run("toolchain/init-workspace.sh", cwd=ws, HARNESS_DSH_DIR=str(box.install), PY_CODE="1") # a failing verdict does not stop init
+ self.assertEqual(r.returncode, 0, r.stderr)
+ self.assertTrue(all((ws / d).is_dir() for d in (".harness", "out", "public")))
+ self.assertEqual(os.readlink(ws / "node_modules"), f"{box.install}/node_modules")
+ self.assertEqual(box.logged(), [f"python3 {box.install}/toolchain/verdict.py"])
+
+ def test_a_node_modules_already_there_is_kept(self):
+ box = Sandbox(self).tools("python3")
+ ws = box.root / "ws"
+ (ws / "node_modules").mkdir(parents=True)
+ r = box.run("toolchain/init-workspace.sh", cwd=ws, HARNESS_DSH_DIR=str(box.install))
+ self.assertEqual(r.returncode, 0, r.stderr)
+ self.assertFalse((ws / "node_modules").is_symlink())
+
+ def test_needs_the_install_dir(self):
+ box = Sandbox(self)
+ r = box.run("toolchain/init-workspace.sh", cwd=box.root)
+ self.assertNotEqual(r.returncode, 0)
+ self.assertIn("HARNESS_DSH_DIR", r.stderr)
+
+
+class Wrappers(unittest.TestCase):
+ def test_remotion_is_node_on_remotion_mjs_with_the_same_arguments_and_exit_code(self):
+ box = Sandbox(self).tools("node")
+ r = box.run("toolchain/remotion", "render", "Main", "out/main.mp4", NODE_CODE="7")
+ self.assertEqual(r.returncode, 7)
+ self.assertEqual(box.logged(), [f"node {box.install}/toolchain/remotion.mjs render Main out/main.mp4"])
+
+ def test_viewer_sh_runs_the_pane_server(self):
+ box = Sandbox(self).tools("node")
+ r = box.run("viewer.sh", HARNESS_VIEWER_PORT="4321", HARNESS_WORKSPACE=str(box.root))
+ self.assertEqual(r.returncode, 0, r.stderr)
+ self.assertEqual(box.logged(), [f"node {box.install}/viewer.mjs"])
+
+ def test_viewer_sh_needs_its_port_and_workspace(self):
+ box = Sandbox(self).tools("node")
+ for env, missing in (({"HARNESS_WORKSPACE": "/tmp"}, "HARNESS_VIEWER_PORT"), ({"HARNESS_VIEWER_PORT": "1"}, "HARNESS_WORKSPACE")):
+ with self.subTest(missing=missing):
+ r = box.run("viewer.sh", **env)
+ self.assertNotEqual(r.returncode, 0)
+ self.assertIn(missing, r.stderr)
+ self.assertEqual(box.logged(), [])
+
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/store/agents/remotion/toolchain/test_verdict.py b/store/agents/remotion/toolchain/test_verdict.py
index d6e39120f..dbe43f981 100644
--- a/store/agents/remotion/toolchain/test_verdict.py
+++ b/store/agents/remotion/toolchain/test_verdict.py
@@ -1,7 +1,12 @@
-import sys, unittest
+import contextlib, io, json, os, runpy, subprocess, sys, tempfile, unittest
from pathlib import Path
+from unittest import mock
sys.path.insert(0, str(Path(__file__).parent))
-from verdict import judge
+import verdict
+from verdict import composition_ids, judge
+
+HERE = Path(__file__).resolve().parent
+
class Judge(unittest.TestCase):
def test_bundles_with_a_render(self):
@@ -11,8 +16,148 @@ class Judge(unittest.TestCase):
def test_bundle_error(self):
v = judge(True, [], "src/Main.tsx(12,5): error TS2304: Cannot find name 'foo'.", None, False)
self.assertFalse(v["ready"]); self.assertEqual(v["phases"][1]["state"], "failed")
+ self.assertEqual(v["summary"], "does not bundle")
def test_stale_render_is_a_warning(self):
v = judge(True, ["Main"], None, "out/main.mp4", True)
self.assertTrue(v["ready"]); self.assertEqual(v["phases"][2]["state"], "active"); self.assertEqual(v["findings"][0]["severity"], "warning")
+ self.assertEqual(v["summary"], "1 composition: Main · main.mp4 (stale)")
+ def test_no_compositions_is_an_error(self):
+ v = judge(True, [], None, None, False)
+ self.assertFalse(v["ready"]); self.assertIn("no compositions registered", v["findings"][0]["message"])
+ def test_many_compositions_are_shortened_and_a_bundled_project_without_a_render_is_rendering_next(self):
+ v = judge(True, ["A", "B", "C", "D", "E"], None, None, False)
+ self.assertEqual(v["summary"], "5 compositions: A, B, C, D…")
+ self.assertEqual(v["phases"][2]["state"], "active")
+ def test_no_project(self):
+ v = judge(False, [], None, None, False)
+ self.assertEqual(v["summary"], "no project yet")
+ self.assertEqual([p["state"] for p in v["phases"]], ["active", "pending", "pending"])
+ def test_a_render_of_a_project_that_no_longer_bundles(self):
+ v = judge(True, [], "boom", "out/main.mp4", False)
+ self.assertEqual((v["summary"], v["artifact"], v["phases"][2]["state"]), ("main.mp4", "out/main.mp4", "pending"))
+
+
+class CompositionIds(unittest.TestCase):
+ def test_quiet_prints_every_id_on_one_line(self):
+ # Remotion 4.0.525's printCompositions with --quiet: compositions.map((c) => c.id).join(' ')
+ self.assertEqual(composition_ids("Main Intro Outro\n"), ["Main", "Intro", "Outro"])
+ def test_chatter_and_blanks_are_not_ids(self):
+ self.assertEqual(composition_ids("Bundling 100%\n\nGetting composition\n(stuff)\nMain\n"), ["Main"])
+
+
+# `remotion compositions src/index.ts --quiet`, played by a script: stdout, stderr and the exit code
+# come from files beside it, so each test says what the CLI answers.
+FAKE = """#!/bin/sh
+here="$(dirname "$0")"
+cat "$here/stdout" 2>/dev/null
+cat "$here/stderr" >&2 2>/dev/null
+exit "$(cat "$here/code" 2>/dev/null || echo 0)"
+"""
+
+
+class Main(unittest.TestCase):
+ """verdict.py on a workspace: what it runs, what it writes, what it prints and returns."""
+
+ def setUp(self):
+ tmp = tempfile.TemporaryDirectory()
+ self.addCleanup(tmp.cleanup)
+ self.ws = Path(tmp.name) / "ws"
+ self.ws.mkdir()
+ self.cli = Path(tmp.name) / "cli"
+ self.cli.mkdir()
+ (self.cli / "remotion").write_text(FAKE)
+ (self.cli / "remotion").chmod(0o755)
+ for name, value in (("WS", self.ws), ("REMOTION", str(self.cli / "remotion"))):
+ patcher = mock.patch.object(verdict, name, value)
+ patcher.start()
+ self.addCleanup(patcher.stop)
+
+ def answer(self, stdout="", stderr="", code=0):
+ (self.cli / "stdout").write_text(stdout); (self.cli / "stderr").write_text(stderr); (self.cli / "code").write_text(str(code))
+
+ def project(self):
+ (self.ws / "src").mkdir(exist_ok=True)
+ (self.ws / "src" / "Root.tsx").write_text("export const Root = () => null\n")
+ (self.ws / "src" / "index.ts").write_text("registerRoot(Root)\n")
+
+ def write(self, rel, body=b"x", mtime=None):
+ path = self.ws / rel
+ path.parent.mkdir(parents=True, exist_ok=True)
+ path.write_bytes(body)
+ if mtime is not None:
+ os.utime(path, (mtime, mtime))
+ return path
+
+ def main(self):
+ out = io.StringIO()
+ with contextlib.redirect_stdout(out):
+ code = verdict.main(["verdict.py"])
+ return code, out.getvalue(), json.loads((self.ws / ".harness" / "verdict.json").read_text())
+
+ def test_an_empty_folder_is_no_project(self):
+ code, printed, v = self.main()
+ self.assertEqual((code, v["summary"], v["artifact"]), (1, "no project yet", None))
+ self.assertEqual(printed, "not ready · no project yet\n")
+
+ def test_every_composition_the_quiet_cli_lists_is_counted(self):
+ self.project()
+ self.answer(stdout="Main Intro Outro\n")
+ code, printed, v = self.main()
+ self.assertEqual(code, 0)
+ self.assertEqual(v["summary"], "3 compositions: Main, Intro, Outro")
+ self.assertEqual(printed, "ready · 3 compositions: Main, Intro, Outro\n")
+
+ def test_the_newest_render_is_the_artifact_and_stale_when_the_source_moved_on(self):
+ self.project()
+ self.answer(stdout="Main\n")
+ os.utime(self.ws / "src" / "Root.tsx", (2000, 2000)); os.utime(self.ws / "src" / "index.ts", (2000, 2000))
+ self.write("out/old.mp4", mtime=1000)
+ self.write("out/main.webm", mtime=3000)
+ self.write("out/notes.txt", mtime=9000) # not a render
+ (self.ws / "out" / "folder.gif").mkdir() # not a file
+ self.write("out/node_modules/cache.mp4", mtime=9000) # never a render
+ _, _, v = self.main()
+ self.assertEqual((v["artifact"], v["summary"]), ("out/main.webm", "1 composition: Main · main.webm"))
+ self.write("src/Main.tsx", mtime=4000)
+ code, printed, v = self.main()
+ self.assertEqual((code, v["summary"]), (0, "1 composition: Main · main.webm (stale)"))
+ self.assertIn(" warning main.webm is older than the source — render again", printed)
+
+ def test_a_bundle_error_is_the_last_line_the_cli_printed(self):
+ self.project()
+ # stderr without a final newline, and chatter on stdout: the two used to be glued into one line
+ self.answer(stdout="Bundling 40%\n", stderr="Error: bundling failed\nsrc/Main.tsx(3,1): error TS1005: ';' expected.", code=1)
+ code, printed, v = self.main()
+ self.assertEqual(code, 1)
+ self.assertEqual(v["findings"], [{"severity": "error", "kind": "bundle", "message": "src/Main.tsx(3,1): error TS1005: ';' expected."}])
+ self.assertIn(" error src/Main.tsx(3,1): error TS1005", printed)
+
+ def test_a_failure_on_stdout_alone_or_silent(self):
+ self.project()
+ self.answer(stdout="Could not find src/index.ts\n", code=1)
+ self.assertEqual(self.main()[2]["findings"][0]["message"], "Could not find src/index.ts")
+ self.answer(code=3)
+ _, _, v = self.main()
+ self.assertEqual(v["findings"][0]["message"], "remotion compositions exited 3")
+
+ def test_a_cli_that_cannot_run_or_hangs_is_a_bundle_error(self):
+ self.project()
+ with mock.patch.object(verdict, "REMOTION", str(self.ws / "missing" / "remotion")):
+ _, _, v = self.main()
+ self.assertTrue(v["findings"][0]["message"].startswith("remotion could not run ("), v["findings"])
+ with mock.patch.object(verdict.subprocess, "run", side_effect=subprocess.TimeoutExpired(["remotion"], 600)):
+ _, _, v = self.main()
+ self.assertIn("timed out after 600 seconds", v["findings"][0]["message"])
+
+ def test_run_as_a_script(self):
+ self.project()
+ self.answer(stdout="Main\n")
+ env = {"HARNESS_WORKSPACE": str(self.ws), "REMOTION": str(self.cli / "remotion")}
+ with mock.patch.dict(os.environ, env), mock.patch.object(sys, "argv", ["verdict.py"]), contextlib.redirect_stdout(io.StringIO()):
+ with self.assertRaises(SystemExit) as exit_:
+ runpy.run_path(str(HERE / "verdict.py"), run_name="__main__")
+ self.assertEqual(exit_.exception.code, 0)
+ self.assertTrue(json.loads((self.ws / ".harness" / "verdict.json").read_text())["ready"])
+
if __name__ == "__main__": unittest.main()
diff --git a/store/agents/remotion/toolchain/verdict.py b/store/agents/remotion/toolchain/verdict.py
index c9e558b58..ad4d02ab2 100755
--- a/store/agents/remotion/toolchain/verdict.py
+++ b/store/agents/remotion/toolchain/verdict.py
@@ -26,6 +26,22 @@ def newest(root: Path, suffixes: tuple[str, ...]) -> Path | None:
return best[1] if best else None
+ID_RE = re.compile(r"[A-Za-z0-9_\-]+")
+CHATTER = ("Bundling", "Getting", "Downloading", "Compositions", "id", "ID")
+
+
+def composition_ids(stdout: str) -> list[str]:
+ """The ids `remotion compositions --quiet` prints — all of them on ONE line, separated by spaces
+ (Remotion 4's printCompositions). A line that does not start with an id (a header, a blank,
+ progress) is dropped rather than counted."""
+ ids: list[str] = []
+ for line in stdout.splitlines():
+ words = line.split()
+ if words and ID_RE.fullmatch(words[0]) and words[0] not in CHATTER:
+ ids += [w for w in words if ID_RE.fullmatch(w)]
+ return ids
+
+
def judge(written: bool, comps: list[str], bundle_err: str | None, render: str | None, stale: bool) -> dict:
findings: list[dict] = []
if bundle_err:
@@ -46,7 +62,8 @@ def judge(written: bool, comps: list[str], bundle_err: str | None, render: str |
if render:
bits.append(f"{Path(render).name}{' (stale)' if stale else ''}")
if not bits:
- bits.append("bundles" if bundled else ("does not bundle" if written else "no project yet"))
+ # Bundled means compositions, which are always named above: only the failures get here.
+ bits.append("does not bundle" if written else "no project yet")
return {"spec": 1, "ready": bool(bundled), "summary": " · ".join(bits), "findings": findings,
"artifact": render, "phases": phases, "updatedAt": time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime())}
@@ -59,16 +76,11 @@ def main(argv: list[str]) -> int:
try:
r = subprocess.run([REMOTION, "compositions", "src/index.ts", "--quiet"], capture_output=True, text=True, cwd=WS, timeout=600)
if r.returncode != 0:
- lines = [l for l in (r.stderr + r.stdout).splitlines() if l.strip()]
+ # The error is stderr's last line; stdout only when stderr said nothing.
+ lines = [l for l in r.stderr.splitlines() if l.strip()] or [l for l in r.stdout.splitlines() if l.strip()]
bundle_err = lines[-1] if lines else f"remotion compositions exited {r.returncode}"
else:
- # One composition per line, its id first; anything that is not an id (a header, a
- # blank, progress) is dropped rather than counted.
- comps = []
- for line in r.stdout.splitlines():
- first = line.strip().split()[0] if line.strip() else ""
- if re.fullmatch(r"[A-Za-z0-9_\-]+", first) and first not in ("Bundling", "Getting", "Downloading", "Compositions", "id", "ID"):
- comps.append(first)
+ comps = composition_ids(r.stdout)
except (OSError, subprocess.TimeoutExpired) as error:
bundle_err = f"remotion could not run ({error})"
render = newest(WS / "out", (".mp4", ".webm", ".gif")) if (WS / "out").is_dir() else None