@hexagen-monaco/sync 0.11.0 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/LICENSE +8 -5
  2. package/README.md +2 -2
  3. package/dist/application/ports/out/file-system.port.d.ts.map +1 -1
  4. package/dist/application/ports/out/symbol-reference-index.port.d.ts +9 -9
  5. package/dist/application/ports/out/symbol-reference-index.port.d.ts.map +1 -1
  6. package/dist/application/use-cases/migrate-manifest.use-case.d.ts +4 -1
  7. package/dist/application/use-cases/migrate-manifest.use-case.d.ts.map +1 -1
  8. package/dist/application/use-cases/refactoring-impact.use-case.d.ts +6 -5
  9. package/dist/application/use-cases/refactoring-impact.use-case.d.ts.map +1 -1
  10. package/dist/cli.js +891 -323
  11. package/dist/cli.js.map +1 -1
  12. package/dist/commands/adopt/index.d.ts.map +1 -1
  13. package/dist/commands/bootstrap/index.d.ts +21 -0
  14. package/dist/commands/bootstrap/index.d.ts.map +1 -1
  15. package/dist/commands/manifest/migrate.d.ts.map +1 -1
  16. package/dist/commands/scan/index.d.ts +185 -0
  17. package/dist/commands/scan/index.d.ts.map +1 -0
  18. package/dist/commands/shared/index.d.ts +1 -0
  19. package/dist/commands/shared/index.d.ts.map +1 -1
  20. package/dist/commands/shared/lstat-exists.d.ts +7 -0
  21. package/dist/commands/shared/lstat-exists.d.ts.map +1 -0
  22. package/dist/domain/services/impact-request-validator.d.ts.map +1 -1
  23. package/dist/domain/services/layer-dir-resolver.d.ts +20 -1
  24. package/dist/domain/services/layer-dir-resolver.d.ts.map +1 -1
  25. package/dist/generators/layer-folders.d.ts +9 -1
  26. package/dist/generators/layer-folders.d.ts.map +1 -1
  27. package/dist/generators/package-src-index.d.ts +5 -0
  28. package/dist/generators/package-src-index.d.ts.map +1 -0
  29. package/dist/index.js +106 -11
  30. package/dist/index.js.map +1 -1
  31. package/dist/infrastructure/adapters/atomic-file-system.adapter.d.ts.map +1 -1
  32. package/dist/infrastructure/adapters/file-system-workspace.adapter.d.ts.map +1 -1
  33. package/dist/infrastructure/adapters/ts-morph-symbol-index.adapter.d.ts +1 -1
  34. package/dist/infrastructure/adapters/ts-morph-symbol-index.adapter.d.ts.map +1 -1
  35. package/dist/sync-engine.d.ts.map +1 -1
  36. package/dist/types/index.d.ts +20 -1
  37. package/dist/types/index.d.ts.map +1 -1
  38. package/package.json +1 -1
  39. package/dist/commands/bootstrap.d.ts +0 -30
  40. package/dist/commands/bootstrap.d.ts.map +0 -1
package/dist/cli.js CHANGED
@@ -1,17 +1,17 @@
1
1
  #!/usr/bin/env node
2
2
  import { Command } from 'commander';
3
- import * as path35 from 'path';
4
- import path35__default, { dirname, join } from 'path';
5
- import * as fs24 from 'fs';
6
- import fs24__default, { mkdirSync, writeFileSync, renameSync, unlinkSync, existsSync, readFileSync, promises, realpathSync, lstatSync, createWriteStream } from 'fs';
7
- import fs27, { readFile } from 'fs/promises';
3
+ import * as path34 from 'path';
4
+ import path34__default, { dirname, join } from 'path';
5
+ import * as fs26 from 'fs';
6
+ import fs26__default, { mkdirSync, writeFileSync, renameSync, unlinkSync, existsSync, readFileSync, promises, realpathSync, lstatSync, createWriteStream } from 'fs';
7
+ import fs29, { readFile } from 'fs/promises';
8
8
  import { promisify, isDeepStrictEqual } from 'util';
9
- import { exec, execSync, spawn, execFileSync } from 'child_process';
9
+ import { exec, execSync, spawn, spawnSync, execFileSync } from 'child_process';
10
10
  import yaml10 from 'js-yaml';
11
11
  import crypto from 'crypto';
12
12
  import { z } from 'zod';
13
13
  import { fileURLToPath } from 'url';
14
- import { Project, SyntaxKind, MethodSignature } from 'ts-morph';
14
+ import { Project, ts, SyntaxKind, MethodSignature } from 'ts-morph';
15
15
  import * as readline from 'readline';
16
16
  import { tmpdir } from 'os';
17
17
 
@@ -32,11 +32,11 @@ var MigrationReport = class {
32
32
  );
33
33
  return;
34
34
  }
35
- const reportPath = config.report ? path35__default.resolve(config.workspaceRoot, config.report) : path35__default.join(config.workspaceRoot, "SYNC-MIGRATION-REPORT.md");
36
- await fs27.mkdir(path35__default.dirname(reportPath), { recursive: true });
35
+ const reportPath = config.report ? path34__default.resolve(config.workspaceRoot, config.report) : path34__default.join(config.workspaceRoot, "SYNC-MIGRATION-REPORT.md");
36
+ await fs29.mkdir(path34__default.dirname(reportPath), { recursive: true });
37
37
  let preContent = null;
