@pattern-stack/codegen 0.14.0 → 0.14.1

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 (30) hide show
  1. package/dist/runtime/subsystems/bridge/bridge-delivery.memory-backend.d.ts +1 -1
  2. package/dist/runtime/subsystems/bridge/bridge-delivery.memory-backend.js +2 -2
  3. package/dist/runtime/subsystems/bridge/bridge-delivery.memory-backend.js.map +1 -1
  4. package/dist/runtime/subsystems/bridge/bridge.module.js +172 -159
  5. package/dist/runtime/subsystems/bridge/bridge.module.js.map +1 -1
  6. package/dist/runtime/subsystems/bridge/index.js +154 -141
  7. package/dist/runtime/subsystems/bridge/index.js.map +1 -1
  8. package/dist/runtime/subsystems/index.js +161 -148
  9. package/dist/runtime/subsystems/index.js.map +1 -1
  10. package/dist/runtime/subsystems/jobs/index.js +128 -115
  11. package/dist/runtime/subsystems/jobs/index.js.map +1 -1
  12. package/dist/runtime/subsystems/jobs/job-orchestrator.memory-backend.js +128 -6
  13. package/dist/runtime/subsystems/jobs/job-orchestrator.memory-backend.js.map +1 -1
  14. package/dist/runtime/subsystems/jobs/job-run-service.memory-backend.js +17 -0
  15. package/dist/runtime/subsystems/jobs/job-run-service.memory-backend.js.map +1 -1
  16. package/dist/runtime/subsystems/jobs/job-step-service.memory-backend.js +25 -2
  17. package/dist/runtime/subsystems/jobs/job-step-service.memory-backend.js.map +1 -1
  18. package/dist/runtime/subsystems/jobs/job-worker.module.d.ts +26 -1
  19. package/dist/runtime/subsystems/jobs/job-worker.module.js +150 -137
  20. package/dist/runtime/subsystems/jobs/job-worker.module.js.map +1 -1
  21. package/dist/runtime/subsystems/jobs/jobs-domain.module.js +133 -124
  22. package/dist/runtime/subsystems/jobs/jobs-domain.module.js.map +1 -1
  23. package/dist/src/cli/index.js +804 -454
  24. package/dist/src/cli/index.js.map +1 -1
  25. package/package.json +1 -1
  26. package/runtime/subsystems/bridge/bridge-delivery.memory-backend.ts +8 -1
  27. package/runtime/subsystems/jobs/job-orchestrator.memory-backend.ts +8 -3
  28. package/runtime/subsystems/jobs/job-run-service.memory-backend.ts +4 -1
  29. package/runtime/subsystems/jobs/job-step-service.memory-backend.ts +7 -2
  30. package/runtime/subsystems/jobs/job-worker.module.ts +13 -1
@@ -1073,8 +1073,8 @@ var icons = {
1073
1073
  };
1074
1074
 
1075
1075
  // src/cli/commands/entity.ts
1076
- import fs9 from "fs";
1077
- import path13 from "path";
1076
+ import fs10 from "fs";
1077
+ import path14 from "path";
1078
1078
  import { Command as Command2, Option as Option2 } from "clipanion";
1079
1079
 
1080
1080
  // src/utils/yaml-loader.ts
@@ -3082,8 +3082,8 @@ function loadEntityFromYaml(filePath) {
3082
3082
  }
3083
3083
  function formatZodErrors(error) {
3084
3084
  return error.errors.map((err) => {
3085
- const path34 = err.path.join(".");
3086
- const location = path34 ? `at '${path34}'` : "at root";
3085
+ const path36 = err.path.join(".");
3086
+ const location = path36 ? `at '${path36}'` : "at root";
3087
3087
  return `${err.message} ${location}`;
3088
3088
  });
3089
3089
  }
@@ -3684,8 +3684,8 @@ function collectEntitySurfaces(entities) {
3684
3684
  return surfaces;
3685
3685
  }
