@happyvertical/smrt-core 0.55.10 → 0.55.11

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.
Files changed (78) hide show
  1. package/AGENTS.md +2 -0
  2. package/agents/build-knowledge.md +40 -0
  3. package/agents/cookbook-engine.md +102 -0
  4. package/agents/cookbook.md +63 -0
  5. package/dist/consumer-plugin/artifact-publication.js +3 -3
  6. package/dist/consumer-plugin/artifact-publication.js.map +1 -1
  7. package/dist/consumer-plugin/hosted-sti-collections.d.ts +10 -0
  8. package/dist/consumer-plugin/hosted-sti-collections.d.ts.map +1 -0
  9. package/dist/consumer-plugin/hosted-sti-collections.js +92 -0
  10. package/dist/consumer-plugin/hosted-sti-collections.js.map +1 -0
  11. package/dist/consumer-plugin/index.d.ts +1 -1
  12. package/dist/consumer-plugin/index.d.ts.map +1 -1
  13. package/dist/consumer-plugin/index.js +76 -51
  14. package/dist/consumer-plugin/index.js.map +1 -1
  15. package/dist/cookbook/engine/commands.d.ts +37 -0
  16. package/dist/cookbook/engine/commands.d.ts.map +1 -0
  17. package/dist/cookbook/engine/commands.js +275 -0
  18. package/dist/cookbook/engine/commands.js.map +1 -0
  19. package/dist/cookbook/engine/defaults.d.ts +10 -0
  20. package/dist/cookbook/engine/defaults.d.ts.map +1 -0
  21. package/dist/cookbook/engine/defaults.js +49 -0
  22. package/dist/cookbook/engine/defaults.js.map +1 -0
  23. package/dist/cookbook/engine/document.d.ts +66 -0
  24. package/dist/cookbook/engine/document.d.ts.map +1 -0
  25. package/dist/cookbook/engine/document.js +357 -0
  26. package/dist/cookbook/engine/document.js.map +1 -0
  27. package/dist/cookbook/engine/engine.d.ts +49 -0
  28. package/dist/cookbook/engine/engine.d.ts.map +1 -0
  29. package/dist/cookbook/engine/engine.js +399 -0
  30. package/dist/cookbook/engine/engine.js.map +1 -0
  31. package/dist/cookbook/engine/index.d.ts +14 -0
  32. package/dist/cookbook/engine/index.d.ts.map +1 -0
  33. package/dist/cookbook/engine/index.js +8 -0
  34. package/dist/cookbook/engine/nav.d.ts +45 -0
  35. package/dist/cookbook/engine/nav.d.ts.map +1 -0
  36. package/dist/cookbook/engine/nav.js +191 -0
  37. package/dist/cookbook/engine/nav.js.map +1 -0
  38. package/dist/cookbook/engine/schemas.d.ts +29 -0
  39. package/dist/cookbook/engine/schemas.d.ts.map +1 -0
  40. package/dist/cookbook/engine/schemas.js +363 -0
  41. package/dist/cookbook/engine/schemas.js.map +1 -0
  42. package/dist/cookbook/engine/types.d.ts +331 -0
  43. package/dist/cookbook/engine/types.d.ts.map +1 -0
  44. package/dist/cookbook/engine/types.js +10 -0
  45. package/dist/cookbook/engine/types.js.map +1 -0
  46. package/dist/cookbook/engine.d.ts +2 -0
  47. package/dist/cookbook/engine.d.ts.map +1 -0
  48. package/dist/cookbook/engine.js +9 -0
  49. package/dist/cookbook/index.d.ts +6 -0
  50. package/dist/cookbook/index.d.ts.map +1 -0
  51. package/dist/cookbook/v1.schema.json +131 -0
  52. package/dist/cookbook/validate.d.ts +37 -0
  53. package/dist/cookbook/validate.d.ts.map +1 -0
  54. package/dist/cookbook/validate.js +172 -0
  55. package/dist/cookbook/validate.js.map +1 -0
  56. package/dist/cookbook.d.ts +7 -0
  57. package/dist/cookbook.d.ts.map +1 -0
  58. package/dist/cookbook.js +2 -0
  59. package/dist/manifest/static-manifest.js +1 -1
  60. package/dist/manifest/static-manifest.js.map +1 -1
  61. package/dist/manifest/store.js +1 -1
  62. package/dist/manifest.json +1 -1
  63. package/dist/prebuild/index.js +13 -13
  64. package/dist/prebuild/index.js.map +1 -1
  65. package/dist/smrt-knowledge.json +23 -7
  66. package/dist/vite-plugin/web-collections.d.ts +5 -0
  67. package/dist/vite-plugin/web-collections.d.ts.map +1 -1
  68. package/dist/vite-plugin/web-collections.js +1 -1
  69. package/dist/vite-plugin/web-collections.js.map +1 -1
  70. package/dist/vite-preset/cookbook-exposure.d.ts +11 -0
  71. package/dist/vite-preset/cookbook-exposure.d.ts.map +1 -0
  72. package/dist/vite-preset/cookbook-exposure.js +95 -0
  73. package/dist/vite-preset/cookbook-exposure.js.map +1 -0
  74. package/dist/vite-preset/index.d.ts +9 -0
  75. package/dist/vite-preset/index.d.ts.map +1 -1
  76. package/dist/vite-preset/index.js +17 -7
  77. package/dist/vite-preset/index.js.map +1 -1
  78. package/package.json +18 -6
