@series-inc/stowkit-cli 0.1.24 → 0.1.26

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
@@ -9,6 +9,7 @@ import { initProject } from './init.js';
9
9
  import { cleanupProject } from './cleanup.js';
10
10
  import { createMaterial } from './create-material.js';
11
11
  import { renameAsset, moveAsset, deleteAsset, setStringId } from './asset-commands.js';
12
+ import { inspectPack } from './inspect.js';
12
13
  const args = process.argv.slice(2);
13
14
  const thisDir = path.dirname(fileURLToPath(import.meta.url));
14
15
  function checkForUpdate() {
@@ -24,7 +25,7 @@ function checkForUpdate() {
24
25
  const latest = data.version;
25
26
  if (latest && latest !== localVersion) {
26
27
  console.log(`\n Update available: ${localVersion} → ${latest}`);
27
- console.log(` Run: npm install -g @series-inc/stowkit-cli\n`);
28
+ console.log(` Run: stowkit update\n`);
28
29
  }
29
30
  })
30
31
  .catch(() => { clearTimeout(timeout); });
@@ -49,6 +50,9 @@ Usage:
49
50
  stowkit move <path> <folder> Move an asset to a different folder
50
51
  stowkit delete <path> Delete an asset and its sidecar files
51
52
  stowkit set-id <path> <id> Change an asset's stringId
53
+ stowkit inspect <file.stow> Show manifest of a built .stow pack
54
+ stowkit update Update CLI to latest version and refresh skill files
55
+ stowkit version Show installed version
52
56
  stowkit packer [dir] Open the packer GUI
53
57
  stowkit editor [dir] Open the level editor
54
58
  stowkit serve [dir] Start API server only (no GUI)
@@ -76,6 +80,10 @@ function resolveAppDir(packageName, monorepoFolder) {
76
80
  }
77
81
  return null;
78
82
  }
