@yansirplus/cli 0.5.17
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/PUBLIC_API.md +22 -0
- package/README.md +34 -0
- package/dist/build/agent-authoring/config.d.ts +177 -0
- package/dist/build/agent-authoring/config.js +607 -0
- package/dist/build/agent-authoring/manifest-compiler.d.ts +159 -0
- package/dist/build/agent-authoring/manifest-compiler.js +737 -0
- package/dist/build/agent-authoring/shared.d.ts +10 -0
- package/dist/build/agent-authoring/shared.js +57 -0
- package/dist/build/agent-authoring/static-target.d.ts +59 -0
- package/dist/build/agent-authoring/static-target.js +1857 -0
- package/dist/build/agent-authoring.d.ts +9 -0
- package/dist/build/agent-authoring.js +5 -0
- package/dist/build/build-cli.d.ts +2 -0
- package/dist/build/build-cli.js +264 -0
- package/dist/check/algorithmic/architecture-checks.mjs +971 -0
- package/dist/check/algorithmic/client-boundary-checks.mjs +337 -0
- package/dist/check/algorithmic/convergence-smoke-checks.mjs +608 -0
- package/dist/check/algorithmic/distribution-checks.mjs +919 -0
- package/dist/check/algorithmic/owner-checks.mjs +647 -0
- package/dist/check/algorithmic/package-boundary-checks.mjs +985 -0
- package/dist/check/algorithmic/projection-boundary-checks.mjs +302 -0
- package/dist/check/algorithmic/repo-surface-checks.mjs +267 -0
- package/dist/check/algorithmic/runtime-structural-checks.mjs +264 -0
- package/dist/check/algorithmic/source-alias-checks.mjs +106 -0
- package/dist/check/algorithmic/static-target-checks.mjs +447 -0
- package/dist/check/algorithmic-checks.mjs +482 -0
- package/dist/check/check-coverage.mjs +231 -0
- package/dist/check/command-runner.mjs +22 -0
- package/dist/check/default-gate.mjs +51 -0
- package/dist/check/gate-selector.mjs +305 -0
- package/dist/check/manifest-rules.mjs +223 -0
- package/dist/check/package-graph.mjs +464 -0
- package/dist/generate/generate-agent-docs.mjs +435 -0
- package/dist/generate/generate-carrier-reference.mjs +514 -0
- package/dist/generate/generate-docs.mjs +345 -0
- package/dist/generate/generate-effect-skill-manifests.mjs +193 -0
- package/dist/generate/project-docs-site.mjs +190 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +25 -0
- package/dist/lib/agent-docs-model.mjs +888 -0
- package/dist/lib/boundary-rules.mjs +63 -0
- package/dist/lib/capability-routes.mjs +354 -0
- package/dist/lib/projection-sink.mjs +113 -0
- package/dist/lib/public-api-model.mjs +306 -0
- package/dist/main.mjs +233 -0
- package/dist/runner.mjs +127 -0
- package/package.json +32 -0
|
@@ -0,0 +1,482 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { execFileSync } from "node:child_process";
|
|
3
|
+
import fs from "node:fs";
|
|
4
|
+
import os from "node:os";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
7
|
+
import ts from "typescript";
|
|
8
|
+
import { runCommand } from "./command-runner.mjs";
|
|
9
|
+
import {
|
|
10
|
+
importSpecifierRecords,
|
|
11
|
+
packageImportCycles as graphPackageImportCycles,
|
|
12
|
+
packageManifestDependencyEdges,
|
|
13
|
+
packageSourceImportEdges as graphPackageSourceImportEdges,
|
|
14
|
+
moduleGraphOracleFailures,
|
|
15
|
+
sourceModuleGraph,
|
|
16
|
+
tsconfigReferenceEdges,
|
|
17
|
+
workspacePackageRecords as graphWorkspacePackageRecords,
|
|
18
|
+
} from "./package-graph.mjs";
|
|
19
|
+
import { collectAgentDocsModel } from "../lib/agent-docs-model.mjs";
|
|
20
|
+
import { createOwnerChecks } from "./algorithmic/owner-checks.mjs";
|
|
21
|
+
import { createArchitectureChecks } from "./algorithmic/architecture-checks.mjs";
|
|
22
|
+
import { createDistributionChecks } from "./algorithmic/distribution-checks.mjs";
|
|
23
|
+
import { createClientBoundaryChecks } from "./algorithmic/client-boundary-checks.mjs";
|
|
24
|
+
import {
|
|
25
|
+
createPackageBoundaryChecks,
|
|
26
|
+
packageExportSubpaths,
|
|
27
|
+
} from "./algorithmic/package-boundary-checks.mjs";
|
|
28
|
+
import { createRuntimeStructuralChecks } from "./algorithmic/runtime-structural-checks.mjs";
|
|
29
|
+
import { createStaticTargetChecks } from "./algorithmic/static-target-checks.mjs";
|
|
30
|
+
import { createRepoSurfaceChecks } from "./algorithmic/repo-surface-checks.mjs";
|
|
31
|
+
import { createProjectionBoundaryChecks } from "./algorithmic/projection-boundary-checks.mjs";
|
|
32
|
+
import { createConvergenceSmokeChecks } from "./algorithmic/convergence-smoke-checks.mjs";
|
|
33
|
+
import { createSourceAliasChecks } from "./algorithmic/source-alias-checks.mjs";
|
|
34
|
+
import {
|
|
35
|
+
apiSourceMode,
|
|
36
|
+
exportedNamesForPackage,
|
|
37
|
+
sourceTsdocApiMarkdown,
|
|
38
|
+
sourceTsdocModes,
|
|
39
|
+
sourceTsdocRecordsForPackage,
|
|
40
|
+
validateSourceTsdocRecords,
|
|
41
|
+
} from "../lib/public-api-model.mjs";
|
|
42
|
+
|
|
43
|
+
const repoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../../../..");
|
|
44
|
+
const compare = (left, right) => left.localeCompare(right);
|
|
45
|
+
const toRepoPath = (file) => path.relative(repoRoot, file).split(path.sep).join("/");
|
|
46
|
+
const read = (relativePath) => fs.readFileSync(path.join(repoRoot, relativePath), "utf8");
|
|
47
|
+
const readJson = (relativePath) => JSON.parse(read(relativePath));
|
|
48
|
+
const isRecord = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
49
|
+
|
|
50
|
+
const walk = (relativePath, options = {}) => {
|
|
51
|
+
const absolutePath = path.join(repoRoot, relativePath);
|
|
52
|
+
if (!fs.existsSync(absolutePath)) return [];
|
|
53
|
+
const stat = fs.statSync(absolutePath);
|
|
54
|
+
if (stat.isFile()) return [relativePath];
|
|
55
|
+
const ignored = options.ignored ?? new Set(["node_modules", "dist", ".wrangler", ".turbo"]);
|
|
56
|
+
const files = [];
|
|
57
|
+
for (const entry of fs.readdirSync(absolutePath, { withFileTypes: true })) {
|
|
58
|
+
if (entry.isDirectory() && ignored.has(entry.name)) continue;
|
|
59
|
+
const child = path.join(relativePath, entry.name);
|
|
60
|
+
if (entry.isDirectory()) files.push(...walk(child, options));
|
|
61
|
+
if (entry.isFile()) files.push(child.split(path.sep).join("/"));
|
|
62
|
+
}
|
|
63
|
+
return files.sort(compare);
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const failIfAny = (label, failures) => {
|
|
67
|
+
if (failures.length === 0) {
|
|
68
|
+
console.log(`${label} passed`);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
throw new Error(failures.join("\n"));
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const repoSurfaceChecks = createRepoSurfaceChecks({
|
|
75
|
+
fs,
|
|
76
|
+
path,
|
|
77
|
+
ts,
|
|
78
|
+
repoRoot,
|
|
79
|
+
read,
|
|
80
|
+
readJson,
|
|
81
|
+
walk,
|
|
82
|
+
compare,
|
|
83
|
+
isRecord,
|
|
84
|
+
failIfAny,
|
|
85
|
+
collectAgentDocsModel,
|
|
86
|
+
apiSourceMode,
|
|
87
|
+
exportedNamesForPackage,
|
|
88
|
+
sourceTsdocApiMarkdown,
|
|
89
|
+
sourceTsdocModes,
|
|
90
|
+
sourceTsdocRecordsForPackage,
|
|
91
|
+
validateSourceTsdocRecords,
|
|
92
|
+
});
|
|
93
|
+
const manifestNames = repoSurfaceChecks.manifestNames;
|
|
94
|
+
const ruleConstraints = repoSurfaceChecks.ruleConstraints;
|
|
95
|
+
const checkPublicApi = repoSurfaceChecks.checkPublicApi;
|
|
96
|
+
const checkEventNamespaces = repoSurfaceChecks.checkEventNamespaces;
|
|
97
|
+
const checkRepoToolingSurface = repoSurfaceChecks.checkRepoToolingSurface;
|
|
98
|
+
|
|
99
|
+
const clientBoundaryChecks = createClientBoundaryChecks({
|
|
100
|
+
fs,
|
|
101
|
+
path,
|
|
102
|
+
repoRoot,
|
|
103
|
+
read,
|
|
104
|
+
readJson,
|
|
105
|
+
walk,
|
|
106
|
+
failIfAny,
|
|
107
|
+
});
|
|
108
|
+
const workspacePackageRecords = clientBoundaryChecks.workspacePackageRecords;
|
|
109
|
+
const clientSectionBody = clientBoundaryChecks.clientSectionBody;
|
|
110
|
+
const checkClientBoundaries = clientBoundaryChecks.checkClientBoundaries;
|
|
111
|
+
|
|
112
|
+
const sourceAliasChecks = createSourceAliasChecks({
|
|
113
|
+
fs,
|
|
114
|
+
path,
|
|
115
|
+
pathToFileURL,
|
|
116
|
+
repoRoot,
|
|
117
|
+
readJson,
|
|
118
|
+
toRepoPath,
|
|
119
|
+
compare,
|
|
120
|
+
isRecord,
|
|
121
|
+
failIfAny,
|
|
122
|
+
});
|
|
123
|
+
const checkSourceAliases = sourceAliasChecks.checkSourceAliases;
|
|
124
|
+
|
|
125
|
+
const packageSourceFiles = () =>
|
|
126
|
+
walk("packages").filter(
|
|
127
|
+
(file) =>
|
|
128
|
+
/\.(?:ts|tsx|mts|cts)$/u.test(file) &&
|
|
129
|
+
!file.endsWith(".d.ts") &&
|
|
130
|
+
file.split("/").includes("src"),
|
|
131
|
+
);
|
|
132
|
+
|
|
133
|
+
const packageTestFiles = () =>
|
|
134
|
+
walk("packages").filter(
|
|
135
|
+
(file) =>
|
|
136
|
+
/\.(?:ts|tsx|mts|cts)$/u.test(file) &&
|
|
137
|
+
!file.endsWith(".d.ts") &&
|
|
138
|
+
file.split("/").includes("test"),
|
|
139
|
+
);
|
|
140
|
+
|
|
141
|
+
const nodeLabel = (sourceFile, node) => {
|
|
142
|
+
const position = sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile));
|
|
143
|
+
return `${toRepoPath(sourceFile.fileName)}:${position.line + 1}:${position.character + 1}`;
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
const unwrap = (node) => {
|
|
147
|
+
let current = node;
|
|
148
|
+
while (
|
|
149
|
+
ts.isAsExpression(current) ||
|
|
150
|
+
ts.isSatisfiesExpression(current) ||
|
|
151
|
+
ts.isParenthesizedExpression(current)
|
|
152
|
+
) {
|
|
153
|
+
current = current.expression;
|
|
154
|
+
}
|
|
155
|
+
return current;
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
const callName = (expression) => {
|
|
159
|
+
const unwrapped = unwrap(expression);
|
|
160
|
+
if (ts.isIdentifier(unwrapped)) return unwrapped.text;
|
|
161
|
+
if (ts.isPropertyAccessExpression(unwrapped)) return unwrapped.name.text;
|
|
162
|
+
return undefined;
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
const runtimeStructuralChecks = createRuntimeStructuralChecks({
|
|
166
|
+
fs,
|
|
167
|
+
path,
|
|
168
|
+
ts,
|
|
169
|
+
execFileSync,
|
|
170
|
+
repoRoot,
|
|
171
|
+
read,
|
|
172
|
+
readJson,
|
|
173
|
+
walk,
|
|
174
|
+
isRecord,
|
|
175
|
+
failIfAny,
|
|
176
|
+
packageSourceFiles,
|
|
177
|
+
nodeLabel,
|
|
178
|
+
unwrap,
|
|
179
|
+
callName,
|
|
180
|
+
graphWorkspacePackageRecords,
|
|
181
|
+
graphPackageSourceImportEdges,
|
|
182
|
+
packageManifestDependencyEdges,
|
|
183
|
+
tsconfigReferenceEdges,
|
|
184
|
+
});
|
|
185
|
+
const checkTransactionSync = runtimeStructuralChecks.checkTransactionSync;
|
|
186
|
+
const checkBackendNeutrality = runtimeStructuralChecks.checkBackendNeutrality;
|
|
187
|
+
const checkGateTierGovernance = runtimeStructuralChecks.checkGateTierGovernance;
|
|
188
|
+
const checkSpikeHygiene = runtimeStructuralChecks.checkSpikeHygiene;
|
|
189
|
+
|
|
190
|
+
const ownerChecks = createOwnerChecks({
|
|
191
|
+
ts,
|
|
192
|
+
graphWorkspacePackageRecords,
|
|
193
|
+
repoRoot,
|
|
194
|
+
read,
|
|
195
|
+
walk,
|
|
196
|
+
compare,
|
|
197
|
+
isRecord,
|
|
198
|
+
unwrap,
|
|
199
|
+
callName,
|
|
200
|
+
packageSourceFiles,
|
|
201
|
+
packageTestFiles,
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
export const ownerCouplingFindingsForSource = ownerChecks.ownerCouplingFindingsForSource;
|
|
205
|
+
export const ownerIdentityBoundaryFindingsForSource =
|
|
206
|
+
ownerChecks.ownerIdentityBoundaryFindingsForSource;
|
|
207
|
+
export const ownerIdentityBoundaryNegativeFixtureFailures =
|
|
208
|
+
ownerChecks.ownerIdentityBoundaryNegativeFixtureFailures;
|
|
209
|
+
export const ownerIdDeclarationFindingsForSource = ownerChecks.ownerIdDeclarationFindingsForSource;
|
|
210
|
+
export const coreClaimedNamespaceFindingsForSource =
|
|
211
|
+
ownerChecks.coreClaimedNamespaceFindingsForSource;
|
|
212
|
+
export const ownerIdRegistryFindings = ownerChecks.ownerIdRegistryFindings;
|
|
213
|
+
const ownerIdRegistry = ownerChecks.ownerIdRegistry;
|
|
214
|
+
const checkOwnerCoupling = ownerChecks.checkOwnerCoupling;
|
|
215
|
+
const checkOwnerIdentityBoundary = ownerChecks.checkOwnerIdentityBoundary;
|
|
216
|
+
const checkOwnerIds = ownerChecks.checkOwnerIds;
|
|
217
|
+
|
|
218
|
+
const architectureChecks = createArchitectureChecks({
|
|
219
|
+
fs,
|
|
220
|
+
path,
|
|
221
|
+
graphWorkspacePackageRecords,
|
|
222
|
+
sourceModuleGraph,
|
|
223
|
+
importSpecifierRecords,
|
|
224
|
+
repoRoot,
|
|
225
|
+
read,
|
|
226
|
+
readJson,
|
|
227
|
+
walk,
|
|
228
|
+
compare,
|
|
229
|
+
isRecord,
|
|
230
|
+
failIfAny,
|
|
231
|
+
ownerIdRegistry,
|
|
232
|
+
ownerIdRegistryFindings,
|
|
233
|
+
packageExportSubpaths,
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
const distributionRootsRegistryPath = architectureChecks.distributionRootsRegistryPath;
|
|
237
|
+
const packageUnitsRegistryPath = architectureChecks.packageUnitsRegistryPath;
|
|
238
|
+
const moduleBucketRegistry = architectureChecks.moduleBucketRegistry;
|
|
239
|
+
export const moduleBucketForPath = architectureChecks.moduleBucketForPath;
|
|
240
|
+
export const moduleAmbientForPath = architectureChecks.moduleAmbientForPath;
|
|
241
|
+
export const moduleBucketRegistryFindings = architectureChecks.moduleBucketRegistryFindings;
|
|
242
|
+
export const packageUnitsRegistryFindings = architectureChecks.packageUnitsRegistryFindings;
|
|
243
|
+
export const distributionRootsRegistryFindings =
|
|
244
|
+
architectureChecks.distributionRootsRegistryFindings;
|
|
245
|
+
export const moduleBucketFindingsForEdges = architectureChecks.moduleBucketFindingsForEdges;
|
|
246
|
+
export const moduleBucketNegativeFixtureFailures =
|
|
247
|
+
architectureChecks.moduleBucketNegativeFixtureFailures;
|
|
248
|
+
const checkModuleBuckets = architectureChecks.checkModuleBuckets;
|
|
249
|
+
const checkArchitectureSources = architectureChecks.checkArchitectureSources;
|
|
250
|
+
|
|
251
|
+
let packageBoundaryChecks;
|
|
252
|
+
const distributionChecks = createDistributionChecks({
|
|
253
|
+
fs,
|
|
254
|
+
path,
|
|
255
|
+
ts,
|
|
256
|
+
repoRoot,
|
|
257
|
+
compare,
|
|
258
|
+
isRecord,
|
|
259
|
+
readJson,
|
|
260
|
+
walk,
|
|
261
|
+
failIfAny,
|
|
262
|
+
importSpecifierRecords,
|
|
263
|
+
graphWorkspacePackageRecords,
|
|
264
|
+
sourceModuleGraph,
|
|
265
|
+
moduleBucketRegistry,
|
|
266
|
+
packageUnitsRegistryFindings,
|
|
267
|
+
distributionRootsRegistryFindings,
|
|
268
|
+
packageUnitsRegistryPath,
|
|
269
|
+
distributionRootsRegistryPath,
|
|
270
|
+
distributionMinimalityFailures: () => packageBoundaryChecks.distributionMinimalityFailures(),
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
export const distributionManifestFindings = distributionChecks.distributionManifestFindings;
|
|
274
|
+
export const distributionSourceProbeFindingsForSource =
|
|
275
|
+
distributionChecks.distributionSourceProbeFindingsForSource;
|
|
276
|
+
export const distributionSubpathFindings = distributionChecks.distributionSubpathFindings;
|
|
277
|
+
export const distributionFindingsForPackage = distributionChecks.distributionFindingsForPackage;
|
|
278
|
+
export const distributionEffectPeerFindings = distributionChecks.distributionEffectPeerFindings;
|
|
279
|
+
export const distributionUnitRegistryFindings = distributionChecks.distributionUnitRegistryFindings;
|
|
280
|
+
export const distributionUnitNegativeFixtureFailures =
|
|
281
|
+
distributionChecks.distributionUnitNegativeFixtureFailures;
|
|
282
|
+
const distributionUnitFinding = distributionChecks.distributionUnitFinding;
|
|
283
|
+
const packageUnitOptionalPeerEntries = distributionChecks.packageUnitOptionalPeerEntries;
|
|
284
|
+
const formatDistributionFinding = distributionChecks.formatDistributionFinding;
|
|
285
|
+
const checkDistributionUnits = distributionChecks.checkDistributionUnits;
|
|
286
|
+
|
|
287
|
+
packageBoundaryChecks = createPackageBoundaryChecks({
|
|
288
|
+
fs,
|
|
289
|
+
path,
|
|
290
|
+
execFileSync,
|
|
291
|
+
repoRoot,
|
|
292
|
+
read,
|
|
293
|
+
readJson,
|
|
294
|
+
walk,
|
|
295
|
+
compare,
|
|
296
|
+
isRecord,
|
|
297
|
+
failIfAny,
|
|
298
|
+
ruleConstraints,
|
|
299
|
+
graphWorkspacePackageRecords,
|
|
300
|
+
graphPackageSourceImportEdges,
|
|
301
|
+
graphPackageImportCycles,
|
|
302
|
+
sourceModuleGraph,
|
|
303
|
+
moduleGraphOracleFailures,
|
|
304
|
+
importSpecifierRecords,
|
|
305
|
+
distributionExportEntries: distributionChecks.distributionExportEntries,
|
|
306
|
+
distributionClosureForRoots: distributionChecks.distributionClosureForRoots,
|
|
307
|
+
distributionUnitFinding,
|
|
308
|
+
packageUnitOptionalPeerEntries,
|
|
309
|
+
formatDistributionFinding,
|
|
310
|
+
checkModuleBuckets,
|
|
311
|
+
moduleAmbientForPath,
|
|
312
|
+
allowedAmbientImports: architectureChecks.allowedAmbientImports,
|
|
313
|
+
packageUnitsRegistryPath,
|
|
314
|
+
distributionRootsRegistryPath,
|
|
315
|
+
});
|
|
316
|
+
export const packageConstraintNameFailures = packageBoundaryChecks.packageConstraintNameFailures;
|
|
317
|
+
export const packageUnitOptionalPeerAllowsEdge =
|
|
318
|
+
packageBoundaryChecks.packageUnitOptionalPeerAllowsEdge;
|
|
319
|
+
export const consumerFacingSpecifierFailuresForContent =
|
|
320
|
+
packageBoundaryChecks.consumerFacingSpecifierFailuresForContent;
|
|
321
|
+
export const markdownLinkFailuresForContent = packageBoundaryChecks.markdownLinkFailuresForContent;
|
|
322
|
+
export const obsoletePublicPackageFailures = packageBoundaryChecks.obsoletePublicPackageFailures;
|
|
323
|
+
const consumerFacingSpecifierFailures = packageBoundaryChecks.consumerFacingSpecifierFailures;
|
|
324
|
+
const checkDocsLinkIntegrity = packageBoundaryChecks.checkDocsLinkIntegrity;
|
|
325
|
+
const packageUnitOptionalPeerFindings = packageBoundaryChecks.packageUnitOptionalPeerFindings;
|
|
326
|
+
const checkNoObsoletePublicPackages = packageBoundaryChecks.checkNoObsoletePublicPackages;
|
|
327
|
+
const packageUnitsRegistry = packageBoundaryChecks.packageUnitsRegistry;
|
|
328
|
+
const distributionRootsRegistry = packageBoundaryChecks.distributionRootsRegistry;
|
|
329
|
+
const packageUnitRecords = packageBoundaryChecks.packageUnitRecords;
|
|
330
|
+
const packageUnitSourceNames = packageBoundaryChecks.packageUnitSourceNames;
|
|
331
|
+
const packageUnitPublicSpecifiers = packageBoundaryChecks.packageUnitPublicSpecifiers;
|
|
332
|
+
const packageUnitPublicSpecifierForSource =
|
|
333
|
+
packageBoundaryChecks.packageUnitPublicSpecifierForSource;
|
|
334
|
+
const selectedSourceSpecifiersForProfileUnit =
|
|
335
|
+
packageBoundaryChecks.selectedSourceSpecifiersForProfileUnit;
|
|
336
|
+
const specifierMatchesPackage = packageBoundaryChecks.specifierMatchesPackage;
|
|
337
|
+
const checkSubstrateImportDag = packageBoundaryChecks.checkSubstrateImportDag;
|
|
338
|
+
const checkConvergenceImportDag = packageBoundaryChecks.checkConvergenceImportDag;
|
|
339
|
+
const checkModuleGraphOracle = packageBoundaryChecks.checkModuleGraphOracle;
|
|
340
|
+
const checkSubpathNoLeak = packageBoundaryChecks.checkSubpathNoLeak;
|
|
341
|
+
const checkProfileVerification = packageBoundaryChecks.checkProfileVerification;
|
|
342
|
+
|
|
343
|
+
const staticTargetChecks = createStaticTargetChecks({ read, failIfAny });
|
|
344
|
+
const checkGeneratedStaticTargetLinking = staticTargetChecks.checkGeneratedStaticTargetLinking;
|
|
345
|
+
|
|
346
|
+
const projectionBoundaryChecks = createProjectionBoundaryChecks({
|
|
347
|
+
fs,
|
|
348
|
+
path,
|
|
349
|
+
ts,
|
|
350
|
+
repoRoot,
|
|
351
|
+
read,
|
|
352
|
+
readJson,
|
|
353
|
+
walk,
|
|
354
|
+
isRecord,
|
|
355
|
+
failIfAny,
|
|
356
|
+
graphWorkspacePackageRecords,
|
|
357
|
+
sourceModuleGraph,
|
|
358
|
+
workspacePackageRecords,
|
|
359
|
+
});
|
|
360
|
+
const projectionFoldBoundaryFailures = projectionBoundaryChecks.projectionFoldBoundaryFailures;
|
|
361
|
+
const checkProjectionFoldBoundary = projectionBoundaryChecks.checkProjectionFoldBoundary;
|
|
362
|
+
const checkLimitRegistry = projectionBoundaryChecks.checkLimitRegistry;
|
|
363
|
+
|
|
364
|
+
const convergenceSmokeChecks = createConvergenceSmokeChecks({
|
|
365
|
+
fs,
|
|
366
|
+
os,
|
|
367
|
+
path,
|
|
368
|
+
execFileSync,
|
|
369
|
+
repoRoot,
|
|
370
|
+
read,
|
|
371
|
+
readJson,
|
|
372
|
+
walk,
|
|
373
|
+
isRecord,
|
|
374
|
+
failIfAny,
|
|
375
|
+
manifestNames,
|
|
376
|
+
checkPublicApi,
|
|
377
|
+
checkClientBoundaries,
|
|
378
|
+
clientSectionBody,
|
|
379
|
+
checkGeneratedStaticTargetLinking,
|
|
380
|
+
checkSpikeHygiene,
|
|
381
|
+
moduleBucketRegistry,
|
|
382
|
+
workspacePackageRecords,
|
|
383
|
+
consumerFacingSpecifierFailures,
|
|
384
|
+
packageUnitPublicSpecifiers,
|
|
385
|
+
packageUnitPublicSpecifierForSource,
|
|
386
|
+
packageUnitRecords,
|
|
387
|
+
packageUnitSourceNames,
|
|
388
|
+
packageUnitsRegistry,
|
|
389
|
+
distributionRootsRegistry,
|
|
390
|
+
selectedSourceSpecifiersForProfileUnit,
|
|
391
|
+
runProfileTypecheck: packageBoundaryChecks.runProfileTypecheck,
|
|
392
|
+
obsoletePublicPackageFailures,
|
|
393
|
+
packageUnitOptionalPeerFindings,
|
|
394
|
+
specifierMatchesPackage,
|
|
395
|
+
projectionFoldBoundaryFailures,
|
|
396
|
+
});
|
|
397
|
+
const checkConvergenceBoundary = convergenceSmokeChecks.checkConvergenceBoundary;
|
|
398
|
+
const checkConvergencePublicSurface = convergenceSmokeChecks.checkConvergencePublicSurface;
|
|
399
|
+
const checkDocsSiteBuild = convergenceSmokeChecks.checkDocsSiteBuild;
|
|
400
|
+
const checkCliSurface = convergenceSmokeChecks.checkCliSurface;
|
|
401
|
+
const checkConsumerImports = convergenceSmokeChecks.checkConsumerImports;
|
|
402
|
+
const checkDogfoodSmoke = convergenceSmokeChecks.checkDogfoodSmoke;
|
|
403
|
+
|
|
404
|
+
const checkBoundaryProjection = () => runCommand("vp check", { cwd: repoRoot });
|
|
405
|
+
|
|
406
|
+
const checkerById = new Map([
|
|
407
|
+
["architecture-sources", checkArchitectureSources],
|
|
408
|
+
["backend-neutrality", checkBackendNeutrality],
|
|
409
|
+
["boundaries", checkBoundaryProjection],
|
|
410
|
+
["cli-surface", checkCliSurface],
|
|
411
|
+
["client-boundaries", checkClientBoundaries],
|
|
412
|
+
["consumer-imports", checkConsumerImports],
|
|
413
|
+
["convergence-boundary", checkConvergenceBoundary],
|
|
414
|
+
["convergence-import-dag", checkConvergenceImportDag],
|
|
415
|
+
["convergence-public-surface", checkConvergencePublicSurface],
|
|
416
|
+
["d12-a155-substrate-absorption", checkBoundaryProjection],
|
|
417
|
+
["distribution-units", checkDistributionUnits],
|
|
418
|
+
["dogfood-smoke", checkDogfoodSmoke],
|
|
419
|
+
["docs-link-integrity", checkDocsLinkIntegrity],
|
|
420
|
+
["docs-site-build", checkDocsSiteBuild],
|
|
421
|
+
["event-namespaces", checkEventNamespaces],
|
|
422
|
+
["limit-registry", checkLimitRegistry],
|
|
423
|
+
["generated-static-target-linking", checkGeneratedStaticTargetLinking],
|
|
424
|
+
["gate-tier-governance", checkGateTierGovernance],
|
|
425
|
+
["module-graph-oracle", checkModuleGraphOracle],
|
|
426
|
+
["module-buckets", checkModuleBuckets],
|
|
427
|
+
["no-obsolete-public-packages", checkNoObsoletePublicPackages],
|
|
428
|
+
["owner-coupling", checkOwnerCoupling],
|
|
429
|
+
["owner-identity-boundary", checkOwnerIdentityBoundary],
|
|
430
|
+
["owner-ids", checkOwnerIds],
|
|
431
|
+
["profile-verification", checkProfileVerification],
|
|
432
|
+
["projection-fold-boundary", checkProjectionFoldBoundary],
|
|
433
|
+
["public-api", checkPublicApi],
|
|
434
|
+
["repo-tooling-surface", checkRepoToolingSurface],
|
|
435
|
+
["source-aliases", checkSourceAliases],
|
|
436
|
+
["spike-hygiene", checkSpikeHygiene],
|
|
437
|
+
["subpath-no-leak", checkSubpathNoLeak],
|
|
438
|
+
["substrate-import-dag", checkSubstrateImportDag],
|
|
439
|
+
["transaction-sync", checkTransactionSync],
|
|
440
|
+
]);
|
|
441
|
+
const checkerIdsWithArgs = new Set([
|
|
442
|
+
"distribution-units",
|
|
443
|
+
"dogfood-smoke",
|
|
444
|
+
"consumer-imports",
|
|
445
|
+
"module-buckets",
|
|
446
|
+
"owner-coupling",
|
|
447
|
+
"owner-identity-boundary",
|
|
448
|
+
"profile-verification",
|
|
449
|
+
"subpath-no-leak",
|
|
450
|
+
]);
|
|
451
|
+
|
|
452
|
+
export const listAlgorithmicCheckers = () => [...checkerById.keys()].sort(compare);
|
|
453
|
+
export const hasAlgorithmicChecker = (checkerId) => checkerById.has(checkerId);
|
|
454
|
+
export const algorithmicCheckerAcceptsArgs = (checkerId) => checkerIdsWithArgs.has(checkerId);
|
|
455
|
+
|
|
456
|
+
export const runAlgorithmicChecker = async (checkerId, args = []) => {
|
|
457
|
+
const checker = checkerById.get(checkerId);
|
|
458
|
+
if (checker === undefined) throw new Error(`unknown algorithmic checker ${checkerId}`);
|
|
459
|
+
console.log(`$ agentos algorithmic-check ${checkerId}`);
|
|
460
|
+
await Promise.resolve(checker(args));
|
|
461
|
+
};
|
|
462
|
+
|
|
463
|
+
const isCli =
|
|
464
|
+
process.argv[1] !== undefined && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url);
|
|
465
|
+
|
|
466
|
+
if (isCli) {
|
|
467
|
+
const [checkerId, ...rest] = process.argv.slice(2);
|
|
468
|
+
if (checkerId === undefined || checkerId === "--help" || checkerId === "-h") {
|
|
469
|
+
console.log("usage: node packages/cli/src/check/algorithmic-checks.mjs <checker-id>");
|
|
470
|
+
process.exit(checkerId === undefined ? 1 : 0);
|
|
471
|
+
}
|
|
472
|
+
if (!algorithmicCheckerAcceptsArgs(checkerId) && rest.length > 0) {
|
|
473
|
+
console.error(`unexpected argument(s): ${rest.join(" ")}`);
|
|
474
|
+
process.exit(1);
|
|
475
|
+
}
|
|
476
|
+
try {
|
|
477
|
+
await runAlgorithmicChecker(checkerId, rest);
|
|
478
|
+
} catch (error) {
|
|
479
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
480
|
+
process.exit(1);
|
|
481
|
+
}
|
|
482
|
+
}
|