@ultimat3/cli 31.33.0 → 31.35.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/package.json +29 -29
- package/src/docs-section.ts +2 -2
- package/src/error-contract.ts +153 -27
- package/src/error-unthrown.ts +44 -16
- package/src/index.ts +5 -1
- package/wiki/CLI-Reference.md +1 -1
- package/wiki/N-Plus-One-Detection.md +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ultimat3/cli",
|
|
3
|
-
"version": "31.
|
|
3
|
+
"version": "31.35.0",
|
|
4
4
|
"description": "The `x` binary: new, dev, build, verify, generate, db, mcp, doctor, deploy",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ultimate",
|
|
@@ -53,34 +53,34 @@
|
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"@babel/core": "^8.0.10",
|
|
56
|
-
"@ultimat3/action": "31.
|
|
57
|
-
"@ultimat3/admin": "31.
|
|
58
|
-
"@ultimat3/ai": "31.
|
|
59
|
-
"@ultimat3/auth": "31.
|
|
60
|
-
"@ultimat3/cache": "31.
|
|
61
|
-
"@ultimat3/core": "31.
|
|
62
|
-
"@ultimat3/db": "31.
|
|
63
|
-
"@ultimat3/entity": "31.
|
|
64
|
-
"@ultimat3/flags": "31.
|
|
65
|
-
"@ultimat3/http": "31.
|
|
66
|
-
"@ultimat3/i18n": "31.
|
|
67
|
-
"@ultimat3/jobs": "31.
|
|
68
|
-
"@ultimat3/mail": "31.
|
|
69
|
-
"@ultimat3/manifest": "31.
|
|
70
|
-
"@ultimat3/mcp": "31.
|
|
71
|
-
"@ultimat3/money": "31.
|
|
72
|
-
"@ultimat3/notify": "31.
|
|
73
|
-
"@ultimat3/policy": "31.
|
|
74
|
-
"@ultimat3/pwa": "31.
|
|
75
|
-
"@ultimat3/query": "31.
|
|
76
|
-
"@ultimat3/realtime": "31.
|
|
77
|
-
"@ultimat3/render": "31.
|
|
78
|
-
"@ultimat3/schema": "31.
|
|
79
|
-
"@ultimat3/scraping": "31.
|
|
80
|
-
"@ultimat3/seo": "31.
|
|
81
|
-
"@ultimat3/storage": "31.
|
|
82
|
-
"@ultimat3/testing": "31.
|
|
83
|
-
"@ultimat3/time": "31.
|
|
56
|
+
"@ultimat3/action": "31.35.0",
|
|
57
|
+
"@ultimat3/admin": "31.35.0",
|
|
58
|
+
"@ultimat3/ai": "31.35.0",
|
|
59
|
+
"@ultimat3/auth": "31.35.0",
|
|
60
|
+
"@ultimat3/cache": "31.35.0",
|
|
61
|
+
"@ultimat3/core": "31.35.0",
|
|
62
|
+
"@ultimat3/db": "31.35.0",
|
|
63
|
+
"@ultimat3/entity": "31.35.0",
|
|
64
|
+
"@ultimat3/flags": "31.35.0",
|
|
65
|
+
"@ultimat3/http": "31.35.0",
|
|
66
|
+
"@ultimat3/i18n": "31.35.0",
|
|
67
|
+
"@ultimat3/jobs": "31.35.0",
|
|
68
|
+
"@ultimat3/mail": "31.35.0",
|
|
69
|
+
"@ultimat3/manifest": "31.35.0",
|
|
70
|
+
"@ultimat3/mcp": "31.35.0",
|
|
71
|
+
"@ultimat3/money": "31.35.0",
|
|
72
|
+
"@ultimat3/notify": "31.35.0",
|
|
73
|
+
"@ultimat3/policy": "31.35.0",
|
|
74
|
+
"@ultimat3/pwa": "31.35.0",
|
|
75
|
+
"@ultimat3/query": "31.35.0",
|
|
76
|
+
"@ultimat3/realtime": "31.35.0",
|
|
77
|
+
"@ultimat3/render": "31.35.0",
|
|
78
|
+
"@ultimat3/schema": "31.35.0",
|
|
79
|
+
"@ultimat3/scraping": "31.35.0",
|
|
80
|
+
"@ultimat3/seo": "31.35.0",
|
|
81
|
+
"@ultimat3/storage": "31.35.0",
|
|
82
|
+
"@ultimat3/testing": "31.35.0",
|
|
83
|
+
"@ultimat3/time": "31.35.0",
|
|
84
84
|
"babel-preset-solid": "^1.9.16"
|
|
85
85
|
}
|
|
86
86
|
}
|
package/src/docs-section.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
// why: Bun ships no path module; the page is joined onto the wiki directory the CLI resolved.
|
|
6
6
|
import { join } from 'node:path';
|
|
7
|
-
import { wikiSection } from '@ultimat3/manifest';
|
|
7
|
+
import { isErrorCodesPage, wikiSection } from '@ultimat3/manifest';
|
|
8
8
|
import type { WikiSource } from './docs-sources';
|
|
9
9
|
import { msg } from './messages';
|
|
10
10
|
import type { CommandResult } from './output';
|
|
@@ -35,7 +35,7 @@ export async function sectionResult(
|
|
|
35
35
|
topic: WikiTopic,
|
|
36
36
|
query: string,
|
|
37
37
|
): Promise<CommandResult | undefined> {
|
|
38
|
-
if (topic.page
|
|
38
|
+
if (isErrorCodesPage(topic.page)) return undefined;
|
|
39
39
|
const file = Bun.file(join(wiki.dir, `${topic.page}.md`));
|
|
40
40
|
if (!(await file.exists())) return undefined;
|
|
41
41
|
const text = wikiSection(await file.text(), topic.anchor);
|
package/src/error-contract.ts
CHANGED
|
@@ -178,16 +178,86 @@ export const checkErrorFixes = async (root: string): Promise<readonly Finding[]>
|
|
|
178
178
|
(await checkErrorFixReport(root)).findings;
|
|
179
179
|
|
|
180
180
|
/**
|
|
181
|
-
*
|
|
182
|
-
*
|
|
183
|
-
*
|
|
181
|
+
* One page of the error reference as the host read it, `path` relative to the repo root. The
|
|
182
|
+
* reference is a SET — an index (`wiki/Error-Codes.md`, which holds the reserved block) and one
|
|
183
|
+
* `Error-Codes-<owner>.md` per owner — and every rule here reads the whole set: a check handed one
|
|
184
|
+
* page would read every other owner's code as undocumented, or every ghost on them as absent.
|
|
184
185
|
*/
|
|
186
|
+
export interface ErrorCodePage {
|
|
187
|
+
readonly path: string;
|
|
188
|
+
readonly text: string;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/** Where the index lives when the host read no page at all: the framework's own reference. */
|
|
192
|
+
const DEFAULT_INDEX = 'wiki/Error-Codes.md';
|
|
193
|
+
const INDEX_NAME = 'Error-Codes.md';
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* The index of the set — the page the reserved block lives on. A set with no `Error-Codes.md` is
|
|
197
|
+
* one page a deprecated single-page caller named, and that page is its own index.
|
|
198
|
+
*/
|
|
199
|
+
export const errorCodeIndex = (pages: readonly ErrorCodePage[]): string =>
|
|
200
|
+
pages.find((page) => page.path === INDEX_NAME || page.path.endsWith(`/${INDEX_NAME}`))?.path ??
|
|
201
|
+
pages[0]?.path ??
|
|
202
|
+
DEFAULT_INDEX;
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Who owns a declaration, read off its path: a package by its directory name, anything else by its
|
|
206
|
+
* top directory (`scripts`). The same rule `scripts/manifest.ts`' `ownerOf` files a code under in
|
|
207
|
+
* `framework.manifest.json`, so the page this names is the page the manifest says it lives on.
|
|
208
|
+
*/
|
|
209
|
+
function errorCodeOwner(at: string): string {
|
|
210
|
+
const segments = at.split('/');
|
|
211
|
+
return (segments[0] === 'packages' ? segments[1] : segments[0]) ?? '';
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/** The owner page a code's row belongs on: `Error-Codes-<owner>.md`, beside the index. */
|
|
215
|
+
function errorCodeOwnerPage(pages: readonly ErrorCodePage[], at: string): string {
|
|
216
|
+
const index = errorCodeIndex(pages);
|
|
217
|
+
const dir = index.slice(0, index.lastIndexOf('/') + 1);
|
|
218
|
+
return `${dir}Error-Codes-${errorCodeOwner(at)}.md`;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
const CODE_MENTION = /`(X_[A-Z0-9_]+)`/g;
|
|
222
|
+
|
|
223
|
+
/** Pages in path order, so "the first page naming a code" is the same answer on every machine. */
|
|
224
|
+
const byPath = (pages: readonly ErrorCodePage[]): readonly ErrorCodePage[] =>
|
|
225
|
+
[...pages].sort((a, b) => (a.path < b.path ? -1 : a.path > b.path ? 1 : 0));
|
|
226
|
+
|
|
227
|
+
const mentionsOf = (
|
|
228
|
+
pages: readonly ErrorCodePage[],
|
|
229
|
+
textOf: (page: ErrorCodePage) => string,
|
|
230
|
+
): ReadonlyMap<string, string> => {
|
|
231
|
+
const out = new Map<string, string>();
|
|
232
|
+
for (const page of byPath(pages)) {
|
|
233
|
+
for (const match of textOf(page).matchAll(CODE_MENTION)) {
|
|
234
|
+
const code = match[1] as string;
|
|
235
|
+
if (!out.has(code)) out.set(code, page.path);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
return out;
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* A code is documented when a page of the set names it — code → the first page (by path) that
|
|
243
|
+
* does. Deliberately not "owns a table row": a page legitimately groups near-identical codes onto
|
|
244
|
+
* one row, and a rule that forbade that would be a rule about formatting rather than coverage. The
|
|
245
|
+
* index's generated "every code" table names each code plain, never in backticks, so it documents
|
|
246
|
+
* nothing on its own: the row on the owner page (or the reserved block) does.
|
|
247
|
+
*/
|
|
248
|
+
export const documentedCodesIn = (pages: readonly ErrorCodePage[]): ReadonlyMap<string, string> =>
|
|
249
|
+
mentionsOf(pages, (page) => page.text);
|
|
250
|
+
|
|
251
|
+
/** The one-page set a deprecated single-page caller's markdown stands for. */
|
|
252
|
+
const legacyPage = (text: string): readonly ErrorCodePage[] => [{ path: DEFAULT_INDEX, text }];
|
|
253
|
+
|
|
254
|
+
/** @deprecated Use documentedCodesIn(pages) — the error reference is a page set since 31.35.0; removed at the next major. */
|
|
185
255
|
export const documentedCodes = (markdown: string): ReadonlySet<string> =>
|
|
186
|
-
new Set(
|
|
256
|
+
new Set(documentedCodesIn(legacyPage(markdown)).keys());
|
|
187
257
|
|
|
188
258
|
const undocumentedFinding = (code: string, at: string, line: number, page: string): Finding => ({
|
|
189
259
|
code: 'X_ERROR_CODE_UNDOCUMENTED',
|
|
190
|
-
cause: `${code} is declared at ${at}:${line} and
|
|
260
|
+
cause: `${code} is declared at ${at}:${line} and no error reference page has an entry for it`,
|
|
191
261
|
fix: `add a row for ${code} to ${page}, with its cause and the command that fixes it`,
|
|
192
262
|
docs: ERROR_DOCS_URL,
|
|
193
263
|
at: page,
|
|
@@ -197,12 +267,12 @@ const undocumentedFinding = (code: string, at: string, line: number, page: strin
|
|
|
197
267
|
* The heading below which the reference stops making live claims. What follows is a code that is
|
|
198
268
|
* reserved (documented, nothing throws it yet) or a superseded name kept so an old log line still
|
|
199
269
|
* resolves. Both earn their rows; neither is a code an agent can be handed today, which is the
|
|
200
|
-
* only thing the registry rule below is about.
|
|
270
|
+
* only thing the registry rule below is about. It lives on the index; an owner page has none.
|
|
201
271
|
*/
|
|
202
272
|
export const RESERVED_HEADING = '## Reserved codes';
|
|
203
273
|
|
|
204
274
|
/**
|
|
205
|
-
*
|
|
275
|
+
* One page's live text: everything above its reserved heading, or all of it.
|
|
206
276
|
*
|
|
207
277
|
* The heading is matched as a whole line, never as a substring. The same text is quoted in prose,
|
|
208
278
|
* in a fenced sample and in this file's own `unregisteredFinding` fix — and `indexOf` would cut the
|
|
@@ -210,16 +280,34 @@ export const RESERVED_HEADING = '## Reserved codes';
|
|
|
210
280
|
* registry rule. A gate that stops reading halfway through the page reads green over the half it
|
|
211
281
|
* never saw.
|
|
212
282
|
*/
|
|
213
|
-
|
|
283
|
+
const liveText = (markdown: string): string => {
|
|
214
284
|
const lines = markdown.split('\n');
|
|
215
285
|
const cut = lines.findIndex((line) => line.trim() === RESERVED_HEADING);
|
|
216
|
-
return
|
|
286
|
+
return cut === -1 ? markdown : lines.slice(0, cut).join('\n');
|
|
287
|
+
};
|
|
288
|
+
|
|
289
|
+
/** The codes the reference presents as live — code → the first page naming it above any cut. */
|
|
290
|
+
export const liveCodesIn = (pages: readonly ErrorCodePage[]): ReadonlyMap<string, string> =>
|
|
291
|
+
mentionsOf(pages, (page) => liveText(page.text));
|
|
292
|
+
|
|
293
|
+
/** @deprecated Use liveCodesIn(pages) — the error reference is a page set since 31.35.0; removed at the next major. */
|
|
294
|
+
export function liveCodes(markdown: string): ReadonlySet<string> {
|
|
295
|
+
return new Set(liveCodesIn(legacyPage(markdown)).keys());
|
|
217
296
|
}
|
|
218
297
|
|
|
219
|
-
|
|
298
|
+
/** A deprecated caller's one page, read off disk: `undefined` when it is not there. */
|
|
299
|
+
export async function readLegacyPage(
|
|
300
|
+
root: string,
|
|
301
|
+
page: string,
|
|
302
|
+
): Promise<readonly ErrorCodePage[] | undefined> {
|
|
303
|
+
const file = Bun.file(join(root, page));
|
|
304
|
+
return (await file.exists()) ? [{ path: page, text: await file.text() }] : undefined;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
const unregisteredFinding = (code: string, page: string, index: string): Finding => ({
|
|
220
308
|
code: 'X_ERROR_CODE_UNREGISTERED',
|
|
221
309
|
cause: `${page} documents ${code} as a live code and nothing registers it, so "x errors explain ${code}" refuses a code this page promises`,
|
|
222
|
-
fix: `register ${code} through registerErrorCodes() in its package's src/errors.ts, or move its row under "${RESERVED_HEADING}" in ${
|
|
310
|
+
fix: `register ${code} through registerErrorCodes() in its package's src/errors.ts, or move its row under "${RESERVED_HEADING}" in ${index}`,
|
|
223
311
|
docs: ERROR_DOCS_URL,
|
|
224
312
|
at: page,
|
|
225
313
|
});
|
|
@@ -232,19 +320,27 @@ const unregisteredFinding = (code: string, page: string): Finding => ({
|
|
|
232
320
|
*
|
|
233
321
|
* `known` is what the host can answer for: the process-wide registry, plus whatever codes the host
|
|
234
322
|
* repo's own gate scripts declare (`X_ROADMAP_*` and friends never ship, so no package may own
|
|
235
|
-
* them).
|
|
323
|
+
* them). An empty reference is `checkErrorCodeDocsIn`'s finding to report, not a second copy here.
|
|
236
324
|
*/
|
|
325
|
+
export function checkErrorCodeRegistryIn(
|
|
326
|
+
pages: readonly ErrorCodePage[],
|
|
327
|
+
known: ReadonlySet<string>,
|
|
328
|
+
): readonly Finding[] {
|
|
329
|
+
const index = errorCodeIndex(pages);
|
|
330
|
+
return [...liveCodesIn(pages)]
|
|
331
|
+
.filter(([code]) => !known.has(code))
|
|
332
|
+
.sort(([a], [b]) => a.localeCompare(b))
|
|
333
|
+
.map(([code, page]) => unregisteredFinding(code, page, index));
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
/** @deprecated Use checkErrorCodeRegistryIn(pages, known) — the error reference is a page set since 31.35.0; removed at the next major. */
|
|
237
337
|
export async function checkErrorCodeRegistry(
|
|
238
338
|
root: string,
|
|
239
339
|
page: string,
|
|
240
340
|
known: ReadonlySet<string>,
|
|
241
341
|
): Promise<readonly Finding[]> {
|
|
242
|
-
const
|
|
243
|
-
|
|
244
|
-
return [...liveCodes(await reference.text())]
|
|
245
|
-
.filter((code) => !known.has(code))
|
|
246
|
-
.sort()
|
|
247
|
-
.map((code) => unregisteredFinding(code, page));
|
|
342
|
+
const pages = await readLegacyPage(root, page);
|
|
343
|
+
return pages === undefined ? [] : checkErrorCodeRegistryIn(pages, known);
|
|
248
344
|
}
|
|
249
345
|
|
|
250
346
|
/**
|
|
@@ -327,14 +423,46 @@ export async function checkErrorCodeResolution(root: string): Promise<readonly F
|
|
|
327
423
|
return findings;
|
|
328
424
|
}
|
|
329
425
|
|
|
426
|
+
/** A declared code no page names, reported where `rowPage` says its row belongs. */
|
|
427
|
+
async function undocumentedIn(
|
|
428
|
+
root: string,
|
|
429
|
+
pages: readonly ErrorCodePage[],
|
|
430
|
+
rowPage: (at: string) => string,
|
|
431
|
+
): Promise<readonly Finding[]> {
|
|
432
|
+
const documented = documentedCodesIn(pages);
|
|
433
|
+
return (await collectDeclaredCodes(root))
|
|
434
|
+
.filter((site) => !documented.has(site.code))
|
|
435
|
+
.map((site) => undocumentedFinding(site.code, site.at, site.line, rowPage(site.at)));
|
|
436
|
+
}
|
|
437
|
+
|
|
330
438
|
/**
|
|
331
|
-
* Every `X_*` code shipped source declares must appear on the repo's error reference
|
|
332
|
-
* the
|
|
333
|
-
*
|
|
439
|
+
* Every `X_*` code shipped source declares must appear on the repo's error reference — on some page
|
|
440
|
+
* of the set, and a missing one is owed on its owner's page. The set is the host repo's to name — a
|
|
441
|
+
* framework monorepo publishes one, a generated app does not — which is why this arrives through
|
|
442
|
+
* the same host-check seam the tier table uses on `boundaries`.
|
|
334
443
|
*/
|
|
444
|
+
export async function checkErrorCodeDocsIn(
|
|
445
|
+
root: string,
|
|
446
|
+
pages: readonly ErrorCodePage[],
|
|
447
|
+
): Promise<readonly Finding[]> {
|
|
448
|
+
if (pages.length === 0) {
|
|
449
|
+
return [
|
|
450
|
+
{
|
|
451
|
+
code: 'X_ERROR_CODE_UNDOCUMENTED',
|
|
452
|
+
cause: 'the error reference has no page, so no code can be documented',
|
|
453
|
+
fix: `git restore --source=HEAD -- wiki/Error-Codes.md 'wiki/Error-Codes-*.md' # the pages were deleted; a new repo creates them with bun run new-error-code`,
|
|
454
|
+
docs: ERROR_DOCS_URL,
|
|
455
|
+
at: DEFAULT_INDEX,
|
|
456
|
+
},
|
|
457
|
+
];
|
|
458
|
+
}
|
|
459
|
+
return undocumentedIn(root, pages, (at) => errorCodeOwnerPage(pages, at));
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
/** @deprecated Use checkErrorCodeDocsIn(root, pages) — the error reference is a page set since 31.35.0; removed at the next major. */
|
|
335
463
|
export async function checkErrorCodeDocs(root: string, page: string): Promise<readonly Finding[]> {
|
|
336
|
-
const
|
|
337
|
-
if (
|
|
464
|
+
const pages = await readLegacyPage(root, page);
|
|
465
|
+
if (pages === undefined) {
|
|
338
466
|
return [
|
|
339
467
|
{
|
|
340
468
|
code: 'X_ERROR_CODE_UNDOCUMENTED',
|
|
@@ -345,8 +473,6 @@ export async function checkErrorCodeDocs(root: string, page: string): Promise<re
|
|
|
345
473
|
},
|
|
346
474
|
];
|
|
347
475
|
}
|
|
348
|
-
|
|
349
|
-
return (
|
|
350
|
-
.filter((site) => !documented.has(site.code))
|
|
351
|
-
.map((site) => undocumentedFinding(site.code, site.at, site.line, page));
|
|
476
|
+
// The one page is where every row goes: a single-page reference has no owner pages.
|
|
477
|
+
return undocumentedIn(root, pages, () => page);
|
|
352
478
|
}
|
package/src/error-unthrown.ts
CHANGED
|
@@ -8,7 +8,13 @@
|
|
|
8
8
|
// why: Bun ships no path API; `join` builds the absolute path of each scanned file.
|
|
9
9
|
import { join } from 'node:path';
|
|
10
10
|
import { ERROR_DOCS_URL, maskLiterals, stripComments } from '@ultimat3/core';
|
|
11
|
-
import {
|
|
11
|
+
import type { ErrorCodePage } from './error-contract';
|
|
12
|
+
import {
|
|
13
|
+
documentedCodesIn,
|
|
14
|
+
errorCodeIndex,
|
|
15
|
+
RESERVED_HEADING,
|
|
16
|
+
readLegacyPage,
|
|
17
|
+
} from './error-contract';
|
|
12
18
|
import type { Finding } from './output';
|
|
13
19
|
import { eachSourceFile, isGenerated, isTest } from './source-files';
|
|
14
20
|
import { isCodeRegistry } from './ts-scan';
|
|
@@ -91,18 +97,28 @@ export async function collectCodeUse(root: string): Promise<CodeUse> {
|
|
|
91
97
|
return { registered, used };
|
|
92
98
|
}
|
|
93
99
|
|
|
94
|
-
/**
|
|
95
|
-
|
|
100
|
+
/**
|
|
101
|
+
* Codes that sit under a reserved heading — declared unthrown by WHERE they are, not by words. The
|
|
102
|
+
* heading lives on the index; each page is read on its own, so its cut never leaks onto the next.
|
|
103
|
+
*/
|
|
104
|
+
export function declaredUnthrownIn(pages: readonly ErrorCodePage[]): ReadonlySet<string> {
|
|
96
105
|
const out = new Set<string>();
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
106
|
+
for (const page of pages) {
|
|
107
|
+
let reserved = false;
|
|
108
|
+
for (const line of page.text.split('\n')) {
|
|
109
|
+
if (line.trim() === RESERVED_HEADING) reserved = true;
|
|
110
|
+
const row = /^\|\s*`(X_[A-Z0-9_]+)`\s*\|/.exec(line);
|
|
111
|
+
if (row !== null && reserved) out.add(row[1] ?? '');
|
|
112
|
+
}
|
|
102
113
|
}
|
|
103
114
|
return out;
|
|
104
115
|
}
|
|
105
116
|
|
|
117
|
+
/** @deprecated Use declaredUnthrownIn(pages) — the error reference is a page set since 31.35.0; removed at the next major. */
|
|
118
|
+
export function declaredUnthrown(markdown: string): ReadonlySet<string> {
|
|
119
|
+
return declaredUnthrownIn([{ path: 'wiki/Error-Codes.md', text: markdown }]);
|
|
120
|
+
}
|
|
121
|
+
|
|
106
122
|
const unthrownFinding = (code: string, page: string): Finding => ({
|
|
107
123
|
code: 'X_ERROR_CODE_UNTHROWN',
|
|
108
124
|
cause: `${code} is registered and ${page} presents it as live, but no shipped source constructs it — a reader matching on it waits for an error that cannot arrive. Add it to UNTHROWN_CODES in ${UNTHROWN_CODES_FILE} and say so in its row, or throw it again where it belongs`,
|
|
@@ -123,22 +139,25 @@ const staleFinding = (code: string): Finding => ({
|
|
|
123
139
|
|
|
124
140
|
/**
|
|
125
141
|
* Registered, used by nothing, and not declared unthrown on the reference. A host check — the page
|
|
126
|
-
* is the host repo's to name, and only a monorepo's walk sees every package's source; in a
|
|
127
|
-
* generated app every framework code would read as unthrown.
|
|
142
|
+
* set is the host repo's to name, and only a monorepo's walk sees every package's source; in a
|
|
143
|
+
* generated app every framework code would read as unthrown. Reported at the page whose row
|
|
144
|
+
* presents the code as live, or the index when no page names it. An empty set reports nothing:
|
|
145
|
+
* `checkErrorCodeDocsIn` owns that finding.
|
|
128
146
|
*/
|
|
129
|
-
export async function
|
|
147
|
+
export async function checkErrorCodesThrownIn(
|
|
130
148
|
root: string,
|
|
131
|
-
|
|
149
|
+
pages: readonly ErrorCodePage[],
|
|
132
150
|
listed: ReadonlySet<string> = UNTHROWN_CODES,
|
|
133
151
|
): Promise<readonly Finding[]> {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
const
|
|
152
|
+
if (pages.length === 0) return [];
|
|
153
|
+
const reserved = declaredUnthrownIn(pages);
|
|
154
|
+
const documented = documentedCodesIn(pages);
|
|
155
|
+
const index = errorCodeIndex(pages);
|
|
137
156
|
const { registered, used } = await collectCodeUse(root);
|
|
138
157
|
const unthrown = [...registered]
|
|
139
158
|
.filter((code) => !used.has(code) && !listed.has(code) && !reserved.has(code))
|
|
140
159
|
.sort()
|
|
141
|
-
.map((code) => unthrownFinding(code,
|
|
160
|
+
.map((code) => unthrownFinding(code, documented.get(code) ?? index));
|
|
142
161
|
// Only the THROWN-again direction: a listed name no registry holds waives nothing (the code it
|
|
143
162
|
// was meant to name is still reported), and a host repo's fixture registering none of this
|
|
144
163
|
// repo's codes would otherwise read every listing as stale.
|
|
@@ -148,3 +167,12 @@ export async function checkErrorCodesThrown(
|
|
|
148
167
|
.map((code) => staleFinding(code));
|
|
149
168
|
return [...unthrown, ...stale];
|
|
150
169
|
}
|
|
170
|
+
|
|
171
|
+
/** @deprecated Use checkErrorCodesThrownIn(root, pages, listed) — the error reference is a page set since 31.35.0; removed at the next major. */
|
|
172
|
+
export async function checkErrorCodesThrown(
|
|
173
|
+
root: string,
|
|
174
|
+
page: string,
|
|
175
|
+
listed: ReadonlySet<string> = UNTHROWN_CODES,
|
|
176
|
+
): Promise<readonly Finding[]> {
|
|
177
|
+
return checkErrorCodesThrownIn(root, (await readLegacyPage(root, page)) ?? [], listed);
|
|
178
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -48,17 +48,21 @@ export { dispatch } from './dispatch';
|
|
|
48
48
|
export { checkSourceDrift, reconcileSchemaHash, writeSchemaHash } from './drift';
|
|
49
49
|
export { registeredErrorCodes } from './error-catalog';
|
|
50
50
|
export type { CliErrorCode } from './error-codes';
|
|
51
|
+
export type { ErrorCodePage } from './error-contract';
|
|
51
52
|
export {
|
|
52
53
|
BANNED_PHRASES,
|
|
53
54
|
COMMAND_TOKENS,
|
|
54
55
|
checkErrorCodeDocs,
|
|
56
|
+
checkErrorCodeDocsIn,
|
|
55
57
|
checkErrorCodeRegistry,
|
|
58
|
+
checkErrorCodeRegistryIn,
|
|
56
59
|
checkErrorFixes,
|
|
57
60
|
collectDeclaredCodes,
|
|
58
61
|
documentedCodes,
|
|
62
|
+
documentedCodesIn,
|
|
59
63
|
fixProblem,
|
|
60
64
|
} from './error-contract';
|
|
61
|
-
export { checkErrorCodesThrown } from './error-unthrown';
|
|
65
|
+
export { checkErrorCodesThrown, checkErrorCodesThrownIn } from './error-unthrown';
|
|
62
66
|
export {
|
|
63
67
|
BadFlagError,
|
|
64
68
|
MissingPositionalError,
|
package/wiki/CLI-Reference.md
CHANGED
|
@@ -634,7 +634,7 @@ Errors, seed: `X_DECLARATION_UNKNOWN` (no seed of that name — the cause lists
|
|
|
634
634
|
|
|
635
635
|
Errors, schema: `X_DB_DRIFT`, `X_SCHEMA_DUMP_DRIFT`, `X_DB_GEN_FAILED`, `X_DB_MIGRATE_FAILED`, `X_DB_BRANCH_FAILED`, `X_MIGRATION_CONFLICT`, `X_MIGRATION_IRREVERSIBLE`, `X_MIGRATION_VIEW_DEPENDS`, `X_MIGRATE_CONCURRENT`, `X_NOT_IMPLEMENTED`. `X_DB_STUDIO_FAILED` is reserved and no longer thrown — `studio` left `x db` `As of 2026-11-15` ([Known gaps](Known-Gaps#open-by-decision)).
|
|
636
636
|
|
|
637
|
-
Errors, backfill: `X_BACKFILL_PENDING` (`--pending`, and the only one that is not a refusal — the sweep simply has not run), `X_BACKFILL_UNKNOWN`, `X_BACKFILL_ENVIRONMENT`, `X_BACKFILL_MIGRATION_PENDING`, `X_BACKFILL_APPLIED`, `X_BACKFILL_RUNNING`. All six are `@ultimat3/jobs`', carry a one-line runnable `fix:`, and are what a non-zero exit from these shapes means — full wording in [Error codes →
|
|
637
|
+
Errors, backfill: `X_BACKFILL_PENDING` (`--pending`, and the only one that is not a refusal — the sweep simply has not run), `X_BACKFILL_UNKNOWN`, `X_BACKFILL_ENVIRONMENT`, `X_BACKFILL_MIGRATION_PENDING`, `X_BACKFILL_APPLIED`, `X_BACKFILL_RUNNING`. All six are `@ultimat3/jobs`', carry a one-line runnable `fix:`, and are what a non-zero exit from these shapes means — full wording in [Error codes → `@ultimat3/jobs`](Error-Codes-jobs). `X_BACKFILL_STALLED` is the seventh and never reaches this command: it is raised by the pass, on a worker, so it surfaces through `x jobs show <id>`.
|
|
638
638
|
|
|
639
639
|
## x verify
|
|
640
640
|
|
|
@@ -25,7 +25,7 @@ Who *raises* it is a separate question, and the answer differs by surface:
|
|
|
25
25
|
|
|
26
26
|
`packages/cli/src/statement-loop.ts` is what keeps them identical: it calls `@ultimat3/entity`'s
|
|
27
27
|
`nPlusOne` and reads `code`/`cause`/`fix` off the resulting error rather than restating any of it.
|
|
28
|
-
Full row, verbatim: [Error codes →
|
|
28
|
+
Full row, verbatim: [Error codes → `@ultimat3/entity`](Error-Codes-entity).
|
|
29
29
|
|
|
30
30
|
## Before / after
|
|
31
31
|
|