@series-inc/stowkit-cli 0.1.25 → 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 +11 -0
- package/dist/inspect.d.ts +3 -0
- package/dist/inspect.js +165 -0
- package/dist/server.js +6 -4
- package/package.json +1 -1
- package/skill.md +1 -0
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() {
|
|
@@ -49,6 +50,7 @@ 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
|
|
52
54
|
stowkit update Update CLI to latest version and refresh skill files
|
|
53
55
|
stowkit version Show installed version
|
|
54
56
|
stowkit packer [dir] Open the packer GUI
|
|
@@ -208,6 +210,15 @@ async function main() {
|
|
|
208
210
|
await setStringId('.', positional[0], positional[1]);
|
|
209
211
|
break;
|
|
210
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
|
+
}
|
|
211
222
|
case 'packer': {
|
|
212
223
|
const packerDir = resolveAppDir('@series-inc/stowkit-packer-gui', 'stowkit-packer-gui');
|
|
213
224
|
if (!packerDir) {
|
package/dist/inspect.js
ADDED
|
@@ -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
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
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
package/skill.md
CHANGED
|
@@ -50,6 +50,7 @@ stowkit rename <path> <name> # Rename an asset file (preserves extension, upd
|
|
|
50
50
|
stowkit move <path> <folder> # Move an asset to a different folder (updates GLB child refs)
|
|
51
51
|
stowkit delete <path> # Delete an asset and its .stowmeta/.stowcache files
|
|
52
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)
|
|
53
54
|
stowkit packer [dir] # Open the packer GUI in browser
|
|
54
55
|
stowkit editor [dir] # Open the level editor in browser
|
|
55
56
|
stowkit serve [dir] # Start API server only (no GUI)
|