38
38
  try {
39
- preContent = await fs27.readFile(reportPath, "utf8");
39
+ preContent = await fs29.readFile(reportPath, "utf8");
40
40
  } catch (e) {
41
41
  if (!(e instanceof Error && "code" in e && e.code === "ENOENT"))
42
42
  throw e;
@@ -86,7 +86,7 @@ var SyncJournal = class {
86
86
  */
87
87
  describeEntries(workspaceRoot) {
88
88
  return this.entries.map(
89
- (e) => `${e.kind} ${path35__default.relative(workspaceRoot, e.path)}`
89
+ (e) => `${e.kind} ${path34__default.relative(workspaceRoot, e.path)}`
90
90
  );
91
91
  }
92
92
  /**
@@ -112,11 +112,11 @@ var SyncJournal = class {
112
112
  failures: []
113
113
  };
114
114
  for (const entry of [...this.entries].reverse()) {
115
- const relative = path35__default.relative(workspaceRoot, entry.path);
115
+ const relative = path34__default.relative(workspaceRoot, entry.path);
116
116
  try {
117
117
  if (entry.preContent === null) {
118
118
  try {
119
- await fs27.unlink(entry.path);
119
+ await fs29.unlink(entry.path);
120
120
  } catch (err3) {
121
121
  if (!(err3 instanceof Error && "code" in err3 && err3.code === "ENOENT")) {
122
122
  throw err3;
@@ -124,8 +124,8 @@ var SyncJournal = class {
124
124
  }
125
125
  logger2.info(`rolled back (removed) ${relative}`);
126
126
  } else {
127
- await fs27.mkdir(path35__default.dirname(entry.path), { recursive: true });
128
- await fs27.writeFile(entry.path, entry.preContent, {
127
+ await fs29.mkdir(path34__default.dirname(entry.path), { recursive: true });
128
+ await fs29.writeFile(entry.path, entry.preContent, {
129
129
  encoding: "utf8"
130
130
  });
131
131
  logger2.info(`rolled back (restored) ${relative}`);
@@ -144,9 +144,9 @@ var SyncJournal = class {
144
144
  };
145
145
  var LOCK_FILE = ".architecture/.sync.lock";
146
146
  var LockFile = class {
147
- constructor(workspaceRoot, fsImpl = fs27, logger2 = console) {
147
+ constructor(workspaceRoot, fsImpl = fs29, logger2 = console) {
148
148
  this.workspaceRoot = workspaceRoot;
149
- this.lockPath = path35__default.join(workspaceRoot, LOCK_FILE);
149
+ this.lockPath = path34__default.join(workspaceRoot, LOCK_FILE);
150
150
  this.fsImpl = fsImpl;
151
151
  this.logger = logger2;
152
152
  }
@@ -219,7 +219,7 @@ var PACKAGE_NAMES = [
219
219
  function binEntryOf(pkgJsonPath) {
220
220
  let parsed;
221
221
  try {
222
- parsed = JSON.parse(fs24__default.readFileSync(pkgJsonPath, "utf8"));
222
+ parsed = JSON.parse(fs26__default.readFileSync(pkgJsonPath, "utf8"));
223
223
  } catch {
224
224
  return null;
225
225
  }
@@ -234,22 +234,22 @@ function binEntryOf(pkgJsonPath) {
234
234
  }
235
235
  function resolveFromPackage(dir) {
236
236
  for (const pkgName of PACKAGE_NAMES) {
237
- const pkgDir = path35__default.join(dir, "node_modules", ...pkgName.split("/"));
238
- const entry = binEntryOf(path35__default.join(pkgDir, "package.json"));
237
+ const pkgDir = path34__default.join(dir, "node_modules", ...pkgName.split("/"));
238
+ const entry = binEntryOf(path34__default.join(pkgDir, "package.json"));
239
239
  if (entry === null) continue;
240
- const binPath = path35__default.join(pkgDir, entry);
241
- if (fs24__default.existsSync(binPath)) return binPath;
240
+ const binPath = path34__default.join(pkgDir, entry);
241
+ if (fs26__default.existsSync(binPath)) return binPath;
242
242
  }
243
243
  return null;
244
244
  }
245
245
  function resolveArchLinterBin(startDir) {
246
- let dir = path35__default.resolve(startDir);
246
+ let dir = path34__default.resolve(startDir);
247
247
  for (; ; ) {
248
- const candidate = path35__default.join(dir, "node_modules", ".bin", BIN_NAME);
249
- if (fs24__default.existsSync(candidate)) return candidate;
248
+ const candidate = path34__default.join(dir, "node_modules", ".bin", BIN_NAME);
249
+ if (fs26__default.existsSync(candidate)) return candidate;
250
250
  const fromPackage = resolveFromPackage(dir);
251
251
  if (fromPackage !== null) return fromPackage;
252
- const parent = path35__default.dirname(dir);
252
+ const parent = path34__default.dirname(dir);
253
253
  if (parent === dir) return null;
254
254
  dir = parent;
255
255
  }
@@ -404,7 +404,7 @@ function isGeneratedFile(content) {
404
404
  return content.includes(GENERATED_MARKER);
405
405
  }
406
406
  function isProtectedRoot(filePath, config) {
407
- const relative = path35__default.relative(config.workspaceRoot, filePath);
407
+ const relative = path34__default.relative(config.workspaceRoot, filePath);
408
408
  const isRootLevel = !relative.startsWith("packages/") && !relative.startsWith("tools/") && !relative.startsWith("apps/");
409
409
  return isRootLevel && Array.from(protectedFiles).some(
410
410
  (f) => relative.endsWith(f) || relative.includes(f)
@@ -412,12 +412,12 @@ function isProtectedRoot(filePath, config) {
412
412
  }
413
413
  function isInScope(filePath, config) {
414
414
  if (!config.only || config.only.length === 0) return true;
415
- const relativePath = path35__default.relative(config.workspaceRoot, filePath);
415
+ const relativePath = path34__default.relative(config.workspaceRoot, filePath);
416
416
  return matchesScope(relativePath, config.only);
417
417
  }
418
418
  async function safeWriteFileAtomic(filePath, content, config, report, skipGeneratedCheck = false) {
419
419
  const { dryRun, forceRoot, logger: logger2, workspaceRoot } = config;
420
- const relativePath = path35__default.relative(workspaceRoot, filePath);
420
+ const relativePath = path34__default.relative(workspaceRoot, filePath);
421
421
  if (!isInScope(filePath, config)) {
422
422
  logger2.debug(`skipped (outside --only) ${relativePath}`);
423
423
  return "skipped";
@@ -426,7 +426,7 @@ async function safeWriteFileAtomic(filePath, content, config, report, skipGenera
426
426
  let currentContent = "";
427
427
  let currentHash = "";
428
428
  try {
429
- currentContent = await fs27.readFile(filePath, "utf8");
429
+ currentContent = await fs29.readFile(filePath, "utf8");
430
430
  currentHash = contentHash(currentContent);
431
431
  exists = true;
432
432
  } catch (e) {
@@ -457,20 +457,20 @@ async function safeWriteFileAtomic(filePath, content, config, report, skipGenera
457
457
  return exists ? "updated" : "created";
458
458
  }
459
459
  config.journal?.recordWrite(filePath, exists ? currentContent : null);
460
- await fs27.mkdir(path35__default.dirname(filePath), { recursive: true });
461
- const tmpName = `.${path35__default.basename(filePath)}.${crypto.randomUUID()}.tmp`;
462
- const tmpPath = path35__default.join(path35__default.dirname(filePath), tmpName);
463
- await fs27.writeFile(tmpPath, content, { encoding: "utf8" });
460
+ await fs29.mkdir(path34__default.dirname(filePath), { recursive: true });
461
+ const tmpName = `.${path34__default.basename(filePath)}.${crypto.randomUUID()}.tmp`;
462
+ const tmpPath = path34__default.join(path34__default.dirname(filePath), tmpName);
463
+ await fs29.writeFile(tmpPath, content, { encoding: "utf8" });
464
464
  try {
465
- await fs27.rename(tmpPath, filePath);
465
+ await fs29.rename(tmpPath, filePath);
466
466
  const status = exists ? "updated" : "created";
467
467
  logger2.info(`${status} ${relativePath}`);
468
468
  return status;
469
469
  } catch (err3) {
470
470
  if (err3 instanceof Error && "code" in err3 && err3.code === "EXDEV") {
471
471
  try {
472
- await fs27.copyFile(tmpPath, filePath);
473
- await fs27.unlink(tmpPath);
472
+ await fs29.copyFile(tmpPath, filePath);
473
+ await fs29.unlink(tmpPath);
474
474
  const status = exists ? "updated" : "created";
475
475
  logger2.info(`${status} ${relativePath}`);
476
476
  return status;
@@ -478,7 +478,7 @@ async function safeWriteFileAtomic(filePath, content, config, report, skipGenera
478
478
  logger2.warn(`EXDEV fallback failed for ${relativePath}: ${copyErr}`);
479
479
  }
480
480
  }
481
- await fs27.unlink(tmpPath).catch(() => {
481
+ await fs29.unlink(tmpPath).catch(() => {
482
482
  });
483
483
  throw err3;
484
484
  }
@@ -519,11 +519,33 @@ function resolveEmissionDir(layers, site) {
519
519
  const layer = site.slice(0, slash);
520
520
  return resolveLayerDir(layers, layer, site.slice(slash + 1));
521
521
  }
522
+ function hasDeclaredNames(value) {
523
+ return Array.isArray(value) && value.length > 0;
524
+ }
525
+ function layerDeclaresContent(layerName, contextLayers) {
526
+ if (!contextLayers) return false;
527
+ if (layerName === "domain") {
528
+ const layer = contextLayers.domain;
529
+ if (!layer) return false;
530
+ return hasDeclaredNames(layer.entities) || hasDeclaredNames(layer.value_objects) || hasDeclaredNames(layer.domain_services) || hasDeclaredNames(layer.ports?.in) || hasDeclaredNames(layer.ports?.out);
531
+ }
532
+ if (layerName === "application") {
533
+ const layer = contextLayers.application;
534
+ if (!layer) return false;
535
+ return hasDeclaredNames(layer.use_cases) || hasDeclaredNames(layer.factories) || hasDeclaredNames(layer.ports?.in) || hasDeclaredNames(layer.ports?.out);
536
+ }
537
+ if (layerName === "infrastructure") {
538
+ const layer = contextLayers.infrastructure;
539
+ if (!layer) return false;
540
+ return hasDeclaredNames(layer.adapters);
541
+ }
542
+ return false;
543
+ }
522
544
 
523
545
  // src/generators/layer-folders.ts
524
546
  async function directoryExists(dirPath) {
525
547
  try {
526
- const stats = await fs27.stat(dirPath);
548
+ const stats = await fs29.stat(dirPath);
527
549
  return stats.isDirectory();
528
550
  } catch (e) {
529
551
  if (e instanceof Error && "code" in e && e.code === "ENOENT") {
@@ -535,21 +557,21 @@ async function directoryExists(dirPath) {
535
557
  async function ensureDirectoryCounted(dirPath, config, result) {
536
558
  const existed = await directoryExists(dirPath);
537
559
  if (existed) return;
538
- const relativePath = path35__default.relative(config.workspaceRoot, dirPath);
560
+ const relativePath = path34__default.relative(config.workspaceRoot, dirPath);
539
561
  if (config.dryRun) {
540
562
  config.logger.info(`[DRY-RUN] would create directory ${relativePath}`);
541
563
  } else {
542
- await fs27.mkdir(dirPath, { recursive: true });
564
+ await fs29.mkdir(dirPath, { recursive: true });
543
565
  config.logger.info(`created directory ${relativePath}`);
544
566
  }
545
567
  result.created.push(dirPath);
546
568
  result.totalOps += 1;
547
569
  }
548
570
  async function ensureGitkeepCounted(dirPath, config, result) {
549
- const keepPath = path35__default.join(dirPath, ".gitkeep");
571
+ const keepPath = path34__default.join(dirPath, ".gitkeep");
550
572
  let entries = null;
551
573
  if (await directoryExists(dirPath)) {
552
- entries = await fs27.readdir(dirPath);
574
+ entries = await fs29.readdir(dirPath);
553
575
  }
554
576
  if (entries !== null) {
555
577
  const keepIsOnlyEntry = entries.length === 1 && entries[0] === ".gitkeep";
@@ -557,7 +579,7 @@ async function ensureGitkeepCounted(dirPath, config, result) {
557
579
  return;
558
580
  }
559
581
  if (keepIsOnlyEntry) {
560
- const existing = await fs27.readFile(keepPath, "utf8").catch(() => null);
582
+ const existing = await fs29.readFile(keepPath, "utf8").catch(() => null);
561
583
  if (existing !== null && existing !== "") {
562
584
  return;
563
585
  }
@@ -574,7 +596,7 @@ async function ensureGitkeepCounted(dirPath, config, result) {
574
596
  }
575
597
  async function loadYamlSafe(filePath) {
576
598
  try {
577
- const content = await fs27.readFile(filePath, "utf8");
599
+ const content = await fs29.readFile(filePath, "utf8");
578
600
  return yaml10.load(content);
579
601
  } catch (e) {
580
602
  if (e instanceof Error && "code" in e && e.code === "ENOENT") {
@@ -583,10 +605,10 @@ async function loadYamlSafe(filePath) {
583
605
  throw e;
584
606
  }
585
607
  }
586
- async function ensureLayerFolders(moduleDir, layers, config) {
608
+ async function ensureLayerFolders(moduleDir, layers, config, contextLayers) {
587
609
  const result = createEmptyResult();
588
610
  const { logger: logger2 } = config;
589
- const layerRulesPath = path35__default.join(
611
+ const layerRulesPath = path34__default.join(
590
612
  config.workspaceRoot,
591
613
  ".architecture",
592
614
  "invariants",
@@ -597,8 +619,11 @@ async function ensureLayerFolders(moduleDir, layers, config) {
597
619
  logger2.warn("layer-rules.yaml not found — skipping layer rule enforcement");
598
620
  }
599
621
  for (const [layerName, layerConfig] of Object.entries(layers)) {
600
- const layerPath = path35__default.join(moduleDir, resolveLayerDir(layers, layerName));
601
- if (!isInScope(layerPath, config) && !isInScope(path35__default.join(layerPath, "index.ts"), config)) {
622
+ if (!layerDeclaresContent(layerName, contextLayers)) {
623
+ continue;
624
+ }
625
+ const layerPath = path34__default.join(moduleDir, resolveLayerDir(layers, layerName));
626
+ if (!isInScope(layerPath, config) && !isInScope(path34__default.join(layerPath, "index.ts"), config)) {
602
627
  continue;
603
628
  }
604
629
  await ensureDirectoryCounted(layerPath, config, result);
@@ -614,8 +639,8 @@ async function ensureLayerFolders(moduleDir, layers, config) {
614
639
  );
615
640
  continue;
616
641
  }
617
- const subPath = path35__default.join(layerPath, normalizedSub);
618
- if (!isInScope(subPath, config) && !isInScope(path35__default.join(subPath, "index.ts"), config)) {
642
+ const subPath = path34__default.join(layerPath, normalizedSub);
643
+ if (!isInScope(subPath, config) && !isInScope(path34__default.join(subPath, "index.ts"), config)) {
619
644
  continue;
620
645
  }
621
646
  await ensureDirectoryCounted(subPath, config, result);
@@ -710,16 +735,16 @@ var CircularExportError = class extends Error {
710
735
  };
711
736
  async function generateRecursiveBarrels(moduleDir, config, report) {
712
737
  const result = createEmptyResult();
713
- const srcDir = path35__default.join(moduleDir, "src");
738
+ const srcDir = path34__default.join(moduleDir, "src");
714
739
  const layers = ["domain", "application", "infrastructure"];
715
740
  const pendingWrites = [];
716
741
  const preserved = [];
717
742
  const exportGraph = /* @__PURE__ */ new Map();
718
743
  const layersWithContent = [];
719
744
  for (const layer of layers) {
720
- const layerDir = path35__default.join(srcDir, layer);
745
+ const layerDir = path34__default.join(srcDir, layer);
721
746
  try {
722
- await fs27.access(layerDir);
747
+ await fs29.access(layerDir);
723
748
  } catch {
724
749
  continue;
725
750
  }
@@ -733,7 +758,7 @@ async function generateRecursiveBarrels(moduleDir, config, report) {
733
758
  if (layerExports.length > 0) layersWithContent.push(layer);
734
759
  }
735
760
  if (config.mode === "external" && layersWithContent.length > 0) {
736
- const rootBarrelPath = path35__default.join(srcDir, "index.ts");
761
+ const rootBarrelPath = path34__default.join(srcDir, "index.ts");
737
762
  if (await shouldGenerateBarrel(rootBarrelPath, preserved, config.logger)) {
738
763
  const content = generateBarrelContent(
739
764
  layersWithContent.map((name) => ({ name, isDirectory: true }))
@@ -747,7 +772,7 @@ async function generateRecursiveBarrels(moduleDir, config, report) {
747
772
  });
748
773
  exportGraph.set(
749
774
  rootBarrelPath,
750
- layersWithContent.map((name) => path35__default.join(srcDir, name, "index.ts"))
775
+ layersWithContent.map((name) => path34__default.join(srcDir, name, "index.ts"))
751
776
  );
752
777
  }
753
778
  }
@@ -767,9 +792,9 @@ async function generateRecursiveBarrels(moduleDir, config, report) {
767
792
  continue;
768
793
  }
769
794
  try {
770
- const preContent = await fs27.readFile(pending.filePath, "utf8");
795
+ const preContent = await fs29.readFile(pending.filePath, "utf8");
771
796
  config.journal?.recordDelete(pending.filePath, preContent);
772
- await fs27.unlink(pending.filePath);
797
+ await fs29.unlink(pending.filePath);
773
798
  result.deleted.push(pending.filePath);
774
799
  result.totalOps++;
775
800
  continue;
@@ -796,7 +821,7 @@ async function walkDirectory(dirPath, pendingWrites, preserved, exportGraph, con
796
821
  const exportEntries = [];
797
822
  let entries;
798
823
  try {
799
- entries = await fs27.readdir(dirPath, { withFileTypes: true });
824
+ entries = await fs29.readdir(dirPath, { withFileTypes: true });
800
825
  } catch {
801
826
  return exportEntries;
802
827
  }
@@ -813,7 +838,7 @@ async function walkDirectory(dirPath, pendingWrites, preserved, exportGraph, con
813
838
  }
814
839
  }
815
840
  for (const dir of directories) {
816
- const subDirPath = path35__default.join(dirPath, dir);
841
+ const subDirPath = path34__default.join(dirPath, dir);
817
842
  const subExports = await walkDirectory(
818
843
  subDirPath,
819
844
  pendingWrites,
@@ -821,7 +846,7 @@ async function walkDirectory(dirPath, pendingWrites, preserved, exportGraph, con
821
846
  exportGraph,
822
847
  config
823
848
  );
824
- const subBarrelPath = path35__default.join(subDirPath, "index.ts");
849
+ const subBarrelPath = path34__default.join(subDirPath, "index.ts");
825
850
  const isQueuedForDeletion = pendingWrites.some(
826
851
  (p) => p.filePath === subBarrelPath && p.content === ""
827
852
  );
@@ -833,9 +858,9 @@ async function walkDirectory(dirPath, pendingWrites, preserved, exportGraph, con
833
858
  exportEntries.push({ name: file, isDirectory: false });
834
859
  }
835
860
  if (exportEntries.length === 0) {
836
- const barrelPath2 = path35__default.join(dirPath, "index.ts");
861
+ const barrelPath2 = path34__default.join(dirPath, "index.ts");
837
862
  const existingBarrel = await readFileIfExists(barrelPath2);
838
- const dirName = path35__default.basename(dirPath);
863
+ const dirName = path34__default.basename(dirPath);
839
864
  const isLayerDir = ["domain", "application", "infrastructure"].includes(
840
865
  dirName
841
866
  );
@@ -885,7 +910,7 @@ export {};
885
910
  }
886
911
  return [];
887
912
  }
888
- const barrelPath = path35__default.join(dirPath, "index.ts");
913
+ const barrelPath = path34__default.join(dirPath, "index.ts");
889
914
  const shouldCreateBarrel = await shouldGenerateBarrel(
890
915
  barrelPath,
891
916
  preserved,
@@ -905,14 +930,14 @@ export {};
905
930
  content,
906
931
  isNew: !existingContent
907
932
  });
908
- const exportPaths = exportEntries.filter((e) => e.isDirectory).map((e) => path35__default.join(dirPath, e.name, "index.ts"));
933
+ const exportPaths = exportEntries.filter((e) => e.isDirectory).map((e) => path34__default.join(dirPath, e.name, "index.ts"));
909
934
  exportGraph.set(barrelPath, exportPaths);
910
935
  }
911
936
  return exportEntries;
912
937
  }
913
938
  async function hasBarrel(dirPath) {
914
939
  try {
915
- await fs27.access(path35__default.join(dirPath, "index.ts"));
940
+ await fs29.access(path34__default.join(dirPath, "index.ts"));
916
941
  return true;
917
942
  } catch {
918
943
  return false;
@@ -932,7 +957,7 @@ async function shouldGenerateBarrel(barrelPath, preserved, logger2) {
932
957
  }
933
958
  async function readFileIfExists(filePath) {
934
959
  try {
935
- return await fs27.readFile(filePath, "utf8");
960
+ return await fs29.readFile(filePath, "utf8");
936
961
  } catch (err3) {
937
962
  if (err3 && typeof err3 === "object" && "code" in err3 && err3.code === "ENOENT") {
938
963
  return null;
@@ -992,7 +1017,7 @@ async function generatePackageJson(modulePath, moduleName, config, report) {
992
1017
  const moduleOverrides = context?.packageJson ?? {};
993
1018
  const scope = config.manifest ? resolveScope(config.manifest) : "generated-project";
994
1019
  const dependsOnDeps = context ? expandDependsOn(context, scope) : {};
995
- const pkgPath = path35__default.join(modulePath, "package.json");
1020
+ const pkgPath = path34__default.join(modulePath, "package.json");
996
1021
  const dependencies = {
997
1022
  ...dependsOnDeps,
998
1023
  ...defaults.dependencies ?? {},
@@ -1044,7 +1069,7 @@ async function generatePackageJson(modulePath, moduleName, config, report) {
1044
1069
  };
1045
1070
  let currentPkg = {};
1046
1071
  try {
1047
- const currentContent = await fs27.readFile(pkgPath, "utf8");
1072
+ const currentContent = await fs29.readFile(pkgPath, "utf8");
1048
1073
  currentPkg = JSON.parse(currentContent);
1049
1074
  } catch (e) {
1050
1075
  if (!(e instanceof Error && "code" in e && e.code === "ENOENT")) {
@@ -1086,11 +1111,11 @@ async function generatePackageJson(modulePath, moduleName, config, report) {
1086
1111
  );
1087
1112
  recordWriteStatus(result, pkgPath, status);
1088
1113
  if (config.mode === "external") {
1089
- const vitestConfigPath = path35__default.join(modulePath, "vitest.config.ts");
1114
+ const vitestConfigPath = path34__default.join(modulePath, "vitest.config.ts");
1090
1115
  if (isInScope(vitestConfigPath, config)) {
1091
1116
  let vitestConfigExists = false;
1092
1117
  try {
1093
- await fs27.stat(vitestConfigPath);
1118
+ await fs29.stat(vitestConfigPath);
1094
1119
  vitestConfigExists = true;
1095
1120
  } catch (e) {
1096
1121
  if (!(e instanceof Error && "code" in e && e.code === "ENOENT")) {
@@ -1187,7 +1212,7 @@ function buildTemplate(base, context, scope) {
1187
1212
  }
1188
1213
  async function generateTsconfig(moduleDir, moduleName, config, report) {
1189
1214
  const result = createEmptyResult();
1190
- const filePath = path35__default.join(moduleDir, "tsconfig.json");
1215
+ const filePath = path34__default.join(moduleDir, "tsconfig.json");
1191
1216
  try {
1192
1217
  const base = resolveWorkspaceTemplate(config.manifest);
1193
1218
  const context = config.manifest.bounded_contexts?.find(
@@ -1213,19 +1238,50 @@ async function generateTsconfig(moduleDir, moduleName, config, report) {
1213
1238
  return result;
1214
1239
  }
1215
1240
  }
1241
+ var SRC_INDEX_STUB = `${GENERATED_MARKER2}
1242
+
1243
+ export {};
1244
+ `;
1245
+ async function ensurePackageSrcIndex(moduleDir, config, report) {
1246
+ const result = createEmptyResult();
1247
+ const filePath = path34__default.join(moduleDir, "src", "index.ts");
1248
+ if (!isInScope(filePath, config)) {
1249
+ result.skipped.push(filePath);
1250
+ return result;
1251
+ }
1252
+ try {
1253
+ await fs29.stat(filePath);
1254
+ result.skipped.push(filePath);
1255
+ return result;
1256
+ } catch (err3) {
1257
+ if (err3.code !== "ENOENT") throw err3;
1258
+ }
1259
+ if (!config.dryRun) {
1260
+ await fs29.mkdir(path34__default.dirname(filePath), { recursive: true });
1261
+ }
1262
+ const status = await safeWriteFileAtomic(
1263
+ filePath,
1264
+ SRC_INDEX_STUB,
1265
+ config,
1266
+ report,
1267
+ false
1268
+ );
1269
+ recordWriteStatus(result, filePath, status);
1270
+ return result;
1271
+ }
1216
1272
  async function reapLegacyFolders(moduleDir, config, report) {
1217
1273
  const { dryRun, logger: logger2 } = config;
1218
1274
  const legacyLayers = ["domain", "application", "infrastructure"];
1219
1275
  for (const layer of legacyLayers) {
1220
- const layerPath = path35__default.join(moduleDir, layer);
1221
- const relativePath = path35__default.relative(config.workspaceRoot, layerPath);
1276
+ const layerPath = path34__default.join(moduleDir, layer);
1277
+ const relativePath = path34__default.relative(config.workspaceRoot, layerPath);
1222
1278
  try {
1223
- const entries = await fs27.readdir(layerPath);
1279
+ const entries = await fs29.readdir(layerPath);
1224
1280
  if (entries.length === 0) {
1225
1281
  if (dryRun) {
1226
1282
  logger2.info(`[DRY-RUN] would delete empty folder ${relativePath}`);
1227
1283
  } else {
1228
- await fs27.rmdir(layerPath);
1284
+ await fs29.rmdir(layerPath);
1229
1285
  logger2.info(`deleted empty folder ${relativePath}`);
1230
1286
  if (report) report.record("deleted", layerPath);
1231
1287
  }
@@ -1287,6 +1343,33 @@ function interpolate(template, vars) {
1287
1343
  });
1288
1344
  return { output, warnings };
1289
1345
  }
1346
+ var CURRENT_SCHEMA_VERSION = "1.0.0";
1347
+ function majorOf(version) {
1348
+ const match = /^(\d+)(?:\.|$)/.exec(version);
1349
+ return match ? match[1] : null;
1350
+ }
1351
+ var SUPPORTED_MAJOR = majorOf(CURRENT_SCHEMA_VERSION);
1352
+ z.object({
1353
+ schemaVersion: z.string({ required_error: "schemaVersion is required" }).refine((v) => majorOf(v) !== null, {
1354
+ message: "schemaVersion must start with a numeric major, e.g. '1.0.0'"
1355
+ }).refine((v) => majorOf(v) === SUPPORTED_MAJOR, {
1356
+ message: `Unsupported schemaVersion major; this consumer understands ${SUPPORTED_MAJOR}.x`
1357
+ }),
1358
+ // `layout` is the raw TEXT of the producer's .architecture/layout.yaml, not
1359
+ // a structured object: packages/sync reads that file, and the web adapter
1360
+ // guards on `typeof rec.layout === "string"` before clipping it to an
1361
+ // excerpt. A looser z.unknown() here let a structured fixture through that
1362
+ // the real consumer would silently ignore.
1363
+ layout: z.string().nullable().optional(),
1364
+ // Nullable like its siblings: the producer emits an explicit null when the
1365
+ // count is unknown (the linter prints "Files scanned" on inherited stdio,
1366
+ // so scan cannot see it until BF-0.3 captures that stream). Making this
1367
+ // optional-but-not-nullable would force the producer to choose between
1368
+ // omitting the key and failing its own schema.
1369
+ filesScanned: z.number().int().min(0).nullable().optional(),
1370
+ reportMarkdown: z.string().nullable().optional(),
1371
+ error: z.string().nullable().optional()
1372
+ }).passthrough();
1290
1373
 
1291
1374
  // src/generators/root-file-templates.ts
1292
1375
  var BUILTIN_PACKAGE_JSON_TEMPLATE = `{
@@ -1451,7 +1534,7 @@ function assertValidToolchainVersion(version, source) {
1451
1534
  function resolveToolchainVersion() {
1452
1535
  {
1453
1536
  return assertValidToolchainVersion(
1454
- "0.11.0",
1537
+ "0.12.0",
1455
1538
  "build-injected __HEXAGEN_TOOLCHAIN_VERSION__"
1456
1539
  );
1457
1540
  }
@@ -1545,7 +1628,7 @@ async function generateRootFiles(config, report) {
1545
1628
  "package.json"
1546
1629
  );
1547
1630
  await writeRootFile(
1548
- path35__default.join(config.workspaceRoot, "package.json"),
1631
+ path34__default.join(config.workspaceRoot, "package.json"),
1549
1632
  packageJsonContent,
1550
1633
  config,
1551
1634
  report,
@@ -1562,7 +1645,7 @@ async function generateRootFiles(config, report) {
1562
1645
  "tsconfig.base.json"
1563
1646
  );
1564
1647
  await writeRootFile(
1565
- path35__default.join(config.workspaceRoot, "tsconfig.base.json"),
1648
+ path34__default.join(config.workspaceRoot, "tsconfig.base.json"),
1566
1649
  tsconfigContent,
1567
1650
  config,
1568
1651
  report,
@@ -1577,7 +1660,7 @@ async function generateRootFiles(config, report) {
1577
1660
  "turbo.json"
1578
1661
  );
1579
1662
  await writeRootFile(
1580
- path35__default.join(config.workspaceRoot, "turbo.json"),
1663
+ path34__default.join(config.workspaceRoot, "turbo.json"),
1581
1664
  turboContent,
1582
1665
  config,
1583
1666
  report,
@@ -1588,7 +1671,7 @@ async function generateRootFiles(config, report) {
1588
1671
  BUILTIN_GITIGNORE_TEMPLATE
1589
1672
  );
1590
1673
  await writeRootFile(
1591
- path35__default.join(config.workspaceRoot, ".gitignore"),
1674
+ path34__default.join(config.workspaceRoot, ".gitignore"),
1592
1675
  interpolateAndWarn(gitignoreTemplate, vars, config, ".gitignore"),
1593
1676
  config,
1594
1677
  report,
@@ -1599,7 +1682,7 @@ async function generateRootFiles(config, report) {
1599
1682
  BUILTIN_YARNRC_TEMPLATE
1600
1683
  );
1601
1684
  await writeRootFile(
1602
- path35__default.join(config.workspaceRoot, ".yarnrc.yml"),
1685
+ path34__default.join(config.workspaceRoot, ".yarnrc.yml"),
1603
1686
  interpolateAndWarn(yarnrcTemplate, vars, config, ".yarnrc.yml"),
1604
1687
  config,
1605
1688
  report,
@@ -1610,7 +1693,7 @@ async function generateRootFiles(config, report) {
1610
1693
  BUILTIN_SETUP_MD_TEMPLATE
1611
1694
  );
1612
1695
  await writeRootFile(
1613
- path35__default.join(config.workspaceRoot, "SETUP.md"),
1696
+ path34__default.join(config.workspaceRoot, "SETUP.md"),
1614
1697
  interpolateAndWarn(setupTemplate, vars, config, "SETUP.md"),
1615
1698
  config,
1616
1699
  report,
@@ -1901,9 +1984,9 @@ async function writeManifestIfFreshExternal(config, result, report) {
1901
1984
  if (config.mode !== "external") {
1902
1985
  return;
1903
1986
  }
1904
- const archDir = path35__default.join(config.workspaceRoot, ".architecture");
1905
- const manifestPath = path35__default.join(archDir, "manifest.yaml");
1906
- const relative = path35__default.relative(config.workspaceRoot, manifestPath);
1987
+ const archDir = path34__default.join(config.workspaceRoot, ".architecture");
1988
+ const manifestPath = path34__default.join(archDir, "manifest.yaml");
1989
+ const relative = path34__default.relative(config.workspaceRoot, manifestPath);
1907
1990
  if (!isInScope(manifestPath, config)) {
1908
1991
  config.logger.debug(`skipped (outside --only) ${relative}`);
1909
1992
  result.skipped.push(manifestPath);
@@ -1911,7 +1994,7 @@ async function writeManifestIfFreshExternal(config, result, report) {
1911
1994
  }
1912
1995
  let exists = false;
1913
1996
  try {
1914
- await fs27.access(manifestPath);
1997
+ await fs29.access(manifestPath);
1915
1998
  exists = true;
1916
1999
  } catch {
1917
2000
  exists = false;
@@ -1931,8 +2014,8 @@ async function writeManifestIfFreshExternal(config, result, report) {
1931
2014
  }
1932
2015
  const content = yaml10.dump(config.manifest);
1933
2016
  config.journal?.recordWrite(manifestPath, null);
1934
- await fs27.mkdir(archDir, { recursive: true });
1935
- await fs27.writeFile(manifestPath, content, { encoding: "utf8" });
2017
+ await fs29.mkdir(archDir, { recursive: true });
2018
+ await fs29.writeFile(manifestPath, content, { encoding: "utf8" });
1936
2019
  config.logger.info(`created ${relative}`);
1937
2020
  if (report)
1938
2021
  report.record(
@@ -1946,7 +2029,7 @@ async function writeManifestIfFreshExternal(config, result, report) {
1946
2029
  async function generateArchitectureFiles(config, report) {
1947
2030
  const result = createEmptyResult();
1948
2031
  const manifest = config.manifest;
1949
- const archRoot = path35__default.join(config.workspaceRoot, ".architecture");
2032
+ const archRoot = path34__default.join(config.workspaceRoot, ".architecture");
1950
2033
  const archInvariants = manifest.monorepo?.archInvariants;
1951
2034
  const { vars, ownershipCollisions } = buildInterpolationVars(manifest);
1952
2035
  const workspaceTemplate = vars.workspaceTemplate ?? "modular-monolith";
@@ -1956,7 +2039,7 @@ async function generateArchitectureFiles(config, report) {
1956
2039
  );
1957
2040
  }
1958
2041
  await writeManifestIfFreshExternal(config, result, report);
1959
- const layerRulesPath = path35__default.join(archRoot, "invariants", "layer-rules.yaml");
2042
+ const layerRulesPath = path34__default.join(archRoot, "invariants", "layer-rules.yaml");
1960
2043
  const layerRulesTemplate = resolveTemplate2(
1961
2044
  archInvariants?.layerRules,
1962
2045
  builtInLayerRules(workspaceTemplate)
@@ -1975,7 +2058,7 @@ async function generateArchitectureFiles(config, report) {
1975
2058
  true
1976
2059
  );
1977
2060
  recordWriteStatus(result, layerRulesPath, layerRulesStatus);
1978
- const linterConfigPath = path35__default.join(
2061
+ const linterConfigPath = path34__default.join(
1979
2062
  archRoot,
1980
2063
  "invariants",
1981
2064
  "linter-config.yaml"
@@ -1998,7 +2081,7 @@ async function generateArchitectureFiles(config, report) {
1998
2081
  true
1999
2082
  );
2000
2083
  recordWriteStatus(result, linterConfigPath, linterConfigStatus);
2001
- const generatorConfigPath = path35__default.join(archRoot, "generator.config.yaml");
2084
+ const generatorConfigPath = path34__default.join(archRoot, "generator.config.yaml");
2002
2085
  const generatorConfigTemplate = resolveTemplate2(
2003
2086
  archInvariants?.generatorConfig,
2004
2087
  GENERATOR_CONFIG_TEMPLATE
@@ -2936,7 +3019,7 @@ ${content}`;
2936
3019
  }
2937
3020
  async function generateEslintConfig(moduleDir, moduleName, config, report, options = {}) {
2938
3021
  const result = createEmptyResult();
2939
- const filePath = path35__default.join(moduleDir, "eslint.config.js");
3022
+ const filePath = path34__default.join(moduleDir, "eslint.config.js");
2940
3023
  try {
2941
3024
  const { template, source } = resolveTemplate3(
2942
3025
  config.manifest,
@@ -3024,9 +3107,9 @@ async function emitAppFile(appDir, relPath, template, vars, config, report, resu
3024
3107
  `apps/${appName}/${relPath}`,
3025
3108
  config
3026
3109
  );
3027
- const target = path35__default.resolve(appDir, relPath);
3028
- const relative = path35__default.relative(appDir, target);
3029
- if (relative === "" || relative.startsWith("..") || path35__default.isAbsolute(relative)) {
3110
+ const target = path34__default.resolve(appDir, relPath);
3111
+ const relative = path34__default.relative(appDir, target);
3112
+ if (relative === "" || relative.startsWith("..") || path34__default.isAbsolute(relative)) {
3030
3113
  config.logger.warn(
3031
3114
  `[apps] skipping file with unsafe path (escapes apps/${appName}): ${relPath}`
3032
3115
  );
@@ -3041,7 +3124,7 @@ async function emitAppFile(appDir, relPath, template, vars, config, report, resu
3041
3124
  }
3042
3125
  if (!config.dryRun && isInScope(target, config)) {
3043
3126
  try {
3044
- await fs27.mkdir(path35__default.dirname(target), { recursive: true });
3127
+ await fs29.mkdir(path34__default.dirname(target), { recursive: true });
3045
3128
  } catch (err3) {
3046
3129
  const message = err3 instanceof Error ? err3.message : String(err3);
3047
3130
  config.logger.error(
@@ -3132,12 +3215,12 @@ async function generateApps(config, report) {
3132
3215
  version: app.version ?? "",
3133
3216
  depends_on: (app.depends_on ?? []).join(", ")
3134
3217
  };
3135
- const appDir = path35__default.join(config.workspaceRoot, "apps", app.name);
3136
- const srcDir = path35__default.join(appDir, "src");
3218
+ const appDir = path34__default.join(config.workspaceRoot, "apps", app.name);
3219
+ const srcDir = path34__default.join(appDir, "src");
3137
3220
  if (!config.dryRun && isInScope(appDir, config)) {
3138
3221
  try {
3139
- await fs27.mkdir(appDir, { recursive: true });
3140
- await fs27.mkdir(srcDir, { recursive: true });
3222
+ await fs29.mkdir(appDir, { recursive: true });
3223
+ await fs29.mkdir(srcDir, { recursive: true });
3141
3224
  } catch (err3) {
3142
3225
  const message = err3 instanceof Error ? err3.message : String(err3);
3143
3226
  config.logger.error(
@@ -3155,7 +3238,7 @@ async function generateApps(config, report) {
3155
3238
  `apps/${app.name}/package.json`,
3156
3239
  config
3157
3240
  );
3158
- const pkgPath = path35__default.join(appDir, "package.json");
3241
+ const pkgPath = path34__default.join(appDir, "package.json");
3159
3242
  const status = await safeWriteFileAtomic(
3160
3243
  pkgPath,
3161
3244
  pkgContent,
@@ -3171,7 +3254,7 @@ async function generateApps(config, report) {
3171
3254
  const tsConfig = frameworkConfig.tsConfig;
3172
3255
  if (tsConfig) {
3173
3256
  const tsContent = JSON.stringify(tsConfig, null, 2) + "\n";
3174
- const tsPath = path35__default.join(appDir, "tsconfig.json");
3257
+ const tsPath = path34__default.join(appDir, "tsconfig.json");
3175
3258
  const status = await safeWriteFileAtomic(
3176
3259
  tsPath,
3177
3260
  tsContent,
@@ -3238,14 +3321,14 @@ async function generateApps(config, report) {
3238
3321
  }
3239
3322
  }
3240
3323
  function relativeImportSpecifier(fromFile, toFile) {
3241
- let rel = path35__default.relative(path35__default.dirname(fromFile), toFile).split(path35__default.sep).join("/").replace(/\.tsx?$/, ".js");
3324
+ let rel = path34__default.relative(path34__default.dirname(fromFile), toFile).split(path34__default.sep).join("/").replace(/\.tsx?$/, ".js");
3242
3325
  if (!rel.startsWith(".")) rel = `./${rel}`;
3243
3326
  return rel;
3244
3327
  }
3245
3328
  function rewriteRelativeSpecifier(specifier, fromFile, toFile) {
3246
3329
  if (!specifier.startsWith(".")) return specifier;
3247
- const absolute = path35__default.resolve(path35__default.dirname(fromFile), specifier);
3248
- let rel = path35__default.relative(path35__default.dirname(toFile), absolute).split(path35__default.sep).join("/");
3330
+ const absolute = path34__default.resolve(path34__default.dirname(fromFile), specifier);
3331
+ let rel = path34__default.relative(path34__default.dirname(toFile), absolute).split(path34__default.sep).join("/");
3249
3332
  if (!rel.startsWith(".")) rel = `./${rel}`;
3250
3333
  return rel;
3251
3334
  }
@@ -3884,13 +3967,13 @@ function resolveNaming(kind, contextNaming, manifestNaming) {
3884
3967
  async function writeStubFile(filePath, content, config, report) {
3885
3968
  if (!isInScope(filePath, config)) {
3886
3969
  config.logger.debug(
3887
- `skipped (outside --only) ${path35__default.relative(config.workspaceRoot, filePath)}`
3970
+ `skipped (outside --only) ${path34__default.relative(config.workspaceRoot, filePath)}`
3888
3971
  );
3889
3972
  return "skipped";
3890
3973
  }
3891
3974
  try {
3892
- await fs27.stat(filePath);
3893
- const relative = path35__default.relative(config.workspaceRoot, filePath);
3975
+ await fs29.stat(filePath);
3976
+ const relative = path34__default.relative(config.workspaceRoot, filePath);
3894
3977
  config.logger.debug(`stub preserved ${relative}`);
3895
3978
  if (report) {
3896
3979
  report.record(
@@ -3906,7 +3989,7 @@ async function writeStubFile(filePath, content, config, report) {
3906
3989
  }
3907
3990
  }
3908
3991
  if (!config.dryRun) {
3909
- await fs27.mkdir(path35__default.dirname(filePath), { recursive: true });
3992
+ await fs29.mkdir(path34__default.dirname(filePath), { recursive: true });
3910
3993
  }
3911
3994
  return safeWriteFileAtomic(filePath, content, config, report, false);
3912
3995
  }
@@ -3929,7 +4012,7 @@ async function tryAnalyzeRelatedPort(moduleDir, name, kind, context, relatedPort
3929
4012
  `${derivedPortName}.ts`
3930
4013
  ];
3931
4014
  for (const filename of possibleFilenames) {
3932
- const portFilePath = path35__default.join(moduleDir, portSubdir, filename);
4015
+ const portFilePath = path34__default.join(moduleDir, portSubdir, filename);
3933
4016
  const analysis = analyzePortFile(portFilePath);
3934
4017
  if (analysis) {
3935
4018
  return analysis;
@@ -3985,7 +4068,7 @@ async function generateStubs(moduleDir, moduleName, config, report) {
3985
4068
  `stubs.naming.${kind}`,
3986
4069
  interpolation
3987
4070
  );
3988
- const filePath = path35__default.join(moduleDir, subdir, filename);
4071
+ const filePath = path34__default.join(moduleDir, subdir, filename);
3989
4072
  let content;
3990
4073
  if (kind === "adapter" || kind === "useCase") {
3991
4074
  const relatedPortNaming = resolveNaming(
@@ -4015,7 +4098,7 @@ async function generateStubs(moduleDir, moduleName, config, report) {
4015
4098
  contextNaming,
4016
4099
  manifestNaming
4017
4100
  );
4018
- const outPortDir = path35__default.join(
4101
+ const outPortDir = path34__default.join(
4019
4102
  moduleDir,
4020
4103
  resolveEmissionDir(layersConfig, "application/ports/out")
4021
4104
  );
@@ -4027,7 +4110,7 @@ async function generateStubs(moduleDir, moduleName, config, report) {
4027
4110
  "stubs.naming.outPort",
4028
4111
  interpolation
4029
4112
  );
4030
- const outPortPath = path35__default.join(outPortDir, outFile);
4113
+ const outPortPath = path34__default.join(outPortDir, outFile);
4031
4114
  const analyzed = analyzePortFile(outPortPath);
4032
4115
  return {
4033
4116
  interfaceName: analyzed?.interfaceName ?? `${base}Port`,
@@ -4130,19 +4213,19 @@ ${methodLines}
4130
4213
  `;
4131
4214
  }
4132
4215
  async function emitPortAndAdapter(result, config, report, scope, spec) {
4133
- const moduleRoot = path35__default.join(
4216
+ const moduleRoot = path34__default.join(
4134
4217
  config.workspaceRoot,
4135
4218
  "packages",
4136
4219
  spec.contextName
4137
4220
  );
4138
- const portDir = path35__default.join(
4221
+ const portDir = path34__default.join(
4139
4222
  moduleRoot,
4140
4223
  "src",
4141
4224
  "application",
4142
4225
  "ports",
4143
4226
  spec.portKind
4144
4227
  );
4145
- const portPath = path35__default.join(
4228
+ const portPath = path34__default.join(
4146
4229
  portDir,
4147
4230
  `${spec.portBase}.${spec.portKind}-port.ts`
4148
4231
  );
@@ -4150,7 +4233,7 @@ async function emitPortAndAdapter(result, config, report, scope, spec) {
4150
4233
  return;
4151
4234
  }
4152
4235
  if (!config.dryRun) {
4153
- await fs27.mkdir(portDir, { recursive: true });
4236
+ await fs29.mkdir(portDir, { recursive: true });
4154
4237
  }
4155
4238
  recordWriteStatus(
4156
4239
  result,
@@ -4175,13 +4258,13 @@ async function emitPortAndAdapter(result, config, report, scope, spec) {
4175
4258
  );
4176
4259
  return;
4177
4260
  }
4178
- const adapterDir = path35__default.join(moduleRoot, "src", "infrastructure", "adapters");
4179
- const adapterPath = path35__default.join(adapterDir, `${spec.portBase}.adapter.ts`);
4261
+ const adapterDir = path34__default.join(moduleRoot, "src", "infrastructure", "adapters");
4262
+ const adapterPath = path34__default.join(adapterDir, `${spec.portBase}.adapter.ts`);
4180
4263
  if (!isInScope(adapterPath, config)) {
4181
4264
  return;
4182
4265
  }
4183
4266
  if (!config.dryRun) {
4184
- await fs27.mkdir(adapterDir, { recursive: true });
4267
+ await fs29.mkdir(adapterDir, { recursive: true });
4185
4268
  }
4186
4269
  const adapterClassName = `${toPascalCaseIdentifier(spec.portBase)}Adapter`;
4187
4270
  const portSpecifier = relativeImportSpecifier(adapterPath, portPath);
@@ -4208,7 +4291,7 @@ function operationImports(ops) {
4208
4291
  return ops.flatMap((op) => [`${op}Request`, `${op}Response`]);
4209
4292
  }
4210
4293
  async function writeSharedContract(result, config, report, relSegments, content) {
4211
- const contractPath = path35__default.join(
4294
+ const contractPath = path34__default.join(
4212
4295
  config.workspaceRoot,
4213
4296
  "packages",
4214
4297
  "shared",
@@ -4216,7 +4299,7 @@ async function writeSharedContract(result, config, report, relSegments, content)
4216
4299
  ...relSegments
4217
4300
  );
4218
4301
  if (!config.dryRun) {
4219
- await fs27.mkdir(path35__default.dirname(contractPath), { recursive: true });
4302
+ await fs29.mkdir(path34__default.dirname(contractPath), { recursive: true });
4220
4303
  }
4221
4304
  recordWriteStatus(
4222
4305
  result,
@@ -4368,7 +4451,7 @@ async function generateSharedKernel(config, report) {
4368
4451
  (bc) => bc.name?.toLowerCase() === "shared"
4369
4452
  );
4370
4453
  if (!hasShared) return result;
4371
- const kernelPath = path35__default.join(
4454
+ const kernelPath = path34__default.join(
4372
4455
  config.workspaceRoot,
4373
4456
  "packages",
4374
4457
  "shared",
@@ -4381,14 +4464,14 @@ async function generateSharedKernel(config, report) {
4381
4464
  return result;
4382
4465
  }
4383
4466
  try {
4384
- await fs27.stat(kernelPath);
4467
+ await fs29.stat(kernelPath);
4385
4468
  result.skipped.push(kernelPath);
4386
4469
  return result;
4387
4470
  } catch (err3) {
4388
4471
  if (err3.code !== "ENOENT") throw err3;
4389
4472
  }
4390
4473
  if (!config.dryRun) {
4391
- await fs27.mkdir(path35__default.dirname(kernelPath), { recursive: true });
4474
+ await fs29.mkdir(path34__default.dirname(kernelPath), { recursive: true });
4392
4475
  }
4393
4476
  const status = await safeWriteFileAtomic(
4394
4477
  kernelPath,
@@ -4867,21 +4950,21 @@ var WorkspaceConfigSchema = z.object({
4867
4950
  turboConfig: z.record(z.unknown()).optional()
4868
4951
  }).passthrough();
4869
4952
  function assertPathWithinArchitecture(workspaceRoot, relativePath) {
4870
- const resolved = path35__default.resolve(workspaceRoot, ".architecture", relativePath);
4871
- const archRoot = path35__default.resolve(workspaceRoot, ".architecture");
4953
+ const resolved = path34__default.resolve(workspaceRoot, ".architecture", relativePath);
4954
+ const archRoot = path34__default.resolve(workspaceRoot, ".architecture");
4872
4955
  try {
4873
4956
  const realResolved = realpathSync(resolved);
4874
4957
  const realArchRoot = realpathSync(archRoot);
4875
- const archRootWithSep = realArchRoot + path35__default.sep;
4958
+ const archRootWithSep = realArchRoot + path34__default.sep;
4876
4959
  if (realResolved !== realArchRoot && !realResolved.startsWith(archRootWithSep)) {
4877
4960
  throw new Error(`Path traversal detected: "${relativePath}" resolves outside .architecture/`);
4878
4961
  }
4879
4962
  } catch (err3) {
4880
4963
  if (err3 instanceof Error && "code" in err3 && err3.code === "ENOENT") {
4881
4964
  let checkPath = archRoot;
4882
- const pathSegments = path35__default.relative(archRoot, resolved).split(path35__default.sep);
4965
+ const pathSegments = path34__default.relative(archRoot, resolved).split(path34__default.sep);
4883
4966
  for (const segment of pathSegments) {
4884
- checkPath = path35__default.join(checkPath, segment);
4967
+ checkPath = path34__default.join(checkPath, segment);
4885
4968
  try {
4886
4969
  const stat = lstatSync(checkPath);
4887
4970
  if (stat.isSymbolicLink()) {
@@ -4897,7 +4980,7 @@ function assertPathWithinArchitecture(workspaceRoot, relativePath) {
4897
4980
  throw statErr;
4898
4981
  }
4899
4982
  }
4900
- const archRootWithSep = archRoot + path35__default.sep;
4983
+ const archRootWithSep = archRoot + path34__default.sep;
4901
4984
  if (resolved !== archRoot && !resolved.startsWith(archRootWithSep)) {
4902
4985
  throw new Error(`Path traversal detected: "${relativePath}" resolves outside .architecture/`);
4903
4986
  }
@@ -4907,7 +4990,7 @@ function assertPathWithinArchitecture(workspaceRoot, relativePath) {
4907
4990
  }
4908
4991
  }
4909
4992
  async function mergeSplitManifest(workspaceRoot, manifestPath) {
4910
- const content = await fs27.readFile(manifestPath, "utf-8");
4993
+ const content = await fs29.readFile(manifestPath, "utf-8");
4911
4994
  const parsed = yaml10.load(content);
4912
4995
  if (parsed == null) {
4913
4996
  throw new Error("Manifest file is empty");
@@ -4936,10 +5019,10 @@ async function mergeSplitManifest(workspaceRoot, manifestPath) {
4936
5019
  };
4937
5020
  if (typeof index.workspace_config === "string") {
4938
5021
  assertPathWithinArchitecture(workspaceRoot, index.workspace_config);
4939
- const sideCarPath = path35__default.join(workspaceRoot, ".architecture", index.workspace_config);
5022
+ const sideCarPath = path34__default.join(workspaceRoot, ".architecture", index.workspace_config);
4940
5023
  let sideCarContent;
4941
5024
  try {
4942
- sideCarContent = await fs27.readFile(sideCarPath, "utf-8");
5025
+ sideCarContent = await fs29.readFile(sideCarPath, "utf-8");
4943
5026
  } catch (err3) {
4944
5027
  if (err3 instanceof Error && "code" in err3 && err3.code === "ENOENT") {
4945
5028
  throw new Error(`Workspace config file not found: ${sideCarPath}`);
@@ -4962,10 +5045,10 @@ async function mergeSplitManifest(workspaceRoot, manifestPath) {
4962
5045
  for (const entry of indexContexts) {
4963
5046
  const indexEntry = entry;
4964
5047
  assertPathWithinArchitecture(workspaceRoot, indexEntry.file);
4965
- const contextFilePath = path35__default.join(workspaceRoot, ".architecture", indexEntry.file);
5048
+ const contextFilePath = path34__default.join(workspaceRoot, ".architecture", indexEntry.file);
4966
5049
  let contextContent;
4967
5050
  try {
4968
- contextContent = await fs27.readFile(contextFilePath, "utf-8");
5051
+ contextContent = await fs29.readFile(contextFilePath, "utf-8");
4969
5052
  } catch (err3) {
4970
5053
  if (err3 instanceof Error && "code" in err3 && err3.code === "ENOENT") {
4971
5054
  throw new Error(`Context file not found: ${contextFilePath}`);
@@ -4997,10 +5080,10 @@ async function mergeSplitManifest(workspaceRoot, manifestPath) {
4997
5080
  continue;
4998
5081
  }
4999
5082
  assertPathWithinArchitecture(workspaceRoot, appEntry.file);
5000
- const appFilePath = path35__default.join(workspaceRoot, ".architecture", appEntry.file);
5083
+ const appFilePath = path34__default.join(workspaceRoot, ".architecture", appEntry.file);
5001
5084
  let appContent;
5002
5085
  try {
5003
- appContent = await fs27.readFile(appFilePath, "utf-8");
5086
+ appContent = await fs29.readFile(appFilePath, "utf-8");
5004
5087
  } catch (err3) {
5005
5088
  if (err3 instanceof Error && "code" in err3 && err3.code === "ENOENT") {
5006
5089
  throw new Error(`App file not found: ${appFilePath}`);
@@ -5019,16 +5102,16 @@ async function mergeSplitManifest(workspaceRoot, manifestPath) {
5019
5102
 
5020
5103
  // src/sync-engine-init.ts
5021
5104
  var __filename$1 = fileURLToPath(import.meta.url);
5022
- var __dirname$1 = path35__default.dirname(__filename$1);
5105
+ var __dirname$1 = path34__default.dirname(__filename$1);
5023
5106
  function isENOENT(err3) {
5024
5107
  return err3 instanceof Error && "code" in err3 && err3.code === "ENOENT";
5025
5108
  }
5026
5109
  async function findRootFrom(startDir, problems) {
5027
5110
  let currentDir = startDir;
5028
- while (currentDir !== path35__default.parse(currentDir).root) {
5029
- const pkgPath = path35__default.join(currentDir, "package.json");
5111
+ while (currentDir !== path34__default.parse(currentDir).root) {
5112
+ const pkgPath = path34__default.join(currentDir, "package.json");
5030
5113
  try {
5031
- const pkgContent = await fs27.readFile(pkgPath, "utf-8");
5114
+ const pkgContent = await fs29.readFile(pkgPath, "utf-8");
5032
5115
  const pkg = JSON.parse(pkgContent);
5033
5116
  if (pkg.workspaces && Array.isArray(pkg.workspaces)) {
5034
5117
  return currentDir;
@@ -5039,7 +5122,7 @@ async function findRootFrom(startDir, problems) {
5039
5122
  problems.push(new Error(`${pkgPath}: ${reason}`));
5040
5123
  }
5041
5124
  }
5042
- currentDir = path35__default.dirname(currentDir);
5125
+ currentDir = path34__default.dirname(currentDir);
5043
5126
  }
5044
5127
  return null;
5045
5128
  }
@@ -5064,7 +5147,7 @@ async function loadManifest(workspaceRoot, flags, options) {
5064
5147
  return { manifest: options.manifest, manifestMissing: false };
5065
5148
  }
5066
5149
  const { logger: logger2, dryRun } = flags;
5067
- const manifestPath = path35__default.join(workspaceRoot, ".architecture/manifest.yaml");
5150
+ const manifestPath = path34__default.join(workspaceRoot, ".architecture/manifest.yaml");
5068
5151
  logger2.debug(`[debug] __dirname (ESM): ${__dirname$1}`);
5069
5152
  logger2.debug(`[debug] resolved workspaceRoot: ${workspaceRoot}`);
5070
5153
  logger2.debug(`[debug] resolved manifestPath: ${manifestPath}`);
@@ -5187,11 +5270,16 @@ var SyncEngine = class {
5187
5270
  );
5188
5271
  continue;
5189
5272
  }
5190
- const moduleDir = path35__default.join(this.workspaceRoot, "packages", mod.name);
5273
+ const moduleDir = path34__default.join(this.workspaceRoot, "packages", mod.name);
5191
5274
  logger2.info(
5192
5275
  `Ensuring directories for module: ${mod.name} at ${moduleDir}`
5193
5276
  );
5194
- const layerResult = await ensureLayerFolders(moduleDir, layers, config);
5277
+ const layerResult = await ensureLayerFolders(
5278
+ moduleDir,
5279
+ layers,
5280
+ config,
5281
+ mod.layers
5282
+ );
5195
5283
  mergeResult2(result, layerResult);
5196
5284
  }
5197
5285
  return result;
@@ -5207,7 +5295,7 @@ var SyncEngine = class {
5207
5295
  const stubs = createEmptyResult();
5208
5296
  for (const module of modules) {
5209
5297
  const moduleName = module.name;
5210
- const moduleDir = path35__default.join(this.workspaceRoot, "packages", moduleName);
5298
+ const moduleDir = path34__default.join(this.workspaceRoot, "packages", moduleName);
5211
5299
  if (moduleName.includes("..") || moduleName.includes("/") || moduleName.startsWith(".")) {
5212
5300
  logger2.warn(
5213
5301
  `Skipping invalid module name (potential path traversal): ${moduleName}`
@@ -5232,6 +5320,11 @@ var SyncEngine = class {
5232
5320
  config,
5233
5321
  this.report
5234
5322
  );
5323
+ const srcIndexResult = await ensurePackageSrcIndex(
5324
+ moduleDir,
5325
+ config,
5326
+ this.report
5327
+ );
5235
5328
  const eslintResult = await generateEslintConfig(
5236
5329
  moduleDir,
5237
5330
  moduleName,
@@ -5247,6 +5340,7 @@ var SyncEngine = class {
5247
5340
  this.noteFailure("Barrels", barrelResult);
5248
5341
  this.noteFailure("package.json", pkgResult);
5249
5342
  this.noteFailure("tsconfig.json", tsResult);
5343
+ this.noteFailure("src/index.ts", srcIndexResult);
5250
5344
  this.noteFailure("ESLint", eslintResult);
5251
5345
  this.noteFailure("Stubs", stubResult);
5252
5346
  if (this.partialConfig.mode === "self-regen") {
@@ -5255,6 +5349,7 @@ var SyncEngine = class {
5255
5349
  mergeResult2(barrels, barrelResult);
5256
5350
  mergeResult2(pkgs, pkgResult);
5257
5351
  mergeResult2(tsconfigs, tsResult);
5352
+ mergeResult2(tsconfigs, srcIndexResult);
5258
5353
  mergeResult2(eslint, eslintResult);
5259
5354
  mergeResult2(stubs, stubResult);
5260
5355
  }
@@ -5386,7 +5481,7 @@ var SyncEngine = class {
5386
5481
  if (!moduleName || moduleName.includes("..") || moduleName.includes("/") || moduleName.startsWith(".")) {
5387
5482
  continue;
5388
5483
  }
5389
- const moduleDir = path35__default.join(this.workspaceRoot, "packages", moduleName);
5484
+ const moduleDir = path34__default.join(this.workspaceRoot, "packages", moduleName);
5390
5485
  const pass2 = await generateBarrels(
5391
5486
  moduleDir,
5392
5487
  this.fullConfig,
@@ -5489,7 +5584,7 @@ Sync completed with ${this.failures.length} generator failure(s) — see the FAI
5489
5584
  } else {
5490
5585
  for (const f of outcome.failures) {
5491
5586
  logger2.error(
5492
- `Rollback failed for ${path35__default.relative(this.workspaceRoot, f.path)}: intended to ${f.intended} — ${f.error}`
5587
+ `Rollback failed for ${path34__default.relative(this.workspaceRoot, f.path)}: intended to ${f.intended} — ${f.error}`
5493
5588
  );
5494
5589
  }
5495
5590
  logger2.error(
@@ -5525,7 +5620,7 @@ function err2(error) {
5525
5620
  var execAsync3 = promisify(exec);
5526
5621
  async function loadManifest2(workspaceRoot) {
5527
5622
  try {
5528
- const manifestPath = path35__default.join(
5623
+ const manifestPath = path34__default.join(
5529
5624
  workspaceRoot,
5530
5625
  ".architecture/manifest.yaml"
5531
5626
  );
@@ -5952,8 +6047,17 @@ function resolveTemplatesDir() {
5952
6047
  if (process.env.HEXAGEN_TEMPLATES_DIR) {
5953
6048
  return process.env.HEXAGEN_TEMPLATES_DIR;
5954
6049
  }
5955
- const cliDir = path35__default.dirname(fileURLToPath(import.meta.url));
5956
- return path35__default.resolve(cliDir, "templates");
6050
+ const cliDir = path34__default.dirname(fileURLToPath(import.meta.url));
6051
+ return path34__default.resolve(cliDir, "templates");
6052
+ }
6053
+ async function lstatExists(target) {
6054
+ try {
6055
+ await promises.lstat(target);
6056
+ return ok2(true);
6057
+ } catch (e) {
6058
+ if (e.code === "ENOENT") return ok2(false);
6059
+ return err2(e instanceof Error ? e : new Error(String(e)));
6060
+ }
5957
6061
  }
5958
6062
 
5959
6063
  // src/commands/arch/port.ts
@@ -7002,8 +7106,23 @@ function emptyConfig() {
7002
7106
  function isInstalled(config, templateId) {
7003
7107
  return templateId in config.templates;
7004
7108
  }
7109
+
7110
+ // ../template-engine/dist/domain/conflict-path.js
7111
+ function posixExtname(filePath) {
7112
+ let end = filePath.length;
7113
+ while (end > 0 && filePath.charCodeAt(end - 1) === 47)
7114
+ end -= 1;
7115
+ const baseStart = filePath.lastIndexOf("/", end - 1) + 1;
7116
+ const base = filePath.slice(baseStart, end);
7117
+ if (base === "." || base === "..")
7118
+ return "";
7119
+ const dot = base.lastIndexOf(".");
7120
+ if (dot <= 0)
7121
+ return "";
7122
+ return base.slice(dot);
7123
+ }
7005
7124
  function conflictFilePath(filePath) {
7006
- const ext = path35__default.extname(filePath);
7125
+ const ext = posixExtname(filePath);
7007
7126
  return ext ? filePath.slice(0, -ext.length) + ".hexagen-update" + ext : filePath + ".hexagen-update";
7008
7127
  }
7009
7128
 
@@ -7246,25 +7365,25 @@ var ValidateTemplatesUseCase = class {
7246
7365
  return { results, totalWarnings, totalErrors };
7247
7366
  }
7248
7367
  };
7249
- var PACKAGE_ROOT = path35__default.resolve(path35__default.dirname(fileURLToPath(import.meta.url)), "..", "..");
7368
+ var PACKAGE_ROOT = path34__default.resolve(path34__default.dirname(fileURLToPath(import.meta.url)), "..", "..");
7250
7369
  var FileSystemTemplateRegistry = class {
7251
7370
  templatesDir;
7252
7371
  cache = null;
7253
7372
  constructor(templatesDir) {
7254
- this.templatesDir = templatesDir ?? path35__default.join(PACKAGE_ROOT, "templates");
7373
+ this.templatesDir = templatesDir ?? path34__default.join(PACKAGE_ROOT, "templates");
7255
7374
  }
7256
7375
  async loadAll() {
7257
7376
  if (this.cache)
7258
7377
  return this.cache;
7259
7378
  let entries;
7260
7379
  try {
7261
- entries = await fs27.readdir(this.templatesDir);
7380
+ entries = await fs29.readdir(this.templatesDir);
7262
7381
  } catch {
7263
7382
  return [];
7264
7383
  }
7265
7384
  const manifests = [];
7266
7385
  for (const entry of entries) {
7267
- const manifestPath = path35__default.join(this.templatesDir, entry, "manifest.json");
7386
+ const manifestPath = path34__default.join(this.templatesDir, entry, "manifest.json");
7268
7387
  const manifest = await this.readManifest(manifestPath);
7269
7388
  if (manifest)
7270
7389
  manifests.push(manifest);
@@ -7273,13 +7392,13 @@ var FileSystemTemplateRegistry = class {
7273
7392
  return manifests;
7274
7393
  }
7275
7394
  async loadOne(id) {
7276
- const manifestPath = path35__default.join(this.templatesDir, id, "manifest.json");
7395
+ const manifestPath = path34__default.join(this.templatesDir, id, "manifest.json");
7277
7396
  return this.readManifest(manifestPath);
7278
7397
  }
7279
7398
  async readManifest(manifestPath) {
7280
7399
  let raw;
7281
7400
  try {
7282
- raw = await fs27.readFile(manifestPath, "utf-8");
7401
+ raw = await fs29.readFile(manifestPath, "utf-8");
7283
7402
  } catch {
7284
7403
  return null;
7285
7404
  }
@@ -7415,35 +7534,35 @@ ${prompt} (comma-separated numbers)`);
7415
7534
  }
7416
7535
  }
7417
7536
  };
7418
- var PACKAGE_ROOT2 = path35__default.resolve(path35__default.dirname(fileURLToPath(import.meta.url)), "..", "..");
7537
+ var PACKAGE_ROOT2 = path34__default.resolve(path34__default.dirname(fileURLToPath(import.meta.url)), "..", "..");
7419
7538
  var FileSystemFileEmitter = class {
7420
7539
  templatesDir;
7421
7540
  withTests;
7422
7541
  constructor(templatesDir, options = {}) {
7423
- this.templatesDir = templatesDir ?? path35__default.join(PACKAGE_ROOT2, "templates");
7542
+ this.templatesDir = templatesDir ?? path34__default.join(PACKAGE_ROOT2, "templates");
7424
7543
  this.withTests = options.withTests ?? false;
7425
7544
  }
7426
7545
  async emit(manifest, answers, projectRoot, config) {
7427
7546
  const warnings = [];
7428
7547
  const generatedFiles = [];
7429
- const templateFilesDir = path35__default.join(this.templatesDir, manifest.id, "files");
7430
- const resolvedRoot = path35__default.resolve(projectRoot);
7548
+ const templateFilesDir = path34__default.join(this.templatesDir, manifest.id, "files");
7549
+ const resolvedRoot = path34__default.resolve(projectRoot);
7431
7550
  for (const out of manifest.outputs) {
7432
7551
  if (!isOutputEnabled(out, answers))
7433
7552
  continue;
7434
7553
  const outputRelPath = outputPath(out);
7435
7554
  if (!this.withTests && isTestOutput(outputRelPath))
7436
7555
  continue;
7437
- const destFile = path35__default.resolve(projectRoot, outputRelPath);
7438
- if (!destFile.startsWith(resolvedRoot + path35__default.sep) && destFile !== resolvedRoot) {
7556
+ const destFile = path34__default.resolve(projectRoot, outputRelPath);
7557
+ if (!destFile.startsWith(resolvedRoot + path34__default.sep) && destFile !== resolvedRoot) {
7439
7558
  throw new Error(`Output path '${outputRelPath}' escapes the project root`);
7440
7559
  }
7441
- const sourceFile = path35__default.join(templateFilesDir, outputRelPath);
7560
+ const sourceFile = path34__default.join(templateFilesDir, outputRelPath);
7442
7561
  let templateContent;
7443
7562
  let sourceMode = 420;
7444
7563
  try {
7445
- const raw = await fs27.readFile(sourceFile, "utf-8");
7446
- sourceMode = (await fs27.stat(sourceFile)).mode & 511;
7564
+ const raw = await fs29.readFile(sourceFile, "utf-8");
7565
+ sourceMode = (await fs29.stat(sourceFile)).mode & 511;
7447
7566
  const { output, warnings: interpWarnings } = interpolate(raw, answers);
7448
7567
  templateContent = output;
7449
7568
  for (const key of interpWarnings) {
@@ -7458,7 +7577,7 @@ var FileSystemFileEmitter = class {
7458
7577
  const templateHash = sha256(templateContent);
7459
7578
  let existingContent = null;
7460
7579
  try {
7461
- existingContent = await fs27.readFile(destFile, "utf-8");
7580
+ existingContent = await fs29.readFile(destFile, "utf-8");
7462
7581
  } catch {
7463
7582
  }
7464
7583
  if (existingContent !== null) {
@@ -7468,7 +7587,7 @@ var FileSystemFileEmitter = class {
7468
7587
  if (!isAlreadyIdentical && !wasGeneratedByHexagen) {
7469
7588
  const conflictDest = conflictFilePath(destFile);
7470
7589
  await atomicWrite(conflictDest, templateContent, sourceMode);
7471
- const rel = path35__default.relative(projectRoot, conflictDest);
7590
+ const rel = path34__default.relative(projectRoot, conflictDest);
7472
7591
  warnings.push(`⚠️ Conflict: ${outputRelPath} has local changes.
7473
7592
  New version written to ${rel}
7474
7593
  Review and merge manually, then delete the conflict file.`);
@@ -7482,18 +7601,18 @@ var FileSystemFileEmitter = class {
7482
7601
  }
7483
7602
  };
7484
7603
  async function atomicWrite(filePath, content, mode) {
7485
- await fs27.mkdir(path35__default.dirname(filePath), { recursive: true });
7604
+ await fs29.mkdir(path34__default.dirname(filePath), { recursive: true });
7486
7605
  const tmp = `${filePath}.tmp.${Date.now()}`;
7487
7606
  try {
7488
- await fs27.writeFile(tmp, content, "utf-8");
7607
+ await fs29.writeFile(tmp, content, "utf-8");
7489
7608
  if (mode !== void 0 && (mode & 73) !== 0) {
7490
- const created = (await fs27.stat(tmp)).mode & 511;
7609
+ const created = (await fs29.stat(tmp)).mode & 511;
7491
7610
  const execBits = mode & 73 & ~process.umask();
7492
- await fs27.chmod(tmp, created | execBits);
7611
+ await fs29.chmod(tmp, created | execBits);
7493
7612
  }
7494
- await fs27.rename(tmp, filePath);
7613
+ await fs29.rename(tmp, filePath);
7495
7614
  } catch (err3) {
7496
- await fs27.rm(tmp, { force: true }).catch(() => {
7615
+ await fs29.rm(tmp, { force: true }).catch(() => {
7497
7616
  });
7498
7617
  throw err3;
7499
7618
  }
@@ -7503,9 +7622,9 @@ function sha256(content) {
7503
7622
  }
7504
7623
  var FileSystemTemplateConfigStore = class {
7505
7624
  async load(projectRoot) {
7506
- const configPath = path35__default.join(projectRoot, TEMPLATE_CONFIG_FILE);
7625
+ const configPath = path34__default.join(projectRoot, TEMPLATE_CONFIG_FILE);
7507
7626
  try {
7508
- const raw = await fs27.readFile(configPath, "utf-8");
7627
+ const raw = await fs29.readFile(configPath, "utf-8");
7509
7628
  return JSON.parse(raw);
7510
7629
  } catch (err3) {
7511
7630
  if (err3.code === "ENOENT")
@@ -7514,16 +7633,16 @@ var FileSystemTemplateConfigStore = class {
7514
7633
  }
7515
7634
  }
7516
7635
  async save(projectRoot, config) {
7517
- const configPath = path35__default.join(projectRoot, TEMPLATE_CONFIG_FILE);
7636
+ const configPath = path34__default.join(projectRoot, TEMPLATE_CONFIG_FILE);
7518
7637
  const tmp = `${configPath}.tmp.${Date.now()}`;
7519
- await fs27.writeFile(tmp, JSON.stringify(config, null, 2), "utf-8");
7520
- await fs27.rename(tmp, configPath);
7638
+ await fs29.writeFile(tmp, JSON.stringify(config, null, 2), "utf-8");
7639
+ await fs29.rename(tmp, configPath);
7521
7640
  }
7522
7641
  };
7523
7642
  var FileSystemProjectFilePresence = class {
7524
7643
  async exists(projectRoot, relativePath) {
7525
7644
  try {
7526
- await fs27.access(path35__default.join(projectRoot, relativePath));
7645
+ await fs29.access(path34__default.join(projectRoot, relativePath));
7527
7646
  return true;
7528
7647
  } catch {
7529
7648
  return false;
@@ -7975,35 +8094,35 @@ var FileSystemWorkspaceAdapter = class {
7975
8094
  }
7976
8095
  workspaceRoot;
7977
8096
  listPackages() {
7978
- const packagesDir = path35.join(this.workspaceRoot, "packages");
7979
- if (!fs24.existsSync(packagesDir)) {
8097
+ const packagesDir = path34.join(this.workspaceRoot, "packages");
8098
+ if (!fs26.existsSync(packagesDir)) {
7980
8099
  return [];
7981
8100
  }
7982
- return fs24.readdirSync(packagesDir, { withFileTypes: true }).filter((dirent) => dirent.isDirectory()).map((dirent) => dirent.name);
8101
+ return fs26.readdirSync(packagesDir, { withFileTypes: true }).filter((dirent) => dirent.isDirectory()).map((dirent) => dirent.name);
7983
8102
  }
7984
8103
  listApps() {
7985
- const appsDir = path35.join(this.workspaceRoot, "apps");
7986
- if (!fs24.existsSync(appsDir)) {
8104
+ const appsDir = path34.join(this.workspaceRoot, "apps");
8105
+ if (!fs26.existsSync(appsDir)) {
7987
8106
  return [];
7988
8107
  }
7989
- return fs24.readdirSync(appsDir, { withFileTypes: true }).filter((dirent) => dirent.isDirectory()).map((dirent) => dirent.name);
8108
+ return fs26.readdirSync(appsDir, { withFileTypes: true }).filter((dirent) => dirent.isDirectory()).map((dirent) => dirent.name);
7990
8109
  }
7991
8110
  getSourceFiles(dir) {
7992
- if (!fs24.existsSync(dir)) {
8111
+ if (!fs26.existsSync(dir)) {
7993
8112
  return [];
7994
8113
  }
7995
- const entries = fs24.readdirSync(dir, { withFileTypes: true });
8114
+ const entries = fs26.readdirSync(dir, { withFileTypes: true });
7996
8115
  return entries.map((entry) => ({
7997
- path: path35.join(dir, entry.name),
8116
+ path: path34.join(dir, entry.name),
7998
8117
  isDirectory: entry.isDirectory()
7999
8118
  }));
8000
8119
  }
8001
8120
  fileExists(filePath) {
8002
- return fs24.existsSync(filePath);
8121
+ return fs26.existsSync(filePath);
8003
8122
  }
8004
8123
  readFile(filePath) {
8005
8124
  try {
8006
- return fs24.readFileSync(filePath, "utf-8");
8125
+ return fs26.readFileSync(filePath, "utf-8");
8007
8126
  } catch {
8008
8127
  return null;
8009
8128
  }
@@ -8031,15 +8150,24 @@ var TsMorphSymbolIndexAdapter = class {
8031
8150
  }
8032
8151
  }
8033
8152
  findReferences(symbolName) {
8034
- return this.project.getSourceFiles().filter((file) => file.getFullText().includes(symbolName)).map((file) => ({
8035
- // `getFilePath()` returns a StandardizedFilePath: absolute and
8036
- // slash-separated even on Windows. That is exactly the dialect the DTO
8037
- // promises, so it crosses the boundary unmodified.
8038
- filePath: file.getFilePath(),
8039
- reason: describeReference(file, symbolName)
8040
- }));
8153
+ return this.project.getSourceFiles().filter((file) => file.getFullText().includes(symbolName)).map((file) => {
8154
+ const diagnostics = syntacticDiagnosticsOf(this.project, file);
8155
+ return {
8156
+ // `getFilePath()` returns a StandardizedFilePath: absolute and
8157
+ // slash-separated even on Windows. That is exactly the dialect the DTO
8158
+ // promises, so it crosses the boundary unmodified.
8159
+ filePath: file.getFilePath(),
8160
+ reason: describeReference(file, symbolName),
8161
+ ...diagnostics.length > 0 ? { diagnostics } : {}
8162
+ };
8163
+ });
8041
8164
  }
8042
8165
  };
8166
+ function syntacticDiagnosticsOf(project, file) {
8167
+ return project.getProgram().compilerObject.getSyntacticDiagnostics(file.compilerNode).map(
8168
+ (diagnostic) => ts.flattenDiagnosticMessageText(diagnostic.messageText, " ")
8169
+ );
8170
+ }
8043
8171
  function describeReference(file, symbolName) {
8044
8172
  for (const iface of file.getInterfaces()) {
8045
8173
  if (iface.getName() === symbolName) {
@@ -8089,7 +8217,7 @@ var layoutSchema = z.object({
8089
8217
 
8090
8218
  // src/infrastructure/config/load-layout-config.ts
8091
8219
  function loadLayoutConfig(workspaceRoot) {
8092
- const filePath = path35__default.join(
8220
+ const filePath = path34__default.join(
8093
8221
  workspaceRoot,
8094
8222
  ...LAYOUT_YAML_RELATIVE_PATH.split("/")
8095
8223
  );
@@ -8113,14 +8241,20 @@ function loadLayoutConfig(workspaceRoot) {
8113
8241
  // src/domain/services/impact-request-validator.ts
8114
8242
  function validateRenameRequest(type, newName) {
8115
8243
  if (!newName || newName.trim() === "") {
8116
- return { valid: false, error: "New name is required for rename operations" };
8244
+ return {
8245
+ valid: false,
8246
+ error: "New name is required for rename operations"
8247
+ };
8117
8248
  }
8118
8249
  if (type === "rename-port") {
8119
8250
  if (!newName.endsWith("Port")) {
8120
8251
  return { valid: false, error: "Port names must end with 'Port'" };
8121
8252
  }
8122
8253
  if (!/^[A-Z][a-zA-Z0-9]*Port$/.test(newName)) {
8123
- return { valid: false, error: "Port names must be in PascalCase and end with 'Port'" };
8254
+ return {
8255
+ valid: false,
8256
+ error: "Port names must be in PascalCase and end with 'Port'"
8257
+ };
8124
8258
  }
8125
8259
  }
8126
8260
  if (type === "rename-use-case") {
@@ -8128,7 +8262,10 @@ function validateRenameRequest(type, newName) {
8128
8262
  return { valid: false, error: "Use case names must end with 'UseCase'" };
8129
8263
  }
8130
8264
  if (!/^[A-Z][a-zA-Z0-9]*UseCase$/.test(newName)) {
8131
- return { valid: false, error: "Use case names must be in PascalCase and end with 'UseCase'" };
8265
+ return {
8266
+ valid: false,
8267
+ error: "Use case names must be in PascalCase and end with 'UseCase'"
8268
+ };
8132
8269
  }
8133
8270
  }
8134
8271
  if (type === "rename-entity") {
@@ -8143,7 +8280,10 @@ function validateMoveRequest(type, newLocation) {
8143
8280
  return { valid: true };
8144
8281
  }
8145
8282
  if (!newLocation || newLocation.trim() === "") {
8146
- return { valid: false, error: "New location is required for move operations" };
8283
+ return {
8284
+ valid: false,
8285
+ error: "New location is required for move operations"
8286
+ };
8147
8287
  }
8148
8288
  return { valid: true };
8149
8289
  }
@@ -8343,7 +8483,8 @@ var RefactoringImpactUseCase = class {
8343
8483
  const warnings = this.generateWarnings(
8344
8484
  filesToModify,
8345
8485
  crossPackageDeps,
8346
- architecturalImpact
8486
+ architecturalImpact,
8487
+ references
8347
8488
  );
8348
8489
  const estimatedChanges = this.estimateChanges(filesToModify);
8349
8490
  return ok2({
@@ -8450,7 +8591,7 @@ var RefactoringImpactUseCase = class {
8450
8591
  assessImpact(files, crossPackageDeps) {
8451
8592
  return assessArchitecturalImpact(files, crossPackageDeps, this.manifest);
8452
8593
  }
8453
- generateWarnings(files, crossPackageDeps, architecturalImpact) {
8594
+ generateWarnings(files, crossPackageDeps, architecturalImpact, references) {
8454
8595
  const warnings = [];
8455
8596
  if (architecturalImpact === "BOUNDARY_VIOLATION") {
8456
8597
  warnings.push("This refactoring would violate architectural boundaries");
@@ -8477,6 +8618,18 @@ var RefactoringImpactUseCase = class {
8477
8618
  `This refactoring will require updating ${testFiles.length} test files`
8478
8619
  );
8479
8620
  }
8621
+ for (const reference of references) {
8622
+ if (reference.diagnostics === void 0 || reference.diagnostics.length === 0) {
8623
+ continue;
8624
+ }
8625
+ const relativePath = toWorkspaceRelativePosixPath(
8626
+ this.workspaceRoot,
8627
+ reference.filePath
8628
+ );
8629
+ warnings.push(
8630
+ `Could not parse ${relativePath} (syntactic); impact for this file is incomplete`
8631
+ );
8632
+ }
8480
8633
  return warnings;
8481
8634
  }
8482
8635
  estimateChanges(files) {
@@ -8558,15 +8711,15 @@ async function updateBarrelExport(sourceFile, oldName, newName) {
8558
8711
  }
8559
8712
  async function updateManifestEntry(workspaceRoot, updateFn) {
8560
8713
  try {
8561
- const manifestPath = path35__default.join(
8714
+ const manifestPath = path34__default.join(
8562
8715
  workspaceRoot,
8563
8716
  ".architecture/manifest.yaml"
8564
8717
  );
8565
- const content = await fs27.readFile(manifestPath, "utf-8");
8718
+ const content = await fs29.readFile(manifestPath, "utf-8");
8566
8719
  const manifest = yaml10.load(content);
8567
8720
  updateFn(manifest);
8568
8721
  const updatedContent = yaml10.dump(manifest, { indent: 2 });
8569
- await fs27.writeFile(manifestPath, updatedContent, "utf-8");
8722
+ await fs29.writeFile(manifestPath, updatedContent, "utf-8");
8570
8723
  return ok2(void 0);
8571
8724
  } catch (error) {
8572
8725
  return err2(error);
@@ -8630,7 +8783,7 @@ var RenamePortPattern = class {
8630
8783
  (f) => f.reason.includes("Declares")
8631
8784
  );
8632
8785
  for (const file of portFiles) {
8633
- const filePath = path35__default.join(this.workspaceRoot, file.path);
8786
+ const filePath = path34__default.join(this.workspaceRoot, file.path);
8634
8787
  const sourceFile = this.project.addSourceFileAtPath(filePath);
8635
8788
  const existingInterface = sourceFile.getInterface(request.newName);
8636
8789
  if (existingInterface) {
@@ -8652,7 +8805,7 @@ var RenamePortPattern = class {
8652
8805
  const warnings = [];
8653
8806
  try {
8654
8807
  for (const file of impact.filesToModify) {
8655
- const filePath = path35__default.join(this.workspaceRoot, file.path);
8808
+ const filePath = path34__default.join(this.workspaceRoot, file.path);
8656
8809
  if (file.path.endsWith(".ts") || file.path.endsWith(".tsx")) {
8657
8810
  try {
8658
8811
  this.project.addSourceFileAtPath(filePath);
@@ -8755,7 +8908,7 @@ var RenamePortPattern = class {
8755
8908
  */
8756
8909
  async renamePortFile(relativePath, oldName, newName) {
8757
8910
  try {
8758
- const filePath = path35__default.join(this.workspaceRoot, relativePath);
8911
+ const filePath = path34__default.join(this.workspaceRoot, relativePath);
8759
8912
  const sourceFile = this.project.getSourceFile(filePath);
8760
8913
  if (!sourceFile) {
8761
8914
  return err2(new Error(`Source file not found: ${relativePath}`));
@@ -8768,17 +8921,17 @@ var RenamePortPattern = class {
8768
8921
  if (typeAlias) {
8769
8922
  typeAlias.rename(newName);
8770
8923
  }
8771
- const oldFileName = path35__default.basename(relativePath);
8924
+ const oldFileName = path34__default.basename(relativePath);
8772
8925
  const newFileName = oldFileName.replace(
8773
8926
  toKebabCase(oldName),
8774
8927
  toKebabCase(newName)
8775
8928
  );
8776
8929
  if (oldFileName !== newFileName) {
8777
- const newFilePath = path35__default.join(path35__default.dirname(filePath), newFileName);
8930
+ const newFilePath = path34__default.join(path34__default.dirname(filePath), newFileName);
8778
8931
  await sourceFile.move(newFilePath);
8779
8932
  return ok2([
8780
8933
  relativePath,
8781
- path35__default.relative(this.workspaceRoot, newFilePath)
8934
+ path34__default.relative(this.workspaceRoot, newFilePath)
8782
8935
  ]);
8783
8936
  }
8784
8937
  return ok2([relativePath]);
@@ -8791,7 +8944,7 @@ var RenamePortPattern = class {
8791
8944
  */
8792
8945
  async updateImports(relativePath, oldName, newName) {
8793
8946
  try {
8794
- const filePath = path35__default.join(this.workspaceRoot, relativePath);
8947
+ const filePath = path34__default.join(this.workspaceRoot, relativePath);
8795
8948
  const sourceFile = this.project.getSourceFile(filePath);
8796
8949
  if (!sourceFile) {
8797
8950
  return ok2([]);
@@ -8807,7 +8960,7 @@ var RenamePortPattern = class {
8807
8960
  */
8808
8961
  async updateBarrelExport(relativePath, oldName, newName) {
8809
8962
  try {
8810
- const filePath = path35__default.join(this.workspaceRoot, relativePath);
8963
+ const filePath = path34__default.join(this.workspaceRoot, relativePath);
8811
8964
  const sourceFile = this.project.getSourceFile(filePath);
8812
8965
  if (!sourceFile) {
8813
8966
  return ok2([]);
@@ -8850,7 +9003,7 @@ var RenamePortPattern = class {
8850
9003
  */
8851
9004
  async updateTestDouble(relativePath, oldName, newName) {
8852
9005
  try {
8853
- const filePath = path35__default.join(this.workspaceRoot, relativePath);
9006
+ const filePath = path34__default.join(this.workspaceRoot, relativePath);
8854
9007
  const sourceFile = this.project.getSourceFile(filePath);
8855
9008
  if (!sourceFile) {
8856
9009
  return ok2([]);
@@ -8880,17 +9033,17 @@ var RenamePortPattern = class {
8880
9033
  );
8881
9034
  modified = modified || importsModified;
8882
9035
  if (modified) {
8883
- const oldFileName = path35__default.basename(relativePath);
9036
+ const oldFileName = path34__default.basename(relativePath);
8884
9037
  const newFileName = oldFileName.replace(
8885
9038
  toKebabCase(oldName),
8886
9039
  toKebabCase(newName)
8887
9040
  );
8888
9041
  if (oldFileName !== newFileName) {
8889
- const newFilePath = path35__default.join(path35__default.dirname(filePath), newFileName);
9042
+ const newFilePath = path34__default.join(path34__default.dirname(filePath), newFileName);
8890
9043
  await sourceFile.move(newFilePath);
8891
9044
  return ok2([
8892
9045
  relativePath,
8893
- path35__default.relative(this.workspaceRoot, newFilePath)
9046
+ path34__default.relative(this.workspaceRoot, newFilePath)
8894
9047
  ]);
8895
9048
  }
8896
9049
  }
@@ -8963,7 +9116,7 @@ var RenameUseCasePattern = class {
8963
9116
  const warnings = [];
8964
9117
  try {
8965
9118
  for (const file of impact.filesToModify) {
8966
- const filePath = path35__default.join(this.workspaceRoot, file.path);
9119
+ const filePath = path34__default.join(this.workspaceRoot, file.path);
8967
9120
  if (file.path.endsWith(".ts") || file.path.endsWith(".tsx")) {
8968
9121
  try {
8969
9122
  this.project.addSourceFileAtPath(filePath);
@@ -9074,7 +9227,7 @@ var RenameUseCasePattern = class {
9074
9227
  */
9075
9228
  async renameUseCaseFile(relativePath, oldName, newName) {
9076
9229
  try {
9077
- const filePath = path35__default.join(this.workspaceRoot, relativePath);
9230
+ const filePath = path34__default.join(this.workspaceRoot, relativePath);
9078
9231
  const sourceFile = this.project.getSourceFile(filePath);
9079
9232
  if (!sourceFile) {
9080
9233
  return err2(new Error(`Source file not found: ${relativePath}`));
@@ -9083,17 +9236,17 @@ var RenameUseCasePattern = class {
9083
9236
  if (classDecl) {
9084
9237
  classDecl.rename(newName);
9085
9238
  }
9086
- const oldFileName = path35__default.basename(relativePath);
9239
+ const oldFileName = path34__default.basename(relativePath);
9087
9240
  const newFileName = oldFileName.replace(
9088
9241
  toKebabCase(oldName),
9089
9242
  toKebabCase(newName)
9090
9243
  );
9091
9244
  if (oldFileName !== newFileName) {
9092
- const newFilePath = path35__default.join(path35__default.dirname(filePath), newFileName);
9245
+ const newFilePath = path34__default.join(path34__default.dirname(filePath), newFileName);
9093
9246
  await sourceFile.move(newFilePath);
9094
9247
  return ok2([
9095
9248
  relativePath,
9096
- path35__default.relative(this.workspaceRoot, newFilePath)
9249
+ path34__default.relative(this.workspaceRoot, newFilePath)
9097
9250
  ]);
9098
9251
  }
9099
9252
  return ok2([relativePath]);
@@ -9103,7 +9256,7 @@ var RenameUseCasePattern = class {
9103
9256
  }
9104
9257
  async updateImports(relativePath, oldName, newName) {
9105
9258
  try {
9106
- const filePath = path35__default.join(this.workspaceRoot, relativePath);
9259
+ const filePath = path34__default.join(this.workspaceRoot, relativePath);
9107
9260
  const sourceFile = this.project.getSourceFile(filePath);
9108
9261
  if (!sourceFile) {
9109
9262
  return ok2([]);
@@ -9119,7 +9272,7 @@ var RenameUseCasePattern = class {
9119
9272
  */
9120
9273
  async updateBarrelExport(relativePath, oldName, newName) {
9121
9274
  try {
9122
- const filePath = path35__default.join(this.workspaceRoot, relativePath);
9275
+ const filePath = path34__default.join(this.workspaceRoot, relativePath);
9123
9276
  const sourceFile = this.project.getSourceFile(filePath);
9124
9277
  if (!sourceFile) {
9125
9278
  return ok2([]);
@@ -9156,24 +9309,24 @@ var RenameUseCasePattern = class {
9156
9309
  */
9157
9310
  async updateTestFile(relativePath, oldName, newName) {
9158
9311
  try {
9159
- const filePath = path35__default.join(this.workspaceRoot, relativePath);
9312
+ const filePath = path34__default.join(this.workspaceRoot, relativePath);
9160
9313
  const sourceFile = this.project.getSourceFile(filePath);
9161
9314
  if (!sourceFile) {
9162
9315
  return ok2([]);
9163
9316
  }
9164
9317
  const modified = await updateImports(sourceFile, oldName, newName);
9165
9318
  if (modified) {
9166
- const oldFileName = path35__default.basename(relativePath);
9319
+ const oldFileName = path34__default.basename(relativePath);
9167
9320
  const newFileName = oldFileName.replace(
9168
9321
  toKebabCase(oldName),
9169
9322
  toKebabCase(newName)
9170
9323
  );
9171
9324
  if (oldFileName !== newFileName) {
9172
- const newFilePath = path35__default.join(path35__default.dirname(filePath), newFileName);
9325
+ const newFilePath = path34__default.join(path34__default.dirname(filePath), newFileName);
9173
9326
  await sourceFile.move(newFilePath);
9174
9327
  return ok2([
9175
9328
  relativePath,
9176
- path35__default.relative(this.workspaceRoot, newFilePath)
9329
+ path34__default.relative(this.workspaceRoot, newFilePath)
9177
9330
  ]);
9178
9331
  }
9179
9332
  }
@@ -9184,7 +9337,7 @@ var RenameUseCasePattern = class {
9184
9337
  }
9185
9338
  async updateCompositionRoot(relativePath, oldName, newName) {
9186
9339
  try {
9187
- const filePath = path35__default.join(this.workspaceRoot, relativePath);
9340
+ const filePath = path34__default.join(this.workspaceRoot, relativePath);
9188
9341
  const sourceFile = this.project.getSourceFile(filePath);
9189
9342
  if (!sourceFile) {
9190
9343
  return ok2([]);
@@ -9254,7 +9407,7 @@ var RenameEntityPattern = class {
9254
9407
  if (file.path.endsWith(".ts") || file.path.endsWith(".tsx")) {
9255
9408
  try {
9256
9409
  this.project.addSourceFileAtPath(
9257
- path35__default.join(this.workspaceRoot, file.path)
9410
+ path34__default.join(this.workspaceRoot, file.path)
9258
9411
  );
9259
9412
  } catch {
9260
9413
  }
@@ -9312,7 +9465,7 @@ var RenameEntityPattern = class {
9312
9465
  async renameEntityFile(relativePath, oldName, newName) {
9313
9466
  try {
9314
9467
  const sourceFile = this.project.getSourceFile(
9315
- path35__default.join(this.workspaceRoot, relativePath)
9468
+ path34__default.join(this.workspaceRoot, relativePath)
9316
9469
  );
9317
9470
  if (!sourceFile) return err2(new Error(`File not found: ${relativePath}`));
9318
9471
  const classDecl = sourceFile.getClass(oldName);
@@ -9329,7 +9482,7 @@ var RenameEntityPattern = class {
9329
9482
  async updateReferences(relativePath, oldName, newName) {
9330
9483
  try {
9331
9484
  const sourceFile = this.project.getSourceFile(
9332
- path35__default.join(this.workspaceRoot, relativePath)
9485
+ path34__default.join(this.workspaceRoot, relativePath)
9333
9486
  );
9334
9487
  if (!sourceFile) return ok2([]);
9335
9488
  let modified = false;
@@ -9348,11 +9501,11 @@ var RenameEntityPattern = class {
9348
9501
  }
9349
9502
  async updateManifest(oldName, newName) {
9350
9503
  try {
9351
- const manifestPath = path35__default.join(
9504
+ const manifestPath = path34__default.join(
9352
9505
  this.workspaceRoot,
9353
9506
  ".architecture/manifest.yaml"
9354
9507
  );
9355
- const content = await fs27.readFile(manifestPath, "utf-8");
9508
+ const content = await fs29.readFile(manifestPath, "utf-8");
9356
9509
  const manifest = yaml10.load(content);
9357
9510
  if (manifest.bounded_contexts) {
9358
9511
  for (const context of manifest.bounded_contexts) {
@@ -9364,7 +9517,7 @@ var RenameEntityPattern = class {
9364
9517
  }
9365
9518
  }
9366
9519
  }
9367
- await fs27.writeFile(
9520
+ await fs29.writeFile(
9368
9521
  manifestPath,
9369
9522
  yaml10.dump(manifest, { indent: 2 }),
9370
9523
  "utf-8"
@@ -10048,7 +10201,7 @@ var manifestSplitCommander = new Command("split").description("Split monolithic
10048
10201
  const dryRun = options.dryRun ?? false;
10049
10202
  try {
10050
10203
  const workspaceRoot = await findWorkspaceRoot({});
10051
- const monolithicManifestPath = path35__default.join(
10204
+ const monolithicManifestPath = path34__default.join(
10052
10205
  workspaceRoot,
10053
10206
  ".architecture/manifest.yaml"
10054
10207
  );
@@ -10057,7 +10210,7 @@ var manifestSplitCommander = new Command("split").description("Split monolithic
10057
10210
  );
10058
10211
  let manifestContent;
10059
10212
  try {
10060
- manifestContent = await fs27.readFile(monolithicManifestPath, "utf-8");
10213
+ manifestContent = await fs29.readFile(monolithicManifestPath, "utf-8");
10061
10214
  } catch {
10062
10215
  throw new Error(`Failed to read manifest.yaml. Does it exist?`);
10063
10216
  }
@@ -10085,14 +10238,14 @@ Validation successful. Found ${contexts.length} bounded contexts.`
10085
10238
  const planes = rawYaml.planes ?? {};
10086
10239
  const planeLookup = buildPlaneLookup(planes);
10087
10240
  console.log("Splitting manifest into the new directory structure...");
10088
- const archDir = path35__default.join(workspaceRoot, ".architecture");
10089
- const contextsDir = path35__default.join(archDir, "contexts");
10090
- const appsDir = path35__default.join(archDir, "apps");
10091
- const invariantsDir = path35__default.join(archDir, "invariants");
10241
+ const archDir = path34__default.join(workspaceRoot, ".architecture");
10242
+ const contextsDir = path34__default.join(archDir, "contexts");
10243
+ const appsDir = path34__default.join(archDir, "apps");
10244
+ const invariantsDir = path34__default.join(archDir, "invariants");
10092
10245
  if (!dryRun) {
10093
- await fs27.mkdir(contextsDir, { recursive: true });
10094
- await fs27.mkdir(appsDir, { recursive: true });
10095
- await fs27.mkdir(invariantsDir, { recursive: true });
10246
+ await fs29.mkdir(contextsDir, { recursive: true });
10247
+ await fs29.mkdir(appsDir, { recursive: true });
10248
+ await fs29.mkdir(invariantsDir, { recursive: true });
10096
10249
  }
10097
10250
  const CATEGORY_B_KEYS = /* @__PURE__ */ new Set(["monorepo", "generator"]);
10098
10251
  const workspaceConfig = {};
@@ -10132,12 +10285,12 @@ Validation successful. Found ${contexts.length} bounded contexts.`
10132
10285
  }
10133
10286
  for (const ctx of contexts) {
10134
10287
  const plane = planeLookup.get(ctx.name) ?? ctx.plane ?? "core";
10135
- const ctxDir = path35__default.join(contextsDir, plane, ctx.name);
10288
+ const ctxDir = path34__default.join(contextsDir, plane, ctx.name);
10136
10289
  const contextData = normalizeContextData(
10137
10290
  extractContextData(ctx)
10138
10291
  );
10139
10292
  contextData.plane = plane;
10140
- const ctxFilePath = path35__default.join(ctxDir, "context.yaml");
10293
+ const ctxFilePath = path34__default.join(ctxDir, "context.yaml");
10141
10294
  const ctxYaml = yaml10.dump(contextData, {
10142
10295
  noRefs: true,
10143
10296
  sortKeys: false,
@@ -10146,8 +10299,8 @@ Validation successful. Found ${contexts.length} bounded contexts.`
10146
10299
  if (dryRun) {
10147
10300
  console.log(`[dry-run] Would create: ${ctxFilePath}`);
10148
10301
  } else {
10149
- await fs27.mkdir(ctxDir, { recursive: true });
10150
- await fs27.writeFile(ctxFilePath, ctxYaml, "utf-8");
10302
+ await fs29.mkdir(ctxDir, { recursive: true });
10303
+ await fs29.writeFile(ctxFilePath, ctxYaml, "utf-8");
10151
10304
  }
10152
10305
  indexManifest.bounded_contexts.push({
10153
10306
  name: ctx.name,
@@ -10163,7 +10316,7 @@ Validation successful. Found ${contexts.length} bounded contexts.`
10163
10316
  if (typeof app === "object" && app !== null && "name" in app) {
10164
10317
  const typedApp = app;
10165
10318
  const appName = typedApp.name;
10166
- const appFilePath = path35__default.join(appsDir, `${appName}.app.yaml`);
10319
+ const appFilePath = path34__default.join(appsDir, `${appName}.app.yaml`);
10167
10320
  const appYaml = yaml10.dump(app, {
10168
10321
  noRefs: true,
10169
10322
  sortKeys: false,
@@ -10172,7 +10325,7 @@ Validation successful. Found ${contexts.length} bounded contexts.`
10172
10325
  if (dryRun) {
10173
10326
  console.log(`[dry-run] Would create: ${appFilePath}`);
10174
10327
  } else {
10175
- await fs27.writeFile(appFilePath, appYaml, "utf-8");
10328
+ await fs29.writeFile(appFilePath, appYaml, "utf-8");
10176
10329
  }
10177
10330
  indexManifest.apps.push({
10178
10331
  name: appName,
@@ -10180,7 +10333,7 @@ Validation successful. Found ${contexts.length} bounded contexts.`
10180
10333
  });
10181
10334
  }
10182
10335
  }
10183
- const workspaceConfigPath = path35__default.join(archDir, "workspace.config.yaml");
10336
+ const workspaceConfigPath = path34__default.join(archDir, "workspace.config.yaml");
10184
10337
  const workspaceConfigYaml = yaml10.dump(workspaceConfig, {
10185
10338
  noRefs: true,
10186
10339
  sortKeys: false,
@@ -10191,7 +10344,7 @@ Validation successful. Found ${contexts.length} bounded contexts.`
10191
10344
  console.log("\n--- Preview of workspace.config.yaml ---\n");
10192
10345
  console.log(workspaceConfigYaml);
10193
10346
  } else {
10194
- await fs27.writeFile(workspaceConfigPath, workspaceConfigYaml, "utf-8");
10347
+ await fs29.writeFile(workspaceConfigPath, workspaceConfigYaml, "utf-8");
10195
10348
  }
10196
10349
  const indexYaml = yaml10.dump(indexManifest, {
10197
10350
  noRefs: true,
@@ -10212,9 +10365,9 @@ Validation successful. Found ${contexts.length} bounded contexts.`
10212
10365
  console.log(header + indexYaml);
10213
10366
  } else {
10214
10367
  const backupPath = monolithicManifestPath + ".pre-split-backup";
10215
- await fs27.copyFile(monolithicManifestPath, backupPath);
10368
+ await fs29.copyFile(monolithicManifestPath, backupPath);
10216
10369
  console.log(`Backup created at ${backupPath}`);
10217
- await fs27.writeFile(monolithicManifestPath, header + indexYaml, "utf-8");
10370
+ await fs29.writeFile(monolithicManifestPath, header + indexYaml, "utf-8");
10218
10371
  }
10219
10372
  console.log("\n✅ Manifest split completed successfully!");
10220
10373
  if (dryRun) {
@@ -10237,10 +10390,12 @@ Validation successful. Found ${contexts.length} bounded contexts.`
10237
10390
  });
10238
10391
  var MANIFEST_MIGRATIONS = [];
10239
10392
  var MigrateManifestUseCase = class {
10240
- constructor(currentVersion = CURRENT_MANIFEST_SCHEMA_VERSION, migrations = MANIFEST_MIGRATIONS) {
10393
+ constructor(deepEqual, currentVersion = CURRENT_MANIFEST_SCHEMA_VERSION, migrations = MANIFEST_MIGRATIONS) {
10394
+ this.deepEqual = deepEqual;
10241
10395
  this.currentVersion = currentVersion;
10242
10396
  this.migrations = migrations;
10243
10397
  }
10398
+ deepEqual;
10244
10399
  currentVersion;
10245
10400
  migrations;
10246
10401
  execute(content) {
@@ -10308,7 +10463,7 @@ var MigrateManifestUseCase = class {
10308
10463
  let stampedCleanly = false;
10309
10464
  try {
10310
10465
  const reparsed = yaml10.load(after);
10311
- stampedCleanly = readManifestSchemaVersion(reparsed) === this.currentVersion && isDeepStrictEqual(
10466
+ stampedCleanly = readManifestSchemaVersion(reparsed) === this.currentVersion && this.deepEqual(
10312
10467
  {
10313
10468
  ...yaml10.load(before),
10314
10469
  schemaVersion: this.currentVersion
@@ -10332,17 +10487,19 @@ var manifestMigrateCommander = new Command("migrate").description(
10332
10487
  const dryRun = options.dryRun ?? false;
10333
10488
  try {
10334
10489
  const workspaceRoot = await findWorkspaceRoot({});
10335
- const manifestPath = path35__default.join(
10490
+ const manifestPath = path34__default.join(
10336
10491
  workspaceRoot,
10337
10492
  ".architecture/manifest.yaml"
10338
10493
  );
10339
10494
  let content;
10340
10495
  try {
10341
- content = await fs27.readFile(manifestPath, "utf-8");
10496
+ content = await fs29.readFile(manifestPath, "utf-8");
10342
10497
  } catch {
10343
10498
  throw new Error(`Failed to read ${manifestPath}. Does it exist?`);
10344
10499
  }
10345
- const result = new MigrateManifestUseCase().execute(content);
10500
+ const result = new MigrateManifestUseCase(isDeepStrictEqual).execute(
10501
+ content
10502
+ );
10346
10503
  const from = result.fromVersion === void 0 ? "legacy (no schemaVersion)" : `schemaVersion ${result.fromVersion}`;
10347
10504
  console.log(`Manifest: ${manifestPath}`);
10348
10505
  console.log(`From : ${from}`);
@@ -10363,15 +10520,15 @@ var manifestMigrateCommander = new Command("migrate").description(
10363
10520
  return;
10364
10521
  }
10365
10522
  const backupPath = manifestPath + ".pre-migrate-backup";
10366
- await fs27.copyFile(manifestPath, backupPath);
10523
+ await fs29.copyFile(manifestPath, backupPath);
10367
10524
  console.log(`
10368
10525
  Backup created at ${backupPath}`);
10369
10526
  const tempPath = manifestPath + ".tmp";
10370
10527
  try {
10371
- await fs27.writeFile(tempPath, result.content, "utf-8");
10372
- await fs27.rename(tempPath, manifestPath);
10528
+ await fs29.writeFile(tempPath, result.content, "utf-8");
10529
+ await fs29.rename(tempPath, manifestPath);
10373
10530
  } catch (writeErr) {
10374
- await fs27.rm(tempPath, { force: true });
10531
+ await fs29.rm(tempPath, { force: true });
10375
10532
  throw writeErr;
10376
10533
  }
10377
10534
  console.log("✅ Manifest migrated successfully.");
@@ -10413,17 +10570,17 @@ async function pathExists(p) {
10413
10570
  }
10414
10571
  async function expandGlob(root, glob) {
10415
10572
  if (glob.endsWith("/*") && !glob.slice(0, -2).includes("*")) {
10416
- const dir = path35__default.join(root, glob.slice(0, -2));
10573
+ const dir = path34__default.join(root, glob.slice(0, -2));
10417
10574
  if (!await pathExists(dir)) return [];
10418
10575
  const entries = await promises.readdir(dir, { withFileTypes: true });
10419
- return entries.filter((e) => e.isDirectory() && !e.name.startsWith(".")).map((e) => path35__default.join(glob.slice(0, -2), e.name));
10576
+ return entries.filter((e) => e.isDirectory() && !e.name.startsWith(".")).map((e) => path34__default.join(glob.slice(0, -2), e.name));
10420
10577
  }
10421
10578
  if (glob.includes("*")) {
10422
10579
  throw new Error(
10423
10580
  `Complex globs like '${glob}' are not supported. Only simple trailing '/*' globs are currently supported.`
10424
10581
  );
10425
10582
  }
10426
- const abs = path35__default.join(root, glob);
10583
+ const abs = path34__default.join(root, glob);
10427
10584
  return await pathExists(abs) ? [glob] : [];
10428
10585
  }
10429
10586
  async function detectLayers(absRoot) {
@@ -10431,7 +10588,7 @@ async function detectLayers(absRoot) {
10431
10588
  for (const [layer, candidates] of Object.entries(LAYER_ALIASES)) {
10432
10589
  const found = [];
10433
10590
  for (const candidate of candidates) {
10434
- if (await pathExists(path35__default.join(absRoot, candidate))) {
10591
+ if (await pathExists(path34__default.join(absRoot, candidate))) {
10435
10592
  found.push(candidate);
10436
10593
  }
10437
10594
  }
@@ -10445,7 +10602,7 @@ function contextNameFrom(pkgName, dirName) {
10445
10602
  return dirName;
10446
10603
  }
10447
10604
  async function detectWorkspaces(root) {
10448
- const pkgPath = path35__default.join(root, "package.json");
10605
+ const pkgPath = path34__default.join(root, "package.json");
10449
10606
  let pkg = {};
10450
10607
  try {
10451
10608
  pkg = JSON.parse(await promises.readFile(pkgPath, "utf8"));
@@ -10458,17 +10615,17 @@ async function detectWorkspaces(root) {
10458
10615
  const packages = [];
10459
10616
  const seenNames = /* @__PURE__ */ new Set();
10460
10617
  for (const rel of candidates) {
10461
- const abs = path35__default.join(root, rel);
10618
+ const abs = path34__default.join(root, rel);
10462
10619
  let packageName;
10463
10620
  try {
10464
10621
  const child = JSON.parse(
10465
- await promises.readFile(path35__default.join(abs, "package.json"), "utf8")
10622
+ await promises.readFile(path34__default.join(abs, "package.json"), "utf8")
10466
10623
  );
10467
10624
  packageName = child.name;
10468
10625
  } catch {
10469
10626
  packageName = void 0;
10470
10627
  }
10471
- const dirName = rel === "." ? path35__default.basename(root) : path35__default.basename(rel);
10628
+ const dirName = rel === "." ? path34__default.basename(root) : path34__default.basename(rel);
10472
10629
  const name = contextNameFrom(packageName, dirName);
10473
10630
  if (seenNames.has(name)) {
10474
10631
  throw new Error(
@@ -10478,12 +10635,12 @@ async function detectWorkspaces(root) {
10478
10635
  seenNames.add(name);
10479
10636
  packages.push({
10480
10637
  name,
10481
- root: rel === "." ? "." : rel.split(path35__default.sep).join("/"),
10638
+ root: rel === "." ? "." : rel.split(path34__default.sep).join("/"),
10482
10639
  packageName,
10483
10640
  layers: await detectLayers(abs)
10484
10641
  });
10485
10642
  }
10486
- const system = typeof pkg.name === "string" && pkg.name.length > 0 ? pkg.name.replace(/^@[^/]+\//, "") : path35__default.basename(root);
10643
+ const system = typeof pkg.name === "string" && pkg.name.length > 0 ? pkg.name.replace(/^@[^/]+\//, "") : path34__default.basename(root);
10487
10644
  return { system, packages };
10488
10645
  }
10489
10646
 
@@ -10512,7 +10669,7 @@ async function runAdopt(options) {
10512
10669
  );
10513
10670
  }
10514
10671
  const contents = serializeLayout(detection);
10515
- const layoutPath = path35__default.join(options.root, ".architecture", "layout.yaml");
10672
+ const layoutPath = path34__default.join(options.root, ".architecture", "layout.yaml");
10516
10673
  if (options.dryRun === true) {
10517
10674
  return ok2({
10518
10675
  layoutPath,
@@ -10527,9 +10684,10 @@ async function runAdopt(options) {
10527
10684
  )
10528
10685
  );
10529
10686
  }
10530
- await promises.mkdir(path35__default.dirname(layoutPath), { recursive: true });
10531
- const exists = await promises.stat(layoutPath).then(() => true).catch(() => false);
10532
- if (exists && options.force !== true) {
10687
+ await promises.mkdir(path34__default.dirname(layoutPath), { recursive: true });
10688
+ const existsLookup = await lstatExists(layoutPath);
10689
+ if (!existsLookup.success) return existsLookup;
10690
+ if (existsLookup.value && options.force !== true) {
10533
10691
  return err2(
10534
10692
  new Error(
10535
10693
  `Refusing to overwrite existing ${layoutPath}. Pass --force to overwrite.`
@@ -10537,10 +10695,13 @@ async function runAdopt(options) {
10537
10695
  );
10538
10696
  }
10539
10697
  await promises.writeFile(layoutPath, contents, "utf8");
10540
- const hasManifest = await promises.stat(path35__default.join(options.root, ".architecture", "manifest.yaml")).then(() => true).catch(() => false);
10698
+ const manifestLookup = await lstatExists(
10699
+ path34__default.join(options.root, ".architecture", "manifest.yaml")
10700
+ );
10701
+ if (!manifestLookup.success) return manifestLookup;
10541
10702
  const nextSteps = [
10542
- `Wrote ${path35__default.relative(options.root, layoutPath) || ".architecture/layout.yaml"}.`,
10543
- hasManifest ? "Run `hexagen-lint --root .` to produce a first report (vacuous runs exit 2)." : "No manifest yet — run `hexagen bootstrap --yes` (or answer its questions) before linting."
10703
+ `Wrote ${path34__default.relative(options.root, layoutPath) || ".architecture/layout.yaml"}.`,
10704
+ manifestLookup.value ? "Run `hexagen-lint --root .` to produce a first report (vacuous runs exit 2)." : "No manifest yet — run `hexagen bootstrap --yes` (or answer its questions) before linting."
10544
10705
  ];
10545
10706
  if (options.invokeLint === true) {
10546
10707
  nextSteps.push(
@@ -10554,7 +10715,7 @@ async function runAdopt(options) {
10554
10715
  }
10555
10716
  async function adoptCommand(options) {
10556
10717
  const result = await runAdopt({
10557
- root: path35__default.resolve(options.root ?? process.cwd()),
10718
+ root: path34__default.resolve(options.root ?? process.cwd()),
10558
10719
  yes: options.yes,
10559
10720
  dryRun: options.dryRun,
10560
10721
  invokeLint: options.invokeLint,
@@ -10584,10 +10745,6 @@ var EMPTY_BASELINE = `{
10584
10745
  "entries": []
10585
10746
  }
10586
10747
  `;
10587
- function sanitizeScope2(raw) {
10588
- const cleaned = raw.trim().toLowerCase().replace(/^@+/, "").replace(/[^a-z0-9._-]/g, "-").replace(/[._-]{2,}/g, "-").slice(0, 214).replace(/^[._-]+|[._-]+$/g, "");
10589
- return cleaned.length > 0 ? cleaned : "generated-project";
10590
- }
10591
10748
  async function readAnswers(options) {
10592
10749
  if (options.answersPath) {
10593
10750
  try {
@@ -10624,7 +10781,7 @@ async function proposeAnswers(root, yes) {
10624
10781
  if (yes) {
10625
10782
  return ok2({
10626
10783
  system: detection.system,
10627
- scope: sanitizeScope2(detection.system),
10784
+ scope: sanitizeScope(detection.system),
10628
10785
  architecture: "modular-monolith",
10629
10786
  contexts: detection.packages.map((pkg) => ({
10630
10787
  name: pkg.name,
@@ -10649,7 +10806,7 @@ async function proposeAnswers(root, yes) {
10649
10806
  const system = await promptService.ask(
10650
10807
  `System name [${detection.system}]: `
10651
10808
  );
10652
- const scopeDefault = sanitizeScope2(system || detection.system);
10809
+ const scopeDefault = sanitizeScope(system || detection.system);
10653
10810
  const scope = await promptService.ask(`npm scope [${scopeDefault}]: `);
10654
10811
  const contexts = [];
10655
10812
  for (const pkg of detection.packages) {
@@ -10669,7 +10826,7 @@ async function proposeAnswers(root, yes) {
10669
10826
  }
10670
10827
  return ok2({
10671
10828
  system: system || detection.system,
10672
- scope: sanitizeScope2(scope || scopeDefault),
10829
+ scope: sanitizeScope(scope || scopeDefault),
10673
10830
  architecture: "modular-monolith",
10674
10831
  contexts
10675
10832
  });
@@ -10681,7 +10838,7 @@ function emitManifest(answers) {
10681
10838
  return yaml10.dump(
10682
10839
  {
10683
10840
  system: answers.system ?? "app",
10684
- scope: sanitizeScope2(answers.scope ?? answers.system ?? "app"),
10841
+ scope: sanitizeScope(answers.scope ?? answers.system ?? "app"),
10685
10842
  architecture: answers.architecture ?? "modular-monolith",
10686
10843
  bounded_contexts: answers.contexts.filter((c) => c.include).map((c) => ({
10687
10844
  name: c.name,
@@ -10740,24 +10897,22 @@ async function runBootstrap(options) {
10740
10897
  );
10741
10898
  }
10742
10899
  const detection = await detectWorkspaces(options.root);
10743
- const archDir = path35__default.join(options.root, ".architecture");
10900
+ const archDir = path34__default.join(options.root, ".architecture");
10744
10901
  const files = [
10745
- path35__default.join(archDir, "manifest.yaml"),
10746
- path35__default.join(archDir, "layout.yaml"),
10747
- path35__default.join(archDir, "arch-lint-baseline.json")
10902
+ path34__default.join(archDir, "manifest.yaml"),
10903
+ ...options.skipLayout === true ? [] : [path34__default.join(archDir, "layout.yaml")],
10904
+ path34__default.join(archDir, "arch-lint-baseline.json")
10748
10905
  ];
10749
- if (options.dryRun === true) {
10750
- return ok2({ files, wrote: false });
10751
- }
10752
10906
  if (options.force !== true) {
10753
10907
  const blockers = [];
10754
10908
  for (const file of files) {
10755
10909
  try {
10756
- await promises.stat(file);
10757
- } catch {
10758
- continue;
10910
+ await promises.lstat(file);
10911
+ } catch (e) {
10912
+ if (e.code === "ENOENT") continue;
10913
+ return err2(e instanceof Error ? e : new Error(String(e)));
10759
10914
  }
10760
- if (path35__default.basename(file) === "arch-lint-baseline.json") {
10915
+ if (path34__default.basename(file) === "arch-lint-baseline.json") {
10761
10916
  try {
10762
10917
  const parsed = JSON.parse(await promises.readFile(file, "utf8"));
10763
10918
  if (Array.isArray(parsed.entries) && parsed.entries.length > 0) {
@@ -10780,12 +10935,16 @@ ${blockers.map((b) => ` ${b}`).join("\n")}`
10780
10935
  );
10781
10936
  }
10782
10937
  }
10938
+ if (options.dryRun === true) {
10939
+ return ok2({ files, wrote: false });
10940
+ }
10783
10941
  await promises.mkdir(archDir, { recursive: true });
10784
- for (const [i, content] of [
10942
+ const contents = [
10785
10943
  emitManifest(answers),
10786
- emitLayout(answers, detection),
10944
+ ...options.skipLayout === true ? [] : [emitLayout(answers, detection)],
10787
10945
  EMPTY_BASELINE
10788
- ].entries()) {
10946
+ ];
10947
+ for (const [i, content] of contents.entries()) {
10789
10948
  await promises.writeFile(`${files[i]}.tmp`, content, "utf8");
10790
10949
  }
10791
10950
  for (const f of files) {
@@ -10798,7 +10957,7 @@ ${blockers.map((b) => ` ${b}`).join("\n")}`
10798
10957
  }
10799
10958
  async function bootstrapCommand(options) {
10800
10959
  const result = await runBootstrap({
10801
- root: path35__default.resolve(options.root ?? process.cwd()),
10960
+ root: path34__default.resolve(options.root ?? process.cwd()),
10802
10961
  yes: options.yes,
10803
10962
  answersPath: options.answers,
10804
10963
  stdinJson: options.stdinJson,
@@ -10828,7 +10987,7 @@ async function bootstrapCommand(options) {
10828
10987
  console.log("Dry-run: no files were written.");
10829
10988
  }
10830
10989
  var bootstrapCommander = new Command("bootstrap").description(
10831
- "Propose candidate bounded contexts as questions and emit manifest.yaml + layout.yaml + arch-lint-baseline.json after ratification"
10990
+ "Propose candidate bounded contexts as questions and emit manifest.yaml + layout.yaml + arch-lint-baseline.json after ratification. Does not infer depends_on from the import graph; supply contexts[].dependsOn in --answers if you need declared edges."
10832
10991
  ).option("--root <path>", "Project root (defaults to cwd)").option("--yes", "Accept every detected candidate (for tests / CI)").option(
10833
10992
  "--answers <file>",
10834
10993
  "JSON answers file (deterministic, non-interactive)"
@@ -11029,8 +11188,8 @@ var EMPTY_DRIFT = {
11029
11188
  collected: false
11030
11189
  };
11031
11190
  function buildEngagementReport(input) {
11032
- const baselinePath = path35__default.join(input.workspaceRoot, DEFAULT_BASELINE_REL);
11033
- const layoutPath = path35__default.join(input.workspaceRoot, DEFAULT_LAYOUT_REL);
11191
+ const baselinePath = path34__default.join(input.workspaceRoot, DEFAULT_BASELINE_REL);
11192
+ const layoutPath = path34__default.join(input.workspaceRoot, DEFAULT_LAYOUT_REL);
11034
11193
  const baselinePresent = existsSync(baselinePath);
11035
11194
  let suppressions = [];
11036
11195
  if (baselinePresent) {
@@ -11346,7 +11505,7 @@ function buildHandoffZip(report, workspaceRoot) {
11346
11505
  `
11347
11506
  }
11348
11507
  ];
11349
- const manifestPath = path35__default.join(
11508
+ const manifestPath = path34__default.join(
11350
11509
  workspaceRoot,
11351
11510
  ".architecture",
11352
11511
  "manifest.yaml"
@@ -11357,14 +11516,14 @@ function buildHandoffZip(report, workspaceRoot) {
11357
11516
  content: readFileSync(manifestPath, "utf8")
11358
11517
  });
11359
11518
  }
11360
- const layoutPath = path35__default.join(workspaceRoot, DEFAULT_LAYOUT_REL);
11519
+ const layoutPath = path34__default.join(workspaceRoot, DEFAULT_LAYOUT_REL);
11361
11520
  if (existsSync(layoutPath)) {
11362
11521
  entries.push({
11363
11522
  name: "layout.yaml",
11364
11523
  content: readFileSync(layoutPath, "utf8")
11365
11524
  });
11366
11525
  }
11367
- const baselinePath = path35__default.join(workspaceRoot, DEFAULT_BASELINE_REL);
11526
+ const baselinePath = path34__default.join(workspaceRoot, DEFAULT_BASELINE_REL);
11368
11527
  if (existsSync(baselinePath)) {
11369
11528
  entries.push({
11370
11529
  name: "arch-lint-baseline.json",
@@ -11460,11 +11619,11 @@ async function reportCommand(options = {}) {
11460
11619
  git: createGitReader(workspaceRoot),
11461
11620
  lint: createSpawnLintCollector(workspaceRoot)
11462
11621
  });
11463
- const outDir = path35__default.resolve(workspaceRoot, options.out ?? ".");
11622
+ const outDir = path34__default.resolve(workspaceRoot, options.out ?? ".");
11464
11623
  mkdirSync(outDir, { recursive: true });
11465
11624
  const format = options.format ?? "both";
11466
- const markdownPath = path35__default.join(outDir, "hexagen-report.md");
11467
- const htmlPath = path35__default.join(outDir, "hexagen-report.html");
11625
+ const markdownPath = path34__default.join(outDir, "hexagen-report.md");
11626
+ const htmlPath = path34__default.join(outDir, "hexagen-report.html");
11468
11627
  if (format === "md" || format === "both") {
11469
11628
  writeFileSync(markdownPath, renderReportMarkdown(report), "utf8");
11470
11629
  }
@@ -11473,11 +11632,11 @@ async function reportCommand(options = {}) {
11473
11632
  }
11474
11633
  let handoffPath;
11475
11634
  if (options.handoff) {
11476
- handoffPath = path35__default.resolve(
11635
+ handoffPath = path34__default.resolve(
11477
11636
  workspaceRoot,
11478
- options.handoffOut ?? path35__default.join(outDir, "hexagen-handoff.zip")
11637
+ options.handoffOut ?? path34__default.join(outDir, "hexagen-handoff.zip")
11479
11638
  );
11480
- mkdirSync(path35__default.dirname(handoffPath), { recursive: true });
11639
+ mkdirSync(path34__default.dirname(handoffPath), { recursive: true });
11481
11640
  writeFileSync(handoffPath, buildHandoffZip(report, workspaceRoot));
11482
11641
  }
11483
11642
  return { markdownPath, htmlPath, handoffPath };
@@ -11502,6 +11661,414 @@ async function runReportCommand(options) {
11502
11661
  }
11503
11662
  }
11504
11663
 
11664
+ // src/commands/scan/index.ts
11665
+ function readRequiredArtifact(filePath) {
11666
+ return readFileSync(filePath, "utf8");
11667
+ }
11668
+ function readOptionalArtifact(filePath) {
11669
+ try {
11670
+ return readFileSync(filePath, "utf8");
11671
+ } catch (e) {
11672
+ if (e?.code === "ENOENT") return null;
11673
+ throw e;
11674
+ }
11675
+ }
11676
+ function lintVerdict(exitCode) {
11677
+ if (exitCode === 0) {
11678
+ return "Architecture check passed (exit 0).";
11679
+ }
11680
+ if (exitCode === 1) {
11681
+ return "Architecture check found violations (exit 1). See hexagen-lint output.";
11682
+ }
11683
+ return `Architecture check could not run or scanned zero files (exit ${exitCode}). This is not a pass.`;
11684
+ }
11685
+ function uncollectedFindings(failureReason) {
11686
+ return {
11687
+ fresh: [],
11688
+ baselined: [],
11689
+ stale: [],
11690
+ expired: [],
11691
+ collected: false,
11692
+ failureReason
11693
+ };
11694
+ }
11695
+ function toLintOutcome(value) {
11696
+ if (typeof value === "number") {
11697
+ return {
11698
+ exitCode: value,
11699
+ findings: uncollectedFindings(
11700
+ "the lint runner reported an exit code only; hexagen-lint --json was not read"
11701
+ ),
11702
+ filesScanned: null
11703
+ };
11704
+ }
11705
+ return value;
11706
+ }
11707
+ function parseJsonRecord(line) {
11708
+ try {
11709
+ const value = JSON.parse(line);
11710
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
11711
+ return { ok: false, error: new Error("not a JSON object") };
11712
+ }
11713
+ return { ok: true, value };
11714
+ } catch (e) {
11715
+ return { ok: false, error: e instanceof Error ? e : new Error(String(e)) };
11716
+ }
11717
+ }
11718
+ function collectFilesScanned(stdout) {
11719
+ const line = stdout.split(/\r?\n/).map((l) => l.trim()).filter((l) => l.startsWith("{")).at(-1);
11720
+ if (line === void 0) return null;
11721
+ const parsed = parseJsonRecord(line);
11722
+ if (!parsed.ok) return null;
11723
+ {
11724
+ const raw = parsed.value;
11725
+ return typeof raw.filesScanned === "number" && Number.isInteger(raw.filesScanned) && raw.filesScanned > 0 ? raw.filesScanned : null;
11726
+ }
11727
+ }
11728
+ function collectLintFindings(stdout) {
11729
+ let parsed;
11730
+ try {
11731
+ parsed = parseLintJson(stdout);
11732
+ } catch (e) {
11733
+ return uncollectedFindings(
11734
+ `hexagen-lint --json output was not valid JSON: ${e instanceof Error ? e.message : String(e)}`
11735
+ );
11736
+ }
11737
+ if (!parsed.collected && parsed.failureReason === void 0) {
11738
+ return uncollectedFindings(
11739
+ "hexagen-lint --json printed no JSON line, so no findings could be read"
11740
+ );
11741
+ }
11742
+ return parsed;
11743
+ }
11744
+ var LINT_STDOUT_MAX_BYTES = 32 * 1024 * 1024;
11745
+ function invokeHexagenLint(root) {
11746
+ const bin = resolveArchLinterBin(root);
11747
+ if (bin === null) {
11748
+ console.error(
11749
+ "hexagen-lint not found — architecture was not checked (exit 2)."
11750
+ );
11751
+ return {
11752
+ exitCode: 2,
11753
+ findings: uncollectedFindings("hexagen-lint binary was not found"),
11754
+ filesScanned: null
11755
+ };
11756
+ }
11757
+ const useNode = /\.[cm]?js$/i.test(bin);
11758
+ const lintArgs = ["--root", root, "--json", "--ratchet"];
11759
+ const result = spawnSync(
11760
+ useNode ? process.execPath : bin,
11761
+ useNode ? [bin, ...lintArgs] : lintArgs,
11762
+ {
11763
+ cwd: root,
11764
+ stdio: ["ignore", "pipe", "inherit"],
11765
+ encoding: "utf8",
11766
+ maxBuffer: LINT_STDOUT_MAX_BYTES,
11767
+ timeout: resolveLinterTimeoutMs()
11768
+ }
11769
+ );
11770
+ if (result.error) {
11771
+ const errno = result.error.code;
11772
+ const message = errno === "ENOBUFS" ? `hexagen-lint produced more than ${LINT_STDOUT_MAX_BYTES} bytes of output and was stopped — architecture was not checked (exit 2).` : errno === "ETIMEDOUT" ? `hexagen-lint timed out and was stopped — architecture was not checked (exit 2).` : `hexagen-lint failed to start: ${result.error.message}`;
11773
+ console.error(message);
11774
+ return {
11775
+ exitCode: 2,
11776
+ findings: uncollectedFindings(message),
11777
+ filesScanned: null
11778
+ };
11779
+ }
11780
+ const stdout = typeof result.stdout === "string" ? result.stdout : "";
11781
+ for (const line of stdout.split(/\r?\n/)) {
11782
+ const trimmed = line.trim();
11783
+ if (trimmed !== "" && !trimmed.startsWith("{")) {
11784
+ console.log(line);
11785
+ }
11786
+ }
11787
+ if (result.status == null) {
11788
+ return {
11789
+ exitCode: 2,
11790
+ findings: uncollectedFindings(
11791
+ `hexagen-lint exited without a status code${result.signal ? ` (killed by ${result.signal})` : ""}`
11792
+ ),
11793
+ filesScanned: null
11794
+ };
11795
+ }
11796
+ return {
11797
+ exitCode: result.status,
11798
+ findings: collectLintFindings(stdout),
11799
+ filesScanned: collectFilesScanned(stdout)
11800
+ };
11801
+ }
11802
+ async function previewScan(root, options) {
11803
+ const layoutPath = path34__default.join(root, ".architecture", "layout.yaml");
11804
+ const manifestPath = path34__default.join(root, ".architecture", "manifest.yaml");
11805
+ const adopted = await runAdopt({ root, dryRun: true });
11806
+ if (!adopted.success) return adopted;
11807
+ const nextSteps = [...adopted.value.nextSteps];
11808
+ const manifestLookup = await lstatExists(manifestPath);
11809
+ if (!manifestLookup.success) return manifestLookup;
11810
+ if (!manifestLookup.value && options.skipBootstrap !== true) {
11811
+ const detection = await detectWorkspaces(root);
11812
+ nextSteps.push("Proposed bootstrap answers (not written):");
11813
+ nextSteps.push(` system: ${detection.system}`);
11814
+ nextSteps.push(" architecture: modular-monolith");
11815
+ for (const pkg of detection.packages) {
11816
+ nextSteps.push(` - ${pkg.name} (${pkg.root})`);
11817
+ }
11818
+ const bootstrapped = await runBootstrap({
11819
+ root,
11820
+ yes: true,
11821
+ dryRun: true,
11822
+ skipLayout: true
11823
+ });
11824
+ if (!bootstrapped.success) return bootstrapped;
11825
+ nextSteps.push("Would write:");
11826
+ for (const file of bootstrapped.value.files) {
11827
+ nextSteps.push(` ${file}`);
11828
+ }
11829
+ }
11830
+ return ok2({
11831
+ layoutPath,
11832
+ manifestPath,
11833
+ wrote: false,
11834
+ lintExitCode: 0,
11835
+ reportPaths: [],
11836
+ nextSteps,
11837
+ // --dry-run writes nothing, so there is nothing to report on. The envelope
11838
+ // is still emitted so a machine consumer gets the same shape on every
11839
+ // path and never has to special-case "preview returned no JSON".
11840
+ envelope: {
11841
+ schemaVersion: CURRENT_SCHEMA_VERSION,
11842
+ layout: null,
11843
+ filesScanned: null,
11844
+ reportMarkdown: null,
11845
+ error: null,
11846
+ // --dry-run never spawns the linter, so there is nothing to report.
11847
+ // Stated as an uncollected summary with a reason rather than four empty
11848
+ // arrays, which a consumer would render as "a clean tree".
11849
+ findings: uncollectedFindings("--dry-run does not run hexagen-lint")
11850
+ }
11851
+ });
11852
+ }
11853
+ async function runScan(options) {
11854
+ try {
11855
+ const root = options.root;
11856
+ const layoutPath = path34__default.join(root, ".architecture", "layout.yaml");
11857
+ const manifestPath = path34__default.join(root, ".architecture", "manifest.yaml");
11858
+ if (options.handoff === true && options.noReport === true) {
11859
+ return err2(
11860
+ new Error(
11861
+ "--handoff needs the engagement report; drop --no-report (the handoff zip is packed from the report)."
11862
+ )
11863
+ );
11864
+ }
11865
+ if (options.handoff === true && options.dryRun === true) {
11866
+ return err2(
11867
+ new Error(
11868
+ "--handoff writes a file, so it cannot be combined with --dry-run. Re-run with --yes to produce the handoff zip."
11869
+ )
11870
+ );
11871
+ }
11872
+ if (options.dryRun === true) {
11873
+ return previewScan(root, options);
11874
+ }
11875
+ if (options.yes !== true) {
11876
+ return err2(
11877
+ new Error(
11878
+ "Refusing to write architecture files without ratification. Re-run with --yes, or pass --dry-run to preview."
11879
+ )
11880
+ );
11881
+ }
11882
+ const layoutLookup = await lstatExists(layoutPath);
11883
+ if (!layoutLookup.success) return layoutLookup;
11884
+ const layoutExists = layoutLookup.value;
11885
+ const nextSteps = [];
11886
+ let wroteLayout = false;
11887
+ if (!layoutExists || options.force === true) {
11888
+ const adopted = await runAdopt({
11889
+ root,
11890
+ yes: true,
11891
+ force: options.force
11892
+ });
11893
+ if (!adopted.success) return adopted;
11894
+ wroteLayout = adopted.value.wrote;
11895
+ nextSteps.push(
11896
+ ...adopted.value.nextSteps.filter(
11897
+ (line) => !/No manifest yet/.test(line) && !/hexagen-lint --root/.test(line)
11898
+ )
11899
+ );
11900
+ } else {
11901
+ nextSteps.push(
11902
+ `Kept existing ${path34__default.relative(root, layoutPath) || ".architecture/layout.yaml"}.`
11903
+ );
11904
+ }
11905
+ const manifestLookup = await lstatExists(manifestPath);
11906
+ if (!manifestLookup.success) return manifestLookup;
11907
+ let wroteManifest = false;
11908
+ if (!manifestLookup.value && options.skipBootstrap !== true) {
11909
+ const bootstrapped = await runBootstrap({
11910
+ root,
11911
+ yes: true,
11912
+ force: options.force,
11913
+ // Scan owns layout.yaml via adopt. Bootstrap writes the missing
11914
+ // manifest (and an empty baseline if that is not already populated).
11915
+ skipLayout: true
11916
+ });
11917
+ if (!bootstrapped.success) return bootstrapped;
11918
+ wroteManifest = bootstrapped.value.wrote;
11919
+ if (wroteManifest) {
11920
+ nextSteps.push(
11921
+ "Wrote .architecture/manifest.yaml via bootstrap --yes (does not infer depends_on)."
11922
+ );
11923
+ }
11924
+ }
11925
+ const lintOutcome = toLintOutcome(
11926
+ await Promise.resolve((options.lint ?? invokeHexagenLint)(root))
11927
+ );
11928
+ const lintExitCode = lintOutcome.exitCode;
11929
+ nextSteps.push(lintVerdict(lintExitCode));
11930
+ const reportPaths = [];
11931
+ let handoffPath;
11932
+ const manifestNow = await lstatExists(manifestPath);
11933
+ if (!manifestNow.success) return manifestNow;
11934
+ if (options.noReport !== true) {
11935
+ if (!manifestNow.value) {
11936
+ if (options.handoff === true) {
11937
+ return err2(
11938
+ new Error(
11939
+ "Cannot write a handoff zip without .architecture/manifest.yaml — the zip is packed from the report, which needs a manifest. Omit --skip-bootstrap, or run hexagen bootstrap --yes first."
11940
+ )
11941
+ );
11942
+ }
11943
+ nextSteps.push(
11944
+ "Skipped report — no .architecture/manifest.yaml (omit --skip-bootstrap, or run hexagen bootstrap --yes)."
11945
+ );
11946
+ } else {
11947
+ try {
11948
+ const written = await (options.report ?? reportCommand)({
11949
+ cwd: root,
11950
+ format: "both",
11951
+ handoff: options.handoff === true,
11952
+ handoffOut: options.handoffOut
11953
+ });
11954
+ reportPaths.push(written.markdownPath, written.htmlPath);
11955
+ nextSteps.push(`Wrote ${written.markdownPath}`);
11956
+ nextSteps.push(`Wrote ${written.htmlPath}`);
11957
+ if (options.handoff === true) {
11958
+ if (written.handoffPath === void 0) {
11959
+ return err2(
11960
+ new Error(
11961
+ "Report ran but produced no handoff zip, so there is nothing to upload."
11962
+ )
11963
+ );
11964
+ }
11965
+ handoffPath = written.handoffPath;
11966
+ nextSteps.push(`Wrote ${handoffPath}`);
11967
+ }
11968
+ } catch (e) {
11969
+ return err2(
11970
+ new Error(
11971
+ `Report failed: ${e instanceof Error ? e.message : String(e)}`
11972
+ )
11973
+ );
11974
+ }
11975
+ }
11976
+ }
11977
+ nextSteps.push(
11978
+ "Review layout.yaml and manifest.yaml. hexagen bootstrap does not infer depends_on from the import graph."
11979
+ );
11980
+ const markdownPath = reportPaths.find((f) => f.endsWith(".md")) ?? null;
11981
+ return ok2({
11982
+ layoutPath,
11983
+ manifestPath,
11984
+ wrote: wroteLayout || wroteManifest,
11985
+ lintExitCode,
11986
+ reportPaths,
11987
+ handoffPath,
11988
+ nextSteps,
11989
+ envelope: {
11990
+ schemaVersion: CURRENT_SCHEMA_VERSION,
11991
+ layout: readRequiredArtifact(layoutPath),
11992
+ // The real count, from the same --json run the findings came from.
11993
+ // Null only when the linter could not run or its output could not be
11994
+ // parsed -- never a silent 0, which reads as "scanned nothing and
11995
+ // passed".
11996
+ filesScanned: lintOutcome.filesScanned,
11997
+ reportMarkdown: markdownPath ? readOptionalArtifact(markdownPath) : null,
11998
+ error: null,
11999
+ findings: lintOutcome.findings
12000
+ }
12001
+ });
12002
+ } catch (e) {
12003
+ return err2(e instanceof Error ? e : new Error(String(e)));
12004
+ }
12005
+ }
12006
+ async function scanCommand(options) {
12007
+ const result = await runScan({
12008
+ root: path34__default.resolve(options.root ?? process.cwd()),
12009
+ yes: options.yes,
12010
+ dryRun: options.dryRun,
12011
+ force: options.force,
12012
+ skipBootstrap: options.skipBootstrap,
12013
+ noReport: options.noReport,
12014
+ handoff: options.handoff,
12015
+ handoffOut: options.handoffOut
12016
+ });
12017
+ if (!result.success) {
12018
+ console.error(`❌ ${result.error.message}`);
12019
+ console.log(
12020
+ JSON.stringify({
12021
+ schemaVersion: CURRENT_SCHEMA_VERSION,
12022
+ layout: null,
12023
+ filesScanned: null,
12024
+ reportMarkdown: null,
12025
+ error: result.error.message,
12026
+ // The scan did not complete, so whatever the linter may or may not
12027
+ // have said is not a verdict on this tree. `collected: false` says
12028
+ // that; empty arrays alone would read as "clean".
12029
+ findings: uncollectedFindings(
12030
+ `the scan did not complete, so hexagen-lint findings were not reported: ${result.error.message}`
12031
+ )
12032
+ })
12033
+ );
12034
+ process.exitCode = 2;
12035
+ return;
12036
+ }
12037
+ for (const line of result.value.nextSteps) {
12038
+ console.log(line);
12039
+ }
12040
+ console.log(JSON.stringify(result.value.envelope));
12041
+ process.exitCode = result.value.lintExitCode;
12042
+ }
12043
+ var scanCommander = new Command("scan").description(
12044
+ "Import a brownfield tree: write layout.yaml, optionally bootstrap a starting manifest, run hexagen-lint, and write an engagement report"
12045
+ ).option("--root <path>", "Project root (defaults to cwd)").option("--yes", "Accept detected mappings and write files").option(
12046
+ "--dry-run",
12047
+ "Print the proposed layout (and bootstrap answers if no manifest) without writing"
12048
+ ).option("--force", "Overwrite existing layout.yaml").option(
12049
+ "--skip-bootstrap",
12050
+ "Do not run bootstrap even if .architecture/manifest.yaml is missing"
12051
+ ).option("--no-report", "Skip writing hexagen-report.md / hexagen-report.html").option(
12052
+ "--handoff",
12053
+ "Also write hexagen-handoff.zip (report + manifest + layout + baseline + ledger) for upload"
12054
+ ).option(
12055
+ "--handoff-out <path>",
12056
+ "Handoff zip path, relative to --root (default: <root>/hexagen-handoff.zip)"
12057
+ ).action(
12058
+ async (opts) => {
12059
+ await scanCommand({
12060
+ root: opts.root,
12061
+ yes: opts.yes,
12062
+ dryRun: opts.dryRun,
12063
+ force: opts.force,
12064
+ skipBootstrap: opts.skipBootstrap,
12065
+ noReport: opts.report === false,
12066
+ handoff: opts.handoff,
12067
+ handoffOut: opts.handoffOut
12068
+ });
12069
+ }
12070
+ );
12071
+
11505
12072
  // src/cli.ts
11506
12073
  function createLogger() {
11507
12074
  return {
@@ -11595,6 +12162,7 @@ function buildProgram() {
11595
12162
  program2.addCommand(manifestCommander);
11596
12163
  program2.addCommand(adoptCommander);
11597
12164
  program2.addCommand(bootstrapCommander);
12165
+ program2.addCommand(scanCommander);
11598
12166
  const templatesCommand = program2.command("templates").description("Manage and inspect add-on templates");
11599
12167
  templatesCommand.command("list").description("List all available add-on templates").action(async () => {
11600
12168
  await listTemplatesCommand();