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.

Publish to npm as @staryone/motlab, with motlab setup for the skills

StaryOnea22bf2368e8c
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2b4f681..a3b94c7 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,20 @@
Changes are listed by release, newest first. The sections dated before 0.1.0 record what was built on the way to the first release.
+## 0.2.0 (not released yet)
+
+### Added
+
+- motlab is on npm as `@staryone/motlab`, since the name `motlab` was taken there by an unrelated package. `npm install -g @staryone/motlab` installs the engine and the command. The package holds the engine, the skills, the example project and the docs (90 files, 943 kB packed); `bench/`, `test/` and the README images stay in the repository.
+- `motlab setup` copies the skills to agent folders after an npm install. It runs `install.js --skills-only`, so it takes the installer's skill options (`--skill`, `--skill-dir`, `--link`, `--update`, `--force`, `--dry-run`) and ends with `motlab doctor`.
+
+### Changed
+
+- From an npm install, `motlab update` asks npm for the newest version and prints the commands that get it (`npm install -g @staryone/motlab@latest`, then `motlab setup --update`), and `motlab uninstall` says to finish with `npm uninstall -g @staryone/motlab`. A clone works as before.
+- The README installs with npm first; the clone and `install.js` are under "From a clone instead".
+
+Tried on Windows 11: the packed tarball installed with `npm install -g --prefix` into a separate folder, with a separate home folder. `motlab setup --skill claude,agents`, `setup --update --dry-run`, `update`, `uninstall --yes`, and `motlab render` of a copy of the example at `--scale 0.5` (9 s, 3 scenes, in 11 s). Not tried: an install from the npm registry, macOS and Linux, and nvm for Windows as the global folder.
+
## 0.1.0 (2026-11-16)
The first release.
diff --git a/README.md b/README.md
index e8a8c83..d523aeb 100644
--- a/README.md
+++ b/README.md
@@ -8,7 +8,7 @@
A video engine where every scene is code, and an agent skill that writes the scenes for you.
-<code>git clone https://github.com/staryone/motlab.git && cd motlab && node install.js</code>
+<code>npm install -g @staryone/motlab && motlab setup</code>
[Demo](#watch-the-demo) · [Install](#install) · [Quick start](#quick-start) · [Speed](#speed) · [How it works](#how-it-works) · [Docs](#documentation) · [FAQ](#faq) · [Roadmap](ROADMAP.md)
@@ -45,34 +45,46 @@ https://github.com/user-attachments/assets/522d1db2-a0bd-43bd-84b7-9f071f224854
You need Node 24 or newer, Google Chrome or Chromium, and ffmpeg with ffprobe on PATH. Python 3 is optional and only used by the skills' helper scripts. Blender is optional too, for the asset skill's main 3D path.
```bash
-git clone https://github.com/staryone/motlab.git
-cd motlab
-node install.js
-motlab doctor
+npm install -g @staryone/motlab
+motlab setup
```
-The installer runs `npm ci`, puts a `motlab` command in `~/.local/bin`, copies both skills to `~/.claude/skills/`, and checks the machine. `motlab doctor` checks it again at any time.
+npm installs the engine and the `motlab` command. `motlab setup` copies both skills to `~/.claude/skills/` and checks the machine; `motlab doctor` checks it again at any time.
-<details><summary>Skills for other agents, and the other installer options</summary>
+<details><summary>Skills for other agents, and the other options</summary>
<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, or `--skill none` for no skills
+- `--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
</details>
-Later, `motlab update` gets the newest version from GitHub and copies the skills again to every agent folder they were installed in, and `motlab uninstall` removes the command, the skills and motlab's own files again.
+<details><summary>From a clone instead, to work on motlab</summary>
+
+<br>
+
+```bash
+git clone https://github.com/staryone/motlab.git
+cd motlab
+node install.js
+```
+
+The installer runs `npm ci`, puts a `motlab` command in `~/.local/bin` and copies the skills. It takes the same options, plus `--skill none` for no skills. Use it too when npm's global folder is not on PATH, as can happen with nvm for Windows.
+
+</details>
+
+Later, `motlab update` tells you when a new version is out and how to get it (from a clone it pulls it from GitHub itself), and `motlab uninstall` removes the skills and motlab's own files again.
[Install guide and per-OS notes](docs/install.md) · [Instructions for an agent doing the install](docs/install-for-agents.md)
## Quick start
-1. Run `motlab edit example`. It starts the viewer in the background, opens the sample project and prints its address, `http://127.0.0.1:4173/p/example/`. Space plays, the arrow keys on the timeline step one frame, Ctrl+scroll zooms the timeline, and a drag on the preview marks a box.
+1. Run `motlab edit example` in a folder that holds the sample project. In a clone that is the clone itself; after an npm install, copy `example/` out of the engine folder that `motlab --help` prints. It starts the viewer in the background, opens the sample project and prints its address, `http://127.0.0.1:4173/p/example/`. Space plays, the arrow keys on the timeline step one frame, Ctrl+scroll zooms the timeline, and a drag on the preview marks a box.
2. To make your own video, put your references in a folder and ask your agent, for example:
```text
@@ -150,7 +162,7 @@ Footage is decoded inside the page with Mediabunny, so a scene can cut and trim
<br>
-> The installer copies it for Claude Code by default. `--skill agents` covers Codex, Cursor, OpenCode, GitHub Copilot, Gemini CLI, Amp and Windsurf, and `--skill antigravity` the Antigravity App and CLI. `--skill-dir` takes any other agent's skill folder.
+> `motlab setup` and the installer copy it for Claude Code by default. `--skill agents` covers Codex, Cursor, OpenCode, GitHub Copilot, Gemini CLI, Amp and Windsurf, and `--skill antigravity` the Antigravity App and CLI. `--skill-dir` takes any other agent's skill folder.
</details>
diff --git a/ROADMAP.md b/ROADMAP.md
index 8635ed1..ea3cc8e 100644
--- a/ROADMAP.md
+++ b/ROADMAP.md
@@ -16,6 +16,7 @@ What is not built, what has not been tested, and ideas that came up while using
## Not tested yet
- The benchmark against Remotion and HyperFrames on macOS and Linux, with their own downloaded browsers, and on scenes heavy on text, images or footage. It was one scene on Windows, at 1080p and 4K.
+- The npm package beyond a tarball on Windows: installed from the registry, on macOS and Linux, and with nvm for Windows, where npm's global folder may not be on PATH.
- macOS, and Linux beyond the tests, including `motlab update` there. On Linux, CI renders the end-to-end tests on an Ubuntu runner; no real video has been made there. On macOS the Chrome paths and the Metal flag are in the code, but nothing has run.
- Renders longer than 10 minutes, and a 10-minute render on a machine that is doing nothing else.
- A machine without a GPU beyond the tests. CI runs the end-to-end tests on Linux and Windows runners without a GPU, and the benchmark ran with Chrome drawing on SwiftShader on the test laptop (1080p and 4K, in `docs/rendering.md`), but no real video has been rendered on such a machine, and no 3D (WebGL) scene.
diff --git a/docs/cli.md b/docs/cli.md
index a385300..278bb8f 100644
--- a/docs/cli.md
+++ b/docs/cli.md
@@ -9,11 +9,12 @@ motlab stills <page.html> <outDir> <t1> <t2> ... single frames as PNG or JPEG
motlab video <page.html> <out.mp4> [options] one page as an MP4
motlab events <page.html> <out.json> the page's EVENTS, for syncing sound
motlab doctor check Node, Chrome, ffmpeg and the skill's Python packages
-motlab update [--dry-run] the newest motlab from GitHub, and the skills copied again where they were installed
-motlab uninstall [--dry-run] [--yes] remove the command, the skills, ~/.motlab and the encoder cache
+motlab setup [--skill <target>] [--update] ... copy the skills to agent folders, after npm install -g
+motlab update [--dry-run] the newest motlab (from GitHub, or the npm commands that get it), and the skills copied again where they were installed
+motlab uninstall [--dry-run] [--yes] remove the skills, ~/.motlab, the encoder cache and a clone's command
```
-The viewer commands are described in [the viewer](viewer.md), `motlab update` in [Updating](install.md#updating) and `motlab uninstall` in [Removing](install.md#removing).
+The viewer commands are described in [the viewer](viewer.md), `motlab setup` in [From npm](install.md#from-npm), `motlab update` in [Updating](install.md#updating) and `motlab uninstall` in [Removing](install.md#removing).
`<project>` is a folder with `project.json`, or a project file in it such as `video/project-tiktok.json` (a [version](projects.md#versions)). `motlab --help` prints the same list and the engine folder.
diff --git a/docs/install-for-agents.md b/docs/install-for-agents.md
index abcc413..0299d08 100644
--- a/docs/install-for-agents.md
+++ b/docs/install-for-agents.md
@@ -12,9 +12,23 @@ ffprobe -version
Node must be 24 or newer. If Node is missing or older, tell the user and give them the command from the table in [install.md](install.md#requirements) for their OS. Do the same for Chrome and ffmpeg. Do not continue until Node 24 is there; Chrome and ffmpeg can be fixed after the install, because `motlab doctor` reports them again.
-## 2. Get the repository
+## 2. npm or a clone
-If the user has no clone yet, ask where it should live (a folder they keep, not a temporary one, because the `motlab` command runs from it):
+Ask which they want. npm is simpler for using motlab; a clone is for working on it, or for a machine where `npm prefix -g` is not on PATH (it can be missing with nvm for Windows).
+
+With npm, pick the skill target as in step 3, then:
+
+```bash
+npm install -g @staryone/motlab
+motlab setup --skill <target> --dry-run
+motlab setup --skill <target>
+```
+
+`motlab setup` takes the same skill options as the installer and runs `motlab doctor` at the end. If `motlab` is not found after the npm install, show the user `npm prefix -g` and ask before changing their PATH. To update later, `motlab update` prints the two commands (`npm install -g @staryone/motlab@latest`, then `motlab setup --update`). Then skip to step 4.
+
+## Get the repository
+
+For a clone: if the user has none yet, ask where it should live (a folder they keep, not a temporary one, because the `motlab` command runs from it):
```bash
git clone https://github.com/staryone/motlab.git <folder>
@@ -42,7 +56,7 @@ motlab doctor
motlab --help
```
-`doctor` must end with `Ready.` (warnings about Python are fine if the user does not need the skill's scripts). `motlab --help` prints the engine folder; it must be the clone from step 2. If it is another folder, an older launcher comes first on PATH; tell the user which one.
+`doctor` must end with `Ready.` (warnings about Python are fine if the user does not need the skill's scripts). `motlab --help` prints the engine folder; it must be the clone from step 2, or the folder in npm's global `node_modules` for an npm install. If it is another folder, an older launcher comes first on PATH; tell the user which one.
Python packages for the skill's scripts, if the user wants them:
@@ -52,10 +66,10 @@ python -m pip install -r <folder>/skills/motlab/requirements.txt
## 5. Tell the user
-Say in a few lines what was installed and where (the clone, the launcher, the two skill folders), what `doctor` still reports, and how to start: `motlab edit <folder>/example` opens the example in the viewer (it starts the viewer in the background) and prints the address, `http://127.0.0.1:4173/p/example/`; `motlab stop` ends it. A new agent session may be needed before the skills show up.
+Say in a few lines what was installed and where (the clone and the launcher, or the npm package, and the two skill folders), what `doctor` still reports, and how to start: `motlab edit <folder>/example` opens the example in the viewer (it starts the viewer in the background) and prints the address, `http://127.0.0.1:4173/p/example/`; `motlab stop` ends it. A new agent session may be needed before the skills show up.
## Do not
-- create video projects inside the clone or the installed skill folder; a project lives in its own folder
+- create video projects inside the clone, the npm package or the installed skill folder; a project lives in its own folder
- delete or overwrite a folder you did not create
- render a user's project unless they ask for it; the user exports from the viewer
diff --git a/docs/install.md b/docs/install.md
index c889a71..45d9d94 100644
--- a/docs/install.md
+++ b/docs/install.md
@@ -1,6 +1,6 @@
# Installing motlab
-motlab has two parts: the engine (the `motlab` command, the viewer and the renderer) and two agent skills: `skills/motlab/` makes videos, and `skills/motlab-assets/` makes reusable asset kits for them. The installer sets up both parts. If an agent is doing the install for you, point it at [install-for-agents.md](install-for-agents.md).
+motlab has two parts: the engine (the `motlab` command, the viewer and the renderer) and two agent skills: `skills/motlab/` makes videos, and `skills/motlab-assets/` makes reusable asset kits for them. There are two ways to install both: from npm, or from a clone with the installer. Take npm to use motlab, and the clone to work on it. If an agent is doing the install for you, point it at [install-for-agents.md](install-for-agents.md).
## Requirements
@@ -27,6 +27,19 @@ The skill's scripts need numpy, scipy and Pillow:
python -m pip install -r skills/motlab/requirements.txt
```
+## From npm
+
+```bash
+npm install -g @staryone/motlab
+motlab setup
+```
+
+npm installs the engine and its one dependency and makes the `motlab` command. `motlab setup` copies both skills to an agent skill folder (Claude Code by default) and runs `motlab doctor`. It takes the skill options of the installer below: `--skill`, `--skill-dir`, `--link`, `--update`, `--force` and `--dry-run`, so `motlab setup --skill claude,agents` puts the skills in two places. The engine folder is inside npm's global folder; `motlab --help` prints it, and the example project is in it.
+
+The command only works if npm's global folder is on PATH. `npm prefix -g` prints that folder (on Windows the command goes in it, elsewhere in its `bin`). With the Node installer from nodejs.org or Homebrew it is on PATH already. With nvm for Windows it may not be; then use the clone below, whose installer writes its own launcher.
+
+This was tested on Windows 11 with a packed tarball installed into a separate npm folder: `setup`, `update`, `uninstall` and a render of the example. It has not been tried on macOS or Linux, or from the npm registry itself.
+
## With the installer
```bash
@@ -55,6 +68,7 @@ Options:
| `--bin <dir>` | put the launcher somewhere else |
| `--update` | the skills again in every folder from `~/.motlab/install.json`, and in any folder from the table below that already has the motlab skill (an install from before that file). `--skill` and `--skill-dir` add folders. `motlab update` runs this |
| `--force` | replace a folder at a skill path that has no `SKILL.md` |
+| `--skills-only` | the skills and `motlab doctor` only: no `npm ci` and no launcher. `motlab setup` runs this |
| `--dry-run` | print every step and change nothing |
Skill targets. Each one is the agent's user skill folder, as its docs gave it in November 2026:
@@ -83,7 +97,7 @@ node bin/motlab.js doctor
Then either run `node /path/to/motlab/bin/motlab.js` directly, or make a launcher yourself. On Windows, `motlab.cmd` containing `@node "C:\path\to\motlab\bin\motlab.js" %*` in a folder on PATH. On macOS and Linux, a `motlab` file containing `exec node "/path/to/motlab/bin/motlab.js" "$@"`, marked executable.
-`npm link` and `npm install -g .` also work where npm's global folder is on PATH. They do not with nvm for Windows in its default setup, which is why the installer writes its own launcher.
+`npm link` and `npm install -g .` also work where npm's global folder is on PATH, as `npm install -g @staryone/motlab` does. They may not with nvm for Windows, which is why the installer writes its own launcher.
To install the skills by hand, copy or link `skills/motlab/` and `skills/motlab-assets/` to your agent's skill folder (see the table above), side by side. Both call `motlab` and find the engine folder through `motlab --help`; `motlab-assets` also uses scripts from the motlab skill there.
@@ -93,7 +107,16 @@ To install the skills by hand, copy or link `skills/motlab/` and `skills/motlab-
motlab update
```
-It works in the clone the `motlab` command runs from:
+From npm, `motlab update` asks npm for the newest version. If there is one, it prints the two commands that get it:
+
+```bash
+npm install -g @staryone/motlab@latest
+motlab setup --update
+```
+
+The second copies the skills again to every folder they went to before, since npm only replaces the engine.
+
+From a clone, it works in the clone the `motlab` command runs from:
1. Stops if the clone has changes to tracked files, is not on a branch, or has commits that GitHub does not. It says what to do about each.
2. Fetches the branch from `origin` and lists the new commits. With none it says so and stops.
@@ -118,7 +141,7 @@ With `--link`, the skills update with `git pull` alone, but run the installer an
motlab uninstall
```
-It stops the viewer and removes the launcher (`~/.local/bin/motlab`, and `motlab.cmd` on Windows), the two skill folders in every agent folder they were installed in, `~/.motlab/` (where the installer put things, the viewer's recent projects and its log) and the encoder timings (`%LOCALAPPDATA%\motlab` on Windows, `~/.cache/motlab` elsewhere; with `MOTLAB_CACHE_DIR` only the timings file). It lists everything and asks first; `--yes` skips the question and `--dry-run` only lists. A skill installed with `--link` is removed as a link, and what it points to stays. It leaves the clone, because it runs from there: delete that folder afterwards.
+It stops the viewer and removes the launcher (`~/.local/bin/motlab`, and `motlab.cmd` on Windows), the two skill folders in every agent folder they were installed in, `~/.motlab/` (where the installer put things, the viewer's recent projects and its log) and the encoder timings (`%LOCALAPPDATA%\motlab` on Windows, `~/.cache/motlab` elsewhere; with `MOTLAB_CACHE_DIR` only the timings file). It lists everything and asks first; `--yes` skips the question and `--dry-run` only lists. A skill installed with `--link` is removed as a link, and what it points to stays. It leaves the clone, because it runs from there: delete that folder afterwards. From npm there is no launcher to remove, and `npm uninstall -g @staryone/motlab` removes the engine and the command afterwards.
## Check the machine
@@ -138,5 +161,5 @@ Windows
macOS and Linux
-- The code has the macOS and Linux Chrome paths and uses ANGLE on Metal on macOS. On Linux, CI runs the tests and their end-to-end renders on an Ubuntu runner with Google Chrome and the distribution's ffmpeg; no real video and no install with `install.js` have been tried there, and macOS has not been tested at all. Reports are welcome.
+- The code has the macOS and Linux Chrome paths and uses ANGLE on Metal on macOS. On Linux, CI runs the tests and their end-to-end renders on an Ubuntu runner with Google Chrome and the distribution's ffmpeg; no real video and no install with `install.js` or npm have been tried there, and macOS has not been tested at all. Reports are welcome.
- A machine without a GPU should still render through Chrome's software drawing and software H.264 encoder, only slower. On the Windows test laptop with Chrome drawing on SwiftShader, the benchmark scene took 2.8 times as long at 1080p and 4.5 times at 4K ([rendering](rendering.md#without-a-gpu)). A machine with no GPU at all has not been tested.
diff --git a/install.js b/install.js
index 4dcf646..e9f92e6 100644
--- a/install.js
+++ b/install.js
@@ -9,6 +9,8 @@
// node install.js --bin <dir> where the `motlab` command goes (default ~/.local/bin)
// node install.js --dry-run print what would happen and change nothing
// node install.js --update the skills again where they went last time (what `motlab update` runs)
+// node install.js --skills-only only the skills: no npm ci and no launcher (what `motlab setup` runs after
+// `npm install -g @staryone/motlab`, where npm made the command)
//
// Where the skills, the launcher and --link went is kept in ~/.motlab/install.json for --update. It never installs
// Chrome, ffmpeg or Python; it says how to get them.
@@ -35,13 +37,14 @@ const SKILL_DIRS = {
const { values: o } = parseArgs({ options: {
skill: { type: 'string' }, 'skill-dir': { type: 'string', multiple: true }, link: { type: 'boolean' }, bin: { type: 'string' },
- update: { type: 'boolean' }, 'dry-run': { type: 'boolean' }, force: { type: 'boolean' }, help: { type: 'boolean', short: 'h' },
+ update: { type: 'boolean' }, 'skills-only': { type: 'boolean' }, 'dry-run': { type: 'boolean' }, force: { type: 'boolean' }, help: { type: 'boolean', short: 'h' },
} });
-if (o.help) { console.log(`usage: node install.js [--skill ${Object.keys(SKILL_DIRS).join('|')}|none[,...]] [--skill-dir <dir>] [--link] [--bin <dir>] [--update] [--force] [--dry-run]`); process.exit(0); }
+if (o.help) { console.log(`usage: node install.js [--skill ${Object.keys(SKILL_DIRS).join('|')}|none[,...]] [--skill-dir <dir>] [--link] [--bin <dir>] [--update] [--skills-only] [--force] [--dry-run]`); process.exit(0); }
// --update puts the skills where they went before: the folders in the record, and any agent folder above that already
// has the motlab skill (an install from before there was a record). --skill and --skill-dir add to them.
const RECORD = join(HOME, '.motlab', 'install.json');
-let last = {}; if (o.update) try { last = JSON.parse(readFileSync(RECORD, 'utf8')); } catch {}
+let prev = {}; try { prev = JSON.parse(readFileSync(RECORD, 'utf8')); } catch {}
+const last = o.update ? prev : {}, only = o['skills-only'];
const found = o.update ? Object.values(SKILL_DIRS).filter(d => existsSync(join(d, 'motlab', 'SKILL.md'))) : [];
const targets = (o.skill ?? (o.update ? 'none' : 'claude')).split(',').map(t => t.trim()).filter(t => t && t !== 'none');
const bad = targets.filter(t => !SKILL_DIRS[t]);
@@ -53,23 +56,24 @@ const dry = o['dry-run'], say = s => console.log(dry ? `[dry run] ${s}` : s);
if (Number(process.versions.node.split('.')[0]) < 24) { console.error(`motlab needs Node 24 or newer; this is ${process.version}.`); process.exit(1); }
-// 1. npm packages
-say(`npm ci in ${HERE}`);
-if (!dry) {
+// 1. npm packages (an npm install already has them)
+if (!only) say(`npm ci in ${HERE}`);
+if (!only && !dry) {
const r = spawnSync('npm ci --no-audit --no-fund', { cwd: HERE, stdio: 'inherit', shell: true }); // one string: npm is npm.cmd on Windows
if (r.status !== 0) { console.error('npm ci failed. Fix the error above and run the installer again.'); process.exit(1); }
}
// 2. the `motlab` command: small launchers that run this folder's bin/motlab.js
-const bin = resolve(o.bin || last.bin || join(HOME, '.local', 'bin')), entry = join(HERE, 'bin', 'motlab.js');
+// With --skills-only npm made the command, and the record keeps the launcher folder of a clone install, if there was one.
+const bin = only ? prev.bin : resolve(o.bin || last.bin || join(HOME, '.local', 'bin')), entry = join(HERE, 'bin', 'motlab.js');
const launchers = WIN
? [['motlab.cmd', `@node "${entry}" %*\r\n`], ['motlab', `#!/bin/sh\nexec node "${entry.replaceAll('\\', '/')}" "$@"\n`]] // cmd/PowerShell, Git Bash
: [['motlab', `#!/bin/sh\nexec node "${entry}" "$@"\n`]];
-for (const [name, body] of launchers) {
+if (!only) for (const [name, body] of launchers) {
say(`write ${join(bin, name)}`);
if (!dry) { mkdirSync(bin, { recursive: true }); writeFileSync(join(bin, name), body); if (!WIN) chmodSync(join(bin, name), 0o755); }
}
-const onPath = (process.env.PATH || '').split(delimiter).some(p => p && resolve(p).toLowerCase() === bin.toLowerCase());
+const onPath = only || (process.env.PATH || '').split(delimiter).some(p => p && resolve(p).toLowerCase() === bin.toLowerCase());
if (!onPath) console.log(`\n${bin} is not on PATH yet. Add it, then open a new terminal:\n ${WIN
? `[Environment]::SetEnvironmentVariable('Path', [Environment]::GetEnvironmentVariable('Path', 'User') + ';${bin}', 'User') (PowerShell)`
: `echo 'export PATH="${bin}:$PATH"' >> ~/.profile`}\n`);
diff --git a/package-lock.json b/package-lock.json
index d2035eb..f4342fc 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
- "name": "motlab",
- "version": "0.1.0",
+ "name": "@staryone/motlab",
+ "version": "0.2.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
- "name": "motlab",
- "version": "0.1.0",
+ "name": "@staryone/motlab",
+ "version": "0.2.0",
"license": "MIT",
"dependencies": {
"mediabunny": "1.65.2"
diff --git a/package.json b/package.json
index dd2c49f..9189454 100644
--- a/package.json
+++ b/package.json
@@ -1,9 +1,9 @@
{
- "name": "motlab",
- "version": "0.1.0",
- "private": true,
+ "name": "@staryone/motlab",
+ "version": "0.2.0",
"description": "Video as code: canvas scene pages rendered frame by frame in headless Chrome with WebCodecs, a project format with audio, a web viewer, and an agent skill that builds the scenes.",
"license": "MIT",
+ "author": "StaryOne",
"repository": {
"type": "git",
"url": "git+https://github.com/staryone/motlab.git"
@@ -28,6 +28,22 @@
"bin": {
"motlab": "bin/motlab.js"
},
+ "files": [
+ "bin/",
+ "src/",
+ "skills/",
+ "example/",
+ "!example/out/",
+ "!example/selection.json",
+ "!example/selection/",
+ "docs/",
+ "install.js",
+ "CHANGELOG.md",
+ "THIRD_PARTY_NOTICES.md"
+ ],
+ "publishConfig": {
+ "access": "public"
+ },
"scripts": {
"test": "node --test",
"doctor": "node bin/motlab.js doctor"
diff --git a/skills/motlab/SKILL.md b/skills/motlab/SKILL.md
index f6f0a85..1ed0f99 100644
--- a/skills/motlab/SKILL.md
+++ b/skills/motlab/SKILL.md
@@ -27,13 +27,15 @@ your own work) and `motlab events` are fine. Render only if the user asks for it
`motlab` is a command on PATH. Run `motlab --help` once at the start: it lists the commands and prints the engine
folder (its README, the `example/` project and `src/page/footage.js`).
-If `motlab` is not found, ask the user where their motlab clone is (the folder with `install.js` and `bin/motlab.js`)
-and run `node install.js --skill none` there; it puts the command on PATH. If they have no clone, follow
-`docs/install-for-agents.md` from https://github.com/staryone/motlab. Until the command is on PATH, call
+If `motlab` is not found, ask the user how they installed it. From npm (`npm install -g @staryone/motlab`), npm's
+global folder (`npm prefix -g`) is probably not on PATH; show them that and ask before changing PATH. From a clone (the
+folder with `install.js` and `bin/motlab.js`), run `node install.js --skill none` there; it puts the command on PATH.
+If they have neither, follow `docs/install-for-agents.md` from https://github.com/staryone/motlab. Until the command is on PATH, call
`node <engine>/bin/motlab.js`. Never hard-code the engine path anywhere else. If a render or still fails because Chrome
or ffmpeg is missing, run `motlab doctor` and show the user what it reports. When the user asks to update motlab or
-its skills, run `motlab update`. If it stops because the engine folder has local changes or commits of its own, show
-the user its message and ask; never stash, reset or discard their changes. The new skills load in a new session.
+its skills, run `motlab update`. For an npm install it prints the two commands that update it; run them if the user
+agrees. If it stops because the engine folder has local changes or commits of its own, show the user its message and
+ask; never stash, reset or discard their changes. The new skills load in a new session.
## The workflow
diff --git a/src/cli.js b/src/cli.js
index 2590d69..a56961f 100644
--- a/src/cli.js
+++ b/src/cli.js
@@ -1,3 +1,4 @@
+import { spawnSync } from 'node:child_process';
import { fileURLToPath } from 'node:url';
import { parseArgs } from 'node:util';
import { doctor } from './doctor.js';
@@ -21,10 +22,15 @@ const USAGE = `motlab: render a canvas page (canvas #c, renderAt(t), TOTAL, read
motlab video <page.html> <out.mp4> [--fps 24] [--scale 2] [--audio file] [--encoder auto|hw|sw] [--workers N]
motlab events <page.html> <out.json>
motlab doctor check Node, Chrome, ffmpeg and the skill's Python packages
+ motlab setup [--skill claude|agents|antigravity|...] [--skill-dir <dir>] [--link] [--update] [--dry-run]
+ copy the skills to agent folders (after npm install -g; default
+ Claude Code). --update copies them again where they went before
motlab update [--dry-run] the newest motlab from GitHub, its npm packages, and the skills
- copied again to every agent folder they were installed in
- motlab uninstall [--dry-run] [--yes] remove the command, the skills, ~/.motlab and the encoder cache
- (it lists them and asks first; the clone folder is left)
+ copied again to every agent folder they were installed in (for an
+ npm install it says which version is out and how to get it)
+ motlab uninstall [--dry-run] [--yes] remove the skills, ~/.motlab, the encoder cache and a clone's
+ command (it lists them and asks first; the clone folder or the npm
+ package is left)
--fps frames per second (default 24)
--scale passed to the page as ?scale=; 2 turns a 1920x1080 page into 4K (default 2 for video, 1 for stills)
@@ -54,6 +60,11 @@ const num = (name, v, { min = 0, int = false } = {}) => {
};
export async function main(argv) {
+ // setup hands its options to install.js, which has its own (--skill, --skill-dir, --link, --update, --dry-run).
+ if (argv[0] === 'setup') {
+ const install = fileURLToPath(new URL('../install.js', import.meta.url));
+ return spawnSync(process.execPath, [install, '--skills-only', ...argv.slice(1)], { stdio: 'inherit' }).status ?? 1;
+ }
const { values: v, positionals } = parseArgs({ args: argv, allowPositionals: true, options: {
fps: { type: 'string' }, scale: { type: 'string' }, audio: { type: 'string' }, encoder: { type: 'string' }, codec: { type: 'string' },
workers: { type: 'string' }, bitrate: { type: 'string' }, qp: { type: 'string' }, mux: { type: 'string' }, root: { type: 'string' }, chrome: { type: 'string' },
@@ -74,7 +85,7 @@ export async function main(argv) {
await renderProject({ dir: page, out, scale: num('scale', v.scale, { min: 0.01 }) });
return 0;
}
- if (!['stills', 'video', 'events'].includes(mode)) throw new Error(`unknown mode "${mode}" (render, start, edit, stop, restart, stills, video, events, doctor, update or uninstall)`);
+ if (!['stills', 'video', 'events'].includes(mode)) throw new Error(`unknown mode "${mode}" (render, start, edit, stop, restart, stills, video, events, doctor, setup, update or uninstall)`);
if (!page || !out) throw new Error(`${mode} needs a page and an output path`);
const common = { page, root: v.root, chrome: v.chrome };
diff --git a/src/uninstall.js b/src/uninstall.js
index 02d4638..905faa9 100644
--- a/src/uninstall.js
+++ b/src/uninstall.js
@@ -1,16 +1,18 @@
// motlab uninstall: removes what install.js put on this machine. It stops the viewer, then deletes the `motlab`
// launchers, the two skill folders in every agent folder from ~/.motlab/install.json (or, without that record, in
// the agent folders install.js knows), ~/.motlab and the encoder cache. It lists everything and asks first. The
-// clone is left, because this command runs from it.
+// clone is left, because this command runs from it, and so is an npm install, which npm uninstall -g removes.
import { existsSync, lstatSync, readFileSync, rmSync } from 'node:fs';
import { homedir } from 'node:os';
import { dirname, join } from 'node:path';
import { createInterface } from 'node:readline/promises';
-import { fileURLToPath } from 'node:url';
import { cacheFile } from './probe.js';
+import { FROM_NPM, PKG, ROOT } from './update.js';
import { stopViewer } from './viewer.js';
-const HOME = homedir(), STATE = join(HOME, '.motlab'), ROOT = fileURLToPath(new URL('..', import.meta.url)).replace(/[\\/]$/, '');
+const HOME = homedir(), STATE = join(HOME, '.motlab');
+// What is left afterwards: the clone, or the npm package (npm made the command, so npm removes it).
+const REST = FROM_NPM ? `run npm uninstall -g ${PKG.name}` : `delete ${ROOT}`;
// The agent skill folders install.js writes to, for an install from before ~/.motlab/install.json existed.
const KNOWN = ['.claude/skills', '.agents/skills', '.gemini/config/skills', '.config/opencode/skills', '.cursor/skills', '.copilot/skills'].map(d => join(HOME, d));
@@ -38,10 +40,10 @@ function targets() {
export async function uninstall({ dryRun = false, yes = false } = {}) {
const list = targets();
- if (!list.length) { console.log('Nothing from motlab is installed here.'); return 0; }
+ if (!list.length) { console.log(`Nothing from motlab is installed here${FROM_NPM ? `. To remove the command, ${REST}` : ''}.`); return 0; }
console.log('motlab uninstall removes:');
for (const t of list) console.log(` ${t.path} (${t.what})`);
- console.log(`It leaves the clone in ${ROOT}; delete that folder yourself afterwards.`);
+ console.log(FROM_NPM ? `It leaves the npm package; ${REST} afterwards.` : `It leaves the clone in ${ROOT}; delete that folder yourself afterwards.`);
if (dryRun) return 0;
if (!yes) {
if (!process.stdin.isTTY) { console.log('Run it again with --yes to remove them.'); return 1; }
@@ -56,6 +58,6 @@ export async function uninstall({ dryRun = false, yes = false } = {}) {
try { rmSync(t.path, t.link ? {} : { recursive: true, force: true, maxRetries: 5, retryDelay: 200 }); console.log(`removed ${t.path}`); }
catch (e) { console.log(`could not remove ${t.path}: ${e.message}`); }
}
- console.log(`\nDone. To remove the rest, delete ${ROOT}.`);
+ console.log(`\nDone. To remove the rest, ${REST}.`);
return 0;
}
diff --git a/src/update.js b/src/update.js
index aae4c02..32e6826 100644
--- a/src/update.js
+++ b/src/update.js
@@ -1,18 +1,31 @@
import { spawnSync } from 'node:child_process';
-import { existsSync } from 'node:fs';
+import { existsSync, readFileSync } from 'node:fs';
import { join } from 'node:path';
import { fileURLToPath } from 'node:url';
// motlab update: the engine folder is a git clone. It fetches its branch from origin, fast-forwards to it, and runs the
// new install.js with --update, which runs npm ci and copies the skills again to every folder they were installed in.
-const ROOT = fileURLToPath(new URL('..', import.meta.url)).replace(/[\\/]$/, '');
+// An engine folder inside node_modules came from `npm install -g`; there it says which version is out and how to get it.
+export const ROOT = fileURLToPath(new URL('..', import.meta.url)).replace(/[\\/]$/, '');
+export const FROM_NPM = /[\\/]node_modules[\\/]/.test(ROOT);
+export const PKG = JSON.parse(readFileSync(join(ROOT, 'package.json'), 'utf8'));
const git = (...args) => {
const r = spawnSync('git', args, { cwd: ROOT, encoding: 'utf8' });
if (r.error) throw new Error('git was not found. Install git, or update by hand as in docs/install.md#updating');
return { ok: r.status === 0, out: (r.stdout || '').trimEnd(), err: (r.stderr || '').trim() };
};
+function updateFromNpm() {
+ const r = spawnSync(`npm view ${PKG.name} version`, { encoding: 'utf8', shell: true }); // one string: npm is npm.cmd on Windows
+ const latest = r.status === 0 ? r.stdout.trim() : null;
+ if (latest === PKG.version) { console.log(`motlab is up to date (${PKG.version}).`); return 0; }
+ console.log(latest ? `motlab ${latest} is out; this is ${PKG.version}.` : `Could not ask npm for the newest version (this is ${PKG.version}).`);
+ console.log(`Update it with npm, then copy the skills again:\n npm install -g ${PKG.name}@latest\n motlab setup --update\nThen run motlab restart if the viewer is running.`);
+ return 1;
+}
+
export function update({ dryRun = false } = {}) {
+ if (FROM_NPM) return updateFromNpm();
if (!existsSync(join(ROOT, '.git'))) throw new Error(`${ROOT} is not a git clone, so it cannot update itself. Clone motlab again (docs/install.md) and run node install.js there`);
const branch = git('rev-parse', '--abbrev-ref', 'HEAD').out;
if (branch === 'HEAD') throw new Error(`${ROOT} is not on a branch. Check out main, then run motlab update again`);
diff --git a/test/install.test.js b/test/install.test.js
index d52650b..a8c109c 100644
--- a/test/install.test.js
+++ b/test/install.test.js
@@ -49,3 +49,18 @@ test('motlab uninstall removes what the installer wrote and nothing else', () =>
assert.ok(existsSync(join(home, 'bin', 'other.cmd')) && existsSync(join(home, '.claude', 'skills', 'someone-else')), 'other files stay');
} finally { rmSync(home, { recursive: true, force: true }); }
});
+
+// After `npm install -g`, npm has made the command, so `motlab setup` (install.js --skills-only) copies the skills
+// and writes no launcher and runs no npm ci. It keeps the launcher folder of an earlier clone install in the record.
+test('motlab setup copies the skills and nothing else', () => {
+ const home = mkdtempSync(join(tmpdir(), 'motlab-home-'));
+ try {
+ mkdirSync(join(home, '.motlab'));
+ writeFileSync(join(home, '.motlab', 'install.json'), JSON.stringify({ skillDirs: [], bin: join(home, 'bin') }));
+ const r = spawnSync(process.execPath, ['bin/motlab.js', 'setup', '--skill-dir', join(home, 'agent'), '--skill', 'none', '--dry-run'],
+ { encoding: 'utf8', env: { ...process.env, HOME: home, USERPROFILE: home } });
+ assert.equal(r.status, 0, r.stdout + r.stderr);
+ assert.ok(r.stdout.includes(`-> ${join(home, 'agent', 'motlab')}`) && r.stdout.includes(`-> ${join(home, 'agent', 'motlab-assets')}`), r.stdout);
+ assert.ok(!/npm ci|write .*motlab/.test(r.stdout), r.stdout);
+ } finally { rmSync(home, { recursive: true, force: true }); }
+});