83
+ function getVersion() {
84
+ const pkg = JSON.parse(fs.readFileSync(path.resolve(thisDir, '../package.json'), 'utf-8'));
85
+ return pkg.version;
86
+ }
79
87
  function openBrowser(url) {
80
88
  import('node:child_process').then(({ exec }) => {
81
89
  const cmd = process.platform === 'win32' ? 'start' : process.platform === 'darwin' ? 'open' : 'xdg-open';
@@ -99,6 +107,33 @@ async function main() {
99
107
  case 'init':
100
108
  await initProject(projectDir, { update: args.includes('--update') });
101
109
  break;
110
+ case 'update': {
111
+ const currentVersion = getVersion();
112
+ console.log(`Current version: ${currentVersion}`);
113
+ console.log('Checking for updates...');
114
+ const res = await fetch('https://registry.npmjs.org/@series-inc/stowkit-cli/latest');
115
+ const data = await res.json();
116
+ const latest = data.version;
117
+ if (latest === currentVersion) {
118
+ console.log('Already on the latest version.');
119
+ }
120
+ else {
121
+ console.log(`Updating: ${currentVersion} → ${latest}`);
122
+ const { execSync } = await import('node:child_process');
123
+ execSync('npm install -g @series-inc/stowkit-cli@latest', { stdio: 'inherit' });
124
+ console.log(`Updated to ${latest}.`);
125
+ }
126
+ // Refresh skill files if in a StowKit project
127
+ const configExists = existsSync(path.resolve(projectDir, '.felicityproject'));
128
+ if (configExists) {
129
+ await initProject(projectDir, { update: true });
130
+ }
131
+ break;
132
+ }
133
+ case 'version':
134
+ case '--version':
135
+ console.log(getVersion());
136
+ break;
102
137
  case 'build':
103
138
  await fullBuild(projectDir, opts);
104
139
  break;
@@ -175,6 +210,15 @@ async function main() {
175
210
  await setStringId('.', positional[0], positional[1]);
176
211
  break;
177
212
  }
213
+ case 'inspect': {
214
+ const stowPath = args.find(a => !a.startsWith('-') && a !== command);
215
+ if (!stowPath) {
216
+ console.error('Usage: stowkit inspect <file.stow>');
217
+ process.exit(1);
218
+ }
219
+ await inspectPack(stowPath, { verbose });
220
+ break;
221
+ }
178
222
  case 'packer': {
179
223
  const packerDir = resolveAppDir('@series-inc/stowkit-packer-gui', 'stowkit-packer-gui');
180
224
  if (!packerDir) {
@@ -0,0 +1,3 @@
1
+ export declare function inspectPack(filePath: string, opts?: {
2
+ verbose?: boolean;
3
+ }): Promise<void>;
@@ -0,0 +1,165 @@
1
+ import * as fs from 'node:fs/promises';
2
+ import * as path from 'node:path';
3
+ import { BinaryReader } from './core/binary.js';
4
+ import { AssetType } from './core/types.js';
5
+ import { STOW_MAGIC, FILE_HEADER_SIZE, STRING_ID_SIZE, } from './core/constants.js';
6
+ import { unwrapMetadata } from './format/metadata.js';
7
+ const ASSET_TYPE_NAMES = {
8
+ [AssetType.Unknown]: 'unknown',
9
+ [AssetType.StaticMesh]: 'staticMesh',
10
+ [AssetType.Texture2D]: 'texture',
11
+ [AssetType.Audio]: 'audio',
12
+ [AssetType.MaterialSchema]: 'material',
13
+ [AssetType.SkinnedMesh]: 'skinnedMesh',
14
+ [AssetType.AnimationClip]: 'animation',
15
+ [AssetType.GlbContainer]: 'glbContainer',
16
+ };
17
+ function formatBytes(bytes) {
18
+ if (bytes < 1024)
19
+ return `${bytes} B`;
20
+ if (bytes < 1024 * 1024)
21
+ return `${(bytes / 1024).toFixed(1)} KB`;
22
+ return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
23
+ }
24
+ /** Read stringId from the start of unwrapped asset metadata based on type. */
25
+ function readStringIdAndDetails(type, meta) {
26
+ const r = new BinaryReader(meta);
27
+ switch (type) {
28
+ case AssetType.Texture2D: {
29
+ const width = r.readUint32();
30
+ const height = r.readUint32();
31
+ const channels = r.readUint32();
32
+ r.readUint32(); // channelFormat
33
+ const stringId = r.readFixedString(STRING_ID_SIZE);
34
+ return { stringId, details: `${width}x${height}, ${channels}ch` };
35
+ }
36
+ case AssetType.Audio: {
37
+ const stringId = r.readFixedString(STRING_ID_SIZE);
38
+ const sampleRate = r.readUint32();
39
+ const channels = r.readUint32();
40
+ const durationMs = r.readUint32();
41
+ const durSec = (durationMs / 1000).toFixed(1);
42
+ return { stringId, details: `${durSec}s, ${sampleRate}Hz, ${channels}ch` };
43
+ }
44
+ case AssetType.StaticMesh: {
45
+ const geoCount = r.readUint32();
46
+ const matCount = r.readUint32();
47
+ const nodeCount = r.readUint32();
48
+ const stringId = r.readFixedString(STRING_ID_SIZE);
49
+ return { stringId, details: `${geoCount} geo, ${matCount} mat, ${nodeCount} nodes` };
50
+ }
51
+ case AssetType.SkinnedMesh: {
52
+ const geoCount = r.readUint32();
53
+ const matCount = r.readUint32();
54
+ const nodeCount = r.readUint32();
55
+ const boneCount = r.readUint32();
56
+ const stringId = r.readFixedString(STRING_ID_SIZE);
57
+ return { stringId, details: `${geoCount} geo, ${boneCount} bones` };
58
+ }
59
+ case AssetType.AnimationClip: {
60
+ const stringId = r.readFixedString(STRING_ID_SIZE);
61
+ r.readFixedString(STRING_ID_SIZE); // targetMeshId
62
+ r.readUint32(); // metadataVersion
63
+ const duration = r.readFloat32();
64
+ const trackCount = r.readUint32();
65
+ return { stringId, details: `${duration.toFixed(2)}s, ${trackCount} tracks` };
66
+ }
67
+ case AssetType.MaterialSchema: {
68
+ const stringId = r.readFixedString(STRING_ID_SIZE);
69
+ const schemaName = r.readFixedString(64);
70
+ const fieldCount = r.readUint32();
71
+ return { stringId, details: `schema: ${schemaName}, ${fieldCount} fields` };
72
+ }
73
+ default:
74
+ return { stringId: '?', details: '' };
75
+ }
76
+ }
77
+ export async function inspectPack(filePath, opts) {
78
+ const absPath = path.resolve(filePath);
79
+ const data = await fs.readFile(absPath);
80
+ const buf = new Uint8Array(data);
81
+ if (buf.length < FILE_HEADER_SIZE) {
82
+ throw new Error(`File too small to be a .stow pack: ${buf.length} bytes`);
83
+ }
84
+ // Read header
85
+ const hr = new BinaryReader(buf);
86
+ const magic = hr.readUint32();
87
+ if (magic !== STOW_MAGIC) {
88
+ throw new Error(`Invalid magic: 0x${magic.toString(16)} (expected 0x${STOW_MAGIC.toString(16)})`);
89
+ }
90
+ const version = hr.readUint32();
91
+ const assetCount = hr.readUint32();
92
+ const dirOffset = hr.readUint64AsNumber();
93
+ // Read directory entries
94
+ const entries = [];
95
+ const dr = new BinaryReader(buf, dirOffset);
96
+ for (let i = 0; i < assetCount; i++) {
97
+ entries.push({
98
+ uid: dr.readUint64(),
99
+ type: dr.readUint32(),
100
+ dataOffset: dr.readUint64AsNumber(),
101
+ dataSize: dr.readUint64AsNumber(),
102
+ metadataOffset: dr.readUint64AsNumber(),
103
+ metadataSize: dr.readUint32(),
104
+ });
105
+ }
106
+ // Parse each asset's metadata
107
+ const assets = [];
108
+ for (const entry of entries) {
109
+ const typeName = ASSET_TYPE_NAMES[entry.type] ?? `type(${entry.type})`;
110
+ let stringId = '?';
111
+ let tags = [];
112
+ let details = '';
113
+ if (entry.metadataOffset > 0 && entry.metadataSize > 0) {
114
+ const rawMeta = buf.slice(entry.metadataOffset, entry.metadataOffset + entry.metadataSize);
115
+ // Try tag-wrapped first; if tagCsvLength looks unreasonable, treat as raw metadata
116
+ let assetMeta;
117
+ try {
118
+ const unwrapped = unwrapMetadata(rawMeta);
119
+ // Sanity check: tagCsvLength should be small (< 4096); if it's huge, it's raw metadata
120
+ const tagCsvLen = new DataView(rawMeta.buffer, rawMeta.byteOffset, 4).getUint32(0, true);
121
+ if (tagCsvLen < 4096 && tagCsvLen < rawMeta.length) {
122
+ tags = unwrapped.tags;
123
+ assetMeta = unwrapped.assetMetadata;
124
+ }
125
+ else {
126
+ assetMeta = rawMeta;
127
+ }
128
+ }
129
+ catch {
130
+ assetMeta = rawMeta;
131
+ }
132
+ try {
133
+ const parsed = readStringIdAndDetails(entry.type, assetMeta);
134
+ stringId = parsed.stringId;
135
+ details = parsed.details;
136
+ }
137
+ catch {
138
+ // Metadata format not recognized — show what we can
139
+ }
140
+ }
141
+ assets.push({ type: typeName, stringId, dataSize: entry.dataSize, tags, details });
142
+ }
143
+ // Sort by type then stringId
144
+ assets.sort((a, b) => a.type.localeCompare(b.type) || a.stringId.localeCompare(b.stringId));
145
+ // Print
146
+ const packName = path.basename(absPath);
147
+ const totalSize = buf.length;
148
+ console.log(`\nPack: ${packName} (${formatBytes(totalSize)}, v${version})`);
149
+ console.log(`Assets: ${assetCount}\n`);
150
+ // Calculate column widths
151
+ const typeWidth = Math.max(4, ...assets.map(a => a.type.length));
152
+ const idWidth = Math.max(8, ...assets.map(a => a.stringId.length));
153
+ for (const a of assets) {
154
+ const type = `[${a.type}]`.padEnd(typeWidth + 2);
155
+ const id = a.stringId.padEnd(idWidth);
156
+ const size = formatBytes(a.dataSize).padStart(10);
157
+ let line = ` ${type} ${id} ${size}`;
158
+ if (opts?.verbose && a.details)
159
+ line += ` ${a.details}`;
160
+ if (a.tags.length > 0 && a.tags[0] !== '')
161
+ line += ` [${a.tags.join(', ')}]`;
162
+ console.log(line);
163
+ }
164
+ console.log('');
165
+ }
package/dist/server.js CHANGED
@@ -1473,10 +1473,12 @@ export async function startServer(opts = {}) {
1473
1473
  }));
1474
1474
  ws.on('close', () => wsClients.delete(ws));
1475
1475
  });
1476
- // Initialize worker pool
1477
- workerPool = initWorkerPool(opts.wasmDir);
1478
- // Open project if specified
1479
- if (opts.projectDir) {
1476
+ // Initialize worker pool (shared across servers in the same process)
1477
+ if (!workerPool) {
1478
+ workerPool = initWorkerPool(opts.wasmDir);
1479
+ }
1480
+ // Open project if specified (skip if already loaded — e.g. stowkit editor starts two servers)
1481
+ if (opts.projectDir && (!projectConfig || projectConfig.projectDir !== opts.projectDir)) {
1480
1482
  await openProject(opts.projectDir);
1481
1483
  queueProcessing();
1482
1484
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@series-inc/stowkit-cli",
3
- "version": "0.1.24",
3
+ "version": "0.1.26",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "stowkit": "./dist/cli.js"
package/skill.md CHANGED
@@ -38,6 +38,8 @@ A StowKit project has a `.felicityproject` JSON file at its root:
38
38
  ```bash
39
39
  stowkit init [dir] # Scaffold a new project (creates .felicityproject, assets/, public/cdn-assets/)
40
40
  stowkit init --update [dir] # Update AI skill files to match installed CLI version
41
+ stowkit update # Update CLI to latest version and refresh skill files
42
+ stowkit version # Show installed version
41
43
  stowkit build [dir] # Full build: scan + process + pack
42
44
  stowkit scan [dir] # Detect new assets and generate .stowmeta defaults
43
45
  stowkit process [dir] # Compress assets (respects cache)
@@ -48,6 +50,7 @@ stowkit rename <path> <name> # Rename an asset file (preserves extension, upd
48
50
  stowkit move <path> <folder> # Move an asset to a different folder (updates GLB child refs)
49
51
  stowkit delete <path> # Delete an asset and its .stowmeta/.stowcache files
50
52
  stowkit set-id <path> <id> # Change an asset's stringId
53
+ stowkit inspect <file.stow> # Show manifest of a built .stow pack (use -v for details)
51
54
  stowkit packer [dir] # Open the packer GUI in browser
52
55
  stowkit editor [dir] # Open the level editor in browser
53
56
  stowkit serve [dir] # Start API server only (no GUI)
@@ -506,17 +509,19 @@ PerfLogger.enable();
506
509
  PerfLogger.disable();
507
510
  ```
508
511
 
509
- ## Updating This Skill File
512
+ ## Updating the CLI and This Skill File
510
513
 
511
- This skill file is bundled with the `@series-inc/stowkit-cli` package. When the CLI is updated to a newer version, the local copy of this file may become outdated. To refresh it:
514
+ This skill file is bundled with the `@series-inc/stowkit-cli` package. To update the CLI to the latest version and refresh this file in one step:
512
515
 
513
516
  ```bash
514
- stowkit init --update
517
+ stowkit update
515
518
  ```
516
519
 
517
- This overwrites `.claude/skills/stowkit/SKILL.md` and `.cursor/rules/stowkit.mdc` with the version shipped in the currently installed CLI. It does not touch the project config, directories, or any asset files.
520
+ This updates the global CLI install, then overwrites `.claude/skills/stowkit/SKILL.md` and `.cursor/rules/stowkit.mdc` with the version shipped in the new CLI. It does not touch the project config, directories, or any asset files.
518
521
 
519
- **When to run this:** After upgrading the CLI (`npm install -g @series-inc/stowkit-cli@latest`), or if you notice this skill file is missing documentation for commands that exist in `stowkit --help`.
522
+ To refresh skill files without updating the CLI: `stowkit init --update`
523
+
524
+ **When to run this:** If you notice this skill file is missing documentation for commands that exist in `stowkit --help`, or if the user asks you to update StowKit.
520
525
 
521
526
  ## Common Tasks for AI Agents
522
527