retiam 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/cli.js CHANGED
@@ -1,209 +1,213 @@
1
- #!/usr/bin/env node
2
-
3
- // =========================================================================
4
- // File: bin/cli.js - Retiam Unified CLI Entrypoint
5
- // =========================================================================
6
-
7
- import { spawn } from 'child_process';
8
- import path from 'path';
9
- import { fileURLToPath } from 'url';
10
- import { createRequire } from 'module';
11
-
12
- const __filename = fileURLToPath(import.meta.url);
13
- const __dirname = path.dirname(__filename);
14
-
15
- const args = process.argv.slice(2);
16
- const command = args[0];
17
-
18
- const renderScript = path.join(__dirname, 'render.js');
19
- const exportScript = path.join(__dirname, 'export.js');
20
- const lintScript = path.join(__dirname, 'lint.js');
21
- const snapshotScript = path.join(__dirname, 'snapshot.js');
22
- const initScript = path.join(__dirname, 'init.js');
23
-
24
- function runScript(scriptPath, scriptArgs) {
25
- if (scriptPath === renderScript || scriptPath === snapshotScript) {
26
- try {
27
- createRequire(import.meta.url).resolve('puppeteer');
28
- } catch {
29
- console.error('Retiam render and snapshot require the optional Puppeteer dependency. Install it in your project with: npm install --save-dev puppeteer');
30
- process.exit(1);
31
- }
32
- }
33
- const child = spawn(process.execPath, [scriptPath, ...scriptArgs], { stdio: 'inherit' });
34
- child.on('error', (error) => {
35
- console.error(`Unable to start Retiam command: ${error.message}`);
36
- process.exit(1);
37
- });
38
- child.on('exit', (code, signal) => process.exit(code ?? (signal ? 1 : 0)));
39
- }
40
-
41
- function printRootHelp() {
42
- console.log(`
43
- 🎬 Retiam WebGPU Engine CLI (Agent-Native Edition)
44
-
45
- Usage:
46
- npx retiam <command> [file] [options]
47
- npx retiam [file] [options] (shortcut for render)
48
- npx retiam help <command> (detailed help for a single command)
49
-
50
- Commands Overview:
51
- init, create Initialize a complete Retiam WebGPU animation skeleton project
52
- lint Statically analyze scenes for runtime hazards and async timing bugs
53
- snapshot Capture multi-timestamp visual PNG keyframes via headless WebGPU
54
- render Render high-fidelity video (MP4/WebM) via WebGPU & FFmpeg
55
- export Bundle scene into an embeddable <retiam-scene> Web Component
56
-
57
- ================================================================================
58
- 1. RENDER (npx retiam render [file] [options])
59
- Render a scene into an MP4/WebM video via headless Chrome and FFmpeg.
60
-
61
- Arguments:
62
- [file] Target scene TypeScript file (default: src/main.ts)
63
-
64
- Options:
65
- -w, --width <px> Output video width (default: 1920)
66
- -h, --height <px> Output video height (default: 1080)
67
- -f, --fps <num> Render frame rate (default: 60)
68
- -d, --duration <ms> Maximum rendering duration limit in milliseconds
69
- -o, --out <dir> Output directory for video (default: ./outputs/video)
70
- --raytrace [true|false] Enable or disable hardware raytracing
71
- --no-raytrace Explicitly disable raytracing
72
- --denoiser <format> Denoiser pipeline ('none', 'spatial', 'oidn', 'native')
73
- --raw Use native raw HDR frame buffer export
74
- --replay <file.json> Replay recorded interactions JSON during rendering
75
- --help Show render-specific help
76
-
77
- Examples:
78
- npx retiam render src/scenes/AStarScene.ts
79
- npx retiam render MyScene.ts -w 1920 -h 1080 -f 60
80
- npx retiam render MyScene.ts -d 15000 --raytrace false
81
-
82
- ================================================================================
83
- 2. SNAPSHOT (npx retiam snapshot <file> [options])
84
- Capture visual PNG keyframe snapshots at specific timeline seconds.
85
-
86
- Arguments:
87
- <file> Target scene TypeScript file (e.g. MyScene.ts)
88
-
89
- Options:
90
- --times <sec,sec,...> Comma-separated timeline seconds (default: 1.0, 2.5)
91
- -w, --width <px> Snapshot width in pixels (default: 1280)
92
- -h, --height <px> Snapshot height in pixels (default: 720)
93
- -o, --out <dir> Output directory for images (default: ./outputs/snapshot)
94
- --json Output structured JSON for agents & CI automation
95
- --help Show snapshot-specific help
96
-
97
- Examples:
98
- npx retiam snapshot MyScene.ts
99
- npx retiam snapshot MyScene.ts --times 1.0,3.5,7.0 -w 1920 -h 1080
100
- npx retiam snapshot MyScene.ts --times 5.0 --out ./outputs/snapshot --json
101
-
102
- ================================================================================
103
- 3. INIT / CREATE (npx retiam init [directory] [options])
104
- Initialize a complete, ready-to-run Retiam WebGPU animation project skeleton.
105
-
106
- Arguments:
107
- [directory] Destination directory (default: ./retiam-animation)
108
-
109
- Options:
110
- -n, --name <name> Project name for package.json (default: directory name)
111
- --title <text> Hero text for starter Hello World scene (default: Hello World)
112
- --pm <manager> Package manager: npm, pnpm, yarn, bun (default: auto or npm)
113
- -f, --force Overwrite destination directory if files already exist
114
- -y, --yes Skip interactive prompts and use defaults
115
- --install Automatically install dependencies after initialization
116
- --git Initialize a Git repository (git init)
117
- --json Output structured JSON for agents & CI automation
118
- --help, -h Show init-specific help
119
-
120
- Examples:
121
- npx retiam init
122
- npx retiam init my-animation
123
- npx retiam create quantum-viz --title "Quantum Mechanics" --pm pnpm
124
- npx retiam init intro-scene -y --install
125
-
126
- ================================================================================
127
- 4. LINT (npx retiam lint <file> [options])
128
- Static analyzer and AST validator detecting common animation bugs and timing hazards.
129
-
130
- Arguments:
131
- <file> Target scene file to analyze (e.g. MyScene.ts)
132
-
133
- Options:
134
- --json Output machine-readable JSON with line numbers & suggested fixes
135
- --help, -h Show lint-specific help
136
-
137
- Checks Performed:
138
- - Validates Scene class structure and async run() contract
139
- - Detects un-awaited this.play() or this.wait() timing races
140
- - Warns about dangling entities not attached to scene graph
141
- - Catches Three.js / Python Manim hallucinations
142
- - Flags extreme world coordinates exceeding standard camera frustum
143
-
144
- Examples:
145
- npx retiam lint MyScene.ts
146
- npx retiam lint MyScene.ts --json
147
-
148
- ================================================================================
149
- 5. EXPORT (npx retiam export [file] [outDir] [options])
150
- Compile the scene into a standalone, zero-dependency <retiam-scene> Web Component.
151
-
152
- Arguments:
153
- [file] Source scene file to bundle (default: src/main.ts)
154
- [outDir] Target distribution folder (default: outputs/embed)
155
-
156
- Options:
157
- -o, --out <dir> Target distribution folder (default: outputs/embed)
158
- --help, -h Show export-specific help
159
-
160
- Examples:
161
- npx retiam export MyScene.ts
162
- npx retiam export MyScene.ts ./outputs/embed
163
- `);
164
- }
165
-
166
- if (command === 'lint') {
167
- // Usage: npx retiam lint src/MyScene.ts [--json]
168
- runScript(lintScript, args.slice(1));
169
- }
170
- else if (command === 'snapshot') {
171
- // Usage: npx retiam snapshot src/MyScene.ts [--times 1.0,2.5] [--out ./outputs/snapshot] [--json]
172
- runScript(snapshotScript, args.slice(1));
173
- }
174
- else if (command === 'init' || command === 'create' || command === 'scaffold') {
175
- // Usage: npx retiam init [directory] [options]
176
- runScript(initScript, args.slice(1));
177
- }
178
- else if (command === 'export') {
179
- // Usage: npx retiam export src/main.ts
180
- runScript(exportScript, args.slice(1));
181
- }
182
- else if (command === 'render') {
183
- // Usage: npx retiam render src/main.ts
184
- runScript(renderScript, args.slice(1));
185
- }
186
- else if (command === 'help') {
187
- const sub = args[1];
188
- if (sub === 'lint') {
189
- runScript(lintScript, ['--help']);
190
- } else if (sub === 'snapshot') {
191
- runScript(snapshotScript, ['--help']);
192
- } else if (sub === 'init' || sub === 'create' || sub === 'scaffold') {
193
- runScript(initScript, ['--help']);
194
- } else if (sub === 'export') {
195
- runScript(exportScript, ['--help']);
196
- } else if (sub === 'render') {
197
- runScript(renderScript, ['--help']);
198
- } else {
199
- printRootHelp();
200
- }
201
- }
202
- else if (command === '-h' || command === '--help' || !command) {
203
- printRootHelp();
204
- }
205
- else {
206
- // Fallback: Default to rendering if a file path or flag is passed directly
207
- // Usage: npx retiam src/main.ts
208
- runScript(renderScript, args);
209
- }
1
+ #!/usr/bin/env node
2
+
3
+ // =========================================================================
4
+ // File: bin/cli.js - Retiam Unified CLI Entrypoint
5
+ // =========================================================================
6
+
7
+ import { spawn } from 'child_process';
8
+ import path from 'path';
9
+ import { fileURLToPath } from 'url';
10
+ import { createRequire } from 'module';
11
+
12
+ const __filename = fileURLToPath(import.meta.url);
13
+ const __dirname = path.dirname(__filename);
14
+
15
+ const args = process.argv.slice(2);
16
+ const command = args[0];
17
+
18
+ const renderScript = path.join(__dirname, 'render.js');
19
+ const exportScript = path.join(__dirname, 'export.js');
20
+ const lintScript = path.join(__dirname, 'lint.js');
21
+ const snapshotScript = path.join(__dirname, 'snapshot.js');
22
+ const initScript = path.join(__dirname, 'init.js');
23
+
24
+ function runScript(scriptPath, scriptArgs) {
25
+ if (scriptPath === renderScript || scriptPath === snapshotScript) {
26
+ try {
27
+ createRequire(import.meta.url).resolve('puppeteer');
28
+ } catch {
29
+ console.error('Retiam installation is incomplete: its required Puppeteer dependency is missing. Reinstall Retiam in your project with: npm install retiam');
30
+ process.exit(1);
31
+ }
32
+ }
33
+ const child = spawn(process.execPath, [scriptPath, ...scriptArgs], { stdio: 'inherit' });
34
+ child.on('error', (error) => {
35
+ console.error(`Unable to start Retiam command: ${error.message}`);
36
+ process.exit(1);
37
+ });
38
+ child.on('exit', (code, signal) => process.exit(code ?? (signal ? 1 : 0)));
39
+ }
40
+
41
+ function printRootHelp() {
42
+ console.log(`
43
+ 🎬 Retiam WebGPU Engine CLI (Agent-Native Edition)
44
+
45
+ Usage:
46
+ npx retiam <command> [file] [options]
47
+ npx retiam [file] [options] (shortcut for render)
48
+ npx retiam help <command> (detailed help for a single command)
49
+
50
+ Commands Overview:
51
+ init, create Initialize a complete Retiam WebGPU animation skeleton project
52
+ lint Statically analyze scenes for runtime hazards and async timing bugs
53
+ snapshot Capture multi-timestamp visual PNG keyframes via headless WebGPU
54
+ render Render high-fidelity video (MP4/WebM) via WebGPU & FFmpeg
55
+ export Bundle scene into an embeddable <retiam-scene> Web Component
56
+
57
+ ================================================================================
58
+ 1. RENDER (npx retiam render [file] [options])
59
+ Render a scene into an MP4/WebM video via headless Chrome and FFmpeg.
60
+
61
+ Arguments:
62
+ [file] Target scene TypeScript file (default: src/main.ts)
63
+
64
+ Options:
65
+ -w, --width <px> Output video width (default: 1920)
66
+ -h, --height <px> Output video height (default: 1080)
67
+ -f, --fps <num> Render frame rate (default: 60)
68
+ -d, --duration <ms> Maximum rendering duration limit in milliseconds
69
+ -o, --out <dir> Output directory for video (default: ./outputs/video)
70
+ --raytrace [true|false] Enable or disable hardware raytracing
71
+ --no-raytrace Explicitly disable raytracing
72
+ --denoiser <format> Denoiser pipeline ('none', 'spatial', 'oidn', 'native')
73
+ --raw Use native raw HDR frame buffer export
74
+ --replay <file.json> Replay recorded interactions JSON during rendering
75
+ --help Show render-specific help
76
+
77
+ Examples:
78
+ npx retiam render src/scenes/AStarScene.ts
79
+ npx retiam render MyScene.ts -w 1920 -h 1080 -f 60
80
+ npx retiam render MyScene.ts -d 15000 --raytrace false
81
+
82
+ Configuration:
83
+ Reads config.js in the project root (retiam.config.js takes priority).
84
+ Command-line flags override file settings.
85
+
86
+ ================================================================================
87
+ 2. SNAPSHOT (npx retiam snapshot <file> [options])
88
+ Capture visual PNG keyframe snapshots at specific timeline seconds.
89
+
90
+ Arguments:
91
+ <file> Target scene TypeScript file (e.g. MyScene.ts)
92
+
93
+ Options:
94
+ --times <sec,sec,...> Comma-separated timeline seconds (default: 1.0, 2.5)
95
+ -w, --width <px> Snapshot width in pixels (default: 1280)
96
+ -h, --height <px> Snapshot height in pixels (default: 720)
97
+ -o, --out <dir> Output directory for images (default: ./outputs/snapshot)
98
+ --json Output structured JSON for agents & CI automation
99
+ --help Show snapshot-specific help
100
+
101
+ Examples:
102
+ npx retiam snapshot MyScene.ts
103
+ npx retiam snapshot MyScene.ts --times 1.0,3.5,7.0 -w 1920 -h 1080
104
+ npx retiam snapshot MyScene.ts --times 5.0 --out ./outputs/snapshot --json
105
+
106
+ ================================================================================
107
+ 3. INIT / CREATE (npx retiam init [directory] [options])
108
+ Initialize a complete, ready-to-run Retiam WebGPU animation project skeleton.
109
+
110
+ Arguments:
111
+ [directory] Destination directory (default: ./retiam-animation)
112
+
113
+ Options:
114
+ -n, --name <name> Project name for package.json (default: directory name)
115
+ --title <text> Hero text for starter Hello World scene (default: Hello World)
116
+ --pm <manager> Package manager: npm, pnpm, yarn, bun (default: auto or npm)
117
+ -f, --force Overwrite destination directory if files already exist
118
+ -y, --yes Skip interactive prompts and use defaults
119
+ --install Automatically install dependencies after initialization
120
+ --git Initialize a Git repository (git init)
121
+ --json Output structured JSON for agents & CI automation
122
+ --help, -h Show init-specific help
123
+
124
+ Examples:
125
+ npx retiam init
126
+ npx retiam init my-animation
127
+ npx retiam create quantum-viz --title "Quantum Mechanics" --pm pnpm
128
+ npx retiam init intro-scene -y --install
129
+
130
+ ================================================================================
131
+ 4. LINT (npx retiam lint <file> [options])
132
+ Static analyzer and AST validator detecting common animation bugs and timing hazards.
133
+
134
+ Arguments:
135
+ <file> Target scene file to analyze (e.g. MyScene.ts)
136
+
137
+ Options:
138
+ --json Output machine-readable JSON with line numbers & suggested fixes
139
+ --help, -h Show lint-specific help
140
+
141
+ Checks Performed:
142
+ - Validates Scene class structure and async run() contract
143
+ - Detects un-awaited this.play() or this.wait() timing races
144
+ - Warns about dangling entities not attached to scene graph
145
+ - Catches Three.js / Python Manim hallucinations
146
+ - Flags extreme world coordinates exceeding standard camera frustum
147
+
148
+ Examples:
149
+ npx retiam lint MyScene.ts
150
+ npx retiam lint MyScene.ts --json
151
+
152
+ ================================================================================
153
+ 5. EXPORT (npx retiam export [file] [outDir] [options])
154
+ Compile the scene into a standalone, zero-dependency <retiam-scene> Web Component.
155
+
156
+ Arguments:
157
+ [file] Source scene file to bundle (default: src/main.ts)
158
+ [outDir] Target distribution folder (default: outputs/embed)
159
+
160
+ Options:
161
+ -o, --out <dir> Target distribution folder (default: outputs/embed)
162
+ --help, -h Show export-specific help
163
+
164
+ Examples:
165
+ npx retiam export MyScene.ts
166
+ npx retiam export MyScene.ts ./outputs/embed
167
+ `);
168
+ }
169
+
170
+ if (command === 'lint') {
171
+ // Usage: npx retiam lint src/MyScene.ts [--json]
172
+ runScript(lintScript, args.slice(1));
173
+ }
174
+ else if (command === 'snapshot') {
175
+ // Usage: npx retiam snapshot src/MyScene.ts [--times 1.0,2.5] [--out ./outputs/snapshot] [--json]
176
+ runScript(snapshotScript, args.slice(1));
177
+ }
178
+ else if (command === 'init' || command === 'create' || command === 'scaffold') {
179
+ // Usage: npx retiam init [directory] [options]
180
+ runScript(initScript, args.slice(1));
181
+ }
182
+ else if (command === 'export') {
183
+ // Usage: npx retiam export src/main.ts
184
+ runScript(exportScript, args.slice(1));
185
+ }
186
+ else if (command === 'render') {
187
+ // Usage: npx retiam render src/main.ts
188
+ runScript(renderScript, args.slice(1));
189
+ }
190
+ else if (command === 'help') {
191
+ const sub = args[1];
192
+ if (sub === 'lint') {
193
+ runScript(lintScript, ['--help']);
194
+ } else if (sub === 'snapshot') {
195
+ runScript(snapshotScript, ['--help']);
196
+ } else if (sub === 'init' || sub === 'create' || sub === 'scaffold') {
197
+ runScript(initScript, ['--help']);
198
+ } else if (sub === 'export') {
199
+ runScript(exportScript, ['--help']);
200
+ } else if (sub === 'render') {
201
+ runScript(renderScript, ['--help']);
202
+ } else {
203
+ printRootHelp();
204
+ }
205
+ }
206
+ else if (command === '-h' || command === '--help' || !command) {
207
+ printRootHelp();
208
+ }
209
+ else {
210
+ // Fallback: Default to rendering if a file path or flag is passed directly
211
+ // Usage: npx retiam src/main.ts
212
+ runScript(renderScript, args);
213
+ }