Skip to content

Video as code: canvas scenes rendered with WebCodecs in headless Chrome, a review viewer, and agent skills that build the video from your references.

README setup per agent; clear messages for missing mediabunny and lost WebGL

StaryOne73782d91e363
diff --git a/CHANGELOG.md b/CHANGELOG.md
index bbac20d..9e4cb72 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,11 +8,14 @@ Changes are listed by release, newest first. The sections dated before 0.1.0 rec
- `npm install -g @motlab/cli` gave no working `motlab` command under nvm for Windows 2.0, whose shim mode keeps npm's global folder off PATH, and the README's next step, `motlab setup`, failed there with "not recognized". Setup now notices when npm's command folder is not on PATH and writes the same `motlab` launcher to `~/.local/bin` that the clone installer writes, pointing at the engine in npm's folder, and prints the line that adds `~/.local/bin` to PATH when it is missing. `motlab uninstall` removes it, and an update with `npm install -g @motlab/cli@latest` keeps it working. Where npm's folder is on PATH nothing changes.
- Setup run from npx's cache, with no global install, stops and says to install first instead of copying skills from a folder npx may clear.
+- When mediabunny is not installed, as in a clone where `npm ci` was never run, the renderer said only that the page "failed to fetch dynamically imported module ... mediabunny.mjs" before it fell back to the raw bitstream. It now says mediabunny is not installed and to run `npm ci` in the engine folder. Seen on a Linux VPS where the tests ran in a fresh clone; checked on Windows with a copy of the engine that has no `node_modules`.
+- A scene transition whose WebGL context was lost failed with "transition fade: null", because the shader logs come back empty then. It now says the context was lost and to render again. Seen once on CI's Ubuntu runner, where Chrome draws with SwiftShader, and passed when the job ran again; the message was checked by losing the context on purpose with `WEBGL_lose_context`.
- `motlab doctor` reported mediabunny missing when npm put it next to the engine folder instead of inside it, as npx does. It now finds it the way the server does, through Node's module resolution.
### Changed
- When Chrome is missing on Linux, `motlab doctor` prints the commands that install Google's `.deb` on x64 Debian or Ubuntu, and says the Chromium snap can fail headless, instead of "install Google Chrome or Chromium from your distribution". On other processors it says to use the distribution's Chromium, not the snap. Checked by printing the hint with the platform set to Linux x64 and arm64 on the Windows laptop; the commands have not been run on Linux.
+- The README's install section lists the setup command for each agent (Claude Code, the agents that read `~/.agents/skills`, Antigravity, several at once, any other folder) instead of a folded list of options.
- The README and the install docs run setup as `npx @motlab/cli setup`, which works before `motlab` is on PATH; npx runs the installed package and downloads nothing.
To tell whether npm's folder is on the user's PATH, setup drops the folders a Node process sees in front of it that the terminal does not have: nvm's shim puts Node's own folder first, and npx adds its `node_modules\.bin` folders, node-gyp-bin and Node's folder again. Under nvm, Node's folder is npm's global folder, so without this the check always passed. `test/install.test.js` covers both cases on the CI runners.
diff --git a/README.md b/README.md
index a34047f..3330dfb 100644
--- a/README.md
+++ b/README.md
@@ -49,20 +49,19 @@ npm install -g @motlab/cli
npx @motlab/cli setup
```
-npm installs the engine. Setup copies both skills to `~/.claude/skills/`, checks the machine, and makes sure the `motlab` command works: where npm's folder is not on PATH (nvm for Windows), it adds the command to `~/.local/bin`. After that it is `motlab` everywhere, and `motlab doctor` checks the machine again at any time.
+npm installs the engine. Setup copies both skills to your agent's skill folder, checks the machine, and makes sure the `motlab` command works: where npm's folder is not on PATH (nvm for Windows), it adds the command to `~/.local/bin`. After that it is `motlab` everywhere, and `motlab doctor` checks the machine again at any time.
-<details><summary>Skills for other agents, and the other options</summary>
+Setup installs the skills for Claude Code unless you name another agent:
-<br>
-
-- `--skill agents` for Codex, Cursor, OpenCode, Copilot, Gemini CLI, Amp and Windsurf
-- `--skill antigravity` for the Antigravity App and CLI
-- several at once with commas: `--skill claude,agents,antigravity`
-- `--skill-dir <dir>` for any other agent's skill folder
-- `--link` to link the skills instead of copying them
-- `--dry-run` to see every step first
+| Your agent | Setup command |
+|---|---|
+| Claude Code | `npx @motlab/cli setup` |
+| Codex, Cursor, OpenCode, GitHub Copilot, Gemini CLI, Amp, Windsurf | `npx @motlab/cli setup --skill agents` |
+| Antigravity (App and CLI) | `npx @motlab/cli setup --skill antigravity` |
+| Several of them | `npx @motlab/cli setup --skill claude,agents,antigravity` |
+| Any other agent | `npx @motlab/cli setup --skill-dir <its skill folder>` |
-</details>
+Running it again for another agent adds the skills there too. `--dry-run` shows every step first, and `--link` links the skills instead of copying them. Start a new agent session afterwards so it loads them.
<details><summary>From a clone instead, to work on motlab</summary>
diff --git a/src/doctor.js b/src/doctor.js
index 03ae675..8542e32 100644
--- a/src/doctor.js
+++ b/src/doctor.js
@@ -5,7 +5,7 @@ import { createRequire } from 'node:module';
import { findChrome } from './chrome.js';
// Found the way the server finds it: npm may put it inside the engine folder (a clone, a global install) or next to it.
-const hasMediabunny = () => { try { createRequire(import.meta.url).resolve('mediabunny'); return true; } catch { return false; } };
+export const hasMediabunny = () => { try { createRequire(import.meta.url).resolve('mediabunny'); return true; } catch { return false; } };
const run = (cmd, args) => {
const r = spawnSync(cmd, args, { encoding: 'utf8', shell: false });
diff --git a/src/page/transitions.js b/src/page/transitions.js
index dac25d8..3d286f9 100644
--- a/src/page/transitions.js
+++ b/src/page/transitions.js
@@ -69,16 +69,21 @@ export function createMixer() {
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([-1, -1, 3, -1, -1, 3]), gl.STATIC_DRAW); // one triangle over the frame
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true);
+ // A lost context makes every WebGL call fail and the info logs come back null ("transition fade: null"). It happened
+ // once on a GPU-less CI runner, where Chrome draws with SwiftShader; render again.
+ const lost = () => { if (gl.isContextLost()) throw new Error("scene transitions lost their WebGL context (Chrome's GPU process restarted); render again"); };
+
function program(name) {
if (programs.has(name)) return programs.get(name);
+ lost();
const t = findTransition(name), p = gl.createProgram();
for (const [type, src] of [[gl.VERTEX_SHADER, VERT], [gl.FRAGMENT_SHADER, frag(t.glsl)]]) {
const s = gl.createShader(type); gl.shaderSource(s, src); gl.compileShader(s);
- if (!gl.getShaderParameter(s, gl.COMPILE_STATUS)) throw new Error(`transition ${t.name}: ${gl.getShaderInfoLog(s)}`);
+ if (!gl.getShaderParameter(s, gl.COMPILE_STATUS)) { lost(); throw new Error(`transition ${t.name}: ${gl.getShaderInfoLog(s)}`); }
gl.attachShader(p, s);
}
gl.bindAttribLocation(p, 0, 'p'); gl.linkProgram(p);
- if (!gl.getProgramParameter(p, gl.LINK_STATUS)) throw new Error(`transition ${t.name}: ${gl.getProgramInfoLog(p)}`);
+ if (!gl.getProgramParameter(p, gl.LINK_STATUS)) { lost(); throw new Error(`transition ${t.name}: ${gl.getProgramInfoLog(p)}`); }
const entry = { p, t, u: n => gl.getUniformLocation(p, n) };
programs.set(name, entry); return entry;
}
diff --git a/src/render.js b/src/render.js
index 2bc02af..216fcb9 100644
--- a/src/render.js
+++ b/src/render.js
@@ -4,9 +4,11 @@ import { createReadStream, createWriteStream, existsSync, mkdirSync, mkdtempSync
import { tmpdir } from 'node:os';
import { dirname, join, relative, resolve, sep } from 'node:path';
import { pipeline } from 'node:stream/promises';
+import { fileURLToPath } from 'node:url';
import { setTimeout as sleep } from 'node:timers/promises';
import { attachPage, findChrome, launchChrome } from './chrome.js';
import { frameCount, splitFrames } from './codecs.js';
+import { hasMediabunny } from './doctor.js';
import { finalize, probeVideo } from './ffmpeg.js';
import { label, rate, selectEncoder } from './probe.js';
import { startServer } from './server.js';
@@ -127,7 +129,9 @@ export async function renderVideo(o) {
try { res = await attempt(want === 'raw' ? 'raw' : 'mediabunny'); }
catch (e) {
if (want !== 'auto' || o.signal?.aborted) throw e;
- log(`\nMediabunny path failed (${e.message.split('\n')[0]}). Retrying with raw bitstream and ffmpeg.`);
+ // Without the npm package the page only says it "failed to fetch" mediabunny.mjs, so the cause is named here.
+ const why = hasMediabunny() ? e.message.split('\n')[0] : `mediabunny is not installed: run npm ci in ${fileURLToPath(new URL('..', import.meta.url))}`;
+ log(`\nMediabunny path failed (${why}). Retrying with raw bitstream and ffmpeg.`);
res = await attempt('raw');
}
if (process.stdout.isTTY) process.stdout.write('\r');