@archpilotlabs/archpilot 0.0.10 → 0.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/archpilot-cli.js +421 -148
- package/package.json +1 -1
package/dist/archpilot-cli.js
CHANGED
|
@@ -215333,6 +215333,14 @@ function usesPythonImportParser(adapter) {
|
|
|
215333
215333
|
function supportsDependencyImportParsing(adapter) {
|
|
215334
215334
|
return usesTypeScriptParser(adapter) || usesJavaImportParser(adapter) || usesPhpImportParser(adapter) || usesGoImportParser(adapter) || usesPythonImportParser(adapter);
|
|
215335
215335
|
}
|
|
215336
|
+
async function pathExists4(targetPath) {
|
|
215337
|
+
try {
|
|
215338
|
+
await import_node_fs8.promises.access(targetPath);
|
|
215339
|
+
return true;
|
|
215340
|
+
} catch {
|
|
215341
|
+
return false;
|
|
215342
|
+
}
|
|
215343
|
+
}
|
|
215336
215344
|
async function readTextFileIfExists2(filePath) {
|
|
215337
215345
|
try {
|
|
215338
215346
|
return await import_node_fs8.promises.readFile(filePath, { encoding: "utf8" });
|
|
@@ -215352,7 +215360,7 @@ async function readPackageName(packageJsonPath) {
|
|
|
215352
215360
|
return void 0;
|
|
215353
215361
|
}
|
|
215354
215362
|
}
|
|
215355
|
-
async function buildWorkspacePackageAliasMap(moduleRoots) {
|
|
215363
|
+
async function buildWorkspacePackageAliasMap(workspaceRoot, moduleRoots) {
|
|
215356
215364
|
const aliases = [];
|
|
215357
215365
|
for (const [moduleId, moduleRoot] of [...moduleRoots.entries()].sort(
|
|
215358
215366
|
([left], [right]) => left.localeCompare(right)
|
|
@@ -215363,6 +215371,7 @@ async function buildWorkspacePackageAliasMap(moduleRoots) {
|
|
|
215363
215371
|
}
|
|
215364
215372
|
aliases.push({ packageName, moduleId, moduleRoot });
|
|
215365
215373
|
}
|
|
215374
|
+
aliases.push(...await buildTsConfigPathAliasMap(workspaceRoot, moduleRoots));
|
|
215366
215375
|
return aliases.sort((left, right) => {
|
|
215367
215376
|
const lengthCompare = right.packageName.length - left.packageName.length;
|
|
215368
215377
|
if (lengthCompare !== 0) {
|
|
@@ -215371,6 +215380,63 @@ async function buildWorkspacePackageAliasMap(moduleRoots) {
|
|
|
215371
215380
|
return left.packageName.localeCompare(right.packageName);
|
|
215372
215381
|
});
|
|
215373
215382
|
}
|
|
215383
|
+
async function buildTsConfigPathAliasMap(workspaceRoot, moduleRoots) {
|
|
215384
|
+
const contents = await readTextFileIfExists2(path8.join(workspaceRoot, "tsconfig.json"));
|
|
215385
|
+
if (!contents) {
|
|
215386
|
+
return [];
|
|
215387
|
+
}
|
|
215388
|
+
let paths;
|
|
215389
|
+
try {
|
|
215390
|
+
const parsed = JSON.parse(contents);
|
|
215391
|
+
paths = parsed.compilerOptions?.paths;
|
|
215392
|
+
} catch {
|
|
215393
|
+
return [];
|
|
215394
|
+
}
|
|
215395
|
+
if (!paths) {
|
|
215396
|
+
return [];
|
|
215397
|
+
}
|
|
215398
|
+
const aliases = [];
|
|
215399
|
+
for (const [aliasPattern, targetPatterns] of Object.entries(paths).sort(
|
|
215400
|
+
([left], [right]) => left.localeCompare(right)
|
|
215401
|
+
)) {
|
|
215402
|
+
if (!Array.isArray(targetPatterns)) {
|
|
215403
|
+
continue;
|
|
215404
|
+
}
|
|
215405
|
+
const aliasPrefix = aliasPattern.replace(/\/\*$/u, "");
|
|
215406
|
+
if (aliasPrefix.length === 0) {
|
|
215407
|
+
continue;
|
|
215408
|
+
}
|
|
215409
|
+
for (const targetPattern of targetPatterns) {
|
|
215410
|
+
if (typeof targetPattern !== "string" || targetPattern.trim().length === 0) {
|
|
215411
|
+
continue;
|
|
215412
|
+
}
|
|
215413
|
+
const isWildcard = /\/\*$/u.test(aliasPattern) && /\/\*$/u.test(targetPattern);
|
|
215414
|
+
const normalizedTarget = normalizePath2(targetPattern).replace(/\/\*$/u, "");
|
|
215415
|
+
const absoluteTarget = path8.join(workspaceRoot, ...normalizedTarget.split("/"));
|
|
215416
|
+
const moduleEntry = [...moduleRoots.entries()].filter(([, moduleRoot2]) => isPathInsideOrEqual(absoluteTarget, moduleRoot2)).sort((left, right) => right[1].length - left[1].length || left[0].localeCompare(right[0]))[0];
|
|
215417
|
+
if (!moduleEntry) {
|
|
215418
|
+
continue;
|
|
215419
|
+
}
|
|
215420
|
+
const [moduleId, moduleRoot] = moduleEntry;
|
|
215421
|
+
if (isWildcard) {
|
|
215422
|
+
aliases.push({
|
|
215423
|
+
packageName: aliasPrefix,
|
|
215424
|
+
moduleId,
|
|
215425
|
+
moduleRoot,
|
|
215426
|
+
targetRoot: absoluteTarget
|
|
215427
|
+
});
|
|
215428
|
+
continue;
|
|
215429
|
+
}
|
|
215430
|
+
aliases.push({
|
|
215431
|
+
packageName: aliasPrefix,
|
|
215432
|
+
moduleId,
|
|
215433
|
+
moduleRoot,
|
|
215434
|
+
targetFile: absoluteTarget
|
|
215435
|
+
});
|
|
215436
|
+
}
|
|
215437
|
+
}
|
|
215438
|
+
return aliases;
|
|
215439
|
+
}
|
|
215374
215440
|
function validateDependencyModuleRules(moduleName, value) {
|
|
215375
215441
|
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
215376
215442
|
throw new DependencyRulesConfigError(
|
|
@@ -215430,8 +215496,44 @@ async function readDependencyRulesConfig(workspaceRoot) {
|
|
|
215430
215496
|
}, {});
|
|
215431
215497
|
return { modules };
|
|
215432
215498
|
}
|
|
215433
|
-
async function findModuleRoots(workspaceRoot, modulesRootRelativePath = "src/modules") {
|
|
215434
|
-
|
|
215499
|
+
async function findModuleRoots(workspaceRoot, modulesRootRelativePath = "src/modules", architectureContract) {
|
|
215500
|
+
const discoveredModuleRoots = await discoverModuleRoots(
|
|
215501
|
+
workspaceRoot,
|
|
215502
|
+
modulesRootRelativePath
|
|
215503
|
+
);
|
|
215504
|
+
const moduleRoots = /* @__PURE__ */ new Map();
|
|
215505
|
+
const registryEntries = architectureContract?.modules ? Object.entries(architectureContract.modules).sort(
|
|
215506
|
+
([left], [right]) => left.localeCompare(right)
|
|
215507
|
+
) : [];
|
|
215508
|
+
for (const [moduleName, moduleReference] of registryEntries) {
|
|
215509
|
+
const configuredPath = moduleReference.path;
|
|
215510
|
+
if (!configuredPath || typeof configuredPath !== "string") {
|
|
215511
|
+
continue;
|
|
215512
|
+
}
|
|
215513
|
+
const normalizedConfiguredPath = normalizePath2(configuredPath);
|
|
215514
|
+
if (/\.[a-z0-9]+$/iu.test(normalizedConfiguredPath)) {
|
|
215515
|
+
continue;
|
|
215516
|
+
}
|
|
215517
|
+
const absolutePath = path8.join(
|
|
215518
|
+
workspaceRoot,
|
|
215519
|
+
...normalizedConfiguredPath.split("/")
|
|
215520
|
+
);
|
|
215521
|
+
try {
|
|
215522
|
+
const stats = await import_node_fs8.promises.stat(absolutePath);
|
|
215523
|
+
if (stats.isDirectory()) {
|
|
215524
|
+
moduleRoots.set(moduleName, absolutePath);
|
|
215525
|
+
}
|
|
215526
|
+
} catch {
|
|
215527
|
+
}
|
|
215528
|
+
}
|
|
215529
|
+
for (const [moduleName, moduleRoot] of discoveredModuleRoots.entries()) {
|
|
215530
|
+
if (!moduleRoots.has(moduleName)) {
|
|
215531
|
+
moduleRoots.set(moduleName, moduleRoot);
|
|
215532
|
+
}
|
|
215533
|
+
}
|
|
215534
|
+
return new Map(
|
|
215535
|
+
[...moduleRoots.entries()].sort(([left], [right]) => left.localeCompare(right))
|
|
215536
|
+
);
|
|
215435
215537
|
}
|
|
215436
215538
|
async function buildExplicitStandaloneModulePathMap(workspaceRoot, architectureContract) {
|
|
215437
215539
|
const moduleRegistry = architectureContract?.modules && typeof architectureContract.modules === "object" && !Array.isArray(architectureContract.modules) ? architectureContract.modules : void 0;
|
|
@@ -215857,7 +215959,14 @@ async function resolveWorkspacePackageImportPath(importSpecifier, workspacePacka
|
|
|
215857
215959
|
const packageAlias = workspacePackageAliases.map((alias2) => ({
|
|
215858
215960
|
alias: alias2,
|
|
215859
215961
|
remainder: resolvePackageAliasRemainder(alias2.packageName, importSpecifier)
|
|
215860
|
-
})).
|
|
215962
|
+
})).sort((left, right) => {
|
|
215963
|
+
const leftCanResolveRemainder = left.remainder !== void 0 && left.remainder.length > 0 && left.alias.targetRoot !== void 0;
|
|
215964
|
+
const rightCanResolveRemainder = right.remainder !== void 0 && right.remainder.length > 0 && right.alias.targetRoot !== void 0;
|
|
215965
|
+
if (leftCanResolveRemainder !== rightCanResolveRemainder) {
|
|
215966
|
+
return leftCanResolveRemainder ? -1 : 1;
|
|
215967
|
+
}
|
|
215968
|
+
return 0;
|
|
215969
|
+
}).find(
|
|
215861
215970
|
(candidate) => candidate.remainder !== void 0
|
|
215862
215971
|
);
|
|
215863
215972
|
if (!packageAlias) {
|
|
@@ -215865,7 +215974,13 @@ async function resolveWorkspacePackageImportPath(importSpecifier, workspacePacka
|
|
|
215865
215974
|
}
|
|
215866
215975
|
const { alias, remainder } = packageAlias;
|
|
215867
215976
|
if (remainder.length === 0) {
|
|
215868
|
-
return resolveImportPath(alias.moduleRoot, adapter);
|
|
215977
|
+
return resolveImportPath(alias.targetFile ?? alias.targetRoot ?? alias.moduleRoot, adapter);
|
|
215978
|
+
}
|
|
215979
|
+
if (alias.targetRoot) {
|
|
215980
|
+
return resolveImportPath(
|
|
215981
|
+
path8.join(alias.targetRoot, ...remainder.split("/").filter((segment) => segment.length > 0)),
|
|
215982
|
+
adapter
|
|
215983
|
+
);
|
|
215869
215984
|
}
|
|
215870
215985
|
return void 0;
|
|
215871
215986
|
}
|
|
@@ -215970,7 +216085,10 @@ async function resolveCrossModuleImport(workspaceRoot, modulesRootRelativePath,
|
|
|
215970
216085
|
const indexEntrypointCandidates = adapter.dependencyParsingFileExtensions.map(
|
|
215971
216086
|
(extension) => `index${extension}`
|
|
215972
216087
|
);
|
|
215973
|
-
const
|
|
216088
|
+
const nestedIndexEntrypointCandidates = adapter.dependencyParsingFileExtensions.flatMap(
|
|
216089
|
+
(extension) => [`src/index${extension}`, `public/index${extension}`]
|
|
216090
|
+
);
|
|
216091
|
+
const isPublicImport = indexEntrypointCandidates.includes(targetSubPath) || nestedIndexEntrypointCandidates.includes(targetSubPath) || adapter.publicEntrypointDirectoryNames.some(
|
|
215974
216092
|
(dirName) => targetSubPath.startsWith(`${dirName}/`)
|
|
215975
216093
|
);
|
|
215976
216094
|
return {
|
|
@@ -216248,9 +216366,87 @@ function isImportWithinPublicEntrypoints(resolvedTargetRelativePath, publicEntry
|
|
|
216248
216366
|
}
|
|
216249
216367
|
return false;
|
|
216250
216368
|
}
|
|
216251
|
-
function
|
|
216252
|
-
const
|
|
216253
|
-
|
|
216369
|
+
async function filterExistingPublicEntrypoints(workspaceRoot, publicEntrypoints) {
|
|
216370
|
+
const existingEntrypoints = [];
|
|
216371
|
+
for (const publicEntrypoint of normalizePathList([...publicEntrypoints])) {
|
|
216372
|
+
const absolutePath = path8.join(workspaceRoot, ...publicEntrypoint.split("/"));
|
|
216373
|
+
if (await pathExists4(absolutePath)) {
|
|
216374
|
+
existingEntrypoints.push(publicEntrypoint);
|
|
216375
|
+
}
|
|
216376
|
+
}
|
|
216377
|
+
return existingEntrypoints;
|
|
216378
|
+
}
|
|
216379
|
+
async function inferExistingPublicEntrypointsFromModuleRoot(workspaceRoot, moduleRoot) {
|
|
216380
|
+
if (!moduleRoot) {
|
|
216381
|
+
return [];
|
|
216382
|
+
}
|
|
216383
|
+
const candidateSubpaths = [
|
|
216384
|
+
"index.ts",
|
|
216385
|
+
"index.tsx",
|
|
216386
|
+
"index.js",
|
|
216387
|
+
"index.jsx",
|
|
216388
|
+
"src/index.ts",
|
|
216389
|
+
"src/index.tsx",
|
|
216390
|
+
"src/index.js",
|
|
216391
|
+
"src/index.jsx",
|
|
216392
|
+
"public/index.ts",
|
|
216393
|
+
"public/index.tsx",
|
|
216394
|
+
"public/index.js",
|
|
216395
|
+
"public/index.jsx"
|
|
216396
|
+
];
|
|
216397
|
+
const existingEntrypoints = [];
|
|
216398
|
+
for (const candidateSubpath of candidateSubpaths) {
|
|
216399
|
+
const candidatePath = path8.join(moduleRoot, ...candidateSubpath.split("/"));
|
|
216400
|
+
if (await pathExists4(candidatePath)) {
|
|
216401
|
+
existingEntrypoints.push(
|
|
216402
|
+
normalizePath2(path8.relative(workspaceRoot, candidatePath))
|
|
216403
|
+
);
|
|
216404
|
+
}
|
|
216405
|
+
}
|
|
216406
|
+
return existingEntrypoints.sort((left, right) => left.localeCompare(right));
|
|
216407
|
+
}
|
|
216408
|
+
async function resolveModulePublicEntrypoints(workspaceRoot, architectureContract, moduleName, targetContract, moduleRoots) {
|
|
216409
|
+
const registryPublicEntrypoints = architectureContract.modules[moduleName]?.publicEntrypoints ?? [];
|
|
216410
|
+
const explicitPublicEntrypoints = sortUnique2([
|
|
216411
|
+
...registryPublicEntrypoints,
|
|
216412
|
+
...targetContract.publicEntrypoints
|
|
216413
|
+
]);
|
|
216414
|
+
const existingExplicitEntrypoints = await filterExistingPublicEntrypoints(
|
|
216415
|
+
workspaceRoot,
|
|
216416
|
+
explicitPublicEntrypoints
|
|
216417
|
+
);
|
|
216418
|
+
if (existingExplicitEntrypoints.length > 0) {
|
|
216419
|
+
return existingExplicitEntrypoints;
|
|
216420
|
+
}
|
|
216421
|
+
return inferExistingPublicEntrypointsFromModuleRoot(
|
|
216422
|
+
workspaceRoot,
|
|
216423
|
+
moduleRoots.get(moduleName)
|
|
216424
|
+
);
|
|
216425
|
+
}
|
|
216426
|
+
function labelPublicEntrypoint(publicEntrypoint) {
|
|
216427
|
+
const normalizedEntrypoint = normalizePath2(publicEntrypoint);
|
|
216428
|
+
const fileName = normalizedEntrypoint.split("/").at(-1) ?? "";
|
|
216429
|
+
return /^index\.[cm]?[jt]sx?$/iu.test(fileName) ? `${fileName} public entrypoint` : "public entrypoint";
|
|
216430
|
+
}
|
|
216431
|
+
function describePublicEntrypointTargets(publicEntrypoints) {
|
|
216432
|
+
if (publicEntrypoints.length <= 1) {
|
|
216433
|
+
return publicEntrypoints[0] ?? "unknown public entrypoint";
|
|
216434
|
+
}
|
|
216435
|
+
return publicEntrypoints.join(", ");
|
|
216436
|
+
}
|
|
216437
|
+
async function describeModulePublicImportGuidance(workspaceRoot, moduleName, moduleRoots) {
|
|
216438
|
+
const moduleRoot = moduleRoots.get(moduleName);
|
|
216439
|
+
const inferredEntrypoints = await inferExistingPublicEntrypointsFromModuleRoot(
|
|
216440
|
+
workspaceRoot,
|
|
216441
|
+
moduleRoot
|
|
216442
|
+
);
|
|
216443
|
+
if (inferredEntrypoints.length > 0) {
|
|
216444
|
+
return `Use the public entrypoint at ${describePublicEntrypointTargets(inferredEntrypoints)} instead.`;
|
|
216445
|
+
}
|
|
216446
|
+
if (moduleRoot) {
|
|
216447
|
+
return `Use an existing public entrypoint under ${normalizePath2(path8.relative(workspaceRoot, moduleRoot))} instead.`;
|
|
216448
|
+
}
|
|
216449
|
+
return "Use an existing target module public entrypoint instead.";
|
|
216254
216450
|
}
|
|
216255
216451
|
function buildActualImportedModuleSetBySource(imports, registeredModuleIds) {
|
|
216256
216452
|
const bySource = /* @__PURE__ */ new Map();
|
|
@@ -216302,12 +216498,19 @@ function buildInboundDependencyMap(bySource, moduleIds) {
|
|
|
216302
216498
|
async function buildDependencyGraphSummary(workspaceRoot, architectureContract, options) {
|
|
216303
216499
|
const modulesRoot = options?.modulesRootRelativePath ?? resolveModulesRootFromContract(architectureContract);
|
|
216304
216500
|
const adapter = resolvePrimaryAdapterFromContract(architectureContract);
|
|
216305
|
-
const moduleRoots = await findModuleRoots(
|
|
216501
|
+
const moduleRoots = await findModuleRoots(
|
|
216502
|
+
workspaceRoot,
|
|
216503
|
+
modulesRoot,
|
|
216504
|
+
architectureContract
|
|
216505
|
+
);
|
|
216306
216506
|
const explicitStandaloneModuleByPath = await buildExplicitStandaloneModulePathMap(
|
|
216307
216507
|
workspaceRoot,
|
|
216308
216508
|
architectureContract
|
|
216309
216509
|
);
|
|
216310
|
-
const workspacePackageAliases = await buildWorkspacePackageAliasMap(
|
|
216510
|
+
const workspacePackageAliases = await buildWorkspacePackageAliasMap(
|
|
216511
|
+
workspaceRoot,
|
|
216512
|
+
moduleRoots
|
|
216513
|
+
);
|
|
216311
216514
|
const moduleIds = sortUnique2([...moduleRoots.keys(), ...explicitStandaloneModuleByPath.values()]);
|
|
216312
216515
|
const registeredModuleIds = new Set(moduleIds);
|
|
216313
216516
|
const imports = await collectCrossModuleImports(
|
|
@@ -216386,12 +216589,19 @@ async function validateDependencyContractBoundaries(workspaceRoot, architectureC
|
|
|
216386
216589
|
}
|
|
216387
216590
|
const modulesRoot = options.modulesRootRelativePath ?? resolveModulesRootFromContract(architectureContract);
|
|
216388
216591
|
const adapter = resolvePrimaryAdapterFromContract(architectureContract);
|
|
216389
|
-
const moduleRoots = await findModuleRoots(
|
|
216592
|
+
const moduleRoots = await findModuleRoots(
|
|
216593
|
+
workspaceRoot,
|
|
216594
|
+
modulesRoot,
|
|
216595
|
+
architectureContract
|
|
216596
|
+
);
|
|
216390
216597
|
const explicitStandaloneModuleByPath = await buildExplicitStandaloneModulePathMap(
|
|
216391
216598
|
workspaceRoot,
|
|
216392
216599
|
architectureContract
|
|
216393
216600
|
);
|
|
216394
|
-
const workspacePackageAliases = await buildWorkspacePackageAliasMap(
|
|
216601
|
+
const workspacePackageAliases = await buildWorkspacePackageAliasMap(
|
|
216602
|
+
workspaceRoot,
|
|
216603
|
+
moduleRoots
|
|
216604
|
+
);
|
|
216395
216605
|
const imports = await collectCrossModuleImports(
|
|
216396
216606
|
workspaceRoot,
|
|
216397
216607
|
modulesRoot,
|
|
@@ -216448,6 +216658,7 @@ async function validateDependencyContractBoundaries(workspaceRoot, architectureC
|
|
|
216448
216658
|
),
|
|
216449
216659
|
filePath: dependencyImport.sourceFileRelativePath,
|
|
216450
216660
|
line: dependencyImport.line,
|
|
216661
|
+
importSpecifier: dependencyImport.importSpecifier,
|
|
216451
216662
|
findingType: "module-dependency",
|
|
216452
216663
|
module: dependencyImport.sourceModule,
|
|
216453
216664
|
target: dependencyImport.targetModule
|
|
@@ -216470,6 +216681,7 @@ async function validateDependencyContractBoundaries(workspaceRoot, architectureC
|
|
|
216470
216681
|
),
|
|
216471
216682
|
filePath: dependencyImport.sourceFileRelativePath,
|
|
216472
216683
|
line: dependencyImport.line,
|
|
216684
|
+
importSpecifier: dependencyImport.importSpecifier,
|
|
216473
216685
|
findingType: "module-dependency",
|
|
216474
216686
|
module: dependencyImport.sourceModule,
|
|
216475
216687
|
target: dependencyImport.targetModule
|
|
@@ -216563,6 +216775,7 @@ async function validateDependencyContractBoundaries(workspaceRoot, architectureC
|
|
|
216563
216775
|
),
|
|
216564
216776
|
filePath: dependencyImport.sourceFileRelativePath,
|
|
216565
216777
|
line: dependencyImport.line,
|
|
216778
|
+
importSpecifier: dependencyImport.importSpecifier,
|
|
216566
216779
|
findingType: "module-dependency",
|
|
216567
216780
|
module: dependencyImport.sourceModule,
|
|
216568
216781
|
target: dependencyImport.targetModule
|
|
@@ -216570,42 +216783,31 @@ async function validateDependencyContractBoundaries(workspaceRoot, architectureC
|
|
|
216570
216783
|
}
|
|
216571
216784
|
continue;
|
|
216572
216785
|
}
|
|
216573
|
-
|
|
216574
|
-
|
|
216575
|
-
|
|
216576
|
-
|
|
216577
|
-
|
|
216578
|
-
|
|
216579
|
-
|
|
216580
|
-
|
|
216581
|
-
|
|
216582
|
-
|
|
216583
|
-
|
|
216584
|
-
`Module '${dependencyImport.sourceModule}' must import module '${dependencyImport.targetModule}' via its ${publicEntrypointLabel}: ${expectedEntrypoint}.`,
|
|
216585
|
-
{
|
|
216586
|
-
findingType: "module-dependency",
|
|
216587
|
-
module: dependencyImport.sourceModule,
|
|
216588
|
-
target: dependencyImport.targetModule
|
|
216589
|
-
}
|
|
216590
|
-
),
|
|
216591
|
-
filePath: dependencyImport.sourceFileRelativePath,
|
|
216592
|
-
line: dependencyImport.line,
|
|
216593
|
-
findingType: "module-dependency",
|
|
216594
|
-
module: dependencyImport.sourceModule,
|
|
216595
|
-
target: dependencyImport.targetModule
|
|
216596
|
-
});
|
|
216786
|
+
const publicEntrypoints = await resolveModulePublicEntrypoints(
|
|
216787
|
+
workspaceRoot,
|
|
216788
|
+
architectureContract,
|
|
216789
|
+
dependencyImport.targetModule,
|
|
216790
|
+
targetContract.contract,
|
|
216791
|
+
moduleRoots
|
|
216792
|
+
);
|
|
216793
|
+
if (publicEntrypoints.length === 0) {
|
|
216794
|
+
continue;
|
|
216795
|
+
}
|
|
216796
|
+
if (options.suppressPublicSurfaceFailuresForNonPublicImports === true && !dependencyImport.isPublicImport) {
|
|
216597
216797
|
continue;
|
|
216598
216798
|
}
|
|
216599
|
-
if (
|
|
216799
|
+
if (!isImportWithinPublicEntrypoints(
|
|
216600
216800
|
dependencyImport.resolvedTargetRelativePath,
|
|
216601
|
-
|
|
216801
|
+
publicEntrypoints
|
|
216602
216802
|
)) {
|
|
216803
|
+
const publicEntrypointLabel = labelPublicEntrypoint(publicEntrypoints[0] ?? "");
|
|
216804
|
+
const expectedEntrypoint = describePublicEntrypointTargets(publicEntrypoints);
|
|
216603
216805
|
failures.push({
|
|
216604
216806
|
result: makeValidationResult(
|
|
216605
216807
|
"AP-DEP-005",
|
|
216606
216808
|
"error",
|
|
216607
216809
|
false,
|
|
216608
|
-
`Module '${dependencyImport.sourceModule}'
|
|
216810
|
+
`Module '${dependencyImport.sourceModule}' must import module '${dependencyImport.targetModule}' via its ${publicEntrypointLabel}: ${expectedEntrypoint}.`,
|
|
216609
216811
|
{
|
|
216610
216812
|
findingType: "module-dependency",
|
|
216611
216813
|
module: dependencyImport.sourceModule,
|
|
@@ -216614,6 +216816,7 @@ async function validateDependencyContractBoundaries(workspaceRoot, architectureC
|
|
|
216614
216816
|
),
|
|
216615
216817
|
filePath: dependencyImport.sourceFileRelativePath,
|
|
216616
216818
|
line: dependencyImport.line,
|
|
216819
|
+
importSpecifier: dependencyImport.importSpecifier,
|
|
216617
216820
|
findingType: "module-dependency",
|
|
216618
216821
|
module: dependencyImport.sourceModule,
|
|
216619
216822
|
target: dependencyImport.targetModule
|
|
@@ -216718,12 +216921,19 @@ async function validateDependencyBoundaries(workspaceRoot, options) {
|
|
|
216718
216921
|
const parsedArchitectureContract = await loadArchitectureContract(workspaceRoot);
|
|
216719
216922
|
const adapter = resolvePrimaryAdapterFromContract(parsedArchitectureContract);
|
|
216720
216923
|
const modulesRootRelativePath = options.modulesRootRelativePath ?? resolveModulesRootFromContract(parsedArchitectureContract);
|
|
216721
|
-
const moduleRoots = await findModuleRoots(
|
|
216924
|
+
const moduleRoots = await findModuleRoots(
|
|
216925
|
+
workspaceRoot,
|
|
216926
|
+
modulesRootRelativePath,
|
|
216927
|
+
parsedArchitectureContract
|
|
216928
|
+
);
|
|
216722
216929
|
const explicitStandaloneModuleByPath = await buildExplicitStandaloneModulePathMap(
|
|
216723
216930
|
workspaceRoot,
|
|
216724
216931
|
parsedArchitectureContract
|
|
216725
216932
|
);
|
|
216726
|
-
const workspacePackageAliases = await buildWorkspacePackageAliasMap(
|
|
216933
|
+
const workspacePackageAliases = await buildWorkspacePackageAliasMap(
|
|
216934
|
+
workspaceRoot,
|
|
216935
|
+
moduleRoots
|
|
216936
|
+
);
|
|
216727
216937
|
const imports = await collectCrossModuleImports(
|
|
216728
216938
|
workspaceRoot,
|
|
216729
216939
|
modulesRootRelativePath,
|
|
@@ -216820,6 +217030,7 @@ async function validateDependencyBoundaries(workspaceRoot, options) {
|
|
|
216820
217030
|
),
|
|
216821
217031
|
filePath: violation.sourceFileRelativePath,
|
|
216822
217032
|
line: violation.line,
|
|
217033
|
+
importSpecifier: violation.importSpecifier,
|
|
216823
217034
|
findingType: "module-dependency",
|
|
216824
217035
|
module: violation.sourceModule,
|
|
216825
217036
|
target: violation.targetModule
|
|
@@ -216852,12 +217063,17 @@ async function validateDependencyBoundaries(workspaceRoot, options) {
|
|
|
216852
217063
|
});
|
|
216853
217064
|
} else {
|
|
216854
217065
|
for (const violation of violations) {
|
|
217066
|
+
const publicImportGuidance = await describeModulePublicImportGuidance(
|
|
217067
|
+
workspaceRoot,
|
|
217068
|
+
violation.targetModule,
|
|
217069
|
+
moduleRoots
|
|
217070
|
+
);
|
|
216855
217071
|
findings.push({
|
|
216856
217072
|
result: makeValidationResult(
|
|
216857
217073
|
"AP-DEP-003",
|
|
216858
217074
|
"error",
|
|
216859
217075
|
false,
|
|
216860
|
-
`${violation.sourceFileRelativePath}:${violation.line} imports non-public path "${violation.importSpecifier}" from module "${violation.targetModule}".
|
|
217076
|
+
`${violation.sourceFileRelativePath}:${violation.line} imports non-public path "${violation.importSpecifier}" from module "${violation.targetModule}". ${publicImportGuidance}`,
|
|
216861
217077
|
{
|
|
216862
217078
|
findingType: "module-dependency",
|
|
216863
217079
|
module: violation.sourceModule,
|
|
@@ -216866,6 +217082,7 @@ async function validateDependencyBoundaries(workspaceRoot, options) {
|
|
|
216866
217082
|
),
|
|
216867
217083
|
filePath: violation.sourceFileRelativePath,
|
|
216868
217084
|
line: violation.line,
|
|
217085
|
+
importSpecifier: violation.importSpecifier,
|
|
216869
217086
|
findingType: "module-dependency",
|
|
216870
217087
|
module: violation.sourceModule,
|
|
216871
217088
|
target: violation.targetModule
|
|
@@ -216880,12 +217097,19 @@ async function buildModuleDependencyGraphSnapshot(workspaceRoot, options) {
|
|
|
216880
217097
|
const parsedArchitectureContract = await loadArchitectureContract(workspaceRoot);
|
|
216881
217098
|
const adapter = resolvePrimaryAdapterFromContract(parsedArchitectureContract);
|
|
216882
217099
|
const modulesRootRelativePath = options?.modulesRootRelativePath ?? resolveModulesRootFromContract(parsedArchitectureContract);
|
|
216883
|
-
const moduleRoots = await findModuleRoots(
|
|
217100
|
+
const moduleRoots = await findModuleRoots(
|
|
217101
|
+
workspaceRoot,
|
|
217102
|
+
modulesRootRelativePath,
|
|
217103
|
+
parsedArchitectureContract
|
|
217104
|
+
);
|
|
216884
217105
|
const explicitStandaloneModuleByPath = await buildExplicitStandaloneModulePathMap(
|
|
216885
217106
|
workspaceRoot,
|
|
216886
217107
|
parsedArchitectureContract
|
|
216887
217108
|
);
|
|
216888
|
-
const workspacePackageAliases = await buildWorkspacePackageAliasMap(
|
|
217109
|
+
const workspacePackageAliases = await buildWorkspacePackageAliasMap(
|
|
217110
|
+
workspaceRoot,
|
|
217111
|
+
moduleRoots
|
|
217112
|
+
);
|
|
216889
217113
|
const discoveredModules = sortUnique2([
|
|
216890
217114
|
...moduleRoots.keys(),
|
|
216891
217115
|
...explicitStandaloneModuleByPath.values()
|
|
@@ -216979,7 +217203,7 @@ function normalizeStringArray(value) {
|
|
|
216979
217203
|
}
|
|
216980
217204
|
return normalizedValues;
|
|
216981
217205
|
}
|
|
216982
|
-
async function
|
|
217206
|
+
async function pathExists5(targetPath) {
|
|
216983
217207
|
try {
|
|
216984
217208
|
await import_node_fs9.promises.access(targetPath);
|
|
216985
217209
|
return true;
|
|
@@ -217115,7 +217339,7 @@ async function validateModuleContractIntegrity(workspaceRoot, contract, options)
|
|
|
217115
217339
|
if (!moduleReference.contract) {
|
|
217116
217340
|
continue;
|
|
217117
217341
|
}
|
|
217118
|
-
const exists = await
|
|
217342
|
+
const exists = await pathExists5(
|
|
217119
217343
|
toWorkspaceAbsolutePath(workspaceRoot, moduleReference.contract)
|
|
217120
217344
|
);
|
|
217121
217345
|
if (!exists) {
|
|
@@ -217151,7 +217375,7 @@ async function validateModuleContractIntegrity(workspaceRoot, contract, options)
|
|
|
217151
217375
|
}
|
|
217152
217376
|
const contractPath = moduleReference.contract;
|
|
217153
217377
|
const fullContractPath = toWorkspaceAbsolutePath(workspaceRoot, contractPath);
|
|
217154
|
-
if (!await
|
|
217378
|
+
if (!await pathExists5(fullContractPath)) {
|
|
217155
217379
|
continue;
|
|
217156
217380
|
}
|
|
217157
217381
|
const parsedContract = await readModuleContract(workspaceRoot, contractPath);
|
|
@@ -217210,7 +217434,7 @@ async function validateModuleContractIntegrity(workspaceRoot, contract, options)
|
|
|
217210
217434
|
}
|
|
217211
217435
|
const contractPath = moduleReference.contract;
|
|
217212
217436
|
const fullContractPath = toWorkspaceAbsolutePath(workspaceRoot, contractPath);
|
|
217213
|
-
if (!await
|
|
217437
|
+
if (!await pathExists5(fullContractPath)) {
|
|
217214
217438
|
continue;
|
|
217215
217439
|
}
|
|
217216
217440
|
const parsedContract = await readModuleContract(workspaceRoot, contractPath);
|
|
@@ -217568,7 +217792,7 @@ function hasKeywordMatch(record, keywords) {
|
|
|
217568
217792
|
const haystack = `${record.fileName} ${record.title}`.toLowerCase();
|
|
217569
217793
|
return keywords.some((keyword) => haystack.includes(keyword));
|
|
217570
217794
|
}
|
|
217571
|
-
function
|
|
217795
|
+
function pathExists6(targetPath) {
|
|
217572
217796
|
return (0, import_promises.access)(targetPath).then(() => true).catch(() => false);
|
|
217573
217797
|
}
|
|
217574
217798
|
function buildSummary(records) {
|
|
@@ -217593,7 +217817,7 @@ function createAdrValidationResult(input2) {
|
|
|
217593
217817
|
async function validateAdrEnforcement(workspaceRoot, config) {
|
|
217594
217818
|
const adrDirectoryRelativePath = await resolveAdrDirectoryRelativePath(workspaceRoot);
|
|
217595
217819
|
const adrDirectory = getAdrDirectoryPath(workspaceRoot, adrDirectoryRelativePath);
|
|
217596
|
-
const adrDirectoryExists = await
|
|
217820
|
+
const adrDirectoryExists = await pathExists6(adrDirectory);
|
|
217597
217821
|
if (!adrDirectoryExists) {
|
|
217598
217822
|
return {
|
|
217599
217823
|
results: [
|
|
@@ -217646,7 +217870,7 @@ async function validateAdrEnforcement(workspaceRoot, config) {
|
|
|
217646
217870
|
}
|
|
217647
217871
|
]
|
|
217648
217872
|
];
|
|
217649
|
-
const dependencyContextExists = await
|
|
217873
|
+
const dependencyContextExists = await pathExists6(path11.join(workspaceRoot, ".archpilot", "dependency-rules.json")) || await pathExists6(path11.join(workspaceRoot, ".archpilot", "contracts"));
|
|
217650
217874
|
const checksToRun = [
|
|
217651
217875
|
requiredCoverageChecks[0],
|
|
217652
217876
|
...dependencyContextExists ? [requiredCoverageChecks[1]] : [],
|
|
@@ -218157,13 +218381,6 @@ var overallSetupGapWarningPenalty = 1;
|
|
|
218157
218381
|
var overallSetupGapInfoPenalty = 1;
|
|
218158
218382
|
var minScore = 0;
|
|
218159
218383
|
var maxScore = 100;
|
|
218160
|
-
var crossModuleDependencyRuleIds = /* @__PURE__ */ new Set([
|
|
218161
|
-
"AP-DEP-002",
|
|
218162
|
-
"AP-DEP-003",
|
|
218163
|
-
"AP-DEP-004",
|
|
218164
|
-
"AP-DEP-005",
|
|
218165
|
-
"AP-DEP-010"
|
|
218166
|
-
]);
|
|
218167
218384
|
var crossModuleContractRuleIds = /* @__PURE__ */ new Set(["AP-DEP-004", "AP-DEP-005"]);
|
|
218168
218385
|
var cycleRuleIds = /* @__PURE__ */ new Set(["AP-DEP-001", "AP-DEP-008"]);
|
|
218169
218386
|
function clampScore(value) {
|
|
@@ -218217,6 +218434,22 @@ function getQualityPenaltyForResult(result) {
|
|
|
218217
218434
|
}
|
|
218218
218435
|
return base + getAdditionalQualityPenalty(result);
|
|
218219
218436
|
}
|
|
218437
|
+
function dedupeResultsByDeductionKey(results) {
|
|
218438
|
+
const seen = /* @__PURE__ */ new Set();
|
|
218439
|
+
const deduped = [];
|
|
218440
|
+
for (const result of results) {
|
|
218441
|
+
if (!result.deductionKey) {
|
|
218442
|
+
deduped.push(result);
|
|
218443
|
+
continue;
|
|
218444
|
+
}
|
|
218445
|
+
if (seen.has(result.deductionKey)) {
|
|
218446
|
+
continue;
|
|
218447
|
+
}
|
|
218448
|
+
seen.add(result.deductionKey);
|
|
218449
|
+
deduped.push(result);
|
|
218450
|
+
}
|
|
218451
|
+
return deduped;
|
|
218452
|
+
}
|
|
218220
218453
|
function getReadinessPenaltyForSetupGapSeverity(severity) {
|
|
218221
218454
|
if (severity === "error") {
|
|
218222
218455
|
return readinessSetupGapErrorPenalty;
|
|
@@ -218227,7 +218460,7 @@ function getReadinessPenaltyForSetupGapSeverity(severity) {
|
|
|
218227
218460
|
return readinessSetupGapInfoPenalty;
|
|
218228
218461
|
}
|
|
218229
218462
|
function deriveGovernanceRiskLevelFromResults(results) {
|
|
218230
|
-
const qualityFailures = results.filter(
|
|
218463
|
+
const qualityFailures = dedupeResultsByDeductionKey(results).filter(
|
|
218231
218464
|
(result) => !result.passed && (result.impact ?? "quality") === "quality"
|
|
218232
218465
|
);
|
|
218233
218466
|
const hasCriticalRule = qualityFailures.some(
|
|
@@ -218246,21 +218479,14 @@ function deriveGovernanceRiskLevelFromResults(results) {
|
|
|
218246
218479
|
}
|
|
218247
218480
|
function applyFinalScoreAdjustments(input2) {
|
|
218248
218481
|
let adjusted = input2.baseScore;
|
|
218249
|
-
const
|
|
218250
|
-
|
|
218251
|
-
).length;
|
|
218252
|
-
const crossModuleContractViolations = input2.results.filter(
|
|
218482
|
+
const uniqueResults = dedupeResultsByDeductionKey(input2.results);
|
|
218483
|
+
const crossModuleContractViolations = uniqueResults.filter(
|
|
218253
218484
|
(result) => !result.passed && (result.impact ?? "quality") === "quality" && typeof result.ruleId === "string" && crossModuleContractRuleIds.has(result.ruleId)
|
|
218254
218485
|
).length;
|
|
218255
|
-
const cycleViolations =
|
|
218486
|
+
const cycleViolations = uniqueResults.filter(
|
|
218256
218487
|
(result) => !result.passed && (result.impact ?? "quality") === "quality" && typeof result.ruleId === "string" && cycleRuleIds.has(result.ruleId)
|
|
218257
218488
|
).length;
|
|
218258
|
-
const blockingViolations = input2.results.filter(
|
|
218259
|
-
(result) => !result.passed && result.severity === "error" && (result.impact ?? "quality") === "quality"
|
|
218260
|
-
).length;
|
|
218261
|
-
adjusted -= Math.min(8, blockingViolations * 2);
|
|
218262
218489
|
adjusted -= Math.min(6, crossModuleContractViolations * 2);
|
|
218263
|
-
adjusted -= Math.min(4, crossModuleDependencyViolations);
|
|
218264
218490
|
adjusted -= Math.min(4, cycleViolations * 2);
|
|
218265
218491
|
const governanceRiskLevel = input2.context?.governanceRiskLevel ?? deriveGovernanceRiskLevelFromResults(input2.results);
|
|
218266
218492
|
if (governanceRiskLevel === "critical") {
|
|
@@ -219744,7 +219970,7 @@ function normalizeSqlTableName(raw) {
|
|
|
219744
219970
|
}
|
|
219745
219971
|
return trimmed;
|
|
219746
219972
|
}
|
|
219747
|
-
async function
|
|
219973
|
+
async function pathExists7(targetPath) {
|
|
219748
219974
|
try {
|
|
219749
219975
|
await import_node_fs19.promises.access(targetPath);
|
|
219750
219976
|
return true;
|
|
@@ -219765,7 +219991,7 @@ async function readTextFileIfReasonable(filePath) {
|
|
|
219765
219991
|
}
|
|
219766
219992
|
async function collectFilesRecursive(rootPath, includeFile, ignoredDirectoryNames8) {
|
|
219767
219993
|
const collected = [];
|
|
219768
|
-
if (!await
|
|
219994
|
+
if (!await pathExists7(rootPath)) {
|
|
219769
219995
|
return collected;
|
|
219770
219996
|
}
|
|
219771
219997
|
const stack = [rootPath];
|
|
@@ -220649,6 +220875,23 @@ function buildSetupGapDeductionKeyFromMessage(message) {
|
|
|
220649
220875
|
}
|
|
220650
220876
|
return void 0;
|
|
220651
220877
|
}
|
|
220878
|
+
function buildDependencyDeductionKey(result) {
|
|
220879
|
+
if (result.findingType !== "module-dependency") {
|
|
220880
|
+
return void 0;
|
|
220881
|
+
}
|
|
220882
|
+
if (typeof result.sourceFile !== "string" || typeof result.sourceLine !== "number" || typeof result.module !== "string" || typeof result.target !== "string") {
|
|
220883
|
+
return void 0;
|
|
220884
|
+
}
|
|
220885
|
+
return [
|
|
220886
|
+
"quality",
|
|
220887
|
+
result.id,
|
|
220888
|
+
result.module,
|
|
220889
|
+
result.target,
|
|
220890
|
+
result.sourceFile.replace(/\\/g, "/"),
|
|
220891
|
+
String(result.sourceLine),
|
|
220892
|
+
result.importSpecifier ?? ""
|
|
220893
|
+
].join("|");
|
|
220894
|
+
}
|
|
220652
220895
|
function classifyValidationResult(result) {
|
|
220653
220896
|
if (result.passed) {
|
|
220654
220897
|
return {
|
|
@@ -220676,7 +220919,7 @@ function classifyValidationResult(result) {
|
|
|
220676
220919
|
return {
|
|
220677
220920
|
kind: "violation",
|
|
220678
220921
|
scoreImpact: "quality",
|
|
220679
|
-
deductionKey: `quality:${result.id}:${normalizedMessage}`
|
|
220922
|
+
deductionKey: buildDependencyDeductionKey(result) ?? `quality:${result.id}:${normalizedMessage}`
|
|
220680
220923
|
};
|
|
220681
220924
|
}
|
|
220682
220925
|
function getRuleIdSet() {
|
|
@@ -221266,7 +221509,7 @@ function applyValidationExceptions(results, exceptions) {
|
|
|
221266
221509
|
approvedExceptions: dedupedApprovedExceptions
|
|
221267
221510
|
};
|
|
221268
221511
|
}
|
|
221269
|
-
async function
|
|
221512
|
+
async function pathExists8(targetPath) {
|
|
221270
221513
|
try {
|
|
221271
221514
|
await import_node_fs20.promises.access(targetPath);
|
|
221272
221515
|
return true;
|
|
@@ -221305,11 +221548,11 @@ async function readDependencyRulesRawConfig(workspaceRoot) {
|
|
|
221305
221548
|
async function resolveValidationConfigPath(workspaceRoot) {
|
|
221306
221549
|
const configDir = path21.join(workspaceRoot, ".archpilot");
|
|
221307
221550
|
const jsoncPath = path21.join(configDir, "validation-config.jsonc");
|
|
221308
|
-
if (await
|
|
221551
|
+
if (await pathExists8(jsoncPath)) {
|
|
221309
221552
|
return jsoncPath;
|
|
221310
221553
|
}
|
|
221311
221554
|
const jsonPath = path21.join(configDir, "validation-config.json");
|
|
221312
|
-
if (await
|
|
221555
|
+
if (await pathExists8(jsonPath)) {
|
|
221313
221556
|
return jsonPath;
|
|
221314
221557
|
}
|
|
221315
221558
|
return void 0;
|
|
@@ -221435,7 +221678,7 @@ async function validateApiStyle(workspaceRoot, contract, config, validationConfi
|
|
|
221435
221678
|
}
|
|
221436
221679
|
const openApiRelativePath = resolveOpenApiRelativePath(contract);
|
|
221437
221680
|
const openApiPath = path21.join(workspaceRoot, ...openApiRelativePath.split("/"));
|
|
221438
|
-
const exists = await
|
|
221681
|
+
const exists = await pathExists8(openApiPath);
|
|
221439
221682
|
if (openApiRequired) {
|
|
221440
221683
|
results.push({
|
|
221441
221684
|
id: ValidationRuleIds.API_OPENAPI_EXISTS,
|
|
@@ -221488,7 +221731,7 @@ async function validateTenantModel(workspaceRoot, contract, config, validationCo
|
|
|
221488
221731
|
if (config.tenantModel === "same_db_different_schema" && !isRuleDisabled(ValidationRuleIds.DOC_TENANT_DIFFERENT_SCHEMA_ADR, validationConfig)) {
|
|
221489
221732
|
const tenantModelAdrRelativePath = resolveTenantModelAdrRelativePath(contract);
|
|
221490
221733
|
const adrPath = path21.join(workspaceRoot, ...tenantModelAdrRelativePath.split("/"));
|
|
221491
|
-
const exists = await
|
|
221734
|
+
const exists = await pathExists8(adrPath);
|
|
221492
221735
|
results.push({
|
|
221493
221736
|
id: ValidationRuleIds.DOC_TENANT_DIFFERENT_SCHEMA_ADR,
|
|
221494
221737
|
severity: "warning",
|
|
@@ -221541,7 +221784,7 @@ async function validateArchitectureStyle(workspaceRoot, contract, validationConf
|
|
|
221541
221784
|
if (implementationProfile === "typescript-backend" && !isRuleDisabled(ValidationRuleIds.ARCH_OVERVIEW_ARTIFACT_EXISTS, validationConfig)) {
|
|
221542
221785
|
const overviewRelativePath = resolveOverviewRelativePath(contract);
|
|
221543
221786
|
const overviewPath = path21.join(workspaceRoot, ...overviewRelativePath.split("/"));
|
|
221544
|
-
const overviewExists = await
|
|
221787
|
+
const overviewExists = await pathExists8(overviewPath);
|
|
221545
221788
|
results.push({
|
|
221546
221789
|
id: ValidationRuleIds.ARCH_OVERVIEW_ARTIFACT_EXISTS,
|
|
221547
221790
|
severity: "error",
|
|
@@ -221553,7 +221796,7 @@ async function validateArchitectureStyle(workspaceRoot, contract, validationConf
|
|
|
221553
221796
|
const normalizeEntrypoint = (entry) => normalizeRelativePath2(entry.trim());
|
|
221554
221797
|
const hasDeclaredPublicEntrypoint = async (moduleName, entry) => {
|
|
221555
221798
|
const entryPath = path21.join(workspaceRoot, ...normalizeEntrypoint(entry).split("/"));
|
|
221556
|
-
return
|
|
221799
|
+
return pathExists8(entryPath);
|
|
221557
221800
|
};
|
|
221558
221801
|
const readModuleContractPublicEntrypoints = async (moduleName) => {
|
|
221559
221802
|
const registryEntry = contract.modules[moduleName];
|
|
@@ -221578,7 +221821,7 @@ async function validateArchitectureStyle(workspaceRoot, contract, validationConf
|
|
|
221578
221821
|
};
|
|
221579
221822
|
const modulesRootRelativePath2 = await getConfiguredModulesRoot(workspaceRoot, contract);
|
|
221580
221823
|
const modulesRoot = path21.join(workspaceRoot, ...modulesRootRelativePath2.split("/"));
|
|
221581
|
-
if (await
|
|
221824
|
+
if (await pathExists8(modulesRoot)) {
|
|
221582
221825
|
const hierarchicalModules = await discoverHierarchicalModuleRoots(
|
|
221583
221826
|
workspaceRoot,
|
|
221584
221827
|
modulesRootRelativePath2
|
|
@@ -221600,8 +221843,8 @@ async function validateArchitectureStyle(workspaceRoot, contract, validationConf
|
|
|
221600
221843
|
for (const moduleDirectory of moduleDirectories2) {
|
|
221601
221844
|
const moduleName = moduleDirectory.moduleName;
|
|
221602
221845
|
const moduleDir = path21.join(workspaceRoot, ...moduleDirectory.sourcePath.split("/"));
|
|
221603
|
-
const readmeExists = await
|
|
221604
|
-
const indexExists = await
|
|
221846
|
+
const readmeExists = await pathExists8(path21.join(moduleDir, "README.md"));
|
|
221847
|
+
const indexExists = await pathExists8(path21.join(moduleDir, "index.ts"));
|
|
221605
221848
|
const registryPublicEntrypoints = (contract.modules[moduleName]?.publicEntrypoints ?? []).filter((entry) => typeof entry === "string").map((entry) => normalizeEntrypoint(entry));
|
|
221606
221849
|
const contractPublicEntrypoints = await readModuleContractPublicEntrypoints(moduleName);
|
|
221607
221850
|
const declaredPublicEntrypoints = [
|
|
@@ -221648,7 +221891,7 @@ async function validateDatabaseArtifacts(workspaceRoot, contract, config, valida
|
|
|
221648
221891
|
}
|
|
221649
221892
|
const sqlBaselineRelativePath = resolveSqlBaselineRelativePath(contract);
|
|
221650
221893
|
const sqlBaselinePath = path21.join(workspaceRoot, ...sqlBaselineRelativePath.split("/"));
|
|
221651
|
-
const exists = await
|
|
221894
|
+
const exists = await pathExists8(sqlBaselinePath);
|
|
221652
221895
|
results.push({
|
|
221653
221896
|
id: ValidationRuleIds.DB_SQL_BASELINE_EXISTS,
|
|
221654
221897
|
severity: "error",
|
|
@@ -221657,6 +221900,34 @@ async function validateDatabaseArtifacts(workspaceRoot, contract, config, valida
|
|
|
221657
221900
|
});
|
|
221658
221901
|
return results;
|
|
221659
221902
|
}
|
|
221903
|
+
function buildDependencyFindingStableKey(finding) {
|
|
221904
|
+
if (!finding.result.id || !finding.module || !finding.target || !finding.filePath || finding.line === void 0 || !finding.importSpecifier) {
|
|
221905
|
+
return void 0;
|
|
221906
|
+
}
|
|
221907
|
+
return [
|
|
221908
|
+
finding.result.id,
|
|
221909
|
+
finding.module,
|
|
221910
|
+
finding.target,
|
|
221911
|
+
finding.filePath.replace(/\\/g, "/"),
|
|
221912
|
+
String(finding.line),
|
|
221913
|
+
finding.importSpecifier
|
|
221914
|
+
].join("|");
|
|
221915
|
+
}
|
|
221916
|
+
function dedupeDependencyFindings(findings) {
|
|
221917
|
+
const seen = /* @__PURE__ */ new Set();
|
|
221918
|
+
const deduped = [];
|
|
221919
|
+
for (const finding of findings) {
|
|
221920
|
+
const stableKey = buildDependencyFindingStableKey(finding);
|
|
221921
|
+
if (stableKey && seen.has(stableKey)) {
|
|
221922
|
+
continue;
|
|
221923
|
+
}
|
|
221924
|
+
if (stableKey) {
|
|
221925
|
+
seen.add(stableKey);
|
|
221926
|
+
}
|
|
221927
|
+
deduped.push(finding);
|
|
221928
|
+
}
|
|
221929
|
+
return deduped;
|
|
221930
|
+
}
|
|
221660
221931
|
async function validateModuleDependencies(workspaceRoot, contract, validationConfig, onDependencyConfigError, dependencyRulesConfigOverride) {
|
|
221661
221932
|
const modulesRootRelativePath = await getConfiguredModulesRoot(workspaceRoot, contract);
|
|
221662
221933
|
const dependencyRuleChecks = {
|
|
@@ -221696,10 +221967,11 @@ async function validateModuleDependencies(workspaceRoot, contract, validationCon
|
|
|
221696
221967
|
}),
|
|
221697
221968
|
validateDependencyContractBoundaries(workspaceRoot, contract, {
|
|
221698
221969
|
...contractDependencyRuleChecks,
|
|
221699
|
-
modulesRootRelativePath
|
|
221970
|
+
modulesRootRelativePath,
|
|
221971
|
+
suppressPublicSurfaceFailuresForNonPublicImports: dependencyRuleChecks.checkNonPublicImports
|
|
221700
221972
|
})
|
|
221701
221973
|
]);
|
|
221702
|
-
const findings = [...legacyFindings, ...contractFindings];
|
|
221974
|
+
const findings = dedupeDependencyFindings([...legacyFindings, ...contractFindings]);
|
|
221703
221975
|
const results = [];
|
|
221704
221976
|
for (const finding of findings) {
|
|
221705
221977
|
const resultWithSource = {
|
|
@@ -221710,7 +221982,8 @@ async function validateModuleDependencies(workspaceRoot, contract, validationCon
|
|
|
221710
221982
|
...finding.api ? { api: finding.api } : {},
|
|
221711
221983
|
...finding.findingType ? { findingType: finding.findingType } : {},
|
|
221712
221984
|
...finding.filePath ? { sourceFile: finding.filePath, filePath: finding.filePath } : {},
|
|
221713
|
-
...finding.line !== void 0 ? { sourceLine: finding.line } : {}
|
|
221985
|
+
...finding.line !== void 0 ? { sourceLine: finding.line } : {},
|
|
221986
|
+
...finding.importSpecifier ? { importSpecifier: finding.importSpecifier } : {}
|
|
221714
221987
|
};
|
|
221715
221988
|
results.push(resultWithSource);
|
|
221716
221989
|
}
|
|
@@ -221838,7 +222111,7 @@ async function validateDependencyGraphIsolation(workspaceRoot, contract, depende
|
|
|
221838
222111
|
continue;
|
|
221839
222112
|
}
|
|
221840
222113
|
const moduleDirectoryPath = path21.join(workspaceRoot, ...registryEntry.path.split("/"));
|
|
221841
|
-
const moduleDirectoryExists = await
|
|
222114
|
+
const moduleDirectoryExists = await pathExists8(moduleDirectoryPath);
|
|
221842
222115
|
if (!moduleDirectoryExists) {
|
|
221843
222116
|
continue;
|
|
221844
222117
|
}
|
|
@@ -224408,7 +224681,7 @@ var import_node_fs22 = require("node:fs");
|
|
|
224408
224681
|
async function ensureDirectory(directoryPath) {
|
|
224409
224682
|
await import_node_fs22.promises.mkdir(directoryPath, { recursive: true });
|
|
224410
224683
|
}
|
|
224411
|
-
async function
|
|
224684
|
+
async function pathExists9(targetPath) {
|
|
224412
224685
|
try {
|
|
224413
224686
|
await import_node_fs22.promises.access(targetPath);
|
|
224414
224687
|
return true;
|
|
@@ -224417,7 +224690,7 @@ async function pathExists8(targetPath) {
|
|
|
224417
224690
|
}
|
|
224418
224691
|
}
|
|
224419
224692
|
async function createFileIfMissing(filePath, content) {
|
|
224420
|
-
if (await
|
|
224693
|
+
if (await pathExists9(filePath)) {
|
|
224421
224694
|
return false;
|
|
224422
224695
|
}
|
|
224423
224696
|
await ensureDirectory(path23.dirname(filePath));
|
|
@@ -224525,7 +224798,7 @@ async function previewArch001(context) {
|
|
|
224525
224798
|
];
|
|
224526
224799
|
const filesCreated = [];
|
|
224527
224800
|
for (const targetPath of targetPaths) {
|
|
224528
|
-
if (!await
|
|
224801
|
+
if (!await pathExists9(targetPath)) {
|
|
224529
224802
|
filesCreated.push(relative5(targetPath, context.workspaceRoot));
|
|
224530
224803
|
}
|
|
224531
224804
|
}
|
|
@@ -224546,7 +224819,7 @@ async function applyArch001(context) {
|
|
|
224546
224819
|
];
|
|
224547
224820
|
const filesCreated = [];
|
|
224548
224821
|
for (const targetPath of targetPaths) {
|
|
224549
|
-
const existed = await
|
|
224822
|
+
const existed = await pathExists9(targetPath);
|
|
224550
224823
|
await ensureDirectory(targetPath);
|
|
224551
224824
|
if (!existed) {
|
|
224552
224825
|
filesCreated.push(relative5(targetPath, context.workspaceRoot));
|
|
@@ -224562,8 +224835,8 @@ async function applyArch001(context) {
|
|
|
224562
224835
|
async function previewArch003(context) {
|
|
224563
224836
|
const directoryPath = path24.join(context.workspaceRoot, "docs", "architecture");
|
|
224564
224837
|
const filePath = path24.join(directoryPath, "overview.md");
|
|
224565
|
-
const directoryExists2 = await
|
|
224566
|
-
const fileExists4 = await
|
|
224838
|
+
const directoryExists2 = await pathExists9(directoryPath);
|
|
224839
|
+
const fileExists4 = await pathExists9(filePath);
|
|
224567
224840
|
const filesCreated = [];
|
|
224568
224841
|
if (!directoryExists2) {
|
|
224569
224842
|
filesCreated.push(relative5(directoryPath, context.workspaceRoot));
|
|
@@ -224582,7 +224855,7 @@ async function previewArch003(context) {
|
|
|
224582
224855
|
async function applyArch003(context) {
|
|
224583
224856
|
const directoryPath = path24.join(context.workspaceRoot, "docs", "architecture");
|
|
224584
224857
|
const filePath = path24.join(directoryPath, "overview.md");
|
|
224585
|
-
const directoryExisted = await
|
|
224858
|
+
const directoryExisted = await pathExists9(directoryPath);
|
|
224586
224859
|
const fileCreated = await createFileIfMissing(filePath, architectureOverviewStarterTemplate);
|
|
224587
224860
|
const filesCreated = [];
|
|
224588
224861
|
if (!directoryExisted) {
|
|
@@ -224600,7 +224873,7 @@ async function applyArch003(context) {
|
|
|
224600
224873
|
}
|
|
224601
224874
|
async function previewApi001(context) {
|
|
224602
224875
|
const filePath = path24.join(context.workspaceRoot, "contracts", "openapi.yaml");
|
|
224603
|
-
const exists = await
|
|
224876
|
+
const exists = await pathExists9(filePath);
|
|
224604
224877
|
return {
|
|
224605
224878
|
filesCreated: exists ? [] : [relative5(filePath, context.workspaceRoot)],
|
|
224606
224879
|
filesModified: [],
|
|
@@ -224641,7 +224914,7 @@ async function previewArch005(context) {
|
|
|
224641
224914
|
};
|
|
224642
224915
|
}
|
|
224643
224916
|
const absolutePath = path24.join(context.workspaceRoot, ...modulePath.split("/"));
|
|
224644
|
-
const exists = await
|
|
224917
|
+
const exists = await pathExists9(absolutePath);
|
|
224645
224918
|
return {
|
|
224646
224919
|
filesCreated: exists ? [] : [modulePath],
|
|
224647
224920
|
filesModified: [],
|
|
@@ -224660,7 +224933,7 @@ async function applyArch005(context) {
|
|
|
224660
224933
|
};
|
|
224661
224934
|
}
|
|
224662
224935
|
const absolutePath = path24.join(context.workspaceRoot, ...modulePath.split("/"));
|
|
224663
|
-
const existed = await
|
|
224936
|
+
const existed = await pathExists9(absolutePath);
|
|
224664
224937
|
await ensureDirectory(absolutePath);
|
|
224665
224938
|
return {
|
|
224666
224939
|
applied: !existed,
|
|
@@ -224681,7 +224954,7 @@ async function previewArch006(context) {
|
|
|
224681
224954
|
};
|
|
224682
224955
|
}
|
|
224683
224956
|
const absolutePath = path24.join(context.workspaceRoot, ...contractPath.split("/"));
|
|
224684
|
-
const exists = await
|
|
224957
|
+
const exists = await pathExists9(absolutePath);
|
|
224685
224958
|
return {
|
|
224686
224959
|
filesCreated: exists ? [] : [contractPath],
|
|
224687
224960
|
filesModified: [],
|
|
@@ -224723,7 +224996,7 @@ async function applyArch006(context) {
|
|
|
224723
224996
|
}
|
|
224724
224997
|
async function previewDoc001(context) {
|
|
224725
224998
|
const filePath = path24.join(context.workspaceRoot, "docs", "adrs", "adr-001-tenant-model.md");
|
|
224726
|
-
const exists = await
|
|
224999
|
+
const exists = await pathExists9(filePath);
|
|
224727
225000
|
return {
|
|
224728
225001
|
filesCreated: exists ? [] : [relative5(filePath, context.workspaceRoot)],
|
|
224729
225002
|
filesModified: [],
|
|
@@ -224756,7 +225029,7 @@ async function applyDoc001(context) {
|
|
|
224756
225029
|
}
|
|
224757
225030
|
async function previewDoc002(context) {
|
|
224758
225031
|
const filePath = path24.join(context.workspaceRoot, "docs", "adrs", "adr-rbac-model.md");
|
|
224759
|
-
const exists = await
|
|
225032
|
+
const exists = await pathExists9(filePath);
|
|
224760
225033
|
return {
|
|
224761
225034
|
filesCreated: exists ? [] : [relative5(filePath, context.workspaceRoot)],
|
|
224762
225035
|
filesModified: [],
|
|
@@ -224891,7 +225164,7 @@ async function applyDep006(context) {
|
|
|
224891
225164
|
"contracts",
|
|
224892
225165
|
`${parsed.sourceModule}.contract.json`
|
|
224893
225166
|
);
|
|
224894
|
-
if (!await
|
|
225167
|
+
if (!await pathExists9(contractPath)) {
|
|
224895
225168
|
return {
|
|
224896
225169
|
applied: false,
|
|
224897
225170
|
filesCreated: [],
|
|
@@ -225304,7 +225577,7 @@ var jsxExtensions = /* @__PURE__ */ new Set([".tsx", ".jsx"]);
|
|
|
225304
225577
|
function normalizePath4(value) {
|
|
225305
225578
|
return value.replace(/\\/g, "/").replace(/^\.\/+/u, "").replace(/\/+$/u, "").toLowerCase();
|
|
225306
225579
|
}
|
|
225307
|
-
function
|
|
225580
|
+
function pathExists10(targetPath) {
|
|
225308
225581
|
try {
|
|
225309
225582
|
fs24.accessSync(targetPath);
|
|
225310
225583
|
return true;
|
|
@@ -225391,7 +225664,7 @@ function hasDependencyPrefix(dependencies, prefixes) {
|
|
|
225391
225664
|
return false;
|
|
225392
225665
|
}
|
|
225393
225666
|
function hasAnyFile(candidateRoot, filePaths) {
|
|
225394
|
-
return filePaths.some((filePath) =>
|
|
225667
|
+
return filePaths.some((filePath) => pathExists10(path25.join(candidateRoot, ...filePath.split("/"))));
|
|
225395
225668
|
}
|
|
225396
225669
|
function scanForJsxFiles(candidateRoot) {
|
|
225397
225670
|
const queue = [{ absolutePath: candidateRoot, depth: 0 }];
|
|
@@ -225427,25 +225700,25 @@ function collectCandidateSignals(candidateRoot) {
|
|
|
225427
225700
|
const dependencies = collectDependencyNames(packageJsonPath);
|
|
225428
225701
|
return {
|
|
225429
225702
|
dependencies,
|
|
225430
|
-
hasNextConfig:
|
|
225431
|
-
hasViteConfig:
|
|
225432
|
-
hasIndexHtml:
|
|
225433
|
-
hasPublicDir:
|
|
225434
|
-
hasSrcComponents:
|
|
225435
|
-
hasSrcPages:
|
|
225436
|
-
hasSrcApp:
|
|
225703
|
+
hasNextConfig: pathExists10(path25.join(candidateRoot, "next.config.js")) || pathExists10(path25.join(candidateRoot, "next.config.mjs")) || pathExists10(path25.join(candidateRoot, "next.config.ts")),
|
|
225704
|
+
hasViteConfig: pathExists10(path25.join(candidateRoot, "vite.config.js")) || pathExists10(path25.join(candidateRoot, "vite.config.ts")) || pathExists10(path25.join(candidateRoot, "vite.config.mjs")),
|
|
225705
|
+
hasIndexHtml: pathExists10(path25.join(candidateRoot, "index.html")),
|
|
225706
|
+
hasPublicDir: pathExists10(path25.join(candidateRoot, "public")),
|
|
225707
|
+
hasSrcComponents: pathExists10(path25.join(candidateRoot, "src", "components")),
|
|
225708
|
+
hasSrcPages: pathExists10(path25.join(candidateRoot, "src", "pages")),
|
|
225709
|
+
hasSrcApp: pathExists10(path25.join(candidateRoot, "src", "app")),
|
|
225437
225710
|
hasJsxTsconfig: hasJsxEnabled(path25.join(candidateRoot, "tsconfig.json")) || hasJsxEnabled(path25.join(candidateRoot, "jsconfig.json")),
|
|
225438
225711
|
hasJsxFiles: scanForJsxFiles(candidateRoot),
|
|
225439
|
-
hasRoutesDir:
|
|
225440
|
-
hasControllersDir:
|
|
225441
|
-
hasPrismaDir:
|
|
225442
|
-
hasDbDir:
|
|
225443
|
-
hasMigrationsDir:
|
|
225444
|
-
hasApiDir:
|
|
225712
|
+
hasRoutesDir: pathExists10(path25.join(candidateRoot, "routes")),
|
|
225713
|
+
hasControllersDir: pathExists10(path25.join(candidateRoot, "controllers")),
|
|
225714
|
+
hasPrismaDir: pathExists10(path25.join(candidateRoot, "prisma")),
|
|
225715
|
+
hasDbDir: pathExists10(path25.join(candidateRoot, "db")),
|
|
225716
|
+
hasMigrationsDir: pathExists10(path25.join(candidateRoot, "migrations")),
|
|
225717
|
+
hasApiDir: pathExists10(path25.join(candidateRoot, "api")),
|
|
225445
225718
|
hasServerEntrypoint: hasAnyFile(candidateRoot, backendEntrypoints),
|
|
225446
225719
|
hasOpenApiArtifacts: hasAnyFile(candidateRoot, openApiArtifacts),
|
|
225447
225720
|
hasWorkerEntrypoint: hasAnyFile(candidateRoot, workerEntrypoints),
|
|
225448
|
-
hasPackageJson:
|
|
225721
|
+
hasPackageJson: pathExists10(packageJsonPath),
|
|
225449
225722
|
hasExportsField: hasExportsField(packageJsonPath),
|
|
225450
225723
|
hasIndexEntrypoint: hasAnyFile(candidateRoot, indexEntrypoints)
|
|
225451
225724
|
};
|
|
@@ -225614,7 +225887,7 @@ function classifyModuleScope(input2) {
|
|
|
225614
225887
|
return "backend";
|
|
225615
225888
|
}
|
|
225616
225889
|
const candidateRoots = getCandidateRoots(input2.workspaceRoot, input2.modulePath).filter(
|
|
225617
|
-
(candidate) =>
|
|
225890
|
+
(candidate) => pathExists10(candidate)
|
|
225618
225891
|
);
|
|
225619
225892
|
const scores = sumScores(
|
|
225620
225893
|
candidateRoots.map(
|
|
@@ -225637,7 +225910,7 @@ function classifyModuleScope(input2) {
|
|
|
225637
225910
|
function normalizePath5(value) {
|
|
225638
225911
|
return value.replace(/\\/g, "/");
|
|
225639
225912
|
}
|
|
225640
|
-
async function
|
|
225913
|
+
async function pathExists11(targetPath) {
|
|
225641
225914
|
try {
|
|
225642
225915
|
await import_node_fs24.promises.access(targetPath);
|
|
225643
225916
|
return true;
|
|
@@ -225851,7 +226124,7 @@ async function discoverModulesFromArchitectureContract(workspaceRoot, contract,
|
|
|
225851
226124
|
const contractPath = normalizePath5(
|
|
225852
226125
|
typeof registryEntry.contract === "string" ? registryEntry.contract : `${contractsRoot}/${toSafeContractModuleFileStem2(moduleName)}.contract.json`
|
|
225853
226126
|
);
|
|
225854
|
-
const contractExists = await
|
|
226127
|
+
const contractExists = await pathExists11(path26.join(workspaceRoot, ...contractPath.split("/")));
|
|
225855
226128
|
const missingPublicEntrypointAlignment = await resolveMissingPublicEntrypointAlignment(
|
|
225856
226129
|
registryEntry,
|
|
225857
226130
|
contractPath
|
|
@@ -225876,7 +226149,7 @@ async function discoverModulesFromArchitectureContract(workspaceRoot, contract,
|
|
|
225876
226149
|
const registryEntry = moduleRegistry[moduleName];
|
|
225877
226150
|
const sourcePath = normalizePath5(registryEntry?.path ?? `${normalizedModulesRoot}/${moduleName}`);
|
|
225878
226151
|
const contractPath = toContractPath(moduleName, registryEntry);
|
|
225879
|
-
const contractExists = await
|
|
226152
|
+
const contractExists = await pathExists11(path26.join(workspaceRoot, ...contractPath.split("/")));
|
|
225880
226153
|
const missingPublicEntrypointAlignment = await resolveMissingPublicEntrypointAlignment(
|
|
225881
226154
|
registryEntry,
|
|
225882
226155
|
contractPath
|
|
@@ -225900,7 +226173,7 @@ async function discoverModulesFromArchitectureContract(workspaceRoot, contract,
|
|
|
225900
226173
|
}
|
|
225901
226174
|
const registryEntry = moduleRegistry[moduleRoot.moduleId];
|
|
225902
226175
|
const contractPath = toContractPath(moduleRoot.moduleId, registryEntry);
|
|
225903
|
-
const contractExists = await
|
|
226176
|
+
const contractExists = await pathExists11(path26.join(workspaceRoot, ...contractPath.split("/")));
|
|
225904
226177
|
const missingPublicEntrypointAlignment = await resolveMissingPublicEntrypointAlignment(
|
|
225905
226178
|
registryEntry,
|
|
225906
226179
|
contractPath
|
|
@@ -225933,7 +226206,7 @@ async function discoverModulesFromFallbackScan(workspaceRoot, modulesRoot = "src
|
|
|
225933
226206
|
sourcePathExists: true,
|
|
225934
226207
|
...resolveModuleScopeForPath(workspaceRoot, moduleRoot.sourcePath) ? { scope: resolveModuleScopeForPath(workspaceRoot, moduleRoot.sourcePath) } : {},
|
|
225935
226208
|
contractPath,
|
|
225936
|
-
contractExists: await
|
|
226209
|
+
contractExists: await pathExists11(path26.join(workspaceRoot, ...contractPath.split("/")))
|
|
225937
226210
|
});
|
|
225938
226211
|
}
|
|
225939
226212
|
for (const moduleName of moduleNames) {
|
|
@@ -225946,7 +226219,7 @@ async function discoverModulesFromFallbackScan(workspaceRoot, modulesRoot = "src
|
|
|
225946
226219
|
sourcePathExists: true,
|
|
225947
226220
|
...resolveModuleScopeForPath(workspaceRoot, sourcePath) ? { scope: resolveModuleScopeForPath(workspaceRoot, sourcePath) } : {},
|
|
225948
226221
|
contractPath,
|
|
225949
|
-
contractExists: await
|
|
226222
|
+
contractExists: await pathExists11(path26.join(workspaceRoot, ...contractPath.split("/")))
|
|
225950
226223
|
});
|
|
225951
226224
|
}
|
|
225952
226225
|
return discovered;
|
|
@@ -227708,7 +227981,7 @@ async function runGithubPrCommentAdapter(workspaceRoot) {
|
|
|
227708
227981
|
// ../core/src/generateOnboardingDocs.ts
|
|
227709
227982
|
var path31 = __toESM(require("node:path"));
|
|
227710
227983
|
var import_node_fs29 = require("node:fs");
|
|
227711
|
-
async function
|
|
227984
|
+
async function pathExists12(filePath) {
|
|
227712
227985
|
try {
|
|
227713
227986
|
await import_node_fs29.promises.access(filePath);
|
|
227714
227987
|
return true;
|
|
@@ -227762,10 +228035,10 @@ async function generateOnboardingDocs(workspaceRoot) {
|
|
|
227762
228035
|
[...map.modules].sort((left, right) => left.moduleName.localeCompare(right.moduleName)).map(async (moduleEntry) => {
|
|
227763
228036
|
const readmePath = `${moduleEntry.sourcePath}/README.md`;
|
|
227764
228037
|
const indexPath = `${moduleEntry.sourcePath}/index.ts`;
|
|
227765
|
-
const readmeExists = await
|
|
228038
|
+
const readmeExists = await pathExists12(
|
|
227766
228039
|
path31.join(workspaceRoot, ...readmePath.split("/"))
|
|
227767
228040
|
);
|
|
227768
|
-
const indexExists = await
|
|
228041
|
+
const indexExists = await pathExists12(
|
|
227769
228042
|
path31.join(workspaceRoot, ...indexPath.split("/"))
|
|
227770
228043
|
);
|
|
227771
228044
|
const hotspot = hotspotByModule.get(moduleEntry.moduleName);
|
|
@@ -228547,7 +228820,7 @@ function normalizePath9(value) {
|
|
|
228547
228820
|
function sortUnique10(values) {
|
|
228548
228821
|
return [...new Set(values)].sort((left, right) => left.localeCompare(right));
|
|
228549
228822
|
}
|
|
228550
|
-
async function
|
|
228823
|
+
async function pathExists13(targetPath) {
|
|
228551
228824
|
try {
|
|
228552
228825
|
await import_node_fs30.promises.access(targetPath);
|
|
228553
228826
|
return true;
|
|
@@ -228792,18 +229065,18 @@ async function generateImpactAnalysis(workspaceRoot, target, options) {
|
|
|
228792
229065
|
const contractPath = moduleEntry.contractPath;
|
|
228793
229066
|
suggestedFilesToInspect.push({
|
|
228794
229067
|
path: readmePath,
|
|
228795
|
-
exists: await
|
|
229068
|
+
exists: await pathExists13(path32.join(workspaceRoot, ...readmePath.split("/"))),
|
|
228796
229069
|
kind: "readme"
|
|
228797
229070
|
});
|
|
228798
229071
|
suggestedFilesToInspect.push({
|
|
228799
229072
|
path: indexPath,
|
|
228800
|
-
exists: await
|
|
229073
|
+
exists: await pathExists13(path32.join(workspaceRoot, ...indexPath.split("/"))),
|
|
228801
229074
|
kind: "entrypoint"
|
|
228802
229075
|
});
|
|
228803
229076
|
if (contractPath) {
|
|
228804
229077
|
suggestedFilesToInspect.push({
|
|
228805
229078
|
path: contractPath,
|
|
228806
|
-
exists: await
|
|
229079
|
+
exists: await pathExists13(path32.join(workspaceRoot, ...contractPath.split("/"))),
|
|
228807
229080
|
kind: "contract"
|
|
228808
229081
|
});
|
|
228809
229082
|
}
|
|
@@ -231126,7 +231399,7 @@ async function applyQuickFixPlan(workspaceRoot, plan) {
|
|
|
231126
231399
|
continue;
|
|
231127
231400
|
}
|
|
231128
231401
|
const absoluteTargetPath = path43.resolve(workspaceRoot, action.targetPath);
|
|
231129
|
-
if (await
|
|
231402
|
+
if (await pathExists9(absoluteTargetPath)) {
|
|
231130
231403
|
skippedExists.push(action.targetPath);
|
|
231131
231404
|
continue;
|
|
231132
231405
|
}
|
|
@@ -231179,7 +231452,7 @@ function normalizePath11(value) {
|
|
|
231179
231452
|
function toAbsolutePath(workspaceRoot, relativePath) {
|
|
231180
231453
|
return path44.join(workspaceRoot, ...relativePath.split("/"));
|
|
231181
231454
|
}
|
|
231182
|
-
async function
|
|
231455
|
+
async function pathExists14(targetPath) {
|
|
231183
231456
|
try {
|
|
231184
231457
|
await import_node_fs39.promises.access(targetPath);
|
|
231185
231458
|
return true;
|
|
@@ -231208,7 +231481,7 @@ async function inferModulePublicEntrypoints(workspaceRoot, moduleSourcePath, ada
|
|
|
231208
231481
|
const normalizedSourcePath = normalizePath11(moduleSourcePath);
|
|
231209
231482
|
if (/\.[a-z0-9]+$/iu.test(normalizedSourcePath)) {
|
|
231210
231483
|
const absoluteSourcePath = toAbsolutePath(workspaceRoot, normalizedSourcePath);
|
|
231211
|
-
if (await
|
|
231484
|
+
if (await pathExists14(absoluteSourcePath)) {
|
|
231212
231485
|
return [normalizedSourcePath];
|
|
231213
231486
|
}
|
|
231214
231487
|
}
|
|
@@ -231235,14 +231508,14 @@ async function inferModulePublicEntrypoints(workspaceRoot, moduleSourcePath, ada
|
|
|
231235
231508
|
const inferred = [];
|
|
231236
231509
|
for (const fileName of orderedCandidates) {
|
|
231237
231510
|
const candidateRelative = `${normalizedSourcePath}/${fileName}`;
|
|
231238
|
-
if (await
|
|
231511
|
+
if (await pathExists14(toAbsolutePath(workspaceRoot, candidateRelative))) {
|
|
231239
231512
|
inferred.push(candidateRelative);
|
|
231240
231513
|
break;
|
|
231241
231514
|
}
|
|
231242
231515
|
}
|
|
231243
231516
|
for (const publicDirName of adapter.publicEntrypointDirectoryNames) {
|
|
231244
231517
|
const publicDirectoryRelative = `${normalizedSourcePath}/${publicDirName}`;
|
|
231245
|
-
if (await
|
|
231518
|
+
if (await pathExists14(toAbsolutePath(workspaceRoot, publicDirectoryRelative))) {
|
|
231246
231519
|
inferred.push(publicDirectoryRelative);
|
|
231247
231520
|
break;
|
|
231248
231521
|
}
|
|
@@ -231333,7 +231606,7 @@ async function generateMissingModuleContracts(workspaceRoot) {
|
|
|
231333
231606
|
const contractPath = resolveContractPath(contract, moduleEntry.moduleName);
|
|
231334
231607
|
const sourcePath = normalizePath11(moduleEntry.sourcePath);
|
|
231335
231608
|
const absoluteContractPath = toAbsolutePath(workspaceRoot, contractPath);
|
|
231336
|
-
const contractExists = await
|
|
231609
|
+
const contractExists = await pathExists14(absoluteContractPath);
|
|
231337
231610
|
const existingContractPublicEntrypoints = contractExists ? await readExistingModuleContractPublicEntrypoints(workspaceRoot, contractPath) : void 0;
|
|
231338
231611
|
const configuredPublicEntrypoints = !contractExists && Array.isArray(getModuleRegistry2(contract)[moduleEntry.moduleName]?.publicEntrypoints) ? sortUnique12(
|
|
231339
231612
|
getModuleRegistry2(contract)[moduleEntry.moduleName]?.publicEntrypoints?.map(
|
|
@@ -231396,7 +231669,7 @@ function normalizePath12(value) {
|
|
|
231396
231669
|
function toAbsolutePath2(workspaceRoot, relativePath) {
|
|
231397
231670
|
return path45.join(workspaceRoot, ...relativePath.split("/"));
|
|
231398
231671
|
}
|
|
231399
|
-
async function
|
|
231672
|
+
async function pathExists15(targetPath) {
|
|
231400
231673
|
try {
|
|
231401
231674
|
await import_node_fs40.promises.access(targetPath);
|
|
231402
231675
|
return true;
|
|
@@ -231459,7 +231732,7 @@ async function bootstrapArchitectureConfig(workspaceRoot, options) {
|
|
|
231459
231732
|
ensuredDirectories.push(".archpilot", ".archpilot/contracts");
|
|
231460
231733
|
const dependencyRulesPath = ".archpilot/dependency-rules.json";
|
|
231461
231734
|
const dependencyRulesAbsolutePath = toAbsolutePath2(workspaceRoot, dependencyRulesPath);
|
|
231462
|
-
if (await
|
|
231735
|
+
if (await pathExists15(dependencyRulesAbsolutePath)) {
|
|
231463
231736
|
skippedExistingFiles.push(dependencyRulesPath);
|
|
231464
231737
|
} else {
|
|
231465
231738
|
await import_node_fs40.promises.writeFile(
|
|
@@ -231471,7 +231744,7 @@ async function bootstrapArchitectureConfig(workspaceRoot, options) {
|
|
|
231471
231744
|
}
|
|
231472
231745
|
const layerRulesPath = ".archpilot/layer-rules.json";
|
|
231473
231746
|
const layerRulesAbsolutePath = toAbsolutePath2(workspaceRoot, layerRulesPath);
|
|
231474
|
-
if (await
|
|
231747
|
+
if (await pathExists15(layerRulesAbsolutePath)) {
|
|
231475
231748
|
skippedExistingFiles.push(layerRulesPath);
|
|
231476
231749
|
} else {
|
|
231477
231750
|
await import_node_fs40.promises.writeFile(layerRulesAbsolutePath, renderLayerRulesConfig(modules), {
|
|
@@ -233550,7 +233823,7 @@ function safeReadDirEntries(directoryPath) {
|
|
|
233550
233823
|
return [];
|
|
233551
233824
|
}
|
|
233552
233825
|
}
|
|
233553
|
-
function
|
|
233826
|
+
function pathExists16(pathValue) {
|
|
233554
233827
|
try {
|
|
233555
233828
|
fs48.accessSync(pathValue);
|
|
233556
233829
|
return true;
|
|
@@ -233785,7 +234058,7 @@ function collectExplicitRoots(workspaceRoot) {
|
|
|
233785
234058
|
"packages",
|
|
233786
234059
|
"libs"
|
|
233787
234060
|
]) {
|
|
233788
|
-
if (
|
|
234061
|
+
if (pathExists16(path53.join(workspaceRoot, ...root.split("/")))) {
|
|
233789
234062
|
roots.push(root);
|
|
233790
234063
|
}
|
|
233791
234064
|
}
|
|
@@ -233805,7 +234078,7 @@ function collectExplicitRoots(workspaceRoot) {
|
|
|
233805
234078
|
`apps/${appEntry.name}/app`,
|
|
233806
234079
|
`apps/${appEntry.name}/src/app`
|
|
233807
234080
|
]) {
|
|
233808
|
-
if (
|
|
234081
|
+
if (pathExists16(path53.join(workspaceRoot, ...candidate.split("/")))) {
|
|
233809
234082
|
roots.push(candidate);
|
|
233810
234083
|
}
|
|
233811
234084
|
}
|
|
@@ -233825,7 +234098,7 @@ function collectExplicitRoots(workspaceRoot) {
|
|
|
233825
234098
|
`${container}/${containerEntry.name}/src/application`,
|
|
233826
234099
|
`${container}/${containerEntry.name}/src/infrastructure`
|
|
233827
234100
|
]) {
|
|
233828
|
-
if (
|
|
234101
|
+
if (pathExists16(path53.join(workspaceRoot, ...candidate.split("/")))) {
|
|
233829
234102
|
roots.push(candidate);
|
|
233830
234103
|
}
|
|
233831
234104
|
}
|
|
@@ -233837,7 +234110,7 @@ function collectJavaPackageRoots(workspaceRoot) {
|
|
|
233837
234110
|
const roots = [];
|
|
233838
234111
|
for (const sourceRoot of ["src/main/java", "src/main/kotlin", "src"]) {
|
|
233839
234112
|
const absoluteSourceRoot = path53.join(workspaceRoot, ...sourceRoot.split("/"));
|
|
233840
|
-
if (!
|
|
234113
|
+
if (!pathExists16(absoluteSourceRoot)) {
|
|
233841
234114
|
continue;
|
|
233842
234115
|
}
|
|
233843
234116
|
const queue = [
|
|
@@ -234644,7 +234917,7 @@ function safeReadText3(filePath, maxChars = 3e4) {
|
|
|
234644
234917
|
return void 0;
|
|
234645
234918
|
}
|
|
234646
234919
|
}
|
|
234647
|
-
function
|
|
234920
|
+
function pathExists17(pathValue) {
|
|
234648
234921
|
try {
|
|
234649
234922
|
fs51.accessSync(pathValue);
|
|
234650
234923
|
return true;
|
|
@@ -234750,7 +235023,7 @@ function collectCandidateRoots(workspaceRoot, topology) {
|
|
|
234750
235023
|
}
|
|
234751
235024
|
}
|
|
234752
235025
|
for (const root of ["backend", "frontend"]) {
|
|
234753
|
-
if (
|
|
235026
|
+
if (pathExists17(path56.join(workspaceRoot, root))) {
|
|
234754
235027
|
roots.add(root);
|
|
234755
235028
|
}
|
|
234756
235029
|
}
|