@hexagen-monaco/sync 0.15.0 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -1,10 +1,10 @@
1
1
  #!/usr/bin/env node
2
2
  import { Command, InvalidArgumentError } from 'commander';
3
- import * as path64 from 'path';
4
- import path64__default, { dirname, join } from 'path';
5
- import * as fs29 from 'fs';
6
- import fs29__default, { mkdirSync, writeFileSync, renameSync, unlinkSync, existsSync, readFileSync, promises, realpathSync, constants, lstatSync, createWriteStream } from 'fs';
7
- import fs25, { readFile, mkdir, writeFile, lstat, realpath, open, unlink, link, stat, chmod, rename, appendFile } from 'fs/promises';
3
+ import * as path65 from 'path';
4
+ import path65__default, { dirname, join } from 'path';
5
+ import * as fs30 from 'fs';
6
+ import fs30__default, { mkdirSync, writeFileSync, renameSync, unlinkSync, existsSync, readFileSync, promises, realpathSync, constants, lstatSync, createWriteStream } from 'fs';
7
+ import fs26, { readFile, mkdir, writeFile, lstat, realpath, open, unlink, link, stat, chmod, rename, appendFile } from 'fs/promises';
8
8
  import { promisify, isDeepStrictEqual } from 'util';
9
9
  import { exec, execSync, spawn, execFileSync, spawnSync } from 'child_process';
10
10
  import yaml10 from 'js-yaml';
@@ -32,11 +32,11 @@ var MigrationReport = class {
32
32
  );
33
33
  return;
34
34
  }
35
- const reportPath = config.report ? path64__default.resolve(config.workspaceRoot, config.report) : path64__default.join(config.workspaceRoot, "SYNC-MIGRATION-REPORT.md");
36
- await fs25.mkdir(path64__default.dirname(reportPath), { recursive: true });
35
+ const reportPath = config.report ? path65__default.resolve(config.workspaceRoot, config.report) : path65__default.join(config.workspaceRoot, "SYNC-MIGRATION-REPORT.md");
36
+ await fs26.mkdir(path65__default.dirname(reportPath), { recursive: true });
37
37
  let preContent = null;
