Skip to content

Commit dc79b5c

Browse files
committed
feat: make CLI globally installable via npm as @resciencelab/shader-cli
- Rename package to @resciencelab/shader-cli with 'shader-cli' binary - Use remote runtime (shader-lab.rescience.dev) instead of local dev server - Move Playwright to optionalDependencies with lazy import - Add 'shader-cli setup' command for Playwright installation - Switch build from bun to tsc for Node.js compatibility - Add shebang, LICENSE, postbuild script - Update README with npm install instructions
1 parent 96567c4 commit dc79b5c

10 files changed

Lines changed: 283 additions & 102 deletions

File tree

README.md

Lines changed: 57 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,18 @@
1414
<summary>CLI commands used to generate the above</summary>
1515

1616
```bash
17-
cd cli
18-
bun run src/index.ts -- project new -o scene.lab
19-
bun run src/index.ts -- --project scene.lab layer add crt \
17+
shader-cli project new -o scene.lab
18+
shader-cli --project scene.lab layer add crt \
2019
-p crtMode=composite-tv -p cellSize=4 -p scanlineIntensity=0.3 \
2120
-p flickerIntensity=0.15 -p glitchIntensity=0.2 -p glitchSpeed=3 \
2221
-p bloomEnabled=true -p bloomIntensity=1.5 -p barrelDistortion=0.1 \
2322
-p vignetteIntensity=0.6
24-
bun run src/index.ts -- --project scene.lab layer add text \
23+
shader-cli --project scene.lab layer add text \
2524
-p "text=ReScience Lab" -p fontSize=190 -p fontWeight=800 -p "textColor=#e0e0e0"
26-
bun run src/index.ts -- --project scene.lab layer add gradient \
25+
shader-cli --project scene.lab layer add gradient \
2726
-p preset=sunset -p animate=true -p motionAmount=0.5 -p tonemapMode=cinematic
28-
bun run src/index.ts -- --project scene.lab timeline duration 6
29-
bun run src/index.ts -- --project scene.lab export video -o output.webm
27+
shader-cli --project scene.lab timeline duration 6
28+
shader-cli --project scene.lab export video -o output.webm
3029
```
3130
</details>
3231