3686
3686
  function resolveImportRef(ref, opts) {
3687
- const { path: path34, exportName } = parseImportRef(ref);
3688
- const file = resolveModuleFile(path34, opts);
3687
+ const { path: path36, exportName } = parseImportRef(ref);
3688
+ const file = resolveModuleFile(path36, opts);
3689
3689
  if (!file) {
3690
3690
  return { status: "module-not-found", resolvedFrom: opts.sourceRoot };
3691
3691
  }
@@ -3905,19 +3905,19 @@ function findCircularDependencies(graph) {
3905
3905
  const cycles = [];
3906
3906
  const visited = /* @__PURE__ */ new Set();
3907
3907
  const recursionStack = /* @__PURE__ */ new Set();
3908
- function dfs(node, path34) {
3908
+ function dfs(node, path36) {
3909
3909
  visited.add(node);
3910
3910
  recursionStack.add(node);
3911
3911
  const outgoingEdges = graph.edges.filter((e) => e.from === node);
3912
3912
  for (const edge of outgoingEdges) {
3913
3913
  if (!visited.has(edge.to)) {
3914
- dfs(edge.to, [...path34, edge.to]);
3914
+ dfs(edge.to, [...path36, edge.to]);
3915
3915
  } else if (recursionStack.has(edge.to)) {
3916
- const cycleStart = path34.indexOf(edge.to);
3916
+ const cycleStart = path36.indexOf(edge.to);
3917
3917
  if (cycleStart !== -1) {
3918
- cycles.push([...path34.slice(cycleStart), edge.to]);
3918
+ cycles.push([...path36.slice(cycleStart), edge.to]);
3919
3919
  } else {
3920
- cycles.push([...path34, edge.to]);
3920
+ cycles.push([...path36, edge.to]);
3921
3921
  }
3922
3922
  }
3923
3923
  }
@@ -4514,8 +4514,8 @@ function suggestTransitiveRelationships(graph, options) {
4514
4514
  for (const [entityName, entity] of graph.entities) {
4515
4515
  if (shouldExcludeEntity(entityName, opts)) continue;
4516
4516
  const paths = findTransitivePaths(graph, entityName, opts);
4517
- for (const path34 of paths) {
4518
- suggestions.push(createSuggestion(path34));
4517
+ for (const path36 of paths) {
4518
+ suggestions.push(createSuggestion(path36));
4519
4519
  }
4520
4520
  }
4521
4521
  return suggestions;
@@ -4546,7 +4546,7 @@ function findTransitivePaths(graph, sourceEntity, opts) {
4546
4546
  while (queue.length > 0) {
4547
4547
  const current = queue.shift();
4548
4548
  if (!current) continue;
4549
- const { entity, depth, path: path34, visited } = current;
4549
+ const { entity, depth, path: path36, visited } = current;
4550
4550
  if (depth >= opts.maxDepth) continue;
4551
4551
  const currentEntity = graph.entities.get(entity);
4552
4552
  if (!currentEntity) continue;
@@ -4557,7 +4557,7 @@ function findTransitivePaths(graph, sourceEntity, opts) {
4557
4557
  if (shouldExcludeEntity(target, opts)) continue;
4558
4558
  if (visited.has(target)) continue;
4559
4559
  const newPath = [
4560
- ...path34,
4560
+ ...path36,
4561
4561
  {
4562
4562
  via: entity,
4563
4563
  relationship: relName,
@@ -4625,15 +4625,15 @@ function generateYamlSnippet(name, target, throughPath) {
4625
4625
  target: ${target}
4626
4626
  through: "${throughPath}"`;
4627
4627
  }
4628
- function createSuggestion(path34) {
4629
- const pathDescription = [path34.source, ...path34.hops.map((h) => h.via), path34.target].join(" -> ");
4628
+ function createSuggestion(path36) {
4629
+ const pathDescription = [path36.source, ...path36.hops.map((h) => h.via), path36.target].join(" -> ");
4630
4630
  return {
4631
4631
  severity: "info",
4632
4632
  type: "transitive_suggestion",
4633
- entity: path34.source,
4633
+ entity: path36.source,
4634
4634
  message: `Potential transitive relationship: ${pathDescription}`,
4635
- suggestion: `Add "${path34.suggestedName}" relationship via "${path34.throughPath}"`,
4636
- path: path34
4635
+ suggestion: `Add "${path36.suggestedName}" relationship via "${path36.throughPath}"`,
4636
+ path: path36
4637
4637
  };
4638
4638
  }
4639
4639
 
@@ -6279,6 +6279,24 @@ import path8 from "path";
6279
6279
  // src/cli/shared/subsystem-detect.ts
6280
6280
  import fs4 from "fs";
6281
6281
  import path6 from "path";
6282
+
6283
+ // src/cli/shared/runtime-import.ts
6284
+ var PACKAGE = "@pattern-stack/codegen";
6285
+ function resolveRuntimeMode(config) {
6286
+ return config?.runtime === "vendored" ? "vendored" : "package";
6287
+ }
6288
+ function subsystemsImport(mode, subsystem) {
6289
+ if (mode === "vendored") {
6290
+ return subsystem ? `@shared/subsystems/${subsystem}` : "@shared/subsystems";
6291
+ }
6292
+ return `${PACKAGE}/subsystems`;
6293
+ }
6294
+ function runtimeImport(mode, relpath) {
6295
+ const clean = relpath.replace(/^\/+/, "");
6296
+ return mode === "vendored" ? `@shared/${clean}` : `${PACKAGE}/runtime/${clean}`;
6297
+ }
6298
+
6299
+ // src/cli/shared/subsystem-detect.ts
6282
6300
  var SUBSYSTEMS = [
6283
6301
  {
6284
6302
  name: "events",
@@ -6475,6 +6493,36 @@ async function detectInstalledSubsystems(ctx) {
6475
6493
  const states = await detectSubsystemStatesImpl(ctx);
6476
6494
  return states.filter((s) => s.status === "installed");
6477
6495
  }
6496
+ function configuredSubsystemNames(config) {
6497
+ const subsystems = config?.subsystems;
6498
+ const raw = subsystems?.install;
6499
+ if (!Array.isArray(raw)) return [];
6500
+ const known = new Set(KNOWN_NAMES);
6501
+ const seen = /* @__PURE__ */ new Set();
6502
+ const out = [];
6503
+ for (const entry of raw) {
6504
+ if (typeof entry !== "string") continue;
6505
+ if (!known.has(entry)) continue;
6506
+ const name = entry;
6507
+ if (seen.has(name)) continue;
6508
+ seen.add(name);
6509
+ out.push(name);
6510
+ }
6511
+ return out;
6512
+ }
6513
+ function configuredInstalledSubsystems(config) {
6514
+ return configuredSubsystemNames(config).map((name) => {
6515
+ const desc3 = SUBSYSTEMS.find((s) => s.name === name);
6516
+ const cfg = config?.[name];
6517
+ const backend = typeof cfg?.backend === "string" ? cfg.backend : desc3?.defaultBackend ?? "drizzle";
6518
+ return {
6519
+ name,
6520
+ path: `@pattern-stack/codegen/subsystems#${name}`,
6521
+ backend,
6522
+ status: "installed"
6523
+ };
6524
+ });
6525
+ }
6478
6526
 
6479
6527
  // src/cli/shared/subsystems-path.ts
6480
6528
  import path7 from "path";
@@ -6523,55 +6571,55 @@ function quoteBullmqDomainOpts(input) {
6523
6571
  return `{ ${parts.join(", ")} }`;
6524
6572
  }
6525
6573
  var COMPOSERS = {
6526
- events: ({ subsystemsRel, cfg }) => {
6574
+ events: ({ moduleImport, cfg }) => {
6527
6575
  const backend = cfg?.backend ?? "drizzle";
6528
6576
  const multiTenant = Boolean(cfg?.multi_tenant);
6529
6577
  return {
6530
6578
  imports: [
6531
- `import { EventsModule } from '${subsystemsRel}/events/events.module';`
6579
+ `import { EventsModule } from '${moduleImport("events", "events.module")}';`
6532
6580
  ],
6533
6581
  calls: [
6534
6582
  ` EventsModule.forRoot(${quoteOpts({ backend, multiTenant })}),`
6535
6583
  ]
6536
6584
  };
6537
6585
  },
6538
- jobs: ({ subsystemsRel, cfg }) => {
6586
+ jobs: ({ moduleImport, cfg }) => {
6539
6587
  const backend = cfg?.backend ?? "drizzle";
6540
6588
  const multiTenant = Boolean(cfg?.multi_tenant);
6541
6589
  const workerMode = (cfg?.worker_mode ?? "standalone").trim();
6542
6590
  const imports = [
6543
- `import { JobsDomainModule } from '${subsystemsRel}/jobs/jobs-domain.module';`
6591
+ `import { JobsDomainModule } from '${moduleImport("jobs", "jobs-domain.module")}';`
6544
6592
  ];
6545
6593
  const bullExt = backend === "bullmq" ? cfg?.extensions?.bullmq : void 0;
6546
6594
  const domainOpts = quoteBullmqDomainOpts({ backend, multiTenant, bullExt });
6547
6595
  const calls = [` JobsDomainModule.forRoot(${domainOpts}),`];
6548
6596
  if (workerMode === "embedded") {
6549
6597
  imports.push(
6550
- `import { JobWorkerModule } from '${subsystemsRel}/jobs/job-worker.module';`
6598
+ `import { JobWorkerModule } from '${moduleImport("jobs", "job-worker.module")}';`
6551
6599
  );
6552
6600
  const workerOpts = backend === "bullmq" ? `{ mode: 'embedded', backend: 'bullmq'${bullExt ? `, domainModuleExtensions: { bullmq: ${jsonToTs(bullExt)} }` : ""} }` : `{ mode: 'embedded' }`;
6553
6601
  calls.push(` JobWorkerModule.forRoot(${workerOpts}),`);
6554
6602
  }
6555
6603
  return { imports, calls };
6556
6604
  },
6557
- bridge: ({ subsystemsRel, cfg }) => {
6605
+ bridge: ({ moduleImport, cfg }) => {
6558
6606
  const backend = cfg?.backend ?? "drizzle";
6559
6607
  const multiTenant = Boolean(cfg?.multi_tenant);
6560
6608
  return {
6561
6609
  imports: [
6562
- `import { BridgeModule } from '${subsystemsRel}/bridge/bridge.module';`
6610
+ `import { BridgeModule } from '${moduleImport("bridge", "bridge.module")}';`
6563
6611
  ],
6564
6612
  calls: [
6565
6613
  ` BridgeModule.forRoot(${quoteOpts({ backend, multiTenant })}),`
6566
6614
  ]
6567
6615
  };
6568
6616
  },
6569
- integration: ({ subsystemsRel, cfg }) => {
6617
+ integration: ({ moduleImport, cfg }) => {
6570
6618
  const backend = cfg?.backend ?? "drizzle";
6571
6619
  const multiTenant = Boolean(cfg?.multi_tenant);
6572
6620
  return {
6573
6621
  imports: [
6574
- `import { IntegrationModule } from '${subsystemsRel}/integration/integration.module';`
6622
+ `import { IntegrationModule } from '${moduleImport("integration", "integration.module")}';`
6575
6623
  ],
6576
6624
  calls: [
6577
6625
  ` IntegrationModule.forRoot(${quoteOpts({ backend, multiTenant })}),`
@@ -6579,6 +6627,13 @@ var COMPOSERS = {
6579
6627
  };
6580
6628
  }
6581
6629
  };
6630
+ var PACKAGE2 = "@pattern-stack/codegen";
6631
+ function makeModuleImport(mode, subsystemsRel) {
6632
+ if (mode === "vendored") {
6633
+ return (subsystem, moduleBasename) => `${subsystemsRel}/${subsystem}/${moduleBasename}`;
6634
+ }
6635
+ return (subsystem) => subsystem === "events" ? `${PACKAGE2}/subsystems` : `${PACKAGE2}/runtime/subsystems/${subsystem}/index`;
6636
+ }
6582
6637
  var COMPOSABLE_ORDER = ["events", "jobs", "bridge", "integration"];
6583
6638
  var HEADER3 = `// AUTO-GENERATED by @pattern-stack/codegen. DO NOT EDIT.
6584
6639
  // Subsystem composition barrel \u2014 reflects \`subsystems.install\` in
@@ -6593,7 +6648,8 @@ var HEADER3 = `// AUTO-GENERATED by @pattern-stack/codegen. DO NOT EDIT.
6593
6648
  // Regenerated by every \`codegen entity new\` / \`codegen subsystem install\`.
6594
6649
 
6595
6650
  `;
6596
- function buildSubsystemBarrel(installed, config, subsystemsRel) {
6651
+ function buildSubsystemBarrel(installed, config, subsystemsRel, mode = "vendored") {
6652
+ const moduleImport = makeModuleImport(mode, subsystemsRel);
6597
6653
  const actable = installed.filter((i) => i.status !== "incomplete");
6598
6654
  const installedNames = new Set(actable.map((i) => i.name));
6599
6655
  const emitted = [];
@@ -6608,7 +6664,7 @@ function buildSubsystemBarrel(installed, config, subsystemsRel) {
6608
6664
  continue;
6609
6665
  }
6610
6666
  const cfg = config?.[name] ?? void 0;
6611
- const out = composer({ subsystemsRel, cfg });
6667
+ const out = composer({ moduleImport, cfg });
6612
6668
  allImports.push(...out.imports);
6613
6669
  allCalls.push(...out.calls);
6614
6670
  emitted.push(name);
@@ -6629,7 +6685,10 @@ ${allCalls.join("\n")}
6629
6685
  async function regenerateSubsystemBarrel(opts) {
6630
6686
  const { ctx, dryRun = false } = opts;
6631
6687
  const generatedDir = opts.generatedDir ?? resolveGeneratedDir(ctx);
6632
- const installed = await detectInstalledSubsystems(ctx);
6688
+ const mode = resolveRuntimeMode(ctx.config);
6689
+ const installed = mode === "package" ? configuredInstalledSubsystems(
6690
+ ctx.config
6691
+ ) : await detectInstalledSubsystems(ctx);
6633
6692
  const subsystemsAbs = resolveSubsystemsRoot(ctx);
6634
6693
  const barrelAbs = path8.resolve(generatedDir, "subsystems.ts");
6635
6694
  let subsystemsRel = path8.relative(path8.dirname(barrelAbs), subsystemsAbs).split(path8.sep).join("/");
@@ -6637,7 +6696,8 @@ async function regenerateSubsystemBarrel(opts) {
6637
6696
  const { content, emitted, skipped } = buildSubsystemBarrel(
6638
6697
  installed,
6639
6698
  ctx.config,
6640
- subsystemsRel
6699
+ subsystemsRel,
6700
+ mode
6641
6701
  );
6642
6702
  let written = false;
6643
6703
  if (!dryRun) {
@@ -6654,11 +6714,101 @@ async function regenerateSubsystemBarrel(opts) {
6654
6714
  };
6655
6715
  }
6656
6716
 
6657
- // src/cli/shared/bridge-registry-generator.ts
6717
+ // src/cli/shared/subsystem-schema-generator.ts
6658
6718
  import fs6 from "fs";
6659
6719
  import path9 from "path";
6660
- import ts2 from "typescript";
6720
+ var PACKAGE3 = "@pattern-stack/codegen";
6721
+ var SCHEMA_SYMBOLS = {
6722
+ events: ["domainEvents"],
6723
+ jobs: [
6724
+ "jobs",
6725
+ "jobRuns",
6726
+ "jobSteps",
6727
+ "jobRunStatusEnum",
6728
+ "jobStepKindEnum",
6729
+ "jobStepStatusEnum",
6730
+ "collisionModeEnum",
6731
+ "replayFromEnum",
6732
+ "parentClosePolicyEnum",
6733
+ "waitKindEnum",
6734
+ "triggerSourceEnum"
6735
+ ],
6736
+ bridge: ["bridgeDelivery", "bridgeDeliveryStatusEnum"],
6737
+ integration: [
6738
+ "integrationSubscriptions",
6739
+ "integrationRuns",
6740
+ "integrationRunItems",
6741
+ "integrationRunDirectionEnum",
6742
+ "integrationRunActionEnum",
6743
+ "integrationRunStatusEnum",
6744
+ "integrationRunItemOperationEnum",
6745
+ "integrationRunItemStatusEnum"
6746
+ ]
6747
+ };
6748
+ var SCHEMA_ORDER = ["events", "jobs", "bridge", "integration"];
6661
6749
  var HEADER4 = `// AUTO-GENERATED by @pattern-stack/codegen. Do not edit.
6750
+ // Subsystem Drizzle schema barrel \u2014 re-exports the tables + pgEnums of every
6751
+ // installed subsystem so drizzle-kit emits their CREATE TABLE / CREATE TYPE.
6752
+ //
6753
+ // Fold into your drizzle-kit schema entrypoint once, alongside the entity
6754
+ // schema barrel:
6755
+ //
6756
+ // // src/schema.ts
6757
+ // export * from './generated/schema'; // entity tables
6758
+ // export * from './generated/subsystems-schema'; // subsystem tables + enums
6759
+ //
6760
+ // Regenerated by every \`codegen entity new\` / \`codegen subsystem install\`.
6761
+
6762
+ `;
6763
+ function schemaImportFor(mode, subsystem, subsystemsRel) {
6764
+ return mode === "vendored" ? `${subsystemsRel}/${subsystem}` : `${PACKAGE3}/runtime/subsystems/${subsystem}/index`;
6765
+ }
6766
+ function buildSubsystemSchemaBarrel(installed, subsystemsRel, mode) {
6767
+ const actable = installed.filter((i) => i.status !== "incomplete");
6768
+ const installedNames = new Set(actable.map((i) => i.name));
6769
+ const emitted = [];
6770
+ const lines = [];
6771
+ for (const name of SCHEMA_ORDER) {
6772
+ if (!installedNames.has(name)) continue;
6773
+ const symbols = SCHEMA_SYMBOLS[name];
6774
+ if (!symbols || symbols.length === 0) continue;
6775
+ const importSpec = schemaImportFor(mode, name, subsystemsRel);
6776
+ lines.push(`export { ${symbols.join(", ")} } from '${importSpec}';`);
6777
+ emitted.push(name);
6778
+ }
6779
+ const body = lines.length === 0 ? "export {};\n" : lines.join("\n") + "\n";
6780
+ return { content: HEADER4 + body, emitted };
6781
+ }
6782
+ async function regenerateSubsystemSchemaBarrel(opts) {
6783
+ const { ctx, dryRun = false } = opts;
6784
+ const generatedDir = opts.generatedDir ?? resolveGeneratedDir(ctx);
6785
+ const mode = resolveRuntimeMode(ctx.config);
6786
+ const installed = mode === "package" ? configuredInstalledSubsystems(
6787
+ ctx.config
6788
+ ) : await detectInstalledSubsystems(ctx);
6789
+ const subsystemsAbs = resolveSubsystemsRoot(ctx);
6790
+ const barrelAbs = path9.resolve(generatedDir, "subsystems-schema.ts");
6791
+ let subsystemsRel = path9.relative(path9.dirname(barrelAbs), subsystemsAbs).split(path9.sep).join("/");
6792
+ if (!subsystemsRel.startsWith(".")) subsystemsRel = "./" + subsystemsRel;
6793
+ const { content, emitted } = buildSubsystemSchemaBarrel(
6794
+ installed,
6795
+ subsystemsRel,
6796
+ mode
6797
+ );
6798
+ let written = false;
6799
+ if (!dryRun) {
6800
+ fs6.mkdirSync(path9.dirname(barrelAbs), { recursive: true });
6801
+ fs6.writeFileSync(barrelAbs, content);
6802
+ written = true;
6803
+ }
6804
+ return { schemaBarrel: barrelAbs, emitted, content, written };
6805
+ }
6806
+
6807
+ // src/cli/shared/bridge-registry-generator.ts
6808
+ import fs7 from "fs";
6809
+ import path10 from "path";
6810
+ import ts2 from "typescript";
6811
+ var HEADER5 = `// AUTO-GENERATED by @pattern-stack/codegen. Do not edit.
6662
6812
  // Run \`codegen entity new --all\` to refresh.
6663
6813
  `;
6664
6814
  var DuplicateTriggerError = class extends Error {
@@ -6716,12 +6866,12 @@ var UnknownTriggerEventError = class extends Error {
6716
6866
  name = "UnknownTriggerEventError";
6717
6867
  };
6718
6868
  function findHandlerFiles(dir) {
6719
- if (!fs6.existsSync(dir)) return [];
6869
+ if (!fs7.existsSync(dir)) return [];
6720
6870
  const out = [];
6721
- for (const entry of fs6.readdirSync(dir, { withFileTypes: true })) {
6871
+ for (const entry of fs7.readdirSync(dir, { withFileTypes: true })) {
6722
6872
  if (entry.name.startsWith(".")) continue;
6723
6873
  if (entry.name === "node_modules" || entry.name === "generated") continue;
6724
- const full = path9.join(dir, entry.name);
6874
+ const full = path10.join(dir, entry.name);
6725
6875
  if (entry.isDirectory()) {
6726
6876
  out.push(...findHandlerFiles(full));
6727
6877
  } else if (entry.isFile() && entry.name.endsWith(".ts") && !entry.name.endsWith(".d.ts")) {
@@ -6784,7 +6934,7 @@ function scanHandlerFiles(handlersDir) {
6784
6934
  const files = findHandlerFiles(handlersDir);
6785
6935
  const out = [];
6786
6936
  for (const filePath of files) {
6787
- const text2 = fs6.readFileSync(filePath, "utf8");
6937
+ const text2 = fs7.readFileSync(filePath, "utf8");
6788
6938
  const sourceFile = ts2.createSourceFile(
6789
6939
  filePath,
6790
6940
  text2,
@@ -6799,9 +6949,9 @@ function scanHandlerFiles(handlersDir) {
6799
6949
  }
6800
6950
  function readKnownEventTypes(eventsGeneratedDir) {
6801
6951
  if (!eventsGeneratedDir) return [];
6802
- const registryPath = path9.join(eventsGeneratedDir, "registry.ts");
6803
- if (!fs6.existsSync(registryPath)) return [];
6804
- const text2 = fs6.readFileSync(registryPath, "utf8");
6952
+ const registryPath = path10.join(eventsGeneratedDir, "registry.ts");
6953
+ if (!fs7.existsSync(registryPath)) return [];
6954
+ const text2 = fs7.readFileSync(registryPath, "utf8");
6805
6955
  const out = /* @__PURE__ */ new Set();
6806
6956
  const re = /^\s*'([a-zA-Z0-9_.-]+)':\s*\{/gm;
6807
6957
  let m;
@@ -6813,9 +6963,9 @@ function readKnownEventTypes(eventsGeneratedDir) {
6813
6963
  function readEventTiers(eventsGeneratedDir) {
6814
6964
  const out = /* @__PURE__ */ new Map();
6815
6965
  if (!eventsGeneratedDir) return out;
6816
- const registryPath = path9.join(eventsGeneratedDir, "registry.ts");
6817
- if (!fs6.existsSync(registryPath)) return out;
6818
- const text2 = fs6.readFileSync(registryPath, "utf8");
6966
+ const registryPath = path10.join(eventsGeneratedDir, "registry.ts");
6967
+ if (!fs7.existsSync(registryPath)) return out;
6968
+ const text2 = fs7.readFileSync(registryPath, "utf8");
6819
6969
  const re = /'([a-zA-Z0-9_.-]+)':\s*\{[^}]*?tier:\s*'(domain|audit)'/g;
6820
6970
  let m;
6821
6971
  while ((m = re.exec(text2)) !== null) {
@@ -6872,7 +7022,7 @@ function validateAgainstEventRegistry(triggers, knownEventTypes) {
6872
7022
  }
6873
7023
  function buildBridgeRegistryContent(triggers) {
6874
7024
  const chunks = [];
6875
- chunks.push(HEADER4);
7025
+ chunks.push(HEADER5);
6876
7026
  chunks.push("");
6877
7027
  chunks.push(`import type { BridgeRegistry } from '../bridge.protocol';`);
6878
7028
  chunks.push("");
@@ -6910,11 +7060,11 @@ function buildBridgeRegistryContent(triggers) {
6910
7060
  var OUTPUT_FILE_NAME = "registry.ts";
6911
7061
  async function generateBridgeRegistry(opts) {
6912
7062
  const { handlersDir, eventsGeneratedDir, outputDir, dryRun = false } = opts;
6913
- const bridgeProtocolPath = path9.resolve(outputDir, "..", "bridge.protocol.ts");
6914
- if (!fs6.existsSync(bridgeProtocolPath)) {
6915
- const strayPath = path9.join(outputDir, OUTPUT_FILE_NAME);
6916
- if (!dryRun && fs6.existsSync(strayPath)) {
6917
- fs6.rmSync(strayPath);
7063
+ const bridgeProtocolPath = path10.resolve(outputDir, "..", "bridge.protocol.ts");
7064
+ if (!fs7.existsSync(bridgeProtocolPath)) {
7065
+ const strayPath = path10.join(outputDir, OUTPUT_FILE_NAME);
7066
+ if (!dryRun && fs7.existsSync(strayPath)) {
7067
+ fs7.rmSync(strayPath);
6918
7068
  }
6919
7069
  return {
6920
7070
  outputDir,
@@ -6935,13 +7085,13 @@ async function generateBridgeRegistry(opts) {
6935
7085
  const content = buildBridgeRegistryContent(triggers);
6936
7086
  const file = {
6937
7087
  name: OUTPUT_FILE_NAME,
6938
- outputPath: path9.join(outputDir, OUTPUT_FILE_NAME),
7088
+ outputPath: path10.join(outputDir, OUTPUT_FILE_NAME),
6939
7089
  content
6940
7090
  };
6941
7091
  let written = false;
6942
7092
  if (!dryRun) {
6943
- fs6.mkdirSync(outputDir, { recursive: true });
6944
- fs6.writeFileSync(file.outputPath, file.content);
7093
+ fs7.mkdirSync(outputDir, { recursive: true });
7094
+ fs7.writeFileSync(file.outputPath, file.content);
6945
7095
  written = true;
6946
7096
  }
6947
7097
  const eventTypeCount = new Set(triggers.map((t) => t.event)).size;
@@ -6957,8 +7107,8 @@ async function generateBridgeRegistry(opts) {
6957
7107
  }
6958
7108
 
6959
7109
  // src/cli/shared/orchestration-generator.ts
6960
- import fs7 from "fs";
6961
- import path10 from "path";
7110
+ import fs8 from "fs";
7111
+ import path11 from "path";
6962
7112
  var OrchestrationEmissionError = class extends Error {
6963
7113
  constructor(issueType, patternName, message) {
6964
7114
  super(`[${issueType}] ${patternName}: ${message}`);
@@ -6969,7 +7119,7 @@ var OrchestrationEmissionError = class extends Error {
6969
7119
  patternName;
6970
7120
  name = "OrchestrationEmissionError";
6971
7121
  };
6972
- var HEADER5 = `// AUTO-GENERATED by @pattern-stack/codegen. Do not edit.
7122
+ var HEADER6 = `// AUTO-GENERATED by @pattern-stack/codegen. Do not edit.
6973
7123
  // See ADR-032 \u2014 Orchestration Patterns.
6974
7124
  `;
6975
7125
  function splitWords(str) {
@@ -7133,7 +7283,7 @@ function buildTokensTs(pattern) {
7133
7283
  typeImports.push({ specifier: reg.valueTypeImport, name: reg.valueType });
7134
7284
  }
7135
7285
  const lines = [];
7136
- lines.push(HEADER5.trimEnd());
7286
+ lines.push(HEADER6.trimEnd());
7137
7287
  lines.push("");
7138
7288
  for (const i of emitTypeImports(typeImports)) lines.push(i);
7139
7289
  lines.push("");
@@ -7166,7 +7316,7 @@ function buildProvidersTs(pattern) {
7166
7316
  }
7167
7317
  const optsType = forRootOptionsTypeName(pattern);
7168
7318
  const lines = [];
7169
- lines.push(HEADER5.trimEnd());
7319
+ lines.push(HEADER6.trimEnd());
7170
7320
  lines.push("");
7171
7321
  lines.push(`import type { Provider } from '@nestjs/common';`);
7172
7322
  for (const i of emitTypeImports(typeImports)) lines.push(i);
@@ -7233,7 +7383,7 @@ function buildDispatcherTs(pattern) {
7233
7383
  const tokenValues = registries.map(({ names: names2 }) => names2.tokenConst);
7234
7384
  const mapTypes = registries.map(({ names: names2 }) => names2.mapType);
7235
7385
  const lines = [];
7236
- lines.push(HEADER5.trimEnd());
7386
+ lines.push(HEADER6.trimEnd());
7237
7387
  lines.push("");
7238
7388
  lines.push(`import { Inject, Injectable } from '@nestjs/common';`);
7239
7389
  for (const i of emitTypeImports(typeImports)) lines.push(i);
@@ -7307,7 +7457,7 @@ function buildModuleTs(pattern) {
7307
7457
  }
7308
7458
  const tokenValues = registries.map(({ names: names2 }) => names2.tokenConst);
7309
7459
  const lines = [];
7310
- lines.push(HEADER5.trimEnd());
7460
+ lines.push(HEADER6.trimEnd());
7311
7461
  lines.push("");
7312
7462
  lines.push(`import { type DynamicModule, Module } from '@nestjs/common';`);
7313
7463
  for (const i of emitTypeImports(typeImports)) lines.push(i);
@@ -7341,7 +7491,7 @@ function buildModuleTs(pattern) {
7341
7491
  }
7342
7492
  function buildIndexTs(pattern) {
7343
7493
  const lines = [];
7344
- lines.push(HEADER5.trimEnd());
7494
+ lines.push(HEADER6.trimEnd());
7345
7495
  lines.push("");
7346
7496
  lines.push(`export * from './tokens.js';`);
7347
7497
  lines.push(`export * from './dispatcher.js';`);
@@ -7352,7 +7502,7 @@ function buildIndexTs(pattern) {
7352
7502
  }
7353
7503
  function buildRootBarrelTs(patterns) {
7354
7504
  const lines = [];
7355
- lines.push(HEADER5.trimEnd());
7505
+ lines.push(HEADER6.trimEnd());
7356
7506
  lines.push("");
7357
7507
  if (patterns.length === 0) {
7358
7508
  lines.push("// No orchestration patterns registered.");
@@ -7370,11 +7520,11 @@ function buildRootBarrelTs(patterns) {
7370
7520
  function buildPatternFiles(pattern, outputRoot) {
7371
7521
  assertEmittable(pattern);
7372
7522
  const slug = toKebabCase2(pattern.name);
7373
- const outputDir = path10.join(outputRoot, slug);
7523
+ const outputDir = path11.join(outputRoot, slug);
7374
7524
  const make = (name, content) => ({
7375
7525
  name,
7376
- outputPath: path10.join(outputDir, name),
7377
- relativePath: path10.join(slug, name),
7526
+ outputPath: path11.join(outputDir, name),
7527
+ relativePath: path11.join(slug, name),
7378
7528
  content
7379
7529
  });
7380
7530
  const files = [
@@ -7402,21 +7552,21 @@ function generateOrchestrationModules(opts) {
7402
7552
  }
7403
7553
  const rootBarrel = {
7404
7554
  name: "index.ts",
7405
- outputPath: path10.join(outputRoot, "index.ts"),
7555
+ outputPath: path11.join(outputRoot, "index.ts"),
7406
7556
  relativePath: "index.ts",
7407
7557
  content: buildRootBarrelTs(patterns)
7408
7558
  };
7409
7559
  allFiles.push(rootBarrel);
7410
7560
  let written = false;
7411
7561
  if (!dryRun && patterns.length > 0) {
7412
- fs7.mkdirSync(outputRoot, { recursive: true });
7562
+ fs8.mkdirSync(outputRoot, { recursive: true });
7413
7563
  for (const r of perPattern) {
7414
- fs7.mkdirSync(r.outputDir, { recursive: true });
7564
+ fs8.mkdirSync(r.outputDir, { recursive: true });
7415
7565
  for (const f of r.files) {
7416
- fs7.writeFileSync(f.outputPath, f.content);
7566
+ fs8.writeFileSync(f.outputPath, f.content);
7417
7567
  }
7418
7568
  }
7419
- fs7.writeFileSync(rootBarrel.outputPath, rootBarrel.content);
7569
+ fs8.writeFileSync(rootBarrel.outputPath, rootBarrel.content);
7420
7570
  written = true;
7421
7571
  }
7422
7572
  return {
@@ -7428,8 +7578,8 @@ function generateOrchestrationModules(opts) {
7428
7578
  }
7429
7579
 
7430
7580
  // src/cli/shared/event-codegen-generator.ts
7431
- import fs8 from "fs";
7432
- import path11 from "path";
7581
+ import fs9 from "fs";
7582
+ import path12 from "path";
7433
7583
 
7434
7584
  // src/parser/load-events.ts
7435
7585
  import { basename as basename2, resolve as resolve4 } from "path";
@@ -7559,7 +7709,7 @@ function isEventFieldType(s) {
7559
7709
  }
7560
7710
 
7561
7711
  // src/cli/shared/event-codegen-generator.ts
7562
- var HEADER6 = `// AUTO-GENERATED by @pattern-stack/codegen. Do not edit.
7712
+ var HEADER7 = `// AUTO-GENERATED by @pattern-stack/codegen. Do not edit.
7563
7713
  // Run \`codegen entity new --all\` to refresh.
7564
7714
  `;
7565
7715
  function toCamelCase2(input) {
@@ -7613,7 +7763,7 @@ function aggregateTypeLiteral(ev) {
7613
7763
  function collectEntityEvents(entitiesDir) {
7614
7764
  const events = [];
7615
7765
  const issues = [];
7616
- if (!fs8.existsSync(entitiesDir)) {
7766
+ if (!fs9.existsSync(entitiesDir)) {
7617
7767
  return { events, issues };
7618
7768
  }
7619
7769
  const files = findYamlFiles(entitiesDir);
@@ -7657,7 +7807,7 @@ function mergeEvents(topLevel, entitySugar) {
7657
7807
  function collectMergedEvents(opts) {
7658
7808
  const { entitiesDir, eventsDir } = opts;
7659
7809
  const entityNames = [];
7660
- if (fs8.existsSync(entitiesDir)) {
7810
+ if (fs9.existsSync(entitiesDir)) {
7661
7811
  const entityFiles = findYamlFiles(entitiesDir);
7662
7812
  for (const f of entityFiles) {
7663
7813
  const result = loadEntityFromYaml(f);
@@ -7680,7 +7830,7 @@ function collectMergedEvents(opts) {
7680
7830
  function buildTypesContent(events) {
7681
7831
  const sorted = [...events].sort((a, b) => a.type.localeCompare(b.type));
7682
7832
  if (sorted.length === 0) {
7683
- return HEADER6 + `
7833
+ return HEADER7 + `
7684
7834
  import type { DomainEvent } from '../event-bus.protocol';
7685
7835
 
7686
7836
  export type AppDomainEvent = never;
@@ -7691,7 +7841,7 @@ export type PayloadOfType<T extends EventTypeName> = DomainEvent['payload'];
7691
7841
  `;
7692
7842
  }
7693
7843
  const chunks = [];
7694
- chunks.push(HEADER6);
7844
+ chunks.push(HEADER7);
7695
7845
  chunks.push("");
7696
7846
  chunks.push(`import type { DomainEvent } from '../event-bus.protocol';`);
7697
7847
  chunks.push("");
@@ -7739,7 +7889,7 @@ export type PayloadOfType<T extends EventTypeName> = DomainEvent['payload'];
7739
7889
  function buildSchemasContent(events) {
7740
7890
  const sorted = [...events].sort((a, b) => a.type.localeCompare(b.type));
7741
7891
  if (sorted.length === 0) {
7742
- return HEADER6 + `
7892
+ return HEADER7 + `
7743
7893
  import { z } from 'zod';
7744
7894
  import type { EventTypeName } from './types';
7745
7895
 
@@ -7747,7 +7897,7 @@ export const eventPayloadSchemas = {} as Record<EventTypeName, z.ZodType>;
7747
7897
  `;
7748
7898
  }
7749
7899
  const chunks = [];
7750
- chunks.push(HEADER6);
7900
+ chunks.push(HEADER7);
7751
7901
  chunks.push("");
7752
7902
  chunks.push(`import { z } from 'zod';`);
7753
7903
  chunks.push(`import type { EventTypeName } from './types';`);
@@ -7802,7 +7952,7 @@ var REGISTRY_GETTER = [
7802
7952
  function buildRegistryContent(events) {
7803
7953
  const sorted = [...events].sort((a, b) => a.type.localeCompare(b.type));
7804
7954
  const chunks = [];
7805
- chunks.push(HEADER6);
7955
+ chunks.push(HEADER7);
7806
7956
  chunks.push("");
7807
7957
  chunks.push(`import type { EventTypeName } from './types';`);
7808
7958
  chunks.push("");
@@ -7982,10 +8132,10 @@ export class TypedEventBus {
7982
8132
  }
7983
8133
  `;
7984
8134
  function buildBusContent(_events) {
7985
- return HEADER6 + "\n" + BUS_BODY;
8135
+ return HEADER7 + "\n" + BUS_BODY;
7986
8136
  }
7987
8137
  function buildIndexContent(_events) {
7988
- return HEADER6 + `
8138
+ return HEADER7 + `
7989
8139
  export * from './types';
7990
8140
  export * from './schemas';
7991
8141
  export * from './registry';
@@ -8014,15 +8164,15 @@ async function generateEventCodegen(opts) {
8014
8164
  };
8015
8165
  const files = OUTPUT_FILE_NAMES.map((name) => ({
8016
8166
  name,
8017
- outputPath: path11.join(outputDir, name),
8167
+ outputPath: path12.join(outputDir, name),
8018
8168
  content: builders[name](merged)
8019
8169
  }));
8020
8170
  const hasError = issues.some((i) => i.severity === "error");
8021
8171
  let written = false;
8022
8172
  if (!dryRun && !hasError) {
8023
- fs8.mkdirSync(outputDir, { recursive: true });
8173
+ fs9.mkdirSync(outputDir, { recursive: true });
8024
8174
  for (const file of files) {
8025
- fs8.writeFileSync(file.outputPath, file.content);
8175
+ fs9.writeFileSync(file.outputPath, file.content);
8026
8176
  }
8027
8177
  written = true;
8028
8178
  }
@@ -8118,22 +8268,6 @@ import {
8118
8268
  } from "fs";
8119
8269
  import { dirname, join as join11 } from "path";
8120
8270
 
8121
- // src/cli/shared/runtime-import.ts
8122
- var PACKAGE = "@pattern-stack/codegen";
8123
- function resolveRuntimeMode(config) {
8124
- return config?.runtime === "vendored" ? "vendored" : "package";
8125
- }
8126
- function subsystemsImport(mode, subsystem) {
8127
- if (mode === "vendored") {
8128
- return subsystem ? `@shared/subsystems/${subsystem}` : "@shared/subsystems";
8129
- }
8130
- return `${PACKAGE}/subsystems`;
8131
- }
8132
- function runtimeImport(mode, relpath) {
8133
- const clean = relpath.replace(/^\/+/, "");
8134
- return mode === "vendored" ? `@shared/${clean}` : `${PACKAGE}/runtime/${clean}`;
8135
- }
8136
-
8137
8271
  // src/cli/shared/sink-emission-generator.ts
8138
8272
  var SCAFFOLD_SENTINEL = "// <CODEGEN-SCAFFOLD-V1>";
8139
8273
  var USER_ID_FIELD = "userId";
@@ -8357,8 +8491,8 @@ function generateIntegrationAggregator(surface, entries) {
8357
8491
  );
8358
8492
  const importLines = sorted.map((e) => {
8359
8493
  const cls = assemblyModuleClass(e.entityName, e.provider);
8360
- const path34 = `./modules/${e.provider}/${e.entityName}-integration.module`;
8361
- return `import { ${cls} } from '${path34}';`;
8494
+ const path36 = `./modules/${e.provider}/${e.entityName}-integration.module`;
8495
+ return `import { ${cls} } from '${path36}';`;
8362
8496
  }).join("\n");
8363
8497
  const membersInline = moduleClasses.join(", ");
8364
8498
  return `${generatedBanner(`surface: ${surface}`)}
@@ -8982,9 +9116,9 @@ function emitAdapters(opts) {
8982
9116
  [aggregatorPath, generateSurfaceAggregator(surface, slugs, mode)],
8983
9117
  [typedViewPath, generateTypedView(surface, slugs, entitiesBySurface.get(surface) ?? [])]
8984
9118
  ];
8985
- for (const [path34, content] of files) {
8986
- if (!opts.dryRun) writeIfChanged(path34, content);
8987
- result.written.push(path34);
9119
+ for (const [path36, content] of files) {
9120
+ if (!opts.dryRun) writeIfChanged(path36, content);
9121
+ result.written.push(path36);
8988
9122
  }
8989
9123
  if (opts.backendSrcAbs) {
8990
9124
  const aliases = opts.aliases ?? {};
@@ -9330,14 +9464,14 @@ function relativeSource(filePath) {
9330
9464
  }
9331
9465
 
9332
9466
  // src/cli/shared/events-path.ts
9333
- import path12 from "path";
9467
+ import path13 from "path";
9334
9468
  var FALLBACK = "events";
9335
9469
  function resolveEventsDirFromConfig(cwd, config) {
9336
9470
  const configured = config?.paths?.events_dir;
9337
9471
  if (typeof configured === "string" && configured.length > 0) {
9338
- return path12.resolve(cwd, configured);
9472
+ return path13.resolve(cwd, configured);
9339
9473
  }
9340
- return path12.resolve(cwd, FALLBACK);
9474
+ return path13.resolve(cwd, FALLBACK);
9341
9475
  }
9342
9476
  function resolveEventsDir(ctx) {
9343
9477
  return resolveEventsDirFromConfig(ctx.cwd, ctx.config);
@@ -9366,10 +9500,10 @@ function printInfo(msg) {
9366
9500
  // src/cli/commands/entity.ts
9367
9501
  function resolveProvidersDir(ctx) {
9368
9502
  const fromConfig = ctx.config?.paths?.providers;
9369
- return fromConfig != null ? path13.resolve(ctx.cwd, fromConfig) : path13.resolve(ctx.cwd, "definitions/providers");
9503
+ return fromConfig != null ? path14.resolve(ctx.cwd, fromConfig) : path14.resolve(ctx.cwd, "definitions/providers");
9370
9504
  }
9371
9505
  function listEntityYamls2(dir, providersDir) {
9372
- if (!fs9.existsSync(dir)) return [];
9506
+ if (!fs10.existsSync(dir)) return [];
9373
9507
  return findYamlFiles(dir, {
9374
9508
  excludeDirs: providersDir ? [providersDir] : []
9375
9509
  });
@@ -9448,11 +9582,11 @@ async function hints(ctx) {
9448
9582
  { command: "codegen entity validate", description: "Validate YAML definitions" },
9449
9583
  { command: "codegen entity list", description: "List entities as a table" }
9450
9584
  ];
9451
- const providersDir = ctx.config?.paths?.providers != null ? path13.resolve(
9585
+ const providersDir = ctx.config?.paths?.providers != null ? path14.resolve(
9452
9586
  ctx.cwd,
9453
9587
  ctx.config.paths.providers
9454
- ) : path13.resolve(ctx.cwd, "definitions/providers");
9455
- if (fs9.existsSync(providersDir)) {
9588
+ ) : path14.resolve(ctx.cwd, "definitions/providers");
9589
+ if (fs10.existsSync(providersDir)) {
9456
9590
  baseHints.push({
9457
9591
  command: "codegen entity new --all",
9458
9592
  description: "Regenerate provider modules + adapter scaffolds (Track D)"
@@ -9507,14 +9641,14 @@ var EntityNewCommand = class extends Command2 {
9507
9641
  }
9508
9642
  let targets = [];
9509
9643
  if (this.all) {
9510
- const dir = ctx.entitiesDir ?? path13.resolve(ctx.cwd, "entities");
9644
+ const dir = ctx.entitiesDir ?? path14.resolve(ctx.cwd, "entities");
9511
9645
  targets = listEntityYamls2(dir, resolveProvidersDir(ctx));
9512
9646
  if (targets.length === 0) {
9513
9647
  printError(`No entity YAML files found in ${dir}`);
9514
9648
  return 1;
9515
9649
  }
9516
9650
  } else if (this.yaml) {
9517
- targets = [path13.resolve(ctx.cwd, this.yaml)];
9651
+ targets = [path14.resolve(ctx.cwd, this.yaml)];
9518
9652
  } else {
9519
9653
  printError("Missing YAML path. Pass a file or --all.");
9520
9654
  return 2;
@@ -9531,7 +9665,7 @@ var EntityNewCommand = class extends Command2 {
9531
9665
  }
9532
9666
  if (invalid.length > 0 && !this.continueOnError) {
9533
9667
  for (const i of invalid) {
9534
- printError(`${path13.basename(i.file)} \u2014 ${i.message}`);
9668
+ printError(`${path14.basename(i.file)} \u2014 ${i.message}`);
9535
9669
  for (const detail of i.details ?? []) {
9536
9670
  printError(` \u2022 ${detail}`);
9537
9671
  }
@@ -9540,7 +9674,7 @@ var EntityNewCommand = class extends Command2 {
9540
9674
  return 1;
9541
9675
  }
9542
9676
  }
9543
- const entitiesDirForEmits = ctx.entitiesDir ?? path13.resolve(ctx.cwd, "entities");
9677
+ const entitiesDirForEmits = ctx.entitiesDir ?? path14.resolve(ctx.cwd, "entities");
9544
9678
  const eventsDirForEmits = resolveEventsDir(ctx);
9545
9679
  const allEntitiesForEmits = loadEntities(entitiesDirForEmits, {
9546
9680
  excludeDirs: [resolveProvidersDir(ctx)]
@@ -9589,35 +9723,35 @@ var EntityNewCommand = class extends Command2 {
9589
9723
  if (!isJsonMode()) return 1;
9590
9724
  }
9591
9725
  }
9592
- const entitiesDir = ctx.entitiesDir ?? path13.resolve(ctx.cwd, "entities");
9593
- const relationshipsDir = path13.resolve(ctx.cwd, "relationships");
9726
+ const entitiesDir = ctx.entitiesDir ?? path14.resolve(ctx.cwd, "entities");
9727
+ const relationshipsDir = path14.resolve(ctx.cwd, "relationships");
9594
9728
  const generatedDir = resolveGeneratedDir(ctx);
9595
9729
  const architecture = resolveArchitecture(ctx);
9596
9730
  const subsystemsRoot = resolveSubsystemsRoot(ctx);
9597
- const scopeEntityTypePath = path13.resolve(
9731
+ const scopeEntityTypePath = path14.resolve(
9598
9732
  subsystemsRoot,
9599
9733
  "jobs/generated/scope-entity-type.ts"
9600
9734
  );
9601
9735
  const eventsDir = resolveEventsDir(ctx);
9602
- const eventCodegenOutputDir = path13.resolve(
9736
+ const eventCodegenOutputDir = path14.resolve(
9603
9737
  subsystemsRoot,
9604
9738
  "events/generated"
9605
9739
  );
9606
- const bridgeRegistryOutputDir = path13.resolve(
9740
+ const bridgeRegistryOutputDir = path14.resolve(
9607
9741
  subsystemsRoot,
9608
9742
  "bridge/generated"
9609
9743
  );
9610
9744
  const backendSrcForHandlers = ctx.config?.paths?.backend_src ?? "src";
9611
9745
  const runtimeMode = resolveRuntimeMode(ctx.config);
9612
- const bridgeHandlersDir = path13.resolve(
9746
+ const bridgeHandlersDir = path14.resolve(
9613
9747
  ctx.cwd,
9614
9748
  backendSrcForHandlers,
9615
9749
  "jobs"
9616
9750
  );
9617
9751
  const orchestrationConfigured = ctx.config?.paths?.orchestration_src;
9618
- const orchestrationOutputRoot = path13.resolve(
9752
+ const orchestrationOutputRoot = path14.resolve(
9619
9753
  ctx.cwd,
9620
- typeof orchestrationConfigured === "string" && orchestrationConfigured.length > 0 ? orchestrationConfigured : path13.join(backendSrcForHandlers, "orchestration")
9754
+ typeof orchestrationConfigured === "string" && orchestrationConfigured.length > 0 ? orchestrationConfigured : path14.join(backendSrcForHandlers, "orchestration")
9621
9755
  );
9622
9756
  const orchestrationGlobs = (() => {
9623
9757
  const fromCfg = ctx.config?.patterns;
@@ -9745,7 +9879,7 @@ var EntityNewCommand = class extends Command2 {
9745
9879
  }
9746
9880
  if (invalid.length > 0) {
9747
9881
  for (const i of invalid) {
9748
- printWarning(`${path13.basename(i.file)} \u2014 ${i.message}`);
9882
+ printWarning(`${path14.basename(i.file)} \u2014 ${i.message}`);
9749
9883
  }
9750
9884
  }
9751
9885
  console.log("");
@@ -9763,7 +9897,7 @@ var EntityNewCommand = class extends Command2 {
9763
9897
  }
9764
9898
  const succeeded = [];
9765
9899
  const failed = [
9766
- ...invalid.map((i) => ({ name: path13.basename(i.file), file: i.file, message: i.message }))
9900
+ ...invalid.map((i) => ({ name: path14.basename(i.file), file: i.file, message: i.message }))
9767
9901
  ];
9768
9902
  for (const v of validated) {
9769
9903
  if (!isJsonMode()) {
@@ -9806,6 +9940,14 @@ var EntityNewCommand = class extends Command2 {
9806
9940
  printWarning(`subsystem barrel regeneration failed \u2014 ${msg}`);
9807
9941
  }
9808
9942
  }
9943
+ try {
9944
+ await regenerateSubsystemSchemaBarrel({ ctx, generatedDir });
9945
+ } catch (err) {
9946
+ const msg = err instanceof Error ? err.message : String(err);
9947
+ if (!isJsonMode()) {
9948
+ printWarning(`subsystem schema barrel regeneration failed \u2014 ${msg}`);
9949
+ }
9950
+ }
9809
9951
  let scopeResult = null;
9810
9952
  try {
9811
9953
  scopeResult = await generateScopeEntityType({
@@ -9878,12 +10020,12 @@ var EntityNewCommand = class extends Command2 {
9878
10020
  let providerResult = null;
9879
10021
  try {
9880
10022
  const providersDir = resolveProvidersDir(ctx);
9881
- const providerOutputRoot = path13.resolve(
10023
+ const providerOutputRoot = path14.resolve(
9882
10024
  ctx.cwd,
9883
10025
  backendSrcForHandlers,
9884
10026
  "integrations/providers"
9885
10027
  );
9886
- const entitySurfaces = fs9.existsSync(entitiesDir) ? collectEntitySurfaces(
10028
+ const entitySurfaces = fs10.existsSync(entitiesDir) ? collectEntitySurfaces(
9887
10029
  loadEntitiesFromYaml(
9888
10030
  findYamlFiles(entitiesDir, { excludeDirs: [providersDir] })
9889
10031
  ).successes.map((s) => s.definition)
@@ -9920,12 +10062,12 @@ var EntityNewCommand = class extends Command2 {
9920
10062
  try {
9921
10063
  if (providerResult && !providerResult.skipped && providerResult.issues.length === 0) {
9922
10064
  const providersDir = providerResult.providersDir;
9923
- const adapterOutputRoot = path13.resolve(
10065
+ const adapterOutputRoot = path14.resolve(
9924
10066
  ctx.cwd,
9925
10067
  backendSrcForHandlers,
9926
10068
  "integrations"
9927
10069
  );
9928
- const entityDefs = fs9.existsSync(entitiesDir) ? loadEntitiesFromYaml(
10070
+ const entityDefs = fs10.existsSync(entitiesDir) ? loadEntitiesFromYaml(
9929
10071
  findYamlFiles(entitiesDir, { excludeDirs: [providersDir] })
9930
10072
  ).successes.map((s) => s.definition) : [];
9931
10073
  const loadedProviders = loadProvidersFromYaml(
@@ -9939,7 +10081,7 @@ var EntityNewCommand = class extends Command2 {
9939
10081
  providers: loadedProviders,
9940
10082
  entities: entityDefs,
9941
10083
  outputRoot: adapterOutputRoot,
9942
- backendSrcAbs: path13.resolve(ctx.cwd, backendSrcForHandlers),
10084
+ backendSrcAbs: path14.resolve(ctx.cwd, backendSrcForHandlers),
9943
10085
  aliases: assemblyTsAliases?.aliases ?? {},
9944
10086
  mode: runtimeMode
9945
10087
  });
@@ -10041,22 +10183,22 @@ var EntityNewCommand = class extends Command2 {
10041
10183
  }
10042
10184
  if (barrelResult) {
10043
10185
  printInfo(
10044
- `barrels regenerated (${barrelResult.entityCount} entities) \u2192 ${path13.relative(ctx.cwd, barrelResult.modulesBarrel)}, ${path13.relative(ctx.cwd, barrelResult.schemaBarrel)}`
10186
+ `barrels regenerated (${barrelResult.entityCount} entities) \u2192 ${path14.relative(ctx.cwd, barrelResult.modulesBarrel)}, ${path14.relative(ctx.cwd, barrelResult.schemaBarrel)}`
10045
10187
  );
10046
10188
  }
10047
10189
  if (scopeResult) {
10048
10190
  printInfo(
10049
- `scope-entity-type regenerated (${scopeResult.scopeableNames.length} scopeable) \u2192 ${path13.relative(ctx.cwd, scopeResult.outputPath)}`
10191
+ `scope-entity-type regenerated (${scopeResult.scopeableNames.length} scopeable) \u2192 ${path14.relative(ctx.cwd, scopeResult.outputPath)}`
10050
10192
  );
10051
10193
  }
10052
10194
  if (eventCodegenResult) {
10053
10195
  printInfo(
10054
- `event codegen regenerated (${eventCodegenResult.eventCount} events) \u2192 ${path13.relative(ctx.cwd, eventCodegenResult.outputDir)}`
10196
+ `event codegen regenerated (${eventCodegenResult.eventCount} events) \u2192 ${path14.relative(ctx.cwd, eventCodegenResult.outputDir)}`
10055
10197
  );
10056
10198
  }
10057
10199
  if (orchestrationResult && orchestrationResult.patterns.length > 0) {
10058
10200
  printInfo(
10059
- `orchestration regenerated (${orchestrationResult.patterns.length} patterns, ${orchestrationResult.files.length} files) \u2192 ${path13.relative(ctx.cwd, orchestrationResult.outputRoot)}`
10201
+ `orchestration regenerated (${orchestrationResult.patterns.length} patterns, ${orchestrationResult.files.length} files) \u2192 ${path14.relative(ctx.cwd, orchestrationResult.outputRoot)}`
10060
10202
  );
10061
10203
  }
10062
10204
  }
@@ -10142,8 +10284,8 @@ var EntityValidateCommand = class extends Command2 {
10142
10284
  json: this.json,
10143
10285
  skipDetection: true
10144
10286
  });
10145
- const targetDir = this.dir ? path13.resolve(ctx.cwd, this.dir) : ctx.entitiesDir ?? path13.resolve(ctx.cwd, "entities");
10146
- if (!fs9.existsSync(targetDir)) {
10287
+ const targetDir = this.dir ? path14.resolve(ctx.cwd, this.dir) : ctx.entitiesDir ?? path14.resolve(ctx.cwd, "entities");
10288
+ if (!fs10.existsSync(targetDir)) {
10147
10289
  printError(`Directory not found: ${targetDir}`);
10148
10290
  return 1;
10149
10291
  }
@@ -10194,8 +10336,8 @@ var entityNoun = {
10194
10336
  var entity_default = entityNoun;
10195
10337
 
10196
10338
  // src/cli/commands/subsystem.ts
10197
- import fs11 from "fs";
10198
- import path22 from "path";
10339
+ import fs13 from "fs";
10340
+ import path24 from "path";
10199
10341
  import { Command as Command3, Option as Option3 } from "clipanion";
10200
10342
 
10201
10343
  // src/cli/shared/config-block-detect.ts
@@ -10228,26 +10370,26 @@ function stripConfigBlock(yamlSource, subsystem) {
10228
10370
  }
10229
10371
 
10230
10372
  // src/cli/shared/events-scaffold-locals.ts
10231
- import path14 from "path";
10373
+ import path15 from "path";
10232
10374
  function resolveEventsScaffoldLocals(input) {
10233
10375
  const { cwd, config } = input;
10234
10376
  void input.fileExists;
10235
10377
  const eventsBlock = config?.events ?? {};
10236
10378
  const subsystemsRoot = resolveSubsystemsRootFromConfig(cwd, config);
10237
- const configPath = path14.resolve(cwd, "codegen.config.yaml");
10238
- const schemaPath = path14.resolve(
10379
+ const configPath = path15.resolve(cwd, "codegen.config.yaml");
10380
+ const schemaPath = path15.resolve(
10239
10381
  subsystemsRoot,
10240
10382
  "events",
10241
10383
  "domain-events.schema.ts"
10242
10384
  );
10243
- const generatedKeepPath = path14.resolve(
10385
+ const generatedKeepPath = path15.resolve(
10244
10386
  subsystemsRoot,
10245
10387
  "events",
10246
10388
  "generated",
10247
10389
  ".gitkeep"
10248
10390
  );
10249
10391
  return {
10250
- appName: path14.basename(cwd),
10392
+ appName: path15.basename(cwd),
10251
10393
  multiTenant: normaliseMultiTenant(eventsBlock.multi_tenant),
10252
10394
  configPath,
10253
10395
  schemaPath,
@@ -10273,7 +10415,7 @@ function localsToHygenArgs(locals) {
10273
10415
  }
10274
10416
 
10275
10417
  // src/cli/shared/jobs-scaffold-locals.ts
10276
- import path15 from "path";
10418
+ import path16 from "path";
10277
10419
  var MAIN_HOOK_SENTINEL = "JOBS \u2014 Embedded worker mode (optional)";
10278
10420
  function workerSkipValue(exists) {
10279
10421
  return exists ? "true" : "";
@@ -10282,10 +10424,10 @@ function resolveJobsScaffoldLocals(input) {
10282
10424
  const { cwd, config, fileExists, readFile } = input;
10283
10425
  const jobsBlock = config?.jobs ?? {};
10284
10426
  const subsystemsRoot = resolveSubsystemsRootFromConfig(cwd, config);
10285
- const workerPath = path15.resolve(cwd, "worker.ts");
10286
- const mainTsPath = path15.resolve(cwd, "src/main.ts");
10287
- const configPath = path15.resolve(cwd, "codegen.config.yaml");
10288
- const schemaPath = path15.resolve(
10427
+ const workerPath = path16.resolve(cwd, "worker.ts");
10428
+ const mainTsPath = path16.resolve(cwd, "src/main.ts");
10429
+ const configPath = path16.resolve(cwd, "codegen.config.yaml");
10430
+ const schemaPath = path16.resolve(
10289
10431
  subsystemsRoot,
10290
10432
  "jobs",
10291
10433
  "job-orchestration.schema.ts"
@@ -10293,7 +10435,7 @@ function resolveJobsScaffoldLocals(input) {
10293
10435
  const mainContent = readFile(mainTsPath);
10294
10436
  const mainHookInjected = mainContent !== null && mainContent.includes(MAIN_HOOK_SENTINEL);
10295
10437
  return {
10296
- appName: path15.basename(cwd),
10438
+ appName: path16.basename(cwd),
10297
10439
  workerMode: normaliseWorkerMode(jobsBlock.worker_mode),
10298
10440
  multiTenant: normaliseMultiTenant2(jobsBlock.multi_tenant),
10299
10441
  mainTsPath,
@@ -10335,20 +10477,20 @@ function localsToHygenArgs2(locals) {
10335
10477
  }
10336
10478
 
10337
10479
  // src/cli/shared/integration-scaffold-locals.ts
10338
- import path16 from "path";
10480
+ import path17 from "path";
10339
10481
  function resolveIntegrationScaffoldLocals(input) {
10340
10482
  const { cwd, config } = input;
10341
10483
  void input.fileExists;
10342
10484
  const integrationBlock = config?.integration ?? {};
10343
10485
  const subsystemsRoot = resolveSubsystemsRootFromConfig(cwd, config);
10344
- const configPath = path16.resolve(cwd, "codegen.config.yaml");
10345
- const schemaPath = path16.resolve(
10486
+ const configPath = path17.resolve(cwd, "codegen.config.yaml");
10487
+ const schemaPath = path17.resolve(
10346
10488
  subsystemsRoot,
10347
10489
  "integration",
10348
10490
  "integration-audit.schema.ts"
10349
10491
  );
10350
10492
  return {
10351
- appName: path16.basename(cwd),
10493
+ appName: path17.basename(cwd),
10352
10494
  multiTenant: normaliseMultiTenant3(integrationBlock.multi_tenant),
10353
10495
  configPath,
10354
10496
  schemaPath
@@ -10371,21 +10513,21 @@ function localsToHygenArgs3(locals) {
10371
10513
  }
10372
10514
 
10373
10515
  // src/cli/shared/bridge-scaffold-locals.ts
10374
- import path17 from "path";
10516
+ import path18 from "path";
10375
10517
  function resolveBridgeScaffoldLocals(input) {
10376
10518
  const { cwd, config } = input;
10377
10519
  void input.fileExists;
10378
10520
  const bridgeBlock = config?.bridge ?? {};
10379
10521
  const subsystemsRoot = resolveSubsystemsRootFromConfig(cwd, config);
10380
- const configPath = path17.resolve(cwd, "codegen.config.yaml");
10381
- const generatedKeepPath = path17.resolve(
10522
+ const configPath = path18.resolve(cwd, "codegen.config.yaml");
10523
+ const generatedKeepPath = path18.resolve(
10382
10524
  subsystemsRoot,
10383
10525
  "bridge",
10384
10526
  "generated",
10385
10527
  ".gitkeep"
10386
10528
  );
10387
10529
  return {
10388
- appName: path17.basename(cwd),
10530
+ appName: path18.basename(cwd),
10389
10531
  multiTenant: normaliseMultiTenant4(bridgeBlock.multi_tenant),
10390
10532
  configPath,
10391
10533
  generatedKeepPath
@@ -10408,19 +10550,19 @@ function localsToHygenArgs4(locals) {
10408
10550
  }
10409
10551
 
10410
10552
  // src/cli/shared/observability-scaffold-locals.ts
10411
- import path18 from "path";
10553
+ import path19 from "path";
10412
10554
  var FALLBACK_BACKEND_SRC2 = "src";
10413
10555
  function resolveObservabilityScaffoldLocals(input) {
10414
10556
  const { cwd, config } = input;
10415
10557
  void input.fileExists;
10416
10558
  const backendSrc = typeof config?.paths?.backend_src === "string" && config.paths.backend_src.length > 0 ? config.paths.backend_src : FALLBACK_BACKEND_SRC2;
10417
- const appModulePath = path18.resolve(cwd, backendSrc, "app.module.ts");
10418
- const configPath = path18.resolve(cwd, "codegen.config.yaml");
10559
+ const appModulePath = path19.resolve(cwd, backendSrc, "app.module.ts");
10560
+ const configPath = path19.resolve(cwd, "codegen.config.yaml");
10419
10561
  const obsBlock = config?.observability ?? {};
10420
10562
  const reporters = obsBlock.reporters ?? {};
10421
10563
  const bridgeMetrics = reporters.bridgeMetrics ?? {};
10422
10564
  return {
10423
- appName: path18.basename(cwd),
10565
+ appName: path19.basename(cwd),
10424
10566
  appModulePath,
10425
10567
  configPath,
10426
10568
  bridgeMetricsEnabled: bridgeMetrics.enabled === true
@@ -10441,7 +10583,7 @@ function localsToHygenArgs5(locals) {
10441
10583
 
10442
10584
  // src/cli/shared/auth-scaffold-locals.ts
10443
10585
  import crypto2 from "crypto";
10444
- import path19 from "path";
10586
+ import path20 from "path";
10445
10587
  var FALLBACK_BACKEND_SRC3 = "src";
10446
10588
  var DEFAULT_REDIRECT_URI_BASE = "http://localhost:3000";
10447
10589
  function resolveAuthScaffoldLocals(input) {
@@ -10453,15 +10595,15 @@ function resolveAuthScaffoldLocals(input) {
10453
10595
  const redirectUriBase = typeof redirectRaw === "string" && redirectRaw.length > 0 ? redirectRaw : DEFAULT_REDIRECT_URI_BASE;
10454
10596
  const tokenEncryptionKey = crypto2.randomBytes(32).toString("base64");
10455
10597
  return {
10456
- appName: path19.basename(cwd),
10457
- configPath: path19.resolve(cwd, "codegen.config.yaml"),
10458
- schemaPath: path19.resolve(
10598
+ appName: path20.basename(cwd),
10599
+ configPath: path20.resolve(cwd, "codegen.config.yaml"),
10600
+ schemaPath: path20.resolve(
10459
10601
  subsystemsRoot,
10460
10602
  "auth",
10461
10603
  "auth-oauth-state.schema.ts"
10462
10604
  ),
10463
- appModulePath: path19.resolve(cwd, backendSrc, "app.module.ts"),
10464
- envConfigPath: path19.resolve(cwd, ".env.config"),
10605
+ appModulePath: path20.resolve(cwd, backendSrc, "app.module.ts"),
10606
+ envConfigPath: path20.resolve(cwd, ".env.config"),
10465
10607
  redirectUriBase,
10466
10608
  tokenEncryptionKey
10467
10609
  };
@@ -10486,7 +10628,7 @@ function localsToHygenArgs6(locals) {
10486
10628
  }
10487
10629
 
10488
10630
  // src/cli/shared/auth-integrations-scaffold-locals.ts
10489
- import path20 from "path";
10631
+ import path21 from "path";
10490
10632
  var FALLBACK_BACKEND_SRC4 = "src";
10491
10633
  var DEFAULT_MODULES_DIR = "modules";
10492
10634
  var DEFAULT_DEFINITIONS_DIR = "definitions/entities";
@@ -10495,17 +10637,17 @@ function resolveAuthIntegrationsScaffoldLocals(input) {
10495
10637
  const backendSrc = typeof config?.paths?.backend_src === "string" && config.paths.backend_src.length > 0 ? config.paths.backend_src : FALLBACK_BACKEND_SRC4;
10496
10638
  const pathsAny = config?.paths;
10497
10639
  const modulesConfigured = pathsAny?.modules_dir;
10498
- const vendorRoot = typeof modulesConfigured === "string" && modulesConfigured.length > 0 ? path20.resolve(cwd, modulesConfigured) : path20.resolve(cwd, backendSrc, DEFAULT_MODULES_DIR);
10640
+ const vendorRoot = typeof modulesConfigured === "string" && modulesConfigured.length > 0 ? path21.resolve(cwd, modulesConfigured) : path21.resolve(cwd, backendSrc, DEFAULT_MODULES_DIR);
10499
10641
  const entitiesConfigured = typeof pathsAny?.entities === "string" && pathsAny.entities.length > 0 ? pathsAny.entities : typeof pathsAny?.entities_dir === "string" && pathsAny.entities_dir.length > 0 ? pathsAny.entities_dir : null;
10500
- const definitionsPath = entitiesConfigured !== null ? path20.resolve(cwd, entitiesConfigured, "connection.yaml") : path20.resolve(cwd, DEFAULT_DEFINITIONS_DIR, "connection.yaml");
10501
- const appModulePath = path20.resolve(cwd, backendSrc, "app.module.ts");
10642
+ const definitionsPath = entitiesConfigured !== null ? path21.resolve(cwd, entitiesConfigured, "connection.yaml") : path21.resolve(cwd, DEFAULT_DEFINITIONS_DIR, "connection.yaml");
10643
+ const appModulePath = path21.resolve(cwd, backendSrc, "app.module.ts");
10502
10644
  let authModuleRegistered = false;
10503
10645
  const appModuleSource = input.readFile(appModulePath);
10504
10646
  if (appModuleSource && appModuleSource.includes("AuthModule.forRoot")) {
10505
10647
  authModuleRegistered = true;
10506
10648
  }
10507
10649
  return {
10508
- appName: path20.basename(cwd),
10650
+ appName: path21.basename(cwd),
10509
10651
  appModulePath,
10510
10652
  vendorRoot,
10511
10653
  definitionsPath,
@@ -10522,11 +10664,11 @@ function localsToHygenArgs7(locals) {
10522
10664
  }
10523
10665
 
10524
10666
  // src/cli/shared/runtime-copier.ts
10525
- import fs10 from "fs";
10526
- import path21 from "path";
10667
+ import fs11 from "fs";
10668
+ import path22 from "path";
10527
10669
  function readIfExists(p) {
10528
10670
  try {
10529
- return fs10.readFileSync(p, "utf-8");
10671
+ return fs11.readFileSync(p, "utf-8");
10530
10672
  } catch {
10531
10673
  return null;
10532
10674
  }
@@ -10541,20 +10683,20 @@ function extractRelativeImports(source) {
10541
10683
  return out;
10542
10684
  }
10543
10685
  function resolveSourceImport(sourceFile, specifier) {
10544
- const base = path21.resolve(path21.dirname(sourceFile), specifier);
10545
- const candidates = [base + ".ts", base + ".tsx", path21.join(base, "index.ts")];
10686
+ const base = path22.resolve(path22.dirname(sourceFile), specifier);
10687
+ const candidates = [base + ".ts", base + ".tsx", path22.join(base, "index.ts")];
10546
10688
  for (const c of candidates) {
10547
- if (fs10.existsSync(c)) return c;
10689
+ if (fs11.existsSync(c)) return c;
10548
10690
  }
10549
10691
  return null;
10550
10692
  }
10551
10693
  async function copyRuntime(opts) {
10552
10694
  const { sourceDir, targetDir, filter, resolveDeps, dryRun, onlyExisting } = opts;
10553
- if (!fs10.existsSync(sourceDir) || !fs10.statSync(sourceDir).isDirectory()) {
10695
+ if (!fs11.existsSync(sourceDir) || !fs11.statSync(sourceDir).isDirectory()) {
10554
10696
  throw new Error(`runtime source directory not found: ${sourceDir}`);
10555
10697
  }
10556
- const runtimeRoot4 = opts.runtimeRoot ? path21.resolve(opts.runtimeRoot) : path21.resolve(sourceDir, "..", "..");
10557
- const depsTargetRoot = opts.depsTargetRoot ?? path21.resolve(targetDir, "..");
10698
+ const runtimeRoot4 = opts.runtimeRoot ? path22.resolve(opts.runtimeRoot) : path22.resolve(sourceDir, "..", "..");
10699
+ const depsTargetRoot = opts.depsTargetRoot ?? path22.resolve(targetDir, "..");
10558
10700
  const result = {
10559
10701
  written: [],
10560
10702
  updated: [],
@@ -10564,9 +10706,9 @@ async function copyRuntime(opts) {
10564
10706
  };
10565
10707
  const queue = [];
10566
10708
  function walk(dir) {
10567
- for (const entry of fs10.readdirSync(dir)) {
10568
- const src = path21.join(dir, entry);
10569
- const stat = fs10.statSync(src);
10709
+ for (const entry of fs11.readdirSync(dir)) {
10710
+ const src = path22.join(dir, entry);
10711
+ const stat = fs11.statSync(src);
10570
10712
  if (stat.isDirectory()) {
10571
10713
  if (entry === "generated") continue;
10572
10714
  walk(src);
@@ -10574,9 +10716,9 @@ async function copyRuntime(opts) {
10574
10716
  }
10575
10717
  if (!stat.isFile()) continue;
10576
10718
  if (!entry.endsWith(".ts") && !entry.endsWith(".tsx")) continue;
10577
- const rel2 = path21.relative(sourceDir, src);
10719
+ const rel2 = path22.relative(sourceDir, src);
10578
10720
  if (filter && !filter(rel2) && !filter(entry)) continue;
10579
- queue.push({ src, dest: path21.join(targetDir, rel2), isDep: false });
10721
+ queue.push({ src, dest: path22.join(targetDir, rel2), isDep: false });
10580
10722
  }
10581
10723
  }
10582
10724
  walk(sourceDir);
@@ -10585,10 +10727,10 @@ async function copyRuntime(opts) {
10585
10727
  const next = queue.shift();
10586
10728
  if (visited.has(next.src)) continue;
10587
10729
  visited.add(next.src);
10588
- if (onlyExisting && !fs10.existsSync(next.dest)) {
10730
+ if (onlyExisting && !fs11.existsSync(next.dest)) {
10589
10731
  continue;
10590
10732
  }
10591
- const content = fs10.readFileSync(next.src, "utf-8");
10733
+ const content = fs11.readFileSync(next.src, "utf-8");
10592
10734
  result.planned.push(next.dest);
10593
10735
  const existing = readIfExists(next.dest);
10594
10736
  const status = existing === content ? "unchanged" : existing === null ? "written" : "updated";
@@ -10597,18 +10739,18 @@ async function copyRuntime(opts) {
10597
10739
  else result.unchanged.push(next.dest);
10598
10740
  if (next.isDep) result.dependenciesCopied.push(next.dest);
10599
10741
  if (!dryRun && status !== "unchanged") {
10600
- fs10.mkdirSync(path21.dirname(next.dest), { recursive: true });
10601
- fs10.writeFileSync(next.dest, content);
10742
+ fs11.mkdirSync(path22.dirname(next.dest), { recursive: true });
10743
+ fs11.writeFileSync(next.dest, content);
10602
10744
  }
10603
10745
  if (resolveDeps) {
10604
10746
  for (const spec of extractRelativeImports(content)) {
10605
10747
  const resolvedSrc = resolveSourceImport(next.src, spec);
10606
10748
  if (!resolvedSrc) continue;
10607
- const relToRuntime = path21.relative(runtimeRoot4, resolvedSrc);
10608
- if (relToRuntime.startsWith("..") || path21.isAbsolute(relToRuntime)) continue;
10609
- const relToSource = path21.relative(sourceDir, resolvedSrc);
10610
- if (!relToSource.startsWith("..") && !path21.isAbsolute(relToSource)) continue;
10611
- const depDest = path21.join(depsTargetRoot, relToRuntime);
10749
+ const relToRuntime = path22.relative(runtimeRoot4, resolvedSrc);
10750
+ if (relToRuntime.startsWith("..") || path22.isAbsolute(relToRuntime)) continue;
10751
+ const relToSource = path22.relative(sourceDir, resolvedSrc);
10752
+ if (!relToSource.startsWith("..") && !path22.isAbsolute(relToSource)) continue;
10753
+ const depDest = path22.join(depsTargetRoot, relToRuntime);
10612
10754
  queue.push({ src: resolvedSrc, dest: depDest, isDep: true });
10613
10755
  }
10614
10756
  }
@@ -10616,19 +10758,87 @@ async function copyRuntime(opts) {
10616
10758
  return result;
10617
10759
  }
10618
10760
 
10761
+ // src/cli/shared/subsystems-install-config.ts
10762
+ import fs12 from "fs";
10763
+ import path23 from "path";
10764
+ import yaml2 from "yaml";
10765
+ function readInstallList(config) {
10766
+ const raw = config?.subsystems?.install;
10767
+ if (!Array.isArray(raw)) return [];
10768
+ return raw.filter((e) => typeof e === "string");
10769
+ }
10770
+ function ensureSubsystemInstalled(configPath, name) {
10771
+ if (!fs12.existsSync(configPath)) {
10772
+ fs12.mkdirSync(path23.dirname(configPath), { recursive: true });
10773
+ fs12.writeFileSync(
10774
+ configPath,
10775
+ `subsystems:
10776
+ install:
10777
+ - ${name}
10778
+ `,
10779
+ "utf-8"
10780
+ );
10781
+ return { outcome: "added", install: [name] };
10782
+ }
10783
+ const source = fs12.readFileSync(configPath, "utf-8");
10784
+ let doc;
10785
+ try {
10786
+ doc = yaml2.parseDocument(source);
10787
+ if (doc.errors.length > 0) {
10788
+ return { outcome: "parse-error", install: [] };
10789
+ }
10790
+ } catch {
10791
+ return { outcome: "parse-error", install: [] };
10792
+ }
10793
+ const current = readInstallList(
10794
+ doc.toJS()
10795
+ );
10796
+ if (current.includes(name)) {
10797
+ return { outcome: "already", install: current };
10798
+ }
10799
+ const subsystemsNode = doc.get("subsystems", true);
10800
+ const installSeq = subsystemsNode && typeof subsystemsNode.get === "function" ? subsystemsNode.get("install", true) : void 0;
10801
+ if (installSeq && Array.isArray(installSeq.items) && installSeq.items.length > 0) {
10802
+ const lastItem = installSeq.items[installSeq.items.length - 1];
10803
+ const range = lastItem.range;
10804
+ if (range) {
10805
+ const insertAt = range[1];
10806
+ const lineStart = source.lastIndexOf("\n", range[0]) + 1;
10807
+ const indent = source.slice(lineStart, range[0]).match(/^\s*/)?.[0] ?? " ";
10808
+ const before = source.slice(0, insertAt);
10809
+ const after = source.slice(insertAt);
10810
+ const next = `${before}
10811
+ ${indent}- ${name}${after}`;
10812
+ fs12.writeFileSync(configPath, next, "utf-8");
10813
+ return { outcome: "added", install: [...current, name] };
10814
+ }
10815
+ }
10816
+ doc.setIn(["subsystems", "install"], [...current, name]);
10817
+ fs12.writeFileSync(configPath, String(doc), "utf-8");
10818
+ return { outcome: "added", install: [...current, name] };
10819
+ }
10820
+
10619
10821
  // src/cli/commands/subsystem.ts
10620
10822
  function runtimeRoot() {
10621
- const pkgRoot = path22.resolve(import.meta.dirname, "..", "..", "..");
10622
- const topLevel = path22.join(pkgRoot, "runtime");
10623
- if (fs11.existsSync(topLevel)) return topLevel;
10624
- return path22.join(pkgRoot, "dist", "runtime");
10823
+ const pkgRoot = path24.resolve(import.meta.dirname, "..", "..", "..");
10824
+ const topLevel = path24.join(pkgRoot, "runtime");
10825
+ if (fs13.existsSync(topLevel)) return topLevel;
10826
+ return path24.join(pkgRoot, "dist", "runtime");
10625
10827
  }
10626
10828
  function subsystemSource(name) {
10627
- return path22.join(runtimeRoot(), "subsystems", name);
10829
+ return path24.join(runtimeRoot(), "subsystems", name);
10628
10830
  }
10629
10831
  function describeSubsystem(name) {
10630
10832
  return SUBSYSTEMS.find((s) => s.name === name) ?? null;
10631
10833
  }
10834
+ var PACKAGE_CONFIG_BLOCK = {
10835
+ events: { detector: "events", actionFolder: "events-config" },
10836
+ jobs: { detector: "jobs", actionFolder: "jobs-config" },
10837
+ integration: { detector: "integration", actionFolder: "integration-config" },
10838
+ bridge: { detector: "bridge", actionFolder: "bridge-config" },
10839
+ observability: { detector: "observability", actionFolder: "observability-config" },
10840
+ auth: { detector: "auth", actionFolder: "auth-config" }
10841
+ };
10632
10842
  async function summary2(ctx) {
10633
10843
  const installed = await detectInstalledSubsystems(ctx);
10634
10844
  const installedNames = new Set(installed.map((i) => i.name));
@@ -10651,7 +10861,7 @@ async function summary2(ctx) {
10651
10861
  }
10652
10862
  body.push(theme.muted("Installed:"));
10653
10863
  for (const i of installed) {
10654
- const rel2 = path22.relative(ctx.cwd, i.path) || i.path;
10864
+ const rel2 = path24.relative(ctx.cwd, i.path) || i.path;
10655
10865
  body.push(
10656
10866
  ` ${theme.success(icons.check)} ${i.name.padEnd(10)} ${theme.muted(
10657
10867
  `${i.backend} backend`
@@ -10774,6 +10984,9 @@ var SubsystemInstallCommand = class extends Command3 {
10774
10984
  if (desc3.name === "auth-integrations") {
10775
10985
  return this.executeAuthIntegrations(ctx);
10776
10986
  }
10987
+ if (resolveRuntimeMode(ctx.config) === "package") {
10988
+ return this.executePackageMode(ctx, desc3, backend);
10989
+ }
10777
10990
  const installed = await detectInstalledSubsystems(ctx);
10778
10991
  const already = installed.find((i) => i.name === desc3.name);
10779
10992
  if (already && !this.force) {
@@ -10791,14 +11004,14 @@ var SubsystemInstallCommand = class extends Command3 {
10791
11004
  return 0;
10792
11005
  }
10793
11006
  const targetRoot = resolveSubsystemsRoot(ctx, this.target);
10794
- const subsystemTarget = path22.join(targetRoot, desc3.name);
11007
+ const subsystemTarget = path24.join(targetRoot, desc3.name);
10795
11008
  const source = subsystemSource(desc3.name);
10796
- if (!fs11.existsSync(source)) {
11009
+ if (!fs13.existsSync(source)) {
10797
11010
  printError(`Runtime subsystem source missing: ${source}`);
10798
11011
  return 1;
10799
11012
  }
10800
11013
  if (!this.force) {
10801
- const gitCheck = checkGitSafety([path22.relative(ctx.cwd, subsystemTarget) || subsystemTarget], ctx.cwd);
11014
+ const gitCheck = checkGitSafety([path24.relative(ctx.cwd, subsystemTarget) || subsystemTarget], ctx.cwd);
10802
11015
  if (gitCheck.inRepo && !gitCheck.clean) {
10803
11016
  printWarning(
10804
11017
  `Uncommitted changes under ${subsystemTarget}. Pass --force to overwrite.`
@@ -10807,7 +11020,7 @@ var SubsystemInstallCommand = class extends Command3 {
10807
11020
  }
10808
11021
  }
10809
11022
  if (!isJsonMode()) {
10810
- printInfo(`target = ${path22.relative(ctx.cwd, subsystemTarget) || subsystemTarget}`);
11023
+ printInfo(`target = ${path24.relative(ctx.cwd, subsystemTarget) || subsystemTarget}`);
10811
11024
  printInfo(`backend = ${backend}`);
10812
11025
  }
10813
11026
  const result = await copyRuntime({
@@ -10816,7 +11029,7 @@ var SubsystemInstallCommand = class extends Command3 {
10816
11029
  filter: backendFileFilter(backend, desc3.name),
10817
11030
  resolveDeps: true,
10818
11031
  runtimeRoot: runtimeRoot(),
10819
- depsTargetRoot: path22.resolve(targetRoot, ".."),
11032
+ depsTargetRoot: path24.resolve(targetRoot, ".."),
10820
11033
  dryRun: this.dryRun
10821
11034
  });
10822
11035
  const jobsScaffold = desc3.name === "jobs" ? runJobsScaffold(ctx.cwd, ctx.config, {
@@ -10911,14 +11124,14 @@ var SubsystemInstallCommand = class extends Command3 {
10911
11124
  if (this.dryRun) {
10912
11125
  printInfo(`Dry run \u2014 ${result.planned.length} files would be written`);
10913
11126
  for (const p of result.planned) {
10914
- console.log(` ${theme.muted(icons.arrow)} ${path22.relative(ctx.cwd, p) || p}`);
11127
+ console.log(` ${theme.muted(icons.arrow)} ${path24.relative(ctx.cwd, p) || p}`);
10915
11128
  }
10916
11129
  if (jobsScaffold?.planned?.length) {
10917
11130
  printInfo(
10918
11131
  `Jobs scaffold \u2014 ${jobsScaffold.planned.length} template targets`
10919
11132
  );
10920
11133
  for (const p of jobsScaffold.planned) {
10921
- console.log(` ${theme.muted(icons.arrow)} ${path22.relative(ctx.cwd, p) || p}`);
11134
+ console.log(` ${theme.muted(icons.arrow)} ${path24.relative(ctx.cwd, p) || p}`);
10922
11135
  }
10923
11136
  }
10924
11137
  if (eventsScaffold?.planned?.length) {
@@ -10926,7 +11139,7 @@ var SubsystemInstallCommand = class extends Command3 {
10926
11139
  `Events scaffold \u2014 ${eventsScaffold.planned.length} template targets`
10927
11140
  );
10928
11141
  for (const p of eventsScaffold.planned) {
10929
- console.log(` ${theme.muted(icons.arrow)} ${path22.relative(ctx.cwd, p) || p}`);
11142
+ console.log(` ${theme.muted(icons.arrow)} ${path24.relative(ctx.cwd, p) || p}`);
10930
11143
  }
10931
11144
  }
10932
11145
  if (integrationScaffold?.planned?.length) {
@@ -10934,7 +11147,7 @@ var SubsystemInstallCommand = class extends Command3 {
10934
11147
  `Integration scaffold \u2014 ${integrationScaffold.planned.length} template targets`
10935
11148
  );
10936
11149
  for (const p of integrationScaffold.planned) {
10937
- console.log(` ${theme.muted(icons.arrow)} ${path22.relative(ctx.cwd, p) || p}`);
11150
+ console.log(` ${theme.muted(icons.arrow)} ${path24.relative(ctx.cwd, p) || p}`);
10938
11151
  }
10939
11152
  }
10940
11153
  if (bridgeScaffold?.planned?.length) {
@@ -10942,7 +11155,7 @@ var SubsystemInstallCommand = class extends Command3 {
10942
11155
  `Bridge scaffold \u2014 ${bridgeScaffold.planned.length} template targets`
10943
11156
  );
10944
11157
  for (const p of bridgeScaffold.planned) {
10945
- console.log(` ${theme.muted(icons.arrow)} ${path22.relative(ctx.cwd, p) || p}`);
11158
+ console.log(` ${theme.muted(icons.arrow)} ${path24.relative(ctx.cwd, p) || p}`);
10946
11159
  }
10947
11160
  }
10948
11161
  if (observabilityScaffold?.planned?.length) {
@@ -10950,7 +11163,7 @@ var SubsystemInstallCommand = class extends Command3 {
10950
11163
  `Observability scaffold \u2014 ${observabilityScaffold.planned.length} template targets`
10951
11164
  );
10952
11165
  for (const p of observabilityScaffold.planned) {
10953
- console.log(` ${theme.muted(icons.arrow)} ${path22.relative(ctx.cwd, p) || p}`);
11166
+ console.log(` ${theme.muted(icons.arrow)} ${path24.relative(ctx.cwd, p) || p}`);
10954
11167
  }
10955
11168
  }
10956
11169
  if (authScaffold?.planned?.length) {
@@ -10958,7 +11171,7 @@ var SubsystemInstallCommand = class extends Command3 {
10958
11171
  `Auth scaffold \u2014 ${authScaffold.planned.length} template targets`
10959
11172
  );
10960
11173
  for (const p of authScaffold.planned) {
10961
- console.log(` ${theme.muted(icons.arrow)} ${path22.relative(ctx.cwd, p) || p}`);
11174
+ console.log(` ${theme.muted(icons.arrow)} ${path24.relative(ctx.cwd, p) || p}`);
10962
11175
  }
10963
11176
  }
10964
11177
  return 0;
@@ -11067,6 +11280,143 @@ var SubsystemInstallCommand = class extends Command3 {
11067
11280
  }
11068
11281
  return 0;
11069
11282
  }
11283
+ /**
11284
+ * ADR-037: package-mode install. The subsystem runtime lives in the
11285
+ * published `@pattern-stack/codegen` package, so installing reduces to a
11286
+ * config + barrel operation with NO file vendoring:
11287
+ *
11288
+ * 1. record the name under `subsystems.install` (the package-mode
11289
+ * source of truth for "installed");
11290
+ * 2. inject the per-subsystem `<name>:` config block via the same Hygen
11291
+ * action vendored mode uses (the block is runtime-agnostic — it only
11292
+ * writes YAML, never code); cache/storage have no config block, so this
11293
+ * step is skipped for them;
11294
+ * 3. regenerate the composition barrel (`<generated>/subsystems.ts`) and
11295
+ * the schema barrel (`<generated>/subsystems-schema.ts`) so AppModule's
11296
+ * `...SUBSYSTEM_MODULES` and drizzle-kit's schema pick up the new
11297
+ * install.
11298
+ *
11299
+ * Idempotent: a name already in `subsystems.install` is a no-op unless
11300
+ * `--force` is passed (which still re-runs config-block injection under
11301
+ * `--force-config` and always regenerates the barrels).
11302
+ */
11303
+ async executePackageMode(ctx, desc3, backend) {
11304
+ const configPath = path24.join(ctx.cwd, "codegen.config.yaml");
11305
+ const installed = configuredSubsystemNames(
11306
+ ctx.config
11307
+ );
11308
+ const already = installed.includes(desc3.name);
11309
+ if (already && !this.force) {
11310
+ if (isJsonMode()) {
11311
+ printJson({
11312
+ command: "subsystem install",
11313
+ subsystem: desc3.name,
11314
+ runtime: "package",
11315
+ status: "already-installed"
11316
+ });
11317
+ } else {
11318
+ printInfo(
11319
+ `${desc3.name} is already in subsystems.install (runtime: package \u2014 nothing to vendor). Pass --force to refresh the config block + barrels.`
11320
+ );
11321
+ }
11322
+ return 0;
11323
+ }
11324
+ const configSubsystem = PACKAGE_CONFIG_BLOCK[desc3.name];
11325
+ const configBlockOutcome = configSubsystem ? planConfigBlockAction(configPath, configSubsystem.detector, this.forceConfig) : null;
11326
+ if (configBlockOutcome === "parse-error") {
11327
+ printError(
11328
+ `codegen.config.yaml is not valid YAML: refusing to inject ${desc3.name} config block. Fix the YAML and re-run.`
11329
+ );
11330
+ return 1;
11331
+ }
11332
+ if (this.dryRun) {
11333
+ if (isJsonMode()) {
11334
+ printJson({
11335
+ command: "subsystem install",
11336
+ subsystem: desc3.name,
11337
+ runtime: "package",
11338
+ dryRun: true,
11339
+ installList: already ? installed : [...installed, desc3.name],
11340
+ configBlockOutcome
11341
+ });
11342
+ } else {
11343
+ printInfo(`Dry run \u2014 runtime: package (no files vendored).`);
11344
+ if (!already) printInfo(` would add '${desc3.name}' to subsystems.install`);
11345
+ if (configBlockOutcome) {
11346
+ printInfo(` ${desc3.name} config block would be ${configBlockOutcome}`);
11347
+ }
11348
+ printInfo(" would regenerate <generated>/subsystems.ts + subsystems-schema.ts");
11349
+ }
11350
+ return 0;
11351
+ }
11352
+ const installResult = ensureSubsystemInstalled(configPath, desc3.name);
11353
+ if (installResult.outcome === "parse-error") {
11354
+ printError(
11355
+ "codegen.config.yaml is not valid YAML: refusing to update subsystems.install. Fix the YAML and re-run."
11356
+ );
11357
+ return 1;
11358
+ }
11359
+ if (configSubsystem && configBlockOutcome) {
11360
+ const configResult = runConfigBlockAction({
11361
+ cwd: ctx.cwd,
11362
+ actionFolder: configSubsystem.actionFolder,
11363
+ configPath,
11364
+ subsystem: configSubsystem.detector,
11365
+ outcome: configBlockOutcome,
11366
+ json: isJsonMode()
11367
+ });
11368
+ if (!configResult.ok) {
11369
+ printError(
11370
+ `${desc3.name} config-block injection failed: ${configResult.error ?? "unknown error"}`
11371
+ );
11372
+ return 1;
11373
+ }
11374
+ }
11375
+ const refreshed = await loadContext({
11376
+ cwd: ctx.cwd,
11377
+ configPath: this.configPath,
11378
+ json: this.json,
11379
+ skipDetection: true
11380
+ });
11381
+ let barrelEmitted = [];
11382
+ let schemaEmitted = [];
11383
+ try {
11384
+ const generatedDir = resolveGeneratedDir(refreshed);
11385
+ const barrel = await regenerateSubsystemBarrel({ ctx: refreshed, generatedDir });
11386
+ barrelEmitted = barrel.emitted;
11387
+ const schema = await regenerateSubsystemSchemaBarrel({ ctx: refreshed, generatedDir });
11388
+ schemaEmitted = schema.emitted;
11389
+ } catch (err) {
11390
+ const msg = err instanceof Error ? err.message : String(err);
11391
+ printWarning(`barrel regeneration failed \u2014 ${msg}`);
11392
+ }
11393
+ if (isJsonMode()) {
11394
+ printJson({
11395
+ command: "subsystem install",
11396
+ subsystem: desc3.name,
11397
+ runtime: "package",
11398
+ backend,
11399
+ vendored: false,
11400
+ installList: installResult.install,
11401
+ installOutcome: installResult.outcome,
11402
+ configBlockOutcome,
11403
+ barrelEmitted,
11404
+ schemaEmitted
11405
+ });
11406
+ return 0;
11407
+ }
11408
+ printSuccess(`${desc3.name} installed (runtime: package \u2014 no files vendored).`);
11409
+ if (installResult.outcome === "added") {
11410
+ printInfo(`Added '${desc3.name}' to subsystems.install.`);
11411
+ }
11412
+ printInfo(
11413
+ `Regenerated <generated>/subsystems.ts (${barrelEmitted.join(", ") || "none"}) + subsystems-schema.ts (${schemaEmitted.join(", ") || "none"}).`
11414
+ );
11415
+ printInfo(
11416
+ "Wire once (if not already): `import { SUBSYSTEM_MODULES } from './generated/subsystems'` into AppModule, and `export * from './generated/subsystems-schema'` into your drizzle-kit schema entrypoint."
11417
+ );
11418
+ return 0;
11419
+ }
11070
11420
  /**
11071
11421
  * OPENAPI-4: install flow for the config-only `openapi-config`
11072
11422
  * pseudo-subsystem.
@@ -11078,7 +11428,7 @@ var SubsystemInstallCommand = class extends Command3 {
11078
11428
  * semantics as jobs/events/integration/bridge.
11079
11429
  */
11080
11430
  async executeOpenApiConfig(ctx) {
11081
- const configPath = path22.join(ctx.cwd, "codegen.config.yaml");
11431
+ const configPath = path24.join(ctx.cwd, "codegen.config.yaml");
11082
11432
  const outcome = planConfigBlockAction(configPath, "openapi", this.forceConfig);
11083
11433
  if (outcome === "parse-error") {
11084
11434
  printError(
@@ -11097,7 +11447,7 @@ var SubsystemInstallCommand = class extends Command3 {
11097
11447
  });
11098
11448
  } else {
11099
11449
  printInfo(`Dry run \u2014 openapi config block would be ${outcome}`);
11100
- console.log(` ${theme.muted(icons.arrow)} ${path22.relative(ctx.cwd, configPath) || configPath}`);
11450
+ console.log(` ${theme.muted(icons.arrow)} ${path24.relative(ctx.cwd, configPath) || configPath}`);
11101
11451
  }
11102
11452
  return 0;
11103
11453
  }
@@ -11192,7 +11542,7 @@ var SubsystemInstallCommand = class extends Command3 {
11192
11542
  );
11193
11543
  for (const p of scaffold.planned) {
11194
11544
  console.log(
11195
- ` ${theme.muted(icons.arrow)} ${path22.relative(ctx.cwd, p) || p}`
11545
+ ` ${theme.muted(icons.arrow)} ${path24.relative(ctx.cwd, p) || p}`
11196
11546
  );
11197
11547
  }
11198
11548
  return 0;
@@ -11216,10 +11566,10 @@ var SubsystemInstallCommand = class extends Command3 {
11216
11566
  }
11217
11567
  };
11218
11568
  function planConfigBlockAction(configPath, subsystem, forceConfig) {
11219
- if (!fs11.existsSync(configPath)) {
11569
+ if (!fs13.existsSync(configPath)) {
11220
11570
  return "inject";
11221
11571
  }
11222
- const source = fs11.readFileSync(configPath, "utf-8");
11572
+ const source = fs13.readFileSync(configPath, "utf-8");
11223
11573
  const state = detectConfigBlock(source, subsystem);
11224
11574
  if (state === "parse-error") return "parse-error";
11225
11575
  if (state === "missing") return "inject";
@@ -11242,9 +11592,9 @@ function runConfigBlockAction(input) {
11242
11592
  );
11243
11593
  }
11244
11594
  try {
11245
- const source = fs11.readFileSync(input.configPath, "utf-8");
11595
+ const source = fs13.readFileSync(input.configPath, "utf-8");
11246
11596
  const stripped = stripConfigBlock(source, input.subsystem);
11247
- fs11.writeFileSync(input.configPath, stripped, "utf-8");
11597
+ fs13.writeFileSync(input.configPath, stripped, "utf-8");
11248
11598
  } catch (err) {
11249
11599
  const message = err instanceof Error ? err.message : String(err);
11250
11600
  return { ok: false, error: `strip failed: ${message}` };
@@ -11282,8 +11632,8 @@ function runJobsScaffold(cwd, config, opts) {
11282
11632
  const locals = resolveJobsScaffoldLocals({
11283
11633
  cwd,
11284
11634
  config,
11285
- fileExists: (p) => fs11.existsSync(p),
11286
- readFile: (p) => fs11.existsSync(p) ? fs11.readFileSync(p, "utf-8") : null
11635
+ fileExists: (p) => fs13.existsSync(p),
11636
+ readFile: (p) => fs13.existsSync(p) ? fs13.readFileSync(p, "utf-8") : null
11287
11637
  });
11288
11638
  const planned = [
11289
11639
  ...!locals.workerExists ? [locals.workerPath] : [],
@@ -11340,7 +11690,7 @@ function runEventsScaffold(cwd, config, opts) {
11340
11690
  const locals = resolveEventsScaffoldLocals({
11341
11691
  cwd,
11342
11692
  config,
11343
- fileExists: (p) => fs11.existsSync(p)
11693
+ fileExists: (p) => fs13.existsSync(p)
11344
11694
  });
11345
11695
  const planned = [
11346
11696
  locals.configPath,
@@ -11396,7 +11746,7 @@ function runIntegrationScaffold(cwd, config, opts) {
11396
11746
  const locals = resolveIntegrationScaffoldLocals({
11397
11747
  cwd,
11398
11748
  config,
11399
- fileExists: (p) => fs11.existsSync(p)
11749
+ fileExists: (p) => fs13.existsSync(p)
11400
11750
  });
11401
11751
  const planned = [
11402
11752
  locals.configPath,
@@ -11451,7 +11801,7 @@ function runBridgeScaffold(cwd, config, opts) {
11451
11801
  const locals = resolveBridgeScaffoldLocals({
11452
11802
  cwd,
11453
11803
  config,
11454
- fileExists: (p) => fs11.existsSync(p)
11804
+ fileExists: (p) => fs13.existsSync(p)
11455
11805
  });
11456
11806
  const planned = [
11457
11807
  locals.configPath,
@@ -11505,7 +11855,7 @@ function runObservabilityScaffold(cwd, config, opts) {
11505
11855
  const locals = resolveObservabilityScaffoldLocals({
11506
11856
  cwd,
11507
11857
  config,
11508
- fileExists: (p) => fs11.existsSync(p)
11858
+ fileExists: (p) => fs13.existsSync(p)
11509
11859
  });
11510
11860
  const planned = [locals.configPath, locals.appModulePath];
11511
11861
  const configBlockOutcome = planConfigBlockAction(
@@ -11574,9 +11924,9 @@ function runAuthScaffold(cwd, config, opts) {
11574
11924
  if (opts.dryRun) {
11575
11925
  return { ok: true, planned, configBlockOutcome };
11576
11926
  }
11577
- if (!fs11.existsSync(locals.envConfigPath)) {
11578
- fs11.mkdirSync(path22.dirname(locals.envConfigPath), { recursive: true });
11579
- fs11.writeFileSync(locals.envConfigPath, "", "utf-8");
11927
+ if (!fs13.existsSync(locals.envConfigPath)) {
11928
+ fs13.mkdirSync(path24.dirname(locals.envConfigPath), { recursive: true });
11929
+ fs13.writeFileSync(locals.envConfigPath, "", "utf-8");
11580
11930
  }
11581
11931
  const result = invokeHygen({
11582
11932
  generator: "subsystem",
@@ -11612,57 +11962,57 @@ function runAuthScaffold(cwd, config, opts) {
11612
11962
  return { ok: true, planned, configBlockOutcome };
11613
11963
  }
11614
11964
  function authIntegrationsExamplesRoot() {
11615
- const pkgRoot = path22.resolve(import.meta.dirname, "..", "..", "..");
11616
- const topLevel = path22.join(pkgRoot, "examples", "auth-integrations");
11617
- if (fs11.existsSync(topLevel)) return topLevel;
11618
- return path22.join(pkgRoot, "dist", "examples", "auth-integrations");
11965
+ const pkgRoot = path24.resolve(import.meta.dirname, "..", "..", "..");
11966
+ const topLevel = path24.join(pkgRoot, "examples", "auth-integrations");
11967
+ if (fs13.existsSync(topLevel)) return topLevel;
11968
+ return path24.join(pkgRoot, "dist", "examples", "auth-integrations");
11619
11969
  }
11620
11970
  function copyTreeIdempotent(srcDir, destDir, force, transform) {
11621
11971
  const written = [];
11622
11972
  const skipped = [];
11623
11973
  const walk = (src, dest) => {
11624
- const entries = fs11.readdirSync(src, { withFileTypes: true });
11974
+ const entries = fs13.readdirSync(src, { withFileTypes: true });
11625
11975
  for (const entry of entries) {
11626
- const srcPath = path22.join(src, entry.name);
11627
- const destPath = path22.join(dest, entry.name);
11976
+ const srcPath = path24.join(src, entry.name);
11977
+ const destPath = path24.join(dest, entry.name);
11628
11978
  if (entry.isDirectory()) {
11629
- fs11.mkdirSync(destPath, { recursive: true });
11979
+ fs13.mkdirSync(destPath, { recursive: true });
11630
11980
  walk(srcPath, destPath);
11631
11981
  continue;
11632
11982
  }
11633
11983
  if (!entry.isFile()) continue;
11634
- if (fs11.existsSync(destPath) && !force) {
11984
+ if (fs13.existsSync(destPath) && !force) {
11635
11985
  skipped.push(destPath);
11636
11986
  continue;
11637
11987
  }
11638
- fs11.mkdirSync(path22.dirname(destPath), { recursive: true });
11988
+ fs13.mkdirSync(path24.dirname(destPath), { recursive: true });
11639
11989
  const isTextSource = transform && (entry.name.endsWith(".ts") || entry.name.endsWith(".tsx"));
11640
11990
  if (isTextSource && transform) {
11641
- const raw = fs11.readFileSync(srcPath, "utf-8");
11642
- fs11.writeFileSync(destPath, transform(raw, destPath), "utf-8");
11991
+ const raw = fs13.readFileSync(srcPath, "utf-8");
11992
+ fs13.writeFileSync(destPath, transform(raw, destPath), "utf-8");
11643
11993
  } else {
11644
- fs11.copyFileSync(srcPath, destPath);
11994
+ fs13.copyFileSync(srcPath, destPath);
11645
11995
  }
11646
11996
  written.push(destPath);
11647
11997
  }
11648
11998
  };
11649
- if (!fs11.existsSync(srcDir)) return { written, skipped };
11650
- fs11.mkdirSync(destDir, { recursive: true });
11999
+ if (!fs13.existsSync(srcDir)) return { written, skipped };
12000
+ fs13.mkdirSync(destDir, { recursive: true });
11651
12001
  walk(srcDir, destDir);
11652
12002
  return { written, skipped };
11653
12003
  }
11654
12004
  var AUTH_BARE_IMPORT_RE = /(['"])@pattern-stack\/codegen\/runtime\/subsystems\/auth\1/g;
11655
12005
  function buildAuthImportRewriter(subsystemsRoot) {
11656
- const authRoot = path22.join(subsystemsRoot, "auth");
12006
+ const authRoot = path24.join(subsystemsRoot, "auth");
11657
12007
  return (content, destPath) => {
11658
12008
  if (!AUTH_BARE_IMPORT_RE.test(content)) {
11659
12009
  AUTH_BARE_IMPORT_RE.lastIndex = 0;
11660
12010
  return content;
11661
12011
  }
11662
12012
  AUTH_BARE_IMPORT_RE.lastIndex = 0;
11663
- let rel2 = path22.relative(path22.dirname(destPath), authRoot);
12013
+ let rel2 = path24.relative(path24.dirname(destPath), authRoot);
11664
12014
  if (!rel2.startsWith(".")) rel2 = `./${rel2}`;
11665
- const relPosix = rel2.split(path22.sep).join("/");
12015
+ const relPosix = rel2.split(path24.sep).join("/");
11666
12016
  return content.replace(
11667
12017
  AUTH_BARE_IMPORT_RE,
11668
12018
  (_match, quote) => `${quote}${relPosix}${quote}`
@@ -11673,20 +12023,20 @@ function runAuthIntegrationsScaffold(cwd, config, opts) {
11673
12023
  const locals = resolveAuthIntegrationsScaffoldLocals({
11674
12024
  cwd,
11675
12025
  config,
11676
- fileExists: (p) => fs11.existsSync(p),
11677
- readFile: (p) => fs11.existsSync(p) ? fs11.readFileSync(p, "utf-8") : null
12026
+ fileExists: (p) => fs13.existsSync(p),
12027
+ readFile: (p) => fs13.existsSync(p) ? fs13.readFileSync(p, "utf-8") : null
11678
12028
  });
11679
12029
  const examplesRoot = authIntegrationsExamplesRoot();
11680
- if (!fs11.existsSync(examplesRoot)) {
12030
+ if (!fs13.existsSync(examplesRoot)) {
11681
12031
  return {
11682
12032
  ok: false,
11683
12033
  planned: [],
11684
12034
  error: `auth-integrations starter source missing: ${examplesRoot}`
11685
12035
  };
11686
12036
  }
11687
- const adaptersSrc = path22.join(examplesRoot, "runtime", "connections");
11688
- const adaptersDest = path22.join(locals.vendorRoot, "connections");
11689
- const connectionYamlSrc = path22.join(
12037
+ const adaptersSrc = path24.join(examplesRoot, "runtime", "connections");
12038
+ const adaptersDest = path24.join(locals.vendorRoot, "connections");
12039
+ const connectionYamlSrc = path24.join(
11690
12040
  examplesRoot,
11691
12041
  "definitions",
11692
12042
  "entities",
@@ -11715,11 +12065,11 @@ function runAuthIntegrationsScaffold(cwd, config, opts) {
11715
12065
  let yamlWritten = false;
11716
12066
  let yamlSkipped = false;
11717
12067
  try {
11718
- if (fs11.existsSync(connectionYamlDest) && !opts.force) {
12068
+ if (fs13.existsSync(connectionYamlDest) && !opts.force) {
11719
12069
  yamlSkipped = true;
11720
- } else if (fs11.existsSync(connectionYamlSrc)) {
11721
- fs11.mkdirSync(path22.dirname(connectionYamlDest), { recursive: true });
11722
- fs11.copyFileSync(connectionYamlSrc, connectionYamlDest);
12070
+ } else if (fs13.existsSync(connectionYamlSrc)) {
12071
+ fs13.mkdirSync(path24.dirname(connectionYamlDest), { recursive: true });
12072
+ fs13.copyFileSync(connectionYamlSrc, connectionYamlDest);
11723
12073
  yamlWritten = true;
11724
12074
  }
11725
12075
  } catch (err) {
@@ -11784,7 +12134,7 @@ var SubsystemListCommand = class extends Command3 {
11784
12134
  name: s.name,
11785
12135
  status: inst ? inst.status : "available",
11786
12136
  backend: inst ? inst.backend : null,
11787
- path: inst ? path22.relative(ctx.cwd, inst.path) || inst.path : null
12137
+ path: inst ? path24.relative(ctx.cwd, inst.path) || inst.path : null
11788
12138
  };
11789
12139
  });
11790
12140
  if (isJsonMode()) {
@@ -11873,14 +12223,14 @@ var SubsystemRemoveCommand = class extends Command3 {
11873
12223
  return 1;
11874
12224
  }
11875
12225
  const subsystemDir = target.path;
11876
- if (!fs11.existsSync(subsystemDir)) {
12226
+ if (!fs13.existsSync(subsystemDir)) {
11877
12227
  printError(
11878
12228
  `Detected install at ${subsystemDir} but the directory is gone \u2014 refusing to act.`
11879
12229
  );
11880
12230
  return 1;
11881
12231
  }
11882
12232
  if (!this.force) {
11883
- const rel2 = path22.relative(ctx.cwd, subsystemDir) || subsystemDir;
12233
+ const rel2 = path24.relative(ctx.cwd, subsystemDir) || subsystemDir;
11884
12234
  const gitCheck = checkGitSafety([rel2], ctx.cwd);
11885
12235
  if (gitCheck.inRepo && !gitCheck.clean) {
11886
12236
  printWarning(
@@ -11890,7 +12240,7 @@ var SubsystemRemoveCommand = class extends Command3 {
11890
12240
  }
11891
12241
  }
11892
12242
  try {
11893
- fs11.rmSync(subsystemDir, { recursive: true, force: true });
12243
+ fs13.rmSync(subsystemDir, { recursive: true, force: true });
11894
12244
  } catch (err) {
11895
12245
  const message = err instanceof Error ? err.message : String(err);
11896
12246
  printError(`Failed to remove ${subsystemDir}: ${message}`);
@@ -11916,7 +12266,7 @@ var SubsystemRemoveCommand = class extends Command3 {
11916
12266
  return 0;
11917
12267
  }
11918
12268
  printSuccess(
11919
- `${desc3.name} subsystem removed (${path22.relative(ctx.cwd, subsystemDir) || subsystemDir}).`
12269
+ `${desc3.name} subsystem removed (${path24.relative(ctx.cwd, subsystemDir) || subsystemDir}).`
11920
12270
  );
11921
12271
  if (barrelRegenerated) {
11922
12272
  printInfo("Regenerated <generated>/subsystems.ts barrel.");
@@ -11944,28 +12294,28 @@ var subsystemNoun = {
11944
12294
  var subsystem_default = subsystemNoun;
11945
12295
 
11946
12296
  // src/cli/commands/project.ts
11947
- import fs17 from "fs";
11948
- import path28 from "path";
12297
+ import fs19 from "fs";
12298
+ import path30 from "path";
11949
12299
  import readline from "readline";
11950
12300
  import { Command as Command7, Option as Option7 } from "clipanion";
11951
12301
  import { stringify as stringifyYaml2 } from "yaml";
11952
12302
 
11953
12303
  // src/cli/shared/init-scaffold.ts
11954
- import fs12 from "fs";
11955
- import path23 from "path";
12304
+ import fs14 from "fs";
12305
+ import path25 from "path";
11956
12306
  import { stringify as stringifyYaml } from "yaml";
11957
12307
  function runtimeRoot2() {
11958
- const pkgRoot = path23.resolve(import.meta.dirname, "..", "..", "..");
11959
- const topLevel = path23.join(pkgRoot, "runtime");
11960
- if (fs12.existsSync(topLevel)) return topLevel;
11961
- return path23.join(pkgRoot, "dist", "runtime");
12308
+ const pkgRoot = path25.resolve(import.meta.dirname, "..", "..", "..");
12309
+ const topLevel = path25.join(pkgRoot, "runtime");
12310
+ if (fs14.existsSync(topLevel)) return topLevel;
12311
+ return path25.join(pkgRoot, "dist", "runtime");
11962
12312
  }
11963
12313
  function resolveRuntimePath(cwd) {
11964
- const shimDir = path23.join(cwd, "src", "shared", "base-classes");
11965
- return path23.relative(shimDir, runtimeRoot2());
12314
+ const shimDir = path25.join(cwd, "src", "shared", "base-classes");
12315
+ return path25.relative(shimDir, runtimeRoot2());
11966
12316
  }
11967
12317
  function loadRuntimeFile(relPath2) {
11968
- return fs12.readFileSync(path23.join(runtimeRoot2(), relPath2), "utf-8");
12318
+ return fs14.readFileSync(path25.join(runtimeRoot2(), relPath2), "utf-8");
11969
12319
  }
11970
12320
  var VENDORED_RUNTIME_FILES = [
11971
12321
  // base-classes — consumer-facing inheritance targets
@@ -12382,10 +12732,10 @@ function mergeTsconfig(raw) {
12382
12732
  };
12383
12733
  }
12384
12734
  function relOf(cwd, abs) {
12385
- return path23.relative(cwd, abs) || abs;
12735
+ return path25.relative(cwd, abs) || abs;
12386
12736
  }
12387
12737
  function fileEntry(cwd, absPath, content, opts) {
12388
- const exists = fs12.existsSync(absPath);
12738
+ const exists = fs14.existsSync(absPath);
12389
12739
  let action;
12390
12740
  let reason = opts.skipReason;
12391
12741
  if (!exists) {
@@ -12400,7 +12750,7 @@ function fileEntry(cwd, absPath, content, opts) {
12400
12750
  return { path: absPath, relPath: relOf(cwd, absPath), action, content, reason };
12401
12751
  }
12402
12752
  function dirEntry(cwd, absPath) {
12403
- const exists = fs12.existsSync(absPath);
12753
+ const exists = fs14.existsSync(absPath);
12404
12754
  return {
12405
12755
  path: absPath,
12406
12756
  relPath: relOf(cwd, absPath),
@@ -12433,7 +12783,7 @@ async function buildInitPlan(ctx, options) {
12433
12783
  const runtimePath = options.runtimePath ?? resolveRuntimePath(cwd);
12434
12784
  const entries = [];
12435
12785
  {
12436
- const configPath = path23.join(cwd, "codegen.config.yaml");
12786
+ const configPath = path25.join(cwd, "codegen.config.yaml");
12437
12787
  const config = {
12438
12788
  // Runtime mode (ADR-037). `package` (default) imports the runtime from
12439
12789
  // `@pattern-stack/codegen/*`; `vendored` imports it via `@shared/*` and
@@ -12468,9 +12818,9 @@ async function buildInitPlan(ctx, options) {
12468
12818
  entries.push(fileEntry(cwd, configPath, content, { force }));
12469
12819
  }
12470
12820
  {
12471
- const tsconfigPath = path23.join(cwd, "tsconfig.json");
12472
- if (fs12.existsSync(tsconfigPath)) {
12473
- const raw = fs12.readFileSync(tsconfigPath, "utf-8");
12821
+ const tsconfigPath = path25.join(cwd, "tsconfig.json");
12822
+ if (fs14.existsSync(tsconfigPath)) {
12823
+ const raw = fs14.readFileSync(tsconfigPath, "utf-8");
12474
12824
  const merged = mergeTsconfig(raw);
12475
12825
  if (merged.parseError) {
12476
12826
  entries.push({
@@ -12515,7 +12865,7 @@ async function buildInitPlan(ctx, options) {
12515
12865
  entries.push(
12516
12866
  fileEntry(
12517
12867
  cwd,
12518
- path23.join(cwd, "src", "shared", "database", "database.module.ts"),
12868
+ path25.join(cwd, "src", "shared", "database", "database.module.ts"),
12519
12869
  databaseModuleContent(runtimeMode),
12520
12870
  { force }
12521
12871
  )
@@ -12523,14 +12873,14 @@ async function buildInitPlan(ctx, options) {
12523
12873
  if (runtimeMode === "vendored") {
12524
12874
  for (const v of VENDORED_RUNTIME_FILES) {
12525
12875
  entries.push(
12526
- fileEntry(cwd, path23.join(cwd, v.target), loadRuntimeFile(v.runtime), { force })
12876
+ fileEntry(cwd, path25.join(cwd, v.target), loadRuntimeFile(v.runtime), { force })
12527
12877
  );
12528
12878
  }
12529
12879
  }
12530
12880
  entries.push(
12531
12881
  fileEntry(
12532
12882
  cwd,
12533
- path23.join(cwd, "src", "generated", "modules.ts"),
12883
+ path25.join(cwd, "src", "generated", "modules.ts"),
12534
12884
  emptyModulesBarrel(),
12535
12885
  { force }
12536
12886
  )
@@ -12538,14 +12888,14 @@ async function buildInitPlan(ctx, options) {
12538
12888
  entries.push(
12539
12889
  fileEntry(
12540
12890
  cwd,
12541
- path23.join(cwd, "src", "generated", "schema.ts"),
12891
+ path25.join(cwd, "src", "generated", "schema.ts"),
12542
12892
  emptySchemaBarrel(),
12543
12893
  { force }
12544
12894
  )
12545
12895
  );
12546
12896
  {
12547
- const appModulePath = path23.join(cwd, "src", "app.module.ts");
12548
- if (!fs12.existsSync(appModulePath)) {
12897
+ const appModulePath = path25.join(cwd, "src", "app.module.ts");
12898
+ if (!fs14.existsSync(appModulePath)) {
12549
12899
  entries.push({
12550
12900
  path: appModulePath,
12551
12901
  relPath: relOf(cwd, appModulePath),
@@ -12562,8 +12912,8 @@ async function buildInitPlan(ctx, options) {
12562
12912
  }
12563
12913
  }
12564
12914
  {
12565
- const mainPath = path23.join(cwd, "src", "main.ts");
12566
- if (!fs12.existsSync(mainPath)) {
12915
+ const mainPath = path25.join(cwd, "src", "main.ts");
12916
+ if (!fs14.existsSync(mainPath)) {
12567
12917
  entries.push({
12568
12918
  path: mainPath,
12569
12919
  relPath: relOf(cwd, mainPath),
@@ -12580,8 +12930,8 @@ async function buildInitPlan(ctx, options) {
12580
12930
  }
12581
12931
  }
12582
12932
  {
12583
- const schemaPath = path23.join(cwd, "src", "schema.ts");
12584
- if (!fs12.existsSync(schemaPath)) {
12933
+ const schemaPath = path25.join(cwd, "src", "schema.ts");
12934
+ if (!fs14.existsSync(schemaPath)) {
12585
12935
  entries.push({
12586
12936
  path: schemaPath,
12587
12937
  relPath: relOf(cwd, schemaPath),
@@ -12597,14 +12947,14 @@ async function buildInitPlan(ctx, options) {
12597
12947
  });
12598
12948
  }
12599
12949
  }
12600
- entries.push(dirEntry(cwd, path23.join(cwd, "entities")));
12950
+ entries.push(dirEntry(cwd, path25.join(cwd, "entities")));
12601
12951
  {
12602
- const entitiesDir = path23.join(cwd, "entities");
12603
- const examplePath = path23.join(entitiesDir, "example.yaml");
12604
- const hasOtherYamls = fs12.existsSync(entitiesDir) && findYamlFiles(entitiesDir).some(
12605
- (f) => path23.basename(f) !== "example.yaml"
12952
+ const entitiesDir = path25.join(cwd, "entities");
12953
+ const examplePath = path25.join(entitiesDir, "example.yaml");
12954
+ const hasOtherYamls = fs14.existsSync(entitiesDir) && findYamlFiles(entitiesDir).some(
12955
+ (f) => path25.basename(f) !== "example.yaml"
12606
12956
  );
12607
- if (fs12.existsSync(examplePath)) {
12957
+ if (fs14.existsSync(examplePath)) {
12608
12958
  entries.push({
12609
12959
  path: examplePath,
12610
12960
  relPath: relOf(cwd, examplePath),
@@ -12650,7 +13000,7 @@ function writePlan(plan) {
12650
13000
  continue;
12651
13001
  }
12652
13002
  if (e.directory) {
12653
- fs12.mkdirSync(e.path, { recursive: true });
13003
+ fs14.mkdirSync(e.path, { recursive: true });
12654
13004
  created.push(e);
12655
13005
  continue;
12656
13006
  }
@@ -12658,8 +13008,8 @@ function writePlan(plan) {
12658
13008
  skipped.push(e);
12659
13009
  continue;
12660
13010
  }
12661
- fs12.mkdirSync(path23.dirname(e.path), { recursive: true });
12662
- fs12.writeFileSync(e.path, e.content, "utf-8");
13011
+ fs14.mkdirSync(path25.dirname(e.path), { recursive: true });
13012
+ fs14.writeFileSync(e.path, e.content, "utf-8");
12663
13013
  if (e.action === "create") created.push(e);
12664
13014
  else if (e.action === "merge") merged.push(e);
12665
13015
  else if (e.action === "overwrite") overwritten.push(e);
@@ -12668,8 +13018,8 @@ function writePlan(plan) {
12668
13018
  }
12669
13019
 
12670
13020
  // src/cli/commands/project-upgrade-openapi.ts
12671
- import fs13 from "fs";
12672
- import path24 from "path";
13021
+ import fs15 from "fs";
13022
+ import path26 from "path";
12673
13023
  import { Command as Command4, Option as Option4 } from "clipanion";
12674
13024
  import { Project, IndentationText, QuoteKind, NewLineKind } from "ts-morph";
12675
13025
 
@@ -12908,35 +13258,35 @@ var MAIN_SWAGGER_IMPORTS = [
12908
13258
  "import { OPENAPI_REGISTRY, OpenApiRegistry } from './shared/openapi';"
12909
13259
  ];
12910
13260
  function runtimeRoot3() {
12911
- const pkgRoot = path24.resolve(import.meta.dirname, "..", "..", "..");
12912
- const topLevel = path24.join(pkgRoot, "runtime");
12913
- if (fs13.existsSync(topLevel)) return topLevel;
12914
- return path24.join(pkgRoot, "dist", "runtime");
13261
+ const pkgRoot = path26.resolve(import.meta.dirname, "..", "..", "..");
13262
+ const topLevel = path26.join(pkgRoot, "runtime");
13263
+ if (fs15.existsSync(topLevel)) return topLevel;
13264
+ return path26.join(pkgRoot, "dist", "runtime");
12915
13265
  }
12916
13266
  function loadRuntimeFile2(rel2) {
12917
- return fs13.readFileSync(path24.join(runtimeRoot3(), rel2), "utf-8");
13267
+ return fs15.readFileSync(path26.join(runtimeRoot3(), rel2), "utf-8");
12918
13268
  }
12919
13269
  function resolveProjectRoot(startDir) {
12920
- let dir = path24.resolve(startDir);
13270
+ let dir = path26.resolve(startDir);
12921
13271
  for (let i = 0; i < 16; i++) {
12922
- if (fs13.existsSync(path24.join(dir, "codegen.config.yaml")) || fs13.existsSync(path24.join(dir, "package.json"))) {
13272
+ if (fs15.existsSync(path26.join(dir, "codegen.config.yaml")) || fs15.existsSync(path26.join(dir, "package.json"))) {
12923
13273
  return dir;
12924
13274
  }
12925
- const parent = path24.dirname(dir);
13275
+ const parent = path26.dirname(dir);
12926
13276
  if (parent === dir) break;
12927
13277
  dir = parent;
12928
13278
  }
12929
- return path24.resolve(startDir);
13279
+ return path26.resolve(startDir);
12930
13280
  }
12931
13281
  async function runUpgradeOpenapi(opts) {
12932
13282
  const { projectRoot, dryRun, force } = opts;
12933
13283
  const changes = [];
12934
13284
  for (const v of OPENAPI_VENDORED_FILES) {
12935
- const target = path24.join(projectRoot, v.target);
12936
- const exists = fs13.existsSync(target);
13285
+ const target = path26.join(projectRoot, v.target);
13286
+ const exists = fs15.existsSync(target);
12937
13287
  const newContent = loadRuntimeFile2(v.runtime);
12938
13288
  if (exists && !force) {
12939
- const existing = fs13.readFileSync(target, "utf-8");
13289
+ const existing = fs15.readFileSync(target, "utf-8");
12940
13290
  if (existing === newContent) {
12941
13291
  changes.push({ path: v.target, action: "unchanged" });
12942
13292
  } else {
@@ -12948,8 +13298,8 @@ async function runUpgradeOpenapi(opts) {
12948
13298
  }
12949
13299
  } else {
12950
13300
  if (!dryRun) {
12951
- fs13.mkdirSync(path24.dirname(target), { recursive: true });
12952
- fs13.writeFileSync(target, newContent);
13301
+ fs15.mkdirSync(path26.dirname(target), { recursive: true });
13302
+ fs15.writeFileSync(target, newContent);
12953
13303
  }
12954
13304
  changes.push({
12955
13305
  path: v.target,
@@ -12957,8 +13307,8 @@ async function runUpgradeOpenapi(opts) {
12957
13307
  });
12958
13308
  }
12959
13309
  }
12960
- const appModulePath = path24.join(projectRoot, "src", "app.module.ts");
12961
- if (!fs13.existsSync(appModulePath)) {
13310
+ const appModulePath = path26.join(projectRoot, "src", "app.module.ts");
13311
+ if (!fs15.existsSync(appModulePath)) {
12962
13312
  return {
12963
13313
  projectRoot,
12964
13314
  changes,
@@ -13041,8 +13391,8 @@ async function runUpgradeOpenapi(opts) {
13041
13391
  } else {
13042
13392
  changes.push({ path: "src/app.module.ts", action: "unchanged" });
13043
13393
  }
13044
- const mainPath = path24.join(projectRoot, "src", "main.ts");
13045
- if (fs13.existsSync(mainPath)) {
13394
+ const mainPath = path26.join(projectRoot, "src", "main.ts");
13395
+ if (fs15.existsSync(mainPath)) {
13046
13396
  const mainSource = project.addSourceFileAtPath(mainPath);
13047
13397
  const mainBefore = mainSource.getFullText();
13048
13398
  const result = ensureMainSwaggerBlock(mainSource, {
@@ -13122,8 +13472,8 @@ var ProjectUpgradeOpenapiCommand = class extends Command4 {
13122
13472
  json = Option4.Boolean("--json", false);
13123
13473
  async execute() {
13124
13474
  if (this.json) setJsonMode(true);
13125
- const startDir = this.pathOpt ? path24.resolve(this.pathOpt) : process.cwd();
13126
- if (!fs13.existsSync(startDir)) {
13475
+ const startDir = this.pathOpt ? path26.resolve(this.pathOpt) : process.cwd();
13476
+ if (!fs15.existsSync(startDir)) {
13127
13477
  printError(`Directory not found: ${startDir}`);
13128
13478
  return 1;
13129
13479
  }
@@ -13198,18 +13548,18 @@ ${CONSUMER_SETUP_POINTER}
13198
13548
  };
13199
13549
 
13200
13550
  // src/cli/commands/project-update.ts
13201
- import fs16 from "fs";
13202
- import path27 from "path";
13551
+ import fs18 from "fs";
13552
+ import path29 from "path";
13203
13553
  import { Command as Command6, Option as Option6 } from "clipanion";
13204
13554
 
13205
13555
  // src/cli/commands/skills.ts
13206
- import fs15 from "fs";
13207
- import path26 from "path";
13556
+ import fs17 from "fs";
13557
+ import path28 from "path";
13208
13558
  import { Command as Command5, Option as Option5 } from "clipanion";
13209
13559
 
13210
13560
  // src/cli/shared/tree-copier.ts
13211
- import fs14 from "fs";
13212
- import path25 from "path";
13561
+ import fs16 from "fs";
13562
+ import path27 from "path";
13213
13563
  var TEXT_EXTENSIONS = [".ts", ".tsx", ".md", ".mdx", ".yaml", ".yml", ".json"];
13214
13564
  function isTextFile(name) {
13215
13565
  return TEXT_EXTENSIONS.some((ext) => name.endsWith(ext));
@@ -13222,26 +13572,26 @@ function copyTreeWithReport(opts) {
13222
13572
  updated: [],
13223
13573
  unchanged: []
13224
13574
  };
13225
- if (!fs14.existsSync(srcDir) || !fs14.statSync(srcDir).isDirectory()) {
13575
+ if (!fs16.existsSync(srcDir) || !fs16.statSync(srcDir).isDirectory()) {
13226
13576
  throw new Error(`tree-copier source directory not found: ${srcDir}`);
13227
13577
  }
13228
13578
  const walk = (relDir) => {
13229
- const absSrcDir = path25.join(srcDir, relDir);
13230
- for (const entry of fs14.readdirSync(absSrcDir, { withFileTypes: true })) {
13231
- const relPath2 = relDir ? path25.posix.join(relDir, entry.name) : entry.name;
13232
- const absSrc = path25.join(srcDir, relPath2);
13579
+ const absSrcDir = path27.join(srcDir, relDir);
13580
+ for (const entry of fs16.readdirSync(absSrcDir, { withFileTypes: true })) {
13581
+ const relPath2 = relDir ? path27.posix.join(relDir, entry.name) : entry.name;
13582
+ const absSrc = path27.join(srcDir, relPath2);
13233
13583
  if (entry.isDirectory()) {
13234
13584
  walk(relPath2);
13235
13585
  continue;
13236
13586
  }
13237
13587
  if (!entry.isFile()) continue;
13238
13588
  if (include && !include(relPath2)) continue;
13239
- const dest = path25.join(destDir, relPath2);
13240
- let content = fs14.readFileSync(absSrc, "utf-8");
13589
+ const dest = path27.join(destDir, relPath2);
13590
+ let content = fs16.readFileSync(absSrc, "utf-8");
13241
13591
  if (transform && isTextFile(entry.name)) {
13242
13592
  content = transform(content, dest);
13243
13593
  }
13244
- const existing = fs14.existsSync(dest) ? fs14.readFileSync(dest, "utf-8") : null;
13594
+ const existing = fs16.existsSync(dest) ? fs16.readFileSync(dest, "utf-8") : null;
13245
13595
  let action;
13246
13596
  if (existing === null) {
13247
13597
  action = "created";
@@ -13251,8 +13601,8 @@ function copyTreeWithReport(opts) {
13251
13601
  action = "updated";
13252
13602
  }
13253
13603
  if (!dryRun && action !== "unchanged") {
13254
- fs14.mkdirSync(path25.dirname(dest), { recursive: true });
13255
- fs14.writeFileSync(dest, content, "utf-8");
13604
+ fs16.mkdirSync(path27.dirname(dest), { recursive: true });
13605
+ fs16.writeFileSync(dest, content, "utf-8");
13256
13606
  }
13257
13607
  const record = { relPath: relPath2, dest, action };
13258
13608
  report.entries.push(record);
@@ -13265,23 +13615,23 @@ function copyTreeWithReport(opts) {
13265
13615
 
13266
13616
  // src/cli/commands/skills.ts
13267
13617
  function consumerSkillsRoot() {
13268
- const pkgRoot = path26.resolve(import.meta.dirname, "..", "..", "..");
13269
- const topLevel = path26.join(pkgRoot, "consumer-skills");
13270
- if (fs15.existsSync(topLevel)) return topLevel;
13271
- return path26.join(pkgRoot, "dist", "consumer-skills");
13618
+ const pkgRoot = path28.resolve(import.meta.dirname, "..", "..", "..");
13619
+ const topLevel = path28.join(pkgRoot, "consumer-skills");
13620
+ if (fs17.existsSync(topLevel)) return topLevel;
13621
+ return path28.join(pkgRoot, "dist", "consumer-skills");
13272
13622
  }
13273
13623
  function skillsTargetDir(cwd) {
13274
- return path26.join(cwd, ".claude", "skills");
13624
+ return path28.join(cwd, ".claude", "skills");
13275
13625
  }
13276
13626
  function availableSkills() {
13277
13627
  const root = consumerSkillsRoot();
13278
- if (!fs15.existsSync(root)) return [];
13279
- return fs15.readdirSync(root, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name).sort();
13628
+ if (!fs17.existsSync(root)) return [];
13629
+ return fs17.readdirSync(root, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name).sort();
13280
13630
  }
13281
13631
  function runSkillsInstall(opts) {
13282
13632
  const sourceRoot = consumerSkillsRoot();
13283
13633
  const targetDir = skillsTargetDir(opts.cwd);
13284
- if (!fs15.existsSync(sourceRoot)) {
13634
+ if (!fs17.existsSync(sourceRoot)) {
13285
13635
  return {
13286
13636
  ok: false,
13287
13637
  sourceRoot,
@@ -13299,8 +13649,8 @@ function runSkillsInstall(opts) {
13299
13649
  async function summary3(ctx) {
13300
13650
  const skills = availableSkills();
13301
13651
  const targetDir = skillsTargetDir(ctx.cwd);
13302
- const installedDirs = fs15.existsSync(targetDir) ? new Set(
13303
- fs15.readdirSync(targetDir, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name)
13652
+ const installedDirs = fs17.existsSync(targetDir) ? new Set(
13653
+ fs17.readdirSync(targetDir, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name)
13304
13654
  ) : /* @__PURE__ */ new Set();
13305
13655
  const body = [];
13306
13656
  if (skills.length === 0) {
@@ -13318,13 +13668,13 @@ async function summary3(ctx) {
13318
13668
  return {
13319
13669
  title: "skills",
13320
13670
  body,
13321
- footer: `${installedCount} of ${skills.length} skills installed \u2192 ${path26.relative(ctx.cwd, targetDir) || targetDir}`
13671
+ footer: `${installedCount} of ${skills.length} skills installed \u2192 ${path28.relative(ctx.cwd, targetDir) || targetDir}`
13322
13672
  };
13323
13673
  }
13324
13674
  async function hints3(ctx) {
13325
13675
  const skills = availableSkills();
13326
13676
  const targetDir = skillsTargetDir(ctx.cwd);
13327
- const allPresent = skills.length > 0 && fs15.existsSync(targetDir) && skills.every((s) => fs15.existsSync(path26.join(targetDir, s)));
13677
+ const allPresent = skills.length > 0 && fs17.existsSync(targetDir) && skills.every((s) => fs17.existsSync(path28.join(targetDir, s)));
13328
13678
  if (allPresent) {
13329
13679
  return [
13330
13680
  { command: "codegen update", description: "Re-sync skills + runtime after a package bump" }
@@ -13399,7 +13749,7 @@ var SkillsInstallCommand = class extends Command5 {
13399
13749
  });
13400
13750
  return 0;
13401
13751
  }
13402
- printInfo(`target = ${path26.relative(ctx.cwd, result.targetDir) || result.targetDir}`);
13752
+ printInfo(`target = ${path28.relative(ctx.cwd, result.targetDir) || result.targetDir}`);
13403
13753
  console.log("");
13404
13754
  renderTreeReport(report);
13405
13755
  console.log("");
@@ -13427,8 +13777,8 @@ var SkillsListCommand = class extends Command5 {
13427
13777
  const skills = availableSkills();
13428
13778
  const targetDir = skillsTargetDir(ctx.cwd);
13429
13779
  const rows = skills.map((name) => {
13430
- const dir = path26.join(targetDir, name);
13431
- return { name, status: fs15.existsSync(dir) ? "installed" : "available" };
13780
+ const dir = path28.join(targetDir, name);
13781
+ return { name, status: fs17.existsSync(dir) ? "installed" : "available" };
13432
13782
  });
13433
13783
  if (isJsonMode()) {
13434
13784
  printJson({ command: "skills list", target: targetDir, skills: rows });
@@ -13457,16 +13807,16 @@ var NON_RUNTIME_SUBSYSTEMS = /* @__PURE__ */ new Set(["openapi-config", "auth-in
13457
13807
  function syncVendoredRuntime(cwd, write) {
13458
13808
  const changes = [];
13459
13809
  for (const v of VENDORED_RUNTIME_FILES) {
13460
- const dest = path27.join(cwd, v.target);
13810
+ const dest = path29.join(cwd, v.target);
13461
13811
  const content = loadRuntimeFile(v.runtime);
13462
- const existing = fs16.existsSync(dest) ? fs16.readFileSync(dest, "utf-8") : null;
13812
+ const existing = fs18.existsSync(dest) ? fs18.readFileSync(dest, "utf-8") : null;
13463
13813
  let action;
13464
13814
  if (existing === null) action = "created";
13465
13815
  else if (existing === content) action = "unchanged";
13466
13816
  else action = "updated";
13467
13817
  if (write && action !== "unchanged") {
13468
- fs16.mkdirSync(path27.dirname(dest), { recursive: true });
13469
- fs16.writeFileSync(dest, content, "utf-8");
13818
+ fs18.mkdirSync(path29.dirname(dest), { recursive: true });
13819
+ fs18.writeFileSync(dest, content, "utf-8");
13470
13820
  }
13471
13821
  changes.push({ path: v.target, action });
13472
13822
  }
@@ -13477,17 +13827,17 @@ async function syncSubsystemRuntime(cwd, inst, write) {
13477
13827
  return { name: inst.name, changes: [], skippedReason: "config-only / vendored elsewhere" };
13478
13828
  }
13479
13829
  const source = subsystemSource(inst.name);
13480
- if (!fs16.existsSync(source)) {
13830
+ if (!fs18.existsSync(source)) {
13481
13831
  return { name: inst.name, changes: [], skippedReason: "no runtime source in package" };
13482
13832
  }
13483
- const subsystemsRoot = path27.dirname(inst.path);
13833
+ const subsystemsRoot = path29.dirname(inst.path);
13484
13834
  const result = await copyRuntime({
13485
13835
  sourceDir: source,
13486
13836
  targetDir: inst.path,
13487
13837
  filter: backendFileFilter(inst.backend, inst.name),
13488
13838
  resolveDeps: true,
13489
13839
  runtimeRoot: runtimeRoot2(),
13490
- depsTargetRoot: path27.resolve(subsystemsRoot, ".."),
13840
+ depsTargetRoot: path29.resolve(subsystemsRoot, ".."),
13491
13841
  dryRun: !write,
13492
13842
  // Refresh files already vendored for this subsystem; never install new
13493
13843
  // ones (that's `subsystem install`). copyRuntime classifies accurately
@@ -13501,7 +13851,7 @@ async function syncSubsystemRuntime(cwd, inst, write) {
13501
13851
  return { name: inst.name, changes };
13502
13852
  }
13503
13853
  function rel(cwd, abs) {
13504
- return path27.relative(cwd, abs) || abs;
13854
+ return path29.relative(cwd, abs) || abs;
13505
13855
  }
13506
13856
  var ProjectUpdateCommand = class extends Command6 {
13507
13857
  static paths = [["project", "update"]];
@@ -13540,7 +13890,7 @@ var ProjectUpdateCommand = class extends Command6 {
13540
13890
  const installed = this.skipSubsystems ? [] : await detectInstalledSubsystems(ctx);
13541
13891
  if (!this.dryRun && !this.force) {
13542
13892
  const vendoredDry = syncVendoredRuntime(ctx.cwd, false);
13543
- const vendoredDirtyCandidates = vendoredDry.filter((c) => c.action === "updated").map((c) => path27.join(ctx.cwd, c.path));
13893
+ const vendoredDirtyCandidates = vendoredDry.filter((c) => c.action === "updated").map((c) => path29.join(ctx.cwd, c.path));
13544
13894
  const skillDirtyCandidates = this.skipSkills ? [] : runSkillsInstall({ cwd: ctx.cwd, dryRun: true }).report?.updated.map((e) => e.dest) ?? [];
13545
13895
  const subsystemDirs = installed.filter((i) => !NON_RUNTIME_SUBSYSTEMS.has(i.name)).map((i) => i.path);
13546
13896
  const gate = checkGitSafety(
@@ -13891,9 +14241,9 @@ var ProjectScanCommand = class extends Command7 {
13891
14241
  cwd = Option7.String("--cwd", { required: false });
13892
14242
  async execute() {
13893
14243
  if (this.json) setJsonMode(true);
13894
- const baseCwd = this.cwd ? path28.resolve(this.cwd) : process.cwd();
13895
- const target = this.directory ? path28.resolve(baseCwd, this.directory) : baseCwd;
13896
- if (!fs17.existsSync(target)) {
14244
+ const baseCwd = this.cwd ? path30.resolve(this.cwd) : process.cwd();
14245
+ const target = this.directory ? path30.resolve(baseCwd, this.directory) : baseCwd;
14246
+ if (!fs19.existsSync(target)) {
13897
14247
  printError(`Directory not found: ${target}`);
13898
14248
  return 1;
13899
14249
  }
@@ -13943,8 +14293,8 @@ var ProjectScanCommand = class extends Command7 {
13943
14293
  `architecture: ${profile.architecture.evidence.join(", ") || "\u2014"}`
13944
14294
  ]);
13945
14295
  }
13946
- const outPath = path28.join(target, "codegen.config.yaml");
13947
- const existsNow = fs17.existsSync(outPath);
14296
+ const outPath = path30.join(target, "codegen.config.yaml");
14297
+ const existsNow = fs19.existsSync(outPath);
13948
14298
  if (this.dryRun) {
13949
14299
  console.log("");
13950
14300
  printInfo("Dry run \u2014 proposed codegen.config.yaml:");
@@ -13957,7 +14307,7 @@ var ProjectScanCommand = class extends Command7 {
13957
14307
  printWarning(`${outPath} already exists \u2014 pass --force via edit; skipping.`);
13958
14308
  return 0;
13959
14309
  }
13960
- fs17.writeFileSync(outPath, yamlText);
14310
+ fs19.writeFileSync(outPath, yamlText);
13961
14311
  printSuccess(`wrote ${outPath}`);
13962
14312
  return 0;
13963
14313
  }
@@ -14064,12 +14414,12 @@ var ProjectInspectCommand = class extends Command7 {
14064
14414
  return 2;
14065
14415
  }
14066
14416
  resolveEntitiesDir(ctx) {
14067
- if (this.dir) return path28.resolve(ctx.cwd, this.dir);
14068
- return ctx.entitiesDir ?? path28.resolve(ctx.cwd, "entities");
14417
+ if (this.dir) return path30.resolve(ctx.cwd, this.dir);
14418
+ return ctx.entitiesDir ?? path30.resolve(ctx.cwd, "entities");
14069
14419
  }
14070
14420
  async runAnalysis(ctx, kind) {
14071
14421
  const entitiesDir = this.resolveEntitiesDir(ctx);
14072
- if (!entitiesDir || !fs17.existsSync(entitiesDir)) {
14422
+ if (!entitiesDir || !fs19.existsSync(entitiesDir)) {
14073
14423
  printError(`Directory not found: ${entitiesDir ?? "(no entities/ dir)"}`);
14074
14424
  return 1;
14075
14425
  }
@@ -14099,7 +14449,7 @@ var ProjectInspectCommand = class extends Command7 {
14099
14449
  out = formatConsole(filtered);
14100
14450
  }
14101
14451
  if (this.output) {
14102
- fs17.writeFileSync(this.output, out);
14452
+ fs19.writeFileSync(this.output, out);
14103
14453
  if (!isJsonMode()) printSuccess(`wrote ${this.output}`);
14104
14454
  } else {
14105
14455
  console.log(out);
@@ -14112,7 +14462,7 @@ var ProjectInspectCommand = class extends Command7 {
14112
14462
  }
14113
14463
  async runManifest(ctx) {
14114
14464
  const entitiesDir = this.resolveEntitiesDir(ctx);
14115
- if (!entitiesDir || !fs17.existsSync(entitiesDir)) {
14465
+ if (!entitiesDir || !fs19.existsSync(entitiesDir)) {
14116
14466
  printError(`Directory not found: ${entitiesDir ?? "(no entities/ dir)"}`);
14117
14467
  return 1;
14118
14468
  }
@@ -14268,17 +14618,17 @@ var ProjectGraphCommand = class extends Command7 {
14268
14618
  json: this.json,
14269
14619
  skipDetection: true
14270
14620
  });
14271
- const entitiesDir = this.dir ? path28.resolve(ctx.cwd, this.dir) : ctx.entitiesDir ?? path28.resolve(ctx.cwd, "entities");
14272
- if (!fs17.existsSync(entitiesDir)) {
14621
+ const entitiesDir = this.dir ? path30.resolve(ctx.cwd, this.dir) : ctx.entitiesDir ?? path30.resolve(ctx.cwd, "entities");
14622
+ if (!fs19.existsSync(entitiesDir)) {
14273
14623
  printError(`Entity directory not found: ${entitiesDir}`);
14274
14624
  return 1;
14275
14625
  }
14276
14626
  const relCandidates = [
14277
- path28.resolve(path28.dirname(entitiesDir), "relationships"),
14278
- path28.resolve(entitiesDir, "relationships"),
14279
- path28.resolve(ctx.cwd, "relationships")
14627
+ path30.resolve(path30.dirname(entitiesDir), "relationships"),
14628
+ path30.resolve(entitiesDir, "relationships"),
14629
+ path30.resolve(ctx.cwd, "relationships")
14280
14630
  ];
14281
- const relationshipsDir = relCandidates.find((d) => fs17.existsSync(d));
14631
+ const relationshipsDir = relCandidates.find((d) => fs19.existsSync(d));
14282
14632
  const result = await analyzeDomain(entitiesDir, relationshipsDir);
14283
14633
  const serialized = serializeDomainGraph(result.graph);
14284
14634
  if (isJsonMode()) {
@@ -14292,20 +14642,20 @@ var ProjectGraphCommand = class extends Command7 {
14292
14642
  return 0;
14293
14643
  }
14294
14644
  if (this.output) {
14295
- const outPath = path28.resolve(ctx.cwd, this.output);
14296
- fs17.writeFileSync(outPath, JSON.stringify(serialized, null, 2));
14645
+ const outPath = path30.resolve(ctx.cwd, this.output);
14646
+ fs19.writeFileSync(outPath, JSON.stringify(serialized, null, 2));
14297
14647
  printSuccess(`Graph written to ${outPath}`);
14298
14648
  printInfo(`${result.entities.length} entities, ${result.relationshipDefinitions.length} relationships, ${result.graph.edges.length} edges`);
14299
14649
  return 0;
14300
14650
  }
14301
14651
  const os = await import("os");
14302
- const tmpDir = fs17.mkdtempSync(path28.join(os.default.tmpdir(), "codegen-graph-"));
14303
- const graphPath = path28.join(tmpDir, "graph.json");
14304
- fs17.writeFileSync(graphPath, JSON.stringify(serialized, null, 2));
14305
- const viewerDir = path28.resolve(import.meta.dirname, "..", "..", "..", "tools", "schema-graph-viewer");
14306
- const viewerDist = path28.join(viewerDir, "dist", "index.html");
14307
- if (fs17.existsSync(viewerDist)) {
14308
- fs17.copyFileSync(graphPath, path28.join(viewerDir, "dist", "graph.json"));
14652
+ const tmpDir = fs19.mkdtempSync(path30.join(os.default.tmpdir(), "codegen-graph-"));
14653
+ const graphPath = path30.join(tmpDir, "graph.json");
14654
+ fs19.writeFileSync(graphPath, JSON.stringify(serialized, null, 2));
14655
+ const viewerDir = path30.resolve(import.meta.dirname, "..", "..", "..", "tools", "schema-graph-viewer");
14656
+ const viewerDist = path30.join(viewerDir, "dist", "index.html");
14657
+ if (fs19.existsSync(viewerDist)) {
14658
+ fs19.copyFileSync(graphPath, path30.join(viewerDir, "dist", "graph.json"));
14309
14659
  printSuccess("Graph exported");
14310
14660
  printInfo(`${result.entities.length} entities, ${result.relationshipDefinitions.length} relationships, ${result.graph.edges.length} edges`);
14311
14661
  printInfo(`Graph JSON: ${graphPath}`);
@@ -14336,8 +14686,8 @@ var projectNoun = {
14336
14686
  var project_default = projectNoun;
14337
14687
 
14338
14688
  // src/cli/commands/dev.ts
14339
- import fs18 from "fs";
14340
- import path29 from "path";
14689
+ import fs20 from "fs";
14690
+ import path31 from "path";
14341
14691
  import { execSync as execSync3, spawn, spawnSync } from "child_process";
14342
14692
  import { Command as Command8, Option as Option8 } from "clipanion";
14343
14693
  var DEFAULT_APP_PORT = 3e3;
@@ -14370,33 +14720,33 @@ function getRedisPort(_ctx) {
14370
14720
  return Number(process.env.DEV_REDIS_PORT ?? DEFAULT_REDIS_PORT);
14371
14721
  }
14372
14722
  function composeFilePath(cwd) {
14373
- const devPath = path29.join(cwd, COMPOSE_FILE);
14374
- if (fs18.existsSync(devPath)) return devPath;
14375
- const rootPath = path29.join(cwd, "docker-compose.yml");
14376
- if (fs18.existsSync(rootPath)) return rootPath;
14723
+ const devPath = path31.join(cwd, COMPOSE_FILE);
14724
+ if (fs20.existsSync(devPath)) return devPath;
14725
+ const rootPath = path31.join(cwd, "docker-compose.yml");
14726
+ if (fs20.existsSync(rootPath)) return rootPath;
14377
14727
  return devPath;
14378
14728
  }
14379
14729
  function pidFilePath(cwd) {
14380
- return path29.join(cwd, PID_FILE);
14730
+ return path31.join(cwd, PID_FILE);
14381
14731
  }
14382
14732
  function readAppPid(cwd) {
14383
14733
  const p = pidFilePath(cwd);
14384
- if (!fs18.existsSync(p)) return null;
14385
- const pid = parseInt(fs18.readFileSync(p, "utf-8").trim(), 10);
14734
+ if (!fs20.existsSync(p)) return null;
14735
+ const pid = parseInt(fs20.readFileSync(p, "utf-8").trim(), 10);
14386
14736
  if (isNaN(pid)) return null;
14387
14737
  try {
14388
14738
  process.kill(pid, 0);
14389
14739
  return pid;
14390
14740
  } catch {
14391
- fs18.rmSync(p, { force: true });
14741
+ fs20.rmSync(p, { force: true });
14392
14742
  return null;
14393
14743
  }
14394
14744
  }
14395
14745
  function writeAppPid(cwd, pid) {
14396
- fs18.writeFileSync(pidFilePath(cwd), String(pid));
14746
+ fs20.writeFileSync(pidFilePath(cwd), String(pid));
14397
14747
  }
14398
14748
  function clearAppPid(cwd) {
14399
- fs18.rmSync(pidFilePath(cwd), { force: true });
14749
+ fs20.rmSync(pidFilePath(cwd), { force: true });
14400
14750
  }
14401
14751
  function checkPostgres(cwd, port) {
14402
14752
  const r = runCmd(`docker exec codegen-dev-postgres pg_isready -U postgres`, cwd, {
@@ -14436,9 +14786,9 @@ function checkApp(cwd, port) {
14436
14786
  };
14437
14787
  }
14438
14788
  function listEntityNames(ctx) {
14439
- if (!ctx.entitiesDir || !fs18.existsSync(ctx.entitiesDir)) return [];
14789
+ if (!ctx.entitiesDir || !fs20.existsSync(ctx.entitiesDir)) return [];
14440
14790
  return findYamlFiles(ctx.entitiesDir).map(
14441
- (f) => path29.basename(f).replace(/\.ya?ml$/, "")
14791
+ (f) => path31.basename(f).replace(/\.ya?ml$/, "")
14442
14792
  );
14443
14793
  }
14444
14794
  function formatServiceLine(svc) {
@@ -14448,8 +14798,8 @@ function formatServiceLine(svc) {
14448
14798
  return `${icon} ${svc.name.padEnd(12)} ${theme.muted(`${svc.host}:${svc.port}`)} ${status}${pidStr}`;
14449
14799
  }
14450
14800
  function ensureComposeFile(cwd, pgPort, redisPort) {
14451
- const composePath = path29.join(cwd, COMPOSE_FILE);
14452
- if (fs18.existsSync(composePath)) return composePath;
14801
+ const composePath = path31.join(cwd, COMPOSE_FILE);
14802
+ if (fs20.existsSync(composePath)) return composePath;
14453
14803
  const content = `# Auto-generated by codegen dev
14454
14804
  # Ports offset from defaults to avoid conflicts with other local services.
14455
14805
  services:
@@ -14484,7 +14834,7 @@ services:
14484
14834
  volumes:
14485
14835
  codegen-dev-pgdata:
14486
14836
  `;
14487
- fs18.writeFileSync(composePath, content);
14837
+ fs20.writeFileSync(composePath, content);
14488
14838
  return composePath;
14489
14839
  }
14490
14840
  var DevUpCommand = class extends Command8 {
@@ -14533,7 +14883,7 @@ var DevUpCommand = class extends Command8 {
14533
14883
  if (!pgReady) printWarning("postgres did not become healthy in time");
14534
14884
  if (!redisReady) printWarning("redis did not become healthy in time");
14535
14885
  const drizzleConfig = ["drizzle.config.ts", "drizzle.config.js"].find(
14536
- (f) => fs18.existsSync(path29.join(ctx.cwd, f))
14886
+ (f) => fs20.existsSync(path31.join(ctx.cwd, f))
14537
14887
  );
14538
14888
  if (drizzleConfig) {
14539
14889
  if (!isJsonMode()) printInfo("pushing database schema...");
@@ -14553,8 +14903,8 @@ var DevUpCommand = class extends Command8 {
14553
14903
  if (!isJsonMode()) printInfo("starting NestJS app...");
14554
14904
  const dbUrl = `postgres://postgres:postgres@localhost:${pgPort}/codegen_dev`;
14555
14905
  const redisUrl = `redis://localhost:${redisPort}`;
14556
- const logFile = path29.join(ctx.cwd, ".dev-app.log");
14557
- const logFd = fs18.openSync(logFile, "a");
14906
+ const logFile = path31.join(ctx.cwd, ".dev-app.log");
14907
+ const logFd = fs20.openSync(logFile, "a");
14558
14908
  const child = spawn("bun", ["src/main.ts"], {
14559
14909
  cwd: ctx.cwd,
14560
14910
  detached: true,
@@ -14567,7 +14917,7 @@ var DevUpCommand = class extends Command8 {
14567
14917
  }
14568
14918
  });
14569
14919
  child.unref();
14570
- fs18.closeSync(logFd);
14920
+ fs20.closeSync(logFd);
14571
14921
  if (child.pid) {
14572
14922
  writeAppPid(ctx.cwd, child.pid);
14573
14923
  spawnSync("sleep", ["2"]);
@@ -14711,8 +15061,8 @@ var DevLogsCommand = class extends Command8 {
14711
15061
  }
14712
15062
  return 0;
14713
15063
  }
14714
- const logFile = path29.join(ctx.cwd, ".dev-app.log");
14715
- if (!fs18.existsSync(logFile)) {
15064
+ const logFile = path31.join(ctx.cwd, ".dev-app.log");
15065
+ if (!fs20.existsSync(logFile)) {
14716
15066
  printInfo("no app logs found \u2014 is the app running?");
14717
15067
  return 0;
14718
15068
  }
@@ -14755,8 +15105,8 @@ var DevRestartCommand = class extends Command8 {
14755
15105
  spawnSync("sleep", ["1"]);
14756
15106
  const dbUrl = `postgres://postgres:postgres@localhost:${pgPort}/codegen_dev`;
14757
15107
  const redisUrl = `redis://localhost:${redisPort}`;
14758
- const logFile = path29.join(ctx.cwd, ".dev-app.log");
14759
- const logFd = fs18.openSync(logFile, "a");
15108
+ const logFile = path31.join(ctx.cwd, ".dev-app.log");
15109
+ const logFd = fs20.openSync(logFile, "a");
14760
15110
  const child = spawn("bun", ["src/main.ts"], {
14761
15111
  cwd: ctx.cwd,
14762
15112
  detached: true,
@@ -14769,7 +15119,7 @@ var DevRestartCommand = class extends Command8 {
14769
15119
  }
14770
15120
  });
14771
15121
  child.unref();
14772
- fs18.closeSync(logFd);
15122
+ fs20.closeSync(logFd);
14773
15123
  if (child.pid) {
14774
15124
  writeAppPid(ctx.cwd, child.pid);
14775
15125
  spawnSync("sleep", ["2"]);
@@ -14884,11 +15234,11 @@ var devNoun = {
14884
15234
  var dev_default = devNoun;
14885
15235
 
14886
15236
  // src/cli/commands/relationship.ts
14887
- import fs19 from "fs";
14888
- import path30 from "path";
15237
+ import fs21 from "fs";
15238
+ import path32 from "path";
14889
15239
  import { Command as Command9, Option as Option9 } from "clipanion";
14890
15240
  function listRelationshipYamls2(dir) {
14891
- if (!fs19.existsSync(dir)) return [];
15241
+ if (!fs21.existsSync(dir)) return [];
14892
15242
  return findYamlFiles(dir).filter(
14893
15243
  (full) => detectYamlType(full) === "relationship"
14894
15244
  );
@@ -14912,7 +15262,7 @@ function padRight2(s, n) {
14912
15262
  return s.length >= n ? s : s + " ".repeat(n - s.length);
14913
15263
  }
14914
15264
  async function summary6(ctx) {
14915
- const relDir = path30.resolve(ctx.cwd, "relationships");
15265
+ const relDir = path32.resolve(ctx.cwd, "relationships");
14916
15266
  const files = listRelationshipYamls2(relDir);
14917
15267
  if (files.length === 0) {
14918
15268
  return {
@@ -14982,14 +15332,14 @@ var RelationshipNewCommand = class extends Command9 {
14982
15332
  }
14983
15333
  let targets = [];
14984
15334
  if (this.all) {
14985
- const dir = path30.resolve(ctx.cwd, "relationships");
15335
+ const dir = path32.resolve(ctx.cwd, "relationships");
14986
15336
  targets = listRelationshipYamls2(dir);
14987
15337
  if (targets.length === 0) {
14988
15338
  printError(`No relationship YAML files found in ${dir}`);
14989
15339
  return 1;
14990
15340
  }
14991
15341
  } else if (this.yaml) {
14992
- targets = [path30.resolve(ctx.cwd, this.yaml)];
15342
+ targets = [path32.resolve(ctx.cwd, this.yaml)];
14993
15343
  } else {
14994
15344
  printError("Missing YAML path. Pass a file or --all.");
14995
15345
  return 2;
@@ -15006,7 +15356,7 @@ var RelationshipNewCommand = class extends Command9 {
15006
15356
  }
15007
15357
  if (invalid.length > 0) {
15008
15358
  for (const i of invalid) {
15009
- printError(`${path30.basename(i.file)} \u2014 ${i.message}`);
15359
+ printError(`${path32.basename(i.file)} \u2014 ${i.message}`);
15010
15360
  }
15011
15361
  if (!isJsonMode()) return 1;
15012
15362
  }
@@ -15037,7 +15387,7 @@ var RelationshipNewCommand = class extends Command9 {
15037
15387
  }
15038
15388
  const succeeded = [];
15039
15389
  const failed = [
15040
- ...invalid.map((i) => ({ name: path30.basename(i.file), file: i.file, message: i.message }))
15390
+ ...invalid.map((i) => ({ name: path32.basename(i.file), file: i.file, message: i.message }))
15041
15391
  ];
15042
15392
  for (const v of validated) {
15043
15393
  if (!isJsonMode()) {
@@ -15056,8 +15406,8 @@ var RelationshipNewCommand = class extends Command9 {
15056
15406
  if (!isJsonMode()) printError(`${v.name} \u2014 ${res.stderr ?? "failed"}`);
15057
15407
  }
15058
15408
  }
15059
- const entitiesDir = ctx.entitiesDir ?? path30.resolve(ctx.cwd, "entities");
15060
- const relationshipsDir = path30.resolve(ctx.cwd, "relationships");
15409
+ const entitiesDir = ctx.entitiesDir ?? path32.resolve(ctx.cwd, "entities");
15410
+ const relationshipsDir = path32.resolve(ctx.cwd, "relationships");
15061
15411
  const generatedDir = resolveGeneratedDir(ctx);
15062
15412
  const architecture = resolveArchitecture(ctx);
15063
15413
  let barrelResult = null;
@@ -15102,7 +15452,7 @@ var RelationshipNewCommand = class extends Command9 {
15102
15452
  }
15103
15453
  if (barrelResult) {
15104
15454
  printInfo(
15105
- `barrels regenerated (${barrelResult.entityCount} modules) \u2192 ${path30.relative(ctx.cwd, barrelResult.modulesBarrel)}, ${path30.relative(ctx.cwd, barrelResult.schemaBarrel)}`
15455
+ `barrels regenerated (${barrelResult.entityCount} modules) \u2192 ${path32.relative(ctx.cwd, barrelResult.modulesBarrel)}, ${path32.relative(ctx.cwd, barrelResult.schemaBarrel)}`
15106
15456
  );
15107
15457
  }
15108
15458
  }
@@ -15125,7 +15475,7 @@ var RelationshipListCommand = class extends Command9 {
15125
15475
  json: this.json,
15126
15476
  skipDetection: true
15127
15477
  });
15128
- const relDir = path30.resolve(ctx.cwd, "relationships");
15478
+ const relDir = path32.resolve(ctx.cwd, "relationships");
15129
15479
  const files = listRelationshipYamls2(relDir);
15130
15480
  if (files.length === 0) {
15131
15481
  printInfo("No relationship definitions found.");
@@ -15165,7 +15515,7 @@ var relationshipNoun = {
15165
15515
  var relationship_default = relationshipNoun;
15166
15516
 
15167
15517
  // src/cli/commands/junction.ts
15168
- import path31 from "path";
15518
+ import path33 from "path";
15169
15519
  import { Command as Command10, Option as Option10 } from "clipanion";
15170
15520
  function summarizeJunctionFile(filePath) {
15171
15521
  const result = loadJunctionFromYaml(filePath);
@@ -15188,7 +15538,7 @@ function padRight3(s, n) {
15188
15538
  return s.length >= n ? s : s + " ".repeat(n - s.length);
15189
15539
  }
15190
15540
  async function summary7(ctx) {
15191
- const junctionDir = path31.resolve(ctx.cwd, "junctions");
15541
+ const junctionDir = path33.resolve(ctx.cwd, "junctions");
15192
15542
  const files = listJunctionYamls(junctionDir);
15193
15543
  if (files.length === 0) {
15194
15544
  return {
@@ -15258,14 +15608,14 @@ var JunctionNewCommand = class extends Command10 {
15258
15608
  }
15259
15609
  let targets = [];
15260
15610
  if (this.all) {
15261
- const dir = path31.resolve(ctx.cwd, "junctions");
15611
+ const dir = path33.resolve(ctx.cwd, "junctions");
15262
15612
  targets = listJunctionYamls(dir);
15263
15613
  if (targets.length === 0) {
15264
15614
  printError(`No junction YAML files found in ${dir}`);
15265
15615
  return 1;
15266
15616
  }
15267
15617
  } else if (this.yaml) {
15268
- targets = [path31.resolve(ctx.cwd, this.yaml)];
15618
+ targets = [path33.resolve(ctx.cwd, this.yaml)];
15269
15619
  } else {
15270
15620
  printError("Missing YAML path. Pass a file or --all.");
15271
15621
  return 2;
@@ -15284,7 +15634,7 @@ var JunctionNewCommand = class extends Command10 {
15284
15634
  }
15285
15635
  if (invalid.length > 0) {
15286
15636
  for (const i of invalid) {
15287
- printError(`${path31.basename(i.file)} \u2014 ${i.message}`);
15637
+ printError(`${path33.basename(i.file)} \u2014 ${i.message}`);
15288
15638
  }
15289
15639
  if (!isJsonMode()) return 1;
15290
15640
  }
@@ -15315,7 +15665,7 @@ var JunctionNewCommand = class extends Command10 {
15315
15665
  }
15316
15666
  const succeeded = [];
15317
15667
  const failed = [
15318
- ...invalid.map((i) => ({ name: path31.basename(i.file), file: i.file, message: i.message }))
15668
+ ...invalid.map((i) => ({ name: path33.basename(i.file), file: i.file, message: i.message }))
15319
15669
  ];
15320
15670
  for (const v of validated) {
15321
15671
  if (!isJsonMode()) {
@@ -15334,9 +15684,9 @@ var JunctionNewCommand = class extends Command10 {
15334
15684
  if (!isJsonMode()) printError(`${v.name} \u2014 ${res.stderr ?? "failed"}`);
15335
15685
  }
15336
15686
  }
15337
- const entitiesDir = ctx.entitiesDir ?? path31.resolve(ctx.cwd, "entities");
15338
- const relationshipsDir = path31.resolve(ctx.cwd, "relationships");
15339
- const junctionsDir = path31.resolve(ctx.cwd, "junctions");
15687
+ const entitiesDir = ctx.entitiesDir ?? path33.resolve(ctx.cwd, "entities");
15688
+ const relationshipsDir = path33.resolve(ctx.cwd, "relationships");
15689
+ const junctionsDir = path33.resolve(ctx.cwd, "junctions");
15340
15690
  const generatedDir = resolveGeneratedDir(ctx);
15341
15691
  const architecture = resolveArchitecture(ctx);
15342
15692
  let barrelResult = null;
@@ -15382,7 +15732,7 @@ var JunctionNewCommand = class extends Command10 {
15382
15732
  }
15383
15733
  if (barrelResult) {
15384
15734
  printInfo(
15385
- `barrels regenerated (${barrelResult.entityCount} modules) \u2192 ${path31.relative(ctx.cwd, barrelResult.modulesBarrel)}, ${path31.relative(ctx.cwd, barrelResult.schemaBarrel)}`
15735
+ `barrels regenerated (${barrelResult.entityCount} modules) \u2192 ${path33.relative(ctx.cwd, barrelResult.modulesBarrel)}, ${path33.relative(ctx.cwd, barrelResult.schemaBarrel)}`
15386
15736
  );
15387
15737
  }
15388
15738
  }
@@ -15405,7 +15755,7 @@ var JunctionListCommand = class extends Command10 {
15405
15755
  json: this.json,
15406
15756
  skipDetection: true
15407
15757
  });
15408
- const junctionDir = path31.resolve(ctx.cwd, "junctions");
15758
+ const junctionDir = path33.resolve(ctx.cwd, "junctions");
15409
15759
  const files = listJunctionYamls(junctionDir);
15410
15760
  if (files.length === 0) {
15411
15761
  printInfo("No junction definitions found.");
@@ -15445,8 +15795,8 @@ var junctionNoun = {
15445
15795
  var junction_default = junctionNoun;
15446
15796
 
15447
15797
  // src/cli/commands/events.ts
15448
- import fs20 from "fs";
15449
- import path32 from "path";
15798
+ import fs22 from "fs";
15799
+ import path34 from "path";
15450
15800
  import ts3 from "typescript";
15451
15801
  import { Command as Command11, Option as Option11 } from "clipanion";
15452
15802
  function scanSourceFileForConsumers(sourceFile, filePath, eventType) {
@@ -15545,7 +15895,7 @@ function scanDirectoryForConsumers(rootDir, eventType) {
15545
15895
  const tier1 = [];
15546
15896
  let hasEventFlowImport = false;
15547
15897
  for (const filePath of files) {
15548
- const text2 = fs20.readFileSync(filePath, "utf8");
15898
+ const text2 = fs22.readFileSync(filePath, "utf8");
15549
15899
  const sourceFile = ts3.createSourceFile(
15550
15900
  filePath,
15551
15901
  text2,
@@ -15582,7 +15932,7 @@ function suggestEventTypes(target, known, limit = 3) {
15582
15932
  return known.map((t) => ({ t, d: levenshtein(target, t) })).sort((a, b) => a.d - b.d).slice(0, limit).map((x) => x.t);
15583
15933
  }
15584
15934
  function renderConsumerReport(result, cwd) {
15585
- const rel2 = (p) => path32.relative(cwd, p) || p;
15935
+ const rel2 = (p) => path34.relative(cwd, p) || p;
15586
15936
  const lines = [];
15587
15937
  const total = result.tier3.length + result.tier2.length + result.tier1.length;
15588
15938
  lines.push(`Event: ${result.eventType}`);
@@ -15618,7 +15968,7 @@ function renderConsumerReport(result, cwd) {
15618
15968
  return lines;
15619
15969
  }
15620
15970
  function runConsumersScan(opts) {
15621
- const scanRoot = opts.scanRoot ?? path32.join(opts.cwd, "src");
15971
+ const scanRoot = opts.scanRoot ?? path34.join(opts.cwd, "src");
15622
15972
  const handlersDir = opts.handlersDir ?? scanRoot;
15623
15973
  const allTriggers = scanHandlerFiles(handlersDir);
15624
15974
  const tier3 = allTriggers.filter((t) => t.event === opts.eventType).map((t) => ({
@@ -15627,8 +15977,8 @@ function runConsumersScan(opts) {
15627
15977
  sourceFile: t.sourceFile,
15628
15978
  sourceLine: t.sourceLine
15629
15979
  }));
15630
- const tier21 = fs20.existsSync(scanRoot) ? scanDirectoryForConsumers(scanRoot, opts.eventType) : { tier2: [], tier1: [], hasEventFlowImport: false };
15631
- const eventsGeneratedDir = opts.eventsGeneratedDir ?? path32.join(
15980
+ const tier21 = fs22.existsSync(scanRoot) ? scanDirectoryForConsumers(scanRoot, opts.eventType) : { tier2: [], tier1: [], hasEventFlowImport: false };
15981
+ const eventsGeneratedDir = opts.eventsGeneratedDir ?? path34.join(
15632
15982
  resolveSubsystemsRootFromContext(opts.cwd, opts.config),
15633
15983
  "events",
15634
15984
  "generated"
@@ -15649,11 +15999,11 @@ function runConsumersScan(opts) {
15649
15999
  function resolveSubsystemsRootFromContext(cwd, config) {
15650
16000
  const configured = config?.paths?.subsystems;
15651
16001
  if (typeof configured === "string" && configured.length > 0) {
15652
- return path32.resolve(cwd, configured);
16002
+ return path34.resolve(cwd, configured);
15653
16003
  }
15654
16004
  const backendSrc = config?.paths?.backend_src;
15655
16005
  const base = typeof backendSrc === "string" && backendSrc.length > 0 ? backendSrc : "src";
15656
- return path32.resolve(cwd, base, "shared", "subsystems");
16006
+ return path34.resolve(cwd, base, "shared", "subsystems");
15657
16007
  }
15658
16008
  var EventsConsumersCommand = class extends Command11 {
15659
16009
  static paths = [["events", "consumers"]];
@@ -15742,7 +16092,7 @@ var eventsNoun = {
15742
16092
  var events_default = eventsNoun;
15743
16093
 
15744
16094
  // src/cli/commands/orchestration.ts
15745
- import path33 from "path";
16095
+ import path35 from "path";
15746
16096
  import { Command as Command12, Option as Option12 } from "clipanion";
15747
16097
  var DEFAULT_PATTERN_GLOBS = ["src/patterns/*.pattern.ts"];
15748
16098
  function resolvePatternGlobs(ctx) {
@@ -15756,10 +16106,10 @@ function resolveOrchestrationOutputRoot(ctx) {
15756
16106
  const paths = ctx.config?.paths;
15757
16107
  const explicit = paths?.orchestration_src;
15758
16108
  if (typeof explicit === "string" && explicit.length > 0) {
15759
- return path33.resolve(ctx.cwd, explicit);
16109
+ return path35.resolve(ctx.cwd, explicit);
15760
16110
  }
15761
16111
  const backendSrc = typeof paths?.backend_src === "string" && paths.backend_src.length > 0 ? paths.backend_src : "app/backend/src";
15762
- return path33.resolve(ctx.cwd, backendSrc, "orchestration");
16112
+ return path35.resolve(ctx.cwd, backendSrc, "orchestration");
15763
16113
  }
15764
16114
  async function reloadRegistry(ctx) {
15765
16115
  _resetRegistryForTests({ includeLibrary: false });
@@ -15848,12 +16198,12 @@ var OrchestrationGenCommand = class extends Command12 {
15848
16198
  );
15849
16199
  for (const f of result.files) {
15850
16200
  console.log(
15851
- ` ${theme.muted(icons.arrow)} ${path33.relative(ctx.cwd, f.outputPath)}`
16201
+ ` ${theme.muted(icons.arrow)} ${path35.relative(ctx.cwd, f.outputPath)}`
15852
16202
  );
15853
16203
  }
15854
16204
  } else {
15855
16205
  printSuccess(
15856
- `Emitted ${result.files.length} file(s) across ${targets.length} pattern(s) \u2192 ${path33.relative(ctx.cwd, outputRoot)}`
16206
+ `Emitted ${result.files.length} file(s) across ${targets.length} pattern(s) \u2192 ${path35.relative(ctx.cwd, outputRoot)}`
15857
16207
  );
15858
16208
  }
15859
16209
  return 0;