@soulcraft/sdk 3.1.1 → 3.2.0
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/modules/kits/index.d.ts +45 -14
- package/dist/modules/kits/index.d.ts.map +1 -1
- package/dist/modules/kits/index.js +359 -35
- package/dist/modules/kits/index.js.map +1 -1
- package/dist/modules/kits/types.d.ts +133 -38
- package/dist/modules/kits/types.d.ts.map +1 -1
- package/dist/modules/kits/types.js +15 -5
- package/dist/modules/kits/types.js.map +1 -1
- package/package.json +1 -1
|
@@ -2,38 +2,69 @@
|
|
|
2
2
|
* @module kits
|
|
3
3
|
* @description Factory for sdk.kits.* — the Soulcraft kit registry module.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
* package. The package is an optional peer dependency loaded lazily via
|
|
7
|
-
* `createRequire` so that the SDK compiles and runs without it installed;
|
|
8
|
-
* calls gracefully return `null` / empty array when it is absent.
|
|
5
|
+
* Supports two operating modes:
|
|
9
6
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
7
|
+
* **Registry mode** (recommended) — fetches kits from the Forge Kit Registry
|
|
8
|
+
* (`forge.soulcraft.com`) over HTTP. Archives (.sck) are downloaded, unpacked
|
|
9
|
+
* to a local disk cache, and served as local filesystem paths. ETag-based
|
|
10
|
+
* revalidation minimizes network traffic. Set `registryUrl` to enable.
|
|
12
11
|
*
|
|
13
|
-
*
|
|
12
|
+
* **Bundled mode** (legacy) — loads kits from the `@soulcraft/kits` npm
|
|
13
|
+
* package via `createRequire()`. This is the backwards-compatible default
|
|
14
|
+
* that products use today. Will be removed once all products migrate to
|
|
15
|
+
* registry mode.
|
|
16
|
+
*
|
|
17
|
+
* The factory returns the same `KitsModule` interface regardless of mode.
|
|
18
|
+
* Callers never need to know which backing store is active.
|
|
19
|
+
*
|
|
20
|
+
* @example Registry mode (production)
|
|
14
21
|
* ```typescript
|
|
15
22
|
* import { createKitsModule } from '@soulcraft/sdk/server'
|
|
16
23
|
*
|
|
24
|
+
* const kits = createKitsModule({
|
|
25
|
+
* registryUrl: process.env.FORGE_REGISTRY_URL, // 'https://forge.soulcraft.com'
|
|
26
|
+
* cachePath: '/home/app/.soulcraft/kits-cache',
|
|
27
|
+
* })
|
|
28
|
+
* const kit = await kits.load('wicks-and-whiskers')
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @example Bundled mode (legacy, no registryUrl)
|
|
32
|
+
* ```typescript
|
|
17
33
|
* const kits = createKitsModule()
|
|
18
34
|
* const kit = await kits.load('wicks-and-whiskers')
|
|
19
|
-
* console.log(kit?.name) // "Wicks & Whiskers"
|
|
20
35
|
* ```
|
|
21
36
|
*/
|
|
22
37
|
import type { KitsModule, CreateKitsModuleOptions } from './types.js';
|
|
23
38
|
/**
|
|
24
39
|
* Create the `sdk.kits.*` module.
|
|
25
40
|
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
41
|
+
* The mode is determined by the options:
|
|
42
|
+
* - `bundledRegistry` set → static in-memory registry (for tests)
|
|
43
|
+
* - `registryUrl` set → HTTP-based registry mode (production)
|
|
44
|
+
* - Neither set → legacy bundled mode via `@soulcraft/kits` package
|
|
28
45
|
*
|
|
29
|
-
* @
|
|
46
|
+
* @param options - Configuration for the kits module.
|
|
47
|
+
* @returns A `KitsModule` instance.
|
|
48
|
+
*
|
|
49
|
+
* @example Registry mode (production)
|
|
50
|
+
* ```typescript
|
|
51
|
+
* const kits = createKitsModule({
|
|
52
|
+
* registryUrl: 'https://forge.soulcraft.com',
|
|
53
|
+
* cachePath: '/home/app/.soulcraft/kits-cache',
|
|
54
|
+
* })
|
|
55
|
+
* ```
|
|
56
|
+
*
|
|
57
|
+
* @example Bundled mode (legacy — no options needed)
|
|
30
58
|
* ```typescript
|
|
31
|
-
* // In production:
|
|
32
59
|
* const kits = createKitsModule()
|
|
60
|
+
* ```
|
|
33
61
|
*
|
|
34
|
-
*
|
|
62
|
+
* @example Test mode — inject mock kits
|
|
63
|
+
* ```typescript
|
|
35
64
|
* const kits = createKitsModule({
|
|
36
|
-
* bundledRegistry: {
|
|
65
|
+
* bundledRegistry: {
|
|
66
|
+
* 'test-kit': { id: 'test-kit', name: 'Test Kit', version: '1.0.0', ... }
|
|
67
|
+
* }
|
|
37
68
|
* })
|
|
38
69
|
* ```
|
|
39
70
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modules/kits/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modules/kits/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAMH,OAAO,KAAK,EAEV,UAAU,EACV,uBAAuB,EAExB,MAAM,YAAY,CAAA;AA2YnB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,GAAE,uBAA4B,GAAG,UAAU,CAoBlF"}
|
|
@@ -2,31 +2,51 @@
|
|
|
2
2
|
* @module kits
|
|
3
3
|
* @description Factory for sdk.kits.* — the Soulcraft kit registry module.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
* package. The package is an optional peer dependency loaded lazily via
|
|
7
|
-
* `createRequire` so that the SDK compiles and runs without it installed;
|
|
8
|
-
* calls gracefully return `null` / empty array when it is absent.
|
|
5
|
+
* Supports two operating modes:
|
|
9
6
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
7
|
+
* **Registry mode** (recommended) — fetches kits from the Forge Kit Registry
|
|
8
|
+
* (`forge.soulcraft.com`) over HTTP. Archives (.sck) are downloaded, unpacked
|
|
9
|
+
* to a local disk cache, and served as local filesystem paths. ETag-based
|
|
10
|
+
* revalidation minimizes network traffic. Set `registryUrl` to enable.
|
|
12
11
|
*
|
|
13
|
-
*
|
|
12
|
+
* **Bundled mode** (legacy) — loads kits from the `@soulcraft/kits` npm
|
|
13
|
+
* package via `createRequire()`. This is the backwards-compatible default
|
|
14
|
+
* that products use today. Will be removed once all products migrate to
|
|
15
|
+
* registry mode.
|
|
16
|
+
*
|
|
17
|
+
* The factory returns the same `KitsModule` interface regardless of mode.
|
|
18
|
+
* Callers never need to know which backing store is active.
|
|
19
|
+
*
|
|
20
|
+
* @example Registry mode (production)
|
|
14
21
|
* ```typescript
|
|
15
22
|
* import { createKitsModule } from '@soulcraft/sdk/server'
|
|
16
23
|
*
|
|
24
|
+
* const kits = createKitsModule({
|
|
25
|
+
* registryUrl: process.env.FORGE_REGISTRY_URL, // 'https://forge.soulcraft.com'
|
|
26
|
+
* cachePath: '/home/app/.soulcraft/kits-cache',
|
|
27
|
+
* })
|
|
28
|
+
* const kit = await kits.load('wicks-and-whiskers')
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @example Bundled mode (legacy, no registryUrl)
|
|
32
|
+
* ```typescript
|
|
17
33
|
* const kits = createKitsModule()
|
|
18
34
|
* const kit = await kits.load('wicks-and-whiskers')
|
|
19
|
-
* console.log(kit?.name) // "Wicks & Whiskers"
|
|
20
35
|
* ```
|
|
21
36
|
*/
|
|
22
37
|
import { createRequire } from 'node:module';
|
|
23
|
-
|
|
24
|
-
|
|
38
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync, rmSync, readdirSync } from 'node:fs';
|
|
39
|
+
import { join, resolve } from 'node:path';
|
|
40
|
+
import { homedir } from 'node:os';
|
|
41
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
42
|
+
// Bundled mode — load from @soulcraft/kits npm package (legacy)
|
|
43
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
25
44
|
const _require = createRequire(import.meta.url);
|
|
45
|
+
/** Module-level cache — loaded once per process. */
|
|
26
46
|
let _kitsPackage = undefined;
|
|
27
47
|
/**
|
|
28
|
-
* Lazily load the `@soulcraft/kits` optional peer dependency.
|
|
29
|
-
* Returns `null` when the package is not installed
|
|
48
|
+
* @description Lazily load the `@soulcraft/kits` optional peer dependency.
|
|
49
|
+
* Returns `null` when the package is not installed.
|
|
30
50
|
*/
|
|
31
51
|
function _loadKitsPackage() {
|
|
32
52
|
if (_kitsPackage !== undefined)
|
|
@@ -40,36 +60,20 @@ function _loadKitsPackage() {
|
|
|
40
60
|
return _kitsPackage;
|
|
41
61
|
}
|
|
42
62
|
/**
|
|
43
|
-
*
|
|
44
|
-
*
|
|
63
|
+
* @description Get the bundled registry from the @soulcraft/kits package.
|
|
64
|
+
* @returns The kit registry, or null if the package is absent.
|
|
45
65
|
*/
|
|
46
66
|
function _getBundledRegistry() {
|
|
47
67
|
return _loadKitsPackage()?.kitRegistry ?? null;
|
|
48
68
|
}
|
|
49
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
50
|
-
// Factory
|
|
51
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
52
69
|
/**
|
|
53
|
-
* Create the
|
|
54
|
-
*
|
|
55
|
-
* @param options - Optional overrides, primarily for testing.
|
|
56
|
-
* @returns A `KitsModule` backed by the `@soulcraft/kits` registry.
|
|
57
|
-
*
|
|
58
|
-
* @example
|
|
59
|
-
* ```typescript
|
|
60
|
-
* // In production:
|
|
61
|
-
* const kits = createKitsModule()
|
|
70
|
+
* @description Create a KitsModule backed by the @soulcraft/kits npm package.
|
|
71
|
+
* This is the legacy mode, retained for backwards compatibility.
|
|
62
72
|
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
* bundledRegistry: { 'test-kit': { id: 'test-kit', name: 'Test Kit', ... } }
|
|
66
|
-
* })
|
|
67
|
-
* ```
|
|
73
|
+
* @param getRegistry - Function that returns the bundled registry (or null).
|
|
74
|
+
* @returns A KitsModule that reads from the installed npm package.
|
|
68
75
|
*/
|
|
69
|
-
|
|
70
|
-
const getRegistry = options.bundledRegistry !== undefined
|
|
71
|
-
? () => options.bundledRegistry ?? null
|
|
72
|
-
: _getBundledRegistry;
|
|
76
|
+
function _createBundledKitsModule(getRegistry) {
|
|
73
77
|
return {
|
|
74
78
|
async load(kitId) {
|
|
75
79
|
const registry = getRegistry();
|
|
@@ -103,4 +107,324 @@ export function createKitsModule(options = {}) {
|
|
|
103
107
|
},
|
|
104
108
|
};
|
|
105
109
|
}
|
|
110
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
111
|
+
// Registry mode — fetch from Forge Kit Registry over HTTP
|
|
112
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
113
|
+
/** Default cache freshness: 5 minutes. */
|
|
114
|
+
const DEFAULT_CACHE_TTL_MS = 300_000;
|
|
115
|
+
/** Default local cache directory: ~/.soulcraft/kits-cache */
|
|
116
|
+
const DEFAULT_CACHE_PATH = join(homedir(), '.soulcraft', 'kits-cache');
|
|
117
|
+
/**
|
|
118
|
+
* @description Read the cache metadata file for a kit.
|
|
119
|
+
* @param cachePath - Root cache directory.
|
|
120
|
+
* @param kitId - Kit identifier.
|
|
121
|
+
* @returns Parsed CacheMeta, or null if missing or invalid.
|
|
122
|
+
*/
|
|
123
|
+
function _readCacheMeta(cachePath, kitId) {
|
|
124
|
+
const metaPath = join(cachePath, kitId, '_cache-meta.json');
|
|
125
|
+
if (!existsSync(metaPath))
|
|
126
|
+
return null;
|
|
127
|
+
try {
|
|
128
|
+
return JSON.parse(readFileSync(metaPath, 'utf-8'));
|
|
129
|
+
}
|
|
130
|
+
catch {
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* @description Write cache metadata for a kit.
|
|
136
|
+
* @param cachePath - Root cache directory.
|
|
137
|
+
* @param kitId - Kit identifier.
|
|
138
|
+
* @param meta - Metadata to persist.
|
|
139
|
+
*/
|
|
140
|
+
function _writeCacheMeta(cachePath, kitId, meta) {
|
|
141
|
+
const metaPath = join(cachePath, kitId, '_cache-meta.json');
|
|
142
|
+
mkdirSync(join(cachePath, kitId), { recursive: true });
|
|
143
|
+
writeFileSync(metaPath, JSON.stringify(meta, null, 2));
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* @description Read a cached kit manifest from disk.
|
|
147
|
+
* @param cachePath - Root cache directory.
|
|
148
|
+
* @param kitId - Kit identifier.
|
|
149
|
+
* @returns Parsed manifest, or null if kit.json is missing.
|
|
150
|
+
*/
|
|
151
|
+
function _readCachedManifest(cachePath, kitId) {
|
|
152
|
+
const kitJsonPath = join(cachePath, kitId, 'kit.json');
|
|
153
|
+
if (!existsSync(kitJsonPath))
|
|
154
|
+
return null;
|
|
155
|
+
try {
|
|
156
|
+
return JSON.parse(readFileSync(kitJsonPath, 'utf-8'));
|
|
157
|
+
}
|
|
158
|
+
catch {
|
|
159
|
+
return null;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* @description Unpack a .sck (ZIP) archive buffer to a target directory.
|
|
164
|
+
*
|
|
165
|
+
* Uses dynamic import of `fflate` to avoid adding it as a hard SDK dependency.
|
|
166
|
+
* All Soulcraft products have fflate installed (Venue uses it for .sca archives,
|
|
167
|
+
* the registry uses it for .sck archives). If fflate is unavailable, the unpack
|
|
168
|
+
* fails with an actionable error message.
|
|
169
|
+
*
|
|
170
|
+
* @param buffer - The .sck archive as a Uint8Array.
|
|
171
|
+
* @param targetDir - Directory to extract into.
|
|
172
|
+
*/
|
|
173
|
+
async function _unpackArchive(buffer, targetDir) {
|
|
174
|
+
// Dynamic import avoids a hard dependency on fflate in the SDK package.json.
|
|
175
|
+
// The type assertion is safe because we only call unzipSync which is stable API.
|
|
176
|
+
let unzipSync;
|
|
177
|
+
try {
|
|
178
|
+
const fflate = await Function('return import("fflate")')();
|
|
179
|
+
unzipSync = fflate.unzipSync;
|
|
180
|
+
}
|
|
181
|
+
catch {
|
|
182
|
+
throw new Error('[sdk.kits] Cannot unpack .sck archive: fflate is not installed. ' +
|
|
183
|
+
'Run: bun add fflate (or npm install fflate)');
|
|
184
|
+
}
|
|
185
|
+
const files = unzipSync(buffer);
|
|
186
|
+
for (const [relPath, content] of Object.entries(files)) {
|
|
187
|
+
const fullPath = join(targetDir, relPath);
|
|
188
|
+
const dir = join(fullPath, '..');
|
|
189
|
+
mkdirSync(dir, { recursive: true });
|
|
190
|
+
writeFileSync(fullPath, content);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* @description Create a KitsModule backed by the Forge Kit Registry.
|
|
195
|
+
*
|
|
196
|
+
* Downloads .sck archives over HTTP, unpacks them to a local disk cache,
|
|
197
|
+
* and serves filesystem paths from the cache. Uses ETag-based revalidation
|
|
198
|
+
* to minimize bandwidth.
|
|
199
|
+
*
|
|
200
|
+
* @param registryUrl - Base URL of the registry (e.g. 'https://forge.soulcraft.com').
|
|
201
|
+
* @param cachePath - Absolute path to the local cache directory.
|
|
202
|
+
* @param cacheTtlMs - Cache freshness duration in milliseconds.
|
|
203
|
+
* @returns A KitsModule that fetches kits from the registry.
|
|
204
|
+
*/
|
|
205
|
+
function _createRegistryKitsModule(registryUrl, cachePath, cacheTtlMs) {
|
|
206
|
+
/** In-memory manifest cache — avoids disk reads on repeated calls. */
|
|
207
|
+
const memCache = new Map();
|
|
208
|
+
/** Strip trailing slash from registry URL for consistent URL building. */
|
|
209
|
+
const baseUrl = registryUrl.replace(/\/+$/, '');
|
|
210
|
+
mkdirSync(cachePath, { recursive: true });
|
|
211
|
+
/**
|
|
212
|
+
* @description Ensure a kit is available in the local cache.
|
|
213
|
+
*
|
|
214
|
+
* Cache flow:
|
|
215
|
+
* 1. Check in-memory cache → if within TTL, return immediately.
|
|
216
|
+
* 2. Check disk cache meta → if within TTL, load manifest from disk.
|
|
217
|
+
* 3. Send HEAD with If-None-Match → if 304, refresh TTL and return cached.
|
|
218
|
+
* 4. GET /api/kits/:id/archive → download, unpack, write cache meta.
|
|
219
|
+
*
|
|
220
|
+
* @param kitId - Kit identifier.
|
|
221
|
+
* @returns CachedKitEntry, or null if the kit doesn't exist.
|
|
222
|
+
*/
|
|
223
|
+
async function ensureCached(kitId) {
|
|
224
|
+
const now = Date.now();
|
|
225
|
+
// 1. In-memory cache hit within TTL
|
|
226
|
+
const mem = memCache.get(kitId);
|
|
227
|
+
if (mem && (now - mem.fetchedAt) < cacheTtlMs) {
|
|
228
|
+
return mem;
|
|
229
|
+
}
|
|
230
|
+
// 2. Disk cache hit within TTL
|
|
231
|
+
const diskMeta = _readCacheMeta(cachePath, kitId);
|
|
232
|
+
if (diskMeta && (now - new Date(diskMeta.fetchedAt).getTime()) < cacheTtlMs) {
|
|
233
|
+
const manifest = _readCachedManifest(cachePath, kitId);
|
|
234
|
+
if (manifest) {
|
|
235
|
+
const entry = {
|
|
236
|
+
manifest,
|
|
237
|
+
etag: diskMeta.etag,
|
|
238
|
+
localPath: join(cachePath, kitId),
|
|
239
|
+
fetchedAt: new Date(diskMeta.fetchedAt).getTime()
|
|
240
|
+
};
|
|
241
|
+
memCache.set(kitId, entry);
|
|
242
|
+
return entry;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
// 3. Revalidate with ETag (conditional GET on archive endpoint)
|
|
246
|
+
const existingEtag = diskMeta?.etag || mem?.etag || null;
|
|
247
|
+
try {
|
|
248
|
+
const archiveUrl = `${baseUrl}/api/kits/${encodeURIComponent(kitId)}/archive`;
|
|
249
|
+
const headers = {};
|
|
250
|
+
if (existingEtag) {
|
|
251
|
+
headers['If-None-Match'] = existingEtag;
|
|
252
|
+
}
|
|
253
|
+
const response = await fetch(archiveUrl, { headers });
|
|
254
|
+
// 304 Not Modified — cache is still valid
|
|
255
|
+
if (response.status === 304) {
|
|
256
|
+
const manifest = _readCachedManifest(cachePath, kitId) || mem?.manifest || null;
|
|
257
|
+
if (manifest) {
|
|
258
|
+
const entry = {
|
|
259
|
+
manifest,
|
|
260
|
+
etag: existingEtag,
|
|
261
|
+
localPath: join(cachePath, kitId),
|
|
262
|
+
fetchedAt: now
|
|
263
|
+
};
|
|
264
|
+
memCache.set(kitId, entry);
|
|
265
|
+
_writeCacheMeta(cachePath, kitId, {
|
|
266
|
+
etag: existingEtag,
|
|
267
|
+
fetchedAt: new Date(now).toISOString(),
|
|
268
|
+
version: manifest.version
|
|
269
|
+
});
|
|
270
|
+
return entry;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
// 404 — kit doesn't exist
|
|
274
|
+
if (response.status === 404) {
|
|
275
|
+
memCache.delete(kitId);
|
|
276
|
+
return null;
|
|
277
|
+
}
|
|
278
|
+
// 200 — download and unpack
|
|
279
|
+
if (response.ok) {
|
|
280
|
+
const buffer = new Uint8Array(await response.arrayBuffer());
|
|
281
|
+
const etag = response.headers.get('etag');
|
|
282
|
+
const kitDir = join(cachePath, kitId);
|
|
283
|
+
// Clear existing cache for this kit (preserve _cache-meta.json)
|
|
284
|
+
if (existsSync(kitDir)) {
|
|
285
|
+
rmSync(kitDir, { recursive: true, force: true });
|
|
286
|
+
}
|
|
287
|
+
await _unpackArchive(buffer, kitDir);
|
|
288
|
+
const manifest = _readCachedManifest(cachePath, kitId);
|
|
289
|
+
if (!manifest) {
|
|
290
|
+
console.error(`[sdk.kits] Downloaded archive for "${kitId}" has no kit.json`);
|
|
291
|
+
return null;
|
|
292
|
+
}
|
|
293
|
+
const entry = {
|
|
294
|
+
manifest,
|
|
295
|
+
etag,
|
|
296
|
+
localPath: kitDir,
|
|
297
|
+
fetchedAt: now
|
|
298
|
+
};
|
|
299
|
+
memCache.set(kitId, entry);
|
|
300
|
+
_writeCacheMeta(cachePath, kitId, {
|
|
301
|
+
etag,
|
|
302
|
+
fetchedAt: new Date(now).toISOString(),
|
|
303
|
+
version: manifest.version
|
|
304
|
+
});
|
|
305
|
+
return entry;
|
|
306
|
+
}
|
|
307
|
+
// Other errors — log and fall through to cached data
|
|
308
|
+
console.error(`[sdk.kits] Registry returned ${response.status} for "${kitId}"`);
|
|
309
|
+
}
|
|
310
|
+
catch (err) {
|
|
311
|
+
// Network error — use stale cache if available
|
|
312
|
+
console.error(`[sdk.kits] Failed to reach registry for "${kitId}":`, err);
|
|
313
|
+
}
|
|
314
|
+
// Stale cache fallback — return whatever we have
|
|
315
|
+
if (mem)
|
|
316
|
+
return mem;
|
|
317
|
+
const manifest = _readCachedManifest(cachePath, kitId);
|
|
318
|
+
if (manifest) {
|
|
319
|
+
const entry = {
|
|
320
|
+
manifest,
|
|
321
|
+
etag: diskMeta?.etag ?? null,
|
|
322
|
+
localPath: join(cachePath, kitId),
|
|
323
|
+
fetchedAt: diskMeta ? new Date(diskMeta.fetchedAt).getTime() : 0
|
|
324
|
+
};
|
|
325
|
+
memCache.set(kitId, entry);
|
|
326
|
+
return entry;
|
|
327
|
+
}
|
|
328
|
+
return null;
|
|
329
|
+
}
|
|
330
|
+
return {
|
|
331
|
+
async load(kitId) {
|
|
332
|
+
const entry = await ensureCached(kitId);
|
|
333
|
+
return entry?.manifest ?? null;
|
|
334
|
+
},
|
|
335
|
+
async list() {
|
|
336
|
+
try {
|
|
337
|
+
const response = await fetch(`${baseUrl}/api/kits`);
|
|
338
|
+
if (!response.ok)
|
|
339
|
+
return [];
|
|
340
|
+
const data = await response.json();
|
|
341
|
+
return data.kits ?? [];
|
|
342
|
+
}
|
|
343
|
+
catch {
|
|
344
|
+
// Offline fallback — read manifests from all cached kit directories
|
|
345
|
+
if (!existsSync(cachePath))
|
|
346
|
+
return [];
|
|
347
|
+
const dirs = readdirSync(cachePath, { withFileTypes: true })
|
|
348
|
+
.filter(d => d.isDirectory() && !d.name.startsWith('.') && !d.name.startsWith('_'));
|
|
349
|
+
const results = [];
|
|
350
|
+
for (const dir of dirs) {
|
|
351
|
+
const manifest = _readCachedManifest(cachePath, dir.name);
|
|
352
|
+
if (manifest)
|
|
353
|
+
results.push(manifest);
|
|
354
|
+
}
|
|
355
|
+
return results;
|
|
356
|
+
}
|
|
357
|
+
},
|
|
358
|
+
async resolveFilesPath(kitId, product) {
|
|
359
|
+
const entry = await ensureCached(kitId);
|
|
360
|
+
if (!entry)
|
|
361
|
+
return null;
|
|
362
|
+
const filesDir = join(entry.localPath, product, 'files');
|
|
363
|
+
return existsSync(filesDir) ? filesDir : null;
|
|
364
|
+
},
|
|
365
|
+
async resolveSkillsPath(kitId) {
|
|
366
|
+
const entry = await ensureCached(kitId);
|
|
367
|
+
if (!entry)
|
|
368
|
+
return null;
|
|
369
|
+
const skillsDir = join(entry.localPath, 'skills');
|
|
370
|
+
return existsSync(skillsDir) ? skillsDir : null;
|
|
371
|
+
},
|
|
372
|
+
async resolveKitsRoot() {
|
|
373
|
+
return cachePath;
|
|
374
|
+
},
|
|
375
|
+
};
|
|
376
|
+
}
|
|
377
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
378
|
+
// Public factory
|
|
379
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
380
|
+
/**
|
|
381
|
+
* Create the `sdk.kits.*` module.
|
|
382
|
+
*
|
|
383
|
+
* The mode is determined by the options:
|
|
384
|
+
* - `bundledRegistry` set → static in-memory registry (for tests)
|
|
385
|
+
* - `registryUrl` set → HTTP-based registry mode (production)
|
|
386
|
+
* - Neither set → legacy bundled mode via `@soulcraft/kits` package
|
|
387
|
+
*
|
|
388
|
+
* @param options - Configuration for the kits module.
|
|
389
|
+
* @returns A `KitsModule` instance.
|
|
390
|
+
*
|
|
391
|
+
* @example Registry mode (production)
|
|
392
|
+
* ```typescript
|
|
393
|
+
* const kits = createKitsModule({
|
|
394
|
+
* registryUrl: 'https://forge.soulcraft.com',
|
|
395
|
+
* cachePath: '/home/app/.soulcraft/kits-cache',
|
|
396
|
+
* })
|
|
397
|
+
* ```
|
|
398
|
+
*
|
|
399
|
+
* @example Bundled mode (legacy — no options needed)
|
|
400
|
+
* ```typescript
|
|
401
|
+
* const kits = createKitsModule()
|
|
402
|
+
* ```
|
|
403
|
+
*
|
|
404
|
+
* @example Test mode — inject mock kits
|
|
405
|
+
* ```typescript
|
|
406
|
+
* const kits = createKitsModule({
|
|
407
|
+
* bundledRegistry: {
|
|
408
|
+
* 'test-kit': { id: 'test-kit', name: 'Test Kit', version: '1.0.0', ... }
|
|
409
|
+
* }
|
|
410
|
+
* })
|
|
411
|
+
* ```
|
|
412
|
+
*/
|
|
413
|
+
export function createKitsModule(options = {}) {
|
|
414
|
+
// Test mode — static in-memory registry takes highest precedence
|
|
415
|
+
if (options.bundledRegistry !== undefined) {
|
|
416
|
+
const getRegistry = () => options.bundledRegistry ?? null;
|
|
417
|
+
return _createBundledKitsModule(getRegistry);
|
|
418
|
+
}
|
|
419
|
+
// Registry mode — fetch from Forge Kit Registry over HTTP
|
|
420
|
+
if (options.registryUrl) {
|
|
421
|
+
const cachePath = options.cachePath
|
|
422
|
+
? resolve(options.cachePath)
|
|
423
|
+
: DEFAULT_CACHE_PATH;
|
|
424
|
+
const cacheTtlMs = options.cacheTtlMs ?? DEFAULT_CACHE_TTL_MS;
|
|
425
|
+
return _createRegistryKitsModule(options.registryUrl, cachePath, cacheTtlMs);
|
|
426
|
+
}
|
|
427
|
+
// Bundled mode (legacy) — load from @soulcraft/kits npm package
|
|
428
|
+
return _createBundledKitsModule(_getBundledRegistry);
|
|
429
|
+
}
|
|
106
430
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/modules/kits/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/modules/kits/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AACjG,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAQjC,gFAAgF;AAChF,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kits
|
|
6
|
-
* and
|
|
7
|
-
* workflow. They contain no TypeScript logic, no server
|
|
5
|
+
* Kits are pure configuration packages: `kit.json` manifests, `SKILL.md` prompt
|
|
6
|
+
* files, template files, and optional station bundles that describe a domain,
|
|
7
|
+
* persona, glossary, and workflow. They contain no TypeScript logic, no server
|
|
8
|
+
* code, and no SDK imports.
|
|
8
9
|
*
|
|
9
|
-
* The `KitsModule` provides read-only access to the kit registry
|
|
10
|
-
*
|
|
10
|
+
* The `KitsModule` provides read-only access to the kit registry. It supports
|
|
11
|
+
* two backing stores:
|
|
12
|
+
*
|
|
13
|
+
* 1. **Registry mode** — when `registryUrl` is provided, kits are fetched from
|
|
14
|
+
* the Forge Kit Registry (`forge.soulcraft.com`) over HTTP. Archives (.sck)
|
|
15
|
+
* are unpacked to a local disk cache for filesystem access. ETag-based cache
|
|
16
|
+
* validation avoids re-downloading unchanged kits.
|
|
17
|
+
*
|
|
18
|
+
* 2. **Bundled mode** (legacy) — when no `registryUrl` is provided, kits are
|
|
19
|
+
* loaded from the `@soulcraft/kits` npm package via `createRequire()`. This
|
|
20
|
+
* is the backwards-compatible fallback used during migration.
|
|
11
21
|
*
|
|
12
22
|
* Kit initialization (populating a workspace's Brainy and VFS from a kit's
|
|
13
23
|
* `starterFiles`) is a product-level concern and lives in each product's
|
|
@@ -49,14 +59,94 @@ export interface SoulcraftKitConfig {
|
|
|
49
59
|
[key: string]: unknown;
|
|
50
60
|
}
|
|
51
61
|
/**
|
|
52
|
-
*
|
|
53
|
-
*
|
|
62
|
+
* Internal cache entry for a kit fetched from the registry.
|
|
63
|
+
* Stored in-memory with its ETag for conditional revalidation.
|
|
64
|
+
*/
|
|
65
|
+
export interface CachedKitEntry {
|
|
66
|
+
/** Parsed kit.json manifest. */
|
|
67
|
+
manifest: SoulcraftKitConfig;
|
|
68
|
+
/** ETag from the registry for conditional requests (If-None-Match). */
|
|
69
|
+
etag: string | null;
|
|
70
|
+
/** Absolute path to the unpacked kit directory on local disk. */
|
|
71
|
+
localPath: string;
|
|
72
|
+
/** Timestamp (ms) when this entry was last fetched or validated. */
|
|
73
|
+
fetchedAt: number;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Options for `createKitsModule()`.
|
|
77
|
+
*
|
|
78
|
+
* Two modes of operation:
|
|
79
|
+
*
|
|
80
|
+
* **Registry mode** — set `registryUrl` to fetch kits from the Forge Kit Registry.
|
|
81
|
+
* The SDK downloads `.sck` archives, unpacks them to `cachePath`, and serves
|
|
82
|
+
* filesystem paths from the local cache. ETag-based revalidation avoids
|
|
83
|
+
* re-downloading unchanged kits.
|
|
84
|
+
*
|
|
85
|
+
* **Bundled mode** (legacy) — omit `registryUrl` to load kits from the
|
|
86
|
+
* `@soulcraft/kits` npm package. This is the backwards-compatible default
|
|
87
|
+
* used during migration. Set `bundledRegistry` to inject a mock registry
|
|
88
|
+
* for testing.
|
|
89
|
+
*
|
|
90
|
+
* @example Registry mode (production)
|
|
91
|
+
* ```typescript
|
|
92
|
+
* const kits = createKitsModule({
|
|
93
|
+
* registryUrl: 'https://forge.soulcraft.com',
|
|
94
|
+
* cachePath: '/home/app/.soulcraft/kits-cache',
|
|
95
|
+
* })
|
|
96
|
+
* ```
|
|
97
|
+
*
|
|
98
|
+
* @example Bundled mode (legacy)
|
|
99
|
+
* ```typescript
|
|
100
|
+
* const kits = createKitsModule() // uses @soulcraft/kits if installed
|
|
101
|
+
* ```
|
|
102
|
+
*
|
|
103
|
+
* @example Test mode
|
|
104
|
+
* ```typescript
|
|
105
|
+
* const kits = createKitsModule({
|
|
106
|
+
* bundledRegistry: { 'test-kit': { id: 'test-kit', name: 'Test', ... } }
|
|
107
|
+
* })
|
|
108
|
+
* ```
|
|
54
109
|
*/
|
|
55
110
|
export interface CreateKitsModuleOptions {
|
|
56
111
|
/**
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
* the
|
|
112
|
+
* Base URL of the Forge Kit Registry (e.g. `'https://forge.soulcraft.com'`).
|
|
113
|
+
*
|
|
114
|
+
* When set, the module operates in **registry mode**: kits are fetched over
|
|
115
|
+
* HTTP, cached locally as unpacked `.sck` archives, and revalidated via ETags.
|
|
116
|
+
* The `@soulcraft/kits` npm package is not needed.
|
|
117
|
+
*
|
|
118
|
+
* When omitted, the module falls back to **bundled mode** using the
|
|
119
|
+
* `@soulcraft/kits` package.
|
|
120
|
+
*/
|
|
121
|
+
registryUrl?: string;
|
|
122
|
+
/**
|
|
123
|
+
* Absolute path to the local disk cache for unpacked kit archives.
|
|
124
|
+
*
|
|
125
|
+
* Defaults to `~/.soulcraft/kits-cache` when `registryUrl` is set.
|
|
126
|
+
* Each kit is stored at `{cachePath}/{kitId}/` with its full directory tree.
|
|
127
|
+
*
|
|
128
|
+
* **Important:** This path must NOT be inside a Brainy data directory to
|
|
129
|
+
* avoid interfering with entity storage and indexing.
|
|
130
|
+
*/
|
|
131
|
+
cachePath?: string;
|
|
132
|
+
/**
|
|
133
|
+
* Cache freshness duration in milliseconds.
|
|
134
|
+
*
|
|
135
|
+
* When a kit is loaded, the SDK checks if the cached copy is younger than
|
|
136
|
+
* this TTL. If so, it returns the cached manifest without a network request.
|
|
137
|
+
* When the TTL expires, the SDK sends an `If-None-Match` request — if the
|
|
138
|
+
* registry returns 304, the cache is refreshed without re-downloading.
|
|
139
|
+
*
|
|
140
|
+
* Defaults to `300_000` (5 minutes).
|
|
141
|
+
*/
|
|
142
|
+
cacheTtlMs?: number;
|
|
143
|
+
/**
|
|
144
|
+
* Override the kit registry with a static in-memory map. Used in tests to
|
|
145
|
+
* avoid both the registry and the `@soulcraft/kits` package.
|
|
146
|
+
*
|
|
147
|
+
* Set to `null` to simulate no kits being available.
|
|
148
|
+
*
|
|
149
|
+
* **Note:** When `bundledRegistry` is set, `registryUrl` is ignored.
|
|
60
150
|
*/
|
|
61
151
|
bundledRegistry?: Record<string, SoulcraftKitConfig> | null;
|
|
62
152
|
}
|
|
@@ -64,10 +154,14 @@ export interface CreateKitsModuleOptions {
|
|
|
64
154
|
* The `sdk.kits.*` namespace — read-only access to the Soulcraft kit registry
|
|
65
155
|
* and template file paths.
|
|
66
156
|
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
157
|
+
* In **registry mode** (recommended), kits are fetched from the Forge Kit
|
|
158
|
+
* Registry at `forge.soulcraft.com`, cached locally, and served from disk.
|
|
159
|
+
* In **bundled mode** (legacy), kits are loaded from the `@soulcraft/kits`
|
|
160
|
+
* npm package.
|
|
161
|
+
*
|
|
162
|
+
* The interface is identical in both modes — callers don't know or care
|
|
163
|
+
* where kits come from. The `registryUrl` option in `createKitsModule()`
|
|
164
|
+
* controls the backing store.
|
|
71
165
|
*
|
|
72
166
|
* @example Load a kit and run AI with its persona
|
|
73
167
|
* ```typescript
|
|
@@ -83,14 +177,17 @@ export interface CreateKitsModuleOptions {
|
|
|
83
177
|
* @example Locate kit template files on disk
|
|
84
178
|
* ```typescript
|
|
85
179
|
* const dir = await sdk.kits.resolveFilesPath('blog-series', 'workshop')
|
|
86
|
-
* //
|
|
180
|
+
* // Registry mode: '~/.soulcraft/kits-cache/blog-series/workshop/files'
|
|
181
|
+
* // Bundled mode: '/path/to/node_modules/@soulcraft/kits/kits/blog-series/workshop/files'
|
|
87
182
|
* ```
|
|
88
183
|
*/
|
|
89
184
|
export interface KitsModule {
|
|
90
185
|
/**
|
|
91
186
|
* Load a single kit configuration by ID.
|
|
92
187
|
*
|
|
93
|
-
*
|
|
188
|
+
* In registry mode, this fetches the manifest from the registry (or returns
|
|
189
|
+
* a cached copy if within the TTL). In bundled mode, it reads from the
|
|
190
|
+
* `@soulcraft/kits` package.
|
|
94
191
|
*
|
|
95
192
|
* @param kitId - The kit identifier (e.g. `'wicks-and-whiskers'`).
|
|
96
193
|
* @returns The kit configuration, or `null` if not found.
|
|
@@ -105,69 +202,67 @@ export interface KitsModule {
|
|
|
105
202
|
/**
|
|
106
203
|
* List all available kits from the registry.
|
|
107
204
|
*
|
|
108
|
-
*
|
|
205
|
+
* In registry mode, this fetches the full kit listing from the registry.
|
|
206
|
+
* In bundled mode, it returns all kits from the `@soulcraft/kits` package.
|
|
109
207
|
*
|
|
110
208
|
* @returns All kit configurations as an array.
|
|
111
209
|
*
|
|
112
210
|
* @example
|
|
113
211
|
* ```typescript
|
|
114
212
|
* const kits = await sdk.kits.list()
|
|
115
|
-
* console.log(kits.
|
|
213
|
+
* console.log(`${kits.length} kits available`)
|
|
116
214
|
* ```
|
|
117
215
|
*/
|
|
118
216
|
list(): Promise<SoulcraftKitConfig[]>;
|
|
119
217
|
/**
|
|
120
218
|
* Resolve the absolute path to a kit's product-specific template files directory.
|
|
121
219
|
*
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
220
|
+
* In registry mode, the path points into the local cache at
|
|
221
|
+
* `{cachePath}/{kitId}/{product}/files/`. The kit is downloaded and unpacked
|
|
222
|
+
* if not already cached. In bundled mode, the path points into the npm package.
|
|
125
223
|
*
|
|
126
|
-
*
|
|
127
|
-
* Use it instead of hard-coding `node_modules` paths or maintaining per-product
|
|
128
|
-
* filesystem layouts.
|
|
224
|
+
* Returns `null` if the kit is not found or the files directory doesn't exist.
|
|
129
225
|
*
|
|
130
|
-
* @param kitId - Kit identifier (e.g. `'blog-series'
|
|
226
|
+
* @param kitId - Kit identifier (e.g. `'blog-series'`).
|
|
131
227
|
* @param product - Product consuming the files: `'workshop'` or `'venue'`.
|
|
132
|
-
* @returns Absolute path to the files directory, or `null` if
|
|
228
|
+
* @returns Absolute path to the files directory, or `null` if not found.
|
|
133
229
|
*
|
|
134
230
|
* @example
|
|
135
231
|
* ```typescript
|
|
136
232
|
* const dir = await sdk.kits.resolveFilesPath('blog-series', 'workshop')
|
|
137
|
-
* // → '
|
|
233
|
+
* // → '~/.soulcraft/kits-cache/blog-series/workshop/files'
|
|
138
234
|
* ```
|
|
139
235
|
*/
|
|
140
236
|
resolveFilesPath(kitId: string, product: 'workshop' | 'venue'): Promise<string | null>;
|
|
141
237
|
/**
|
|
142
238
|
* Resolve the absolute path to a kit's skills directory.
|
|
143
239
|
*
|
|
144
|
-
*
|
|
145
|
-
*
|
|
240
|
+
* In registry mode, the path points into the local cache at
|
|
241
|
+
* `{cachePath}/{kitId}/skills/`. In bundled mode, the path points into
|
|
242
|
+
* the npm package.
|
|
146
243
|
*
|
|
147
244
|
* @param kitId - Kit identifier.
|
|
148
|
-
* @returns Absolute path to the skills directory, or `null` if
|
|
245
|
+
* @returns Absolute path to the skills directory, or `null` if not found.
|
|
149
246
|
*
|
|
150
247
|
* @example
|
|
151
248
|
* ```typescript
|
|
152
249
|
* const dir = await sdk.kits.resolveSkillsPath('blog-series')
|
|
153
|
-
* // → '
|
|
250
|
+
* // → '~/.soulcraft/kits-cache/blog-series/skills'
|
|
154
251
|
* ```
|
|
155
252
|
*/
|
|
156
253
|
resolveSkillsPath(kitId: string): Promise<string | null>;
|
|
157
254
|
/**
|
|
158
|
-
* Resolve the absolute path to the root
|
|
159
|
-
*
|
|
160
|
-
* Useful when enumerating all available kits on the filesystem rather than relying
|
|
161
|
-
* on the `kitRegistry` in-memory list (e.g. build tooling, validators).
|
|
255
|
+
* Resolve the absolute path to the root kits cache or package directory.
|
|
162
256
|
*
|
|
163
|
-
*
|
|
257
|
+
* In registry mode, returns the `cachePath` directory. In bundled mode,
|
|
258
|
+
* returns the `kits/` directory inside the npm package.
|
|
164
259
|
*
|
|
165
|
-
* @returns Absolute path to the
|
|
260
|
+
* @returns Absolute path to the kits root, or `null` if unavailable.
|
|
166
261
|
*
|
|
167
262
|
* @example
|
|
168
263
|
* ```typescript
|
|
169
264
|
* const root = await sdk.kits.resolveKitsRoot()
|
|
170
|
-
* // → '
|
|
265
|
+
* // → '~/.soulcraft/kits-cache'
|
|
171
266
|
* ```
|
|
172
267
|
*/
|
|
173
268
|
resolveKitsRoot(): Promise<string | null>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/modules/kits/types.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/modules/kits/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAMH;;;;;;;GAOG;AACH,MAAM,WAAW,kBAAkB;IACjC,qFAAqF;IACrF,EAAE,EAAE,MAAM,CAAA;IACV,+BAA+B;IAC/B,IAAI,EAAE,MAAM,CAAA;IACZ,wDAAwD;IACxD,WAAW,EAAE,MAAM,CAAA;IACnB,gDAAgD;IAChD,OAAO,EAAE,MAAM,CAAA;IACf,6BAA6B;IAC7B,IAAI,EAAE,OAAO,GAAG,SAAS,GAAG,KAAK,GAAG,SAAS,GAAG,WAAW,CAAA;IAC3D,0CAA0C;IAC1C,MAAM,CAAC,EAAE;QACP,gCAAgC;QAChC,SAAS,CAAC,EAAE,MAAM,CAAA;QAClB,+CAA+C;QAC/C,WAAW,CAAC,EAAE,KAAK,CAAC;YAAE,KAAK,EAAE,MAAM,CAAC;YAAC,MAAM,EAAE,MAAM,CAAA;SAAE,CAAC,CAAA;KACvD,CAAA;IACD,wDAAwD;IACxD,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CACvB;AAMD;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,gCAAgC;IAChC,QAAQ,EAAE,kBAAkB,CAAA;IAC5B,uEAAuE;IACvE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IACnB,iEAAiE;IACjE,SAAS,EAAE,MAAM,CAAA;IACjB,oEAAoE;IACpE,SAAS,EAAE,MAAM,CAAA;CAClB;AAMD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAM,WAAW,uBAAuB;IACtC;;;;;;;;;OASG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IAEpB;;;;;;;;OAQG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB;;;;;;;;;OASG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;IAEnB;;;;;;;OAOG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,GAAG,IAAI,CAAA;CAC5D;AAMD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,WAAW,UAAU;IACzB;;;;;;;;;;;;;;;OAeG;IACH,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC,CAAA;IAEvD;;;;;;;;;;;;;OAaG;IACH,IAAI,IAAI,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAAA;IAErC;;;;;;;;;;;;;;;;;;OAkBG;IACH,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,GAAG,OAAO,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAA;IAEtF;;;;;;;;;;;;;;;OAeG;IACH,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAA;IAExD;;;;;;;;;;;;;OAaG;IACH,eAAe,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAA;CAC1C"}
|
|
@@ -2,12 +2,22 @@
|
|
|
2
2
|
* @module kits/types
|
|
3
3
|
* @description Type definitions for sdk.kits.* — the kit loader and registry module.
|
|
4
4
|
*
|
|
5
|
-
* Kits
|
|
6
|
-
* and
|
|
7
|
-
* workflow. They contain no TypeScript logic, no server
|
|
5
|
+
* Kits are pure configuration packages: `kit.json` manifests, `SKILL.md` prompt
|
|
6
|
+
* files, template files, and optional station bundles that describe a domain,
|
|
7
|
+
* persona, glossary, and workflow. They contain no TypeScript logic, no server
|
|
8
|
+
* code, and no SDK imports.
|
|
8
9
|
*
|
|
9
|
-
* The `KitsModule` provides read-only access to the kit registry
|
|
10
|
-
*
|
|
10
|
+
* The `KitsModule` provides read-only access to the kit registry. It supports
|
|
11
|
+
* two backing stores:
|
|
12
|
+
*
|
|
13
|
+
* 1. **Registry mode** — when `registryUrl` is provided, kits are fetched from
|
|
14
|
+
* the Forge Kit Registry (`forge.soulcraft.com`) over HTTP. Archives (.sck)
|
|
15
|
+
* are unpacked to a local disk cache for filesystem access. ETag-based cache
|
|
16
|
+
* validation avoids re-downloading unchanged kits.
|
|
17
|
+
*
|
|
18
|
+
* 2. **Bundled mode** (legacy) — when no `registryUrl` is provided, kits are
|
|
19
|
+
* loaded from the `@soulcraft/kits` npm package via `createRequire()`. This
|
|
20
|
+
* is the backwards-compatible fallback used during migration.
|
|
11
21
|
*
|
|
12
22
|
* Kit initialization (populating a workspace's Brainy and VFS from a kit's
|
|
13
23
|
* `starterFiles`) is a product-level concern and lives in each product's
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/modules/kits/types.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/modules/kits/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG"}
|