@series-inc/stowkit-cli 0.1.30 → 0.6.14

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/dist/cli.js CHANGED
@@ -38,7 +38,9 @@ checkForUpdate();
38
38
  function printUsage() {
39
39
  console.log(`
40
40
  Usage:
41
- stowkit init [dir] Initialize a StowKit project
41
+ stowkit init [dir] Initialize a StowKit project (interactive menu)
42
+ stowkit init --with-engine Initialize with 3D engine included
43
+ stowkit init --no-engine Initialize without 3D engine (skip prompt)
42
44
  stowkit init --update [dir] Update AI skill files to match installed CLI version
43
45
  stowkit build [dir] Full build: scan + process + pack
44
46
  stowkit scan [dir] Detect new assets, generate .stowmeta defaults
@@ -105,7 +107,11 @@ async function main() {
105
107
  try {
106
108
  switch (command) {
107
109
  case 'init':
108
- await initProject(projectDir, { update: args.includes('--update') });
110
+ await initProject(projectDir, {
111
+ update: args.includes('--update'),
112
+ withEngine: args.includes('--with-engine'),
113
+ noEngine: args.includes('--no-engine'),
114
+ });
109
115
  break;
110
116
  case 'update': {
111
117
  const currentVersion = getVersion();
package/dist/index.d.ts CHANGED
@@ -26,3 +26,4 @@ export { startServer } from './server.js';
26
26
  export type { ServerOptions } from './server.js';
27
27
  export { initProject } from './init.js';
28
28
  export { cleanupProject } from './cleanup.js';
29
+ export { syncRuntimeAssets } from './sync-runtime-assets.js';
package/dist/index.js CHANGED
@@ -33,3 +33,5 @@ export { startServer } from './server.js';
33
33
  export { initProject } from './init.js';
34
34
  // Cleanup
35
35
  export { cleanupProject } from './cleanup.js';
36
+ // Runtime asset sync
37
+ export { syncRuntimeAssets } from './sync-runtime-assets.js';
package/dist/init.d.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  export interface InitOptions {
2
2
  update?: boolean;
3
+ withEngine?: boolean;
4
+ noEngine?: boolean;
3
5
  }
4
6
  export declare function initProject(projectDir: string, opts?: InitOptions): Promise<void>;
package/dist/init.js CHANGED
@@ -1,6 +1,36 @@
1
1
  import * as fs from 'node:fs/promises';
2
2
  import * as path from 'node:path';
3
+ import * as readline from 'node:readline';
3
4
  import { fileURLToPath } from 'node:url';
5
+ async function promptMenu(question, choices) {
6
+ const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
7
+ return new Promise((resolve) => {
8
+ console.log(`\n${question}\n`);
9
+ for (let i = 0; i < choices.length; i++) {
10
+ console.log(` ${i + 1}) ${choices[i]}`);
11
+ }
12
+ console.log('');
13
+ const ask = () => {
14
+ rl.question('Choose [1]: ', (answer) => {
15
+ const trimmed = answer.trim();
16
+ if (trimmed === '') {
17
+ rl.close();
18
+ resolve(0);
19
+ return;
20
+ }
21
+ const num = parseInt(trimmed, 10);
22
+ if (num >= 1 && num <= choices.length) {
23
+ rl.close();
24
+ resolve(num - 1);
25
+ return;
26
+ }
27
+ console.log(` Please enter 1-${choices.length}`);
28
+ ask();
29
+ });
30
+ };
31
+ ask();
32
+ });
33
+ }
4
34
  export async function initProject(projectDir, opts) {
5
35
  const absDir = path.resolve(projectDir);
6
36
  const configPath = path.join(absDir, '.felicityproject');
@@ -15,6 +45,7 @@ export async function initProject(projectDir, opts) {
15
45
  process.exit(1);
16
46
  }
17
47
  await copySkillFiles(absDir);
48
+ await copyEngineSkillFiles(absDir);
18
49
  console.log('Updated AI skill files:');
19
50
  console.log(' .claude/skills/stowkit/SKILL.md');
20
51
  console.log(' .cursor/rules/stowkit.mdc');
@@ -29,6 +60,16 @@ export async function initProject(projectDir, opts) {
29
60
  catch {
30
61
  // Does not exist — create it
31
62
  }
63
+ // Prompt for engine setup unless explicitly set via flag
64
+ let withEngine = opts?.withEngine ?? false;
65
+ const noEngine = opts?.noEngine ?? false;
66
+ if (!withEngine && !noEngine && process.stdin.isTTY) {
67
+ const choice = await promptMenu('What would you like to set up?', [
68
+ 'StowKit (asset pipeline only)',
69
+ 'StowKit + 3D Engine (includes @series-inc/rundot-3d-engine)',
70
+ ]);
71
+ withEngine = choice === 1;
72
+ }
32
73
  // Create srcArtDir with .gitignore for cache files
33
74
  const srcArtDir = 'assets';
34
75
  await fs.mkdir(path.join(absDir, srcArtDir), { recursive: true });
@@ -72,10 +113,36 @@ export async function initProject(projectDir, opts) {
72
113
  console.log(` Output dir: public/cdn-assets/`);
73
114
  console.log(` Config: .felicityproject`);
74
115
  console.log(` AI skills: .claude/skills/stowkit/SKILL.md, .cursor/rules/stowkit.mdc`);
116
+ // Install engine if selected
117
+ if (withEngine) {
118
+ await installEngine(absDir);
119
+ }
75
120
  console.log('');
76
121
  console.log('Drop your assets (PNG, JPG, FBX, WAV, etc.) into assets/');
77
122
  console.log('Then run: stowkit build');
78
123
  }
124
+ async function installEngine(absDir) {
125
+ console.log('');
126
+ console.log('Installing @series-inc/rundot-3d-engine and three...');
127
+ const { execSync } = await import('node:child_process');
128
+ try {
129
+ execSync('npm install @series-inc/rundot-3d-engine three', {
130
+ cwd: absDir,
131
+ stdio: 'inherit',
132
+ });
133
+ }
134
+ catch {
135
+ console.error('Failed to install engine packages. You can install manually:');
136
+ console.error(' npm install @series-inc/rundot-3d-engine three');
137
+ return;
138
+ }
139
+ await copyEngineSkillFiles(absDir);
140
+ console.log('');
141
+ console.log(' 3D Engine installed:');
142
+ console.log(' @series-inc/rundot-3d-engine');
143
+ console.log(' three');
144
+ console.log(' AI skills: .claude/skills/stowkit-engine/SKILL.md, .cursor/rules/stowkit-engine.mdc');
145
+ }
79
146
  async function copySkillFiles(absDir) {
80
147
  const thisDir = path.dirname(fileURLToPath(import.meta.url));
81
148
  const skillSrc = path.resolve(thisDir, '../skill.md');
@@ -92,3 +159,34 @@ async function copySkillFiles(absDir) {
92
159
  // Skill file not found in package — skip silently
93
160
  }
94
161
  }
162
+ async function copyEngineSkillFiles(absDir) {
163
+ const thisDir = path.dirname(fileURLToPath(import.meta.url));
164
+ const candidates = [
165
+ // Monorepo dev: sibling folder
166
+ path.resolve(thisDir, '../../stowkit-engine/SKILL.md'),
167
+ // Installed in project's node_modules
168
+ path.join(absDir, 'node_modules/@series-inc/rundot-3d-engine/SKILL.md'),
169
+ // Installed as dep of CLI: nested node_modules
170
+ path.resolve(thisDir, '../node_modules/@series-inc/rundot-3d-engine/SKILL.md'),
171
+ // Hoisted in global node_modules
172
+ path.resolve(thisDir, '../../../@series-inc/rundot-3d-engine/SKILL.md'),
173
+ ];
174
+ let skillContent = null;
175
+ for (const candidate of candidates) {
176
+ try {
177
+ skillContent = await fs.readFile(candidate, 'utf-8');
178
+ break;
179
+ }
180
+ catch {
181
+ // not found, try next
182
+ }
183
+ }
184
+ if (!skillContent)
185
+ return;
186
+ const claudeDir = path.join(absDir, '.claude', 'skills', 'stowkit-engine');
187
+ await fs.mkdir(claudeDir, { recursive: true });
188
+ await fs.writeFile(path.join(claudeDir, 'SKILL.md'), skillContent);
189
+ const cursorDir = path.join(absDir, '.cursor', 'rules');
190
+ await fs.mkdir(cursorDir, { recursive: true });
191
+ await fs.writeFile(path.join(cursorDir, 'stowkit-engine.mdc'), `---\ndescription: Rundot 3D Engine — VenusGame, GameObject, Component, physics, animations, StowKit asset loading\nalwaysApply: true\n---\n\n${skillContent}`);
192
+ }
@@ -11,6 +11,7 @@ import { readStowmat, stowmatToMaterialConfig } from './app/stowmat-io.js';
11
11
  import { readCacheBlobs, writeCacheBlobs, buildCacheStamp, isCacheValid, } from './app/process-cache.js';
12
12
  import { buildPack, processExtractedAnimations, validatePackDependencies } from './pipeline.js';
13
13
  import { WorkerPool } from './workers/worker-pool.js';
14
+ import { syncRuntimeAssets } from './sync-runtime-assets.js';
14
15
  export async function scanProject(projectDir, opts) {
15
16
  const config = await readProjectConfig(projectDir);
16
17
  const scan = await scanDirectory(config.srcArtDir);
@@ -46,6 +47,8 @@ export async function fullBuild(projectDir, opts) {
46
47
  console.log(`Project: ${config.projectName}`);
47
48
  if (verbose)
48
49
  console.log(`Source dir: ${config.srcArtDir}`);
50
+ // 0. Sync WASM/Basis/Draco from node_modules → public/stowkit/
51
+ syncRuntimeAssets(projectDir, verbose);
49
52
  // 1. Scan
50
53
  const scan = await scanDirectory(config.srcArtDir);
51
54
  if (verbose)
package/dist/server.js CHANGED
@@ -10,6 +10,7 @@ import { detectAssetType, readStowmeta, writeStowmeta, stowmetaToAssetSettings,
10
10
  import { readStowmat, writeStowmat, stowmatToMaterialConfig, materialConfigToStowmat } from './app/stowmat-io.js';
11
11
  import { readCacheBlobs, writeCacheBlobs, buildCacheStamp, isCacheValid, } from './app/process-cache.js';
12
12
  import { buildPack, validatePackDependencies, processExtractedAnimations } from './pipeline.js';
13
+ import { syncRuntimeAssets } from './sync-runtime-assets.js';
13
14
  import { parseGlb, pbrToMaterialConfig } from './encoders/glb-loader.js';
14
15
  import { WorkerPool } from './workers/worker-pool.js';
15
16
  async function scanPrefabFiles(dir, prefix) {
@@ -1577,6 +1578,7 @@ export async function startServer(opts = {}) {
1577
1578
  }
1578
1579
  // Open project if specified (skip if already loaded — e.g. stowkit editor starts two servers)
1579
1580
  if (opts.projectDir && (!projectConfig || projectConfig.projectDir !== opts.projectDir)) {
1581
+ syncRuntimeAssets(opts.projectDir);
1580
1582
  await openProject(opts.projectDir);
1581
1583
  queueProcessing({ force: opts.force });
1582
1584
  }
@@ -0,0 +1,11 @@
1
+ interface SyncResult {
2
+ wasm: boolean;
3
+ basis: boolean;
4
+ draco: boolean;
5
+ }
6
+ /**
7
+ * Copy stowkit_reader.wasm, basis/, and draco/ decoders from node_modules
8
+ * into `<projectDir>/public/stowkit/`.
9
+ */
10
+ export declare function syncRuntimeAssets(projectDir: string, verbose?: boolean): SyncResult;
11
+ export {};
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Sync WASM, Basis, and Draco runtime assets from node_modules to public/stowkit/.
3
+ *
4
+ * Postinstall scripts are unreliable for keeping these in sync (they don't re-run
5
+ * on transitive dep updates). This module is called by `stowkit build` and
6
+ * `stowkit serve/packer/editor` so the files are always fresh.
7
+ */
8
+ import { existsSync, mkdirSync, readdirSync, copyFileSync, statSync } from 'node:fs';
9
+ import { join, resolve } from 'node:path';
10
+ /**
11
+ * Copy stowkit_reader.wasm, basis/, and draco/ decoders from node_modules
12
+ * into `<projectDir>/public/stowkit/`.
13
+ */
14
+ export function syncRuntimeAssets(projectDir, verbose = false) {
15
+ const dest = join(projectDir, 'public', 'stowkit');
16
+ const result = { wasm: false, basis: false, draco: false };
17
+ // ── WASM ────────────────────────────────────────────────────────────────────
18
+ const wasmCandidates = [
19
+ join(projectDir, 'node_modules', '@series-inc', 'stowkit-reader', 'dist', 'stowkit_reader.wasm'),
20
+ ];
21
+ for (const src of wasmCandidates) {
22
+ if (existsSync(src)) {
23
+ mkdirSync(dest, { recursive: true });
24
+ copyFileSync(src, join(dest, 'stowkit_reader.wasm'));
25
+ result.wasm = true;
26
+ if (verbose)
27
+ console.log(' Synced stowkit_reader.wasm → public/stowkit/');
28
+ break;
29
+ }
30
+ }
31
+ // ── Basis & Draco decoders ──────────────────────────────────────────────────
32
+ const loaderCandidates = [
33
+ join(projectDir, 'node_modules', '@series-inc', 'stowkit-three-loader', 'public'),
34
+ ];
35
+ for (const loaderPublic of loaderCandidates) {
36
+ if (!existsSync(loaderPublic))
37
+ continue;
38
+ // Guard against recursive copy
39
+ const srcAbs = resolve(loaderPublic);
40
+ const destAbs = resolve(dest);
41
+ if (destAbs.startsWith(srcAbs + '/') || destAbs.startsWith(srcAbs + '\\') || destAbs === srcAbs)
42
+ continue;
43
+ for (const subdir of ['basis', 'draco']) {
44
+ const src = join(loaderPublic, subdir);
45
+ if (!existsSync(src))
46
+ continue;
47
+ const subdirDest = join(dest, subdir);
48
+ mkdirSync(subdirDest, { recursive: true });
49
+ for (const file of readdirSync(src)) {
50
+ if (statSync(join(src, file)).isFile()) {
51
+ copyFileSync(join(src, file), join(subdirDest, file));
52
+ }
53
+ }
54
+ result[subdir] = true;
55
+ if (verbose)
56
+ console.log(` Synced ${subdir}/ → public/stowkit/${subdir}/`);
57
+ }
58
+ break;
59
+ }
60
+ if (result.wasm || result.basis || result.draco) {
61
+ const parts = [result.wasm && 'WASM', result.basis && 'Basis', result.draco && 'Draco'].filter(Boolean);
62
+ console.log(`Synced runtime assets (${parts.join(', ')}) → public/stowkit/`);
63
+ }
64
+ return result;
65
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@series-inc/stowkit-cli",
3
- "version": "0.1.30",
3
+ "version": "0.6.14",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "stowkit": "./dist/cli.js"
@@ -17,8 +17,8 @@
17
17
  "dev": "tsc --watch"
18
18
  },
19
19
  "dependencies": {
20
- "@series-inc/stowkit-packer-gui": "^0.1.16",
21
- "@series-inc/stowkit-editor": "^0.1.2",
20
+ "@series-inc/stowkit-packer-gui": "^0.1.17",
21
+ "@series-inc/stowkit-editor": "^0.1.3",
22
22
  "draco3d": "^1.5.7",
23
23
  "fbx-parser": "^2.1.3",
24
24
  "@strangeape/ffmpeg-audio-wasm": "^0.1.0",
package/skill.md CHANGED
@@ -36,7 +36,9 @@ A StowKit project has a `.felicityproject` JSON file at its root:
36
36
  ## CLI Commands
37
37
 
38
38
  ```bash
39
- stowkit init [dir] # Scaffold a new project (creates .felicityproject, assets/, public/cdn-assets/)
39
+ stowkit init [dir] # Scaffold a new project (interactive menu: pipeline only or with 3D engine)
40
+ stowkit init --with-engine # Scaffold with 3D engine pre-installed (@series-inc/rundot-3d-engine + three)
41
+ stowkit init --no-engine # Scaffold without 3D engine (skip interactive prompt)
40
42
  stowkit init --update [dir] # Update AI skill files to match installed CLI version
41
43
  stowkit update # Update CLI to latest version and refresh skill files
42
44
  stowkit version # Show installed version
@@ -558,6 +560,17 @@ The CLI always re-extracts GLB containers on every build, so changes to `preserv
558
560
  - **true:** The original scene graph node hierarchy is preserved with local transforms (position, rotation, scale) per node. Use this for complex multi-part models where you need individual nodes at runtime (e.g. a vehicle with doors, a character with attachable accessories).
559
561
  - Skinned meshes are always excluded from hierarchy preservation regardless of this setting.
560
562
 
563
+ ### Inspecting built packs
564
+
565
+ Use `stowkit inspect` to examine the contents of a built `.stow` pack file:
566
+
567
+ ```bash
568
+ stowkit inspect public/cdn-assets/default.stow # Show manifest (asset names, types, sizes)
569
+ stowkit inspect public/cdn-assets/default.stow -v # Verbose — includes metadata details per asset
570
+ ```
571
+
572
+ This is useful for verifying build output, checking which assets ended up in which pack, and debugging asset loading issues at runtime.
573
+
561
574
  ### Other common tasks
562
575
 
563
576
  - **Add a texture:** Place PNG/JPG into `assets/`, run `stowkit build`. The CLI auto-generates the `.stowmeta`. Do NOT create it yourself.
@@ -571,6 +584,9 @@ The CLI always re-extracts GLB containers on every build, so changes to `preserv
571
584
  - **Move an asset:** `stowkit move textures/hero.png characters` (moves to `characters/hero.png`, updates GLB child refs if container)
572
585
  - **Delete an asset:** `stowkit delete textures/unused.png` (removes source + .stowmeta + .stowcache, cascades for GLB containers)
573
586
  - **Change an asset's stringId:** `stowkit set-id textures/hero.png hero_diffuse`
587
+ - **Inspect a built pack:** `stowkit inspect public/cdn-assets/default.stow` (shows manifest; add `-v` for detailed metadata)
574
588
  - **Check project health:** Run `stowkit status`
575
589
  - **Full rebuild:** `stowkit build --force`
576
590
  - **Clean orphaned files:** `stowkit clean`
591
+ - **Set up with engine:** `stowkit init --with-engine` (installs `@series-inc/rundot-3d-engine` + `three`)
592
+ - **Update CLI + skill files:** `stowkit update`