@@ -10,8 +10,9 @@ import { loadVerifiedSmrtGenerationSnapshot, serializeSmrtGenerationSnapshot, sh
10
10
  import { generateClientModule } from "../vite-plugin/generated-client.js";
11
11
  import { activeProducerKnowledgeRoutePaths, activeSvelteKitRouteParticipants, assertNoSvelteKitRouteRootSymlinkConflict, assertSvelteKitRouteCoordinationComplete, contributeSvelteKitRoutes, expectedSvelteKitRouteOwners, markSvelteKitRouteParticipant, producerKnowledgeRoutePaths, revokeSvelteKitRoutes } from "../vite-plugin/sveltekit-route-coordinator.js";
12
12
  import { generateDeclarations } from "../prebuild/index.js";
13
- import * as path from "node:path";
14
- import * as fs from "node:fs";
13
+ import { separateHostedStiCollections } from "./hosted-sti-collections.js";
14
+ import * as path$1 from "node:path";
15
+ import * as fs$1 from "node:fs";
15
16
  //#region src/consumer-plugin/index.ts
16
17
  /**
17
18
  * Vite plugin for consuming SMRT packages
@@ -28,21 +29,21 @@ var VIRTUAL_MODULES = {
28
29
  var CONSUMER_SVELTEKIT_ROUTES_ARTIFACT_VERSION = 1;
29
30
  var CONSUMER_SVELTEKIT_ROUTES_ARTIFACT = "consumer-sveltekit-routes.json";
30
31
  function consumerSvelteKitRoutesArtifactPath(projectRoot) {
31
- return path.join(projectRoot, ".smrt", CONSUMER_SVELTEKIT_ROUTES_ARTIFACT);
32
+ return path$1.join(projectRoot, ".smrt", CONSUMER_SVELTEKIT_ROUTES_ARTIFACT);
32
33
  }
33
34
  /** Persist only project-relative consumer route roots, never an output file list. */
34
35
  function canonicalConsumerRouteRoot(projectRoot, routesDir) {
35
- const root = path.resolve(projectRoot);
36
- const relative = path.relative(root, path.resolve(root, routesDir));
37
- if (!relative || relative === ".." || relative.startsWith(`..${path.sep}`) || path.isAbsolute(relative)) throw new Error(`[smrt:consumer] svelteKit.routesDir must be a project-relative subdirectory (received ${JSON.stringify(routesDir)})`);
38
- return relative.split(path.sep).join("/");
36
+ const root = path$1.resolve(projectRoot);
37
+ const relative = path$1.relative(root, path$1.resolve(root, routesDir));
38
+ if (!relative || relative === ".." || relative.startsWith(`..${path$1.sep}`) || path$1.isAbsolute(relative)) throw new Error(`[smrt:consumer] svelteKit.routesDir must be a project-relative subdirectory (received ${JSON.stringify(routesDir)})`);
39
+ return relative.split(path$1.sep).join("/");
39
40
  }
40
41
  function loadConsumerSvelteKitRouteRoots(projectRoot) {
41
42
  const artifactPath = consumerSvelteKitRoutesArtifactPath(projectRoot);
42
- if (!fs.existsSync(artifactPath)) return [];
43
+ if (!fs$1.existsSync(artifactPath)) return [];
43
44
  let parsed;
44
45
  try {
45
- parsed = JSON.parse(fs.readFileSync(artifactPath, "utf-8"));
46
+ parsed = JSON.parse(fs$1.readFileSync(artifactPath, "utf-8"));
46
47
  } catch {
47
48
  throw new Error(`[smrt:consumer] Cannot read ${CONSUMER_SVELTEKIT_ROUTES_ARTIFACT}; refusing to leave hosted routes unreconciled`);
48
49
  }
@@ -51,7 +52,7 @@ function loadConsumerSvelteKitRouteRoots(projectRoot) {
51
52
  }
52
53
  function publishConsumerSvelteKitRouteRoots(projectRoot, routesDir) {
53
54
  const artifactPath = consumerSvelteKitRoutesArtifactPath(projectRoot);
54
- fs.mkdirSync(path.dirname(artifactPath), { recursive: true });
55
+ fs$1.mkdirSync(path$1.dirname(artifactPath), { recursive: true });
55
56
  publishArtifactFiles([{
56
57
  path: artifactPath,
57
58
  content: JSON.stringify({
@@ -62,7 +63,7 @@ function publishConsumerSvelteKitRouteRoots(projectRoot, routesDir) {
62
63
  }
63
64
  function removeConsumerSvelteKitRouteRoots(projectRoot) {
64
65
  const artifactPath = consumerSvelteKitRoutesArtifactPath(projectRoot);
65
- if (fs.existsSync(artifactPath)) fs.unlinkSync(artifactPath);
66
+ if (fs$1.existsSync(artifactPath)) fs$1.unlinkSync(artifactPath);
66
67
  }
67
68
  /**
68
69
  * A hosting-to-hosting move can replace one configured root with another in a
@@ -73,7 +74,7 @@ function removeConsumerSvelteKitRouteRoots(projectRoot) {
73
74
  async function assertConsumerSvelteKitFormerRouteRootsAreSafe(userConfig, projectRoot, routesDir, env) {
74
75
  if (routesDir.length === 0) return;
75
76
  const activeRoots = (await activeSvelteKitRouteParticipants(userConfig, projectRoot, env)).map((participant) => participant.routesDir);
76
- for (const priorRoutesDir of routesDir) assertNoSvelteKitRouteRootSymlinkConflict(canonicalSvelteKitPath(path.resolve(projectRoot, priorRoutesDir)), activeRoots);
77
+ for (const priorRoutesDir of routesDir) assertNoSvelteKitRouteRootSymlinkConflict(canonicalSvelteKitPath(path$1.resolve(projectRoot, priorRoutesDir)), activeRoots);
77
78
  }
78
79
  async function reconcileConsumerSvelteKitRouteRoots(lifecycle, userConfig, projectRoot, routesDir, afterReconciled, env) {
79
80
  const remaining = new Set(routesDir);
@@ -86,14 +87,14 @@ async function reconcileConsumerSvelteKitRouteRoots(lifecycle, userConfig, proje
86
87
  return;
87
88
  }
88
89
  for (const routesDir of [...remaining]) {
89
- const routeRoot = canonicalSvelteKitPath(path.resolve(projectRoot, routesDir));
90
+ const routeRoot = canonicalSvelteKitPath(path$1.resolve(projectRoot, routesDir));
90
91
  const activeParticipants = await activeSvelteKitRouteParticipants(userConfig, projectRoot, env);
91
92
  assertNoSvelteKitRouteRootSymlinkConflict(routeRoot, activeParticipants.map((participant) => participant.routesDir));
92
- if (activeParticipants.find((participant) => participant.owner === "consumer" && (routeRoot === participant.routesDir || routeRoot.startsWith(`${participant.routesDir}${path.sep}`)))) {
93
+ if (activeParticipants.find((participant) => participant.owner === "consumer" && (routeRoot === participant.routesDir || routeRoot.startsWith(`${participant.routesDir}${path$1.sep}`)))) {
93
94
  reconcileOne(routesDir);
94
95
  continue;
95
96
  }
96
- const containingProducer = activeParticipants.find((participant) => participant.owner === "producer" && (routeRoot === participant.routesDir || routeRoot.startsWith(`${participant.routesDir}${path.sep}`)));
97
+ const containingProducer = activeParticipants.find((participant) => participant.owner === "producer" && (routeRoot === participant.routesDir || routeRoot.startsWith(`${participant.routesDir}${path$1.sep}`)));
97
98
  if (containingProducer) {
98
99
  await revokeSvelteKitRoutes(lifecycle, await expectedSvelteKitRouteOwners(userConfig, containingProducer.projectRoot, containingProducer.routesDir, env), containingProducer.projectRoot, containingProducer.routesDir, () => reconcileOne(routesDir));
99
100
  continue;
@@ -147,6 +148,7 @@ function selectConsumerRouteManifest(manifest, options) {
147
148
  };
148
149
  }
149
150
  const sourceManifest = manifest;
151
+ const collectionBySlot = /* @__PURE__ */ new Map();
150
152
  for (const [manifestKey, objectDef] of Object.entries(manifest.objects)) {
151
153
  const candidate = objectDef;
152
154
  if (!isCollectionManifestClass(sourceManifest, candidate)) continue;
@@ -155,7 +157,19 @@ function selectConsumerRouteManifest(manifest, options) {
155
157
  const itemRef = itemEntry ? consumerObjectRef(itemEntry[0], itemEntry[1]) : void 0;
156
158
  if (!itemRef || !selected.has(itemRef)) continue;
157
159
  const collectionRef = consumerObjectRef(manifestKey, objectDef);
158
- if (collectionRef) objects[collectionRef] = {
160
+ if (!collectionRef) continue;
161
+ const slot = `${itemRef}\0${candidate.collection}`;
162
+ const rival = collectionBySlot.get(slot);
163
+ if (rival) {
164
+ const conventional = `${item?.className}Collection`;
165
+ if (candidate.className !== conventional || rival.className === conventional) continue;
166
+ delete objects[rival.ref];
167
+ }
168
+ collectionBySlot.set(slot, {
169
+ ref: collectionRef,
170
+ className: candidate.className
171
+ });
172
+ objects[collectionRef] = {
159
173
  ...objectDef,
160
174
  qualifiedName: collectionRef
161
175
  };
@@ -180,7 +194,18 @@ function smrtConsumer(options = {}) {
180
194
  let routeLifecycleConfig;
181
195
  function loadGenerationSnapshot() {
182
196
  if (!generationSnapshot) throw new Error("[smrt:consumer] Generation snapshot is not configured");
183
- return loadVerifiedSmrtGenerationSnapshot(generationSnapshot, projectRoot, "dependencies");
197
+ return withHostedStiCollections(loadVerifiedSmrtGenerationSnapshot(generationSnapshot, projectRoot, "dependencies"));
198
+ }
199
+ /**
200
+ * Hosted STI subclasses get their own route collection (#3749), in every
201
+ * manifest view the plugin derives, so routes, the generated client, the
202
+ * `@smrt/web` definitions and the registration agree on the endpoint.
203
+ */
204
+ function withHostedStiCollections(manifest) {
205
+ return consumerSvelteKit ? separateHostedStiCollections(manifest, consumerSvelteKit.objects, (key, def) => consumerObjectRef(key, def)) : manifest;
206
+ }
207
+ async function aggregateHosted(...args) {
208
+ return withHostedStiCollections(await aggregateTypeManifests(...args));
184
209
  }
185
210
  /**
186
211
  * Resolve the packages to aggregate, and whether that list was asserted by
@@ -203,7 +228,7 @@ function smrtConsumer(options = {}) {
203
228
  else if (generationSnapshot) typeManifest = loadGenerationSnapshot();
204
229
  else {
205
230
  const resolved = await resolveConsumerPackages();
206
- typeManifest = await aggregateTypeManifests(resolved.names, projectRoot, { explicit: resolved.explicit });
231
+ typeManifest = await aggregateHosted(resolved.names, projectRoot, { explicit: resolved.explicit });
207
232
  }
208
233
  await generateProjectTypes(typeManifest, typesDir, projectRoot);
209
234
  typesGenerated = true;
@@ -220,14 +245,14 @@ function smrtConsumer(options = {}) {
220
245
  if (consumerSvelteKit) {
221
246
  await assertConsumerSvelteKitFormerRouteRootsAreSafe(userConfig, projectRoot, previousConsumerRouteRoots, env);
222
247
  const routePackages = await resolveConsumerPackages();
223
- const routeManifest = generationSnapshot ? loadGenerationSnapshot() : await aggregateTypeManifests(routePackages.names, projectRoot, { explicit: routePackages.explicit });
248
+ const routeManifest = generationSnapshot ? loadGenerationSnapshot() : await aggregateHosted(routePackages.names, projectRoot, { explicit: routePackages.explicit });
224
249
  const hostedManifest = selectConsumerRouteManifest(routeManifest, consumerSvelteKit);
225
250
  const routesDir = canonicalConsumerRouteRoot(projectRoot, consumerSvelteKit.routesDir ?? "src/routes/api");
226
251
  const reservedRoutePaths = await activeProducerKnowledgeRoutePaths(userConfig, projectRoot, env);
227
252
  const routeOptions = {
228
253
  enabled: true,
229
254
  routesDir,
230
- objectsDir: "src/lib/objects",
255
+ objectsDir: consumerSvelteKit.objectsDir ?? "src/lib/objects",
231
256
  configPath: consumerSvelteKit.configPath ?? "src/lib/server",
232
257
  configFileName: consumerSvelteKit.configFileName ?? "smrt.ts",
233
258
  kebabRoutes: effectiveKebabRoutes,
@@ -286,7 +311,7 @@ function smrtConsumer(options = {}) {
286
311
  smrtPackages = resolvedPackages.names;
287
312
  if (smrtPackages.length > 0) {
288
313
  console.log(`[smrt:consumer] Found SMRT packages: ${smrtPackages.join(", ")}`);
289
- typeManifest = await aggregateTypeManifests(smrtPackages, projectRoot, { explicit: resolvedPackages.explicit });
314
+ typeManifest = await aggregateHosted(smrtPackages, projectRoot, { explicit: resolvedPackages.explicit });
290
315
  const agentSurface = producerApi ? await producerApi.resolveKnowledgeAgentSurface() : void 0;
291
316
  await saveAggregatedManifest(typeManifest, projectRoot, producerApi?.resolveKnowledgeConfig, agentSurface);
292
317
  await generateRegistrationFile(typeManifest, projectRoot);
@@ -307,8 +332,8 @@ function smrtConsumer(options = {}) {
307
332
  if (id in VIRTUAL_MODULES) {
308
333
  if (id !== "@smrt/types") return `\0${VIRTUAL_MODULES[id]}`;
309
334
  const typeFileName = getTypeFileName(id);
310
- const typePath = path.join(projectRoot, typesDir, typeFileName);
311
- if (fs.existsSync(typePath)) return typePath;
335
+ const typePath = path$1.join(projectRoot, typesDir, typeFileName);
336
+ if (fs$1.existsSync(typePath)) return typePath;
312
337
  return `\0${VIRTUAL_MODULES[id]}`;
313
338
  }
314
339
  return null;
@@ -347,12 +372,12 @@ function smrtConsumer(options = {}) {
347
372
  */
348
373
  async function discoverSmrtPackages(projectRoot) {
349
374
  const packages = [];
350
- const nodeModulesPath = path.join(projectRoot, "node_modules");
351
- if (!fs.existsSync(nodeModulesPath)) return packages;
375
+ const nodeModulesPath = path$1.join(projectRoot, "node_modules");
376
+ if (!fs$1.existsSync(nodeModulesPath)) return packages;
352
377
  try {
353
- const packageJsonPath = path.join(projectRoot, "package.json");
354
- if (fs.existsSync(packageJsonPath)) {
355
- const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf-8"));
378
+ const packageJsonPath = path$1.join(projectRoot, "package.json");
379
+ if (fs$1.existsSync(packageJsonPath)) {
380
+ const packageJson = JSON.parse(fs$1.readFileSync(packageJsonPath, "utf-8"));
356
381
  const allDeps = {
357
382
  ...packageJson.dependencies,
358
383
  ...packageJson.devDependencies,
@@ -376,14 +401,14 @@ async function discoverSmrtPackages(projectRoot) {
376
401
  * packages that ship a manifest without exporting a subpath for it.
377
402
  */
378
403
  function legacyStaticManifestPath(packageDir) {
379
- return path.join(packageDir, "dist", "manifest", "static-manifest.js");
404
+ return path$1.join(packageDir, "dist", "manifest", "static-manifest.js");
380
405
  }
381
406
  function packageManifestCandidates(packageDir, packageJson) {
382
407
  return [
383
408
  ...manifestExportCandidates(packageDir, packageJson),
384
409
  legacyStaticManifestPath(packageDir),
385
- path.join(packageDir, "dist", "manifest.json"),
386
- path.join(packageDir, "manifest.json")
410
+ path$1.join(packageDir, "dist", "manifest.json"),
411
+ path$1.join(packageDir, "manifest.json")
387
412
  ];
388
413
  }
389
414
  /**
@@ -406,16 +431,16 @@ function packageManifestCandidates(packageDir, packageJson) {
406
431
  * location counts — exactly the probe this function used before #2923.
407
432
  */
408
433
  async function hasSmrtManifest(nodeModulesPath, packageName) {
409
- const packagePath = path.join(nodeModulesPath, packageName);
434
+ const packagePath = path$1.join(nodeModulesPath, packageName);
410
435
  const legacyStaticManifest = legacyStaticManifestPath(packagePath);
411
436
  for (const manifestPath of packageManifestCandidates(packagePath)) {
412
- if (!fs.existsSync(manifestPath)) continue;
437
+ if (!fs$1.existsSync(manifestPath)) continue;
413
438
  if (!manifestPath.endsWith(".json")) {
414
439
  if (manifestPath === legacyStaticManifest) return true;
415
440
  continue;
416
441
  }
417
442
  try {
418
- if (JSON.parse(fs.readFileSync(manifestPath, "utf-8"))?.moduleType === "smrt") return true;
443
+ if (JSON.parse(fs$1.readFileSync(manifestPath, "utf-8"))?.moduleType === "smrt") return true;
419
444
  } catch {}
420
445
  }
421
446
  return false;
@@ -445,11 +470,11 @@ async function aggregateTypeManifests(packages, projectRoot, options = {}) {
445
470
  for (const packageName of packages) {
446
471
  let loadedManifest = false;
447
472
  try {
448
- const packageDir = path.join(projectRoot, "node_modules", packageName);
449
- const packageJsonPath = path.join(packageDir, "package.json");
473
+ const packageDir = path$1.join(projectRoot, "node_modules", packageName);
474
+ const packageJsonPath = path$1.join(packageDir, "package.json");
450
475
  let packageJson;
451
476
  try {
452
- const packageJsonContent = fs.readFileSync(packageJsonPath, "utf-8");
477
+ const packageJsonContent = fs$1.readFileSync(packageJsonPath, "utf-8");
453
478
  packageJson = JSON.parse(packageJsonContent);
454
479
  } catch {
455
480
  console.warn(`[smrt:consumer] Could not read package.json for ${packageName}`);
@@ -457,14 +482,14 @@ async function aggregateTypeManifests(packages, projectRoot, options = {}) {
457
482
  continue;
458
483
  }
459
484
  const manifestCandidates = packageManifestCandidates(packageDir, packageJson);
460
- for (const manifestPath of manifestCandidates) if (fs.existsSync(manifestPath)) {
485
+ for (const manifestPath of manifestCandidates) if (fs$1.existsSync(manifestPath)) {
461
486
  let manifest;
462
487
  try {
463
488
  if (manifestPath.endsWith(".js")) {
464
489
  const manifestModule = await import(manifestPath);
465
490
  manifest = manifestModule.staticManifest || manifestModule.default;
466
491
  } else {
467
- const manifestContent = fs.readFileSync(manifestPath, "utf-8");
492
+ const manifestContent = fs$1.readFileSync(manifestPath, "utf-8");
468
493
  manifest = JSON.parse(manifestContent);
469
494
  }
470
495
  } catch (error) {
@@ -535,13 +560,13 @@ function determineImportPath(packageJson) {
535
560
  * the file (including the top-level `packageName` the local write sets).
536
561
  */
537
562
  async function saveAggregatedManifest(manifest, projectRoot, resolveKnowledgeConfig, agentSurface) {
538
- const smrtDir = path.join(projectRoot, ".smrt");
539
- const manifestPath = path.join(smrtDir, "manifest.json");
563
+ const smrtDir = path$1.join(projectRoot, ".smrt");
564
+ const manifestPath = path$1.join(smrtDir, "manifest.json");
540
565
  try {
541
- if (!fs.existsSync(smrtDir)) fs.mkdirSync(smrtDir, { recursive: true });
566
+ if (!fs$1.existsSync(smrtDir)) fs$1.mkdirSync(smrtDir, { recursive: true });
542
567
  let merged = manifest;
543
- if (fs.existsSync(manifestPath)) try {
544
- const existing = JSON.parse(fs.readFileSync(manifestPath, "utf-8"));
568
+ if (fs$1.existsSync(manifestPath)) try {
569
+ const existing = JSON.parse(fs$1.readFileSync(manifestPath, "utf-8"));
545
570
  if (existing && typeof existing.objects === "object") merged = {
546
571
  ...existing,
547
572
  ...manifest,
@@ -552,9 +577,9 @@ async function saveAggregatedManifest(manifest, projectRoot, resolveKnowledgeCon
552
577
  }
553
578
  };
554
579
  } catch {}
555
- const knowledgePath = path.join(smrtDir, "smrt-knowledge.json");
556
- const packageJsonPath = path.join(projectRoot, "package.json");
557
- const packageJson = fs.existsSync(packageJsonPath) ? JSON.parse(fs.readFileSync(packageJsonPath, "utf-8")) : void 0;
580
+ const knowledgePath = path$1.join(smrtDir, "smrt-knowledge.json");
581
+ const packageJsonPath = path$1.join(projectRoot, "package.json");
582
+ const packageJson = fs$1.existsSync(packageJsonPath) ? JSON.parse(fs$1.readFileSync(packageJsonPath, "utf-8")) : void 0;
558
583
  const knowledgeConfig = resolveKnowledgeConfig ? await resolveKnowledgeConfig(merged) : await resolveFileKnowledgeConfig(projectRoot, merged.packageName ?? packageJson?.name);
559
584
  if (knowledgeConfig.enabled === false) {
560
585
  publishArtifactFiles([{
@@ -590,8 +615,8 @@ async function saveAggregatedManifest(manifest, projectRoot, resolveKnowledgeCon
590
615
  * for all external SMRT objects discovered during build.
591
616
  */
592
617
  async function generateRegistrationFile(manifest, projectRoot) {
593
- const smrtDir = path.join(projectRoot, ".smrt");
594
- const registerPath = path.join(smrtDir, "register.js");
618
+ const smrtDir = path$1.join(projectRoot, ".smrt");
619
+ const registerPath = path$1.join(smrtDir, "register.js");
595
620
  const importBindings = /* @__PURE__ */ new Map();
596
621
  const importsByPath = /* @__PURE__ */ new Map();
597
622
  let nextImportBinding = 0;
@@ -706,8 +731,8 @@ export function registerAll() {
706
731
  console.log('[smrt:register] Registered ${registeredObjectCount} external ${registeredObjectLabel}');
707
732
  }
708
733
  `;
709
- if (!fs.existsSync(smrtDir)) fs.mkdirSync(smrtDir, { recursive: true });
710
- fs.writeFileSync(registerPath, content, "utf-8");
734
+ if (!fs$1.existsSync(smrtDir)) fs$1.mkdirSync(smrtDir, { recursive: true });
735
+ fs$1.writeFileSync(registerPath, content, "utf-8");
711
736
  console.log(`[smrt:consumer] Generated .smrt/register.js with ${importedEntryCount} external entries (${registeredObjectCount} registered ${registeredObjectLabel})`);
712
737
  }
713
738
  /**