@hexagen-monaco/sync 0.14.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/README.md +63 -0
- package/dist/__tests__/drift-files.test.d.ts +2 -0
- package/dist/__tests__/drift-files.test.d.ts.map +1 -0
- package/dist/application/use-cases/stamp-generator-identity.use-case.d.ts +12 -0
- package/dist/application/use-cases/stamp-generator-identity.use-case.d.ts.map +1 -0
- package/dist/cli.js +2683 -1136
- package/dist/cli.js.map +1 -1
- package/dist/commands/arch/validate-outcome.d.ts +30 -0
- package/dist/commands/arch/validate-outcome.d.ts.map +1 -0
- package/dist/commands/arch/validate.d.ts +3 -1
- package/dist/commands/arch/validate.d.ts.map +1 -1
- package/dist/commands/bootstrap/index.d.ts.map +1 -1
- package/dist/commands/manifest/migrate.d.ts +8 -0
- package/dist/commands/manifest/migrate.d.ts.map +1 -1
- package/dist/commands/remove/index.d.ts +41 -0
- package/dist/commands/remove/index.d.ts.map +1 -0
- package/dist/commands/shared/confirm.d.ts.map +1 -1
- package/dist/commands/sync/check-json-files.test.d.ts +2 -0
- package/dist/commands/sync/check-json-files.test.d.ts.map +1 -0
- package/dist/commands/sync/check-json.d.ts +67 -0
- package/dist/commands/sync/check-json.d.ts.map +1 -0
- package/dist/generators/architecture-files.d.ts.map +1 -1
- package/dist/generators/port-analyzer.d.ts +2 -0
- package/dist/generators/port-analyzer.d.ts.map +1 -1
- package/dist/index.js +683 -554
- package/dist/index.js.map +1 -1
- package/dist/infrastructure/config/index.d.ts +3 -0
- package/dist/infrastructure/config/index.d.ts.map +1 -0
- package/dist/infrastructure/index.d.ts +1 -0
- package/dist/infrastructure/index.d.ts.map +1 -1
- package/dist/preflight.d.ts +4 -1
- package/dist/preflight.d.ts.map +1 -1
- package/dist/results.d.ts +40 -0
- package/dist/results.d.ts.map +1 -1
- package/dist/sync-engine.d.ts +1 -0
- package/dist/sync-engine.d.ts.map +1 -1
- package/dist/types/manifest/generator.d.ts +2 -0
- package/dist/types/manifest/generator.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import path8 from 'path';
|
|
2
2
|
import fs4, { realpathSync, lstatSync, createWriteStream } from 'fs';
|
|
3
3
|
import fs5 from 'fs/promises';
|
|
4
4
|
import { promisify } from 'util';
|
|
5
5
|
import { exec } from 'child_process';
|
|
6
6
|
import yaml3 from 'js-yaml';
|
|
7
|
-
import crypto from 'crypto';
|
|
7
|
+
import crypto, { createHash } from 'crypto';
|
|
8
8
|
import { z } from 'zod';
|
|
9
9
|
import { fileURLToPath } from 'url';
|
|
10
10
|
import { Project, MethodSignature } from 'ts-morph';
|
|
@@ -27,8 +27,8 @@ var MigrationReport = class {
|
|
|
27
27
|
);
|
|
28
28
|
return;
|
|
29
29
|
}
|
|
30
|
-
const reportPath = config.report ?
|
|
31
|
-
await fs5.mkdir(
|
|
30
|
+
const reportPath = config.report ? path8.resolve(config.workspaceRoot, config.report) : path8.join(config.workspaceRoot, "SYNC-MIGRATION-REPORT.md");
|
|
31
|
+
await fs5.mkdir(path8.dirname(reportPath), { recursive: true });
|
|
32
32
|
let preContent = null;
|
|
33
33
|
try {
|
|
34
34
|
preContent = await fs5.readFile(reportPath, "utf8");
|
|
@@ -81,7 +81,7 @@ var SyncJournal = class {
|
|
|
81
81
|
*/
|
|
82
82
|
describeEntries(workspaceRoot) {
|
|
83
83
|
return this.entries.map(
|
|
84
|
-
(e) => `${e.kind} ${
|
|
84
|
+
(e) => `${e.kind} ${path8.relative(workspaceRoot, e.path)}`
|
|
85
85
|
);
|
|
86
86
|
}
|
|
87
87
|
/**
|
|
@@ -107,7 +107,7 @@ var SyncJournal = class {
|
|
|
107
107
|
failures: []
|
|
108
108
|
};
|
|
109
109
|
for (const entry of [...this.entries].reverse()) {
|
|
110
|
-
const relative =
|
|
110
|
+
const relative = path8.relative(workspaceRoot, entry.path);
|
|
111
111
|
try {
|
|
112
112
|
if (entry.preContent === null) {
|
|
113
113
|
try {
|
|
@@ -119,7 +119,7 @@ var SyncJournal = class {
|
|
|
119
119
|
}
|
|
120
120
|
logger.info(`rolled back (removed) ${relative}`);
|
|
121
121
|
} else {
|
|
122
|
-
await fs5.mkdir(
|
|
122
|
+
await fs5.mkdir(path8.dirname(entry.path), { recursive: true });
|
|
123
123
|
await fs5.writeFile(entry.path, entry.preContent, {
|
|
124
124
|
encoding: "utf8"
|
|
125
125
|
});
|
|
@@ -141,7 +141,7 @@ var LOCK_FILE = ".architecture/.sync.lock";
|
|
|
141
141
|
var LockFile = class {
|
|
142
142
|
constructor(workspaceRoot, fsImpl = fs5, logger = console) {
|
|
143
143
|
this.workspaceRoot = workspaceRoot;
|
|
144
|
-
this.lockPath =
|
|
144
|
+
this.lockPath = path8.join(workspaceRoot, LOCK_FILE);
|
|
145
145
|
this.fsImpl = fsImpl;
|
|
146
146
|
this.logger = logger;
|
|
147
147
|
}
|
|
@@ -229,22 +229,22 @@ function binEntryOf(pkgJsonPath) {
|
|
|
229
229
|
}
|
|
230
230
|
function resolveFromPackage(dir) {
|
|
231
231
|
for (const pkgName of PACKAGE_NAMES) {
|
|
232
|
-
const pkgDir =
|
|
233
|
-
const entry = binEntryOf(
|
|
232
|
+
const pkgDir = path8.join(dir, "node_modules", ...pkgName.split("/"));
|
|
233
|
+
const entry = binEntryOf(path8.join(pkgDir, "package.json"));
|
|
234
234
|
if (entry === null) continue;
|
|
235
|
-
const binPath =
|
|
235
|
+
const binPath = path8.join(pkgDir, entry);
|
|
236
236
|
if (fs4.existsSync(binPath)) return binPath;
|
|
237
237
|
}
|
|
238
238
|
return null;
|
|
239
239
|
}
|
|
240
240
|
function resolveArchLinterBin(startDir) {
|
|
241
|
-
let dir =
|
|
241
|
+
let dir = path8.resolve(startDir);
|
|
242
242
|
for (; ; ) {
|
|
243
|
-
const candidate =
|
|
243
|
+
const candidate = path8.join(dir, "node_modules", ".bin", BIN_NAME);
|
|
244
244
|
if (fs4.existsSync(candidate)) return candidate;
|
|
245
245
|
const fromPackage = resolveFromPackage(dir);
|
|
246
246
|
if (fromPackage !== null) return fromPackage;
|
|
247
|
-
const parent =
|
|
247
|
+
const parent = path8.dirname(dir);
|
|
248
248
|
if (parent === dir) return null;
|
|
249
249
|
dir = parent;
|
|
250
250
|
}
|
|
@@ -308,8 +308,6 @@ ${message}`);
|
|
|
308
308
|
}
|
|
309
309
|
}
|
|
310
310
|
}
|
|
311
|
-
|
|
312
|
-
// src/results.ts
|
|
313
311
|
function createEmptyResult() {
|
|
314
312
|
return {
|
|
315
313
|
created: [],
|
|
@@ -333,6 +331,61 @@ function recordWriteStatus(result, filePath, status) {
|
|
|
333
331
|
result.skipped.push(filePath);
|
|
334
332
|
}
|
|
335
333
|
}
|
|
334
|
+
function driftReason(action) {
|
|
335
|
+
if (action === "create") {
|
|
336
|
+
return "missing on disk; sync would create it";
|
|
337
|
+
}
|
|
338
|
+
if (action === "update") {
|
|
339
|
+
return "content differs from generated output";
|
|
340
|
+
}
|
|
341
|
+
return "no longer generated; sync would remove it";
|
|
342
|
+
}
|
|
343
|
+
function normalizeRelativePath(filePath, workspaceRoot) {
|
|
344
|
+
const relative = path8.isAbsolute(filePath) ? path8.relative(workspaceRoot, filePath) : filePath;
|
|
345
|
+
return relative.replaceAll("\\", "/");
|
|
346
|
+
}
|
|
347
|
+
function compareStrings(a, b) {
|
|
348
|
+
if (a < b) return -1;
|
|
349
|
+
if (a > b) return 1;
|
|
350
|
+
return 0;
|
|
351
|
+
}
|
|
352
|
+
function compareDriftFiles(a, b) {
|
|
353
|
+
const byPath = compareStrings(a.path, b.path);
|
|
354
|
+
if (byPath !== 0) return byPath;
|
|
355
|
+
const byAction = compareStrings(a.action, b.action);
|
|
356
|
+
if (byAction !== 0) return byAction;
|
|
357
|
+
return compareStrings(a.generator, b.generator);
|
|
358
|
+
}
|
|
359
|
+
function collectDriftFilesForRow(generator, result, workspaceRoot, seen, files) {
|
|
360
|
+
const buckets = [
|
|
361
|
+
["create", result.created],
|
|
362
|
+
["update", result.updated],
|
|
363
|
+
["delete", result.deleted]
|
|
364
|
+
];
|
|
365
|
+
for (const [action, paths] of buckets) {
|
|
366
|
+
for (const p of paths) {
|
|
367
|
+
const relPath = normalizeRelativePath(p, workspaceRoot);
|
|
368
|
+
const key = `${relPath}\0${action}\0${generator}`;
|
|
369
|
+
if (seen.has(key)) continue;
|
|
370
|
+
seen.add(key);
|
|
371
|
+
files.push({
|
|
372
|
+
path: relPath,
|
|
373
|
+
action,
|
|
374
|
+
generator,
|
|
375
|
+
reason: driftReason(action)
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
function buildDriftFiles(rows, workspaceRoot) {
|
|
381
|
+
const seen = /* @__PURE__ */ new Set();
|
|
382
|
+
const files = [];
|
|
383
|
+
for (const [generator, result] of rows) {
|
|
384
|
+
collectDriftFilesForRow(generator, result, workspaceRoot, seen, files);
|
|
385
|
+
}
|
|
386
|
+
files.sort(compareDriftFiles);
|
|
387
|
+
return files;
|
|
388
|
+
}
|
|
336
389
|
|
|
337
390
|
// src/scope-filter.ts
|
|
338
391
|
var GLOB_META = /[*?]/;
|
|
@@ -400,7 +453,7 @@ function isGeneratedFile(content) {
|
|
|
400
453
|
return content.includes(GENERATED_MARKER);
|
|
401
454
|
}
|
|
402
455
|
function isProtectedRoot(filePath, config) {
|
|
403
|
-
const relative =
|
|
456
|
+
const relative = path8.relative(config.workspaceRoot, filePath).replace(/\\/g, "/");
|
|
404
457
|
const isRootLevel = !relative.startsWith("packages/") && !relative.startsWith("tools/") && !relative.startsWith("apps/");
|
|
405
458
|
return isRootLevel && Array.from(protectedFiles).some(
|
|
406
459
|
(f) => relative.endsWith(f) || relative.includes(f)
|
|
@@ -408,12 +461,12 @@ function isProtectedRoot(filePath, config) {
|
|
|
408
461
|
}
|
|
409
462
|
function isInScope(filePath, config) {
|
|
410
463
|
if (!config.only || config.only.length === 0) return true;
|
|
411
|
-
const relativePath =
|
|
464
|
+
const relativePath = path8.relative(config.workspaceRoot, filePath);
|
|
412
465
|
return matchesScope(relativePath, config.only);
|
|
413
466
|
}
|
|
414
467
|
async function safeWriteFileAtomic(filePath, content, config, report, skipGeneratedCheck = false) {
|
|
415
468
|
const { dryRun, forceRoot, logger, workspaceRoot } = config;
|
|
416
|
-
const relativePath =
|
|
469
|
+
const relativePath = path8.relative(workspaceRoot, filePath);
|
|
417
470
|
if (!isInScope(filePath, config)) {
|
|
418
471
|
logger.debug(`skipped (outside --only) ${relativePath}`);
|
|
419
472
|
return "skipped";
|
|
@@ -453,9 +506,9 @@ async function safeWriteFileAtomic(filePath, content, config, report, skipGenera
|
|
|
453
506
|
return exists ? "updated" : "created";
|
|
454
507
|
}
|
|
455
508
|
config.journal?.recordWrite(filePath, exists ? currentContent : null);
|
|
456
|
-
await fs5.mkdir(
|
|
457
|
-
const tmpName = `.${
|
|
458
|
-
const tmpPath =
|
|
509
|
+
await fs5.mkdir(path8.dirname(filePath), { recursive: true });
|
|
510
|
+
const tmpName = `.${path8.basename(filePath)}.${crypto.randomUUID()}.tmp`;
|
|
511
|
+
const tmpPath = path8.join(path8.dirname(filePath), tmpName);
|
|
459
512
|
await fs5.writeFile(tmpPath, content, { encoding: "utf8" });
|
|
460
513
|
try {
|
|
461
514
|
await fs5.rename(tmpPath, filePath);
|
|
@@ -553,7 +606,7 @@ async function directoryExists(dirPath) {
|
|
|
553
606
|
async function ensureDirectoryCounted(dirPath, config, result) {
|
|
554
607
|
const existed = await directoryExists(dirPath);
|
|
555
608
|
if (existed) return;
|
|
556
|
-
const relativePath =
|
|
609
|
+
const relativePath = path8.relative(config.workspaceRoot, dirPath);
|
|
557
610
|
if (config.dryRun) {
|
|
558
611
|
config.logger.info(`[DRY-RUN] would create directory ${relativePath}`);
|
|
559
612
|
} else {
|
|
@@ -564,7 +617,7 @@ async function ensureDirectoryCounted(dirPath, config, result) {
|
|
|
564
617
|
result.totalOps += 1;
|
|
565
618
|
}
|
|
566
619
|
async function ensureGitkeepCounted(dirPath, config, result) {
|
|
567
|
-
const keepPath =
|
|
620
|
+
const keepPath = path8.join(dirPath, ".gitkeep");
|
|
568
621
|
let entries = null;
|
|
569
622
|
if (await directoryExists(dirPath)) {
|
|
570
623
|
entries = await fs5.readdir(dirPath);
|
|
@@ -604,7 +657,7 @@ async function loadYamlSafe(filePath) {
|
|
|
604
657
|
async function ensureLayerFolders(moduleDir, layers, config, contextLayers) {
|
|
605
658
|
const result = createEmptyResult();
|
|
606
659
|
const { logger } = config;
|
|
607
|
-
const layerRulesPath =
|
|
660
|
+
const layerRulesPath = path8.join(
|
|
608
661
|
config.workspaceRoot,
|
|
609
662
|
".architecture",
|
|
610
663
|
"invariants",
|
|
@@ -618,8 +671,8 @@ async function ensureLayerFolders(moduleDir, layers, config, contextLayers) {
|
|
|
618
671
|
if (!layerDeclaresContent(layerName, contextLayers)) {
|
|
619
672
|
continue;
|
|
620
673
|
}
|
|
621
|
-
const layerPath =
|
|
622
|
-
if (!isInScope(layerPath, config) && !isInScope(
|
|
674
|
+
const layerPath = path8.join(moduleDir, resolveLayerDir(layers, layerName));
|
|
675
|
+
if (!isInScope(layerPath, config) && !isInScope(path8.join(layerPath, "index.ts"), config)) {
|
|
623
676
|
continue;
|
|
624
677
|
}
|
|
625
678
|
await ensureDirectoryCounted(layerPath, config, result);
|
|
@@ -635,8 +688,8 @@ async function ensureLayerFolders(moduleDir, layers, config, contextLayers) {
|
|
|
635
688
|
);
|
|
636
689
|
continue;
|
|
637
690
|
}
|
|
638
|
-
const subPath =
|
|
639
|
-
if (!isInScope(subPath, config) && !isInScope(
|
|
691
|
+
const subPath = path8.join(layerPath, normalizedSub);
|
|
692
|
+
if (!isInScope(subPath, config) && !isInScope(path8.join(subPath, "index.ts"), config)) {
|
|
640
693
|
continue;
|
|
641
694
|
}
|
|
642
695
|
await ensureDirectoryCounted(subPath, config, result);
|
|
@@ -672,18 +725,18 @@ function contentHash2(content) {
|
|
|
672
725
|
function detectCircularExports(exportGraph) {
|
|
673
726
|
const visited = /* @__PURE__ */ new Set();
|
|
674
727
|
const recursionStack = /* @__PURE__ */ new Set();
|
|
675
|
-
const
|
|
728
|
+
const path26 = [];
|
|
676
729
|
function dfs(node) {
|
|
677
730
|
if (recursionStack.has(node)) {
|
|
678
|
-
const cycleStart =
|
|
679
|
-
return [...
|
|
731
|
+
const cycleStart = path26.indexOf(node);
|
|
732
|
+
return [...path26.slice(cycleStart), node];
|
|
680
733
|
}
|
|
681
734
|
if (visited.has(node)) {
|
|
682
735
|
return null;
|
|
683
736
|
}
|
|
684
737
|
visited.add(node);
|
|
685
738
|
recursionStack.add(node);
|
|
686
|
-
|
|
739
|
+
path26.push(node);
|
|
687
740
|
const exports$1 = exportGraph.get(node) ?? [];
|
|
688
741
|
for (const exportPath of exports$1) {
|
|
689
742
|
const cycle = dfs(exportPath);
|
|
@@ -691,7 +744,7 @@ function detectCircularExports(exportGraph) {
|
|
|
691
744
|
return cycle;
|
|
692
745
|
}
|
|
693
746
|
}
|
|
694
|
-
|
|
747
|
+
path26.pop();
|
|
695
748
|
recursionStack.delete(node);
|
|
696
749
|
return null;
|
|
697
750
|
}
|
|
@@ -708,8 +761,8 @@ function generateBarrelContent(entries) {
|
|
|
708
761
|
return null;
|
|
709
762
|
}
|
|
710
763
|
const exportLines = entries.sort((a, b) => a.name.localeCompare(b.name)).map((entry) => {
|
|
711
|
-
const
|
|
712
|
-
return `export * from "${
|
|
764
|
+
const path26 = entry.isDirectory ? `./${entry.name}/index.js` : `./${entry.name}.js`;
|
|
765
|
+
return `export * from "${path26}";`;
|
|
713
766
|
});
|
|
714
767
|
return `${GENERATED_MARKER2}
|
|
715
768
|
|
|
@@ -731,14 +784,14 @@ var CircularExportError = class extends Error {
|
|
|
731
784
|
};
|
|
732
785
|
async function generateRecursiveBarrels(moduleDir, config, report) {
|
|
733
786
|
const result = createEmptyResult();
|
|
734
|
-
const srcDir =
|
|
787
|
+
const srcDir = path8.join(moduleDir, "src");
|
|
735
788
|
const layers = ["domain", "application", "infrastructure"];
|
|
736
789
|
const pendingWrites = [];
|
|
737
790
|
const preserved = [];
|
|
738
791
|
const exportGraph = /* @__PURE__ */ new Map();
|
|
739
792
|
const layersWithContent = [];
|
|
740
793
|
for (const layer of layers) {
|
|
741
|
-
const layerDir =
|
|
794
|
+
const layerDir = path8.join(srcDir, layer);
|
|
742
795
|
try {
|
|
743
796
|
await fs5.access(layerDir);
|
|
744
797
|
} catch {
|
|
@@ -754,7 +807,7 @@ async function generateRecursiveBarrels(moduleDir, config, report) {
|
|
|
754
807
|
if (layerExports.length > 0) layersWithContent.push(layer);
|
|
755
808
|
}
|
|
756
809
|
if (config.mode === "external" && layersWithContent.length > 0) {
|
|
757
|
-
const rootBarrelPath =
|
|
810
|
+
const rootBarrelPath = path8.join(srcDir, "index.ts");
|
|
758
811
|
if (await shouldGenerateBarrel(rootBarrelPath, preserved, config.logger)) {
|
|
759
812
|
const content = generateBarrelContent(
|
|
760
813
|
layersWithContent.map((name) => ({ name, isDirectory: true }))
|
|
@@ -768,7 +821,7 @@ async function generateRecursiveBarrels(moduleDir, config, report) {
|
|
|
768
821
|
});
|
|
769
822
|
exportGraph.set(
|
|
770
823
|
rootBarrelPath,
|
|
771
|
-
layersWithContent.map((name) =>
|
|
824
|
+
layersWithContent.map((name) => path8.join(srcDir, name, "index.ts"))
|
|
772
825
|
);
|
|
773
826
|
}
|
|
774
827
|
}
|
|
@@ -834,7 +887,7 @@ async function walkDirectory(dirPath, pendingWrites, preserved, exportGraph, con
|
|
|
834
887
|
}
|
|
835
888
|
}
|
|
836
889
|
for (const dir of directories) {
|
|
837
|
-
const subDirPath =
|
|
890
|
+
const subDirPath = path8.join(dirPath, dir);
|
|
838
891
|
const subExports = await walkDirectory(
|
|
839
892
|
subDirPath,
|
|
840
893
|
pendingWrites,
|
|
@@ -842,7 +895,7 @@ async function walkDirectory(dirPath, pendingWrites, preserved, exportGraph, con
|
|
|
842
895
|
exportGraph,
|
|
843
896
|
config
|
|
844
897
|
);
|
|
845
|
-
const subBarrelPath =
|
|
898
|
+
const subBarrelPath = path8.join(subDirPath, "index.ts");
|
|
846
899
|
const isQueuedForDeletion = pendingWrites.some(
|
|
847
900
|
(p) => p.filePath === subBarrelPath && p.content === ""
|
|
848
901
|
);
|
|
@@ -854,7 +907,7 @@ async function walkDirectory(dirPath, pendingWrites, preserved, exportGraph, con
|
|
|
854
907
|
exportEntries.push({ name: file, isDirectory: false });
|
|
855
908
|
}
|
|
856
909
|
if (exportEntries.length === 0) {
|
|
857
|
-
const barrelPath2 =
|
|
910
|
+
const barrelPath2 = path8.join(dirPath, "index.ts");
|
|
858
911
|
const existingBarrel = await readFileIfExists(barrelPath2);
|
|
859
912
|
if (existingBarrel) {
|
|
860
913
|
const isGenerated = isGeneratedFile2(existingBarrel);
|
|
@@ -871,7 +924,7 @@ async function walkDirectory(dirPath, pendingWrites, preserved, exportGraph, con
|
|
|
871
924
|
}
|
|
872
925
|
return [];
|
|
873
926
|
}
|
|
874
|
-
const barrelPath =
|
|
927
|
+
const barrelPath = path8.join(dirPath, "index.ts");
|
|
875
928
|
const shouldCreateBarrel = await shouldGenerateBarrel(
|
|
876
929
|
barrelPath,
|
|
877
930
|
preserved,
|
|
@@ -891,14 +944,14 @@ async function walkDirectory(dirPath, pendingWrites, preserved, exportGraph, con
|
|
|
891
944
|
content,
|
|
892
945
|
isNew: !existingContent
|
|
893
946
|
});
|
|
894
|
-
const exportPaths = exportEntries.filter((e) => e.isDirectory).map((e) =>
|
|
947
|
+
const exportPaths = exportEntries.filter((e) => e.isDirectory).map((e) => path8.join(dirPath, e.name, "index.ts"));
|
|
895
948
|
exportGraph.set(barrelPath, exportPaths);
|
|
896
949
|
}
|
|
897
950
|
return exportEntries;
|
|
898
951
|
}
|
|
899
952
|
async function hasBarrel(dirPath) {
|
|
900
953
|
try {
|
|
901
|
-
await fs5.access(
|
|
954
|
+
await fs5.access(path8.join(dirPath, "index.ts"));
|
|
902
955
|
return true;
|
|
903
956
|
} catch {
|
|
904
957
|
return false;
|
|
@@ -963,7 +1016,7 @@ async function generatePackageJson(modulePath, moduleName, config, report) {
|
|
|
963
1016
|
const moduleOverrides = context?.packageJson ?? {};
|
|
964
1017
|
const scope = config.manifest ? resolveScope(config.manifest) : "generated-project";
|
|
965
1018
|
const dependsOnDeps = context ? expandDependsOn(context, scope) : {};
|
|
966
|
-
const pkgPath =
|
|
1019
|
+
const pkgPath = path8.join(modulePath, "package.json");
|
|
967
1020
|
const dependencies = {
|
|
968
1021
|
...dependsOnDeps,
|
|
969
1022
|
...defaults.dependencies ?? {},
|
|
@@ -1057,7 +1110,7 @@ async function generatePackageJson(modulePath, moduleName, config, report) {
|
|
|
1057
1110
|
);
|
|
1058
1111
|
recordWriteStatus(result, pkgPath, status);
|
|
1059
1112
|
if (config.mode === "external") {
|
|
1060
|
-
const vitestConfigPath =
|
|
1113
|
+
const vitestConfigPath = path8.join(modulePath, "vitest.config.ts");
|
|
1061
1114
|
if (isInScope(vitestConfigPath, config)) {
|
|
1062
1115
|
let vitestConfigExists = false;
|
|
1063
1116
|
try {
|
|
@@ -1158,7 +1211,7 @@ function buildTemplate(base, context, scope) {
|
|
|
1158
1211
|
}
|
|
1159
1212
|
async function generateTsconfig(moduleDir, moduleName, config, report) {
|
|
1160
1213
|
const result = createEmptyResult();
|
|
1161
|
-
const filePath =
|
|
1214
|
+
const filePath = path8.join(moduleDir, "tsconfig.json");
|
|
1162
1215
|
try {
|
|
1163
1216
|
const base = resolveWorkspaceTemplate(config.manifest);
|
|
1164
1217
|
const context = config.manifest.bounded_contexts?.find(
|
|
@@ -1190,7 +1243,7 @@ export {};
|
|
|
1190
1243
|
`;
|
|
1191
1244
|
async function ensurePackageSrcIndex(moduleDir, config, report) {
|
|
1192
1245
|
const result = createEmptyResult();
|
|
1193
|
-
const filePath =
|
|
1246
|
+
const filePath = path8.join(moduleDir, "src", "index.ts");
|
|
1194
1247
|
if (!isInScope(filePath, config)) {
|
|
1195
1248
|
result.skipped.push(filePath);
|
|
1196
1249
|
return result;
|
|
@@ -1203,7 +1256,7 @@ async function ensurePackageSrcIndex(moduleDir, config, report) {
|
|
|
1203
1256
|
if (err3.code !== "ENOENT") throw err3;
|
|
1204
1257
|
}
|
|
1205
1258
|
if (!config.dryRun) {
|
|
1206
|
-
await fs5.mkdir(
|
|
1259
|
+
await fs5.mkdir(path8.dirname(filePath), { recursive: true });
|
|
1207
1260
|
}
|
|
1208
1261
|
const status = await safeWriteFileAtomic(
|
|
1209
1262
|
filePath,
|
|
@@ -1219,8 +1272,8 @@ async function reapLegacyFolders(moduleDir, config, report) {
|
|
|
1219
1272
|
const { dryRun, logger } = config;
|
|
1220
1273
|
const legacyLayers = ["domain", "application", "infrastructure"];
|
|
1221
1274
|
for (const layer of legacyLayers) {
|
|
1222
|
-
const layerPath =
|
|
1223
|
-
const relativePath =
|
|
1275
|
+
const layerPath = path8.join(moduleDir, layer);
|
|
1276
|
+
const relativePath = path8.relative(config.workspaceRoot, layerPath);
|
|
1224
1277
|
try {
|
|
1225
1278
|
const entries = await fs5.readdir(layerPath);
|
|
1226
1279
|
if (entries.length === 0) {
|
|
@@ -1694,7 +1747,7 @@ function assertValidToolchainVersion(version, source) {
|
|
|
1694
1747
|
function resolveToolchainVersion() {
|
|
1695
1748
|
{
|
|
1696
1749
|
return assertValidToolchainVersion(
|
|
1697
|
-
"0.
|
|
1750
|
+
"0.16.0",
|
|
1698
1751
|
"build-injected __HEXAGEN_TOOLCHAIN_VERSION__"
|
|
1699
1752
|
);
|
|
1700
1753
|
}
|
|
@@ -1879,7 +1932,7 @@ async function generateRootFiles(config, report) {
|
|
|
1879
1932
|
);
|
|
1880
1933
|
}
|
|
1881
1934
|
await writeRootFile(
|
|
1882
|
-
|
|
1935
|
+
path8.join(config.workspaceRoot, "package.json"),
|
|
1883
1936
|
packageJsonContent,
|
|
1884
1937
|
config,
|
|
1885
1938
|
report,
|
|
@@ -1900,7 +1953,7 @@ async function generateRootFiles(config, report) {
|
|
|
1900
1953
|
tsconfigContent = reindentJson(tsconfigContent, prettierOptions.tabWidth);
|
|
1901
1954
|
}
|
|
1902
1955
|
await writeRootFile(
|
|
1903
|
-
|
|
1956
|
+
path8.join(config.workspaceRoot, "tsconfig.base.json"),
|
|
1904
1957
|
tsconfigContent,
|
|
1905
1958
|
config,
|
|
1906
1959
|
report,
|
|
@@ -1928,7 +1981,7 @@ async function generateRootFiles(config, report) {
|
|
|
1928
1981
|
);
|
|
1929
1982
|
}
|
|
1930
1983
|
await writeRootFile(
|
|
1931
|
-
|
|
1984
|
+
path8.join(config.workspaceRoot, "turbo.json"),
|
|
1932
1985
|
turboContent,
|
|
1933
1986
|
config,
|
|
1934
1987
|
report,
|
|
@@ -1939,7 +1992,7 @@ async function generateRootFiles(config, report) {
|
|
|
1939
1992
|
BUILTIN_GITIGNORE_TEMPLATE
|
|
1940
1993
|
);
|
|
1941
1994
|
await writeRootFile(
|
|
1942
|
-
|
|
1995
|
+
path8.join(config.workspaceRoot, ".gitignore"),
|
|
1943
1996
|
interpolateAndWarn(gitignoreTemplate, vars, config, ".gitignore"),
|
|
1944
1997
|
config,
|
|
1945
1998
|
report,
|
|
@@ -1950,7 +2003,7 @@ async function generateRootFiles(config, report) {
|
|
|
1950
2003
|
BUILTIN_YARNRC_TEMPLATE
|
|
1951
2004
|
);
|
|
1952
2005
|
await writeRootFile(
|
|
1953
|
-
|
|
2006
|
+
path8.join(config.workspaceRoot, ".yarnrc.yml"),
|
|
1954
2007
|
interpolateAndWarn(yarnrcTemplate, vars, config, ".yarnrc.yml"),
|
|
1955
2008
|
config,
|
|
1956
2009
|
report,
|
|
@@ -1961,14 +2014,14 @@ async function generateRootFiles(config, report) {
|
|
|
1961
2014
|
BUILTIN_SETUP_MD_TEMPLATE
|
|
1962
2015
|
);
|
|
1963
2016
|
await writeRootFile(
|
|
1964
|
-
|
|
2017
|
+
path8.join(config.workspaceRoot, "SETUP.md"),
|
|
1965
2018
|
interpolateAndWarn(setupTemplate, vars, config, "SETUP.md"),
|
|
1966
2019
|
config,
|
|
1967
2020
|
report,
|
|
1968
2021
|
result
|
|
1969
2022
|
);
|
|
1970
2023
|
await writeRootFile(
|
|
1971
|
-
|
|
2024
|
+
path8.join(config.workspaceRoot, ".prettierrc.json"),
|
|
1972
2025
|
prettierrcContent,
|
|
1973
2026
|
config,
|
|
1974
2027
|
report,
|
|
@@ -1984,27 +2037,413 @@ async function generateRootFiles(config, report) {
|
|
|
1984
2037
|
return result;
|
|
1985
2038
|
}
|
|
1986
2039
|
}
|
|
2040
|
+
function caseInsensitiveEnum(schema, dir = "lower") {
|
|
2041
|
+
return z.preprocess((value) => typeof value === "string" ? dir === "lower" ? value.trim().toLowerCase() : value.trim().toUpperCase() : value, schema);
|
|
2042
|
+
}
|
|
2043
|
+
var BoundedContextTypeSchema = boundedContextTypeSchema;
|
|
2044
|
+
var PLANE_NAMES = [
|
|
2045
|
+
"projection",
|
|
2046
|
+
"probabilistic",
|
|
2047
|
+
"infrastructure",
|
|
2048
|
+
"shared-kernel",
|
|
2049
|
+
"core",
|
|
2050
|
+
"supporting"
|
|
2051
|
+
];
|
|
2052
|
+
var PlaneTypeSchema = caseInsensitiveEnum(z.enum(PLANE_NAMES));
|
|
2053
|
+
var StatusTypeSchema = caseInsensitiveEnum(z.enum(["active", "frozen", "deprecated", "experimental"]));
|
|
2054
|
+
var RelationshipPatternSchema = caseInsensitiveEnum(z.enum(["U/D", "ACL", "SK", "P", "OHS"]), "upper");
|
|
2055
|
+
var RelationshipRoleSchema = caseInsensitiveEnum(z.enum(["upstream", "downstream", "peer"]));
|
|
2056
|
+
var RelationshipSchema = z.object({
|
|
2057
|
+
context: z.string(),
|
|
2058
|
+
pattern: RelationshipPatternSchema,
|
|
2059
|
+
role: RelationshipRoleSchema.optional(),
|
|
2060
|
+
acl: z.object({
|
|
2061
|
+
adapter: z.string(),
|
|
2062
|
+
location: z.string().optional(),
|
|
2063
|
+
notes: z.string().optional()
|
|
2064
|
+
}).optional(),
|
|
2065
|
+
notes: z.string().optional()
|
|
2066
|
+
});
|
|
2067
|
+
var PortDefinitionSchema = z.object({
|
|
2068
|
+
name: z.string(),
|
|
2069
|
+
owner: z.string().optional()
|
|
2070
|
+
});
|
|
2071
|
+
var LegacyOrNewPortSchema = z.union([
|
|
2072
|
+
z.string(),
|
|
2073
|
+
PortDefinitionSchema
|
|
2074
|
+
]);
|
|
2075
|
+
caseInsensitiveEnum(z.enum(["domain", "application", "infrastructure"]));
|
|
2076
|
+
var UiLayerSchema = z.object({
|
|
2077
|
+
components: z.array(z.string()).optional()
|
|
2078
|
+
}).passthrough();
|
|
2079
|
+
var BoundedContextSchema = z.object({
|
|
2080
|
+
name: z.string(),
|
|
2081
|
+
type: BoundedContextTypeSchema.optional(),
|
|
2082
|
+
plane: PlaneTypeSchema.optional(),
|
|
2083
|
+
status: StatusTypeSchema.optional(),
|
|
2084
|
+
description: z.string().optional(),
|
|
2085
|
+
relationships: z.array(RelationshipSchema).optional(),
|
|
2086
|
+
// PASSTHROUGH, not strict, at every level of this subtree — a deliberate
|
|
2087
|
+
// choice, see the note on the schema below. Zod's default `z.object` STRIPS
|
|
2088
|
+
// undeclared keys, which is how `layers.ui` disappeared between the file on
|
|
2089
|
+
// disk and every consumer of the merged manifest.
|
|
2090
|
+
layers: z.object({
|
|
2091
|
+
domain: z.object({
|
|
2092
|
+
entities: z.array(z.string()).optional(),
|
|
2093
|
+
value_objects: z.array(z.string()).optional()
|
|
2094
|
+
}).passthrough().optional(),
|
|
2095
|
+
application: z.object({
|
|
2096
|
+
use_cases: z.array(z.string()).optional(),
|
|
2097
|
+
ports: z.object({
|
|
2098
|
+
in: z.array(LegacyOrNewPortSchema).optional(),
|
|
2099
|
+
out: z.array(LegacyOrNewPortSchema).optional()
|
|
2100
|
+
}).passthrough().optional()
|
|
2101
|
+
}).passthrough().optional(),
|
|
2102
|
+
infrastructure: z.object({
|
|
2103
|
+
adapters: z.array(z.string()).optional()
|
|
2104
|
+
}).passthrough().optional(),
|
|
2105
|
+
ui: UiLayerSchema.optional()
|
|
2106
|
+
}).passthrough().optional(),
|
|
2107
|
+
depends_on: z.array(z.string()).optional(),
|
|
2108
|
+
wiring: z.array(z.string()).optional(),
|
|
2109
|
+
generator: z.record(z.unknown()).optional()
|
|
2110
|
+
}).passthrough();
|
|
2111
|
+
var AppSchema = z.object({
|
|
2112
|
+
name: z.string(),
|
|
2113
|
+
framework: z.string().optional(),
|
|
2114
|
+
version: z.string().optional(),
|
|
2115
|
+
driver: z.string().optional(),
|
|
2116
|
+
description: z.string().optional(),
|
|
2117
|
+
role: z.string().optional(),
|
|
2118
|
+
router: z.string().optional(),
|
|
2119
|
+
deployment: z.string().optional(),
|
|
2120
|
+
auth: z.string().optional(),
|
|
2121
|
+
schedule: z.string().optional(),
|
|
2122
|
+
ui: z.object({
|
|
2123
|
+
library: z.string().optional(),
|
|
2124
|
+
styling: z.string().optional()
|
|
2125
|
+
}).optional(),
|
|
2126
|
+
responsibilities: z.array(z.string()).optional(),
|
|
2127
|
+
depends_on: z.array(z.string()).optional()
|
|
2128
|
+
}).strip();
|
|
2129
|
+
var CrossContextEdgeSchema = z.object({
|
|
2130
|
+
consumer: z.string(),
|
|
2131
|
+
provider: z.string(),
|
|
2132
|
+
transport: z.enum(["event-bus", "network"]),
|
|
2133
|
+
events: z.array(z.string()).optional(),
|
|
2134
|
+
operations: z.array(z.string()).optional(),
|
|
2135
|
+
integrationPattern: z.enum(["open-host", "acl"]).optional()
|
|
2136
|
+
});
|
|
2137
|
+
var GeneratorBlockSchema = z.object({ name: z.string().min(1).optional() }).passthrough();
|
|
2138
|
+
var IndexManifestSchema = z.object({
|
|
2139
|
+
// Toolchain-compatibility stamp (see manifest-schema-version.ts). Note
|
|
2140
|
+
// `version` below is a DIFFERENT field — its `"2.0"` string is the
|
|
2141
|
+
// index-form discriminator (`isIndexManifest`), not a compatibility gate.
|
|
2142
|
+
schemaVersion: z.number().int().positive().optional(),
|
|
2143
|
+
version: z.string().optional(),
|
|
2144
|
+
description: z.string(),
|
|
2145
|
+
system: z.string().optional(),
|
|
2146
|
+
scope: z.string().optional(),
|
|
2147
|
+
architecture: z.string().optional(),
|
|
2148
|
+
planes: z.record(z.array(z.string())).optional(),
|
|
2149
|
+
bounded_contexts: z.array(z.object({
|
|
2150
|
+
name: z.string(),
|
|
2151
|
+
type: BoundedContextTypeSchema.optional(),
|
|
2152
|
+
plane: PlaneTypeSchema.optional(),
|
|
2153
|
+
status: StatusTypeSchema.optional(),
|
|
2154
|
+
file: z.string(),
|
|
2155
|
+
frozen_since: z.string().optional()
|
|
2156
|
+
})).optional(),
|
|
2157
|
+
apps: z.array(z.object({
|
|
2158
|
+
name: z.string(),
|
|
2159
|
+
file: z.string().optional()
|
|
2160
|
+
})).optional(),
|
|
2161
|
+
invariants: z.record(z.string()).optional(),
|
|
2162
|
+
governance: z.record(z.string()).optional(),
|
|
2163
|
+
agent_instructions: z.record(z.unknown()).optional(),
|
|
2164
|
+
relationship_patterns: z.record(z.object({
|
|
2165
|
+
description: z.string(),
|
|
2166
|
+
acl_required: z.union([z.boolean(), z.literal("optional")]).optional(),
|
|
2167
|
+
linter: z.string().optional()
|
|
2168
|
+
})).optional(),
|
|
2169
|
+
mvk: z.record(z.unknown()).optional(),
|
|
2170
|
+
cross_context: z.array(CrossContextEdgeSchema).optional(),
|
|
2171
|
+
workspace_config: z.string().optional(),
|
|
2172
|
+
legacy_config: z.string().optional()
|
|
2173
|
+
}).strict().refine((data) => {
|
|
2174
|
+
const contexts = data.bounded_contexts ?? [];
|
|
2175
|
+
return contexts.every((ctx) => {
|
|
2176
|
+
if (ctx.plane && ctx.file) {
|
|
2177
|
+
return ctx.file.startsWith(`contexts/${ctx.plane}/`);
|
|
2178
|
+
}
|
|
2179
|
+
return true;
|
|
2180
|
+
});
|
|
2181
|
+
}, {
|
|
2182
|
+
message: "Context plane does not match file path subdirectory",
|
|
2183
|
+
path: ["bounded_contexts"]
|
|
2184
|
+
});
|
|
2185
|
+
var ManifestSchema = z.object({
|
|
2186
|
+
// Toolchain-compatibility stamp (positive int; absent = legacy). NOT the
|
|
2187
|
+
// freeform `version` string below. Compatibility is asserted against the
|
|
2188
|
+
// RAW yaml BEFORE this `.strict()` parse (assertSupportedSchemaVersion in
|
|
2189
|
+
// manifest-schema-version.ts) — this entry only keeps strict mode from
|
|
2190
|
+
// rejecting stamped manifests as carrying an unknown key.
|
|
2191
|
+
schemaVersion: z.number().int().positive().optional(),
|
|
2192
|
+
version: z.string().optional(),
|
|
2193
|
+
description: z.string().optional(),
|
|
2194
|
+
system: z.string().optional(),
|
|
2195
|
+
scope: z.string().optional(),
|
|
2196
|
+
// Structured workspace metadata (the canonical `workspace:` block, also the
|
|
2197
|
+
// first block in the few-shot examples). `system`/`scope` above are derived
|
|
2198
|
+
// from `workspace.name`; `workspace.description` is the only carrier of the
|
|
2199
|
+
// human-readable intent. Emitted by `draftToManifest` so the generated
|
|
2200
|
+
// manifest survives `parseManifestToWizardData`'s strict parse on the
|
|
2201
|
+
// "Use this manifest" path. Optional — legacy/hand-written manifests omit it.
|
|
2202
|
+
workspace: z.object({
|
|
2203
|
+
name: z.string(),
|
|
2204
|
+
description: z.string()
|
|
2205
|
+
}).optional(),
|
|
2206
|
+
architecture: z.string().optional(),
|
|
2207
|
+
// The wizard records the chosen workspace template (e.g. "strict-enterprise")
|
|
2208
|
+
// alongside `architecture`; persisted into .architecture/manifest.yaml.
|
|
2209
|
+
workspaceTemplate: z.string().optional(),
|
|
2210
|
+
planes: z.record(z.array(z.string())).optional(),
|
|
2211
|
+
monorepo: z.record(z.unknown()).optional(),
|
|
2212
|
+
generator: GeneratorBlockSchema.optional(),
|
|
2213
|
+
mvk: z.record(z.unknown()).optional(),
|
|
2214
|
+
invariants: z.record(z.string()).optional(),
|
|
2215
|
+
governance: z.record(z.string()).optional(),
|
|
2216
|
+
agent_instructions: z.record(z.unknown()).optional(),
|
|
2217
|
+
relationship_patterns: z.record(z.object({
|
|
2218
|
+
description: z.string(),
|
|
2219
|
+
acl_required: z.union([z.boolean(), z.literal("optional")]).optional(),
|
|
2220
|
+
linter: z.string().optional()
|
|
2221
|
+
})).optional(),
|
|
2222
|
+
bounded_contexts: z.array(BoundedContextSchema),
|
|
2223
|
+
apps: z.array(AppSchema).optional(),
|
|
2224
|
+
cross_context: z.array(CrossContextEdgeSchema).optional(),
|
|
2225
|
+
context_mappings: z.array(z.object({
|
|
2226
|
+
upstream: z.string(),
|
|
2227
|
+
downstream: z.string(),
|
|
2228
|
+
pattern: z.string().optional(),
|
|
2229
|
+
mechanism: z.string().optional(),
|
|
2230
|
+
notes: z.string().optional(),
|
|
2231
|
+
events: z.array(z.string()).optional()
|
|
2232
|
+
})).optional(),
|
|
2233
|
+
workspaceDefaults: z.record(z.unknown()).optional(),
|
|
2234
|
+
// Both side-car pointers. `mergeSplitManifest` resolves `workspace_config`
|
|
2235
|
+
// into the `monorepo`/`generator` blocks above and then carries the pointer
|
|
2236
|
+
// through with every other index key, so the merged (flat) form has to
|
|
2237
|
+
// accept it — this schema is `.strict()`, and the merge output is re-parsed
|
|
2238
|
+
// against it (sync's `validateManifest`, `parseManifestToWizardData`).
|
|
2239
|
+
workspace_config: z.string().optional(),
|
|
2240
|
+
legacy_config: z.string().optional()
|
|
2241
|
+
}).strict();
|
|
1987
2242
|
|
|
1988
|
-
//
|
|
1989
|
-
var
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2243
|
+
// ../project-configuration/dist/domain/model/manifest-schema/manifest-schema-version.js
|
|
2244
|
+
var CURRENT_MANIFEST_SCHEMA_VERSION = 1;
|
|
2245
|
+
function readManifestSchemaVersion(parsed) {
|
|
2246
|
+
if (parsed === null || typeof parsed !== "object")
|
|
2247
|
+
return void 0;
|
|
2248
|
+
const raw = parsed.schemaVersion;
|
|
2249
|
+
if (raw === void 0)
|
|
2250
|
+
return void 0;
|
|
2251
|
+
if (typeof raw !== "number" || !Number.isInteger(raw) || raw < 1) {
|
|
2252
|
+
throw new Error(`Invalid manifest schemaVersion: expected a positive integer, got ${JSON.stringify(raw)}.`);
|
|
2253
|
+
}
|
|
2254
|
+
return raw;
|
|
2255
|
+
}
|
|
2256
|
+
function assertSupportedSchemaVersion(parsed) {
|
|
2257
|
+
const version = readManifestSchemaVersion(parsed);
|
|
2258
|
+
if (version === void 0)
|
|
2259
|
+
return;
|
|
2260
|
+
if (version > CURRENT_MANIFEST_SCHEMA_VERSION) {
|
|
2261
|
+
throw new Error(`Manifest schemaVersion ${version} is newer than this toolchain supports (reads ≤ ${CURRENT_MANIFEST_SCHEMA_VERSION}). This manifest requires a newer @hexagen-monaco/sync — upgrade it. (Upgrading is always safe: a newer toolchain reads every older manifest, and \`hexagen manifest migrate\` brings one forward on demand.)`);
|
|
2262
|
+
}
|
|
2263
|
+
}
|
|
2001
2264
|
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2265
|
+
// ../project-configuration/dist/domain/model/manifest-schema/generator-identity.js
|
|
2266
|
+
var HEXAGEN_GENERATOR_NAME = "@hexagen-monaco/sync";
|
|
2267
|
+
|
|
2268
|
+
// ../project-configuration/dist/domain/model/manifest-schema/is-index-manifest.js
|
|
2269
|
+
function isIndexManifest(parsed) {
|
|
2270
|
+
if (typeof parsed !== "object" || parsed === null) {
|
|
2271
|
+
return false;
|
|
2272
|
+
}
|
|
2273
|
+
const record = parsed;
|
|
2274
|
+
if (record.version !== "2.0") {
|
|
2275
|
+
return false;
|
|
2276
|
+
}
|
|
2277
|
+
const contexts = record.bounded_contexts;
|
|
2278
|
+
if (!Array.isArray(contexts)) {
|
|
2279
|
+
return false;
|
|
2280
|
+
}
|
|
2281
|
+
return contexts.some((entry) => typeof entry === "object" && entry !== null && typeof entry.file === "string");
|
|
2282
|
+
}
|
|
2283
|
+
var WorkspaceGovernanceSchema = z.object({
|
|
2284
|
+
workspaceName: z.string().min(1, "Workspace name is required"),
|
|
2285
|
+
workspaceTemplate: z.enum(["modular-monolith", "strict-enterprise", "micro-frontend"]).default("modular-monolith"),
|
|
2286
|
+
workspaceDescription: z.string().optional(),
|
|
2287
|
+
packageManager: z.enum(["yarn", "pnpm", "bun"]).default("yarn"),
|
|
2288
|
+
topologyStrictness: z.enum(["strict", "flexible"]).default("flexible"),
|
|
2289
|
+
namespacePrefix: z.string().default("@hexagen"),
|
|
2290
|
+
namingConventions: z.object({
|
|
2291
|
+
contextDirectoryPattern: z.string().default("packages/"),
|
|
2292
|
+
adapterSuffix: z.string().default(".adapter.ts")
|
|
2293
|
+
}).default({
|
|
2294
|
+
contextDirectoryPattern: "packages/",
|
|
2295
|
+
adapterSuffix: ".adapter.ts"
|
|
2296
|
+
})
|
|
2297
|
+
});
|
|
2298
|
+
var PortConfigurationSchema = z.object({
|
|
2299
|
+
inboundPorts: z.array(z.enum([
|
|
2300
|
+
"rest-controller",
|
|
2301
|
+
"graphql-resolver",
|
|
2302
|
+
"event-listener",
|
|
2303
|
+
"cli-command"
|
|
2304
|
+
])).default([]),
|
|
2305
|
+
outboundPorts: z.array(z.enum([
|
|
2306
|
+
"relational-db",
|
|
2307
|
+
"document-db",
|
|
2308
|
+
"external-service-client",
|
|
2309
|
+
"message-publisher"
|
|
2310
|
+
])).default([])
|
|
2311
|
+
});
|
|
2312
|
+
var PeerContextMappingSchema = z.object({
|
|
2313
|
+
consumerContext: z.string(),
|
|
2314
|
+
providerContext: z.string(),
|
|
2315
|
+
integrationPattern: z.enum(["open-host", "acl"]),
|
|
2316
|
+
communicationBoundary: z.enum(["in-process", "networked"])
|
|
2317
|
+
});
|
|
2318
|
+
var BoundedContextSchema2 = z.object({
|
|
2319
|
+
id: z.string(),
|
|
2320
|
+
name: z.string().min(1, "Please enter a name for this bounded context (e.g., 'UserService', 'OrderProcessing')"),
|
|
2321
|
+
description: z.string().optional(),
|
|
2322
|
+
// ADR-0041: `infrastructureTarget` (API backend) and `uiFramework` (below)
|
|
2323
|
+
// are PROJECT-LEVEL choices managed by the wizard's Applications step, which
|
|
2324
|
+
// fans a single selection out to every context. They persist per-context (the
|
|
2325
|
+
// source of truth `deriveApps` reads), but are NOT direct per-context input —
|
|
2326
|
+
// do not re-add per-context UI/API editing without revisiting ADR-0041.
|
|
2327
|
+
// `"none"` = the project opts out of a separate API backend (UI-only, e.g. a
|
|
2328
|
+
// Next.js app with built-in routes); `deriveApps` then emits no `api` app.
|
|
2329
|
+
// Distinct from `undefined` (legacy/unset → defaults to the preset).
|
|
2330
|
+
infrastructureTarget: z.enum(["nestjs", "express", "serverless", "plain-ts", "nitro", "none"]).optional(),
|
|
2331
|
+
coreDomainEntities: z.array(z.string()).default([]),
|
|
2332
|
+
valueObjects: z.array(z.string()).default([]),
|
|
2333
|
+
domainEvents: z.array(z.string()).default([]),
|
|
2334
|
+
portConfiguration: PortConfigurationSchema,
|
|
2335
|
+
// Backward compatibility: support legacy fields
|
|
2336
|
+
apiFramework: z.enum(["Fastify", "Express", "NestJS"]).optional(),
|
|
2337
|
+
uiFramework: z.enum(["", "Next.js", "React Router", "Remix", "Angular", "Vue.js"]).optional().default(""),
|
|
2338
|
+
persistenceAdapter: z.enum(["", "Prisma", "TypeORM", "Mongoose", "Drizzle"]).optional().default(""),
|
|
2339
|
+
messagingAdapter: z.enum(["", "BullMQ", "Temporal", "RabbitMQ"]).optional().default(""),
|
|
2340
|
+
telemetryProvider: z.enum(["", "OpenTelemetry", "None", "Prometheus", "Winston"]).optional().default(""),
|
|
2341
|
+
externalApiPorts: z.array(z.string()).optional(),
|
|
2342
|
+
llmProviders: z.array(z.string()).optional(),
|
|
2343
|
+
blockchainNetworks: z.array(z.string()).optional(),
|
|
2344
|
+
authenticationProvider: z.string().optional(),
|
|
2345
|
+
emailService: z.string().optional(),
|
|
2346
|
+
paymentGateway: z.string().optional(),
|
|
2347
|
+
storageProvider: z.string().optional(),
|
|
2348
|
+
searchService: z.string().optional(),
|
|
2349
|
+
webhookEndpoints: z.array(z.string()).optional(),
|
|
2350
|
+
entities: z.array(z.string()).optional(),
|
|
2351
|
+
useCases: z.array(z.string()).optional()
|
|
2352
|
+
});
|
|
2353
|
+
var ExternalContextSchema = z.object({
|
|
2354
|
+
id: z.string(),
|
|
2355
|
+
name: z.string().min(1, "Peer context name is required"),
|
|
2356
|
+
relationshipType: z.enum(["U", "D", "ACL", "SK", "P", "OHS"]),
|
|
2357
|
+
isEventDriven: z.boolean().optional(),
|
|
2358
|
+
entityNames: z.array(z.string()).optional(),
|
|
2359
|
+
useCaseNames: z.array(z.string()).optional()
|
|
2360
|
+
});
|
|
2361
|
+
z.object({
|
|
2362
|
+
boundedContexts: z.array(BoundedContextSchema2).default([]),
|
|
2363
|
+
externalContexts: z.array(ExternalContextSchema).default([]),
|
|
2364
|
+
governance: WorkspaceGovernanceSchema.default({
|
|
2365
|
+
workspaceName: "@hexagen",
|
|
2366
|
+
workspaceTemplate: "modular-monolith",
|
|
2367
|
+
packageManager: "yarn",
|
|
2368
|
+
topologyStrictness: "flexible",
|
|
2369
|
+
namespacePrefix: "@hexagen",
|
|
2370
|
+
namingConventions: {
|
|
2371
|
+
contextDirectoryPattern: "packages/",
|
|
2372
|
+
adapterSuffix: ".adapter.ts"
|
|
2373
|
+
}
|
|
2374
|
+
}),
|
|
2375
|
+
peerMappings: z.array(PeerContextMappingSchema).default([]),
|
|
2376
|
+
/**
|
|
2377
|
+
* Per-template install-time answers collected by the wizard. Keyed by
|
|
2378
|
+
* template id; each value is a record of question-id → answer. The CLI
|
|
2379
|
+
* use case consumes this via its `overrideAnswers` parameter, so the
|
|
2380
|
+
* wizard can feed answers gathered in the UI directly into a non-
|
|
2381
|
+
* interactive install. Defaults to an empty object for projects that
|
|
2382
|
+
* are scaffolded without the per-template questions step.
|
|
2383
|
+
*/
|
|
2384
|
+
addOnsAnswers: z.record(z.string(), z.record(z.string(), z.union([z.string(), z.boolean(), z.array(z.string())]))).default({}),
|
|
2385
|
+
/**
|
|
2386
|
+
* Provenance of the project's `manifestYaml` (import round-trip integrity,
|
|
2387
|
+
* Item 1). `"imported"` = the manifest is the source of truth (accepted via
|
|
2388
|
+
* `parseManifestToWizardData` — file import or AI generation) and the wizard
|
|
2389
|
+
* projection (`wizardToManifest`) is LOSSY for it, so autosave/export paths
|
|
2390
|
+
* must never overwrite or impersonate the stored manifest. Deliberately
|
|
2391
|
+
* `.optional()` rather than `.default("wizard")`: absent ≡ `"wizard"`
|
|
2392
|
+
* everywhere (guards key on `=== "imported"` only), which keeps every
|
|
2393
|
+
* wizard-authored formState byte-identical to before this field existed and
|
|
2394
|
+
* lets the load perimeter distinguish "legacy record, provenance unknown"
|
|
2395
|
+
* (absent) from an explicit value when running its one-time discriminator.
|
|
2396
|
+
*/
|
|
2397
|
+
manifestSource: z.enum(["wizard", "imported"]).optional()
|
|
2398
|
+
});
|
|
2399
|
+
var MonorepoConfigSchema = z.object({
|
|
2400
|
+
packageManager: z.string().optional(),
|
|
2401
|
+
workspaces: z.array(z.string()).optional(),
|
|
2402
|
+
rootFiles: z.record(z.unknown()).optional(),
|
|
2403
|
+
archInvariants: z.record(z.unknown()).optional()
|
|
2404
|
+
}).passthrough();
|
|
2405
|
+
var GeneratorSyncSchema = z.object({
|
|
2406
|
+
layers: z.record(z.unknown()).optional(),
|
|
2407
|
+
packageJson: z.record(z.unknown()).optional(),
|
|
2408
|
+
stubs: z.record(z.unknown()).optional(),
|
|
2409
|
+
apps: z.record(z.unknown()).optional()
|
|
2410
|
+
}).passthrough();
|
|
2411
|
+
var GeneratorConfigSchema = z.object({
|
|
2412
|
+
name: z.string().min(1).optional(),
|
|
2413
|
+
version: z.string().optional(),
|
|
2414
|
+
sync: GeneratorSyncSchema.optional()
|
|
2415
|
+
}).passthrough();
|
|
2416
|
+
var WorkspaceConfigSchema = z.object({
|
|
2417
|
+
monorepo: MonorepoConfigSchema.optional(),
|
|
2418
|
+
generator: GeneratorConfigSchema.optional(),
|
|
2419
|
+
workspaceDefaults: z.record(z.unknown()).optional(),
|
|
2420
|
+
tsConfigRoot: z.record(z.unknown()).optional(),
|
|
2421
|
+
eslint: z.record(z.unknown()).optional(),
|
|
2422
|
+
rootFiles: z.record(z.unknown()).optional(),
|
|
2423
|
+
generatorConfig: z.record(z.unknown()).optional(),
|
|
2424
|
+
turboConfig: z.record(z.unknown()).optional()
|
|
2425
|
+
}).passthrough();
|
|
2426
|
+
|
|
2427
|
+
// src/generators/architecture-file-templates.ts
|
|
2428
|
+
var LAYER_RULES_COMMON = `shared_kernel:
|
|
2429
|
+
package: "@{scope}/shared"
|
|
2430
|
+
allowed_in_all_layers: true
|
|
2431
|
+
|
|
2432
|
+
layers:
|
|
2433
|
+
domain:
|
|
2434
|
+
access_rule: "internal-only"
|
|
2435
|
+
allowed_imports: ["@{scope}/shared"]
|
|
2436
|
+
|
|
2437
|
+
application:
|
|
2438
|
+
access_rule: "ports-only"
|
|
2439
|
+
allowed_imports: ["domain", "@{scope}/shared"]
|
|
2440
|
+
|
|
2441
|
+
infrastructure:
|
|
2442
|
+
access_rule: "adapters"
|
|
2443
|
+
allowed_imports: ["domain", "application", "@{scope}/shared"]
|
|
2444
|
+
`;
|
|
2445
|
+
var LAYER_RULES_STRICT_ENTERPRISE = `# HexaGen — Architectural Invariants
|
|
2446
|
+
# Template: strict-enterprise — event-bus boundaries
|
|
2008
2447
|
|
|
2009
2448
|
${LAYER_RULES_COMMON}
|
|
2010
2449
|
cross_context:
|
|
@@ -2255,13 +2694,22 @@ function interpolateWithLogging(label, template, vars, config) {
|
|
|
2255
2694
|
}
|
|
2256
2695
|
return output;
|
|
2257
2696
|
}
|
|
2697
|
+
function withGeneratorIdentity(manifest) {
|
|
2698
|
+
return {
|
|
2699
|
+
...manifest,
|
|
2700
|
+
generator: {
|
|
2701
|
+
...manifest.generator,
|
|
2702
|
+
name: manifest.generator?.name ?? HEXAGEN_GENERATOR_NAME
|
|
2703
|
+
}
|
|
2704
|
+
};
|
|
2705
|
+
}
|
|
2258
2706
|
async function writeManifestIfFreshExternal(config, result, report) {
|
|
2259
2707
|
if (config.mode !== "external") {
|
|
2260
2708
|
return;
|
|
2261
2709
|
}
|
|
2262
|
-
const archDir =
|
|
2263
|
-
const manifestPath =
|
|
2264
|
-
const relative =
|
|
2710
|
+
const archDir = path8.join(config.workspaceRoot, ".architecture");
|
|
2711
|
+
const manifestPath = path8.join(archDir, "manifest.yaml");
|
|
2712
|
+
const relative = path8.relative(config.workspaceRoot, manifestPath);
|
|
2265
2713
|
if (!isInScope(manifestPath, config)) {
|
|
2266
2714
|
config.logger.debug(`skipped (outside --only) ${relative}`);
|
|
2267
2715
|
result.skipped.push(manifestPath);
|
|
@@ -2287,7 +2735,7 @@ async function writeManifestIfFreshExternal(config, result, report) {
|
|
|
2287
2735
|
result.totalOps += 1;
|
|
2288
2736
|
return;
|
|
2289
2737
|
}
|
|
2290
|
-
const content = yaml3.dump(config.manifest);
|
|
2738
|
+
const content = yaml3.dump(withGeneratorIdentity(config.manifest));
|
|
2291
2739
|
config.journal?.recordWrite(manifestPath, null);
|
|
2292
2740
|
await fs5.mkdir(archDir, { recursive: true });
|
|
2293
2741
|
await fs5.writeFile(manifestPath, content, { encoding: "utf8" });
|
|
@@ -2304,7 +2752,7 @@ async function writeManifestIfFreshExternal(config, result, report) {
|
|
|
2304
2752
|
async function generateArchitectureFiles(config, report) {
|
|
2305
2753
|
const result = createEmptyResult();
|
|
2306
2754
|
const manifest = config.manifest;
|
|
2307
|
-
const archRoot =
|
|
2755
|
+
const archRoot = path8.join(config.workspaceRoot, ".architecture");
|
|
2308
2756
|
const archInvariants = manifest.monorepo?.archInvariants;
|
|
2309
2757
|
const { vars, ownershipCollisions } = buildInterpolationVars(manifest);
|
|
2310
2758
|
const workspaceTemplate = vars.workspaceTemplate ?? "modular-monolith";
|
|
@@ -2314,7 +2762,7 @@ async function generateArchitectureFiles(config, report) {
|
|
|
2314
2762
|
);
|
|
2315
2763
|
}
|
|
2316
2764
|
await writeManifestIfFreshExternal(config, result, report);
|
|
2317
|
-
const layerRulesPath =
|
|
2765
|
+
const layerRulesPath = path8.join(archRoot, "invariants", "layer-rules.yaml");
|
|
2318
2766
|
const layerRulesTemplate = resolveTemplate2(
|
|
2319
2767
|
archInvariants?.layerRules,
|
|
2320
2768
|
builtInLayerRules(workspaceTemplate)
|
|
@@ -2333,7 +2781,7 @@ async function generateArchitectureFiles(config, report) {
|
|
|
2333
2781
|
true
|
|
2334
2782
|
);
|
|
2335
2783
|
recordWriteStatus(result, layerRulesPath, layerRulesStatus);
|
|
2336
|
-
const linterConfigPath =
|
|
2784
|
+
const linterConfigPath = path8.join(
|
|
2337
2785
|
archRoot,
|
|
2338
2786
|
"invariants",
|
|
2339
2787
|
"linter-config.yaml"
|
|
@@ -2356,7 +2804,7 @@ async function generateArchitectureFiles(config, report) {
|
|
|
2356
2804
|
true
|
|
2357
2805
|
);
|
|
2358
2806
|
recordWriteStatus(result, linterConfigPath, linterConfigStatus);
|
|
2359
|
-
const generatorConfigPath =
|
|
2807
|
+
const generatorConfigPath = path8.join(archRoot, "generator.config.yaml");
|
|
2360
2808
|
const generatorConfigTemplate = resolveTemplate2(
|
|
2361
2809
|
archInvariants?.generatorConfig,
|
|
2362
2810
|
GENERATOR_CONFIG_TEMPLATE
|
|
@@ -3294,7 +3742,7 @@ ${content}`;
|
|
|
3294
3742
|
}
|
|
3295
3743
|
async function generateEslintConfig(moduleDir, moduleName, config, report, options = {}) {
|
|
3296
3744
|
const result = createEmptyResult();
|
|
3297
|
-
const filePath =
|
|
3745
|
+
const filePath = path8.join(moduleDir, "eslint.config.js");
|
|
3298
3746
|
try {
|
|
3299
3747
|
const { template, source } = resolveTemplate3(
|
|
3300
3748
|
config.manifest,
|
|
@@ -3382,9 +3830,9 @@ async function emitAppFile(appDir, relPath, template, vars, config, report, resu
|
|
|
3382
3830
|
`apps/${appName}/${relPath}`,
|
|
3383
3831
|
config
|
|
3384
3832
|
);
|
|
3385
|
-
const target =
|
|
3386
|
-
const relative =
|
|
3387
|
-
if (relative === "" || relative.startsWith("..") ||
|
|
3833
|
+
const target = path8.resolve(appDir, relPath);
|
|
3834
|
+
const relative = path8.relative(appDir, target);
|
|
3835
|
+
if (relative === "" || relative.startsWith("..") || path8.isAbsolute(relative)) {
|
|
3388
3836
|
config.logger.warn(
|
|
3389
3837
|
`[apps] skipping file with unsafe path (escapes apps/${appName}): ${relPath}`
|
|
3390
3838
|
);
|
|
@@ -3399,7 +3847,7 @@ async function emitAppFile(appDir, relPath, template, vars, config, report, resu
|
|
|
3399
3847
|
}
|
|
3400
3848
|
if (!config.dryRun && isInScope(target, config)) {
|
|
3401
3849
|
try {
|
|
3402
|
-
await fs5.mkdir(
|
|
3850
|
+
await fs5.mkdir(path8.dirname(target), { recursive: true });
|
|
3403
3851
|
} catch (err3) {
|
|
3404
3852
|
const message = err3 instanceof Error ? err3.message : String(err3);
|
|
3405
3853
|
config.logger.error(
|
|
@@ -3490,8 +3938,8 @@ async function generateApps(config, report) {
|
|
|
3490
3938
|
version: app.version ?? "",
|
|
3491
3939
|
depends_on: (app.depends_on ?? []).join(", ")
|
|
3492
3940
|
};
|
|
3493
|
-
const appDir =
|
|
3494
|
-
const srcDir =
|
|
3941
|
+
const appDir = path8.join(config.workspaceRoot, "apps", app.name);
|
|
3942
|
+
const srcDir = path8.join(appDir, "src");
|
|
3495
3943
|
if (!config.dryRun && isInScope(appDir, config)) {
|
|
3496
3944
|
try {
|
|
3497
3945
|
await fs5.mkdir(appDir, { recursive: true });
|
|
@@ -3513,7 +3961,7 @@ async function generateApps(config, report) {
|
|
|
3513
3961
|
`apps/${app.name}/package.json`,
|
|
3514
3962
|
config
|
|
3515
3963
|
);
|
|
3516
|
-
const pkgPath =
|
|
3964
|
+
const pkgPath = path8.join(appDir, "package.json");
|
|
3517
3965
|
const status = await safeWriteFileAtomic(
|
|
3518
3966
|
pkgPath,
|
|
3519
3967
|
pkgContent,
|
|
@@ -3529,7 +3977,7 @@ async function generateApps(config, report) {
|
|
|
3529
3977
|
const tsConfig = frameworkConfig.tsConfig;
|
|
3530
3978
|
if (tsConfig) {
|
|
3531
3979
|
const tsContent = JSON.stringify(tsConfig, null, 2) + "\n";
|
|
3532
|
-
const tsPath =
|
|
3980
|
+
const tsPath = path8.join(appDir, "tsconfig.json");
|
|
3533
3981
|
const status = await safeWriteFileAtomic(
|
|
3534
3982
|
tsPath,
|
|
3535
3983
|
tsContent,
|
|
@@ -3596,14 +4044,14 @@ async function generateApps(config, report) {
|
|
|
3596
4044
|
}
|
|
3597
4045
|
}
|
|
3598
4046
|
function relativeImportSpecifier(fromFile, toFile) {
|
|
3599
|
-
let rel =
|
|
4047
|
+
let rel = path8.relative(path8.dirname(fromFile), toFile).split(path8.sep).join("/").replace(/\.tsx?$/, ".js");
|
|
3600
4048
|
if (!rel.startsWith(".")) rel = `./${rel}`;
|
|
3601
4049
|
return rel;
|
|
3602
4050
|
}
|
|
3603
4051
|
function rewriteRelativeSpecifier(specifier, fromFile, toFile) {
|
|
3604
4052
|
if (!specifier.startsWith(".")) return specifier;
|
|
3605
|
-
const absolute =
|
|
3606
|
-
let rel =
|
|
4053
|
+
const absolute = path8.resolve(path8.dirname(fromFile), specifier);
|
|
4054
|
+
let rel = path8.relative(path8.dirname(toFile), absolute).split(path8.sep).join("/");
|
|
3607
4055
|
if (!rel.startsWith(".")) rel = `./${rel}`;
|
|
3608
4056
|
return rel;
|
|
3609
4057
|
}
|
|
@@ -3659,7 +4107,28 @@ function safeParamName(name) {
|
|
|
3659
4107
|
const candidate = name.length === 0 ? "dep" : name;
|
|
3660
4108
|
return RESERVED_IDENTIFIERS.has(candidate) ? `${candidate}_` : candidate;
|
|
3661
4109
|
}
|
|
4110
|
+
var analysisMemo = /* @__PURE__ */ new Map();
|
|
4111
|
+
function resetPortAnalysisMemo() {
|
|
4112
|
+
analysisMemo.clear();
|
|
4113
|
+
}
|
|
3662
4114
|
function analyzePortFile(portFilePath) {
|
|
4115
|
+
const absolute = path8.resolve(portFilePath);
|
|
4116
|
+
let contents;
|
|
4117
|
+
try {
|
|
4118
|
+
contents = fs4.readFileSync(absolute, "utf8");
|
|
4119
|
+
} catch {
|
|
4120
|
+
return null;
|
|
4121
|
+
}
|
|
4122
|
+
const fingerprint = createHash("sha256").update(contents).digest("hex");
|
|
4123
|
+
const key = `${absolute}:${fingerprint}`;
|
|
4124
|
+
if (analysisMemo.has(key)) {
|
|
4125
|
+
return analysisMemo.get(key) ?? null;
|
|
4126
|
+
}
|
|
4127
|
+
const result = analyzePortFileUncached(absolute, contents);
|
|
4128
|
+
analysisMemo.set(key, result);
|
|
4129
|
+
return result;
|
|
4130
|
+
}
|
|
4131
|
+
function analyzePortFileUncached(portFilePath, contents) {
|
|
3663
4132
|
try {
|
|
3664
4133
|
const project = new Project({
|
|
3665
4134
|
skipAddingFilesFromTsConfig: true,
|
|
@@ -3670,7 +4139,9 @@ function analyzePortFile(portFilePath) {
|
|
|
3670
4139
|
// ESNext
|
|
3671
4140
|
}
|
|
3672
4141
|
});
|
|
3673
|
-
const sourceFile = project.
|
|
4142
|
+
const sourceFile = project.createSourceFile(portFilePath, contents, {
|
|
4143
|
+
overwrite: true
|
|
4144
|
+
});
|
|
3674
4145
|
const interfaces = sourceFile.getInterfaces().filter((i) => i.isExported());
|
|
3675
4146
|
if (interfaces.length === 0) {
|
|
3676
4147
|
return null;
|
|
@@ -4242,13 +4713,13 @@ function resolveNaming(kind, contextNaming, manifestNaming) {
|
|
|
4242
4713
|
async function writeStubFile(filePath, content, config, report) {
|
|
4243
4714
|
if (!isInScope(filePath, config)) {
|
|
4244
4715
|
config.logger.debug(
|
|
4245
|
-
`skipped (outside --only) ${
|
|
4716
|
+
`skipped (outside --only) ${path8.relative(config.workspaceRoot, filePath)}`
|
|
4246
4717
|
);
|
|
4247
4718
|
return "skipped";
|
|
4248
4719
|
}
|
|
4249
4720
|
try {
|
|
4250
4721
|
await fs5.stat(filePath);
|
|
4251
|
-
const relative =
|
|
4722
|
+
const relative = path8.relative(config.workspaceRoot, filePath);
|
|
4252
4723
|
config.logger.debug(`stub preserved ${relative}`);
|
|
4253
4724
|
if (report) {
|
|
4254
4725
|
report.record(
|
|
@@ -4264,7 +4735,7 @@ async function writeStubFile(filePath, content, config, report) {
|
|
|
4264
4735
|
}
|
|
4265
4736
|
}
|
|
4266
4737
|
if (!config.dryRun) {
|
|
4267
|
-
await fs5.mkdir(
|
|
4738
|
+
await fs5.mkdir(path8.dirname(filePath), { recursive: true });
|
|
4268
4739
|
}
|
|
4269
4740
|
return safeWriteFileAtomic(filePath, content, config, report, false);
|
|
4270
4741
|
}
|
|
@@ -4287,7 +4758,7 @@ async function tryAnalyzeRelatedPort(moduleDir, name, kind, context, relatedPort
|
|
|
4287
4758
|
`${derivedPortName}.ts`
|
|
4288
4759
|
];
|
|
4289
4760
|
for (const filename of possibleFilenames) {
|
|
4290
|
-
const portFilePath =
|
|
4761
|
+
const portFilePath = path8.join(moduleDir, portSubdir, filename);
|
|
4291
4762
|
const analysis = analyzePortFile(portFilePath);
|
|
4292
4763
|
if (analysis) {
|
|
4293
4764
|
return analysis;
|
|
@@ -4343,7 +4814,7 @@ async function generateStubs(moduleDir, moduleName, config, report) {
|
|
|
4343
4814
|
`stubs.naming.${kind}`,
|
|
4344
4815
|
interpolation
|
|
4345
4816
|
);
|
|
4346
|
-
const filePath =
|
|
4817
|
+
const filePath = path8.join(moduleDir, subdir, filename);
|
|
4347
4818
|
let content;
|
|
4348
4819
|
if (kind === "adapter" || kind === "useCase") {
|
|
4349
4820
|
const relatedPortNaming = resolveNaming(
|
|
@@ -4373,7 +4844,7 @@ async function generateStubs(moduleDir, moduleName, config, report) {
|
|
|
4373
4844
|
contextNaming,
|
|
4374
4845
|
manifestNaming
|
|
4375
4846
|
);
|
|
4376
|
-
const outPortDir =
|
|
4847
|
+
const outPortDir = path8.join(
|
|
4377
4848
|
moduleDir,
|
|
4378
4849
|
resolveEmissionDir(layersConfig, "application/ports/out")
|
|
4379
4850
|
);
|
|
@@ -4385,7 +4856,7 @@ async function generateStubs(moduleDir, moduleName, config, report) {
|
|
|
4385
4856
|
"stubs.naming.outPort",
|
|
4386
4857
|
interpolation
|
|
4387
4858
|
);
|
|
4388
|
-
const outPortPath =
|
|
4859
|
+
const outPortPath = path8.join(outPortDir, outFile);
|
|
4389
4860
|
const analyzed = analyzePortFile(outPortPath);
|
|
4390
4861
|
return {
|
|
4391
4862
|
interfaceName: analyzed?.interfaceName ?? `${base}Port`,
|
|
@@ -4488,19 +4959,19 @@ ${methodLines}
|
|
|
4488
4959
|
`;
|
|
4489
4960
|
}
|
|
4490
4961
|
async function emitPortAndAdapter(result, config, report, scope, spec) {
|
|
4491
|
-
const moduleRoot =
|
|
4962
|
+
const moduleRoot = path8.join(
|
|
4492
4963
|
config.workspaceRoot,
|
|
4493
4964
|
"packages",
|
|
4494
4965
|
spec.contextName
|
|
4495
4966
|
);
|
|
4496
|
-
const portDir =
|
|
4967
|
+
const portDir = path8.join(
|
|
4497
4968
|
moduleRoot,
|
|
4498
4969
|
"src",
|
|
4499
4970
|
"application",
|
|
4500
4971
|
"ports",
|
|
4501
4972
|
spec.portKind
|
|
4502
4973
|
);
|
|
4503
|
-
const portPath =
|
|
4974
|
+
const portPath = path8.join(
|
|
4504
4975
|
portDir,
|
|
4505
4976
|
`${spec.portBase}.${spec.portKind}-port.ts`
|
|
4506
4977
|
);
|
|
@@ -4533,8 +5004,8 @@ async function emitPortAndAdapter(result, config, report, scope, spec) {
|
|
|
4533
5004
|
);
|
|
4534
5005
|
return;
|
|
4535
5006
|
}
|
|
4536
|
-
const adapterDir =
|
|
4537
|
-
const adapterPath =
|
|
5007
|
+
const adapterDir = path8.join(moduleRoot, "src", "infrastructure", "adapters");
|
|
5008
|
+
const adapterPath = path8.join(adapterDir, `${spec.portBase}.adapter.ts`);
|
|
4538
5009
|
if (!isInScope(adapterPath, config)) {
|
|
4539
5010
|
return;
|
|
4540
5011
|
}
|
|
@@ -4566,7 +5037,7 @@ function operationImports(ops) {
|
|
|
4566
5037
|
return ops.flatMap((op) => [`${op}Request`, `${op}Response`]);
|
|
4567
5038
|
}
|
|
4568
5039
|
async function writeSharedContract(result, config, report, relSegments, content) {
|
|
4569
|
-
const contractPath =
|
|
5040
|
+
const contractPath = path8.join(
|
|
4570
5041
|
config.workspaceRoot,
|
|
4571
5042
|
"packages",
|
|
4572
5043
|
"shared",
|
|
@@ -4574,7 +5045,7 @@ async function writeSharedContract(result, config, report, relSegments, content)
|
|
|
4574
5045
|
...relSegments
|
|
4575
5046
|
);
|
|
4576
5047
|
if (!config.dryRun) {
|
|
4577
|
-
await fs5.mkdir(
|
|
5048
|
+
await fs5.mkdir(path8.dirname(contractPath), { recursive: true });
|
|
4578
5049
|
}
|
|
4579
5050
|
recordWriteStatus(
|
|
4580
5051
|
result,
|
|
@@ -4726,7 +5197,7 @@ async function generateSharedKernel(config, report) {
|
|
|
4726
5197
|
(bc) => bc.name?.toLowerCase() === "shared"
|
|
4727
5198
|
);
|
|
4728
5199
|
if (!hasShared) return result;
|
|
4729
|
-
const kernelPath =
|
|
5200
|
+
const kernelPath = path8.join(
|
|
4730
5201
|
config.workspaceRoot,
|
|
4731
5202
|
"packages",
|
|
4732
5203
|
"shared",
|
|
@@ -4746,7 +5217,7 @@ async function generateSharedKernel(config, report) {
|
|
|
4746
5217
|
if (err3.code !== "ENOENT") throw err3;
|
|
4747
5218
|
}
|
|
4748
5219
|
if (!config.dryRun) {
|
|
4749
|
-
await fs5.mkdir(
|
|
5220
|
+
await fs5.mkdir(path8.dirname(kernelPath), { recursive: true });
|
|
4750
5221
|
}
|
|
4751
5222
|
const status = await safeWriteFileAtomic(
|
|
4752
5223
|
kernelPath,
|
|
@@ -4760,12 +5231,18 @@ async function generateSharedKernel(config, report) {
|
|
|
4760
5231
|
}
|
|
4761
5232
|
var execAsync = promisify(exec);
|
|
4762
5233
|
var MAX_BUFFER = 1024 * 1024 * 10;
|
|
4763
|
-
async function ensureDependenciesBuilt(config) {
|
|
5234
|
+
async function ensureDependenciesBuilt(config, options = {}) {
|
|
4764
5235
|
const { logger, dryRun } = config;
|
|
4765
5236
|
if (dryRun) {
|
|
4766
5237
|
logger.info("Pre‑flight: skipping build in dry-run mode");
|
|
4767
5238
|
return;
|
|
4768
5239
|
}
|
|
5240
|
+
if (options.skip) {
|
|
5241
|
+
logger.info(
|
|
5242
|
+
"Preflight: build skipped (--no-preflight); the build is left to the gate"
|
|
5243
|
+
);
|
|
5244
|
+
return;
|
|
5245
|
+
}
|
|
4769
5246
|
logger.info("Pre‑flight: ensuring package dependencies are up‑to‑date...");
|
|
4770
5247
|
try {
|
|
4771
5248
|
const { stdout, stderr } = await execAsync("npx turbo run build", {
|
|
@@ -4843,426 +5320,45 @@ function mergeBarrelPasses(firstPass, secondPass) {
|
|
|
4843
5320
|
}
|
|
4844
5321
|
return combined;
|
|
4845
5322
|
}
|
|
4846
|
-
function
|
|
4847
|
-
|
|
4848
|
-
|
|
4849
|
-
|
|
4850
|
-
|
|
4851
|
-
|
|
4852
|
-
|
|
4853
|
-
|
|
4854
|
-
|
|
4855
|
-
|
|
4856
|
-
|
|
4857
|
-
|
|
4858
|
-
|
|
4859
|
-
|
|
4860
|
-
|
|
4861
|
-
|
|
4862
|
-
|
|
4863
|
-
|
|
4864
|
-
|
|
4865
|
-
|
|
4866
|
-
|
|
4867
|
-
|
|
4868
|
-
|
|
4869
|
-
|
|
4870
|
-
|
|
4871
|
-
|
|
4872
|
-
|
|
4873
|
-
|
|
4874
|
-
|
|
4875
|
-
|
|
4876
|
-
}
|
|
4877
|
-
|
|
4878
|
-
|
|
4879
|
-
|
|
4880
|
-
|
|
4881
|
-
|
|
4882
|
-
|
|
4883
|
-
|
|
4884
|
-
}
|
|
4885
|
-
var BoundedContextSchema = z.object({
|
|
4886
|
-
name: z.string(),
|
|
4887
|
-
type: BoundedContextTypeSchema.optional(),
|
|
4888
|
-
plane: PlaneTypeSchema.optional(),
|
|
4889
|
-
status: StatusTypeSchema.optional(),
|
|
4890
|
-
description: z.string().optional(),
|
|
4891
|
-
relationships: z.array(RelationshipSchema).optional(),
|
|
4892
|
-
// PASSTHROUGH, not strict, at every level of this subtree — a deliberate
|
|
4893
|
-
// choice, see the note on the schema below. Zod's default `z.object` STRIPS
|
|
4894
|
-
// undeclared keys, which is how `layers.ui` disappeared between the file on
|
|
4895
|
-
// disk and every consumer of the merged manifest.
|
|
4896
|
-
layers: z.object({
|
|
4897
|
-
domain: z.object({
|
|
4898
|
-
entities: z.array(z.string()).optional(),
|
|
4899
|
-
value_objects: z.array(z.string()).optional()
|
|
4900
|
-
}).passthrough().optional(),
|
|
4901
|
-
application: z.object({
|
|
4902
|
-
use_cases: z.array(z.string()).optional(),
|
|
4903
|
-
ports: z.object({
|
|
4904
|
-
in: z.array(LegacyOrNewPortSchema).optional(),
|
|
4905
|
-
out: z.array(LegacyOrNewPortSchema).optional()
|
|
4906
|
-
}).passthrough().optional()
|
|
4907
|
-
}).passthrough().optional(),
|
|
4908
|
-
infrastructure: z.object({
|
|
4909
|
-
adapters: z.array(z.string()).optional()
|
|
4910
|
-
}).passthrough().optional(),
|
|
4911
|
-
ui: UiLayerSchema.optional()
|
|
4912
|
-
}).passthrough().optional(),
|
|
4913
|
-
depends_on: z.array(z.string()).optional(),
|
|
4914
|
-
wiring: z.array(z.string()).optional(),
|
|
4915
|
-
generator: z.record(z.unknown()).optional()
|
|
4916
|
-
}).passthrough();
|
|
4917
|
-
var AppSchema = z.object({
|
|
4918
|
-
name: z.string(),
|
|
4919
|
-
framework: z.string().optional(),
|
|
4920
|
-
version: z.string().optional(),
|
|
4921
|
-
driver: z.string().optional(),
|
|
4922
|
-
description: z.string().optional(),
|
|
4923
|
-
role: z.string().optional(),
|
|
4924
|
-
router: z.string().optional(),
|
|
4925
|
-
deployment: z.string().optional(),
|
|
4926
|
-
auth: z.string().optional(),
|
|
4927
|
-
schedule: z.string().optional(),
|
|
4928
|
-
ui: z.object({
|
|
4929
|
-
library: z.string().optional(),
|
|
4930
|
-
styling: z.string().optional()
|
|
4931
|
-
}).optional(),
|
|
4932
|
-
responsibilities: z.array(z.string()).optional(),
|
|
4933
|
-
depends_on: z.array(z.string()).optional()
|
|
4934
|
-
}).strip();
|
|
4935
|
-
var CrossContextEdgeSchema = z.object({
|
|
4936
|
-
consumer: z.string(),
|
|
4937
|
-
provider: z.string(),
|
|
4938
|
-
transport: z.enum(["event-bus", "network"]),
|
|
4939
|
-
events: z.array(z.string()).optional(),
|
|
4940
|
-
operations: z.array(z.string()).optional(),
|
|
4941
|
-
integrationPattern: z.enum(["open-host", "acl"]).optional()
|
|
4942
|
-
});
|
|
4943
|
-
var IndexManifestSchema = z.object({
|
|
4944
|
-
// Toolchain-compatibility stamp (see manifest-schema-version.ts). Note
|
|
4945
|
-
// `version` below is a DIFFERENT field — its `"2.0"` string is the
|
|
4946
|
-
// index-form discriminator (`isIndexManifest`), not a compatibility gate.
|
|
4947
|
-
schemaVersion: z.number().int().positive().optional(),
|
|
4948
|
-
version: z.string().optional(),
|
|
4949
|
-
description: z.string(),
|
|
4950
|
-
system: z.string().optional(),
|
|
4951
|
-
scope: z.string().optional(),
|
|
4952
|
-
architecture: z.string().optional(),
|
|
4953
|
-
planes: z.record(z.array(z.string())).optional(),
|
|
4954
|
-
bounded_contexts: z.array(z.object({
|
|
4955
|
-
name: z.string(),
|
|
4956
|
-
type: BoundedContextTypeSchema.optional(),
|
|
4957
|
-
plane: PlaneTypeSchema.optional(),
|
|
4958
|
-
status: StatusTypeSchema.optional(),
|
|
4959
|
-
file: z.string(),
|
|
4960
|
-
frozen_since: z.string().optional()
|
|
4961
|
-
})).optional(),
|
|
4962
|
-
apps: z.array(z.object({
|
|
4963
|
-
name: z.string(),
|
|
4964
|
-
file: z.string().optional()
|
|
4965
|
-
})).optional(),
|
|
4966
|
-
invariants: z.record(z.string()).optional(),
|
|
4967
|
-
governance: z.record(z.string()).optional(),
|
|
4968
|
-
agent_instructions: z.record(z.unknown()).optional(),
|
|
4969
|
-
relationship_patterns: z.record(z.object({
|
|
4970
|
-
description: z.string(),
|
|
4971
|
-
acl_required: z.union([z.boolean(), z.literal("optional")]).optional(),
|
|
4972
|
-
linter: z.string().optional()
|
|
4973
|
-
})).optional(),
|
|
4974
|
-
mvk: z.record(z.unknown()).optional(),
|
|
4975
|
-
cross_context: z.array(CrossContextEdgeSchema).optional(),
|
|
4976
|
-
workspace_config: z.string().optional(),
|
|
4977
|
-
legacy_config: z.string().optional()
|
|
4978
|
-
}).strict().refine((data) => {
|
|
4979
|
-
const contexts = data.bounded_contexts ?? [];
|
|
4980
|
-
return contexts.every((ctx) => {
|
|
4981
|
-
if (ctx.plane && ctx.file) {
|
|
4982
|
-
return ctx.file.startsWith(`contexts/${ctx.plane}/`);
|
|
4983
|
-
}
|
|
4984
|
-
return true;
|
|
4985
|
-
});
|
|
4986
|
-
}, {
|
|
4987
|
-
message: "Context plane does not match file path subdirectory",
|
|
4988
|
-
path: ["bounded_contexts"]
|
|
4989
|
-
});
|
|
4990
|
-
var ManifestSchema = z.object({
|
|
4991
|
-
// Toolchain-compatibility stamp (positive int; absent = legacy). NOT the
|
|
4992
|
-
// freeform `version` string below. Compatibility is asserted against the
|
|
4993
|
-
// RAW yaml BEFORE this `.strict()` parse (assertSupportedSchemaVersion in
|
|
4994
|
-
// manifest-schema-version.ts) — this entry only keeps strict mode from
|
|
4995
|
-
// rejecting stamped manifests as carrying an unknown key.
|
|
4996
|
-
schemaVersion: z.number().int().positive().optional(),
|
|
4997
|
-
version: z.string().optional(),
|
|
4998
|
-
description: z.string().optional(),
|
|
4999
|
-
system: z.string().optional(),
|
|
5000
|
-
scope: z.string().optional(),
|
|
5001
|
-
// Structured workspace metadata (the canonical `workspace:` block, also the
|
|
5002
|
-
// first block in the few-shot examples). `system`/`scope` above are derived
|
|
5003
|
-
// from `workspace.name`; `workspace.description` is the only carrier of the
|
|
5004
|
-
// human-readable intent. Emitted by `draftToManifest` so the generated
|
|
5005
|
-
// manifest survives `parseManifestToWizardData`'s strict parse on the
|
|
5006
|
-
// "Use this manifest" path. Optional — legacy/hand-written manifests omit it.
|
|
5007
|
-
workspace: z.object({
|
|
5008
|
-
name: z.string(),
|
|
5009
|
-
description: z.string()
|
|
5010
|
-
}).optional(),
|
|
5011
|
-
architecture: z.string().optional(),
|
|
5012
|
-
// The wizard records the chosen workspace template (e.g. "strict-enterprise")
|
|
5013
|
-
// alongside `architecture`; persisted into .architecture/manifest.yaml.
|
|
5014
|
-
workspaceTemplate: z.string().optional(),
|
|
5015
|
-
planes: z.record(z.array(z.string())).optional(),
|
|
5016
|
-
monorepo: z.record(z.unknown()).optional(),
|
|
5017
|
-
generator: z.record(z.unknown()).optional(),
|
|
5018
|
-
mvk: z.record(z.unknown()).optional(),
|
|
5019
|
-
invariants: z.record(z.string()).optional(),
|
|
5020
|
-
governance: z.record(z.string()).optional(),
|
|
5021
|
-
agent_instructions: z.record(z.unknown()).optional(),
|
|
5022
|
-
relationship_patterns: z.record(z.object({
|
|
5023
|
-
description: z.string(),
|
|
5024
|
-
acl_required: z.union([z.boolean(), z.literal("optional")]).optional(),
|
|
5025
|
-
linter: z.string().optional()
|
|
5026
|
-
})).optional(),
|
|
5027
|
-
bounded_contexts: z.array(BoundedContextSchema),
|
|
5028
|
-
apps: z.array(AppSchema).optional(),
|
|
5029
|
-
cross_context: z.array(CrossContextEdgeSchema).optional(),
|
|
5030
|
-
context_mappings: z.array(z.object({
|
|
5031
|
-
upstream: z.string(),
|
|
5032
|
-
downstream: z.string(),
|
|
5033
|
-
pattern: z.string().optional(),
|
|
5034
|
-
mechanism: z.string().optional(),
|
|
5035
|
-
notes: z.string().optional(),
|
|
5036
|
-
events: z.array(z.string()).optional()
|
|
5037
|
-
})).optional(),
|
|
5038
|
-
workspaceDefaults: z.record(z.unknown()).optional(),
|
|
5039
|
-
// Both side-car pointers. `mergeSplitManifest` resolves `workspace_config`
|
|
5040
|
-
// into the `monorepo`/`generator` blocks above and then carries the pointer
|
|
5041
|
-
// through with every other index key, so the merged (flat) form has to
|
|
5042
|
-
// accept it — this schema is `.strict()`, and the merge output is re-parsed
|
|
5043
|
-
// against it (sync's `validateManifest`, `parseManifestToWizardData`).
|
|
5044
|
-
workspace_config: z.string().optional(),
|
|
5045
|
-
legacy_config: z.string().optional()
|
|
5046
|
-
}).strict();
|
|
5047
|
-
|
|
5048
|
-
// ../project-configuration/dist/domain/model/manifest-schema/manifest-schema-version.js
|
|
5049
|
-
var CURRENT_MANIFEST_SCHEMA_VERSION = 1;
|
|
5050
|
-
function readManifestSchemaVersion(parsed) {
|
|
5051
|
-
if (parsed === null || typeof parsed !== "object")
|
|
5052
|
-
return void 0;
|
|
5053
|
-
const raw = parsed.schemaVersion;
|
|
5054
|
-
if (raw === void 0)
|
|
5055
|
-
return void 0;
|
|
5056
|
-
if (typeof raw !== "number" || !Number.isInteger(raw) || raw < 1) {
|
|
5057
|
-
throw new Error(`Invalid manifest schemaVersion: expected a positive integer, got ${JSON.stringify(raw)}.`);
|
|
5058
|
-
}
|
|
5059
|
-
return raw;
|
|
5060
|
-
}
|
|
5061
|
-
function assertSupportedSchemaVersion(parsed) {
|
|
5062
|
-
const version = readManifestSchemaVersion(parsed);
|
|
5063
|
-
if (version === void 0)
|
|
5064
|
-
return;
|
|
5065
|
-
if (version > CURRENT_MANIFEST_SCHEMA_VERSION) {
|
|
5066
|
-
throw new Error(`Manifest schemaVersion ${version} is newer than this toolchain supports (reads ≤ ${CURRENT_MANIFEST_SCHEMA_VERSION}). This manifest requires a newer @hexagen-monaco/sync — upgrade it. (Upgrading is always safe: a newer toolchain reads every older manifest, and \`hexagen manifest migrate\` brings one forward on demand.)`);
|
|
5067
|
-
}
|
|
5068
|
-
}
|
|
5069
|
-
|
|
5070
|
-
// ../project-configuration/dist/domain/model/manifest-schema/is-index-manifest.js
|
|
5071
|
-
function isIndexManifest(parsed) {
|
|
5072
|
-
if (typeof parsed !== "object" || parsed === null) {
|
|
5073
|
-
return false;
|
|
5074
|
-
}
|
|
5075
|
-
const record = parsed;
|
|
5076
|
-
if (record.version !== "2.0") {
|
|
5077
|
-
return false;
|
|
5078
|
-
}
|
|
5079
|
-
const contexts = record.bounded_contexts;
|
|
5080
|
-
if (!Array.isArray(contexts)) {
|
|
5081
|
-
return false;
|
|
5082
|
-
}
|
|
5083
|
-
return contexts.some((entry) => typeof entry === "object" && entry !== null && typeof entry.file === "string");
|
|
5084
|
-
}
|
|
5085
|
-
var WorkspaceGovernanceSchema = z.object({
|
|
5086
|
-
workspaceName: z.string().min(1, "Workspace name is required"),
|
|
5087
|
-
workspaceTemplate: z.enum(["modular-monolith", "strict-enterprise", "micro-frontend"]).default("modular-monolith"),
|
|
5088
|
-
workspaceDescription: z.string().optional(),
|
|
5089
|
-
packageManager: z.enum(["yarn", "pnpm", "bun"]).default("yarn"),
|
|
5090
|
-
topologyStrictness: z.enum(["strict", "flexible"]).default("flexible"),
|
|
5091
|
-
namespacePrefix: z.string().default("@hexagen"),
|
|
5092
|
-
namingConventions: z.object({
|
|
5093
|
-
contextDirectoryPattern: z.string().default("packages/"),
|
|
5094
|
-
adapterSuffix: z.string().default(".adapter.ts")
|
|
5095
|
-
}).default({
|
|
5096
|
-
contextDirectoryPattern: "packages/",
|
|
5097
|
-
adapterSuffix: ".adapter.ts"
|
|
5098
|
-
})
|
|
5099
|
-
});
|
|
5100
|
-
var PortConfigurationSchema = z.object({
|
|
5101
|
-
inboundPorts: z.array(z.enum([
|
|
5102
|
-
"rest-controller",
|
|
5103
|
-
"graphql-resolver",
|
|
5104
|
-
"event-listener",
|
|
5105
|
-
"cli-command"
|
|
5106
|
-
])).default([]),
|
|
5107
|
-
outboundPorts: z.array(z.enum([
|
|
5108
|
-
"relational-db",
|
|
5109
|
-
"document-db",
|
|
5110
|
-
"external-service-client",
|
|
5111
|
-
"message-publisher"
|
|
5112
|
-
])).default([])
|
|
5113
|
-
});
|
|
5114
|
-
var PeerContextMappingSchema = z.object({
|
|
5115
|
-
consumerContext: z.string(),
|
|
5116
|
-
providerContext: z.string(),
|
|
5117
|
-
integrationPattern: z.enum(["open-host", "acl"]),
|
|
5118
|
-
communicationBoundary: z.enum(["in-process", "networked"])
|
|
5119
|
-
});
|
|
5120
|
-
var BoundedContextSchema2 = z.object({
|
|
5121
|
-
id: z.string(),
|
|
5122
|
-
name: z.string().min(1, "Please enter a name for this bounded context (e.g., 'UserService', 'OrderProcessing')"),
|
|
5123
|
-
description: z.string().optional(),
|
|
5124
|
-
// ADR-0041: `infrastructureTarget` (API backend) and `uiFramework` (below)
|
|
5125
|
-
// are PROJECT-LEVEL choices managed by the wizard's Applications step, which
|
|
5126
|
-
// fans a single selection out to every context. They persist per-context (the
|
|
5127
|
-
// source of truth `deriveApps` reads), but are NOT direct per-context input —
|
|
5128
|
-
// do not re-add per-context UI/API editing without revisiting ADR-0041.
|
|
5129
|
-
// `"none"` = the project opts out of a separate API backend (UI-only, e.g. a
|
|
5130
|
-
// Next.js app with built-in routes); `deriveApps` then emits no `api` app.
|
|
5131
|
-
// Distinct from `undefined` (legacy/unset → defaults to the preset).
|
|
5132
|
-
infrastructureTarget: z.enum(["nestjs", "express", "serverless", "plain-ts", "nitro", "none"]).optional(),
|
|
5133
|
-
coreDomainEntities: z.array(z.string()).default([]),
|
|
5134
|
-
valueObjects: z.array(z.string()).default([]),
|
|
5135
|
-
domainEvents: z.array(z.string()).default([]),
|
|
5136
|
-
portConfiguration: PortConfigurationSchema,
|
|
5137
|
-
// Backward compatibility: support legacy fields
|
|
5138
|
-
apiFramework: z.enum(["Fastify", "Express", "NestJS"]).optional(),
|
|
5139
|
-
uiFramework: z.enum(["", "Next.js", "React Router", "Remix", "Angular", "Vue.js"]).optional().default(""),
|
|
5140
|
-
persistenceAdapter: z.enum(["", "Prisma", "TypeORM", "Mongoose", "Drizzle"]).optional().default(""),
|
|
5141
|
-
messagingAdapter: z.enum(["", "BullMQ", "Temporal", "RabbitMQ"]).optional().default(""),
|
|
5142
|
-
telemetryProvider: z.enum(["", "OpenTelemetry", "None", "Prometheus", "Winston"]).optional().default(""),
|
|
5143
|
-
externalApiPorts: z.array(z.string()).optional(),
|
|
5144
|
-
llmProviders: z.array(z.string()).optional(),
|
|
5145
|
-
blockchainNetworks: z.array(z.string()).optional(),
|
|
5146
|
-
authenticationProvider: z.string().optional(),
|
|
5147
|
-
emailService: z.string().optional(),
|
|
5148
|
-
paymentGateway: z.string().optional(),
|
|
5149
|
-
storageProvider: z.string().optional(),
|
|
5150
|
-
searchService: z.string().optional(),
|
|
5151
|
-
webhookEndpoints: z.array(z.string()).optional(),
|
|
5152
|
-
entities: z.array(z.string()).optional(),
|
|
5153
|
-
useCases: z.array(z.string()).optional()
|
|
5154
|
-
});
|
|
5155
|
-
var ExternalContextSchema = z.object({
|
|
5156
|
-
id: z.string(),
|
|
5157
|
-
name: z.string().min(1, "Peer context name is required"),
|
|
5158
|
-
relationshipType: z.enum(["U", "D", "ACL", "SK", "P", "OHS"]),
|
|
5159
|
-
isEventDriven: z.boolean().optional(),
|
|
5160
|
-
entityNames: z.array(z.string()).optional(),
|
|
5161
|
-
useCaseNames: z.array(z.string()).optional()
|
|
5162
|
-
});
|
|
5163
|
-
z.object({
|
|
5164
|
-
boundedContexts: z.array(BoundedContextSchema2).default([]),
|
|
5165
|
-
externalContexts: z.array(ExternalContextSchema).default([]),
|
|
5166
|
-
governance: WorkspaceGovernanceSchema.default({
|
|
5167
|
-
workspaceName: "@hexagen",
|
|
5168
|
-
workspaceTemplate: "modular-monolith",
|
|
5169
|
-
packageManager: "yarn",
|
|
5170
|
-
topologyStrictness: "flexible",
|
|
5171
|
-
namespacePrefix: "@hexagen",
|
|
5172
|
-
namingConventions: {
|
|
5173
|
-
contextDirectoryPattern: "packages/",
|
|
5174
|
-
adapterSuffix: ".adapter.ts"
|
|
5175
|
-
}
|
|
5176
|
-
}),
|
|
5177
|
-
peerMappings: z.array(PeerContextMappingSchema).default([]),
|
|
5178
|
-
/**
|
|
5179
|
-
* Per-template install-time answers collected by the wizard. Keyed by
|
|
5180
|
-
* template id; each value is a record of question-id → answer. The CLI
|
|
5181
|
-
* use case consumes this via its `overrideAnswers` parameter, so the
|
|
5182
|
-
* wizard can feed answers gathered in the UI directly into a non-
|
|
5183
|
-
* interactive install. Defaults to an empty object for projects that
|
|
5184
|
-
* are scaffolded without the per-template questions step.
|
|
5185
|
-
*/
|
|
5186
|
-
addOnsAnswers: z.record(z.string(), z.record(z.string(), z.union([z.string(), z.boolean(), z.array(z.string())]))).default({}),
|
|
5187
|
-
/**
|
|
5188
|
-
* Provenance of the project's `manifestYaml` (import round-trip integrity,
|
|
5189
|
-
* Item 1). `"imported"` = the manifest is the source of truth (accepted via
|
|
5190
|
-
* `parseManifestToWizardData` — file import or AI generation) and the wizard
|
|
5191
|
-
* projection (`wizardToManifest`) is LOSSY for it, so autosave/export paths
|
|
5192
|
-
* must never overwrite or impersonate the stored manifest. Deliberately
|
|
5193
|
-
* `.optional()` rather than `.default("wizard")`: absent ≡ `"wizard"`
|
|
5194
|
-
* everywhere (guards key on `=== "imported"` only), which keeps every
|
|
5195
|
-
* wizard-authored formState byte-identical to before this field existed and
|
|
5196
|
-
* lets the load perimeter distinguish "legacy record, provenance unknown"
|
|
5197
|
-
* (absent) from an explicit value when running its one-time discriminator.
|
|
5198
|
-
*/
|
|
5199
|
-
manifestSource: z.enum(["wizard", "imported"]).optional()
|
|
5200
|
-
});
|
|
5201
|
-
var MonorepoConfigSchema = z.object({
|
|
5202
|
-
packageManager: z.string().optional(),
|
|
5203
|
-
workspaces: z.array(z.string()).optional(),
|
|
5204
|
-
rootFiles: z.record(z.unknown()).optional(),
|
|
5205
|
-
archInvariants: z.record(z.unknown()).optional()
|
|
5206
|
-
}).passthrough();
|
|
5207
|
-
var GeneratorSyncSchema = z.object({
|
|
5208
|
-
layers: z.record(z.unknown()).optional(),
|
|
5209
|
-
packageJson: z.record(z.unknown()).optional(),
|
|
5210
|
-
stubs: z.record(z.unknown()).optional(),
|
|
5211
|
-
apps: z.record(z.unknown()).optional()
|
|
5212
|
-
}).passthrough();
|
|
5213
|
-
var GeneratorConfigSchema = z.object({
|
|
5214
|
-
version: z.string().optional(),
|
|
5215
|
-
sync: GeneratorSyncSchema.optional()
|
|
5216
|
-
}).passthrough();
|
|
5217
|
-
var WorkspaceConfigSchema = z.object({
|
|
5218
|
-
monorepo: MonorepoConfigSchema.optional(),
|
|
5219
|
-
generator: GeneratorConfigSchema.optional(),
|
|
5220
|
-
workspaceDefaults: z.record(z.unknown()).optional(),
|
|
5221
|
-
tsConfigRoot: z.record(z.unknown()).optional(),
|
|
5222
|
-
eslint: z.record(z.unknown()).optional(),
|
|
5223
|
-
rootFiles: z.record(z.unknown()).optional(),
|
|
5224
|
-
generatorConfig: z.record(z.unknown()).optional(),
|
|
5225
|
-
turboConfig: z.record(z.unknown()).optional()
|
|
5226
|
-
}).passthrough();
|
|
5227
|
-
function assertPathWithinArchitecture(workspaceRoot, relativePath) {
|
|
5228
|
-
const resolved = path7.resolve(workspaceRoot, ".architecture", relativePath);
|
|
5229
|
-
const archRoot = path7.resolve(workspaceRoot, ".architecture");
|
|
5230
|
-
try {
|
|
5231
|
-
const realResolved = realpathSync(resolved);
|
|
5232
|
-
const realArchRoot = realpathSync(archRoot);
|
|
5233
|
-
const archRootWithSep = realArchRoot + path7.sep;
|
|
5234
|
-
if (realResolved !== realArchRoot && !realResolved.startsWith(archRootWithSep)) {
|
|
5235
|
-
throw new Error(`Path traversal detected: "${relativePath}" resolves outside .architecture/`);
|
|
5236
|
-
}
|
|
5237
|
-
} catch (err3) {
|
|
5238
|
-
if (err3 instanceof Error && "code" in err3 && err3.code === "ENOENT") {
|
|
5239
|
-
let checkPath = archRoot;
|
|
5240
|
-
const pathSegments = path7.relative(archRoot, resolved).split(path7.sep);
|
|
5241
|
-
for (const segment of pathSegments) {
|
|
5242
|
-
checkPath = path7.join(checkPath, segment);
|
|
5243
|
-
try {
|
|
5244
|
-
const stat = lstatSync(checkPath);
|
|
5245
|
-
if (stat.isSymbolicLink()) {
|
|
5246
|
-
throw new Error(`Path traversal detected: "${relativePath}" contains a symbolic link`);
|
|
5247
|
-
}
|
|
5248
|
-
} catch (statErr) {
|
|
5249
|
-
if (statErr instanceof Error && "code" in statErr && statErr.code === "ENOENT") {
|
|
5250
|
-
break;
|
|
5251
|
-
}
|
|
5252
|
-
if (statErr instanceof Error && statErr.message.includes("Path traversal")) {
|
|
5253
|
-
throw statErr;
|
|
5254
|
-
}
|
|
5255
|
-
throw statErr;
|
|
5256
|
-
}
|
|
5257
|
-
}
|
|
5258
|
-
const archRootWithSep = archRoot + path7.sep;
|
|
5259
|
-
if (resolved !== archRoot && !resolved.startsWith(archRootWithSep)) {
|
|
5260
|
-
throw new Error(`Path traversal detected: "${relativePath}" resolves outside .architecture/`);
|
|
5261
|
-
}
|
|
5262
|
-
} else {
|
|
5263
|
-
throw err3;
|
|
5264
|
-
}
|
|
5265
|
-
}
|
|
5323
|
+
function assertPathWithinArchitecture(workspaceRoot, relativePath) {
|
|
5324
|
+
const resolved = path8.resolve(workspaceRoot, ".architecture", relativePath);
|
|
5325
|
+
const archRoot = path8.resolve(workspaceRoot, ".architecture");
|
|
5326
|
+
try {
|
|
5327
|
+
const realResolved = realpathSync(resolved);
|
|
5328
|
+
const realArchRoot = realpathSync(archRoot);
|
|
5329
|
+
const archRootWithSep = realArchRoot + path8.sep;
|
|
5330
|
+
if (realResolved !== realArchRoot && !realResolved.startsWith(archRootWithSep)) {
|
|
5331
|
+
throw new Error(`Path traversal detected: "${relativePath}" resolves outside .architecture/`);
|
|
5332
|
+
}
|
|
5333
|
+
} catch (err3) {
|
|
5334
|
+
if (err3 instanceof Error && "code" in err3 && err3.code === "ENOENT") {
|
|
5335
|
+
let checkPath = archRoot;
|
|
5336
|
+
const pathSegments = path8.relative(archRoot, resolved).split(path8.sep);
|
|
5337
|
+
for (const segment of pathSegments) {
|
|
5338
|
+
checkPath = path8.join(checkPath, segment);
|
|
5339
|
+
try {
|
|
5340
|
+
const stat = lstatSync(checkPath);
|
|
5341
|
+
if (stat.isSymbolicLink()) {
|
|
5342
|
+
throw new Error(`Path traversal detected: "${relativePath}" contains a symbolic link`);
|
|
5343
|
+
}
|
|
5344
|
+
} catch (statErr) {
|
|
5345
|
+
if (statErr instanceof Error && "code" in statErr && statErr.code === "ENOENT") {
|
|
5346
|
+
break;
|
|
5347
|
+
}
|
|
5348
|
+
if (statErr instanceof Error && statErr.message.includes("Path traversal")) {
|
|
5349
|
+
throw statErr;
|
|
5350
|
+
}
|
|
5351
|
+
throw statErr;
|
|
5352
|
+
}
|
|
5353
|
+
}
|
|
5354
|
+
const archRootWithSep = archRoot + path8.sep;
|
|
5355
|
+
if (resolved !== archRoot && !resolved.startsWith(archRootWithSep)) {
|
|
5356
|
+
throw new Error(`Path traversal detected: "${relativePath}" resolves outside .architecture/`);
|
|
5357
|
+
}
|
|
5358
|
+
} else {
|
|
5359
|
+
throw err3;
|
|
5360
|
+
}
|
|
5361
|
+
}
|
|
5266
5362
|
}
|
|
5267
5363
|
async function mergeSplitManifest(workspaceRoot, manifestPath) {
|
|
5268
5364
|
const content = await fs5.readFile(manifestPath, "utf-8");
|
|
@@ -5294,7 +5390,7 @@ async function mergeSplitManifest(workspaceRoot, manifestPath) {
|
|
|
5294
5390
|
};
|
|
5295
5391
|
if (typeof index.workspace_config === "string") {
|
|
5296
5392
|
assertPathWithinArchitecture(workspaceRoot, index.workspace_config);
|
|
5297
|
-
const sideCarPath =
|
|
5393
|
+
const sideCarPath = path8.join(workspaceRoot, ".architecture", index.workspace_config);
|
|
5298
5394
|
let sideCarContent;
|
|
5299
5395
|
try {
|
|
5300
5396
|
sideCarContent = await fs5.readFile(sideCarPath, "utf-8");
|
|
@@ -5320,7 +5416,7 @@ async function mergeSplitManifest(workspaceRoot, manifestPath) {
|
|
|
5320
5416
|
for (const entry of indexContexts) {
|
|
5321
5417
|
const indexEntry = entry;
|
|
5322
5418
|
assertPathWithinArchitecture(workspaceRoot, indexEntry.file);
|
|
5323
|
-
const contextFilePath =
|
|
5419
|
+
const contextFilePath = path8.join(workspaceRoot, ".architecture", indexEntry.file);
|
|
5324
5420
|
let contextContent;
|
|
5325
5421
|
try {
|
|
5326
5422
|
contextContent = await fs5.readFile(contextFilePath, "utf-8");
|
|
@@ -5355,7 +5451,7 @@ async function mergeSplitManifest(workspaceRoot, manifestPath) {
|
|
|
5355
5451
|
continue;
|
|
5356
5452
|
}
|
|
5357
5453
|
assertPathWithinArchitecture(workspaceRoot, appEntry.file);
|
|
5358
|
-
const appFilePath =
|
|
5454
|
+
const appFilePath = path8.join(workspaceRoot, ".architecture", appEntry.file);
|
|
5359
5455
|
let appContent;
|
|
5360
5456
|
try {
|
|
5361
5457
|
appContent = await fs5.readFile(appFilePath, "utf-8");
|
|
@@ -5377,14 +5473,14 @@ async function mergeSplitManifest(workspaceRoot, manifestPath) {
|
|
|
5377
5473
|
|
|
5378
5474
|
// src/sync-engine-init.ts
|
|
5379
5475
|
var __filename$1 = fileURLToPath(import.meta.url);
|
|
5380
|
-
var __dirname$1 =
|
|
5476
|
+
var __dirname$1 = path8.dirname(__filename$1);
|
|
5381
5477
|
function isENOENT(err3) {
|
|
5382
5478
|
return err3 instanceof Error && "code" in err3 && err3.code === "ENOENT";
|
|
5383
5479
|
}
|
|
5384
5480
|
async function findRootFrom(startDir, problems) {
|
|
5385
5481
|
let currentDir = startDir;
|
|
5386
|
-
while (currentDir !==
|
|
5387
|
-
const pkgPath =
|
|
5482
|
+
while (currentDir !== path8.parse(currentDir).root) {
|
|
5483
|
+
const pkgPath = path8.join(currentDir, "package.json");
|
|
5388
5484
|
try {
|
|
5389
5485
|
const pkgContent = await fs5.readFile(pkgPath, "utf-8");
|
|
5390
5486
|
const pkg = JSON.parse(pkgContent);
|
|
@@ -5397,7 +5493,7 @@ async function findRootFrom(startDir, problems) {
|
|
|
5397
5493
|
problems.push(new Error(`${pkgPath}: ${reason}`));
|
|
5398
5494
|
}
|
|
5399
5495
|
}
|
|
5400
|
-
currentDir =
|
|
5496
|
+
currentDir = path8.dirname(currentDir);
|
|
5401
5497
|
}
|
|
5402
5498
|
return null;
|
|
5403
5499
|
}
|
|
@@ -5422,7 +5518,7 @@ async function loadManifest(workspaceRoot, flags, options) {
|
|
|
5422
5518
|
return { manifest: options.manifest, manifestMissing: false };
|
|
5423
5519
|
}
|
|
5424
5520
|
const { logger, dryRun } = flags;
|
|
5425
|
-
const manifestPath =
|
|
5521
|
+
const manifestPath = path8.join(workspaceRoot, ".architecture/manifest.yaml");
|
|
5426
5522
|
logger.debug(`[debug] __dirname (ESM): ${__dirname$1}`);
|
|
5427
5523
|
logger.debug(`[debug] resolved workspaceRoot: ${workspaceRoot}`);
|
|
5428
5524
|
logger.debug(`[debug] resolved manifestPath: ${manifestPath}`);
|
|
@@ -5545,7 +5641,7 @@ var SyncEngine = class {
|
|
|
5545
5641
|
);
|
|
5546
5642
|
continue;
|
|
5547
5643
|
}
|
|
5548
|
-
const moduleDir =
|
|
5644
|
+
const moduleDir = path8.join(this.workspaceRoot, "packages", mod.name);
|
|
5549
5645
|
logger.info(
|
|
5550
5646
|
`Ensuring directories for module: ${mod.name} at ${moduleDir}`
|
|
5551
5647
|
);
|
|
@@ -5570,7 +5666,7 @@ var SyncEngine = class {
|
|
|
5570
5666
|
const stubs = createEmptyResult();
|
|
5571
5667
|
for (const module of modules) {
|
|
5572
5668
|
const moduleName = module.name;
|
|
5573
|
-
const moduleDir =
|
|
5669
|
+
const moduleDir = path8.join(this.workspaceRoot, "packages", moduleName);
|
|
5574
5670
|
if (moduleName.includes("..") || moduleName.includes("/") || moduleName.startsWith(".")) {
|
|
5575
5671
|
logger.warn(
|
|
5576
5672
|
`Skipping invalid module name (potential path traversal): ${moduleName}`
|
|
@@ -5641,8 +5737,12 @@ var SyncEngine = class {
|
|
|
5641
5737
|
};
|
|
5642
5738
|
}
|
|
5643
5739
|
async run() {
|
|
5740
|
+
resetPortAnalysisMemo();
|
|
5644
5741
|
const { logger, dryRun, allowDirty, mode } = this.partialConfig;
|
|
5645
5742
|
const start = Date.now();
|
|
5743
|
+
let gitStatusMs = null;
|
|
5744
|
+
let preflightMs = null;
|
|
5745
|
+
let linterMs = null;
|
|
5646
5746
|
let lockFile = null;
|
|
5647
5747
|
this.journal = new SyncJournal();
|
|
5648
5748
|
this.failures = [];
|
|
@@ -5652,12 +5752,14 @@ var SyncEngine = class {
|
|
|
5652
5752
|
);
|
|
5653
5753
|
if (mode === "self-regen" && !allowDirty) {
|
|
5654
5754
|
try {
|
|
5755
|
+
const gitStart = Date.now();
|
|
5655
5756
|
const { stdout: gitStatus } = await execAsync2(
|
|
5656
5757
|
"git status --porcelain",
|
|
5657
5758
|
{
|
|
5658
5759
|
cwd: this.options?.targetRoot ?? process.cwd()
|
|
5659
5760
|
}
|
|
5660
5761
|
);
|
|
5762
|
+
gitStatusMs = Date.now() - gitStart;
|
|
5661
5763
|
if (gitStatus && gitStatus.trim().length > 0) {
|
|
5662
5764
|
logger.error(
|
|
5663
5765
|
"Git working tree is dirty. Commit or stash changes, or use --allow-dirty to proceed."
|
|
@@ -5718,10 +5820,15 @@ var SyncEngine = class {
|
|
|
5718
5820
|
}
|
|
5719
5821
|
}
|
|
5720
5822
|
if (mode === "self-regen") {
|
|
5721
|
-
|
|
5823
|
+
const preflightStart = Date.now();
|
|
5824
|
+
await ensureDependenciesBuilt(this.fullConfig, {
|
|
5825
|
+
skip: this.options?.noPreflight
|
|
5826
|
+
});
|
|
5827
|
+
preflightMs = Date.now() - preflightStart;
|
|
5722
5828
|
} else {
|
|
5723
5829
|
logger.info("Skipping preflight build (external mode)");
|
|
5724
5830
|
}
|
|
5831
|
+
const generatorsStart = Date.now();
|
|
5725
5832
|
const rootFilesResult = await generateRootFiles(
|
|
5726
5833
|
this.fullConfig,
|
|
5727
5834
|
this.report
|
|
@@ -5756,7 +5863,7 @@ var SyncEngine = class {
|
|
|
5756
5863
|
if (!moduleName || moduleName.includes("..") || moduleName.includes("/") || moduleName.startsWith(".")) {
|
|
5757
5864
|
continue;
|
|
5758
5865
|
}
|
|
5759
|
-
const moduleDir =
|
|
5866
|
+
const moduleDir = path8.join(this.workspaceRoot, "packages", moduleName);
|
|
5760
5867
|
const pass2 = await generateBarrels(
|
|
5761
5868
|
moduleDir,
|
|
5762
5869
|
this.fullConfig,
|
|
@@ -5766,6 +5873,7 @@ var SyncEngine = class {
|
|
|
5766
5873
|
mergeResult2(secondPassBarrels, pass2);
|
|
5767
5874
|
}
|
|
5768
5875
|
const barrels = mergeBarrelPasses(firstPassBarrels, secondPassBarrels);
|
|
5876
|
+
const generatorsMs = Date.now() - generatorsStart;
|
|
5769
5877
|
const rows = [
|
|
5770
5878
|
["RootFiles", rootFilesResult],
|
|
5771
5879
|
["ArchFiles", archFilesResult],
|
|
@@ -5798,14 +5906,23 @@ var SyncEngine = class {
|
|
|
5798
5906
|
runSummary.skipped += r.skipped.length;
|
|
5799
5907
|
runSummary.totalOps += r.totalOps;
|
|
5800
5908
|
}
|
|
5909
|
+
runSummary.files = buildDriftFiles(rows, this.workspaceRoot);
|
|
5801
5910
|
if (mode === "self-regen") {
|
|
5911
|
+
const linterStart = Date.now();
|
|
5802
5912
|
await runArchLinter(this.fullConfig);
|
|
5913
|
+
linterMs = Date.now() - linterStart;
|
|
5803
5914
|
await this.report.writeReport(this.fullConfig);
|
|
5804
5915
|
} else {
|
|
5805
5916
|
logger.info("Skipping arch-linter and report (external mode)");
|
|
5806
5917
|
}
|
|
5807
5918
|
const duration = Date.now() - start;
|
|
5808
5919
|
runSummary.durationMs = duration;
|
|
5920
|
+
runSummary.phaseTimingsMs = {
|
|
5921
|
+
gitStatus: gitStatusMs,
|
|
5922
|
+
preflight: preflightMs,
|
|
5923
|
+
generators: generatorsMs,
|
|
5924
|
+
linter: linterMs
|
|
5925
|
+
};
|
|
5809
5926
|
if (this.failures.length === 0) {
|
|
5810
5927
|
logger.info("\nSync completed successfully.");
|
|
5811
5928
|
} else {
|
|
@@ -5828,6 +5945,18 @@ Sync completed with ${this.failures.length} generator failure(s) — see the FAI
|
|
|
5828
5945
|
logger.error(`• ${f.row} : FAILED — ${f.message}`);
|
|
5829
5946
|
}
|
|
5830
5947
|
logger.info(`• Total ops : ${runSummary.totalOps}`);
|
|
5948
|
+
logger.info(`
|
|
5949
|
+
=== Phase Timings ===`);
|
|
5950
|
+
const phaseTimingRows = [
|
|
5951
|
+
["git status", gitStatusMs],
|
|
5952
|
+
["preflight", preflightMs],
|
|
5953
|
+
["generators", generatorsMs],
|
|
5954
|
+
["linter", linterMs]
|
|
5955
|
+
];
|
|
5956
|
+
for (const [label, value] of phaseTimingRows) {
|
|
5957
|
+
const formatted = value === null ? "skipped" : `${value}ms`;
|
|
5958
|
+
logger.info(`• ${label} : ${formatted}`);
|
|
5959
|
+
}
|
|
5831
5960
|
return runSummary;
|
|
5832
5961
|
} catch (err3) {
|
|
5833
5962
|
const message = err3 instanceof Error ? err3.message : "Unknown sync error";
|
|
@@ -5859,7 +5988,7 @@ Sync completed with ${this.failures.length} generator failure(s) — see the FAI
|
|
|
5859
5988
|
} else {
|
|
5860
5989
|
for (const f of outcome.failures) {
|
|
5861
5990
|
logger.error(
|
|
5862
|
-
`Rollback failed for ${
|
|
5991
|
+
`Rollback failed for ${path8.relative(this.workspaceRoot, f.path)}: intended to ${f.intended} — ${f.error}`
|
|
5863
5992
|
);
|
|
5864
5993
|
}
|
|
5865
5994
|
logger.error(
|
|
@@ -6000,7 +6129,7 @@ function err2(error) {
|
|
|
6000
6129
|
var execAsync3 = promisify(exec);
|
|
6001
6130
|
async function loadManifest2(workspaceRoot) {
|
|
6002
6131
|
try {
|
|
6003
|
-
const manifestPath =
|
|
6132
|
+
const manifestPath = path8.join(
|
|
6004
6133
|
workspaceRoot,
|
|
6005
6134
|
".architecture/manifest.yaml"
|
|
6006
6135
|
);
|
|
@@ -6041,7 +6170,7 @@ async function validateManifest2(workspaceRoot) {
|
|
|
6041
6170
|
}
|
|
6042
6171
|
async function saveManifest(workspaceRoot, manifest) {
|
|
6043
6172
|
try {
|
|
6044
|
-
const manifestPath =
|
|
6173
|
+
const manifestPath = path8.join(
|
|
6045
6174
|
workspaceRoot,
|
|
6046
6175
|
".architecture/manifest.yaml"
|
|
6047
6176
|
);
|
|
@@ -6053,6 +6182,6 @@ async function saveManifest(workspaceRoot, manifest) {
|
|
|
6053
6182
|
}
|
|
6054
6183
|
}
|
|
6055
6184
|
|
|
6056
|
-
export { DEFAULT_NAMING, DEFAULT_TEMPLATES, SyncEngine, createEmptyResult, err2 as err, isIndexManifest, loadManifest2 as loadManifest, mergeSplitManifest, ok2 as ok, parseArgs, portName, recordWriteStatus, sanitizeScope, saveManifest, validateManifest2 as validateManifest };
|
|
6185
|
+
export { DEFAULT_NAMING, DEFAULT_TEMPLATES, SyncEngine, buildDriftFiles, createEmptyResult, err2 as err, isIndexManifest, loadManifest2 as loadManifest, mergeSplitManifest, ok2 as ok, parseArgs, portName, recordWriteStatus, sanitizeScope, saveManifest, validateManifest2 as validateManifest };
|
|
6057
6186
|
//# sourceMappingURL=index.js.map
|
|
6058
6187
|
//# sourceMappingURL=index.js.map
|