@ultimat3/cli 5.0.1 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +25 -2
- package/README.md +2 -2
- package/package.json +27 -24
- package/src/cmd-build.ts +7 -0
- package/src/cmd-dev.ts +35 -2
- package/src/cmd-generate.ts +16 -348
- package/src/cmd-i18n.ts +32 -16
- package/src/cmd-verify.ts +10 -427
- package/src/compile-externals.ts +34 -0
- package/src/dev-lock.ts +275 -0
- package/src/dev-render.ts +7 -17
- package/src/error-codes.ts +2 -0
- package/src/generate-files.ts +127 -0
- package/src/generate-write.ts +229 -0
- package/src/i18n-audit.ts +39 -1
- package/src/i18n-registration.ts +130 -0
- package/src/island-bundle.ts +7 -0
- package/src/mcp-errors.ts +2 -0
- package/src/messages.ts +3 -0
- package/src/solid-loader.ts +127 -0
- package/src/templates/admin-page.ts +46 -5
- package/src/templates/resource.ts +39 -9
- package/src/templates/route.ts +31 -5
- package/src/templates/scaffold-app.ts +55 -18
- package/src/templates/scaffold-container.ts +2 -2
- package/src/templates/scaffold-db-package.ts +56 -38
- package/src/templates/scaffold-docs.ts +18 -1
- package/src/templates/scaffold-i18n.ts +9 -2
- package/src/templates/scaffold-repo.ts +2 -2
- package/src/verify-checks.ts +339 -0
- package/src/verify-run.ts +122 -0
- package/src/verify-step.ts +7 -0
- package/types/babel-modules.d.ts +31 -0
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
// What each named gate step actually checks, in cost order. Split from `cmd-verify.ts`, which is
|
|
2
|
+
// now the `x verify` command surface alone: the list is the definition of shippable and grows with
|
|
3
|
+
// the framework, while the command that runs it does not.
|
|
4
|
+
|
|
5
|
+
import { existsSync } from 'node:fs';
|
|
6
|
+
import { join } from 'node:path';
|
|
7
|
+
import type { Manifest } from '@ultimat3/manifest';
|
|
8
|
+
import {
|
|
9
|
+
AGENTS_MD_FILENAME,
|
|
10
|
+
assertNoDrift,
|
|
11
|
+
MANIFEST_FILENAME,
|
|
12
|
+
verifyContract,
|
|
13
|
+
} from '@ultimat3/manifest';
|
|
14
|
+
import type { MetaIssue } from '@ultimat3/seo';
|
|
15
|
+
import { validateMeta } from '@ultimat3/seo';
|
|
16
|
+
import { checkAgentsMd } from './app-agents-md';
|
|
17
|
+
import { checkAppBoundaries } from './app-boundaries';
|
|
18
|
+
import { envExampleFindings } from './app-env';
|
|
19
|
+
import { appManifest, readAppManifest } from './app-manifest';
|
|
20
|
+
import { OPENAPI_FILE, openApiJson } from './app-openapi';
|
|
21
|
+
import { APP_CONFIG_FILE } from './app-root';
|
|
22
|
+
import { checkBudgets, readBuildStats } from './budgets';
|
|
23
|
+
import { checkDestructiveMigrations } from './db-destructive';
|
|
24
|
+
import { checkDocumentStyles, documentSurfaces } from './document-styles';
|
|
25
|
+
import { checkSourceDrift } from './drift';
|
|
26
|
+
import { checkErrorFixReport } from './error-contract';
|
|
27
|
+
import { guardFindings } from './guards';
|
|
28
|
+
import { catalogFindings } from './i18n-registration';
|
|
29
|
+
import { msg } from './messages';
|
|
30
|
+
import type { Finding } from './output';
|
|
31
|
+
import { findingFrom } from './output';
|
|
32
|
+
import { scanSiteMeta } from './seo-meta';
|
|
33
|
+
import { floorProblemFindings, readVerifyFloor } from './verify-floor';
|
|
34
|
+
import type { VerifyStep } from './verify-step';
|
|
35
|
+
import { fromExec, fromFindings, hostFindings } from './verify-step';
|
|
36
|
+
import { TEST_STEPS } from './verify-tests';
|
|
37
|
+
import { checkFileSizes, checkPackageShape, hasWorkspacePackages } from './workspace-checks';
|
|
38
|
+
|
|
39
|
+
/** The one file that makes the `roadmap` step answerable, and therefore what `applies` reads. */
|
|
40
|
+
const ROADMAP_FILE = join('docs', 'idea', '14-roadmap.md');
|
|
41
|
+
|
|
42
|
+
/** The whole contract, in cost order. Every check the framework knows how to make lives here. */
|
|
43
|
+
export const VERIFY_STEPS: readonly VerifyStep[] = [
|
|
44
|
+
{
|
|
45
|
+
name: 'typecheck',
|
|
46
|
+
summary: 'tsc -b across every project the root references',
|
|
47
|
+
async run(ctx) {
|
|
48
|
+
const result = await ctx.runner(['bunx', 'tsc', '-b', '--pretty', 'false'], {
|
|
49
|
+
cwd: ctx.root,
|
|
50
|
+
});
|
|
51
|
+
return fromExec(result, {
|
|
52
|
+
code: 'X_TYPECHECK_FAILED',
|
|
53
|
+
cause: 'the project does not typecheck',
|
|
54
|
+
fix: 'bunx tsc -b --pretty false',
|
|
55
|
+
});
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
name: 'lint',
|
|
60
|
+
// Only what biome actually enforces. It claimed "no default exports" while the rule was off
|
|
61
|
+
// (it is not in `recommended`) and "no raw colours" over a file type biome ignores entirely —
|
|
62
|
+
// two thirds of the line were enforced by nothing. `noDefaultExport` is now on in `biome.json`;
|
|
63
|
+
// the colour rule is `packages/ui/src/tokens/tokens.test.ts`, and rides on the `unit` step.
|
|
64
|
+
summary: 'biome: format, no any, no default exports, no unused imports',
|
|
65
|
+
async run(ctx) {
|
|
66
|
+
const result = await ctx.runner(['bunx', 'biome', 'check', '.'], { cwd: ctx.root });
|
|
67
|
+
return fromExec(result, {
|
|
68
|
+
code: 'X_LINT_FAILED',
|
|
69
|
+
cause: 'biome reported problems',
|
|
70
|
+
fix: 'bunx biome check --write .',
|
|
71
|
+
});
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
name: 'boundaries',
|
|
76
|
+
summary: "surface, layer and package-tier imports, and the app's own guards",
|
|
77
|
+
// An app's `guards/` rides here rather than becoming an eighteenth step, for the reason the
|
|
78
|
+
// seam already states: a host adds findings to a step, it can never add, remove, reorder or
|
|
79
|
+
// skip one — so "green" keeps meaning exactly what it meant. This is the step whose host slot
|
|
80
|
+
// already carries "rules this repo makes about itself that the framework cannot know" (the
|
|
81
|
+
// monorepo's tier table arrives through it), and it runs third, before any suite, so a
|
|
82
|
+
// convention failure is reported in seconds rather than after the tests.
|
|
83
|
+
//
|
|
84
|
+
// Discovered, not registered: `guardFindings` reads the directory. A guard that had to
|
|
85
|
+
// announce itself is a guard an app can forget to announce, which is the coupling axiom 8's
|
|
86
|
+
// extension model rejects.
|
|
87
|
+
run: async (ctx) =>
|
|
88
|
+
fromFindings([
|
|
89
|
+
...(await checkAppBoundaries(ctx.root)),
|
|
90
|
+
...(await guardFindings(ctx.root)),
|
|
91
|
+
...(await hostFindings(ctx, 'boundaries')),
|
|
92
|
+
]),
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
name: 'filesize',
|
|
96
|
+
summary: 'one file, one job',
|
|
97
|
+
run: async (ctx) => fromFindings(await checkFileSizes(ctx.root)),
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
name: 'package-shape',
|
|
101
|
+
summary: 'every package ships the same contract files',
|
|
102
|
+
applies: (ctx) => hasWorkspacePackages(ctx.root),
|
|
103
|
+
run: async (ctx) => fromFindings(await checkPackageShape(ctx.root)),
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
name: 'errors',
|
|
107
|
+
summary: 'every X_* code has a runnable fix and a docs page',
|
|
108
|
+
// The fix-line half runs anywhere source does. The docs half needs a reference page to check
|
|
109
|
+
// against, and which file that is belongs to the host repo — hence `hostFindings`.
|
|
110
|
+
//
|
|
111
|
+
// The coverage line rides in `output`, which `--json` carries verbatim: a scan without a
|
|
112
|
+
// parser cannot read every fix, and a step that reports only findings claims a completeness
|
|
113
|
+
// it does not have. "checked 412, could not read 27" is what a reader can act on.
|
|
114
|
+
async run(ctx) {
|
|
115
|
+
const report = await checkErrorFixReport(ctx.root);
|
|
116
|
+
const findings = [...report.findings, ...(await hostFindings(ctx, 'errors'))];
|
|
117
|
+
return {
|
|
118
|
+
...fromFindings(findings),
|
|
119
|
+
output: msg('cli.verify.fixCoverage', {
|
|
120
|
+
checked: report.checked,
|
|
121
|
+
unreadable: report.unreadable,
|
|
122
|
+
}),
|
|
123
|
+
};
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
...TEST_STEPS,
|
|
127
|
+
{
|
|
128
|
+
name: 'drift',
|
|
129
|
+
summary: 'schema source vs migrations, and every destructive statement declared',
|
|
130
|
+
// Only an app owns migrations; a package monorepo's `packages/db` is the driver, not a schema.
|
|
131
|
+
// Source, not database: the gate runs in CI with nothing listening, and the database half is
|
|
132
|
+
// the post-migrate verification `runMigrations` performs where a connection is already open.
|
|
133
|
+
//
|
|
134
|
+
// The destructive rail rides here rather than becoming an eighteenth step because it asks this
|
|
135
|
+
// step's own question — do the committed migrations still describe what the app is doing to its
|
|
136
|
+
// schema? — off the same directory, in the same pass, with no database either.
|
|
137
|
+
applies: async (ctx) => existsSync(join(ctx.root, APP_CONFIG_FILE)),
|
|
138
|
+
run: async (ctx) =>
|
|
139
|
+
fromFindings([
|
|
140
|
+
...(await checkSourceDrift(ctx.root)),
|
|
141
|
+
...(await checkDestructiveMigrations(ctx.root)),
|
|
142
|
+
]),
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
name: 'contract-diff',
|
|
146
|
+
summary: 'the published contract vs the committed manifest',
|
|
147
|
+
// Either file is a published contract on its own: `openapi.json` generates the typed client,
|
|
148
|
+
// so gating on the manifest alone let a stale spec ship a wrong client unchecked.
|
|
149
|
+
applies: async (ctx) =>
|
|
150
|
+
existsSync(join(ctx.root, MANIFEST_FILENAME)) || existsSync(join(ctx.root, OPENAPI_FILE)),
|
|
151
|
+
async run(ctx) {
|
|
152
|
+
const committed = await readAppManifest(ctx.root);
|
|
153
|
+
const { manifest, findings } = await appManifest(ctx.root);
|
|
154
|
+
return fromFindings([
|
|
155
|
+
...findings,
|
|
156
|
+
...(committed === undefined ? [] : contractFindings(committed, manifest)),
|
|
157
|
+
...(await specFindings(ctx.root, manifest)),
|
|
158
|
+
]);
|
|
159
|
+
},
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
name: 'budgets',
|
|
163
|
+
summary: 'per-route JS bytes and LCP, and the global style layer every document carries',
|
|
164
|
+
// The global-style assertion rides here rather than becoming an eighteenth step, because this
|
|
165
|
+
// step already asks the one question it asks: what does the document this build emits actually
|
|
166
|
+
// contain? It is also the same app load — `appManifest` fills render's stylesheet registry on
|
|
167
|
+
// its way through — so a separate step would pay for a second one to answer half a question.
|
|
168
|
+
//
|
|
169
|
+
// A repo with no `app.config.ts` is the framework monorepo, which renders no documents and has
|
|
170
|
+
// no stylesheet registry to read; there is nothing for either half to weigh.
|
|
171
|
+
applies: async (ctx) => existsSync(join(ctx.root, APP_CONFIG_FILE)),
|
|
172
|
+
async run(ctx) {
|
|
173
|
+
// No stats file is NOT "nothing to weigh" — it is every declared budget unmeasured, which is
|
|
174
|
+
// the case `checkBudgets` already names per route (`X_BUDGET_UNMEASURED`). Skipping the half
|
|
175
|
+
// entirely is how a step that has never run once reported green: `.x/` is gitignored, so no
|
|
176
|
+
// CI run and neither gated app has ever had a `build-stats.json` for it to read.
|
|
177
|
+
//
|
|
178
|
+
// Handed over as `undefined` and never as `?? { routes: [] }`: "no build has run here" and
|
|
179
|
+
// "a build ran and could not weigh this route" are two different instructions, and only the
|
|
180
|
+
// caller knows which of them is true. The step still does not BUILD — measuring here would
|
|
181
|
+
// make `x verify` a static build on every run (8.2s on `dummy/social-media-clone`, and 5.9s
|
|
182
|
+
// to a hard `X_PRERENDER_FAILED` on `examples/dummy`), and it would be a second builder
|
|
183
|
+
// beside `apps/web/prerender.ts`, which is where an app reads `SITE_ORIGIN`.
|
|
184
|
+
const stats = await readBuildStats(ctx.root);
|
|
185
|
+
// The load's own findings, FIRST and never dropped. A module that would not import registers
|
|
186
|
+
// no route, so its budget is missing from the manifest and every route it declared reads as
|
|
187
|
+
// `X_BUDGET_UNMEASURED` — the symptom, pointing the reader at `x build` for a file that will
|
|
188
|
+
// not compile. `contract-diff` reports these too when it applies; two red steps naming one
|
|
189
|
+
// broken module is honest, and one of them silently green over it is the false green.
|
|
190
|
+
const { manifest, findings } = await appManifest(ctx.root);
|
|
191
|
+
return fromFindings([
|
|
192
|
+
...findings,
|
|
193
|
+
...checkDocumentStyles(documentSurfaces()),
|
|
194
|
+
...checkBudgets(manifest, stats),
|
|
195
|
+
]);
|
|
196
|
+
},
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
name: 'seo',
|
|
200
|
+
summary: 'every indexable site/ route has a title and a description a search result can render',
|
|
201
|
+
// The SEO checkers shipped in `@ultimat3/seo` with no caller anywhere — `validateMeta` and its
|
|
202
|
+
// asserts were reachable only by an app that called them itself, which is what
|
|
203
|
+
// `packages/seo/src/errors.ts`'s own header said. This is the caller.
|
|
204
|
+
//
|
|
205
|
+
// Its own step rather than a rider on `budgets`: that step asks what a document WEIGHS and
|
|
206
|
+
// this one asks what it SAYS, and a missing `<title>` reported under `budgets` would hand the
|
|
207
|
+
// reader a fix for the wrong question (axiom 4). It costs no second app load — `loadApp`
|
|
208
|
+
// imports each module once per process, so this runs on the registries `budgets` just filled.
|
|
209
|
+
applies: async (ctx) => existsSync(join(ctx.root, APP_CONFIG_FILE)),
|
|
210
|
+
async run(ctx) {
|
|
211
|
+
const scan = await scanSiteMeta(ctx.root);
|
|
212
|
+
// No `baseUrl`: an app declares no base URL anywhere (`packages/core/src/config.ts` has no
|
|
213
|
+
// such key), so canonical checks are skipped rather than run against an origin this file
|
|
214
|
+
// invented. `seo-meta.ts` spells out why that is the honest half.
|
|
215
|
+
const report = validateMeta(scan.records);
|
|
216
|
+
return {
|
|
217
|
+
ok: scan.findings.length === 0 && report.ok,
|
|
218
|
+
findings: [...scan.findings, ...report.issues.map(seoFinding)],
|
|
219
|
+
};
|
|
220
|
+
},
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
name: 'i18n',
|
|
224
|
+
summary: 'every string this app renders resolves — in the catalogs AND in the registry',
|
|
225
|
+
// Its own step rather than a rider on `boundaries`, by that step's own test: a rider must ask
|
|
226
|
+
// the SAME question off the same data, and "did this import cross a line?" is not "did this
|
|
227
|
+
// declaration reach the running app?". Reported under `boundaries`, `X_CATALOG_UNREGISTERED`
|
|
228
|
+
// would send a reader to the import graph for a bug that lives in the boot path (axiom 4).
|
|
229
|
+
//
|
|
230
|
+
// Both halves, because they are one question and both ship the same `⟦key⟧` to a user: a key
|
|
231
|
+
// missing from a locale's catalog, and a catalog no module ever registered. `x i18n check`
|
|
232
|
+
// reports exactly these findings from exactly this call, so the command and the gate cannot
|
|
233
|
+
// disagree about an app.
|
|
234
|
+
//
|
|
235
|
+
// Beside `seo` and after `budgets` for the reason `seo` gives: `loadApp` imports each module
|
|
236
|
+
// once per process, so this runs on the registries `budgets` just filled and pays for no
|
|
237
|
+
// second load. A repo with no `app.config.ts` is the framework monorepo, which registers no
|
|
238
|
+
// app catalogs — SKIPPED there, never passed, because a step that answers `ok` about nothing
|
|
239
|
+
// is the vacuous green this check exists to refuse.
|
|
240
|
+
applies: async (ctx) => existsSync(join(ctx.root, APP_CONFIG_FILE)),
|
|
241
|
+
run: async (ctx) => fromFindings(await catalogFindings(ctx.root)),
|
|
242
|
+
},
|
|
243
|
+
{
|
|
244
|
+
name: 'manifest',
|
|
245
|
+
summary: 'the files an agent reads: generated facts, hand-written conventions, the env example',
|
|
246
|
+
// No `applies`. The drift half has nothing to compare against until `x manifest` has run
|
|
247
|
+
// once, and says so by finding nothing — but `AGENTS.md` is required of every repo the gate
|
|
248
|
+
// runs in, so the step always has a question to answer and must never report as skipped.
|
|
249
|
+
//
|
|
250
|
+
// `.env.example` joins this step rather than becoming an eighteenth: the question is the same
|
|
251
|
+
// one — "does a committed, generated file still describe the code?" — and the step list is the
|
|
252
|
+
// definition of shippable, so it grows only when a genuinely new question needs asking.
|
|
253
|
+
//
|
|
254
|
+
// `x.verify.json` is here for that same question and no other: this step judges the floor
|
|
255
|
+
// FILE, `runVerify` judges the suites against it. A name the gate does not run can never
|
|
256
|
+
// vanish, so a typo in the floor covers nothing — which is the false green the floor exists to
|
|
257
|
+
// close, and it is only visible if something reads the file for its own sake.
|
|
258
|
+
async run(ctx) {
|
|
259
|
+
const agents = await checkAgentsMd(ctx.root);
|
|
260
|
+
const findings = [
|
|
261
|
+
...(await driftFindings(ctx.root)),
|
|
262
|
+
...(await envExampleFindings(ctx.root)),
|
|
263
|
+
...floorProblemFindings(await readVerifyFloor(ctx.root)),
|
|
264
|
+
...agents.findings,
|
|
265
|
+
...(await hostFindings(ctx, 'manifest')),
|
|
266
|
+
];
|
|
267
|
+
// Warnings are not findings: `AGENTS.md` tabulating a route table is a smell a human
|
|
268
|
+
// judges, not a build error. They ride in `output`, which `--json` carries verbatim.
|
|
269
|
+
const output = agents.warnings.map((warning) => `${AGENTS_MD_FILENAME}: ${warning}`);
|
|
270
|
+
return {
|
|
271
|
+
ok: findings.length === 0,
|
|
272
|
+
findings,
|
|
273
|
+
...(output.length === 0 ? {} : { output: output.join('\n') }),
|
|
274
|
+
};
|
|
275
|
+
},
|
|
276
|
+
},
|
|
277
|
+
{
|
|
278
|
+
name: 'roadmap',
|
|
279
|
+
summary: "every roadmap milestone's status marker matches what is actually on disk",
|
|
280
|
+
// A generated app ships no `docs/idea/14-roadmap.md` — only the framework monorepo does, so
|
|
281
|
+
// the FILE is what decides. It keyed on `ctx.hostChecks?.roadmap` until `As of 2026-08`, which
|
|
282
|
+
// is a fact about the CALL: a caller of the exported `runVerify(VERIFY_STEPS, ctx)` passing no
|
|
283
|
+
// `hostChecks`, in a repo whose committed `x.verify.json` names `roadmap`, got
|
|
284
|
+
// `X_VERIFY_SUITE_VANISHED` — whose `fix:` is the command that had just failed.
|
|
285
|
+
applies: async (ctx) => existsSync(join(ctx.root, ROADMAP_FILE)),
|
|
286
|
+
run: async (ctx) => fromFindings(await hostFindings(ctx, 'roadmap')),
|
|
287
|
+
},
|
|
288
|
+
];
|
|
289
|
+
|
|
290
|
+
/** `assertNoDrift` throws `X_MANIFEST_DRIFT`; a step reports, so the error becomes a finding. */
|
|
291
|
+
async function driftFindings(root: string): Promise<readonly Finding[]> {
|
|
292
|
+
const path = join(root, MANIFEST_FILENAME);
|
|
293
|
+
if (!existsSync(path)) return [];
|
|
294
|
+
const { manifest, findings } = await appManifest(root);
|
|
295
|
+
try {
|
|
296
|
+
await assertNoDrift({ manifest, path });
|
|
297
|
+
return findings;
|
|
298
|
+
} catch (error) {
|
|
299
|
+
return [...findings, { ...findingFrom(error), at: MANIFEST_FILENAME }];
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/** A breaking change is allowed — with a major bump. `verifyContract` is the one that decides. */
|
|
304
|
+
function contractFindings(before: Manifest, after: Manifest): readonly Finding[] {
|
|
305
|
+
try {
|
|
306
|
+
verifyContract({ before, after });
|
|
307
|
+
return [];
|
|
308
|
+
} catch (error) {
|
|
309
|
+
return [{ ...findingFrom(error), at: MANIFEST_FILENAME }];
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
/** The typed client is generated from `openapi.json`, so a stale spec ships a wrong client. */
|
|
314
|
+
async function specFindings(root: string, manifest: Manifest): Promise<readonly Finding[]> {
|
|
315
|
+
const path = join(root, OPENAPI_FILE);
|
|
316
|
+
if (!existsSync(path)) return [];
|
|
317
|
+
if ((await Bun.file(path).text()) === openApiJson(manifest)) return [];
|
|
318
|
+
return [
|
|
319
|
+
{
|
|
320
|
+
code: 'X_MANIFEST_STALE',
|
|
321
|
+
cause: `${OPENAPI_FILE} does not match the actions the code registers`,
|
|
322
|
+
fix: 'x manifest',
|
|
323
|
+
docs: 'https://ultimate.dev/errors/X_MANIFEST_STALE',
|
|
324
|
+
at: OPENAPI_FILE,
|
|
325
|
+
},
|
|
326
|
+
];
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* One `MetaIssue` as the gate reports it. `at` is the route FILE and never the URL: every seo error
|
|
331
|
+
* already names the file in its cause, and `at` is what an agent opens.
|
|
332
|
+
*/
|
|
333
|
+
const seoFinding = (issue: MetaIssue): Finding => ({
|
|
334
|
+
code: issue.code,
|
|
335
|
+
cause: issue.cause,
|
|
336
|
+
fix: issue.fix,
|
|
337
|
+
docs: `https://ultimate.dev/errors/${issue.code}`,
|
|
338
|
+
at: issue.file,
|
|
339
|
+
});
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
// Run a step list end to end and turn it into the one table every reader sees. Split from
|
|
2
|
+
// `cmd-verify.ts` because `x build` and the MCP host run the gate without going through the
|
|
3
|
+
// command: what a run means — never bail early, count what actually ran — belongs to neither.
|
|
4
|
+
|
|
5
|
+
import { renderThrowable } from '@ultimat3/core';
|
|
6
|
+
import { msg } from './messages';
|
|
7
|
+
import type { CommandResult, Finding, StepResult } from './output';
|
|
8
|
+
import {
|
|
9
|
+
floorRequires,
|
|
10
|
+
readVerifyFloor,
|
|
11
|
+
skippedSuiteFinding,
|
|
12
|
+
vanishedSuiteFinding,
|
|
13
|
+
} from './verify-floor';
|
|
14
|
+
import type { StepOutcome, VerifyContext, VerifyStep } from './verify-step';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Run every step in order, never bailing early: an agent fixing three things at once needs all
|
|
18
|
+
* three findings from one run, not one per round-trip.
|
|
19
|
+
*/
|
|
20
|
+
export async function runVerify(
|
|
21
|
+
steps: readonly VerifyStep[],
|
|
22
|
+
ctx: VerifyContext,
|
|
23
|
+
): Promise<CommandResult> {
|
|
24
|
+
const floor = await readVerifyFloor(ctx.root);
|
|
25
|
+
const results: StepResult[] = [];
|
|
26
|
+
for (const step of steps) {
|
|
27
|
+
const applies = step.applies === undefined ? true : await step.applies(ctx);
|
|
28
|
+
if (!applies) {
|
|
29
|
+
// A skip this repo already ruled out is not a skip. The step ran here before — the floor is
|
|
30
|
+
// that claim, committed — so "nothing to check" now means the suite was deleted, and the
|
|
31
|
+
// gate says so on the step's own line rather than counting one more thing not to worry
|
|
32
|
+
// about. Recorded as failed and NOT as skipped, so every reader of a step table sees it:
|
|
33
|
+
// the summary, `data.failed`, and the reference-app gate's own red list.
|
|
34
|
+
const required = floorRequires(floor, step.name);
|
|
35
|
+
results.push({
|
|
36
|
+
name: step.name,
|
|
37
|
+
ok: !required,
|
|
38
|
+
durationMs: 0,
|
|
39
|
+
skipped: !required,
|
|
40
|
+
findings: required ? [vanishedSuiteFinding(step.name)] : [],
|
|
41
|
+
});
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
const started = performance.now();
|
|
45
|
+
const outcome = await step.run(ctx).catch(
|
|
46
|
+
(error: unknown): StepOutcome => ({
|
|
47
|
+
ok: false,
|
|
48
|
+
findings: [findingOf(error, step.name)],
|
|
49
|
+
}),
|
|
50
|
+
);
|
|
51
|
+
// A step the floor requires whose suite executed nothing is the same vanished suite as a step
|
|
52
|
+
// with no files at all — the run just had to finish before it could be seen. Appended to the
|
|
53
|
+
// step's own findings so `data.failed`, the counts and every gate reading this table carry it.
|
|
54
|
+
const vanished =
|
|
55
|
+
floorRequires(floor, step.name) && outcome.tests !== undefined && outcome.tests.ran === 0
|
|
56
|
+
? [skippedSuiteFinding(step.name, outcome.tests.skipped)]
|
|
57
|
+
: [];
|
|
58
|
+
results.push({
|
|
59
|
+
name: step.name,
|
|
60
|
+
ok: outcome.ok && vanished.length === 0,
|
|
61
|
+
durationMs: Math.round(performance.now() - started),
|
|
62
|
+
findings: [...outcome.findings, ...vanished],
|
|
63
|
+
...(outcome.output === undefined ? {} : { output: outcome.output }),
|
|
64
|
+
...(outcome.workers === undefined ? {} : { workers: outcome.workers }),
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
const failedSteps = results.filter((step) => !step.ok).map((step) => step.name);
|
|
68
|
+
const skippedSteps = results.filter((step) => step.skipped === true).map((step) => step.name);
|
|
69
|
+
const totalMs = results.reduce((sum, step) => sum + step.durationMs, 0);
|
|
70
|
+
return {
|
|
71
|
+
ok: failedSteps.length === 0,
|
|
72
|
+
command: 'verify',
|
|
73
|
+
summary: verifySummary({ results, failed: failedSteps, skipped: skippedSteps, totalMs }),
|
|
74
|
+
steps: results,
|
|
75
|
+
// `skipped` is a list beside `failed` and not a count, because the two answer the same kind of
|
|
76
|
+
// question — *which* steps, not how many — and a caller ratcheting on coverage needs the names.
|
|
77
|
+
data: { failed: failedSteps, skipped: skippedSteps, durationMs: totalMs },
|
|
78
|
+
exitCode: failedSteps.length === 0 ? 0 : 1,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* What the counts are allowed to claim. A step that does not apply is recorded green so the run
|
|
84
|
+
* continues, and the summary counted it among the "all 17 steps passed" — so a repo whose `job`
|
|
85
|
+
* and `eval` suites do not exist reported the same line as a repo where both ran. `--json` carried
|
|
86
|
+
* the per-step flag all along; the one line every reader actually sees did not, which is how a
|
|
87
|
+
* vacuous gate stayed invisible. It names the skipped steps, not just how many: "17/17" is worth
|
|
88
|
+
* something only when the gap is visible in the same glance.
|
|
89
|
+
*/
|
|
90
|
+
function verifySummary(input: {
|
|
91
|
+
readonly results: readonly StepResult[];
|
|
92
|
+
readonly failed: readonly string[];
|
|
93
|
+
readonly skipped: readonly string[];
|
|
94
|
+
readonly totalMs: number;
|
|
95
|
+
}): string {
|
|
96
|
+
const params = {
|
|
97
|
+
count: input.results.length,
|
|
98
|
+
passed: input.results.filter((step) => step.ok && step.skipped !== true).length,
|
|
99
|
+
failed: input.failed.length,
|
|
100
|
+
skipped: input.skipped.length,
|
|
101
|
+
names: input.skipped.join(', '),
|
|
102
|
+
ms: input.totalMs,
|
|
103
|
+
};
|
|
104
|
+
const clean = input.skipped.length === 0;
|
|
105
|
+
if (input.failed.length === 0) {
|
|
106
|
+
return msg(clean ? 'cli.verify.pass' : 'cli.verify.passSkipped', params);
|
|
107
|
+
}
|
|
108
|
+
return msg(clean ? 'cli.verify.fail' : 'cli.verify.failSkipped', params);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function findingOf(error: unknown, step: string): Finding {
|
|
112
|
+
// A step may throw anything, including an Error that fights being read: `instanceof` runs a
|
|
113
|
+
// Proxy's `getPrototypeOf` trap and `.message` runs a getter, so a hostile throw would take the
|
|
114
|
+
// gate's own report down with it — the one message that may never be lost.
|
|
115
|
+
const cause = renderThrowable(error);
|
|
116
|
+
return {
|
|
117
|
+
code: 'X_VERIFY_FAILED',
|
|
118
|
+
cause: `step "${step}" threw: ${cause}`,
|
|
119
|
+
fix: 'x verify --json',
|
|
120
|
+
docs: 'https://ultimate.dev/errors/X_VERIFY_FAILED',
|
|
121
|
+
};
|
|
122
|
+
}
|
package/src/verify-step.ts
CHANGED
|
@@ -33,6 +33,13 @@ export const VERIFY_STEP_NAMES = [
|
|
|
33
33
|
// enforces — and `verifyCommand.run` passes no host checks at all, so the app path could not
|
|
34
34
|
// have carried it. It runs beside `budgets` because both read the app the same load produced.
|
|
35
35
|
'seo',
|
|
36
|
+
// Nineteenth, by the same test the SEO step above passed and for the same reason it is not a
|
|
37
|
+
// rider: `boundaries` asks whether an import was LEGAL and this asks whether a declaration
|
|
38
|
+
// REACHED the running app, which is a different question with a different fix (axiom 4). It
|
|
39
|
+
// costs no second app load — `budgets` already imported every module, and this reads the
|
|
40
|
+
// registries that load filled. Until it existed, an app could ship every user-facing string as
|
|
41
|
+
// `⟦key⟧` with `x verify` green, because nothing in the gate ever asked (issue #249).
|
|
42
|
+
'i18n',
|
|
36
43
|
'manifest',
|
|
37
44
|
'roadmap',
|
|
38
45
|
] as const;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// Types for the two Babel packages the island JSX transform calls. Neither ships declarations and
|
|
2
|
+
// no `@types/babel-preset-solid` exists — and `@ultimat3/cli` ships SOURCE, so an APP typechecks
|
|
3
|
+
// `solid-loader.ts` and a `@types/*` devDependency here would never reach it. Only the surface
|
|
4
|
+
// actually called is declared: a fuller copy of Babel's types is a second one to keep in step.
|
|
5
|
+
|
|
6
|
+
declare module '@babel/core' {
|
|
7
|
+
export interface BabelTransformOptions {
|
|
8
|
+
readonly filename?: string;
|
|
9
|
+
readonly babelrc?: boolean;
|
|
10
|
+
readonly configFile?: boolean;
|
|
11
|
+
readonly parserOpts?: { readonly plugins?: readonly string[] };
|
|
12
|
+
/** `[preset, options]` pairs. The preset itself is opaque here — it is never called. */
|
|
13
|
+
readonly presets?: readonly (readonly [unknown, unknown])[];
|
|
14
|
+
}
|
|
15
|
+
export interface BabelFileResult {
|
|
16
|
+
readonly code?: string | null;
|
|
17
|
+
}
|
|
18
|
+
export function transformAsync(
|
|
19
|
+
source: string,
|
|
20
|
+
options: BabelTransformOptions,
|
|
21
|
+
): Promise<BabelFileResult | null>;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
declare module 'babel-preset-solid' {
|
|
25
|
+
/** A Babel preset factory, handed straight to `presets:` and never invoked by this package. */
|
|
26
|
+
const preset: unknown;
|
|
27
|
+
// `export =`, not `export default`: the package really is CommonJS whose `module.exports` IS the
|
|
28
|
+
// factory, and that is what `esModuleInterop` gives the default import. It also keeps this file
|
|
29
|
+
// clear of `noDefaultExport`, which `biome.json` waives for `scss.d.ts` alone.
|
|
30
|
+
export = preset;
|
|
31
|
+
}
|