@@ -36,23 +35,35 @@ This is a fork of [basement.studio's Shader Lab](https://github.com/basementstud
3635

3736
## Quick Start
3837

38+
### Install via npm (recommended)
39+
3940
```bash
40-
git clone https://github.com/ReScienceLab/shader-cli.git
41-
cd shader-cli
41+
# Install globally
42+
npm i -g @resciencelab/shader-cli
43+
44+
# One-time setup for video export (installs Playwright + Chromium)
45+
shader-cli setup
46+
47+
# Create a CRT text animation
48+
shader-cli preset apply crt-text --text "Hello World" -o scene.lab
49+
shader-cli --project scene.lab export video -o output.webm
50+
```
4251

43-
# Install editor + CLI dependencies
44-
bun install
45-
cd cli && bun install && cd ..
52+
Or use with `npx` (no install):
4653

47-
# Start the editor (needed for export)
48-
bun run dev &
54+
```bash
55+
npx @resciencelab/shader-cli preset apply crt-text --text "Hello" -o scene.lab
56+
```
57+
58+
### Install from source
4959

50-
# Create a CRT text animation in one command
51-
cd cli
52-
bun run src/index.ts -- preset apply crt-text --text "Hello World" -o scene.lab
53-
bun run src/index.ts -- --project scene.lab export video -o output.webm
60+
```bash
61+
git clone https://github.com/ReScienceLab/shader-cli.git
62+
cd shader-cli/cli && npm install && npm run build && npm link
5463
```
5564

65+
**Runtime:** Export commands use [shader-lab.rescience.dev](https://shader-lab.rescience.dev/tools/shader-lab) by default. Override with `--runtime http://localhost:3000` for local development.
66+
5667
## CLI Commands
5768

5869
### Project Management
@@ -93,7 +104,7 @@ shader-cli timeline keyframe add <layer> <time> <property> <value> [-i smooth]
93104
shader-cli timeline info
94105
```
95106

96-
### Export (requires Chrome + WebGPU)
107+
### Export (requires Playwright + Chrome with WebGPU)
97108
```bash
98109
shader-cli export video [-o out.webm] [--format webm|mp4] [--quality standard] [--fps 30]
99110
shader-cli export image [-o out.png] [--quality standard] [--time 0]
@@ -106,6 +117,11 @@ shader-cli preset list
106117
shader-cli preset apply <name> [--text "Text"] [-o out.lab]
107118
```
108119

120+
### Setup
121+
```bash
122+
shader-cli setup # Install Playwright + Chromium for video export
123+
```
124+
109125
## Built-in Presets
110126

111127
| Preset | Description | Layers |
@@ -127,25 +143,25 @@ shader-cli preset apply <name> [--text "Text"] [-o out.lab]
127143

128144
### Build from scratch
129145
```bash
130-
bun run src/index.ts -- project new -o my.lab
131-
bun run src/index.ts -- --project my.lab layer add gradient -p preset=neon-glow -p animate=true
132-
bun run src/index.ts -- --project my.lab layer add text -p "text=ReScience Lab" -p fontSize=201
133-
bun run src/index.ts -- --project my.lab layer add dithering -p algorithm=bayer-4x4
134-
bun run src/index.ts -- --project my.lab layer add crt -p bloomEnabled=true
135-
bun run src/index.ts -- --project my.lab export video -o output.webm
146+
shader-cli project new -o my.lab
147+
shader-cli --project my.lab layer add gradient -p preset=neon-glow -p animate=true
148+
shader-cli --project my.lab layer add text -p "text=ReScience Lab" -p fontSize=201
149+
shader-cli --project my.lab layer add dithering -p algorithm=bayer-4x4
150+
shader-cli --project my.lab layer add crt -p bloomEnabled=true
151+
shader-cli --project my.lab export video -o output.webm
136152
```
137153

138154
### Agent JSON mode
139155
```bash
140-
bun run src/index.ts -- --json layer types
141-
bun run src/index.ts -- --json layer params crt
142-
bun run src/index.ts -- --json --project my.lab layer set 2 -p bloomIntensity=3.0
143-
bun run src/index.ts -- --json --project my.lab project info
156+
shader-cli --json layer types
157+
shader-cli --json layer params crt
158+
shader-cli --json --project my.lab layer set 2 -p bloomIntensity=3.0
159+
shader-cli --json --project my.lab project info
144160
```
145161

146162
### REPL mode
147163
```bash
148-
bun run src/index.ts
164+
shader-cli
149165
# Enters interactive shell with undo/redo support
150166
```
151167

@@ -173,9 +189,17 @@ shader-cli/
173189

174190
## Requirements
175191

176-
- [Bun](https://bun.sh/) >= 1.3
177-
- Chrome/Chromium with WebGPU support (for export)
178-
- [Playwright](https://playwright.dev/) (for headless export)
192+
- [Node.js](https://nodejs.org/) >= 18
193+
- Chrome/Chromium with WebGPU support (for export — installed automatically via `shader-cli setup`)
194+
195+
## Runtime
196+
197+
Export commands render via a hosted Shader Lab instance at [shader-lab.rescience.dev](https://shader-lab.rescience.dev/tools/shader-lab). No local server needed.
198+
199+
To use a local instance instead:
200+
```bash
201+
shader-cli --runtime http://localhost:3000/tools/shader-lab --project scene.lab export video -o out.webm
202+
```
179203

180204
## Credits
181205

cli/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
node_modules
2+
dist

cli/LICENSE

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
MIT License
2+
3+
Copyright (c) 2025-2026 ReScienceLab
4+
Copyright (c) 2024-2025 basement.studio (original Shader Lab)
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to deal
8+
in the Software without restriction, including without limitation the rights
9+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the Software is
11+
furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in all
14+
copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
SOFTWARE.

cli/package-lock.json

Lines changed: 100 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cli/package.json

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,45 @@
11
{
2-
"name": "@shader-lab/cli",
2+
"name": "@resciencelab/shader-cli",
33
"version": "0.1.0",
4-
"description": "CLI harness for Shader Lab — agent-native shader composition",
4+
"description": "Agent-native CLI for Shader Lab — compose and export WebGPU shader scenes from the terminal",
55
"type": "module",
66
"bin": {
7-
"shader-lab": "./dist/index.js"
7+
"shader-cli": "./dist/index.js"
88
},
9+
"files": [
10+
"dist",
11+
"README.md",
12+
"LICENSE"
13+
],
14+
"engines": {
15+
"node": ">=18"
16+
},
17+
"repository": {
18+
"type": "git",
19+
"url": "https://github.com/ReScienceLab/shader-cli.git",
20+
"directory": "cli"
21+
},
22+
"homepage": "https://github.com/ReScienceLab/shader-cli#readme",
23+
"license": "MIT",
24+
"keywords": [
25+
"shader",
26+
"webgpu",
27+
"cli",
28+
"agent",
29+
"shader-lab",
30+
"video-export",
31+
"glsl",
32+
"post-processing"
33+
],
934
"scripts": {
10-
"build": "bun build src/index.ts --outdir dist --target node --format esm",
11-
"dev": "bun run src/index.ts",
12-
"test": "bun test"
35+
"build": "tsc -p tsconfig.json && node scripts/postbuild.js",
36+
"prepublishOnly": "npm run build",
37+
"dev": "bun run src/index.ts"
1338
},
1439
"dependencies": {
15-
"commander": "^13.1.0",
40+
"commander": "^13.1.0"
41+
},
42+
"optionalDependencies": {
1643
"playwright": "^1.52.0"
1744
},
1845
"devDependencies": {

cli/scripts/postbuild.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { readFileSync, writeFileSync, chmodSync } from "node:fs"
2+
3+
const entry = new URL("../dist/index.js", import.meta.url).pathname
4+
const content = readFileSync(entry, "utf-8")
5+
if (!content.startsWith("#!")) {
6+
writeFileSync(entry, `#!/usr/bin/env node\n${content}`)
7+
}
8+
chmodSync(entry, 0o755)
9+
console.log("postbuild: shebang + chmod done")

0 commit comments

Comments
 (0)