38
38
  try {
39
- preContent = await fs25.readFile(reportPath, "utf8");
39
+ preContent = await fs26.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} ${path64__default.relative(workspaceRoot, e.path)}`
89
+ (e) => `${e.kind} ${path65__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 = path64__default.relative(workspaceRoot, entry.path);
115
+ const relative = path65__default.relative(workspaceRoot, entry.path);
116
116
  try {
117
117
  if (entry.preContent === null) {
118
118
  try {
119
- await fs25.unlink(entry.path);
119
+ await fs26.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 fs25.mkdir(path64__default.dirname(entry.path), { recursive: true });
128
- await fs25.writeFile(entry.path, entry.preContent, {
127
+ await fs26.mkdir(path65__default.dirname(entry.path), { recursive: true });
128
+ await fs26.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 = fs25, logger2 = console) {
147
+ constructor(workspaceRoot, fsImpl = fs26, logger2 = console) {
148
148
  this.workspaceRoot = workspaceRoot;
149
- this.lockPath = path64__default.join(workspaceRoot, LOCK_FILE);
149
+ this.lockPath = path65__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(fs29__default.readFileSync(pkgJsonPath, "utf8"));
222
+ parsed = JSON.parse(fs30__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 = path64__default.join(dir, "node_modules", ...pkgName.split("/"));
238
- const entry = binEntryOf(path64__default.join(pkgDir, "package.json"));
237
+ const pkgDir = path65__default.join(dir, "node_modules", ...pkgName.split("/"));
238
+ const entry = binEntryOf(path65__default.join(pkgDir, "package.json"));
239
239
  if (entry === null) continue;
240
- const binPath = path64__default.join(pkgDir, entry);
241
- if (fs29__default.existsSync(binPath)) return binPath;
240
+ const binPath = path65__default.join(pkgDir, entry);
241
+ if (fs30__default.existsSync(binPath)) return binPath;
242
242
  }
243
243
  return null;
244
244
  }
245
245
  function resolveArchLinterBin(startDir) {
246
- let dir = path64__default.resolve(startDir);
246
+ let dir = path65__default.resolve(startDir);
247
247
  for (; ; ) {
248
- const candidate = path64__default.join(dir, "node_modules", ".bin", BIN_NAME);
249
- if (fs29__default.existsSync(candidate)) return candidate;
248
+ const candidate = path65__default.join(dir, "node_modules", ".bin", BIN_NAME);
249
+ if (fs30__default.existsSync(candidate)) return candidate;
250
250
  const fromPackage = resolveFromPackage(dir);
251
251
  if (fromPackage !== null) return fromPackage;
252
- const parent = path64__default.dirname(dir);
252
+ const parent = path65__default.dirname(dir);
253
253
  if (parent === dir) return null;
254
254
  dir = parent;
255
255
  }
@@ -313,8 +313,6 @@ ${message}`);
313
313
  }
314
314
  }
315
315
  }
316
-
317
- // src/results.ts
318
316
  function createEmptyResult() {
319
317
  return {
320
318
  created: [],
@@ -338,6 +336,61 @@ function recordWriteStatus(result, filePath, status) {
338
336
  result.skipped.push(filePath);
339
337
  }
340
338
  }
339
+ function driftReason(action) {
340
+ if (action === "create") {
341
+ return "missing on disk; sync would create it";
342
+ }
343
+ if (action === "update") {
344
+ return "content differs from generated output";
345
+ }
346
+ return "no longer generated; sync would remove it";
347
+ }
348
+ function normalizeRelativePath(filePath, workspaceRoot) {
349
+ const relative = path65__default.isAbsolute(filePath) ? path65__default.relative(workspaceRoot, filePath) : filePath;
350
+ return relative.replaceAll("\\", "/");
351
+ }
352
+ function compareStrings(a, b) {
353
+ if (a < b) return -1;
354
+ if (a > b) return 1;
355
+ return 0;
356
+ }
357
+ function compareDriftFiles(a, b) {
358
+ const byPath = compareStrings(a.path, b.path);
359
+ if (byPath !== 0) return byPath;
360
+ const byAction = compareStrings(a.action, b.action);
361
+ if (byAction !== 0) return byAction;
362
+ return compareStrings(a.generator, b.generator);
363
+ }
364
+ function collectDriftFilesForRow(generator, result, workspaceRoot, seen, files) {
365
+ const buckets = [
366
+ ["create", result.created],
367
+ ["update", result.updated],
368
+ ["delete", result.deleted]
369
+ ];
370
+ for (const [action, paths] of buckets) {
371
+ for (const p of paths) {
372
+ const relPath = normalizeRelativePath(p, workspaceRoot);
373
+ const key = `${relPath}\0${action}\0${generator}`;
374
+ if (seen.has(key)) continue;
375
+ seen.add(key);
376
+ files.push({
377
+ path: relPath,
378
+ action,
379
+ generator,
380
+ reason: driftReason(action)
381
+ });
382
+ }
383
+ }
384
+ }
385
+ function buildDriftFiles(rows, workspaceRoot) {
386
+ const seen = /* @__PURE__ */ new Set();
387
+ const files = [];
388
+ for (const [generator, result] of rows) {
389
+ collectDriftFilesForRow(generator, result, workspaceRoot, seen, files);
390
+ }
391
+ files.sort(compareDriftFiles);
392
+ return files;
393
+ }
341
394
 
342
395
  // src/scope-filter.ts
343
396
  var GLOB_META = /[*?]/;
@@ -405,7 +458,7 @@ function isGeneratedFile(content) {
405
458
  return content.includes(GENERATED_MARKER);
406
459
  }
407
460
  function isProtectedRoot(filePath, config) {
408
- const relative = path64__default.relative(config.workspaceRoot, filePath).replace(/\\/g, "/");
461
+ const relative = path65__default.relative(config.workspaceRoot, filePath).replace(/\\/g, "/");
409
462
  const isRootLevel = !relative.startsWith("packages/") && !relative.startsWith("tools/") && !relative.startsWith("apps/");
410
463
  return isRootLevel && Array.from(protectedFiles).some(
411
464
  (f) => relative.endsWith(f) || relative.includes(f)
@@ -413,12 +466,12 @@ function isProtectedRoot(filePath, config) {
413
466
  }
414
467
  function isInScope(filePath, config) {
415
468
  if (!config.only || config.only.length === 0) return true;
416
- const relativePath = path64__default.relative(config.workspaceRoot, filePath);
469
+ const relativePath = path65__default.relative(config.workspaceRoot, filePath);
417
470
  return matchesScope(relativePath, config.only);
418
471
  }
419
472
  async function safeWriteFileAtomic(filePath, content, config, report2, skipGeneratedCheck = false) {
420
473
  const { dryRun, forceRoot, logger: logger2, workspaceRoot } = config;
421
- const relativePath = path64__default.relative(workspaceRoot, filePath);
474
+ const relativePath = path65__default.relative(workspaceRoot, filePath);
422
475
  if (!isInScope(filePath, config)) {
423
476
  logger2.debug(`skipped (outside --only) ${relativePath}`);
424
477
  return "skipped";
@@ -427,7 +480,7 @@ async function safeWriteFileAtomic(filePath, content, config, report2, skipGener
427
480
  let currentContent = "";
428
481
  let currentHash = "";
429
482
  try {
430
- currentContent = await fs25.readFile(filePath, "utf8");
483
+ currentContent = await fs26.readFile(filePath, "utf8");
431
484
  currentHash = contentHash(currentContent);
432
485
  exists2 = true;
433
486
  } catch (e) {
@@ -458,20 +511,20 @@ async function safeWriteFileAtomic(filePath, content, config, report2, skipGener
458
511
  return exists2 ? "updated" : "created";
459
512
  }
460
513
  config.journal?.recordWrite(filePath, exists2 ? currentContent : null);
461
- await fs25.mkdir(path64__default.dirname(filePath), { recursive: true });
462
- const tmpName = `.${path64__default.basename(filePath)}.${crypto.randomUUID()}.tmp`;
463
- const tmpPath = path64__default.join(path64__default.dirname(filePath), tmpName);
464
- await fs25.writeFile(tmpPath, content, { encoding: "utf8" });
514
+ await fs26.mkdir(path65__default.dirname(filePath), { recursive: true });
515
+ const tmpName = `.${path65__default.basename(filePath)}.${crypto.randomUUID()}.tmp`;
516
+ const tmpPath = path65__default.join(path65__default.dirname(filePath), tmpName);
517
+ await fs26.writeFile(tmpPath, content, { encoding: "utf8" });
465
518
  try {
466
- await fs25.rename(tmpPath, filePath);
519
+ await fs26.rename(tmpPath, filePath);
467
520
  const status = exists2 ? "updated" : "created";
468
521
  logger2.info(`${status} ${relativePath}`);
469
522
  return status;
470
523
  } catch (err3) {
471
524
  if (err3 instanceof Error && "code" in err3 && err3.code === "EXDEV") {
472
525
  try {
473
- await fs25.copyFile(tmpPath, filePath);
474
- await fs25.unlink(tmpPath);
526
+ await fs26.copyFile(tmpPath, filePath);
527
+ await fs26.unlink(tmpPath);
475
528
  const status = exists2 ? "updated" : "created";
476
529
  logger2.info(`${status} ${relativePath}`);
477
530
  return status;
@@ -479,7 +532,7 @@ async function safeWriteFileAtomic(filePath, content, config, report2, skipGener
479
532
  logger2.warn(`EXDEV fallback failed for ${relativePath}: ${copyErr}`);
480
533
  }
481
534
  }
482
- await fs25.unlink(tmpPath).catch(() => {
535
+ await fs26.unlink(tmpPath).catch(() => {
483
536
  });
484
537
  throw err3;
485
538
  }
@@ -546,7 +599,7 @@ function layerDeclaresContent(layerName, contextLayers) {
546
599
  // src/generators/layer-folders.ts
547
600
  async function directoryExists(dirPath) {
548
601
  try {
549
- const stats = await fs25.stat(dirPath);
602
+ const stats = await fs26.stat(dirPath);
550
603
  return stats.isDirectory();
551
604
  } catch (e) {
552
605
  if (e instanceof Error && "code" in e && e.code === "ENOENT") {
@@ -558,21 +611,21 @@ async function directoryExists(dirPath) {
558
611
  async function ensureDirectoryCounted(dirPath, config, result) {
559
612
  const existed = await directoryExists(dirPath);
560
613
  if (existed) return;
561
- const relativePath = path64__default.relative(config.workspaceRoot, dirPath);
614
+ const relativePath = path65__default.relative(config.workspaceRoot, dirPath);
562
615
  if (config.dryRun) {
563
616
  config.logger.info(`[DRY-RUN] would create directory ${relativePath}`);
564
617
  } else {
565
- await fs25.mkdir(dirPath, { recursive: true });
618
+ await fs26.mkdir(dirPath, { recursive: true });
566
619
  config.logger.info(`created directory ${relativePath}`);
567
620
  }
568
621
  result.created.push(dirPath);
569
622
  result.totalOps += 1;
570
623
  }
571
624
  async function ensureGitkeepCounted(dirPath, config, result) {
572
- const keepPath = path64__default.join(dirPath, ".gitkeep");
625
+ const keepPath = path65__default.join(dirPath, ".gitkeep");
573
626
  let entries = null;
574
627
  if (await directoryExists(dirPath)) {
575
- entries = await fs25.readdir(dirPath);
628
+ entries = await fs26.readdir(dirPath);
576
629
  }
577
630
  if (entries !== null) {
578
631
  const keepIsOnlyEntry = entries.length === 1 && entries[0] === ".gitkeep";
@@ -580,7 +633,7 @@ async function ensureGitkeepCounted(dirPath, config, result) {
580
633
  return;
581
634
  }
582
635
  if (keepIsOnlyEntry) {
583
- const existing = await fs25.readFile(keepPath, "utf8").catch(() => null);
636
+ const existing = await fs26.readFile(keepPath, "utf8").catch(() => null);
584
637
  if (existing !== null && existing !== "") {
585
638
  return;
586
639
  }
@@ -597,7 +650,7 @@ async function ensureGitkeepCounted(dirPath, config, result) {
597
650
  }
598
651
  async function loadYamlSafe(filePath) {
599
652
  try {
600
- const content = await fs25.readFile(filePath, "utf8");
653
+ const content = await fs26.readFile(filePath, "utf8");
601
654
  return yaml10.load(content);
602
655
  } catch (e) {
603
656
  if (e instanceof Error && "code" in e && e.code === "ENOENT") {
@@ -609,7 +662,7 @@ async function loadYamlSafe(filePath) {
609
662
  async function ensureLayerFolders(moduleDir, layers, config, contextLayers) {
610
663
  const result = createEmptyResult();
611
664
  const { logger: logger2 } = config;
612
- const layerRulesPath = path64__default.join(
665
+ const layerRulesPath = path65__default.join(
613
666
  config.workspaceRoot,
614
667
  ".architecture",
615
668
  "invariants",
@@ -623,8 +676,8 @@ async function ensureLayerFolders(moduleDir, layers, config, contextLayers) {
623
676
  if (!layerDeclaresContent(layerName, contextLayers)) {
624
677
  continue;
625
678
  }
626
- const layerPath = path64__default.join(moduleDir, resolveLayerDir(layers, layerName));
627
- if (!isInScope(layerPath, config) && !isInScope(path64__default.join(layerPath, "index.ts"), config)) {
679
+ const layerPath = path65__default.join(moduleDir, resolveLayerDir(layers, layerName));
680
+ if (!isInScope(layerPath, config) && !isInScope(path65__default.join(layerPath, "index.ts"), config)) {
628
681
  continue;
629
682
  }
630
683
  await ensureDirectoryCounted(layerPath, config, result);
@@ -640,8 +693,8 @@ async function ensureLayerFolders(moduleDir, layers, config, contextLayers) {
640
693
  );
641
694
  continue;
642
695
  }
643
- const subPath = path64__default.join(layerPath, normalizedSub);
644
- if (!isInScope(subPath, config) && !isInScope(path64__default.join(subPath, "index.ts"), config)) {
696
+ const subPath = path65__default.join(layerPath, normalizedSub);
697
+ if (!isInScope(subPath, config) && !isInScope(path65__default.join(subPath, "index.ts"), config)) {
645
698
  continue;
646
699
  }
647
700
  await ensureDirectoryCounted(subPath, config, result);
@@ -677,18 +730,18 @@ function contentHash2(content) {
677
730
  function detectCircularExports(exportGraph) {
678
731
  const visited = /* @__PURE__ */ new Set();
679
732
  const recursionStack = /* @__PURE__ */ new Set();
680
- const path72 = [];
733
+ const path73 = [];
681
734
  function dfs(node) {
682
735
  if (recursionStack.has(node)) {
683
- const cycleStart = path72.indexOf(node);
684
- return [...path72.slice(cycleStart), node];
736
+ const cycleStart = path73.indexOf(node);
737
+ return [...path73.slice(cycleStart), node];
685
738
  }
686
739
  if (visited.has(node)) {
687
740
  return null;
688
741
  }
689
742
  visited.add(node);
690
743
  recursionStack.add(node);
691
- path72.push(node);
744
+ path73.push(node);
692
745
  const exports$1 = exportGraph.get(node) ?? [];
693
746
  for (const exportPath of exports$1) {
694
747
  const cycle = dfs(exportPath);
@@ -696,7 +749,7 @@ function detectCircularExports(exportGraph) {
696
749
  return cycle;
697
750
  }
698
751
  }
699
- path72.pop();
752
+ path73.pop();
700
753
  recursionStack.delete(node);
701
754
  return null;
702
755
  }
@@ -713,8 +766,8 @@ function generateBarrelContent(entries) {
713
766
  return null;
714
767
  }
715
768
  const exportLines = entries.sort((a, b) => a.name.localeCompare(b.name)).map((entry) => {
716
- const path72 = entry.isDirectory ? `./${entry.name}/index.js` : `./${entry.name}.js`;
717
- return `export * from "${path72}";`;
769
+ const path73 = entry.isDirectory ? `./${entry.name}/index.js` : `./${entry.name}.js`;
770
+ return `export * from "${path73}";`;
718
771
  });
719
772
  return `${GENERATED_MARKER2}
720
773
 
@@ -736,16 +789,16 @@ var CircularExportError = class extends Error {
736
789
  };
737
790
  async function generateRecursiveBarrels(moduleDir, config, report2) {
738
791
  const result = createEmptyResult();
739
- const srcDir = path64__default.join(moduleDir, "src");
792
+ const srcDir = path65__default.join(moduleDir, "src");
740
793
  const layers = ["domain", "application", "infrastructure"];
741
794
  const pendingWrites = [];
742
795
  const preserved = [];
743
796
  const exportGraph = /* @__PURE__ */ new Map();
744
797
  const layersWithContent = [];
745
798
  for (const layer of layers) {
746
- const layerDir = path64__default.join(srcDir, layer);
799
+ const layerDir = path65__default.join(srcDir, layer);
747
800
  try {
748
- await fs25.access(layerDir);
801
+ await fs26.access(layerDir);
749
802
  } catch {
750
803
  continue;
751
804
  }
@@ -759,7 +812,7 @@ async function generateRecursiveBarrels(moduleDir, config, report2) {
759
812
  if (layerExports.length > 0) layersWithContent.push(layer);
760
813
  }
761
814
  if (config.mode === "external" && layersWithContent.length > 0) {
762
- const rootBarrelPath = path64__default.join(srcDir, "index.ts");
815
+ const rootBarrelPath = path65__default.join(srcDir, "index.ts");
763
816
  if (await shouldGenerateBarrel(rootBarrelPath, preserved, config.logger)) {
764
817
  const content = generateBarrelContent(
765
818
  layersWithContent.map((name) => ({ name, isDirectory: true }))
@@ -773,7 +826,7 @@ async function generateRecursiveBarrels(moduleDir, config, report2) {
773
826
  });
774
827
  exportGraph.set(
775
828
  rootBarrelPath,
776
- layersWithContent.map((name) => path64__default.join(srcDir, name, "index.ts"))
829
+ layersWithContent.map((name) => path65__default.join(srcDir, name, "index.ts"))
777
830
  );
778
831
  }
779
832
  }
@@ -793,9 +846,9 @@ async function generateRecursiveBarrels(moduleDir, config, report2) {
793
846
  continue;
794
847
  }
795
848
  try {
796
- const preContent = await fs25.readFile(pending.filePath, "utf8");
849
+ const preContent = await fs26.readFile(pending.filePath, "utf8");
797
850
  config.journal?.recordDelete(pending.filePath, preContent);
798
- await fs25.unlink(pending.filePath);
851
+ await fs26.unlink(pending.filePath);
799
852
  result.deleted.push(pending.filePath);
800
853
  result.totalOps++;
801
854
  continue;
@@ -822,7 +875,7 @@ async function walkDirectory(dirPath, pendingWrites, preserved, exportGraph, con
822
875
  const exportEntries = [];
823
876
  let entries;
824
877
  try {
825
- entries = await fs25.readdir(dirPath, { withFileTypes: true });
878
+ entries = await fs26.readdir(dirPath, { withFileTypes: true });
826
879
  } catch {
827
880
  return exportEntries;
828
881
  }
@@ -839,7 +892,7 @@ async function walkDirectory(dirPath, pendingWrites, preserved, exportGraph, con
839
892
  }
840
893
  }
841
894
  for (const dir of directories) {
842
- const subDirPath = path64__default.join(dirPath, dir);
895
+ const subDirPath = path65__default.join(dirPath, dir);
843
896
  const subExports = await walkDirectory(
844
897
  subDirPath,
845
898
  pendingWrites,
@@ -847,7 +900,7 @@ async function walkDirectory(dirPath, pendingWrites, preserved, exportGraph, con
847
900
  exportGraph,
848
901
  config
849
902
  );
850
- const subBarrelPath = path64__default.join(subDirPath, "index.ts");
903
+ const subBarrelPath = path65__default.join(subDirPath, "index.ts");
851
904
  const isQueuedForDeletion = pendingWrites.some(
852
905
  (p) => p.filePath === subBarrelPath && p.content === ""
853
906
  );
@@ -859,7 +912,7 @@ async function walkDirectory(dirPath, pendingWrites, preserved, exportGraph, con
859
912
  exportEntries.push({ name: file, isDirectory: false });
860
913
  }
861
914
  if (exportEntries.length === 0) {
862
- const barrelPath2 = path64__default.join(dirPath, "index.ts");
915
+ const barrelPath2 = path65__default.join(dirPath, "index.ts");
863
916
  const existingBarrel = await readFileIfExists(barrelPath2);
864
917
  if (existingBarrel) {
865
918
  const isGenerated = isGeneratedFile2(existingBarrel);
@@ -876,7 +929,7 @@ async function walkDirectory(dirPath, pendingWrites, preserved, exportGraph, con
876
929
  }
877
930
  return [];
878
931
  }
879
- const barrelPath = path64__default.join(dirPath, "index.ts");
932
+ const barrelPath = path65__default.join(dirPath, "index.ts");
880
933
  const shouldCreateBarrel = await shouldGenerateBarrel(
881
934
  barrelPath,
882
935
  preserved,
@@ -896,14 +949,14 @@ async function walkDirectory(dirPath, pendingWrites, preserved, exportGraph, con
896
949
  content,
897
950
  isNew: !existingContent
898
951
  });
899
- const exportPaths = exportEntries.filter((e) => e.isDirectory).map((e) => path64__default.join(dirPath, e.name, "index.ts"));
952
+ const exportPaths = exportEntries.filter((e) => e.isDirectory).map((e) => path65__default.join(dirPath, e.name, "index.ts"));
900
953
  exportGraph.set(barrelPath, exportPaths);
901
954
  }
902
955
  return exportEntries;
903
956
  }
904
957
  async function hasBarrel(dirPath) {
905
958
  try {
906
- await fs25.access(path64__default.join(dirPath, "index.ts"));
959
+ await fs26.access(path65__default.join(dirPath, "index.ts"));
907
960
  return true;
908
961
  } catch {
909
962
  return false;
@@ -923,7 +976,7 @@ async function shouldGenerateBarrel(barrelPath, preserved, logger2) {
923
976
  }
924
977
  async function readFileIfExists(filePath) {
925
978
  try {
926
- return await fs25.readFile(filePath, "utf8");
979
+ return await fs26.readFile(filePath, "utf8");
927
980
  } catch (err3) {
928
981
  if (err3 && typeof err3 === "object" && "code" in err3 && err3.code === "ENOENT") {
929
982
  return null;
@@ -983,7 +1036,7 @@ async function generatePackageJson(modulePath, moduleName, config, report2) {
983
1036
  const moduleOverrides = context?.packageJson ?? {};
984
1037
  const scope = config.manifest ? resolveScope(config.manifest) : "generated-project";
985
1038
  const dependsOnDeps = context ? expandDependsOn(context, scope) : {};
986
- const pkgPath = path64__default.join(modulePath, "package.json");
1039
+ const pkgPath = path65__default.join(modulePath, "package.json");
987
1040
  const dependencies = {
988
1041
  ...dependsOnDeps,
989
1042
  ...defaults.dependencies ?? {},
@@ -1035,7 +1088,7 @@ async function generatePackageJson(modulePath, moduleName, config, report2) {
1035
1088
  };
1036
1089
  let currentPkg = {};
1037
1090
  try {
1038
- const currentContent = await fs25.readFile(pkgPath, "utf8");
1091
+ const currentContent = await fs26.readFile(pkgPath, "utf8");
1039
1092
  currentPkg = JSON.parse(currentContent);
1040
1093
  } catch (e) {
1041
1094
  if (!(e instanceof Error && "code" in e && e.code === "ENOENT")) {
@@ -1077,11 +1130,11 @@ async function generatePackageJson(modulePath, moduleName, config, report2) {
1077
1130
  );
1078
1131
  recordWriteStatus(result, pkgPath, status);
1079
1132
  if (config.mode === "external") {
1080
- const vitestConfigPath = path64__default.join(modulePath, "vitest.config.ts");
1133
+ const vitestConfigPath = path65__default.join(modulePath, "vitest.config.ts");
1081
1134
  if (isInScope(vitestConfigPath, config)) {
1082
1135
  let vitestConfigExists = false;
1083
1136
  try {
1084
- await fs25.stat(vitestConfigPath);
1137
+ await fs26.stat(vitestConfigPath);
1085
1138
  vitestConfigExists = true;
1086
1139
  } catch (e) {
1087
1140
  if (!(e instanceof Error && "code" in e && e.code === "ENOENT")) {
@@ -1178,7 +1231,7 @@ function buildTemplate(base, context, scope) {
1178
1231
  }
1179
1232
  async function generateTsconfig(moduleDir, moduleName, config, report2) {
1180
1233
  const result = createEmptyResult();
1181
- const filePath = path64__default.join(moduleDir, "tsconfig.json");
1234
+ const filePath = path65__default.join(moduleDir, "tsconfig.json");
1182
1235
  try {
1183
1236
  const base = resolveWorkspaceTemplate(config.manifest);
1184
1237
  const context = config.manifest.bounded_contexts?.find(
@@ -1210,20 +1263,20 @@ export {};
1210
1263
  `;
1211
1264
  async function ensurePackageSrcIndex(moduleDir, config, report2) {
1212
1265
  const result = createEmptyResult();
1213
- const filePath = path64__default.join(moduleDir, "src", "index.ts");
1266
+ const filePath = path65__default.join(moduleDir, "src", "index.ts");
1214
1267
  if (!isInScope(filePath, config)) {
1215
1268
  result.skipped.push(filePath);
1216
1269
  return result;
1217
1270
  }
1218
1271
  try {
1219
- await fs25.stat(filePath);
1272
+ await fs26.stat(filePath);
1220
1273
  result.skipped.push(filePath);
1221
1274
  return result;
1222
1275
  } catch (err3) {
1223
1276
  if (err3.code !== "ENOENT") throw err3;
1224
1277
  }
1225
1278
  if (!config.dryRun) {
1226
- await fs25.mkdir(path64__default.dirname(filePath), { recursive: true });
1279
+ await fs26.mkdir(path65__default.dirname(filePath), { recursive: true });
1227
1280
  }
1228
1281
  const status = await safeWriteFileAtomic(
1229
1282
  filePath,
@@ -1239,15 +1292,15 @@ async function reapLegacyFolders(moduleDir, config, report2) {
1239
1292
  const { dryRun, logger: logger2 } = config;
1240
1293
  const legacyLayers = ["domain", "application", "infrastructure"];
1241
1294
  for (const layer of legacyLayers) {
1242
- const layerPath = path64__default.join(moduleDir, layer);
1243
- const relativePath = path64__default.relative(config.workspaceRoot, layerPath);
1295
+ const layerPath = path65__default.join(moduleDir, layer);
1296
+ const relativePath = path65__default.relative(config.workspaceRoot, layerPath);
1244
1297
  try {
1245
- const entries = await fs25.readdir(layerPath);
1298
+ const entries = await fs26.readdir(layerPath);
1246
1299
  if (entries.length === 0) {
1247
1300
  if (dryRun) {
1248
1301
  logger2.info(`[DRY-RUN] would delete empty folder ${relativePath}`);
1249
1302
  } else {
1250
- await fs25.rmdir(layerPath);
1303
+ await fs26.rmdir(layerPath);
1251
1304
  logger2.info(`deleted empty folder ${relativePath}`);
1252
1305
  if (report2) report2.record("deleted", layerPath);
1253
1306
  }
@@ -2199,7 +2252,7 @@ function assertValidToolchainVersion(version, source) {
2199
2252
  function resolveToolchainVersion() {
2200
2253
  {
2201
2254
  return assertValidToolchainVersion(
2202
- "0.15.0",
2255
+ "0.16.0",
2203
2256
  "build-injected __HEXAGEN_TOOLCHAIN_VERSION__"
2204
2257
  );
2205
2258
  }
@@ -2384,7 +2437,7 @@ async function generateRootFiles(config, report2) {
2384
2437
  );
2385
2438
  }
2386
2439
  await writeRootFile(
2387
- path64__default.join(config.workspaceRoot, "package.json"),
2440
+ path65__default.join(config.workspaceRoot, "package.json"),
2388
2441
  packageJsonContent,
2389
2442
  config,
2390
2443
  report2,
@@ -2405,7 +2458,7 @@ async function generateRootFiles(config, report2) {
2405
2458
  tsconfigContent = reindentJson(tsconfigContent, prettierOptions.tabWidth);
2406
2459
  }
2407
2460
  await writeRootFile(
2408
- path64__default.join(config.workspaceRoot, "tsconfig.base.json"),
2461
+ path65__default.join(config.workspaceRoot, "tsconfig.base.json"),
2409
2462
  tsconfigContent,
2410
2463
  config,
2411
2464
  report2,
@@ -2433,7 +2486,7 @@ async function generateRootFiles(config, report2) {
2433
2486
  );
2434
2487
  }
2435
2488
  await writeRootFile(
2436
- path64__default.join(config.workspaceRoot, "turbo.json"),
2489
+ path65__default.join(config.workspaceRoot, "turbo.json"),
2437
2490
  turboContent,
2438
2491
  config,
2439
2492
  report2,
@@ -2444,7 +2497,7 @@ async function generateRootFiles(config, report2) {
2444
2497
  BUILTIN_GITIGNORE_TEMPLATE
2445
2498
  );
2446
2499
  await writeRootFile(
2447
- path64__default.join(config.workspaceRoot, ".gitignore"),
2500
+ path65__default.join(config.workspaceRoot, ".gitignore"),
2448
2501
  interpolateAndWarn(gitignoreTemplate, vars, config, ".gitignore"),
2449
2502
  config,
2450
2503
  report2,
@@ -2455,7 +2508,7 @@ async function generateRootFiles(config, report2) {
2455
2508
  BUILTIN_YARNRC_TEMPLATE
2456
2509
  );
2457
2510
  await writeRootFile(
2458
- path64__default.join(config.workspaceRoot, ".yarnrc.yml"),
2511
+ path65__default.join(config.workspaceRoot, ".yarnrc.yml"),
2459
2512
  interpolateAndWarn(yarnrcTemplate, vars, config, ".yarnrc.yml"),
2460
2513
  config,
2461
2514
  report2,
@@ -2466,14 +2519,14 @@ async function generateRootFiles(config, report2) {
2466
2519
  BUILTIN_SETUP_MD_TEMPLATE
2467
2520
  );
2468
2521
  await writeRootFile(
2469
- path64__default.join(config.workspaceRoot, "SETUP.md"),
2522
+ path65__default.join(config.workspaceRoot, "SETUP.md"),
2470
2523
  interpolateAndWarn(setupTemplate, vars, config, "SETUP.md"),
2471
2524
  config,
2472
2525
  report2,
2473
2526
  result
2474
2527
  );
2475
2528
  await writeRootFile(
2476
- path64__default.join(config.workspaceRoot, ".prettierrc.json"),
2529
+ path65__default.join(config.workspaceRoot, ".prettierrc.json"),
2477
2530
  prettierrcContent,
2478
2531
  config,
2479
2532
  report2,
@@ -3159,9 +3212,9 @@ async function writeManifestIfFreshExternal(config, result, report2) {
3159
3212
  if (config.mode !== "external") {
3160
3213
  return;
3161
3214
  }
3162
- const archDir = path64__default.join(config.workspaceRoot, ".architecture");
3163
- const manifestPath = path64__default.join(archDir, "manifest.yaml");
3164
- const relative = path64__default.relative(config.workspaceRoot, manifestPath);
3215
+ const archDir = path65__default.join(config.workspaceRoot, ".architecture");
3216
+ const manifestPath = path65__default.join(archDir, "manifest.yaml");
3217
+ const relative = path65__default.relative(config.workspaceRoot, manifestPath);
3165
3218
  if (!isInScope(manifestPath, config)) {
3166
3219
  config.logger.debug(`skipped (outside --only) ${relative}`);
3167
3220
  result.skipped.push(manifestPath);
@@ -3169,7 +3222,7 @@ async function writeManifestIfFreshExternal(config, result, report2) {
3169
3222
  }
3170
3223
  let exists2 = false;
3171
3224
  try {
3172
- await fs25.access(manifestPath);
3225
+ await fs26.access(manifestPath);
3173
3226
  exists2 = true;
3174
3227
  } catch {
3175
3228
  exists2 = false;
@@ -3189,8 +3242,8 @@ async function writeManifestIfFreshExternal(config, result, report2) {
3189
3242
  }
3190
3243
  const content = yaml10.dump(withGeneratorIdentity(config.manifest));
3191
3244
  config.journal?.recordWrite(manifestPath, null);
3192
- await fs25.mkdir(archDir, { recursive: true });
3193
- await fs25.writeFile(manifestPath, content, { encoding: "utf8" });
3245
+ await fs26.mkdir(archDir, { recursive: true });
3246
+ await fs26.writeFile(manifestPath, content, { encoding: "utf8" });
3194
3247
  config.logger.info(`created ${relative}`);
3195
3248
  if (report2)
3196
3249
  report2.record(
@@ -3204,7 +3257,7 @@ async function writeManifestIfFreshExternal(config, result, report2) {
3204
3257
  async function generateArchitectureFiles(config, report2) {
3205
3258
  const result = createEmptyResult();
3206
3259
  const manifest = config.manifest;
3207
- const archRoot = path64__default.join(config.workspaceRoot, ".architecture");
3260
+ const archRoot = path65__default.join(config.workspaceRoot, ".architecture");
3208
3261
  const archInvariants = manifest.monorepo?.archInvariants;
3209
3262
  const { vars, ownershipCollisions } = buildInterpolationVars(manifest);
3210
3263
  const workspaceTemplate = vars.workspaceTemplate ?? "modular-monolith";
@@ -3214,7 +3267,7 @@ async function generateArchitectureFiles(config, report2) {
3214
3267
  );
3215
3268
  }
3216
3269
  await writeManifestIfFreshExternal(config, result, report2);
3217
- const layerRulesPath = path64__default.join(archRoot, "invariants", "layer-rules.yaml");
3270
+ const layerRulesPath = path65__default.join(archRoot, "invariants", "layer-rules.yaml");
3218
3271
  const layerRulesTemplate = resolveTemplate2(
3219
3272
  archInvariants?.layerRules,
3220
3273
  builtInLayerRules(workspaceTemplate)
@@ -3233,7 +3286,7 @@ async function generateArchitectureFiles(config, report2) {
3233
3286
  true
3234
3287
  );
3235
3288
  recordWriteStatus(result, layerRulesPath, layerRulesStatus);
3236
- const linterConfigPath = path64__default.join(
3289
+ const linterConfigPath = path65__default.join(
3237
3290
  archRoot,
3238
3291
  "invariants",
3239
3292
  "linter-config.yaml"
@@ -3256,7 +3309,7 @@ async function generateArchitectureFiles(config, report2) {
3256
3309
  true
3257
3310
  );
3258
3311
  recordWriteStatus(result, linterConfigPath, linterConfigStatus);
3259
- const generatorConfigPath = path64__default.join(archRoot, "generator.config.yaml");
3312
+ const generatorConfigPath = path65__default.join(archRoot, "generator.config.yaml");
3260
3313
  const generatorConfigTemplate = resolveTemplate2(
3261
3314
  archInvariants?.generatorConfig,
3262
3315
  GENERATOR_CONFIG_TEMPLATE
@@ -4194,7 +4247,7 @@ ${content}`;
4194
4247
  }
4195
4248
  async function generateEslintConfig(moduleDir, moduleName, config, report2, options = {}) {
4196
4249
  const result = createEmptyResult();
4197
- const filePath = path64__default.join(moduleDir, "eslint.config.js");
4250
+ const filePath = path65__default.join(moduleDir, "eslint.config.js");
4198
4251
  try {
4199
4252
  const { template, source } = resolveTemplate3(
4200
4253
  config.manifest,
@@ -4282,9 +4335,9 @@ async function emitAppFile(appDir, relPath, template, vars, config, report2, res
4282
4335
  `apps/${appName}/${relPath}`,
4283
4336
  config
4284
4337
  );
4285
- const target = path64__default.resolve(appDir, relPath);
4286
- const relative = path64__default.relative(appDir, target);
4287
- if (relative === "" || relative.startsWith("..") || path64__default.isAbsolute(relative)) {
4338
+ const target = path65__default.resolve(appDir, relPath);
4339
+ const relative = path65__default.relative(appDir, target);
4340
+ if (relative === "" || relative.startsWith("..") || path65__default.isAbsolute(relative)) {
4288
4341
  config.logger.warn(
4289
4342
  `[apps] skipping file with unsafe path (escapes apps/${appName}): ${relPath}`
4290
4343
  );
@@ -4299,7 +4352,7 @@ async function emitAppFile(appDir, relPath, template, vars, config, report2, res
4299
4352
  }
4300
4353
  if (!config.dryRun && isInScope(target, config)) {
4301
4354
  try {
4302
- await fs25.mkdir(path64__default.dirname(target), { recursive: true });
4355
+ await fs26.mkdir(path65__default.dirname(target), { recursive: true });
4303
4356
  } catch (err3) {
4304
4357
  const message = err3 instanceof Error ? err3.message : String(err3);
4305
4358
  config.logger.error(
@@ -4390,12 +4443,12 @@ async function generateApps(config, report2) {
4390
4443
  version: app.version ?? "",
4391
4444
  depends_on: (app.depends_on ?? []).join(", ")
4392
4445
  };
4393
- const appDir = path64__default.join(config.workspaceRoot, "apps", app.name);
4394
- const srcDir = path64__default.join(appDir, "src");
4446
+ const appDir = path65__default.join(config.workspaceRoot, "apps", app.name);
4447
+ const srcDir = path65__default.join(appDir, "src");
4395
4448
  if (!config.dryRun && isInScope(appDir, config)) {
4396
4449
  try {
4397
- await fs25.mkdir(appDir, { recursive: true });
4398
- await fs25.mkdir(srcDir, { recursive: true });
4450
+ await fs26.mkdir(appDir, { recursive: true });
4451
+ await fs26.mkdir(srcDir, { recursive: true });
4399
4452
  } catch (err3) {
4400
4453
  const message = err3 instanceof Error ? err3.message : String(err3);
4401
4454
  config.logger.error(
@@ -4413,7 +4466,7 @@ async function generateApps(config, report2) {
4413
4466
  `apps/${app.name}/package.json`,
4414
4467
  config
4415
4468
  );
4416
- const pkgPath = path64__default.join(appDir, "package.json");
4469
+ const pkgPath = path65__default.join(appDir, "package.json");
4417
4470
  const status = await safeWriteFileAtomic(
4418
4471
  pkgPath,
4419
4472
  pkgContent,
@@ -4429,7 +4482,7 @@ async function generateApps(config, report2) {
4429
4482
  const tsConfig = frameworkConfig.tsConfig;
4430
4483
  if (tsConfig) {
4431
4484
  const tsContent = JSON.stringify(tsConfig, null, 2) + "\n";
4432
- const tsPath = path64__default.join(appDir, "tsconfig.json");
4485
+ const tsPath = path65__default.join(appDir, "tsconfig.json");
4433
4486
  const status = await safeWriteFileAtomic(
4434
4487
  tsPath,
4435
4488
  tsContent,
@@ -4496,14 +4549,14 @@ async function generateApps(config, report2) {
4496
4549
  }
4497
4550
  }
4498
4551
  function relativeImportSpecifier(fromFile, toFile) {
4499
- let rel = path64__default.relative(path64__default.dirname(fromFile), toFile).split(path64__default.sep).join("/").replace(/\.tsx?$/, ".js");
4552
+ let rel = path65__default.relative(path65__default.dirname(fromFile), toFile).split(path65__default.sep).join("/").replace(/\.tsx?$/, ".js");
4500
4553
  if (!rel.startsWith(".")) rel = `./${rel}`;
4501
4554
  return rel;
4502
4555
  }
4503
4556
  function rewriteRelativeSpecifier(specifier, fromFile, toFile) {
4504
4557
  if (!specifier.startsWith(".")) return specifier;
4505
- const absolute = path64__default.resolve(path64__default.dirname(fromFile), specifier);
4506
- let rel = path64__default.relative(path64__default.dirname(toFile), absolute).split(path64__default.sep).join("/");
4558
+ const absolute = path65__default.resolve(path65__default.dirname(fromFile), specifier);
4559
+ let rel = path65__default.relative(path65__default.dirname(toFile), absolute).split(path65__default.sep).join("/");
4507
4560
  if (!rel.startsWith(".")) rel = `./${rel}`;
4508
4561
  return rel;
4509
4562
  }
@@ -4559,7 +4612,28 @@ function safeParamName(name) {
4559
4612
  const candidate = name.length === 0 ? "dep" : name;
4560
4613
  return RESERVED_IDENTIFIERS.has(candidate) ? `${candidate}_` : candidate;
4561
4614
  }
4615
+ var analysisMemo = /* @__PURE__ */ new Map();
4616
+ function resetPortAnalysisMemo() {
4617
+ analysisMemo.clear();
4618
+ }
4562
4619
  function analyzePortFile(portFilePath) {
4620
+ const absolute = path65__default.resolve(portFilePath);
4621
+ let contents;
4622
+ try {
4623
+ contents = fs30__default.readFileSync(absolute, "utf8");
4624
+ } catch {
4625
+ return null;
4626
+ }
4627
+ const fingerprint = createHash("sha256").update(contents).digest("hex");
4628
+ const key = `${absolute}:${fingerprint}`;
4629
+ if (analysisMemo.has(key)) {
4630
+ return analysisMemo.get(key) ?? null;
4631
+ }
4632
+ const result = analyzePortFileUncached(absolute, contents);
4633
+ analysisMemo.set(key, result);
4634
+ return result;
4635
+ }
4636
+ function analyzePortFileUncached(portFilePath, contents) {
4563
4637
  try {
4564
4638
  const project = new Project({
4565
4639
  skipAddingFilesFromTsConfig: true,
@@ -4570,7 +4644,9 @@ function analyzePortFile(portFilePath) {
4570
4644
  // ESNext
4571
4645
  }
4572
4646
  });
4573
- const sourceFile = project.addSourceFileAtPath(portFilePath);
4647
+ const sourceFile = project.createSourceFile(portFilePath, contents, {
4648
+ overwrite: true
4649
+ });
4574
4650
  const interfaces = sourceFile.getInterfaces().filter((i) => i.isExported());
4575
4651
  if (interfaces.length === 0) {
4576
4652
  return null;
@@ -5142,13 +5218,13 @@ function resolveNaming(kind, contextNaming, manifestNaming) {
5142
5218
  async function writeStubFile(filePath, content, config, report2) {
5143
5219
  if (!isInScope(filePath, config)) {
5144
5220
  config.logger.debug(
5145
- `skipped (outside --only) ${path64__default.relative(config.workspaceRoot, filePath)}`
5221
+ `skipped (outside --only) ${path65__default.relative(config.workspaceRoot, filePath)}`
5146
5222
  );
5147
5223
  return "skipped";
5148
5224
  }
5149
5225
  try {
5150
- await fs25.stat(filePath);
5151
- const relative = path64__default.relative(config.workspaceRoot, filePath);
5226
+ await fs26.stat(filePath);
5227
+ const relative = path65__default.relative(config.workspaceRoot, filePath);
5152
5228
  config.logger.debug(`stub preserved ${relative}`);
5153
5229
  if (report2) {
5154
5230
  report2.record(
@@ -5164,7 +5240,7 @@ async function writeStubFile(filePath, content, config, report2) {
5164
5240
  }
5165
5241
  }
5166
5242
  if (!config.dryRun) {
5167
- await fs25.mkdir(path64__default.dirname(filePath), { recursive: true });
5243
+ await fs26.mkdir(path65__default.dirname(filePath), { recursive: true });
5168
5244
  }
5169
5245
  return safeWriteFileAtomic(filePath, content, config, report2, false);
5170
5246
  }
@@ -5187,7 +5263,7 @@ async function tryAnalyzeRelatedPort(moduleDir, name, kind, context, relatedPort
5187
5263
  `${derivedPortName}.ts`
5188
5264
  ];
5189
5265
  for (const filename of possibleFilenames) {
5190
- const portFilePath = path64__default.join(moduleDir, portSubdir, filename);
5266
+ const portFilePath = path65__default.join(moduleDir, portSubdir, filename);
5191
5267
  const analysis = analyzePortFile(portFilePath);
5192
5268
  if (analysis) {
5193
5269
  return analysis;
@@ -5243,7 +5319,7 @@ async function generateStubs(moduleDir, moduleName, config, report2) {
5243
5319
  `stubs.naming.${kind}`,
5244
5320
  interpolation
5245
5321
  );
5246
- const filePath = path64__default.join(moduleDir, subdir, filename);
5322
+ const filePath = path65__default.join(moduleDir, subdir, filename);
5247
5323
  let content;
5248
5324
  if (kind === "adapter" || kind === "useCase") {
5249
5325
  const relatedPortNaming = resolveNaming(
@@ -5273,7 +5349,7 @@ async function generateStubs(moduleDir, moduleName, config, report2) {
5273
5349
  contextNaming,
5274
5350
  manifestNaming
5275
5351
  );
5276
- const outPortDir = path64__default.join(
5352
+ const outPortDir = path65__default.join(
5277
5353
  moduleDir,
5278
5354
  resolveEmissionDir(layersConfig, "application/ports/out")
5279
5355
  );
@@ -5285,7 +5361,7 @@ async function generateStubs(moduleDir, moduleName, config, report2) {
5285
5361
  "stubs.naming.outPort",
5286
5362
  interpolation
5287
5363
  );
5288
- const outPortPath = path64__default.join(outPortDir, outFile);
5364
+ const outPortPath = path65__default.join(outPortDir, outFile);
5289
5365
  const analyzed = analyzePortFile(outPortPath);
5290
5366
  return {
5291
5367
  interfaceName: analyzed?.interfaceName ?? `${base}Port`,
@@ -5388,19 +5464,19 @@ ${methodLines}
5388
5464
  `;
5389
5465
  }
5390
5466
  async function emitPortAndAdapter(result, config, report2, scope, spec) {
5391
- const moduleRoot = path64__default.join(
5467
+ const moduleRoot = path65__default.join(
5392
5468
  config.workspaceRoot,
5393
5469
  "packages",
5394
5470
  spec.contextName
5395
5471
  );
5396
- const portDir = path64__default.join(
5472
+ const portDir = path65__default.join(
5397
5473
  moduleRoot,
5398
5474
  "src",
5399
5475
  "application",
5400
5476
  "ports",
5401
5477
  spec.portKind
5402
5478
  );
5403
- const portPath = path64__default.join(
5479
+ const portPath = path65__default.join(
5404
5480
  portDir,
5405
5481
  `${spec.portBase}.${spec.portKind}-port.ts`
5406
5482
  );
@@ -5408,7 +5484,7 @@ async function emitPortAndAdapter(result, config, report2, scope, spec) {
5408
5484
  return;
5409
5485
  }
5410
5486
  if (!config.dryRun) {
5411
- await fs25.mkdir(portDir, { recursive: true });
5487
+ await fs26.mkdir(portDir, { recursive: true });
5412
5488
  }
5413
5489
  recordWriteStatus(
5414
5490
  result,
@@ -5433,13 +5509,13 @@ async function emitPortAndAdapter(result, config, report2, scope, spec) {
5433
5509
  );
5434
5510
  return;
5435
5511
  }
5436
- const adapterDir = path64__default.join(moduleRoot, "src", "infrastructure", "adapters");
5437
- const adapterPath = path64__default.join(adapterDir, `${spec.portBase}.adapter.ts`);
5512
+ const adapterDir = path65__default.join(moduleRoot, "src", "infrastructure", "adapters");
5513
+ const adapterPath = path65__default.join(adapterDir, `${spec.portBase}.adapter.ts`);
5438
5514
  if (!isInScope(adapterPath, config)) {
5439
5515
  return;
5440
5516
  }
5441
5517
  if (!config.dryRun) {
5442
- await fs25.mkdir(adapterDir, { recursive: true });
5518
+ await fs26.mkdir(adapterDir, { recursive: true });
5443
5519
  }
5444
5520
  const adapterClassName = `${toPascalCaseIdentifier(spec.portBase)}Adapter`;
5445
5521
  const portSpecifier = relativeImportSpecifier(adapterPath, portPath);
@@ -5466,7 +5542,7 @@ function operationImports(ops) {
5466
5542
  return ops.flatMap((op) => [`${op}Request`, `${op}Response`]);
5467
5543
  }
5468
5544
  async function writeSharedContract(result, config, report2, relSegments, content) {
5469
- const contractPath2 = path64__default.join(
5545
+ const contractPath2 = path65__default.join(
5470
5546
  config.workspaceRoot,
5471
5547
  "packages",
5472
5548
  "shared",
@@ -5474,7 +5550,7 @@ async function writeSharedContract(result, config, report2, relSegments, content
5474
5550
  ...relSegments
5475
5551
  );
5476
5552
  if (!config.dryRun) {
5477
- await fs25.mkdir(path64__default.dirname(contractPath2), { recursive: true });
5553
+ await fs26.mkdir(path65__default.dirname(contractPath2), { recursive: true });
5478
5554
  }
5479
5555
  recordWriteStatus(
5480
5556
  result,
@@ -5626,7 +5702,7 @@ async function generateSharedKernel(config, report2) {
5626
5702
  (bc) => bc.name?.toLowerCase() === "shared"
5627
5703
  );
5628
5704
  if (!hasShared) return result;
5629
- const kernelPath = path64__default.join(
5705
+ const kernelPath = path65__default.join(
5630
5706
  config.workspaceRoot,
5631
5707
  "packages",
5632
5708
  "shared",
@@ -5639,14 +5715,14 @@ async function generateSharedKernel(config, report2) {
5639
5715
  return result;
5640
5716
  }
5641
5717
  try {
5642
- await fs25.stat(kernelPath);
5718
+ await fs26.stat(kernelPath);
5643
5719
  result.skipped.push(kernelPath);
5644
5720
  return result;
5645
5721
  } catch (err3) {
5646
5722
  if (err3.code !== "ENOENT") throw err3;
5647
5723
  }
5648
5724
  if (!config.dryRun) {
5649
- await fs25.mkdir(path64__default.dirname(kernelPath), { recursive: true });
5725
+ await fs26.mkdir(path65__default.dirname(kernelPath), { recursive: true });
5650
5726
  }
5651
5727
  const status = await safeWriteFileAtomic(
5652
5728
  kernelPath,
@@ -5660,12 +5736,18 @@ async function generateSharedKernel(config, report2) {
5660
5736
  }
5661
5737
  var execAsync = promisify(exec);
5662
5738
  var MAX_BUFFER = 1024 * 1024 * 10;
5663
- async function ensureDependenciesBuilt(config) {
5739
+ async function ensureDependenciesBuilt(config, options = {}) {
5664
5740
  const { logger: logger2, dryRun } = config;
5665
5741
  if (dryRun) {
5666
5742
  logger2.info("Pre‑flight: skipping build in dry-run mode");
5667
5743
  return;
5668
5744
  }
5745
+ if (options.skip) {
5746
+ logger2.info(
5747
+ "Preflight: build skipped (--no-preflight); the build is left to the gate"
5748
+ );
5749
+ return;
5750
+ }
5669
5751
  logger2.info("Pre‑flight: ensuring package dependencies are up‑to‑date...");
5670
5752
  try {
5671
5753
  const { stdout, stderr } = await execAsync("npx turbo run build", {
@@ -5744,21 +5826,21 @@ function mergeBarrelPasses(firstPass, secondPass) {
5744
5826
  return combined;
5745
5827
  }
5746
5828
  function assertPathWithinArchitecture(workspaceRoot, relativePath) {
5747
- const resolved = path64__default.resolve(workspaceRoot, ".architecture", relativePath);
5748
- const archRoot = path64__default.resolve(workspaceRoot, ".architecture");
5829
+ const resolved = path65__default.resolve(workspaceRoot, ".architecture", relativePath);
5830
+ const archRoot = path65__default.resolve(workspaceRoot, ".architecture");
5749
5831
  try {
5750
5832
  const realResolved = realpathSync(resolved);
5751
5833
  const realArchRoot = realpathSync(archRoot);
5752
- const archRootWithSep = realArchRoot + path64__default.sep;
5834
+ const archRootWithSep = realArchRoot + path65__default.sep;
5753
5835
  if (realResolved !== realArchRoot && !realResolved.startsWith(archRootWithSep)) {
5754
5836
  throw new Error(`Path traversal detected: "${relativePath}" resolves outside .architecture/`);
5755
5837
  }
5756
5838
  } catch (err3) {
5757
5839
  if (err3 instanceof Error && "code" in err3 && err3.code === "ENOENT") {
5758
5840
  let checkPath = archRoot;
5759
- const pathSegments = path64__default.relative(archRoot, resolved).split(path64__default.sep);
5841
+ const pathSegments = path65__default.relative(archRoot, resolved).split(path65__default.sep);
5760
5842
  for (const segment of pathSegments) {
5761
- checkPath = path64__default.join(checkPath, segment);
5843
+ checkPath = path65__default.join(checkPath, segment);
5762
5844
  try {
5763
5845
  const stat4 = lstatSync(checkPath);
5764
5846
  if (stat4.isSymbolicLink()) {
@@ -5774,7 +5856,7 @@ function assertPathWithinArchitecture(workspaceRoot, relativePath) {
5774
5856
  throw statErr;
5775
5857
  }
5776
5858
  }
5777
- const archRootWithSep = archRoot + path64__default.sep;
5859
+ const archRootWithSep = archRoot + path65__default.sep;
5778
5860
  if (resolved !== archRoot && !resolved.startsWith(archRootWithSep)) {
5779
5861
  throw new Error(`Path traversal detected: "${relativePath}" resolves outside .architecture/`);
5780
5862
  }
@@ -5784,7 +5866,7 @@ function assertPathWithinArchitecture(workspaceRoot, relativePath) {
5784
5866
  }
5785
5867
  }
5786
5868
  async function mergeSplitManifest(workspaceRoot, manifestPath) {
5787
- const content = await fs25.readFile(manifestPath, "utf-8");
5869
+ const content = await fs26.readFile(manifestPath, "utf-8");
5788
5870
  const parsed = yaml10.load(content);
5789
5871
  if (parsed == null) {
5790
5872
  throw new Error("Manifest file is empty");
@@ -5813,10 +5895,10 @@ async function mergeSplitManifest(workspaceRoot, manifestPath) {
5813
5895
  };
5814
5896
  if (typeof index.workspace_config === "string") {
5815
5897
  assertPathWithinArchitecture(workspaceRoot, index.workspace_config);
5816
- const sideCarPath = path64__default.join(workspaceRoot, ".architecture", index.workspace_config);
5898
+ const sideCarPath = path65__default.join(workspaceRoot, ".architecture", index.workspace_config);
5817
5899
  let sideCarContent;
5818
5900
  try {
5819
- sideCarContent = await fs25.readFile(sideCarPath, "utf-8");
5901
+ sideCarContent = await fs26.readFile(sideCarPath, "utf-8");
5820
5902
  } catch (err3) {
5821
5903
  if (err3 instanceof Error && "code" in err3 && err3.code === "ENOENT") {
5822
5904
  throw new Error(`Workspace config file not found: ${sideCarPath}`);
@@ -5839,10 +5921,10 @@ async function mergeSplitManifest(workspaceRoot, manifestPath) {
5839
5921
  for (const entry of indexContexts) {
5840
5922
  const indexEntry = entry;
5841
5923
  assertPathWithinArchitecture(workspaceRoot, indexEntry.file);
5842
- const contextFilePath = path64__default.join(workspaceRoot, ".architecture", indexEntry.file);
5924
+ const contextFilePath = path65__default.join(workspaceRoot, ".architecture", indexEntry.file);
5843
5925
  let contextContent;
5844
5926
  try {
5845
- contextContent = await fs25.readFile(contextFilePath, "utf-8");
5927
+ contextContent = await fs26.readFile(contextFilePath, "utf-8");
5846
5928
  } catch (err3) {
5847
5929
  if (err3 instanceof Error && "code" in err3 && err3.code === "ENOENT") {
5848
5930
  throw new Error(`Context file not found: ${contextFilePath}`);
@@ -5874,10 +5956,10 @@ async function mergeSplitManifest(workspaceRoot, manifestPath) {
5874
5956
  continue;
5875
5957
  }
5876
5958
  assertPathWithinArchitecture(workspaceRoot, appEntry.file);
5877
- const appFilePath = path64__default.join(workspaceRoot, ".architecture", appEntry.file);
5959
+ const appFilePath = path65__default.join(workspaceRoot, ".architecture", appEntry.file);
5878
5960
  let appContent;
5879
5961
  try {
5880
- appContent = await fs25.readFile(appFilePath, "utf-8");
5962
+ appContent = await fs26.readFile(appFilePath, "utf-8");
5881
5963
  } catch (err3) {
5882
5964
  if (err3 instanceof Error && "code" in err3 && err3.code === "ENOENT") {
5883
5965
  throw new Error(`App file not found: ${appFilePath}`);
@@ -5896,16 +5978,16 @@ async function mergeSplitManifest(workspaceRoot, manifestPath) {
5896
5978
 
5897
5979
  // src/sync-engine-init.ts
5898
5980
  var __filename$1 = fileURLToPath(import.meta.url);
5899
- var __dirname$1 = path64__default.dirname(__filename$1);
5981
+ var __dirname$1 = path65__default.dirname(__filename$1);
5900
5982
  function isENOENT(err3) {
5901
5983
  return err3 instanceof Error && "code" in err3 && err3.code === "ENOENT";
5902
5984
  }
5903
5985
  async function findRootFrom(startDir, problems) {
5904
5986
  let currentDir = startDir;
5905
- while (currentDir !== path64__default.parse(currentDir).root) {
5906
- const pkgPath = path64__default.join(currentDir, "package.json");
5987
+ while (currentDir !== path65__default.parse(currentDir).root) {
5988
+ const pkgPath = path65__default.join(currentDir, "package.json");
5907
5989
  try {
5908
- const pkgContent = await fs25.readFile(pkgPath, "utf-8");
5990
+ const pkgContent = await fs26.readFile(pkgPath, "utf-8");
5909
5991
  const pkg = JSON.parse(pkgContent);
5910
5992
  if (pkg.workspaces && Array.isArray(pkg.workspaces)) {
5911
5993
  return currentDir;
@@ -5916,7 +5998,7 @@ async function findRootFrom(startDir, problems) {
5916
5998
  problems.push(new Error(`${pkgPath}: ${reason}`));
5917
5999
  }
5918
6000
  }
5919
- currentDir = path64__default.dirname(currentDir);
6001
+ currentDir = path65__default.dirname(currentDir);
5920
6002
  }
5921
6003
  return null;
5922
6004
  }
@@ -5941,7 +6023,7 @@ async function loadManifest(workspaceRoot, flags, options) {
5941
6023
  return { manifest: options.manifest, manifestMissing: false };
5942
6024
  }
5943
6025
  const { logger: logger2, dryRun } = flags;
5944
- const manifestPath = path64__default.join(workspaceRoot, ".architecture/manifest.yaml");
6026
+ const manifestPath = path65__default.join(workspaceRoot, ".architecture/manifest.yaml");
5945
6027
  logger2.debug(`[debug] __dirname (ESM): ${__dirname$1}`);
5946
6028
  logger2.debug(`[debug] resolved workspaceRoot: ${workspaceRoot}`);
5947
6029
  logger2.debug(`[debug] resolved manifestPath: ${manifestPath}`);
@@ -6064,7 +6146,7 @@ var SyncEngine = class {
6064
6146
  );
6065
6147
  continue;
6066
6148
  }
6067
- const moduleDir = path64__default.join(this.workspaceRoot, "packages", mod.name);
6149
+ const moduleDir = path65__default.join(this.workspaceRoot, "packages", mod.name);
6068
6150
  logger2.info(
6069
6151
  `Ensuring directories for module: ${mod.name} at ${moduleDir}`
6070
6152
  );
@@ -6089,7 +6171,7 @@ var SyncEngine = class {
6089
6171
  const stubs = createEmptyResult();
6090
6172
  for (const module of modules) {
6091
6173
  const moduleName = module.name;
6092
- const moduleDir = path64__default.join(this.workspaceRoot, "packages", moduleName);
6174
+ const moduleDir = path65__default.join(this.workspaceRoot, "packages", moduleName);
6093
6175
  if (moduleName.includes("..") || moduleName.includes("/") || moduleName.startsWith(".")) {
6094
6176
  logger2.warn(
6095
6177
  `Skipping invalid module name (potential path traversal): ${moduleName}`
@@ -6160,8 +6242,12 @@ var SyncEngine = class {
6160
6242
  };
6161
6243
  }
6162
6244
  async run() {
6245
+ resetPortAnalysisMemo();
6163
6246
  const { logger: logger2, dryRun, allowDirty, mode } = this.partialConfig;
6164
6247
  const start = Date.now();
6248
+ let gitStatusMs = null;
6249
+ let preflightMs = null;
6250
+ let linterMs = null;
6165
6251
  let lockFile = null;
6166
6252
  this.journal = new SyncJournal();
6167
6253
  this.failures = [];
@@ -6171,12 +6257,14 @@ var SyncEngine = class {
6171
6257
  );
6172
6258
  if (mode === "self-regen" && !allowDirty) {
6173
6259
  try {
6260
+ const gitStart = Date.now();
6174
6261
  const { stdout: gitStatus } = await execAsync2(
6175
6262
  "git status --porcelain",
6176
6263
  {
6177
6264
  cwd: this.options?.targetRoot ?? process.cwd()
6178
6265
  }
6179
6266
  );
6267
+ gitStatusMs = Date.now() - gitStart;
6180
6268
  if (gitStatus && gitStatus.trim().length > 0) {
6181
6269
  logger2.error(
6182
6270
  "Git working tree is dirty. Commit or stash changes, or use --allow-dirty to proceed."
@@ -6237,10 +6325,15 @@ var SyncEngine = class {
6237
6325
  }
6238
6326
  }
6239
6327
  if (mode === "self-regen") {
6240
- await ensureDependenciesBuilt(this.fullConfig);
6328
+ const preflightStart = Date.now();
6329
+ await ensureDependenciesBuilt(this.fullConfig, {
6330
+ skip: this.options?.noPreflight
6331
+ });
6332
+ preflightMs = Date.now() - preflightStart;
6241
6333
  } else {
6242
6334
  logger2.info("Skipping preflight build (external mode)");
6243
6335
  }
6336
+ const generatorsStart = Date.now();
6244
6337
  const rootFilesResult = await generateRootFiles(
6245
6338
  this.fullConfig,
6246
6339
  this.report
@@ -6275,7 +6368,7 @@ var SyncEngine = class {
6275
6368
  if (!moduleName || moduleName.includes("..") || moduleName.includes("/") || moduleName.startsWith(".")) {
6276
6369
  continue;
6277
6370
  }
6278
- const moduleDir = path64__default.join(this.workspaceRoot, "packages", moduleName);
6371
+ const moduleDir = path65__default.join(this.workspaceRoot, "packages", moduleName);
6279
6372
  const pass2 = await generateBarrels(
6280
6373
  moduleDir,
6281
6374
  this.fullConfig,
@@ -6285,6 +6378,7 @@ var SyncEngine = class {
6285
6378
  mergeResult2(secondPassBarrels, pass2);
6286
6379
  }
6287
6380
  const barrels = mergeBarrelPasses(firstPassBarrels, secondPassBarrels);
6381
+ const generatorsMs = Date.now() - generatorsStart;
6288
6382
  const rows = [
6289
6383
  ["RootFiles", rootFilesResult],
6290
6384
  ["ArchFiles", archFilesResult],
@@ -6317,14 +6411,23 @@ var SyncEngine = class {
6317
6411
  runSummary.skipped += r.skipped.length;
6318
6412
  runSummary.totalOps += r.totalOps;
6319
6413
  }
6414
+ runSummary.files = buildDriftFiles(rows, this.workspaceRoot);
6320
6415
  if (mode === "self-regen") {
6416
+ const linterStart = Date.now();
6321
6417
  await runArchLinter(this.fullConfig);
6418
+ linterMs = Date.now() - linterStart;
6322
6419
  await this.report.writeReport(this.fullConfig);
6323
6420
  } else {
6324
6421
  logger2.info("Skipping arch-linter and report (external mode)");
6325
6422
  }
6326
6423
  const duration = Date.now() - start;
6327
6424
  runSummary.durationMs = duration;
6425
+ runSummary.phaseTimingsMs = {
6426
+ gitStatus: gitStatusMs,
6427
+ preflight: preflightMs,
6428
+ generators: generatorsMs,
6429
+ linter: linterMs
6430
+ };
6328
6431
  if (this.failures.length === 0) {
6329
6432
  logger2.info("\nSync completed successfully.");
6330
6433
  } else {
@@ -6347,6 +6450,18 @@ Sync completed with ${this.failures.length} generator failure(s) — see the FAI
6347
6450
  logger2.error(`• ${f.row} : FAILED — ${f.message}`);
6348
6451
  }
6349
6452
  logger2.info(`• Total ops : ${runSummary.totalOps}`);
6453
+ logger2.info(`
6454
+ === Phase Timings ===`);
6455
+ const phaseTimingRows = [
6456
+ ["git status", gitStatusMs],
6457
+ ["preflight", preflightMs],
6458
+ ["generators", generatorsMs],
6459
+ ["linter", linterMs]
6460
+ ];
6461
+ for (const [label, value] of phaseTimingRows) {
6462
+ const formatted = value === null ? "skipped" : `${value}ms`;
6463
+ logger2.info(`• ${label} : ${formatted}`);
6464
+ }
6350
6465
  return runSummary;
6351
6466
  } catch (err3) {
6352
6467
  const message = err3 instanceof Error ? err3.message : "Unknown sync error";
@@ -6378,7 +6493,7 @@ Sync completed with ${this.failures.length} generator failure(s) — see the FAI
6378
6493
  } else {
6379
6494
  for (const f of outcome.failures) {
6380
6495
  logger2.error(
6381
- `Rollback failed for ${path64__default.relative(this.workspaceRoot, f.path)}: intended to ${f.intended} — ${f.error}`
6496
+ `Rollback failed for ${path65__default.relative(this.workspaceRoot, f.path)}: intended to ${f.intended} — ${f.error}`
6382
6497
  );
6383
6498
  }
6384
6499
  logger2.error(
@@ -6414,7 +6529,7 @@ function err2(error) {
6414
6529
  promisify(exec);
6415
6530
  async function loadManifest2(workspaceRoot) {
6416
6531
  try {
6417
- const manifestPath = path64__default.join(
6532
+ const manifestPath = path65__default.join(
6418
6533
  workspaceRoot,
6419
6534
  ".architecture/manifest.yaml"
6420
6535
  );
@@ -6757,27 +6872,27 @@ var YamlSaveError = class extends Error {
6757
6872
  filePath;
6758
6873
  };
6759
6874
  var YamlService = class {
6760
- async loadManifest(path72) {
6875
+ async loadManifest(path73) {
6761
6876
  try {
6762
- const content = await readFile(path72, "utf-8");
6877
+ const content = await readFile(path73, "utf-8");
6763
6878
  const manifest = yaml10.load(content);
6764
6879
  return ok2(manifest);
6765
6880
  } catch (e) {
6766
6881
  const error = e;
6767
6882
  if (error.code === "ENOENT") {
6768
- return err2(new YamlLoadError(`File not found: ${path72}`, path72));
6883
+ return err2(new YamlLoadError(`File not found: ${path73}`, path73));
6769
6884
  }
6770
- return err2(new YamlLoadError(error.message, path72));
6885
+ return err2(new YamlLoadError(error.message, path73));
6771
6886
  }
6772
6887
  }
6773
- saveManifest(manifest, path72) {
6774
- const dir = dirname(path72);
6775
- const tempPath = `${path72}.tmp`;
6888
+ saveManifest(manifest, path73) {
6889
+ const dir = dirname(path73);
6890
+ const tempPath = `${path73}.tmp`;
6776
6891
  try {
6777
6892
  mkdirSync(dir, { recursive: true });
6778
6893
  const content = yaml10.dump(manifest, { indent: 2 });
6779
6894
  writeFileSync(tempPath, content, "utf-8");
6780
- renameSync(tempPath, path72);
6895
+ renameSync(tempPath, path73);
6781
6896
  return ok2(void 0);
6782
6897
  } catch (e) {
6783
6898
  const error = e;
@@ -6785,7 +6900,7 @@ var YamlService = class {
6785
6900
  if (existsSync(tempPath)) unlinkSync(tempPath);
6786
6901
  } catch {
6787
6902
  }
6788
- return err2(new YamlSaveError(error.message, path72));
6903
+ return err2(new YamlSaveError(error.message, path73));
6789
6904
  }
6790
6905
  }
6791
6906
  parse(content) {
@@ -6995,8 +7110,8 @@ function resolveTemplatesDir() {
6995
7110
  if (process.env.HEXAGEN_TEMPLATES_DIR) {
6996
7111
  return process.env.HEXAGEN_TEMPLATES_DIR;
6997
7112
  }
6998
- const cliDir = path64__default.dirname(fileURLToPath(import.meta.url));
6999
- return path64__default.resolve(cliDir, "templates");
7113
+ const cliDir = path65__default.dirname(fileURLToPath(import.meta.url));
7114
+ return path65__default.resolve(cliDir, "templates");
7000
7115
  }
7001
7116
  async function lstatExists(target) {
7002
7117
  try {
@@ -7633,8 +7748,8 @@ var removeCommander = new Command("remove").description("Remove a port or bounde
7633
7748
  function getManifestPath2(cwd) {
7634
7749
  return join(cwd, ".architecture", "manifest.yaml");
7635
7750
  }
7636
- async function loadManifestFromPath(path72) {
7637
- const result = await yamlService.loadManifest(path72);
7751
+ async function loadManifestFromPath(path73) {
7752
+ const result = await yamlService.loadManifest(path73);
7638
7753
  if (!result.success) {
7639
7754
  return err2(result.error);
7640
7755
  }
@@ -7892,8 +8007,8 @@ function isOutputEnabled(output, answers) {
7892
8007
  return true;
7893
8008
  return matchesCondition(output.when, answers);
7894
8009
  }
7895
- function isTestOutput(path72) {
7896
- return /\.(test|spec)\.[cm]?[jt]sx?$/.test(path72);
8010
+ function isTestOutput(path73) {
8011
+ return /\.(test|spec)\.[cm]?[jt]sx?$/.test(path73);
7897
8012
  }
7898
8013
 
7899
8014
  // ../template-engine/dist/domain/template-manifest.js
@@ -8085,11 +8200,11 @@ function mergeGeneratedFiles(earlier, current) {
8085
8200
  contentHash: currentHash.get(entry.path) ?? lastEarlierHash.get(entry.path)
8086
8201
  });
8087
8202
  }
8088
- for (const [path72, contentHash3] of currentHash) {
8089
- if (seen.has(path72))
8203
+ for (const [path73, contentHash3] of currentHash) {
8204
+ if (seen.has(path73))
8090
8205
  continue;
8091
- seen.add(path72);
8092
- merged.push({ path: path72, contentHash: contentHash3 });
8206
+ seen.add(path73);
8207
+ merged.push({ path: path73, contentHash: contentHash3 });
8093
8208
  }
8094
8209
  return merged;
8095
8210
  }
@@ -8233,10 +8348,10 @@ function claimedPathKeys(templates, templateId) {
8233
8348
  return [];
8234
8349
  const keys = [];
8235
8350
  for (const entry of generatedFiles) {
8236
- const path72 = entry?.path;
8237
- if (typeof path72 !== "string")
8351
+ const path73 = entry?.path;
8352
+ if (typeof path73 !== "string")
8238
8353
  continue;
8239
- const key = sharedPathKey(path72);
8354
+ const key = sharedPathKey(path73);
8240
8355
  if (key !== null)
8241
8356
  keys.push(key);
8242
8357
  }
@@ -8290,38 +8405,38 @@ function planTemplateRemoval(input) {
8290
8405
  const keptOther = [];
8291
8406
  const keptByFlag = [];
8292
8407
  const alreadyAbsent = [];
8293
- for (const { path: path72, contentHashes } of safe) {
8294
- const key = sharedPathKey(path72);
8408
+ for (const { path: path73, contentHashes } of safe) {
8409
+ const key = sharedPathKey(path73);
8295
8410
  if (key !== null && sharedPaths.has(key)) {
8296
- keptShared.push(path72);
8411
+ keptShared.push(path73);
8297
8412
  continue;
8298
8413
  }
8299
- const state = fileStates.get(path72);
8414
+ const state = fileStates.get(path73);
8300
8415
  if (state === void 0 || state.kind === "other") {
8301
- keptOther.push(path72);
8416
+ keptOther.push(path73);
8302
8417
  continue;
8303
8418
  }
8304
8419
  if (state.kind === "absent") {
8305
- alreadyAbsent.push(path72);
8420
+ alreadyAbsent.push(path73);
8306
8421
  continue;
8307
8422
  }
8308
8423
  if (contentHashes.includes(state.contentHash)) {
8309
8424
  if (keepFiles) {
8310
- keptByFlag.push(path72);
8425
+ keptByFlag.push(path73);
8311
8426
  } else {
8312
- deleteFiles.push(path72);
8427
+ deleteFiles.push(path73);
8313
8428
  }
8314
8429
  continue;
8315
8430
  }
8316
8431
  if (force) {
8317
8432
  if (keepFiles) {
8318
- keptByFlag.push(path72);
8433
+ keptByFlag.push(path73);
8319
8434
  } else {
8320
- deleteFiles.push(path72);
8321
- deleteChanged.push(path72);
8435
+ deleteFiles.push(path73);
8436
+ deleteChanged.push(path73);
8322
8437
  }
8323
8438
  } else {
8324
- keptChanged.push(path72);
8439
+ keptChanged.push(path73);
8325
8440
  }
8326
8441
  }
8327
8442
  return {
@@ -8399,19 +8514,19 @@ function resolveDependencies(requested, registry) {
8399
8514
  }
8400
8515
  const sorted = [];
8401
8516
  const state = /* @__PURE__ */ new Map();
8402
- function visit(id, path72) {
8517
+ function visit(id, path73) {
8403
8518
  const s = state.get(id);
8404
8519
  if (s === "done")
8405
8520
  return;
8406
8521
  if (s === "visiting") {
8407
- const cycleStart = path72.indexOf(id);
8408
- throw new CyclicDependencyError([...path72.slice(cycleStart), id]);
8522
+ const cycleStart = path73.indexOf(id);
8523
+ throw new CyclicDependencyError([...path73.slice(cycleStart), id]);
8409
8524
  }
8410
8525
  state.set(id, "visiting");
8411
8526
  const manifest = registry.get(id);
8412
8527
  for (const dep of manifest.requires) {
8413
8528
  if (needed.has(dep))
8414
- visit(dep, [...path72, id]);
8529
+ visit(dep, [...path73, id]);
8415
8530
  }
8416
8531
  state.set(id, "done");
8417
8532
  sorted.push(id);
@@ -8504,9 +8619,9 @@ var AddTemplateUseCase = class {
8504
8619
  var RemovalDeleteError = class extends Error {
8505
8620
  path;
8506
8621
  partial;
8507
- constructor(message, path72, partial) {
8622
+ constructor(message, path73, partial) {
8508
8623
  super(message);
8509
- this.path = path72;
8624
+ this.path = path73;
8510
8625
  this.partial = partial;
8511
8626
  this.name = "RemovalDeleteError";
8512
8627
  }
@@ -8715,25 +8830,25 @@ var ValidateTemplatesUseCase = class {
8715
8830
  return { results, totalWarnings, totalErrors };
8716
8831
  }
8717
8832
  };
8718
- var PACKAGE_ROOT = path64__default.resolve(path64__default.dirname(fileURLToPath(import.meta.url)), "..", "..");
8833
+ var PACKAGE_ROOT = path65__default.resolve(path65__default.dirname(fileURLToPath(import.meta.url)), "..", "..");
8719
8834
  var FileSystemTemplateRegistry = class {
8720
8835
  templatesDir;
8721
8836
  cache = null;
8722
8837
  constructor(templatesDir) {
8723
- this.templatesDir = templatesDir ?? path64__default.join(PACKAGE_ROOT, "templates");
8838
+ this.templatesDir = templatesDir ?? path65__default.join(PACKAGE_ROOT, "templates");
8724
8839
  }
8725
8840
  async loadAll() {
8726
8841
  if (this.cache)
8727
8842
  return this.cache;
8728
8843
  let entries;
8729
8844
  try {
8730
- entries = await fs25.readdir(this.templatesDir);
8845
+ entries = await fs26.readdir(this.templatesDir);
8731
8846
  } catch {
8732
8847
  return [];
8733
8848
  }
8734
8849
  const manifests = [];
8735
8850
  for (const entry of entries) {
8736
- const manifestPath = path64__default.join(this.templatesDir, entry, "manifest.json");
8851
+ const manifestPath = path65__default.join(this.templatesDir, entry, "manifest.json");
8737
8852
  const manifest = await this.readManifest(manifestPath);
8738
8853
  if (manifest)
8739
8854
  manifests.push(manifest);
@@ -8742,13 +8857,13 @@ var FileSystemTemplateRegistry = class {
8742
8857
  return manifests;
8743
8858
  }
8744
8859
  async loadOne(id) {
8745
- const manifestPath = path64__default.join(this.templatesDir, id, "manifest.json");
8860
+ const manifestPath = path65__default.join(this.templatesDir, id, "manifest.json");
8746
8861
  return this.readManifest(manifestPath);
8747
8862
  }
8748
8863
  async readManifest(manifestPath) {
8749
8864
  let raw;
8750
8865
  try {
8751
- raw = await fs25.readFile(manifestPath, "utf-8");
8866
+ raw = await fs26.readFile(manifestPath, "utf-8");
8752
8867
  } catch {
8753
8868
  return null;
8754
8869
  }
@@ -8884,35 +8999,35 @@ ${prompt} (comma-separated numbers)`);
8884
8999
  }
8885
9000
  }
8886
9001
  };
8887
- var PACKAGE_ROOT2 = path64__default.resolve(path64__default.dirname(fileURLToPath(import.meta.url)), "..", "..");
9002
+ var PACKAGE_ROOT2 = path65__default.resolve(path65__default.dirname(fileURLToPath(import.meta.url)), "..", "..");
8888
9003
  var FileSystemFileEmitter = class {
8889
9004
  templatesDir;
8890
9005
  withTests;
8891
9006
  constructor(templatesDir, options = {}) {
8892
- this.templatesDir = templatesDir ?? path64__default.join(PACKAGE_ROOT2, "templates");
9007
+ this.templatesDir = templatesDir ?? path65__default.join(PACKAGE_ROOT2, "templates");
8893
9008
  this.withTests = options.withTests ?? false;
8894
9009
  }
8895
9010
  async emit(manifest, answers, projectRoot, config) {
8896
9011
  const warnings = [];
8897
9012
  const generatedFiles = [];
8898
- const templateFilesDir = path64__default.join(this.templatesDir, manifest.id, "files");
8899
- const resolvedRoot = path64__default.resolve(projectRoot);
9013
+ const templateFilesDir = path65__default.join(this.templatesDir, manifest.id, "files");
9014
+ const resolvedRoot = path65__default.resolve(projectRoot);
8900
9015
  for (const out of manifest.outputs) {
8901
9016
  if (!isOutputEnabled(out, answers))
8902
9017
  continue;
8903
9018
  const outputRelPath = outputPath(out);
8904
9019
  if (!this.withTests && isTestOutput(outputRelPath))
8905
9020
  continue;
8906
- const destFile = path64__default.resolve(projectRoot, outputRelPath);
8907
- if (!destFile.startsWith(resolvedRoot + path64__default.sep) && destFile !== resolvedRoot) {
9021
+ const destFile = path65__default.resolve(projectRoot, outputRelPath);
9022
+ if (!destFile.startsWith(resolvedRoot + path65__default.sep) && destFile !== resolvedRoot) {
8908
9023
  throw new Error(`Output path '${outputRelPath}' escapes the project root`);
8909
9024
  }
8910
- const sourceFile = path64__default.join(templateFilesDir, outputRelPath);
9025
+ const sourceFile = path65__default.join(templateFilesDir, outputRelPath);
8911
9026
  let templateContent;
8912
9027
  let sourceMode = 420;
8913
9028
  try {
8914
- const raw = await fs25.readFile(sourceFile, "utf-8");
8915
- sourceMode = (await fs25.stat(sourceFile)).mode & 511;
9029
+ const raw = await fs26.readFile(sourceFile, "utf-8");
9030
+ sourceMode = (await fs26.stat(sourceFile)).mode & 511;
8916
9031
  const { output, warnings: interpWarnings } = interpolate(raw, answers);
8917
9032
  templateContent = output;
8918
9033
  for (const key of interpWarnings) {
@@ -8927,7 +9042,7 @@ var FileSystemFileEmitter = class {
8927
9042
  const templateHash = sha256(templateContent);
8928
9043
  let existingContent = null;
8929
9044
  try {
8930
- existingContent = await fs25.readFile(destFile, "utf-8");
9045
+ existingContent = await fs26.readFile(destFile, "utf-8");
8931
9046
  } catch {
8932
9047
  }
8933
9048
  if (existingContent !== null) {
@@ -8937,7 +9052,7 @@ var FileSystemFileEmitter = class {
8937
9052
  if (!isAlreadyIdentical && !wasGeneratedByHexagen) {
8938
9053
  const conflictDest = conflictFilePath(destFile);
8939
9054
  await atomicWrite(conflictDest, templateContent, sourceMode);
8940
- const rel = path64__default.relative(projectRoot, conflictDest);
9055
+ const rel = path65__default.relative(projectRoot, conflictDest);
8941
9056
  warnings.push(`⚠️ Conflict: ${outputRelPath} has local changes.
8942
9057
  New version written to ${rel}
8943
9058
  Review and merge manually, then delete the conflict file.`);
@@ -8951,18 +9066,18 @@ var FileSystemFileEmitter = class {
8951
9066
  }
8952
9067
  };
8953
9068
  async function atomicWrite(filePath, content, mode) {
8954
- await fs25.mkdir(path64__default.dirname(filePath), { recursive: true });
9069
+ await fs26.mkdir(path65__default.dirname(filePath), { recursive: true });
8955
9070
  const tmp = `${filePath}.tmp.${Date.now()}`;
8956
9071
  try {
8957
- await fs25.writeFile(tmp, content, "utf-8");
9072
+ await fs26.writeFile(tmp, content, "utf-8");
8958
9073
  if (mode !== void 0 && (mode & 73) !== 0) {
8959
- const created = (await fs25.stat(tmp)).mode & 511;
9074
+ const created = (await fs26.stat(tmp)).mode & 511;
8960
9075
  const execBits = mode & 73 & ~process.umask();
8961
- await fs25.chmod(tmp, created | execBits);
9076
+ await fs26.chmod(tmp, created | execBits);
8962
9077
  }
8963
- await fs25.rename(tmp, filePath);
9078
+ await fs26.rename(tmp, filePath);
8964
9079
  } catch (err3) {
8965
- await fs25.rm(tmp, { force: true }).catch(() => {
9080
+ await fs26.rm(tmp, { force: true }).catch(() => {
8966
9081
  });
8967
9082
  throw err3;
8968
9083
  }
@@ -8972,9 +9087,9 @@ function sha256(content) {
8972
9087
  }
8973
9088
  var FileSystemTemplateConfigStore = class {
8974
9089
  async load(projectRoot) {
8975
- const configPath = path64__default.join(projectRoot, TEMPLATE_CONFIG_FILE);
9090
+ const configPath = path65__default.join(projectRoot, TEMPLATE_CONFIG_FILE);
8976
9091
  try {
8977
- const raw = await fs25.readFile(configPath, "utf-8");
9092
+ const raw = await fs26.readFile(configPath, "utf-8");
8978
9093
  return JSON.parse(raw);
8979
9094
  } catch (err3) {
8980
9095
  if (err3.code === "ENOENT")
@@ -8990,10 +9105,10 @@ var FileSystemTemplateConfigStore = class {
8990
9105
  * error — never as an I/O failure, never as a silent classification.
8991
9106
  */
8992
9107
  async loadState(projectRoot) {
8993
- const configPath = path64__default.join(projectRoot, TEMPLATE_CONFIG_FILE);
9108
+ const configPath = path65__default.join(projectRoot, TEMPLATE_CONFIG_FILE);
8994
9109
  let parsed;
8995
9110
  try {
8996
- const raw = await fs25.readFile(configPath, "utf-8");
9111
+ const raw = await fs26.readFile(configPath, "utf-8");
8997
9112
  parsed = JSON.parse(raw);
8998
9113
  } catch (err3) {
8999
9114
  if (err3.code === "ENOENT")
@@ -9006,16 +9121,16 @@ var FileSystemTemplateConfigStore = class {
9006
9121
  return configState(parsed);
9007
9122
  }
9008
9123
  async save(projectRoot, config) {
9009
- const configPath = path64__default.join(projectRoot, TEMPLATE_CONFIG_FILE);
9124
+ const configPath = path65__default.join(projectRoot, TEMPLATE_CONFIG_FILE);
9010
9125
  const tmp = `${configPath}.tmp.${crypto.randomUUID()}`;
9011
- await fs25.writeFile(tmp, JSON.stringify(config, null, 2), "utf-8");
9012
- await fs25.rename(tmp, configPath);
9126
+ await fs26.writeFile(tmp, JSON.stringify(config, null, 2), "utf-8");
9127
+ await fs26.rename(tmp, configPath);
9013
9128
  }
9014
9129
  };
9015
9130
  var FileSystemProjectFilePresence = class {
9016
9131
  async exists(projectRoot, relativePath) {
9017
9132
  try {
9018
- await fs25.access(path64__default.join(projectRoot, relativePath));
9133
+ await fs26.access(path65__default.join(projectRoot, relativePath));
9019
9134
  return true;
9020
9135
  } catch {
9021
9136
  return false;
@@ -9046,10 +9161,10 @@ var FileSystemProjectRemovalFiles = class {
9046
9161
  const segments = rel.split("/");
9047
9162
  let current = realRoot;
9048
9163
  for (let i = 0; i < segments.length - 1; i += 1) {
9049
- current = path64__default.join(current, segments[i]);
9164
+ current = path65__default.join(current, segments[i]);
9050
9165
  let stat5;
9051
9166
  try {
9052
- stat5 = await fs25.lstat(current);
9167
+ stat5 = await fs26.lstat(current);
9053
9168
  } catch (err3) {
9054
9169
  const code = err3.code;
9055
9170
  if (code === "ENOENT")
@@ -9067,10 +9182,10 @@ var FileSystemProjectRemovalFiles = class {
9067
9182
  return { kind: "other", detail: "not a directory" };
9068
9183
  }
9069
9184
  }
9070
- const abs = path64__default.join(current, segments[segments.length - 1]);
9185
+ const abs = path65__default.join(current, segments[segments.length - 1]);
9071
9186
  let stat4;
9072
9187
  try {
9073
- stat4 = await fs25.lstat(abs);
9188
+ stat4 = await fs26.lstat(abs);
9074
9189
  } catch (err3) {
9075
9190
  const code = err3.code;
9076
9191
  if (code === "ENOENT")
@@ -9083,12 +9198,12 @@ var FileSystemProjectRemovalFiles = class {
9083
9198
  if (!stat4.isFile()) {
9084
9199
  return { kind: "other", detail: "not a plain file" };
9085
9200
  }
9086
- if (!abs.startsWith(realRoot + path64__default.sep)) {
9201
+ if (!abs.startsWith(realRoot + path65__default.sep)) {
9087
9202
  return { kind: "unsafe" };
9088
9203
  }
9089
9204
  let realAbs;
9090
9205
  try {
9091
- realAbs = await fs25.realpath(abs);
9206
+ realAbs = await fs26.realpath(abs);
9092
9207
  } catch (err3) {
9093
9208
  const code = err3.code;
9094
9209
  if (code === "ENOENT")
@@ -9099,14 +9214,14 @@ var FileSystemProjectRemovalFiles = class {
9099
9214
  unreadable: true
9100
9215
  };
9101
9216
  }
9102
- const relReal = path64__default.relative(realRoot, realAbs).split(path64__default.sep).join("/");
9217
+ const relReal = path65__default.relative(realRoot, realAbs).split(path65__default.sep).join("/");
9103
9218
  if (relReal.startsWith("..") || normaliseRecordedPath(relReal) === null) {
9104
9219
  return { kind: "unsafe" };
9105
9220
  }
9106
9221
  return { kind: "file", abs };
9107
9222
  }
9108
9223
  async inspect(projectRoot, paths) {
9109
- const realRoot = await fs25.realpath(projectRoot);
9224
+ const realRoot = await fs26.realpath(projectRoot);
9110
9225
  const states = /* @__PURE__ */ new Map();
9111
9226
  for (const rel of paths) {
9112
9227
  const located = await this.locate(realRoot, rel);
@@ -9118,7 +9233,7 @@ var FileSystemProjectRemovalFiles = class {
9118
9233
  states.set(rel, { kind: "other", detail: located.detail });
9119
9234
  } else {
9120
9235
  try {
9121
- const content = await fs25.readFile(located.abs, "utf-8");
9236
+ const content = await fs26.readFile(located.abs, "utf-8");
9122
9237
  states.set(rel, { kind: "file", contentHash: sha2562(content) });
9123
9238
  } catch (err3) {
9124
9239
  states.set(rel, {
@@ -9138,7 +9253,7 @@ var FileSystemProjectRemovalFiles = class {
9138
9253
  * with how many were deleted first.
9139
9254
  */
9140
9255
  async deleteFiles(projectRoot, requests) {
9141
- const realRoot = await fs25.realpath(projectRoot);
9256
+ const realRoot = await fs26.realpath(projectRoot);
9142
9257
  const deleted = [];
9143
9258
  const skipped = [];
9144
9259
  for (const request of requests) {
@@ -9161,7 +9276,7 @@ var FileSystemProjectRemovalFiles = class {
9161
9276
  if (request.expectedHashes !== null) {
9162
9277
  let hash;
9163
9278
  try {
9164
- hash = sha2562(await fs25.readFile(located.abs, "utf-8"));
9279
+ hash = sha2562(await fs26.readFile(located.abs, "utf-8"));
9165
9280
  } catch {
9166
9281
  skipped.push({ path: request.path, reason: "unreadable" });
9167
9282
  continue;
@@ -9172,7 +9287,7 @@ var FileSystemProjectRemovalFiles = class {
9172
9287
  }
9173
9288
  }
9174
9289
  try {
9175
- await fs25.unlink(located.abs);
9290
+ await fs26.unlink(located.abs);
9176
9291
  } catch (err3) {
9177
9292
  if (err3.code === "ENOENT") {
9178
9293
  skipped.push({ path: request.path, reason: "absent" });
@@ -9192,16 +9307,16 @@ var FileSystemProjectRemovalFiles = class {
9192
9307
  * `fs.rm`, never recursive.
9193
9308
  */
9194
9309
  async pruneEmptyDirs(projectRoot, deletedPaths) {
9195
- const realRoot = await fs25.realpath(projectRoot);
9310
+ const realRoot = await fs26.realpath(projectRoot);
9196
9311
  const removed = /* @__PURE__ */ new Set();
9197
9312
  for (const rel of deletedPaths) {
9198
9313
  if (normaliseRecordedPath(rel) !== rel)
9199
9314
  continue;
9200
- let current = path64__default.dirname(path64__default.join(realRoot, rel));
9201
- while (current !== realRoot && current.startsWith(realRoot + path64__default.sep)) {
9315
+ let current = path65__default.dirname(path65__default.join(realRoot, rel));
9316
+ while (current !== realRoot && current.startsWith(realRoot + path65__default.sep)) {
9202
9317
  let stat4;
9203
9318
  try {
9204
- stat4 = await fs25.lstat(current);
9319
+ stat4 = await fs26.lstat(current);
9205
9320
  } catch (err3) {
9206
9321
  if (err3.code === "ENOENT")
9207
9322
  break;
@@ -9210,13 +9325,13 @@ var FileSystemProjectRemovalFiles = class {
9210
9325
  if (stat4.isSymbolicLink() || !stat4.isDirectory())
9211
9326
  break;
9212
9327
  try {
9213
- if (await fs25.realpath(current) !== current)
9328
+ if (await fs26.realpath(current) !== current)
9214
9329
  break;
9215
9330
  } catch {
9216
9331
  break;
9217
9332
  }
9218
9333
  try {
9219
- await fs25.rmdir(current);
9334
+ await fs26.rmdir(current);
9220
9335
  } catch (err3) {
9221
9336
  const code = err3.code;
9222
9337
  if (code === "ENOTEMPTY" || code === "EEXIST" || code === "ENOENT") {
@@ -9224,15 +9339,15 @@ var FileSystemProjectRemovalFiles = class {
9224
9339
  }
9225
9340
  throw err3;
9226
9341
  }
9227
- removed.add(path64__default.relative(realRoot, current).split(path64__default.sep).join("/"));
9228
- current = path64__default.dirname(current);
9342
+ removed.add(path65__default.relative(realRoot, current).split(path65__default.sep).join("/"));
9343
+ current = path65__default.dirname(current);
9229
9344
  }
9230
9345
  }
9231
9346
  return [...removed].sort();
9232
9347
  }
9233
9348
  /** The `.hexagen-update` conflict copies that exist beside the given paths. Reads only. */
9234
9349
  async existingConflictCopies(projectRoot, paths) {
9235
- const realRoot = await fs25.realpath(projectRoot);
9350
+ const realRoot = await fs26.realpath(projectRoot);
9236
9351
  const copies = [];
9237
9352
  for (const rel of paths) {
9238
9353
  const conflictRel = conflictFilePath(rel);
@@ -9455,17 +9570,17 @@ async function pathExists(p) {
9455
9570
  }
9456
9571
  async function expandGlob(root, glob) {
9457
9572
  if (glob.endsWith("/*") && !glob.slice(0, -2).includes("*")) {
9458
- const dir = path64__default.join(root, glob.slice(0, -2));
9573
+ const dir = path65__default.join(root, glob.slice(0, -2));
9459
9574
  if (!await pathExists(dir)) return [];
9460
9575
  const entries = await promises.readdir(dir, { withFileTypes: true });
9461
- return entries.filter((e) => e.isDirectory() && !e.name.startsWith(".")).map((e) => path64__default.join(glob.slice(0, -2), e.name));
9576
+ return entries.filter((e) => e.isDirectory() && !e.name.startsWith(".")).map((e) => path65__default.join(glob.slice(0, -2), e.name));
9462
9577
  }
9463
9578
  if (glob.includes("*")) {
9464
9579
  throw new Error(
9465
9580
  `Complex globs like '${glob}' are not supported. Only simple trailing '/*' globs are currently supported.`
9466
9581
  );
9467
9582
  }
9468
- const abs = path64__default.join(root, glob);
9583
+ const abs = path65__default.join(root, glob);
9469
9584
  return await pathExists(abs) ? [glob] : [];
9470
9585
  }
9471
9586
  async function detectLayers(absRoot) {
@@ -9473,7 +9588,7 @@ async function detectLayers(absRoot) {
9473
9588
  for (const [layer, candidates] of Object.entries(LAYER_ALIASES)) {
9474
9589
  const found = [];
9475
9590
  for (const candidate of candidates) {
9476
- if (await pathExists(path64__default.join(absRoot, candidate))) {
9591
+ if (await pathExists(path65__default.join(absRoot, candidate))) {
9477
9592
  found.push(candidate);
9478
9593
  }
9479
9594
  }
@@ -9487,7 +9602,7 @@ function contextNameFrom(pkgName, dirName) {
9487
9602
  return dirName;
9488
9603
  }
9489
9604
  async function detectWorkspaces(root) {
9490
- const pkgPath = path64__default.join(root, "package.json");
9605
+ const pkgPath = path65__default.join(root, "package.json");
9491
9606
  let pkg = {};
9492
9607
  try {
9493
9608
  pkg = JSON.parse(await promises.readFile(pkgPath, "utf8"));
@@ -9500,17 +9615,17 @@ async function detectWorkspaces(root) {
9500
9615
  const packages = [];
9501
9616
  const seenNames = /* @__PURE__ */ new Set();
9502
9617
  for (const rel of candidates) {
9503
- const abs = path64__default.join(root, rel);
9618
+ const abs = path65__default.join(root, rel);
9504
9619
  let packageName;
9505
9620
  try {
9506
9621
  const child = JSON.parse(
9507
- await promises.readFile(path64__default.join(abs, "package.json"), "utf8")
9622
+ await promises.readFile(path65__default.join(abs, "package.json"), "utf8")
9508
9623
  );
9509
9624
  packageName = child.name;
9510
9625
  } catch {
9511
9626
  packageName = void 0;
9512
9627
  }
9513
- const dirName = rel === "." ? path64__default.basename(root) : path64__default.basename(rel);
9628
+ const dirName = rel === "." ? path65__default.basename(root) : path65__default.basename(rel);
9514
9629
  const name = contextNameFrom(packageName, dirName);
9515
9630
  if (seenNames.has(name)) {
9516
9631
  throw new Error(
@@ -9520,12 +9635,12 @@ async function detectWorkspaces(root) {
9520
9635
  seenNames.add(name);
9521
9636
  packages.push({
9522
9637
  name,
9523
- root: rel === "." ? "." : rel.split(path64__default.sep).join("/"),
9638
+ root: rel === "." ? "." : rel.split(path65__default.sep).join("/"),
9524
9639
  packageName,
9525
9640
  layers: await detectLayers(abs)
9526
9641
  });
9527
9642
  }
9528
- const system = typeof pkg.name === "string" && pkg.name.length > 0 ? pkg.name.replace(/^@[^/]+\//, "") : path64__default.basename(root);
9643
+ const system = typeof pkg.name === "string" && pkg.name.length > 0 ? pkg.name.replace(/^@[^/]+\//, "") : path65__default.basename(root);
9529
9644
  return { system, packages };
9530
9645
  }
9531
9646
 
@@ -9826,8 +9941,8 @@ Installed templates: ${installed}
9826
9941
  function getManifestPath3(cwd) {
9827
9942
  return join(cwd, ".architecture", "manifest.yaml");
9828
9943
  }
9829
- async function loadManifest4(path72) {
9830
- const result = await yamlService.loadManifest(path72);
9944
+ async function loadManifest4(path73) {
9945
+ const result = await yamlService.loadManifest(path73);
9831
9946
  if (!result.success) {
9832
9947
  throw result.error;
9833
9948
  }
@@ -10025,35 +10140,35 @@ var FileSystemWorkspaceAdapter = class {
10025
10140
  }
10026
10141
  workspaceRoot;
10027
10142
  listPackages() {
10028
- const packagesDir = path64.join(this.workspaceRoot, "packages");
10029
- if (!fs29.existsSync(packagesDir)) {
10143
+ const packagesDir = path65.join(this.workspaceRoot, "packages");
10144
+ if (!fs30.existsSync(packagesDir)) {
10030
10145
  return [];
10031
10146
  }
10032
- return fs29.readdirSync(packagesDir, { withFileTypes: true }).filter((dirent) => dirent.isDirectory()).map((dirent) => dirent.name);
10147
+ return fs30.readdirSync(packagesDir, { withFileTypes: true }).filter((dirent) => dirent.isDirectory()).map((dirent) => dirent.name);
10033
10148
  }
10034
10149
  listApps() {
10035
- const appsDir = path64.join(this.workspaceRoot, "apps");
10036
- if (!fs29.existsSync(appsDir)) {
10150
+ const appsDir = path65.join(this.workspaceRoot, "apps");
10151
+ if (!fs30.existsSync(appsDir)) {
10037
10152
  return [];
10038
10153
  }
10039
- return fs29.readdirSync(appsDir, { withFileTypes: true }).filter((dirent) => dirent.isDirectory()).map((dirent) => dirent.name);
10154
+ return fs30.readdirSync(appsDir, { withFileTypes: true }).filter((dirent) => dirent.isDirectory()).map((dirent) => dirent.name);
10040
10155
  }
10041
10156
  getSourceFiles(dir) {
10042
- if (!fs29.existsSync(dir)) {
10157
+ if (!fs30.existsSync(dir)) {
10043
10158
  return [];
10044
10159
  }
10045
- const entries = fs29.readdirSync(dir, { withFileTypes: true });
10160
+ const entries = fs30.readdirSync(dir, { withFileTypes: true });
10046
10161
  return entries.map((entry) => ({
10047
- path: path64.join(dir, entry.name),
10162
+ path: path65.join(dir, entry.name),
10048
10163
  isDirectory: entry.isDirectory()
10049
10164
  }));
10050
10165
  }
10051
10166
  fileExists(filePath) {
10052
- return fs29.existsSync(filePath);
10167
+ return fs30.existsSync(filePath);
10053
10168
  }
10054
10169
  readFile(filePath) {
10055
10170
  try {
10056
- return fs29.readFileSync(filePath, "utf-8");
10171
+ return fs30.readFileSync(filePath, "utf-8");
10057
10172
  } catch {
10058
10173
  return null;
10059
10174
  }
@@ -10148,7 +10263,7 @@ var layoutSchema = z.object({
10148
10263
 
10149
10264
  // src/infrastructure/config/load-layout-config.ts
10150
10265
  function loadLayoutConfig(workspaceRoot) {
10151
- const filePath = path64__default.join(
10266
+ const filePath = path65__default.join(
10152
10267
  workspaceRoot,
10153
10268
  ...LAYOUT_YAML_RELATIVE_PATH.split("/")
10154
10269
  );
@@ -10642,15 +10757,15 @@ async function updateBarrelExport(sourceFile, oldName, newName) {
10642
10757
  }
10643
10758
  async function updateManifestEntry(workspaceRoot, updateFn) {
10644
10759
  try {
10645
- const manifestPath = path64__default.join(
10760
+ const manifestPath = path65__default.join(
10646
10761
  workspaceRoot,
10647
10762
  ".architecture/manifest.yaml"
10648
10763
  );
10649
- const content = await fs25.readFile(manifestPath, "utf-8");
10764
+ const content = await fs26.readFile(manifestPath, "utf-8");
10650
10765
  const manifest = yaml10.load(content);
10651
10766
  updateFn(manifest);
10652
10767
  const updatedContent = yaml10.dump(manifest, { indent: 2 });
10653
- await fs25.writeFile(manifestPath, updatedContent, "utf-8");
10768
+ await fs26.writeFile(manifestPath, updatedContent, "utf-8");
10654
10769
  return ok2(void 0);
10655
10770
  } catch (error) {
10656
10771
  return err2(error);
@@ -10714,7 +10829,7 @@ var RenamePortPattern = class {
10714
10829
  (f) => f.reason.includes("Declares")
10715
10830
  );
10716
10831
  for (const file of portFiles) {
10717
- const filePath = path64__default.join(this.workspaceRoot, file.path);
10832
+ const filePath = path65__default.join(this.workspaceRoot, file.path);
10718
10833
  const sourceFile = this.project.addSourceFileAtPath(filePath);
10719
10834
  const existingInterface = sourceFile.getInterface(request.newName);
10720
10835
  if (existingInterface) {
@@ -10736,7 +10851,7 @@ var RenamePortPattern = class {
10736
10851
  const warnings = [];
10737
10852
  try {
10738
10853
  for (const file of impact.filesToModify) {
10739
- const filePath = path64__default.join(this.workspaceRoot, file.path);
10854
+ const filePath = path65__default.join(this.workspaceRoot, file.path);
10740
10855
  if (file.path.endsWith(".ts") || file.path.endsWith(".tsx")) {
10741
10856
  try {
10742
10857
  this.project.addSourceFileAtPath(filePath);
@@ -10839,7 +10954,7 @@ var RenamePortPattern = class {
10839
10954
  */
10840
10955
  async renamePortFile(relativePath, oldName, newName) {
10841
10956
  try {
10842
- const filePath = path64__default.join(this.workspaceRoot, relativePath);
10957
+ const filePath = path65__default.join(this.workspaceRoot, relativePath);
10843
10958
  const sourceFile = this.project.getSourceFile(filePath);
10844
10959
  if (!sourceFile) {
10845
10960
  return err2(new Error(`Source file not found: ${relativePath}`));
@@ -10852,17 +10967,17 @@ var RenamePortPattern = class {
10852
10967
  if (typeAlias) {
10853
10968
  typeAlias.rename(newName);
10854
10969
  }
10855
- const oldFileName = path64__default.basename(relativePath);
10970
+ const oldFileName = path65__default.basename(relativePath);
10856
10971
  const newFileName = oldFileName.replace(
10857
10972
  toKebabCase(oldName),
10858
10973
  toKebabCase(newName)
10859
10974
  );
10860
10975
  if (oldFileName !== newFileName) {
10861
- const newFilePath = path64__default.join(path64__default.dirname(filePath), newFileName);
10976
+ const newFilePath = path65__default.join(path65__default.dirname(filePath), newFileName);
10862
10977
  await sourceFile.move(newFilePath);
10863
10978
  return ok2([
10864
10979
  relativePath,
10865
- path64__default.relative(this.workspaceRoot, newFilePath)
10980
+ path65__default.relative(this.workspaceRoot, newFilePath)
10866
10981
  ]);
10867
10982
  }
10868
10983
  return ok2([relativePath]);
@@ -10875,7 +10990,7 @@ var RenamePortPattern = class {
10875
10990
  */
10876
10991
  async updateImports(relativePath, oldName, newName) {
10877
10992
  try {
10878
- const filePath = path64__default.join(this.workspaceRoot, relativePath);
10993
+ const filePath = path65__default.join(this.workspaceRoot, relativePath);
10879
10994
  const sourceFile = this.project.getSourceFile(filePath);
10880
10995
  if (!sourceFile) {
10881
10996
  return ok2([]);
@@ -10891,7 +11006,7 @@ var RenamePortPattern = class {
10891
11006
  */
10892
11007
  async updateBarrelExport(relativePath, oldName, newName) {
10893
11008
  try {
10894
- const filePath = path64__default.join(this.workspaceRoot, relativePath);
11009
+ const filePath = path65__default.join(this.workspaceRoot, relativePath);
10895
11010
  const sourceFile = this.project.getSourceFile(filePath);
10896
11011
  if (!sourceFile) {
10897
11012
  return ok2([]);
@@ -10934,7 +11049,7 @@ var RenamePortPattern = class {
10934
11049
  */
10935
11050
  async updateTestDouble(relativePath, oldName, newName) {
10936
11051
  try {
10937
- const filePath = path64__default.join(this.workspaceRoot, relativePath);
11052
+ const filePath = path65__default.join(this.workspaceRoot, relativePath);
10938
11053
  const sourceFile = this.project.getSourceFile(filePath);
10939
11054
  if (!sourceFile) {
10940
11055
  return ok2([]);
@@ -10964,17 +11079,17 @@ var RenamePortPattern = class {
10964
11079
  );
10965
11080
  modified = modified || importsModified;
10966
11081
  if (modified) {
10967
- const oldFileName = path64__default.basename(relativePath);
11082
+ const oldFileName = path65__default.basename(relativePath);
10968
11083
  const newFileName = oldFileName.replace(
10969
11084
  toKebabCase(oldName),
10970
11085
  toKebabCase(newName)
10971
11086
  );
10972
11087
  if (oldFileName !== newFileName) {
10973
- const newFilePath = path64__default.join(path64__default.dirname(filePath), newFileName);
11088
+ const newFilePath = path65__default.join(path65__default.dirname(filePath), newFileName);
10974
11089
  await sourceFile.move(newFilePath);
10975
11090
  return ok2([
10976
11091
  relativePath,
10977
- path64__default.relative(this.workspaceRoot, newFilePath)
11092
+ path65__default.relative(this.workspaceRoot, newFilePath)
10978
11093
  ]);
10979
11094
  }
10980
11095
  }
@@ -11047,7 +11162,7 @@ var RenameUseCasePattern = class {
11047
11162
  const warnings = [];
11048
11163
  try {
11049
11164
  for (const file of impact.filesToModify) {
11050
- const filePath = path64__default.join(this.workspaceRoot, file.path);
11165
+ const filePath = path65__default.join(this.workspaceRoot, file.path);
11051
11166
  if (file.path.endsWith(".ts") || file.path.endsWith(".tsx")) {
11052
11167
  try {
11053
11168
  this.project.addSourceFileAtPath(filePath);
@@ -11158,7 +11273,7 @@ var RenameUseCasePattern = class {
11158
11273
  */
11159
11274
  async renameUseCaseFile(relativePath, oldName, newName) {
11160
11275
  try {
11161
- const filePath = path64__default.join(this.workspaceRoot, relativePath);
11276
+ const filePath = path65__default.join(this.workspaceRoot, relativePath);
11162
11277
  const sourceFile = this.project.getSourceFile(filePath);
11163
11278
  if (!sourceFile) {
11164
11279
  return err2(new Error(`Source file not found: ${relativePath}`));
@@ -11167,17 +11282,17 @@ var RenameUseCasePattern = class {
11167
11282
  if (classDecl) {
11168
11283
  classDecl.rename(newName);
11169
11284
  }
11170
- const oldFileName = path64__default.basename(relativePath);
11285
+ const oldFileName = path65__default.basename(relativePath);
11171
11286
  const newFileName = oldFileName.replace(
11172
11287
  toKebabCase(oldName),
11173
11288
  toKebabCase(newName)
11174
11289
  );
11175
11290
  if (oldFileName !== newFileName) {
11176
- const newFilePath = path64__default.join(path64__default.dirname(filePath), newFileName);
11291
+ const newFilePath = path65__default.join(path65__default.dirname(filePath), newFileName);
11177
11292
  await sourceFile.move(newFilePath);
11178
11293
  return ok2([
11179
11294
  relativePath,
11180
- path64__default.relative(this.workspaceRoot, newFilePath)
11295
+ path65__default.relative(this.workspaceRoot, newFilePath)
11181
11296
  ]);
11182
11297
  }
11183
11298
  return ok2([relativePath]);
@@ -11187,7 +11302,7 @@ var RenameUseCasePattern = class {
11187
11302
  }
11188
11303
  async updateImports(relativePath, oldName, newName) {
11189
11304
  try {
11190
- const filePath = path64__default.join(this.workspaceRoot, relativePath);
11305
+ const filePath = path65__default.join(this.workspaceRoot, relativePath);
11191
11306
  const sourceFile = this.project.getSourceFile(filePath);
11192
11307
  if (!sourceFile) {
11193
11308
  return ok2([]);
@@ -11203,7 +11318,7 @@ var RenameUseCasePattern = class {
11203
11318
  */
11204
11319
  async updateBarrelExport(relativePath, oldName, newName) {
11205
11320
  try {
11206
- const filePath = path64__default.join(this.workspaceRoot, relativePath);
11321
+ const filePath = path65__default.join(this.workspaceRoot, relativePath);
11207
11322
  const sourceFile = this.project.getSourceFile(filePath);
11208
11323
  if (!sourceFile) {
11209
11324
  return ok2([]);
@@ -11240,24 +11355,24 @@ var RenameUseCasePattern = class {
11240
11355
  */
11241
11356
  async updateTestFile(relativePath, oldName, newName) {
11242
11357
  try {
11243
- const filePath = path64__default.join(this.workspaceRoot, relativePath);
11358
+ const filePath = path65__default.join(this.workspaceRoot, relativePath);
11244
11359
  const sourceFile = this.project.getSourceFile(filePath);
11245
11360
  if (!sourceFile) {
11246
11361
  return ok2([]);
11247
11362
  }
11248
11363
  const modified = await updateImports(sourceFile, oldName, newName);
11249
11364
  if (modified) {
11250
- const oldFileName = path64__default.basename(relativePath);
11365
+ const oldFileName = path65__default.basename(relativePath);
11251
11366
  const newFileName = oldFileName.replace(
11252
11367
  toKebabCase(oldName),
11253
11368
  toKebabCase(newName)
11254
11369
  );
11255
11370
  if (oldFileName !== newFileName) {
11256
- const newFilePath = path64__default.join(path64__default.dirname(filePath), newFileName);
11371
+ const newFilePath = path65__default.join(path65__default.dirname(filePath), newFileName);
11257
11372
  await sourceFile.move(newFilePath);
11258
11373
  return ok2([
11259
11374
  relativePath,
11260
- path64__default.relative(this.workspaceRoot, newFilePath)
11375
+ path65__default.relative(this.workspaceRoot, newFilePath)
11261
11376
  ]);
11262
11377
  }
11263
11378
  }
@@ -11268,7 +11383,7 @@ var RenameUseCasePattern = class {
11268
11383
  }
11269
11384
  async updateCompositionRoot(relativePath, oldName, newName) {
11270
11385
  try {
11271
- const filePath = path64__default.join(this.workspaceRoot, relativePath);
11386
+ const filePath = path65__default.join(this.workspaceRoot, relativePath);
11272
11387
  const sourceFile = this.project.getSourceFile(filePath);
11273
11388
  if (!sourceFile) {
11274
11389
  return ok2([]);
@@ -11338,7 +11453,7 @@ var RenameEntityPattern = class {
11338
11453
  if (file.path.endsWith(".ts") || file.path.endsWith(".tsx")) {
11339
11454
  try {
11340
11455
  this.project.addSourceFileAtPath(
11341
- path64__default.join(this.workspaceRoot, file.path)
11456
+ path65__default.join(this.workspaceRoot, file.path)
11342
11457
  );
11343
11458
  } catch {
11344
11459
  }
@@ -11396,7 +11511,7 @@ var RenameEntityPattern = class {
11396
11511
  async renameEntityFile(relativePath, oldName, newName) {
11397
11512
  try {
11398
11513
  const sourceFile = this.project.getSourceFile(
11399
- path64__default.join(this.workspaceRoot, relativePath)
11514
+ path65__default.join(this.workspaceRoot, relativePath)
11400
11515
  );
11401
11516
  if (!sourceFile) return err2(new Error(`File not found: ${relativePath}`));
11402
11517
  const classDecl = sourceFile.getClass(oldName);
@@ -11413,7 +11528,7 @@ var RenameEntityPattern = class {
11413
11528
  async updateReferences(relativePath, oldName, newName) {
11414
11529
  try {
11415
11530
  const sourceFile = this.project.getSourceFile(
11416
- path64__default.join(this.workspaceRoot, relativePath)
11531
+ path65__default.join(this.workspaceRoot, relativePath)
11417
11532
  );
11418
11533
  if (!sourceFile) return ok2([]);
11419
11534
  let modified = false;
@@ -11432,11 +11547,11 @@ var RenameEntityPattern = class {
11432
11547
  }
11433
11548
  async updateManifest(oldName, newName) {
11434
11549
  try {
11435
- const manifestPath = path64__default.join(
11550
+ const manifestPath = path65__default.join(
11436
11551
  this.workspaceRoot,
11437
11552
  ".architecture/manifest.yaml"
11438
11553
  );
11439
- const content = await fs25.readFile(manifestPath, "utf-8");
11554
+ const content = await fs26.readFile(manifestPath, "utf-8");
11440
11555
  const manifest = yaml10.load(content);
11441
11556
  if (manifest.bounded_contexts) {
11442
11557
  for (const context of manifest.bounded_contexts) {
@@ -11448,7 +11563,7 @@ var RenameEntityPattern = class {
11448
11563
  }
11449
11564
  }
11450
11565
  }
11451
- await fs25.writeFile(
11566
+ await fs26.writeFile(
11452
11567
  manifestPath,
11453
11568
  yaml10.dump(manifest, { indent: 2 }),
11454
11569
  "utf-8"
@@ -12132,7 +12247,7 @@ var manifestSplitCommander = new Command("split").description("Split monolithic
12132
12247
  const dryRun = options.dryRun ?? false;
12133
12248
  try {
12134
12249
  const workspaceRoot = await findWorkspaceRoot({});
12135
- const monolithicManifestPath = path64__default.join(
12250
+ const monolithicManifestPath = path65__default.join(
12136
12251
  workspaceRoot,
12137
12252
  ".architecture/manifest.yaml"
12138
12253
  );
@@ -12141,7 +12256,7 @@ var manifestSplitCommander = new Command("split").description("Split monolithic
12141
12256
  );
12142
12257
  let manifestContent;
12143
12258
  try {
12144
- manifestContent = await fs25.readFile(monolithicManifestPath, "utf-8");
12259
+ manifestContent = await fs26.readFile(monolithicManifestPath, "utf-8");
12145
12260
  } catch {
12146
12261
  throw new Error(`Failed to read manifest.yaml. Does it exist?`);
12147
12262
  }
@@ -12169,14 +12284,14 @@ Validation successful. Found ${contexts.length} bounded contexts.`
12169
12284
  const planes = rawYaml.planes ?? {};
12170
12285
  const planeLookup = buildPlaneLookup(planes);
12171
12286
  console.log("Splitting manifest into the new directory structure...");
12172
- const archDir = path64__default.join(workspaceRoot, ".architecture");
12173
- const contextsDir = path64__default.join(archDir, "contexts");
12174
- const appsDir = path64__default.join(archDir, "apps");
12175
- const invariantsDir = path64__default.join(archDir, "invariants");
12287
+ const archDir = path65__default.join(workspaceRoot, ".architecture");
12288
+ const contextsDir = path65__default.join(archDir, "contexts");
12289
+ const appsDir = path65__default.join(archDir, "apps");
12290
+ const invariantsDir = path65__default.join(archDir, "invariants");
12176
12291
  if (!dryRun) {
12177
- await fs25.mkdir(contextsDir, { recursive: true });
12178
- await fs25.mkdir(appsDir, { recursive: true });
12179
- await fs25.mkdir(invariantsDir, { recursive: true });
12292
+ await fs26.mkdir(contextsDir, { recursive: true });
12293
+ await fs26.mkdir(appsDir, { recursive: true });
12294
+ await fs26.mkdir(invariantsDir, { recursive: true });
12180
12295
  }
12181
12296
  const CATEGORY_B_KEYS = /* @__PURE__ */ new Set(["monorepo", "generator"]);
12182
12297
  const workspaceConfig = {};
@@ -12216,12 +12331,12 @@ Validation successful. Found ${contexts.length} bounded contexts.`
12216
12331
  }
12217
12332
  for (const ctx of contexts) {
12218
12333
  const plane = planeLookup.get(ctx.name) ?? ctx.plane ?? "core";
12219
- const ctxDir = path64__default.join(contextsDir, plane, ctx.name);
12334
+ const ctxDir = path65__default.join(contextsDir, plane, ctx.name);
12220
12335
  const contextData = normalizeContextData(
12221
12336
  extractContextData(ctx)
12222
12337
  );
12223
12338
  contextData.plane = plane;
12224
- const ctxFilePath = path64__default.join(ctxDir, "context.yaml");
12339
+ const ctxFilePath = path65__default.join(ctxDir, "context.yaml");
12225
12340
  const ctxYaml = yaml10.dump(contextData, {
12226
12341
  noRefs: true,
12227
12342
  sortKeys: false,
@@ -12230,8 +12345,8 @@ Validation successful. Found ${contexts.length} bounded contexts.`
12230
12345
  if (dryRun) {
12231
12346
  console.log(`[dry-run] Would create: ${ctxFilePath}`);
12232
12347
  } else {
12233
- await fs25.mkdir(ctxDir, { recursive: true });
12234
- await fs25.writeFile(ctxFilePath, ctxYaml, "utf-8");
12348
+ await fs26.mkdir(ctxDir, { recursive: true });
12349
+ await fs26.writeFile(ctxFilePath, ctxYaml, "utf-8");
12235
12350
  }
12236
12351
  indexManifest.bounded_contexts.push({
12237
12352
  name: ctx.name,
@@ -12247,7 +12362,7 @@ Validation successful. Found ${contexts.length} bounded contexts.`
12247
12362
  if (typeof app === "object" && app !== null && "name" in app) {
12248
12363
  const typedApp = app;
12249
12364
  const appName = typedApp.name;
12250
- const appFilePath = path64__default.join(appsDir, `${appName}.app.yaml`);
12365
+ const appFilePath = path65__default.join(appsDir, `${appName}.app.yaml`);
12251
12366
  const appYaml = yaml10.dump(app, {
12252
12367
  noRefs: true,
12253
12368
  sortKeys: false,
@@ -12256,7 +12371,7 @@ Validation successful. Found ${contexts.length} bounded contexts.`
12256
12371
  if (dryRun) {
12257
12372
  console.log(`[dry-run] Would create: ${appFilePath}`);
12258
12373
  } else {
12259
- await fs25.writeFile(appFilePath, appYaml, "utf-8");
12374
+ await fs26.writeFile(appFilePath, appYaml, "utf-8");
12260
12375
  }
12261
12376
  indexManifest.apps.push({
12262
12377
  name: appName,
@@ -12264,7 +12379,7 @@ Validation successful. Found ${contexts.length} bounded contexts.`
12264
12379
  });
12265
12380
  }
12266
12381
  }
12267
- const workspaceConfigPath = path64__default.join(archDir, "workspace.config.yaml");
12382
+ const workspaceConfigPath = path65__default.join(archDir, "workspace.config.yaml");
12268
12383
  const workspaceConfigYaml = yaml10.dump(workspaceConfig, {
12269
12384
  noRefs: true,
12270
12385
  sortKeys: false,
@@ -12275,7 +12390,7 @@ Validation successful. Found ${contexts.length} bounded contexts.`
12275
12390
  console.log("\n--- Preview of workspace.config.yaml ---\n");
12276
12391
  console.log(workspaceConfigYaml);
12277
12392
  } else {
12278
- await fs25.writeFile(workspaceConfigPath, workspaceConfigYaml, "utf-8");
12393
+ await fs26.writeFile(workspaceConfigPath, workspaceConfigYaml, "utf-8");
12279
12394
  }
12280
12395
  const indexYaml = yaml10.dump(indexManifest, {
12281
12396
  noRefs: true,
@@ -12296,9 +12411,9 @@ Validation successful. Found ${contexts.length} bounded contexts.`
12296
12411
  console.log(header + indexYaml);
12297
12412
  } else {
12298
12413
  const backupPath = monolithicManifestPath + ".pre-split-backup";
12299
- await fs25.copyFile(monolithicManifestPath, backupPath);
12414
+ await fs26.copyFile(monolithicManifestPath, backupPath);
12300
12415
  console.log(`Backup created at ${backupPath}`);
12301
- await fs25.writeFile(monolithicManifestPath, header + indexYaml, "utf-8");
12416
+ await fs26.writeFile(monolithicManifestPath, header + indexYaml, "utf-8");
12302
12417
  }
12303
12418
  console.log("\n✅ Manifest split completed successfully!");
12304
12419
  if (dryRun) {
@@ -12493,53 +12608,53 @@ var StampGeneratorIdentityUseCase = class {
12493
12608
 
12494
12609
  // src/commands/manifest/migrate.ts
12495
12610
  async function clearSiblingPath(siblingPath) {
12496
- const stat4 = await fs25.lstat(siblingPath).catch(() => null);
12611
+ const stat4 = await fs26.lstat(siblingPath).catch(() => null);
12497
12612
  if (stat4 === null) {
12498
12613
  return;
12499
12614
  }
12500
12615
  if (!stat4.isFile()) {
12501
12616
  throw new Error(
12502
- `refusing to write ${path64__default.basename(siblingPath)}: it exists and is not a regular file`
12617
+ `refusing to write ${path65__default.basename(siblingPath)}: it exists and is not a regular file`
12503
12618
  );
12504
12619
  }
12505
- await fs25.rm(siblingPath);
12620
+ await fs26.rm(siblingPath);
12506
12621
  }
12507
12622
  async function writeWithBackup(filePath, content) {
12508
12623
  const backupPath = filePath + ".pre-migrate-backup";
12509
12624
  const tempPath = filePath + ".tmp";
12510
12625
  await clearSiblingPath(backupPath);
12511
12626
  await clearSiblingPath(tempPath);
12512
- await fs25.copyFile(filePath, backupPath, constants.COPYFILE_EXCL);
12627
+ await fs26.copyFile(filePath, backupPath, constants.COPYFILE_EXCL);
12513
12628
  try {
12514
- await fs25.writeFile(tempPath, content, { encoding: "utf-8", flag: "wx" });
12515
- await fs25.rename(tempPath, filePath);
12629
+ await fs26.writeFile(tempPath, content, { encoding: "utf-8", flag: "wx" });
12630
+ await fs26.rename(tempPath, filePath);
12516
12631
  } catch (writeErr) {
12517
- await fs25.rm(tempPath, { force: true });
12632
+ await fs26.rm(tempPath, { force: true });
12518
12633
  throw writeErr;
12519
12634
  }
12520
12635
  return backupPath;
12521
12636
  }
12522
12637
  async function canonicalPathInsideArchitecture(archDir, filePath, label) {
12523
- const canonicalArchDir = path64__default.join(
12524
- await fs25.realpath(path64__default.dirname(archDir)),
12525
- path64__default.basename(archDir)
12638
+ const canonicalArchDir = path65__default.join(
12639
+ await fs26.realpath(path65__default.dirname(archDir)),
12640
+ path65__default.basename(archDir)
12526
12641
  );
12527
- const targetStat = await fs25.lstat(filePath).catch(() => null);
12642
+ const targetStat = await fs26.lstat(filePath).catch(() => null);
12528
12643
  if (targetStat !== null && !targetStat.isFile()) {
12529
12644
  throw new Error(`${label.kind} is not a regular file: ${label.display}`);
12530
12645
  }
12531
12646
  let canonicalPath;
12532
12647
  if (targetStat === null) {
12533
- const canonicalParent = await fs25.realpath(path64__default.dirname(filePath)).catch(() => null);
12648
+ const canonicalParent = await fs26.realpath(path65__default.dirname(filePath)).catch(() => null);
12534
12649
  if (canonicalParent === null) {
12535
12650
  throw new Error(label.notFound);
12536
12651
  }
12537
- canonicalPath = path64__default.join(canonicalParent, path64__default.basename(filePath));
12652
+ canonicalPath = path65__default.join(canonicalParent, path65__default.basename(filePath));
12538
12653
  } else {
12539
- canonicalPath = await fs25.realpath(filePath);
12654
+ canonicalPath = await fs26.realpath(filePath);
12540
12655
  }
12541
- const canonicalRel = path64__default.relative(canonicalArchDir, canonicalPath);
12542
- if (canonicalRel.startsWith("..") || path64__default.isAbsolute(canonicalRel)) {
12656
+ const canonicalRel = path65__default.relative(canonicalArchDir, canonicalPath);
12657
+ if (canonicalRel.startsWith("..") || path65__default.isAbsolute(canonicalRel)) {
12543
12658
  throw new Error(
12544
12659
  `${label.owner} points outside .architecture/: ${label.display} (.architecture itself must not be a symlink; run migrate in the real directory)`
12545
12660
  );
@@ -12559,12 +12674,12 @@ async function assertUnchangedSinceRead(archDir, filePath, label, canonicalPath)
12559
12674
  }
12560
12675
  }
12561
12676
  async function loadRootManifest(workspaceRoot) {
12562
- const archDir = path64__default.join(workspaceRoot, ".architecture");
12563
- const manifestPath = path64__default.join(workspaceRoot, ".architecture/manifest.yaml");
12677
+ const archDir = path65__default.join(workspaceRoot, ".architecture");
12678
+ const manifestPath = path65__default.join(workspaceRoot, ".architecture/manifest.yaml");
12564
12679
  const manifestLabel = {
12565
12680
  kind: "manifest",
12566
12681
  owner: "manifest",
12567
- display: path64__default.relative(workspaceRoot, manifestPath),
12682
+ display: path65__default.relative(workspaceRoot, manifestPath),
12568
12683
  notFound: `Failed to read ${manifestPath}. Does it exist?`
12569
12684
  };
12570
12685
  const canonicalManifestPath = await canonicalPathInsideArchitecture(
@@ -12574,7 +12689,7 @@ async function loadRootManifest(workspaceRoot) {
12574
12689
  );
12575
12690
  let content;
12576
12691
  try {
12577
- content = await fs25.readFile(canonicalManifestPath, "utf-8");
12692
+ content = await fs26.readFile(canonicalManifestPath, "utf-8");
12578
12693
  } catch {
12579
12694
  throw new Error(`Failed to read ${manifestPath}. Does it exist?`);
12580
12695
  }
@@ -12612,9 +12727,9 @@ async function resolveSideCar(plan) {
12612
12727
  canonicalSideCarPath: void 0
12613
12728
  };
12614
12729
  }
12615
- const sideCarPath = path64__default.join(plan.archDir, workspaceConfigPointer);
12616
- const containmentRel = path64__default.relative(plan.archDir, sideCarPath);
12617
- if (containmentRel.startsWith("..") || path64__default.isAbsolute(containmentRel)) {
12730
+ const sideCarPath = path65__default.join(plan.archDir, workspaceConfigPointer);
12731
+ const containmentRel = path65__default.relative(plan.archDir, sideCarPath);
12732
+ if (containmentRel.startsWith("..") || path65__default.isAbsolute(containmentRel)) {
12618
12733
  throw new Error(
12619
12734
  `workspace_config points outside .architecture/: ${workspaceConfigPointer}`
12620
12735
  );
@@ -12630,10 +12745,10 @@ async function resolveSideCar(plan) {
12630
12745
  sideCarPath,
12631
12746
  sideCarLabel
12632
12747
  );
12633
- const sideCarRel = path64__default.relative(plan.workspaceRoot, canonicalSideCarPath);
12748
+ const sideCarRel = path65__default.relative(plan.workspaceRoot, canonicalSideCarPath);
12634
12749
  let sideCarText;
12635
12750
  try {
12636
- sideCarText = await fs25.readFile(canonicalSideCarPath, "utf-8");
12751
+ sideCarText = await fs26.readFile(canonicalSideCarPath, "utf-8");
12637
12752
  } catch {
12638
12753
  throw new Error(`Workspace config file not found: ${sideCarPath}`);
12639
12754
  }
@@ -12670,7 +12785,7 @@ function stampIdentity(plan, sideCar) {
12670
12785
  }
12671
12786
  if (sideCar.target === "root") {
12672
12787
  const stamp2 = identityStamp.execute(plan.rootContent);
12673
- const rel = path64__default.relative(plan.workspaceRoot, plan.canonicalManifestPath);
12788
+ const rel = path65__default.relative(plan.workspaceRoot, plan.canonicalManifestPath);
12674
12789
  if (stamp2.changed) {
12675
12790
  console.log(
12676
12791
  `Identity: generator.name ${identityLabel} — added to ${rel}`
@@ -12706,7 +12821,7 @@ function printDryRun(plan, sideCar, identity) {
12706
12821
  const wouldRewrite = [];
12707
12822
  if (identity.rootChangedFinal) {
12708
12823
  wouldRewrite.push(
12709
- path64__default.relative(plan.workspaceRoot, plan.canonicalManifestPath)
12824
+ path65__default.relative(plan.workspaceRoot, plan.canonicalManifestPath)
12710
12825
  );
12711
12826
  }
12712
12827
  if (identity.sideCarChanged) {
@@ -12808,7 +12923,7 @@ async function runAdopt(options) {
12808
12923
  );
12809
12924
  }
12810
12925
  const contents = serializeLayout(detection);
12811
- const layoutPath = path64__default.join(options.root, ".architecture", "layout.yaml");
12926
+ const layoutPath = path65__default.join(options.root, ".architecture", "layout.yaml");
12812
12927
  if (options.dryRun === true) {
12813
12928
  return ok2({
12814
12929
  layoutPath,
@@ -12823,7 +12938,7 @@ async function runAdopt(options) {
12823
12938
  )
12824
12939
  );
12825
12940
  }
12826
- await promises.mkdir(path64__default.dirname(layoutPath), { recursive: true });
12941
+ await promises.mkdir(path65__default.dirname(layoutPath), { recursive: true });
12827
12942
  const existsLookup = await lstatExists(layoutPath);
12828
12943
  if (!existsLookup.success) return existsLookup;
12829
12944
  if (existsLookup.value && options.force !== true) {
@@ -12835,11 +12950,11 @@ async function runAdopt(options) {
12835
12950
  }
12836
12951
  await promises.writeFile(layoutPath, contents, "utf8");
12837
12952
  const manifestLookup = await lstatExists(
12838
- path64__default.join(options.root, ".architecture", "manifest.yaml")
12953
+ path65__default.join(options.root, ".architecture", "manifest.yaml")
12839
12954
  );
12840
12955
  if (!manifestLookup.success) return manifestLookup;
12841
12956
  const nextSteps = [
12842
- `Wrote ${path64__default.relative(options.root, layoutPath) || ".architecture/layout.yaml"}.`,
12957
+ `Wrote ${path65__default.relative(options.root, layoutPath) || ".architecture/layout.yaml"}.`,
12843
12958
  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."
12844
12959
  ];
12845
12960
  if (options.invokeLint === true) {
@@ -12854,7 +12969,7 @@ async function runAdopt(options) {
12854
12969
  }
12855
12970
  async function adoptCommand(options) {
12856
12971
  const result = await runAdopt({
12857
- root: path64__default.resolve(options.root ?? process.cwd()),
12972
+ root: path65__default.resolve(options.root ?? process.cwd()),
12858
12973
  yes: options.yes,
12859
12974
  dryRun: options.dryRun,
12860
12975
  invokeLint: options.invokeLint,
@@ -13037,11 +13152,11 @@ async function runBootstrap(options) {
13037
13152
  );
13038
13153
  }
13039
13154
  const detection = await detectWorkspaces(options.root);
13040
- const archDir = path64__default.join(options.root, ".architecture");
13155
+ const archDir = path65__default.join(options.root, ".architecture");
13041
13156
  const files = [
13042
- path64__default.join(archDir, "manifest.yaml"),
13043
- ...options.skipLayout === true ? [] : [path64__default.join(archDir, "layout.yaml")],
13044
- path64__default.join(archDir, "arch-lint-baseline.json")
13157
+ path65__default.join(archDir, "manifest.yaml"),
13158
+ ...options.skipLayout === true ? [] : [path65__default.join(archDir, "layout.yaml")],
13159
+ path65__default.join(archDir, "arch-lint-baseline.json")
13045
13160
  ];
13046
13161
  if (options.force !== true) {
13047
13162
  const blockers = [];
@@ -13052,7 +13167,7 @@ async function runBootstrap(options) {
13052
13167
  if (e.code === "ENOENT") continue;
13053
13168
  return err2(e instanceof Error ? e : new Error(String(e)));
13054
13169
  }
13055
- if (path64__default.basename(file) === "arch-lint-baseline.json") {
13170
+ if (path65__default.basename(file) === "arch-lint-baseline.json") {
13056
13171
  try {
13057
13172
  const parsed = JSON.parse(await promises.readFile(file, "utf8"));
13058
13173
  if (Array.isArray(parsed.entries) && parsed.entries.length > 0) {
@@ -13097,7 +13212,7 @@ ${blockers.map((b) => ` ${b}`).join("\n")}`
13097
13212
  }
13098
13213
  async function bootstrapCommand(options) {
13099
13214
  const result = await runBootstrap({
13100
- root: path64__default.resolve(options.root ?? process.cwd()),
13215
+ root: path65__default.resolve(options.root ?? process.cwd()),
13101
13216
  yes: options.yes,
13102
13217
  answersPath: options.answers,
13103
13218
  stdinJson: options.stdinJson,
@@ -13328,8 +13443,8 @@ var EMPTY_DRIFT = {
13328
13443
  collected: false
13329
13444
  };
13330
13445
  function buildEngagementReport(input) {
13331
- const baselinePath = path64__default.join(input.workspaceRoot, DEFAULT_BASELINE_REL);
13332
- const layoutPath = path64__default.join(input.workspaceRoot, DEFAULT_LAYOUT_REL);
13446
+ const baselinePath = path65__default.join(input.workspaceRoot, DEFAULT_BASELINE_REL);
13447
+ const layoutPath = path65__default.join(input.workspaceRoot, DEFAULT_LAYOUT_REL);
13333
13448
  const baselinePresent = existsSync(baselinePath);
13334
13449
  let suppressions = [];
13335
13450
  if (baselinePresent) {
@@ -13650,7 +13765,7 @@ function buildHandoffZip(report2, workspaceRoot) {
13650
13765
  `
13651
13766
  }
13652
13767
  ];
13653
- const manifestPath = path64__default.join(
13768
+ const manifestPath = path65__default.join(
13654
13769
  workspaceRoot,
13655
13770
  ".architecture",
13656
13771
  "manifest.yaml"
@@ -13661,14 +13776,14 @@ function buildHandoffZip(report2, workspaceRoot) {
13661
13776
  content: readFileSync(manifestPath, "utf8")
13662
13777
  });
13663
13778
  }
13664
- const layoutPath = path64__default.join(workspaceRoot, DEFAULT_LAYOUT_REL);
13779
+ const layoutPath = path65__default.join(workspaceRoot, DEFAULT_LAYOUT_REL);
13665
13780
  if (existsSync(layoutPath)) {
13666
13781
  entries.push({
13667
13782
  name: "layout.yaml",
13668
13783
  content: readFileSync(layoutPath, "utf8")
13669
13784
  });
13670
13785
  }
13671
- const baselinePath = path64__default.join(workspaceRoot, DEFAULT_BASELINE_REL);
13786
+ const baselinePath = path65__default.join(workspaceRoot, DEFAULT_BASELINE_REL);
13672
13787
  if (existsSync(baselinePath)) {
13673
13788
  entries.push({
13674
13789
  name: "arch-lint-baseline.json",
@@ -13764,11 +13879,11 @@ async function reportCommand(options = {}) {
13764
13879
  git: createGitReader(workspaceRoot),
13765
13880
  lint: createSpawnLintCollector(workspaceRoot)
13766
13881
  });
13767
- const outDir = path64__default.resolve(workspaceRoot, options.out ?? ".");
13882
+ const outDir = path65__default.resolve(workspaceRoot, options.out ?? ".");
13768
13883
  mkdirSync(outDir, { recursive: true });
13769
13884
  const format = options.format ?? "both";
13770
- const markdownPath = path64__default.join(outDir, "hexagen-report.md");
13771
- const htmlPath = path64__default.join(outDir, "hexagen-report.html");
13885
+ const markdownPath = path65__default.join(outDir, "hexagen-report.md");
13886
+ const htmlPath = path65__default.join(outDir, "hexagen-report.html");
13772
13887
  if (format === "md" || format === "both") {
13773
13888
  writeFileSync(markdownPath, renderReportMarkdown(report2), "utf8");
13774
13889
  }
@@ -13777,11 +13892,11 @@ async function reportCommand(options = {}) {
13777
13892
  }
13778
13893
  let handoffPath;
13779
13894
  if (options.handoff) {
13780
- handoffPath = path64__default.resolve(
13895
+ handoffPath = path65__default.resolve(
13781
13896
  workspaceRoot,
13782
- options.handoffOut ?? path64__default.join(outDir, "hexagen-handoff.zip")
13897
+ options.handoffOut ?? path65__default.join(outDir, "hexagen-handoff.zip")
13783
13898
  );
13784
- mkdirSync(path64__default.dirname(handoffPath), { recursive: true });
13899
+ mkdirSync(path65__default.dirname(handoffPath), { recursive: true });
13785
13900
  writeFileSync(handoffPath, buildHandoffZip(report2, workspaceRoot));
13786
13901
  }
13787
13902
  return { markdownPath, htmlPath, handoffPath };
@@ -13945,8 +14060,8 @@ function invokeHexagenLint(root) {
13945
14060
  };
13946
14061
  }
13947
14062
  async function previewScan(root, options) {
13948
- const layoutPath = path64__default.join(root, ".architecture", "layout.yaml");
13949
- const manifestPath = path64__default.join(root, ".architecture", "manifest.yaml");
14063
+ const layoutPath = path65__default.join(root, ".architecture", "layout.yaml");
14064
+ const manifestPath = path65__default.join(root, ".architecture", "manifest.yaml");
13950
14065
  const adopted = await runAdopt({ root, dryRun: true });
13951
14066
  if (!adopted.success) return adopted;
13952
14067
  const nextSteps = [...adopted.value.nextSteps];
@@ -13998,8 +14113,8 @@ async function previewScan(root, options) {
13998
14113
  async function runScan(options) {
13999
14114
  try {
14000
14115
  const root = options.root;
14001
- const layoutPath = path64__default.join(root, ".architecture", "layout.yaml");
14002
- const manifestPath = path64__default.join(root, ".architecture", "manifest.yaml");
14116
+ const layoutPath = path65__default.join(root, ".architecture", "layout.yaml");
14117
+ const manifestPath = path65__default.join(root, ".architecture", "manifest.yaml");
14003
14118
  if (options.handoff === true && options.noReport === true) {
14004
14119
  return err2(
14005
14120
  new Error(
@@ -14044,7 +14159,7 @@ async function runScan(options) {
14044
14159
  );
14045
14160
  } else {
14046
14161
  nextSteps.push(
14047
- `Kept existing ${path64__default.relative(root, layoutPath) || ".architecture/layout.yaml"}.`
14162
+ `Kept existing ${path65__default.relative(root, layoutPath) || ".architecture/layout.yaml"}.`
14048
14163
  );
14049
14164
  }
14050
14165
  const manifestLookup = await lstatExists(manifestPath);
@@ -14150,7 +14265,7 @@ async function runScan(options) {
14150
14265
  }
14151
14266
  async function scanCommand(options) {
14152
14267
  const result = await runScan({
14153
- root: path64__default.resolve(options.root ?? process.cwd()),
14268
+ root: path65__default.resolve(options.root ?? process.cwd()),
14154
14269
  yes: options.yes,
14155
14270
  dryRun: options.dryRun,
14156
14271
  force: options.force,
@@ -14363,30 +14478,30 @@ async function realpathOfExistingAncestor(p) {
14363
14478
  for (; ; ) {
14364
14479
  try {
14365
14480
  const real = await promises.realpath(current);
14366
- return path64__default.join(real, path64__default.relative(current, p));
14481
+ return path65__default.join(real, path65__default.relative(current, p));
14367
14482
  } catch {
14368
- const parent = path64__default.dirname(current);
14483
+ const parent = path65__default.dirname(current);
14369
14484
  if (parent === current) return p;
14370
14485
  current = parent;
14371
14486
  }
14372
14487
  }
14373
14488
  }
14374
14489
  function isInside(parent, child) {
14375
- const rel = path64__default.relative(parent, child);
14376
- return rel !== "" && !rel.startsWith("..") && !path64__default.isAbsolute(rel);
14490
+ const rel = path65__default.relative(parent, child);
14491
+ return rel !== "" && !rel.startsWith("..") && !path65__default.isAbsolute(rel);
14377
14492
  }
14378
14493
  async function resolveExcludeFile(root) {
14379
14494
  const printed = gitOut(root, ["rev-parse", "--git-path", "info/exclude"]);
14380
- const file = path64__default.resolve(root, printed);
14495
+ const file = path65__default.resolve(root, printed);
14381
14496
  const allowed = [
14382
14497
  gitOut(root, ["rev-parse", "--absolute-git-dir"]),
14383
- path64__default.resolve(root, gitOut(root, ["rev-parse", "--git-common-dir"])),
14498
+ path65__default.resolve(root, gitOut(root, ["rev-parse", "--git-common-dir"])),
14384
14499
  gitOut(root, ["rev-parse", "--show-toplevel"])
14385
14500
  ];
14386
14501
  let effective = file;
14387
14502
  try {
14388
14503
  if ((await promises.lstat(file)).isSymbolicLink()) {
14389
- effective = path64__default.resolve(path64__default.dirname(file), await promises.readlink(file));
14504
+ effective = path65__default.resolve(path65__default.dirname(file), await promises.readlink(file));
14390
14505
  }
14391
14506
  } catch {
14392
14507
  }
@@ -14426,7 +14541,7 @@ async function ensureExcluded(root, entry) {
14426
14541
  if (e.code !== "ENOENT") throw e;
14427
14542
  }
14428
14543
  if (isExcluded(text, entry)) return { file, wrote: false };
14429
- await promises.mkdir(path64__default.dirname(file), { recursive: true });
14544
+ await promises.mkdir(path65__default.dirname(file), { recursive: true });
14430
14545
  const prefix = text === "" || text.endsWith("\n") ? "" : "\n";
14431
14546
  await promises.appendFile(file, `${prefix}${entry}
14432
14547
  `, "utf8");
@@ -14438,15 +14553,15 @@ async function ensureExcluded(root, entry) {
14438
14553
  }
14439
14554
  }
14440
14555
  async function resolveSidecarOut(root, out) {
14441
- if (out.endsWith("/") || out.endsWith(path64__default.sep)) return null;
14442
- const abs = path64__default.resolve(root, out);
14443
- const sidecar = path64__default.join(root, ".hexagen");
14444
- const rel = path64__default.relative(sidecar, abs);
14445
- if (rel === "" || rel.startsWith("..") || path64__default.isAbsolute(rel)) return null;
14556
+ if (out.endsWith("/") || out.endsWith(path65__default.sep)) return null;
14557
+ const abs = path65__default.resolve(root, out);
14558
+ const sidecar = path65__default.join(root, ".hexagen");
14559
+ const rel = path65__default.relative(sidecar, abs);
14560
+ if (rel === "" || rel.startsWith("..") || path65__default.isAbsolute(rel)) return null;
14446
14561
  const realRoot = await promises.realpath(root);
14447
14562
  const realTarget = await realpathOfExistingAncestor(abs);
14448
- const realRel = path64__default.relative(path64__default.join(realRoot, ".hexagen"), realTarget);
14449
- if (realRel === "" || realRel.startsWith("..") || path64__default.isAbsolute(realRel)) {
14563
+ const realRel = path65__default.relative(path65__default.join(realRoot, ".hexagen"), realTarget);
14564
+ if (realRel === "" || realRel.startsWith("..") || path65__default.isAbsolute(realRel)) {
14450
14565
  return null;
14451
14566
  }
14452
14567
  return abs;
@@ -14527,9 +14642,9 @@ var JS_TO_TS = {
14527
14642
  ".cjs": [".cts"]
14528
14643
  };
14529
14644
  function joinInRepo(dir, rel) {
14530
- if (path64__default.posix.isAbsolute(rel)) return null;
14531
- const joined = path64__default.posix.normalize(
14532
- path64__default.posix.join(dir === "" ? "." : dir, rel)
14645
+ if (path65__default.posix.isAbsolute(rel)) return null;
14646
+ const joined = path65__default.posix.normalize(
14647
+ path65__default.posix.join(dir === "" ? "." : dir, rel)
14533
14648
  );
14534
14649
  if (joined === ".." || joined.startsWith("../")) return null;
14535
14650
  const bare = joined.replace(/\/$/, "");
@@ -14993,7 +15108,7 @@ async function runPass(options) {
14993
15108
  }
14994
15109
  const effective = /* @__PURE__ */ new Map();
14995
15110
  const readConfig = async (file) => {
14996
- const read = await safeReadText(path64__default.join(root, file), maxFileBytes);
15111
+ const read = await safeReadText(path65__default.join(root, file), maxFileBytes);
14997
15112
  if (read.ok) {
14998
15113
  addBytes(read.size);
14999
15114
  const parsed = parseJsonc(read.text);
@@ -15150,7 +15265,7 @@ async function runPass(options) {
15150
15265
  const batch = sources.slice(i, i + BATCH);
15151
15266
  const texts = [];
15152
15267
  for (const f of batch) {
15153
- const read = await safeReadText(path64__default.join(root, f), maxFileBytes);
15268
+ const read = await safeReadText(path65__default.join(root, f), maxFileBytes);
15154
15269
  if (!read.ok) {
15155
15270
  skip(f, read.why === "too-large" ? "larger than 1 MiB" : "unreadable");
15156
15271
  texts.push(null);
@@ -15254,7 +15369,7 @@ async function walk(root, limits) {
15254
15369
  truncated = timeCapReason(limits.maxMs);
15255
15370
  return;
15256
15371
  }
15257
- const abs = rel === "" ? root : path64__default.join(root, rel);
15372
+ const abs = rel === "" ? root : path65__default.join(root, rel);
15258
15373
  let entries;
15259
15374
  try {
15260
15375
  entries = await promises.readdir(abs, { withFileTypes: true });
@@ -15266,7 +15381,7 @@ async function walk(root, limits) {
15266
15381
  let local = scopes;
15267
15382
  if (entries.some((e) => e.name === ".gitignore" && e.isFile())) {
15268
15383
  try {
15269
- const text = await promises.readFile(path64__default.join(abs, ".gitignore"), "utf8");
15384
+ const text = await promises.readFile(path65__default.join(abs, ".gitignore"), "utf8");
15270
15385
  local = [
15271
15386
  ...scopes,
15272
15387
  {
@@ -15426,7 +15541,7 @@ var ObserveError = class extends Error {
15426
15541
  };
15427
15542
  function realNative(p) {
15428
15543
  try {
15429
- return realpathSync.native(path64__default.resolve(p));
15544
+ return realpathSync.native(path65__default.resolve(p));
15430
15545
  } catch {
15431
15546
  throw new ObserveError(`--root ${p} does not exist or is not accessible`);
15432
15547
  }
@@ -15458,7 +15573,7 @@ async function readText(file) {
15458
15573
  async function readMeta(root, rel, notes) {
15459
15574
  let current = root;
15460
15575
  for (const part of rel.split("/")) {
15461
- current = path64__default.join(current, part);
15576
+ current = path65__default.join(current, part);
15462
15577
  try {
15463
15578
  if ((await promises.lstat(current)).isSymbolicLink()) {
15464
15579
  notes.push(`note: ${rel} is a symlink; not read`);
@@ -15532,7 +15647,7 @@ async function collectPackages(root, files, notes, declared) {
15532
15647
  notes.push(`note: ${file} is not valid JSON; package skipped`);
15533
15648
  continue;
15534
15649
  }
15535
- const fallback = dir === "." ? path64__default.basename(path64__default.resolve(root)) || "root" : dir;
15650
+ const fallback = dir === "." ? path65__default.basename(path65__default.resolve(root)) || "root" : dir;
15536
15651
  if (name !== void 0) declared?.add(file);
15537
15652
  if (name === void 0) {
15538
15653
  notes.push(`note: ${file} has no name; reported under its directory`);
@@ -15622,7 +15737,7 @@ async function collectGenerated(root, tree, now, start, maxMs, notes) {
15622
15737
  for (let i = 0; i < candidates.length; i += BATCH) {
15623
15738
  const batch = candidates.slice(i, i + BATCH);
15624
15739
  const hits = await Promise.all(
15625
- batch.map((f) => hasGeneratedHeader(path64__default.join(root, f)))
15740
+ batch.map((f) => hasGeneratedHeader(path65__default.join(root, f)))
15626
15741
  );
15627
15742
  batch.forEach((f, idx) => {
15628
15743
  if (hits[idx]) found.set(f, { path: f, source: "header" });
@@ -15651,7 +15766,7 @@ async function collectDontTouch(root, flagPaths, notes) {
15651
15766
  if (!norm.ok) {
15652
15767
  throw new ObserveError(`--dont-touch "${raw}": ${norm.reason}`);
15653
15768
  }
15654
- const withSlash = !cleaned.endsWith("/") && await isDirectory(path64__default.join(root, cleaned)) ? `${cleaned}/` : cleaned;
15769
+ const withSlash = !cleaned.endsWith("/") && await isDirectory(path65__default.join(root, cleaned)) ? `${cleaned}/` : cleaned;
15655
15770
  items.push({ path: withSlash, source: "flag" });
15656
15771
  }
15657
15772
  let codeowners = null;
@@ -15675,7 +15790,7 @@ async function collectDontTouch(root, flagPaths, notes) {
15675
15790
  skipped += 1;
15676
15791
  continue;
15677
15792
  }
15678
- const asPath = !rel.endsWith("/") && await isDirectory(path64__default.join(root, rel)) ? `${rel}/` : rel;
15793
+ const asPath = !rel.endsWith("/") && await isDirectory(path65__default.join(root, rel)) ? `${rel}/` : rel;
15679
15794
  byPath.set(asPath, {
15680
15795
  path: asPath,
15681
15796
  source: "codeowners",
@@ -15692,7 +15807,7 @@ async function collectDontTouch(root, flagPaths, notes) {
15692
15807
  return { collected: true, items };
15693
15808
  }
15694
15809
  async function observe(options) {
15695
- const root = path64__default.resolve(options.root);
15810
+ const root = path65__default.resolve(options.root);
15696
15811
  const maxFiles = options.maxFiles ?? DEFAULT_MAX_FILES;
15697
15812
  const maxMs = options.maxMs ?? DEFAULT_MAX_MS;
15698
15813
  const now = options.now ?? Date.now;
@@ -15794,14 +15909,14 @@ async function observe(options) {
15794
15909
  }
15795
15910
  async function sidecarProblem(root) {
15796
15911
  try {
15797
- const st = await promises.stat(path64__default.join(root, ".hexagen"));
15798
- return st.isDirectory() ? null : `${path64__default.join(root, ".hexagen")} exists and is not a directory`;
15912
+ const st = await promises.stat(path65__default.join(root, ".hexagen"));
15913
+ return st.isDirectory() ? null : `${path65__default.join(root, ".hexagen")} exists and is not a directory`;
15799
15914
  } catch {
15800
15915
  return null;
15801
15916
  }
15802
15917
  }
15803
15918
  async function runObserve(options) {
15804
- const root = path64__default.resolve(options.root);
15919
+ const root = path65__default.resolve(options.root);
15805
15920
  const messages = [];
15806
15921
  let target = null;
15807
15922
  let excludeFile = null;
@@ -15811,7 +15926,7 @@ async function runObserve(options) {
15811
15926
  target = await resolveSidecarOut(root, options.out);
15812
15927
  if (!target) {
15813
15928
  messages.push(
15814
- `--out must name a file under ${path64__default.join(root, ".hexagen")}${path64__default.sep}; got "${options.out}"`
15929
+ `--out must name a file under ${path65__default.join(root, ".hexagen")}${path65__default.sep}; got "${options.out}"`
15815
15930
  );
15816
15931
  return { exitCode: 2, messages };
15817
15932
  }
@@ -15840,7 +15955,7 @@ async function runObserve(options) {
15840
15955
  const tmp = options.tmpPath?.(target) ?? `${target}.${process.pid}.${randomBytes(4).toString("hex")}.tmp`;
15841
15956
  let created = false;
15842
15957
  try {
15843
- await promises.mkdir(path64__default.dirname(target), { recursive: true });
15958
+ await promises.mkdir(path65__default.dirname(target), { recursive: true });
15844
15959
  const handle = await promises.open(tmp, "wx");
15845
15960
  created = true;
15846
15961
  try {
@@ -15929,13 +16044,13 @@ function isValidEngagementId(id) {
15929
16044
  return ENGAGEMENT_ID_PATTERN.test(id) && !id.includes("..");
15930
16045
  }
15931
16046
  function isRepoMode(workspaceRoot) {
15932
- return existsSync(path64__default.join(workspaceRoot, ".architecture", "manifest.yaml"));
16047
+ return existsSync(path65__default.join(workspaceRoot, ".architecture", "manifest.yaml"));
15933
16048
  }
15934
16049
  function repoKeyPath(workspaceRoot) {
15935
- return path64__default.join(workspaceRoot, ".hexagen", "grant-signing.key");
16050
+ return path65__default.join(workspaceRoot, ".hexagen", "grant-signing.key");
15936
16051
  }
15937
16052
  function engagementKeyPath(engagementId, homeDir = os2.homedir()) {
15938
- return path64__default.join(homeDir, ".hexagen", "keys", `${engagementId}.key`);
16053
+ return path65__default.join(homeDir, ".hexagen", "keys", `${engagementId}.key`);
15939
16054
  }
15940
16055
  function keyFingerprint(keyHex) {
15941
16056
  return createHash("sha256").update(Buffer.from(keyHex, "hex")).digest("hex").slice(0, 16);
@@ -15977,7 +16092,7 @@ function resolveGrantKey(input) {
15977
16092
  const mode = isRepoMode(input.workspaceRoot) ? "repo" : "brownfield";
15978
16093
  if (input.keyFile) {
15979
16094
  return withFingerprint({
15980
- path: path64__default.resolve(input.keyFile),
16095
+ path: path65__default.resolve(input.keyFile),
15981
16096
  source: "key-file",
15982
16097
  mode
15983
16098
  });
@@ -15985,7 +16100,7 @@ function resolveGrantKey(input) {
15985
16100
  const fromEnv = input.env[GRANT_KEY_ENV_VAR];
15986
16101
  if (fromEnv) {
15987
16102
  return withFingerprint({
15988
- path: path64__default.resolve(fromEnv),
16103
+ path: path65__default.resolve(fromEnv),
15989
16104
  source: "env",
15990
16105
  mode
15991
16106
  });
@@ -16021,7 +16136,7 @@ function resolveGrantKey(input) {
16021
16136
  }
16022
16137
  function readSliceEngagementId(workspaceRoot) {
16023
16138
  try {
16024
- const parsed = Slice.safeParse(JSON.parse(readFileSync(path64__default.join(workspaceRoot, ".hexagen", "slice.json"), "utf-8")));
16139
+ const parsed = Slice.safeParse(JSON.parse(readFileSync(path65__default.join(workspaceRoot, ".hexagen", "slice.json"), "utf-8")));
16025
16140
  return parsed.success ? parsed.data.id : void 0;
16026
16141
  } catch {
16027
16142
  return void 0;
@@ -16199,9 +16314,9 @@ async function releaseLock(lockPath, token) {
16199
16314
  }
16200
16315
  }
16201
16316
  async function canonicalTracePath(filePath) {
16202
- const dir = path64__default.dirname(path64__default.resolve(filePath));
16317
+ const dir = path65__default.dirname(path65__default.resolve(filePath));
16203
16318
  await mkdir(dir, { recursive: true });
16204
- const target = path64__default.join(await realpath(dir), path64__default.basename(filePath));
16319
+ const target = path65__default.join(await realpath(dir), path65__default.basename(filePath));
16205
16320
  try {
16206
16321
  return await realpath(target);
16207
16322
  } catch (error) {
@@ -16259,7 +16374,7 @@ function verifyBundleIndex(index, keyHex) {
16259
16374
  var SidecarFileExistsError = class extends Error {
16260
16375
  };
16261
16376
  async function writeTemp(target, text, guard) {
16262
- await mkdir(path64__default.dirname(target), { recursive: true });
16377
+ await mkdir(path65__default.dirname(target), { recursive: true });
16263
16378
  await guard?.();
16264
16379
  const tmp = `${target}.${process.pid}.${randomBytes(4).toString("hex")}.tmp`;
16265
16380
  const handle = await open(tmp, "wx");
@@ -16564,34 +16679,34 @@ function usage(message) {
16564
16679
  }
16565
16680
  async function realOutDirInsideSidecar(root, dir) {
16566
16681
  const realDir = await promises.realpath(dir);
16567
- const sidecar = await promises.realpath(path64__default.join(root, ".hexagen"));
16682
+ const sidecar = await promises.realpath(path65__default.join(root, ".hexagen"));
16568
16683
  const inside2 = (base, target) => {
16569
- const rel = path64__default.relative(base, target);
16570
- return rel === "" || !(rel.startsWith("..") || path64__default.isAbsolute(rel));
16684
+ const rel = path65__default.relative(base, target);
16685
+ return rel === "" || !(rel.startsWith("..") || path65__default.isAbsolute(rel));
16571
16686
  };
16572
16687
  if (!inside2(sidecar, realDir)) {
16573
16688
  throw new Error(`${dir} resolves outside ${sidecar}`);
16574
16689
  }
16575
- if (inside2(path64__default.join(sidecar, "evidence"), realDir)) {
16690
+ if (inside2(path65__default.join(sidecar, "evidence"), realDir)) {
16576
16691
  throw new Error(`${dir} resolves into the evidence directory`);
16577
16692
  }
16578
16693
  return realDir;
16579
16694
  }
16580
16695
  async function runEvidencePack(options) {
16581
- const root = path64__default.resolve(options.root);
16696
+ const root = path65__default.resolve(options.root);
16582
16697
  const now = options.now ?? (() => /* @__PURE__ */ new Date());
16583
16698
  const env = options.env ?? process.env;
16584
16699
  const out = await resolveSidecarOut(root, options.out).catch(() => null);
16585
16700
  if (!out) {
16586
16701
  return usage(
16587
- `--out must name a file under ${path64__default.join(root, ".hexagen")}${path64__default.sep}; got "${options.out}"`
16702
+ `--out must name a file under ${path65__default.join(root, ".hexagen")}${path65__default.sep}; got "${options.out}"`
16588
16703
  );
16589
16704
  }
16590
- const evidenceDir = path64__default.join(root, ".hexagen", "evidence");
16705
+ const evidenceDir = path65__default.join(root, ".hexagen", "evidence");
16591
16706
  const underEvidence = async () => {
16592
16707
  const inside2 = (base, target) => {
16593
- const rel = path64__default.relative(base, target);
16594
- return rel === "" || !(rel.startsWith("..") || path64__default.isAbsolute(rel));
16708
+ const rel = path65__default.relative(base, target);
16709
+ return rel === "" || !(rel.startsWith("..") || path65__default.isAbsolute(rel));
16595
16710
  };
16596
16711
  if (inside2(evidenceDir, out)) return true;
16597
16712
  const realEvidence = await realpathOfExistingAncestor(evidenceDir);
@@ -16602,7 +16717,7 @@ async function runEvidencePack(options) {
16602
16717
  `--out must not be under ${evidenceDir}: the bundle must never replace the evidence it verified`
16603
16718
  );
16604
16719
  }
16605
- const relOut = path64__default.relative(root, out).split(path64__default.sep).join("/");
16720
+ const relOut = path65__default.relative(root, out).split(path65__default.sep).join("/");
16606
16721
  if (new RegExp(BUNDLE_FORBIDDEN_PATH_PATTERN).test(relOut)) {
16607
16722
  return usage(`--out "${relOut}" names a key or env file; refusing`);
16608
16723
  }
@@ -16615,8 +16730,8 @@ async function runEvidencePack(options) {
16615
16730
  if (options.grantFiles.length === 0) {
16616
16731
  return usage("at least one --grant <file> is required");
16617
16732
  }
16618
- const tracePath = path64__default.resolve(options.trace);
16619
- const canonicalTrace = path64__default.join(root, ...TRACE_RELATIVE);
16733
+ const tracePath = path65__default.resolve(options.trace);
16734
+ const canonicalTrace = path65__default.join(root, ...TRACE_RELATIVE);
16620
16735
  try {
16621
16736
  if (realpathSync.native(tracePath) !== realpathSync.native(canonicalTrace)) {
16622
16737
  return usage(
@@ -16649,7 +16764,7 @@ async function runEvidencePack(options) {
16649
16764
  let text;
16650
16765
  let parsed;
16651
16766
  try {
16652
- text = await promises.readFile(path64__default.resolve(file), "utf8");
16767
+ text = await promises.readFile(path65__default.resolve(file), "utf8");
16653
16768
  parsed = JSON.parse(text);
16654
16769
  } catch (error) {
16655
16770
  return usage(`cannot read grant ${file}: ${error.message}`);
@@ -16695,7 +16810,7 @@ async function runEvidencePack(options) {
16695
16810
  for (const v of verdicts) {
16696
16811
  if (!v.valid) problems.push(describeVerdict(v));
16697
16812
  }
16698
- const tipPath = path64__default.join(root, ...TIP_RELATIVE);
16813
+ const tipPath = path65__default.join(root, ...TIP_RELATIVE);
16699
16814
  let tipChecked = false;
16700
16815
  let previousTip = null;
16701
16816
  let tipText = null;
@@ -16838,13 +16953,13 @@ async function runEvidencePack(options) {
16838
16953
  `
16839
16954
  });
16840
16955
  await options.beforeTipWrite?.();
16841
- const outDir = path64__default.dirname(out);
16956
+ const outDir = path65__default.dirname(out);
16842
16957
  await promises.mkdir(outDir, { recursive: true });
16843
16958
  const realOutDir = await realOutDirInsideSidecar(root, outDir);
16844
16959
  await options.beforeWrite?.();
16845
- const tmp = path64__default.join(
16960
+ const tmp = path65__default.join(
16846
16961
  outDir,
16847
- `.${path64__default.basename(out)}.${process.pid}.${randomBytes(4).toString("hex")}.tmp`
16962
+ `.${path65__default.basename(out)}.${process.pid}.${randomBytes(4).toString("hex")}.tmp`
16848
16963
  );
16849
16964
  try {
16850
16965
  const handle = await promises.open(tmp, "wx");
@@ -17015,9 +17130,9 @@ async function readJson(file, label) {
17015
17130
  throw new UsageError(`${file} is not valid JSON`);
17016
17131
  }
17017
17132
  }
17018
- var slicePath = (root) => path64__default.join(root, ".hexagen", "slice.json");
17019
- var observedPath = (root) => path64__default.join(root, ".hexagen", "observed.json");
17020
- var contractPath = (root) => path64__default.join(root, ".hexagen", "contract.json");
17133
+ var slicePath = (root) => path65__default.join(root, ".hexagen", "slice.json");
17134
+ var observedPath = (root) => path65__default.join(root, ".hexagen", "observed.json");
17135
+ var contractPath = (root) => path65__default.join(root, ".hexagen", "contract.json");
17021
17136
  function parseWith(schema, value, file) {
17022
17137
  try {
17023
17138
  return schema.parse(value);
@@ -17033,8 +17148,8 @@ function assertTopLevel(root) {
17033
17148
  let same = false;
17034
17149
  try {
17035
17150
  same = samePath(
17036
- realpathSync.native(path64__default.resolve(top)),
17037
- realpathSync.native(path64__default.resolve(root))
17151
+ realpathSync.native(path65__default.resolve(top)),
17152
+ realpathSync.native(path65__default.resolve(root))
17038
17153
  );
17039
17154
  } catch {
17040
17155
  same = false;
@@ -17235,8 +17350,8 @@ function coveringLine(candidate, grant, file) {
17235
17350
  }
17236
17351
  function nearestTo(candidates, file) {
17237
17352
  const bySeq = [...candidates].reverse();
17238
- const dir = path64__default.posix.dirname(file);
17239
- return bySeq.find((c) => c.paths.some((p) => path64__default.posix.dirname(p) === dir)) ?? bySeq.find((c) => c.paths.length > 0);
17353
+ const dir = path65__default.posix.dirname(file);
17354
+ return bySeq.find((c) => c.paths.some((p) => path65__default.posix.dirname(p) === dir)) ?? bySeq.find((c) => c.paths.length > 0);
17240
17355
  }
17241
17356
  function traceSeqOf(text) {
17242
17357
  try {
@@ -17319,7 +17434,7 @@ async function joinProposals(root, until, lastSeqAtSince, tipSeq, lines, verdict
17319
17434
  return { joined };
17320
17435
  }
17321
17436
  async function runEvidenceVerify(options) {
17322
- const root = path64__default.resolve(options.root);
17437
+ const root = path65__default.resolve(options.root);
17323
17438
  const env = options.env ?? process.env;
17324
17439
  const untilRef = options.until ?? "HEAD";
17325
17440
  const since = resolveCommit(root, options.since);
@@ -17369,7 +17484,7 @@ async function runEvidenceVerify(options) {
17369
17484
  const keyHex = key.keyHex;
17370
17485
  const grants = /* @__PURE__ */ new Map();
17371
17486
  for (const file of options.grantFiles) {
17372
- const loaded = await loadGrantFile(path64__default.resolve(file));
17487
+ const loaded = await loadGrantFile(path65__default.resolve(file));
17373
17488
  if (!loaded.ok) return usage2([loaded.problem]);
17374
17489
  const signature = verifyGrantSignature(loaded.grant, {
17375
17490
  workspaceRoot: root,
@@ -17618,7 +17733,7 @@ async function exists(file) {
17618
17733
  async function runSliceInit(options) {
17619
17734
  const messages = [];
17620
17735
  try {
17621
- const root = path64__default.resolve(options.root);
17736
+ const root = path65__default.resolve(options.root);
17622
17737
  const paths = options.paths;
17623
17738
  const excludes = options.exclude ?? [];
17624
17739
  if (paths.length === 0) throw new UsageError("--path is required");
@@ -17680,7 +17795,7 @@ async function runSliceInit(options) {
17680
17795
  async function runSliceShow(options) {
17681
17796
  const messages = [];
17682
17797
  try {
17683
- const slice = await loadSlice(path64__default.resolve(options.root));
17798
+ const slice = await loadSlice(path65__default.resolve(options.root));
17684
17799
  return {
17685
17800
  exitCode: 0,
17686
17801
  messages,
@@ -17694,7 +17809,7 @@ async function runSliceShow(options) {
17694
17809
  async function runSliceCheck(options) {
17695
17810
  const messages = [];
17696
17811
  try {
17697
- const root = path64__default.resolve(options.root);
17812
+ const root = path65__default.resolve(options.root);
17698
17813
  const slice = await loadSlice(root);
17699
17814
  const observed = await loadObserved(root);
17700
17815
  const stale = staleInputs(root, slice, observed, options.strict === true);
@@ -18030,7 +18145,7 @@ ${lines.join("\n")}
18030
18145
  async function runContractPropose(options) {
18031
18146
  const messages = [];
18032
18147
  try {
18033
- const root = path64__default.resolve(options.root);
18148
+ const root = path65__default.resolve(options.root);
18034
18149
  const slice = await loadSlice(root);
18035
18150
  const observed = await loadObserved(root);
18036
18151
  const stale = staleInputs(root, slice, observed, options.strict === true);
@@ -18126,7 +18241,7 @@ async function writeContract(root, contract, create, yes, messages) {
18126
18241
  async function locked(root, willWrite, fn) {
18127
18242
  if (!willWrite) return fn();
18128
18243
  try {
18129
- return await withContractLock(path64__default.resolve(root), fn);
18244
+ return await withContractLock(path65__default.resolve(root), fn);
18130
18245
  } catch (e) {
18131
18246
  return asResult(e, []);
18132
18247
  }
@@ -18137,7 +18252,7 @@ function runContractAddRule(options) {
18137
18252
  async function addRule(options) {
18138
18253
  const messages = [];
18139
18254
  try {
18140
- const root = path64__default.resolve(options.root);
18255
+ const root = path65__default.resolve(options.root);
18141
18256
  if (options.kind !== "forbid" && options.kind !== "allow-only" && options.kind !== "closed") {
18142
18257
  throw new UsageError("--kind must be forbid, allow-only or closed");
18143
18258
  }
@@ -18191,7 +18306,7 @@ async function addRule(options) {
18191
18306
  async function runContractShow(options) {
18192
18307
  const messages = [];
18193
18308
  try {
18194
- const root = path64__default.resolve(options.root);
18309
+ const root = path65__default.resolve(options.root);
18195
18310
  const contract = await loadContract(root);
18196
18311
  if (!contract)
18197
18312
  throw new UsageError(
@@ -18254,7 +18369,7 @@ function report(prefix, lines) {
18254
18369
  async function check(options) {
18255
18370
  const messages = [];
18256
18371
  try {
18257
- const root = path64__default.resolve(options.root);
18372
+ const root = path65__default.resolve(options.root);
18258
18373
  const slice = await loadSlice(root);
18259
18374
  const contract = await loadContract(root);
18260
18375
  if (contract && contract.sliceId !== slice.id) {
@@ -18481,10 +18596,10 @@ var BUNDLE_ONLY = {
18481
18596
  "evidence/verdicts.json": "evidence"
18482
18597
  };
18483
18598
  function isForbiddenPath(p) {
18484
- return forbidden2.test(p.split(path64__default.sep).join("/"));
18599
+ return forbidden2.test(p.split(path65__default.sep).join("/"));
18485
18600
  }
18486
18601
  function allowListEntry(sourceRel, options = {}) {
18487
- const source = sourceRel.split(path64__default.sep).join("/");
18602
+ const source = sourceRel.split(path65__default.sep).join("/");
18488
18603
  if (isForbiddenPath(source)) return null;
18489
18604
  let role = FIXED[source];
18490
18605
  if (role === void 0 && options.bundleOnly === true) {
@@ -18510,11 +18625,11 @@ var Refusal = class extends Error {
18510
18625
  exitCode;
18511
18626
  };
18512
18627
  var inside = (base, target) => {
18513
- const rel = path64__default.relative(base, target);
18514
- return rel === "" || !(rel.startsWith("..") || path64__default.isAbsolute(rel));
18628
+ const rel = path65__default.relative(base, target);
18629
+ return rel === "" || !(rel.startsWith("..") || path65__default.isAbsolute(rel));
18515
18630
  };
18516
18631
  async function openSidecar(root, home, afterValidate) {
18517
- const dir = path64__default.join(root, ".hexagen");
18632
+ const dir = path65__default.join(root, ".hexagen");
18518
18633
  let real;
18519
18634
  try {
18520
18635
  real = await promises.realpath(dir);
@@ -18526,13 +18641,13 @@ async function openSidecar(root, home, afterValidate) {
18526
18641
  root,
18527
18642
  dir,
18528
18643
  real,
18529
- homeKeys: path64__default.join(realHome, ".hexagen", "keys"),
18644
+ homeKeys: path65__default.join(realHome, ".hexagen", "keys"),
18530
18645
  afterValidate
18531
18646
  };
18532
18647
  }
18533
18648
  async function readAllowed(sc, entry) {
18534
- const file = path64__default.join(sc.dir, ...entry.source.split("/"));
18535
- if (isForbiddenPath(path64__default.relative(sc.root, file))) {
18649
+ const file = path65__default.join(sc.dir, ...entry.source.split("/"));
18650
+ if (isForbiddenPath(path65__default.relative(sc.root, file))) {
18536
18651
  throw new Refusal(`${entry.source}: names a key or env file; refusing`);
18537
18652
  }
18538
18653
  const st = await promises.lstat(file).catch(() => null);
@@ -18551,7 +18666,7 @@ async function readAllowed(sc, entry) {
18551
18666
  `${entry.source}: resolves into ~/.hexagen/keys; refusing`
18552
18667
  );
18553
18668
  }
18554
- if (isForbiddenPath(path64__default.relative(sc.real, real))) {
18669
+ if (isForbiddenPath(path65__default.relative(sc.real, real))) {
18555
18670
  throw new Refusal(
18556
18671
  `${entry.source}: resolves to a key or env file; refusing`
18557
18672
  );
@@ -18570,7 +18685,7 @@ async function readAllowed(sc, entry) {
18570
18685
  }
18571
18686
  async function listDir(sc, sub) {
18572
18687
  try {
18573
- return (await promises.readdir(path64__default.join(sc.dir, sub))).sort();
18688
+ return (await promises.readdir(path65__default.join(sc.dir, sub))).sort();
18574
18689
  } catch (error) {
18575
18690
  if (error.code === "ENOENT") return [];
18576
18691
  throw error;
@@ -18607,7 +18722,7 @@ async function realOutDirInsideSidecar2(sc, dir) {
18607
18722
  if (!inside(sc.real, realDir)) {
18608
18723
  throw new Error(`${dir} resolves outside ${sc.real}`);
18609
18724
  }
18610
- if (inside(path64__default.join(sc.real, "evidence"), realDir)) {
18725
+ if (inside(path65__default.join(sc.real, "evidence"), realDir)) {
18611
18726
  throw new Error(`${dir} resolves into the evidence directory`);
18612
18727
  }
18613
18728
  return realDir;
@@ -18616,10 +18731,10 @@ async function validateOut(sc, outOption) {
18616
18731
  const out = await resolveSidecarOut(sc.root, outOption).catch(() => null);
18617
18732
  if (!out) {
18618
18733
  throw new Refusal(
18619
- `--out must name a file under ${sc.dir}${path64__default.sep}; got "${outOption}"`
18734
+ `--out must name a file under ${sc.dir}${path65__default.sep}; got "${outOption}"`
18620
18735
  );
18621
18736
  }
18622
- const evidenceDir = path64__default.join(sc.dir, "evidence");
18737
+ const evidenceDir = path65__default.join(sc.dir, "evidence");
18623
18738
  if (inside(evidenceDir, out) || inside(
18624
18739
  await realpathOfExistingAncestor(evidenceDir),
18625
18740
  await realpathOfExistingAncestor(out)
@@ -18628,7 +18743,7 @@ async function validateOut(sc, outOption) {
18628
18743
  `--out must not be under ${evidenceDir}: the bundle must never replace the evidence it carries`
18629
18744
  );
18630
18745
  }
18631
- const relOut = path64__default.relative(sc.root, out).split(path64__default.sep).join("/");
18746
+ const relOut = path65__default.relative(sc.root, out).split(path65__default.sep).join("/");
18632
18747
  if (isForbiddenPath(relOut)) {
18633
18748
  throw new Refusal(`--out "${relOut}" names a key or env file; refusing`);
18634
18749
  }
@@ -18696,7 +18811,7 @@ async function runExport(options, sc, outOption) {
18696
18811
  ];
18697
18812
  for (const [name, role, parse] of optional) {
18698
18813
  const entry = allowListEntry(name);
18699
- if (!await promises.lstat(path64__default.join(sc.dir, name)).then(
18814
+ if (!await promises.lstat(path65__default.join(sc.dir, name)).then(
18700
18815
  () => true,
18701
18816
  () => false
18702
18817
  )) {
@@ -18777,7 +18892,7 @@ async function runExport(options, sc, outOption) {
18777
18892
  ]
18778
18893
  };
18779
18894
  }
18780
- const trace = path64__default.join(sc.dir, "evidence", "trace.jsonl");
18895
+ const trace = path65__default.join(sc.dir, "evidence", "trace.jsonl");
18781
18896
  if (await promises.lstat(trace).then(
18782
18897
  () => true,
18783
18898
  () => false
@@ -18789,7 +18904,7 @@ async function runExport(options, sc, outOption) {
18789
18904
  }
18790
18905
  const tmpName = `.workbook-pack-${process.pid}-${randomBytes(4).toString("hex")}.zip`;
18791
18906
  const tmpRel = `.hexagen/${tmpName}`;
18792
- const tmpAbs = path64__default.join(sc.dir, tmpName);
18907
+ const tmpAbs = path65__default.join(sc.dir, tmpName);
18793
18908
  try {
18794
18909
  const pack = await runEvidencePack({
18795
18910
  root: sc.root,
@@ -18857,7 +18972,7 @@ async function runExport(options, sc, outOption) {
18857
18972
  } finally {
18858
18973
  await promises.unlink(tmpAbs).catch(() => void 0);
18859
18974
  }
18860
- } else if (await promises.lstat(path64__default.join(sc.dir, "evidence", "tip.json")).then(
18975
+ } else if (await promises.lstat(path65__default.join(sc.dir, "evidence", "tip.json")).then(
18861
18976
  () => true,
18862
18977
  () => false
18863
18978
  )) {
@@ -18888,12 +19003,12 @@ async function runExport(options, sc, outOption) {
18888
19003
  ` },
18889
19004
  ...c.entries
18890
19005
  ];
18891
- const outDir = path64__default.dirname(out);
19006
+ const outDir = path65__default.dirname(out);
18892
19007
  await promises.mkdir(outDir, { recursive: true });
18893
19008
  const realOutDir = await realOutDirInsideSidecar2(sc, outDir);
18894
- const tmp = path64__default.join(
19009
+ const tmp = path65__default.join(
18895
19010
  outDir,
18896
- `.${path64__default.basename(out)}.${process.pid}.${randomBytes(4).toString("hex")}.tmp`
19011
+ `.${path65__default.basename(out)}.${process.pid}.${randomBytes(4).toString("hex")}.tmp`
18897
19012
  );
18898
19013
  try {
18899
19014
  const handle = await promises.open(tmp, "wx");
@@ -18955,14 +19070,14 @@ async function diffAgainstHead(root, repoRel, bytes) {
18955
19070
  }
18956
19071
  }
18957
19072
  );
18958
- const tmp = await promises.mkdtemp(path64__default.join(os2.tmpdir(), "hexagen-stage-"));
19073
+ const tmp = await promises.mkdtemp(path65__default.join(os2.tmpdir(), "hexagen-stage-"));
18959
19074
  try {
18960
19075
  for (const [side, content] of [
18961
19076
  ["a", headBytes],
18962
19077
  ["b", bytes]
18963
19078
  ]) {
18964
- const target = path64__default.join(tmp, side, ...repoRel.split("/"));
18965
- await promises.mkdir(path64__default.dirname(target), { recursive: true });
19079
+ const target = path65__default.join(tmp, side, ...repoRel.split("/"));
19080
+ await promises.mkdir(path65__default.dirname(target), { recursive: true });
18966
19081
  await promises.writeFile(target, content);
18967
19082
  }
18968
19083
  try {
@@ -19010,10 +19125,10 @@ async function runStage(options, sc, files) {
19010
19125
  const refusals = [];
19011
19126
  const seen = /* @__PURE__ */ new Set();
19012
19127
  for (const given of files) {
19013
- const abs = path64__default.resolve(sc.root, given);
19014
- const relToSidecar = path64__default.relative(sc.dir, abs);
19015
- if (relToSidecar === "" || relToSidecar.startsWith("..") || path64__default.isAbsolute(relToSidecar)) {
19016
- refusals.push(`${given}: not a file under ${sc.dir}${path64__default.sep}`);
19128
+ const abs = path65__default.resolve(sc.root, given);
19129
+ const relToSidecar = path65__default.relative(sc.dir, abs);
19130
+ if (relToSidecar === "" || relToSidecar.startsWith("..") || path65__default.isAbsolute(relToSidecar)) {
19131
+ refusals.push(`${given}: not a file under ${sc.dir}${path65__default.sep}`);
19017
19132
  continue;
19018
19133
  }
19019
19134
  const entry = allowListEntry(relToSidecar);
@@ -19114,7 +19229,7 @@ async function runStage(options, sc, files) {
19114
19229
  };
19115
19230
  }
19116
19231
  async function runWorkbookExport(options) {
19117
- const root = path64__default.resolve(options.root);
19232
+ const root = path65__default.resolve(options.root);
19118
19233
  try {
19119
19234
  if (options.out !== void 0 && (options.stage?.length ?? 0) > 0) {
19120
19235
  throw new Refusal("--out and --stage are separate modes; give one");
@@ -19197,7 +19312,7 @@ function parseDurationMs(input) {
19197
19312
  // src/commands/grant/build.ts
19198
19313
  var MANIFEST_WRITE_PATH = ".architecture/";
19199
19314
  async function loadBoundedContexts(workspaceRoot) {
19200
- const manifestPath = path64__default.join(
19315
+ const manifestPath = path65__default.join(
19201
19316
  workspaceRoot,
19202
19317
  ".architecture",
19203
19318
  "manifest.yaml"
@@ -19218,7 +19333,7 @@ async function expandContexts(workspaceRoot, contexts) {
19218
19333
  const known = await loadBoundedContexts(workspaceRoot);
19219
19334
  if (known === null) {
19220
19335
  throw new Error(
19221
- `--contexts was given but no manifest exists at ${path64__default.join(workspaceRoot, ".architecture", "manifest.yaml")}. Omit --contexts and pass the full prefixes via --paths instead.`
19336
+ `--contexts was given but no manifest exists at ${path65__default.join(workspaceRoot, ".architecture", "manifest.yaml")}. Omit --contexts and pass the full prefixes via --paths instead.`
19222
19337
  );
19223
19338
  }
19224
19339
  const unknown = contexts.filter((name) => !known.has(name));
@@ -19276,8 +19391,8 @@ async function buildGrant(input, keyHex, signFn, contextPaths = []) {
19276
19391
  }
19277
19392
  async function tightenKeyDirs(keyPath) {
19278
19393
  if (process.platform === "win32") return;
19279
- const keysDir = path64__default.dirname(keyPath);
19280
- for (const dir of [keysDir, path64__default.dirname(keysDir)]) {
19394
+ const keysDir = path65__default.dirname(keyPath);
19395
+ for (const dir of [keysDir, path65__default.dirname(keysDir)]) {
19281
19396
  const { mode } = await stat(dir);
19282
19397
  if ((mode & 63) !== 0) {
19283
19398
  await chmod(dir, 448);
@@ -19295,10 +19410,10 @@ async function grantKeyInitCommand(options) {
19295
19410
  process.exitCode = 1;
19296
19411
  return;
19297
19412
  }
19298
- const keyPath = options.keyFile ? path64__default.resolve(options.keyFile) : engagementKeyPath(options.engagement, options.homeDir);
19413
+ const keyPath = options.keyFile ? path65__default.resolve(options.keyFile) : engagementKeyPath(options.engagement, options.homeDir);
19299
19414
  const keyHex = randomBytes(32).toString("hex");
19300
19415
  try {
19301
- await mkdir(path64__default.dirname(keyPath), { recursive: true, mode: 448 });
19416
+ await mkdir(path65__default.dirname(keyPath), { recursive: true, mode: 448 });
19302
19417
  if (!options.keyFile) await tightenKeyDirs(keyPath);
19303
19418
  await writeFile(keyPath, `${keyHex}
19304
19419
  `, { mode: 384, flag: "wx" });
@@ -19330,7 +19445,7 @@ async function loadSlice2(workspaceRoot) {
19330
19445
  let raw;
19331
19446
  try {
19332
19447
  raw = await readFile(
19333
- path64__default.join(workspaceRoot, ".hexagen", "slice.json"),
19448
+ path65__default.join(workspaceRoot, ".hexagen", "slice.json"),
19334
19449
  "utf-8"
19335
19450
  );
19336
19451
  } catch (error) {
@@ -19346,13 +19461,13 @@ function gitToplevel(cwd) {
19346
19461
  encoding: "utf8",
19347
19462
  stdio: ["ignore", "pipe", "ignore"]
19348
19463
  }).trim();
19349
- return top ? realpathSync.native(path64__default.resolve(top)) : null;
19464
+ return top ? realpathSync.native(path65__default.resolve(top)) : null;
19350
19465
  } catch {
19351
19466
  return null;
19352
19467
  }
19353
19468
  }
19354
19469
  function discoverWorkspaceRoot(workspaceRootOption) {
19355
- if (workspaceRootOption) return path64__default.resolve(workspaceRootOption);
19470
+ if (workspaceRootOption) return path65__default.resolve(workspaceRootOption);
19356
19471
  const cwd = process.cwd();
19357
19472
  const found = findWorkspaceRoot2(cwd);
19358
19473
  const top = gitToplevel(cwd);
@@ -19360,8 +19475,8 @@ function discoverWorkspaceRoot(workspaceRootOption) {
19360
19475
  const discovered = found;
19361
19476
  if (top === null) return discovered;
19362
19477
  try {
19363
- const realTop = realpathSync.native(path64__default.resolve(top));
19364
- const realDiscovered = realpathSync.native(path64__default.resolve(discovered));
19478
+ const realTop = realpathSync.native(path65__default.resolve(top));
19479
+ const realDiscovered = realpathSync.native(path65__default.resolve(discovered));
19365
19480
  return isSameOrInside(realTop, realDiscovered) ? discovered : top;
19366
19481
  } catch {
19367
19482
  return top;
@@ -19402,7 +19517,7 @@ async function rowFor(sc, name, verify, now, key) {
19402
19517
  if (isForbiddenPath(rel)) return invalid("names a key or env file");
19403
19518
  const entry = allowListEntry(rel);
19404
19519
  if (entry === null) return invalid("not allow-listed");
19405
- const st = await lstat(path64__default.join(sc.dir, GRANTS_DIR, name)).catch(() => null);
19520
+ const st = await lstat(path65__default.join(sc.dir, GRANTS_DIR, name)).catch(() => null);
19406
19521
  if (st !== null && !st.isFile()) {
19407
19522
  return invalid(st.isSymbolicLink() ? "symlink" : "not a regular file");
19408
19523
  }
@@ -19508,7 +19623,7 @@ async function grantListCommand(options) {
19508
19623
  }
19509
19624
  throw error;
19510
19625
  }
19511
- const dirPath = path64__default.join(sc.dir, GRANTS_DIR);
19626
+ const dirPath = path65__default.join(sc.dir, GRANTS_DIR);
19512
19627
  const dirStat = await lstat(dirPath).catch(() => null);
19513
19628
  if (dirStat === null) {
19514
19629
  fail(
@@ -19594,7 +19709,7 @@ var SIGNING_KEY_RELATIVE_PATH = [".hexagen", "grant-signing.key"];
19594
19709
  var REQUIRED_KEY_HEX_LENGTH = 64;
19595
19710
  var GITIGNORE_ENTRY = ".hexagen/grant-signing.key";
19596
19711
  async function ensureKeyIsGitignored(workspaceRoot) {
19597
- const gitignorePath = path64__default.join(workspaceRoot, ".gitignore");
19712
+ const gitignorePath = path65__default.join(workspaceRoot, ".gitignore");
19598
19713
  let existing = "";
19599
19714
  try {
19600
19715
  existing = await readFile(gitignorePath, "utf-8");
@@ -19623,7 +19738,7 @@ function validateKeyHex(keyHex, keyPath) {
19623
19738
  }
19624
19739
  }
19625
19740
  async function loadOrCreateSigningKey(workspaceRoot) {
19626
- const keyPath = path64__default.join(workspaceRoot, ...SIGNING_KEY_RELATIVE_PATH);
19741
+ const keyPath = path65__default.join(workspaceRoot, ...SIGNING_KEY_RELATIVE_PATH);
19627
19742
  try {
19628
19743
  const keyHex2 = (await readFile(keyPath, "utf-8")).trim();
19629
19744
  validateKeyHex(keyHex2, keyPath);
@@ -19634,7 +19749,7 @@ async function loadOrCreateSigningKey(workspaceRoot) {
19634
19749
  }
19635
19750
  }
19636
19751
  const keyHex = randomBytes(32).toString("hex");
19637
- await mkdir(path64__default.dirname(keyPath), { recursive: true });
19752
+ await mkdir(path65__default.dirname(keyPath), { recursive: true });
19638
19753
  await ensureKeyIsGitignored(workspaceRoot);
19639
19754
  try {
19640
19755
  await writeFile(keyPath, `${keyHex}
@@ -19819,8 +19934,8 @@ function fail2(code, message) {
19819
19934
  process.exitCode = code;
19820
19935
  }
19821
19936
  function isStrictlyInside(parent, child) {
19822
- const rel = path64__default.relative(parent, child);
19823
- return rel !== "" && !rel.startsWith("..") && !path64__default.isAbsolute(rel);
19937
+ const rel = path65__default.relative(parent, child);
19938
+ return rel !== "" && !rel.startsWith("..") && !path65__default.isAbsolute(rel);
19824
19939
  }
19825
19940
  var RefusedError = class extends Error {
19826
19941
  };
@@ -19861,7 +19976,7 @@ async function grantRevokeCommand(options) {
19861
19976
  }
19862
19977
  const brownfield = !isRepoMode(workspaceRoot);
19863
19978
  let sidecarReal;
19864
- let target = path64__default.resolve(options.grantFile);
19979
+ let target = path65__default.resolve(options.grantFile);
19865
19980
  if (brownfield) {
19866
19981
  try {
19867
19982
  await loadSlice2(workspaceRoot);
@@ -19877,11 +19992,11 @@ async function grantRevokeCommand(options) {
19877
19992
  if (!inside2) {
19878
19993
  return fail2(
19879
19994
  2,
19880
- `the grant file must be under ${path64__default.join(workspaceRoot, ".hexagen")}${path64__default.sep}; got "${options.grantFile}"`
19995
+ `the grant file must be under ${path65__default.join(workspaceRoot, ".hexagen")}${path65__default.sep}; got "${options.grantFile}"`
19881
19996
  );
19882
19997
  }
19883
19998
  target = inside2;
19884
- sidecarReal = path64__default.join(await realpath(workspaceRoot), ".hexagen");
19999
+ sidecarReal = path65__default.join(await realpath(workspaceRoot), ".hexagen");
19885
20000
  }
19886
20001
  try {
19887
20002
  target = await realpath(target);
@@ -19891,7 +20006,7 @@ async function grantRevokeCommand(options) {
19891
20006
  if (sidecarReal !== void 0 && !isStrictlyInside(sidecarReal, target)) {
19892
20007
  return fail2(
19893
20008
  2,
19894
- `the grant file must be under ${sidecarReal}${path64__default.sep}; it resolves to "${target}"`
20009
+ `the grant file must be under ${sidecarReal}${path65__default.sep}; it resolves to "${target}"`
19895
20010
  );
19896
20011
  }
19897
20012
  const lockPath = `${target}.lock`;
@@ -20009,10 +20124,10 @@ async function revokeLocked(options, now, workspaceRoot, target, sidecarReal) {
20009
20124
  async () => {
20010
20125
  await options.beforeRename?.();
20011
20126
  if (sidecarReal === void 0) return;
20012
- const dir = await realpath(path64__default.dirname(target));
20127
+ const dir = await realpath(path65__default.dirname(target));
20013
20128
  if (dir !== sidecarReal && !isStrictlyInside(sidecarReal, dir)) {
20014
20129
  throw new RefusedError(
20015
- `the grant's directory now resolves outside ${sidecarReal}${path64__default.sep}`
20130
+ `the grant's directory now resolves outside ${sidecarReal}${path65__default.sep}`
20016
20131
  );
20017
20132
  }
20018
20133
  }
@@ -20160,7 +20275,7 @@ async function issueGrantCommand(options) {
20160
20275
  );
20161
20276
  if (!target) {
20162
20277
  failBrownfield(
20163
- `--out must name a file under ${path64__default.join(workspaceRoot, ".hexagen")}${path64__default.sep}; got "${options.out}"`
20278
+ `--out must name a file under ${path65__default.join(workspaceRoot, ".hexagen")}${path65__default.sep}; got "${options.out}"`
20164
20279
  );
20165
20280
  return;
20166
20281
  }
@@ -20339,8 +20454,8 @@ ${writes.map((w) => ` - ${w}`).join("\n")}`
20339
20454
  return;
20340
20455
  }
20341
20456
  if (options.out) {
20342
- const outPath = path64__default.resolve(workspaceRoot, options.out);
20343
- await mkdir(path64__default.dirname(outPath), { recursive: true });
20457
+ const outPath = path65__default.resolve(workspaceRoot, options.out);
20458
+ await mkdir(path65__default.dirname(outPath), { recursive: true });
20344
20459
  await writeFile(outPath, `${json}
20345
20460
  `, "utf-8");
20346
20461
  console.error(
@@ -20471,9 +20586,12 @@ function buildSyncCheckJson(summary, fatalMessage) {
20471
20586
  pending: null,
20472
20587
  errors: null,
20473
20588
  manifestMissing: null,
20474
- reason: fatalMessage ?? "sync produced no summary"
20589
+ reason: fatalMessage ?? "sync produced no summary",
20590
+ timingsMs: null,
20591
+ files: null
20475
20592
  };
20476
20593
  }
20594
+ const timingsMs = summary.phaseTimingsMs ? { ...summary.phaseTimingsMs, total: summary.durationMs } : null;
20477
20595
  const pending = {
20478
20596
  created: summary.created,
20479
20597
  updated: summary.updated,
@@ -20489,7 +20607,9 @@ function buildSyncCheckJson(summary, fatalMessage) {
20489
20607
  pending,
20490
20608
  errors: summary.errors,
20491
20609
  manifestMissing: true,
20492
- reason: "manifest not found"
20610
+ reason: "manifest not found",
20611
+ timingsMs,
20612
+ files: summary.files ?? []
20493
20613
  };
20494
20614
  }
20495
20615
  if (summary.errors > 0) {
@@ -20501,7 +20621,9 @@ function buildSyncCheckJson(summary, fatalMessage) {
20501
20621
  pending,
20502
20622
  errors: summary.errors,
20503
20623
  manifestMissing: false,
20504
- reason: `${summary.errors} generator failure(s)`
20624
+ reason: `${summary.errors} generator failure(s)`,
20625
+ timingsMs,
20626
+ files: summary.files ?? []
20505
20627
  };
20506
20628
  }
20507
20629
  if (summary.totalOps > 0) {
@@ -20513,7 +20635,9 @@ function buildSyncCheckJson(summary, fatalMessage) {
20513
20635
  pending,
20514
20636
  errors: summary.errors,
20515
20637
  manifestMissing: false,
20516
- reason: null
20638
+ reason: null,
20639
+ timingsMs,
20640
+ files: summary.files ?? []
20517
20641
  };
20518
20642
  }
20519
20643
  return {
@@ -20524,7 +20648,9 @@ function buildSyncCheckJson(summary, fatalMessage) {
20524
20648
  pending,
20525
20649
  errors: summary.errors,
20526
20650
  manifestMissing: false,
20527
- reason: null
20651
+ reason: null,
20652
+ timingsMs,
20653
+ files: summary.files ?? []
20528
20654
  };
20529
20655
  }
20530
20656
 
@@ -20561,6 +20687,9 @@ function buildProgram() {
20561
20687
  "--force-root",
20562
20688
  "Overwrite protected root files (turbo.json, .gitignore)"
20563
20689
  ).option("--allow-dirty", "Skip git clean check (for development)").option(
20690
+ "--no-preflight",
20691
+ "Skip the whole-repo turbo build that real runs perform first. The build is left to the gate (yarn build in CI); use only when something else builds. No effect with --dry-run/--check, which never build."
20692
+ ).option(
20564
20693
  "--strict",
20565
20694
  "Abort the sync when the architecture linter reports a violation (or cannot verify)"
20566
20695
  ).option(
@@ -20591,7 +20720,9 @@ function buildProgram() {
20591
20720
  let summary;
20592
20721
  let fatalMessage;
20593
20722
  try {
20594
- const engine = new SyncEngine(flags);
20723
+ const engine = new SyncEngine(flags, {
20724
+ noPreflight: options.preflight === false
20725
+ });
20595
20726
  summary = await engine.run();
20596
20727
  if (summary.errors > 0) {
20597
20728
  console.error(