@ultimat3/cli 31.39.0 → 31.40.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/package.json +29 -29
- package/src/cmd-errors-guards.ts +69 -0
- package/src/cmd-errors.ts +11 -4
- package/src/cmd-exercise.ts +3 -2
- package/src/cmd-new-spec.ts +6 -1
- package/src/cmd-new-target.ts +73 -0
- package/src/cmd-new.ts +12 -19
- package/src/cmd-repro.ts +2 -1
- package/src/codemods/ci-e2e-browser.ts +7 -1
- package/src/codemods/ci-services-env.ts +25 -0
- package/src/codemods/docs-env-guard.ts +31 -0
- package/src/codemods/index.ts +4 -0
- package/src/dev-boot.ts +3 -0
- package/src/dev-rebuild-isr.ts +17 -0
- package/src/dev-rebuild.ts +14 -5
- package/src/error-contract.ts +11 -4
- package/src/exercise-findings-unreached.ts +94 -0
- package/src/exercise-findings.ts +9 -57
- package/src/exercise-route-api.ts +3 -4
- package/src/fix-sequence.ts +28 -3
- package/src/framework-schema-wait.ts +41 -2
- package/src/generate-feature-required.ts +40 -3
- package/src/generate-kinds.ts +23 -2
- package/src/guards-shipped-names.ts +1 -0
- package/src/messages.ts +5 -0
- package/src/serve-boot.ts +4 -0
- package/src/templates/action.ts +7 -2
- package/src/templates/github/ci.yml.ts +3 -2
- package/src/templates/guard-raw-colour.ts +88 -13
- package/src/templates/guard-released-forms.ts +9 -3
- package/src/templates/guard-undeclared-env.ts +192 -0
- package/src/templates/guard-untranslated-string.ts +29 -1
- package/src/templates/policy.ts +7 -1
- package/src/templates/query.ts +8 -6
- package/src/templates/scaffold-docs.ts +1 -0
- package/src/templates/scaffold-guards.ts +4 -1
- package/src/templates/scaffold-i18n.ts +1 -1
- package/src/templates/scaffold-repo.ts +26 -24
- package/src/templates/shapes/agent.ts +2 -2
- package/src/templates/shapes/offline.ts +1 -1
- package/src/templates/shapes/realtime.ts +2 -2
- package/src/templates/shapes/saas.ts +5 -4
- package/src/templates/slice-foundation.ts +29 -9
- package/wiki/Actions.md +1 -1
- package/wiki/CLI-Reference.md +1 -1
- package/wiki/Getting-Started.md +1 -1
- package/wiki/Installation.md +2 -2
- package/wiki/Queries-And-Live-Queries.md +4 -4
- package/wiki/Realtime.md +2 -2
- package/wiki/Tutorial-04-Jobs-And-Realtime.md +3 -2
- package/wiki/Upgrading.md +2 -1
package/README.md
CHANGED
|
@@ -184,7 +184,7 @@ failure — so a rule ships to every app before the apps are clean of it; a find
|
|
|
184
184
|
contract fails either way. `repo-await-in-loop` ships that way. `x g guard <name>` scaffolds the
|
|
185
185
|
app's own with its test.
|
|
186
186
|
|
|
187
|
-
The twenty-
|
|
187
|
+
The twenty-seven shipped guards (`SHIPPED_GUARD_NAMES`) run **built in**, from the installed CLI,
|
|
188
188
|
never from a copy (`guards-built-in.ts`, `As of 2026-11`): `x new` writes only
|
|
189
189
|
`guards/shipped.json`, `{ "severity": { "<guard>": "error" | "warning" | "off" } }`, and its
|
|
190
190
|
presence is the opt-in. Absent (a legacy app), a shipped guard the app holds a copy of runs that
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ultimat3/cli",
|
|
3
|
-
"version": "31.
|
|
3
|
+
"version": "31.40.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.40.0",
|
|
57
|
+
"@ultimat3/admin": "31.40.0",
|
|
58
|
+
"@ultimat3/ai": "31.40.0",
|
|
59
|
+
"@ultimat3/auth": "31.40.0",
|
|
60
|
+
"@ultimat3/cache": "31.40.0",
|
|
61
|
+
"@ultimat3/core": "31.40.0",
|
|
62
|
+
"@ultimat3/db": "31.40.0",
|
|
63
|
+
"@ultimat3/entity": "31.40.0",
|
|
64
|
+
"@ultimat3/flags": "31.40.0",
|
|
65
|
+
"@ultimat3/http": "31.40.0",
|
|
66
|
+
"@ultimat3/i18n": "31.40.0",
|
|
67
|
+
"@ultimat3/jobs": "31.40.0",
|
|
68
|
+
"@ultimat3/mail": "31.40.0",
|
|
69
|
+
"@ultimat3/manifest": "31.40.0",
|
|
70
|
+
"@ultimat3/mcp": "31.40.0",
|
|
71
|
+
"@ultimat3/money": "31.40.0",
|
|
72
|
+
"@ultimat3/notify": "31.40.0",
|
|
73
|
+
"@ultimat3/policy": "31.40.0",
|
|
74
|
+
"@ultimat3/pwa": "31.40.0",
|
|
75
|
+
"@ultimat3/query": "31.40.0",
|
|
76
|
+
"@ultimat3/realtime": "31.40.0",
|
|
77
|
+
"@ultimat3/render": "31.40.0",
|
|
78
|
+
"@ultimat3/schema": "31.40.0",
|
|
79
|
+
"@ultimat3/scraping": "31.40.0",
|
|
80
|
+
"@ultimat3/seo": "31.40.0",
|
|
81
|
+
"@ultimat3/storage": "31.40.0",
|
|
82
|
+
"@ultimat3/testing": "31.40.0",
|
|
83
|
+
"@ultimat3/time": "31.40.0",
|
|
84
84
|
"babel-preset-solid": "^1.9.16"
|
|
85
85
|
}
|
|
86
86
|
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// `x errors explain` for a code a guard raises: the shipped guards' (`X_RAW_COLOUR`, derived from the
|
|
2
|
+
// guard's name) and the app's own `guards/*.ts`. Neither is in an error registry — the app owns
|
|
3
|
+
// the codes its conventions raise — so each is answered from the guard's own declaration: its
|
|
4
|
+
// `summary`, read off the source text, never by importing and running the rule.
|
|
5
|
+
|
|
6
|
+
// why: Bun ships no path joiner; `guards/` sits under the app root.
|
|
7
|
+
import { join } from 'node:path';
|
|
8
|
+
import { ERROR_DOCS_URL } from '@ultimat3/core';
|
|
9
|
+
import type { ErrorExplanation } from '@ultimat3/mcp';
|
|
10
|
+
import { findAppRoot } from './app-root';
|
|
11
|
+
import { SHIPPED_GUARD_CONFIG, SHIPPED_SEVERITY_FIELD } from './guards-built-in';
|
|
12
|
+
import { SHIPPED_GUARD_NAMES, shippedGuardCode } from './guards-shipped-names';
|
|
13
|
+
|
|
14
|
+
/** `summary: '…'` in a guard's `export const guard = { … }`, the line broken after the colon or not. */
|
|
15
|
+
const SUMMARY = /\bsummary:\s*'((?:[^'\\]|\\.)*)'/;
|
|
16
|
+
|
|
17
|
+
const summaryOf = (source: string): string | undefined => SUMMARY.exec(source)?.[1];
|
|
18
|
+
|
|
19
|
+
const RUN = 'x verify --only boundaries --json';
|
|
20
|
+
|
|
21
|
+
/** A shipped guard: its template's text, loaded only when a guard code was asked about. */
|
|
22
|
+
async function explainShipped(code: string): Promise<ErrorExplanation | undefined> {
|
|
23
|
+
const name = SHIPPED_GUARD_NAMES.find((one) => shippedGuardCode(one) === code);
|
|
24
|
+
if (name === undefined) return undefined;
|
|
25
|
+
const { shippedGuardSource } = await import('./templates/scaffold-guards');
|
|
26
|
+
const summary = summaryOf(shippedGuardSource(name) ?? '') ?? name;
|
|
27
|
+
return {
|
|
28
|
+
code,
|
|
29
|
+
cause: `the shipped ${name} guard refuses it: ${summary} (run by the boundaries step of x verify)`,
|
|
30
|
+
fix: `${RUN} # each ${code} finding names its file:line and the edit that clears it; to stop running the guard, set "${name}": "off" under "${SHIPPED_SEVERITY_FIELD}" in ${SHIPPED_GUARD_CONFIG}`,
|
|
31
|
+
docs: ERROR_DOCS_URL,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** An app guard: the `guards/*.ts` file whose text names the code as a literal. */
|
|
36
|
+
async function explainAppGuard(code: string, cwd: string): Promise<ErrorExplanation | undefined> {
|
|
37
|
+
const literal = new RegExp(`['"\`]${code}['"\`]`);
|
|
38
|
+
// The app's root from anywhere inside it; outside an app, `--cwd` as given.
|
|
39
|
+
const dir = join(findAppRoot(cwd)?.dir ?? cwd, 'guards');
|
|
40
|
+
let files: string[];
|
|
41
|
+
try {
|
|
42
|
+
files = await Array.fromAsync(new Bun.Glob('*.{ts,tsx}').scan({ cwd: dir }));
|
|
43
|
+
} catch {
|
|
44
|
+
// No `guards/` here: not an app, or an app with none — nothing to explain from.
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
for (const file of files.sort()) {
|
|
48
|
+
if (/\.test\.tsx?$/.test(file)) continue;
|
|
49
|
+
const source = await Bun.file(join(dir, file)).text();
|
|
50
|
+
if (!literal.test(source)) continue;
|
|
51
|
+
const at = `guards/${file}`;
|
|
52
|
+
return {
|
|
53
|
+
code,
|
|
54
|
+
cause: `this app's guard ${at} refuses it: ${summaryOf(source) ?? 'its summary is not a plain string'} (run by the boundaries step of x verify)`,
|
|
55
|
+
fix: `${RUN} # each ${code} finding names its file:line and the edit that clears it; the rule is ${at} — delete that file to drop it`,
|
|
56
|
+
docs: ERROR_DOCS_URL,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
return undefined;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** The guard behind `code` — the app's own first, since its file is what this app runs. */
|
|
63
|
+
export async function explainGuardCode(
|
|
64
|
+
code: string,
|
|
65
|
+
cwd: string,
|
|
66
|
+
): Promise<ErrorExplanation | undefined> {
|
|
67
|
+
if (!/^X(?:_[A-Z0-9]+)+$/.test(code)) return undefined;
|
|
68
|
+
return (await explainAppGuard(code, cwd)) ?? (await explainShipped(code));
|
|
69
|
+
}
|
package/src/cmd-errors.ts
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import { nearestName, singleLine } from '@ultimat3/core';
|
|
6
6
|
import type { ErrorExplanation } from '@ultimat3/mcp';
|
|
7
|
+
import { explainGuardCode } from './cmd-errors-guards';
|
|
7
8
|
import { withRecent } from './cmd-errors-recent';
|
|
8
9
|
import { errorsSpec } from './cmd-errors-spec';
|
|
9
10
|
import type { CliCommand, CommandContext } from './command';
|
|
@@ -42,8 +43,12 @@ const detailLines = (explanation: ErrorExplanation): readonly string[] => [
|
|
|
42
43
|
` docs: ${singleLine(explanation.docs)}`,
|
|
43
44
|
];
|
|
44
45
|
|
|
45
|
-
|
|
46
|
-
|
|
46
|
+
/**
|
|
47
|
+
* A registered code, else a guard's — a shipped guard's or this app's own (`cmd-errors-guards.ts`):
|
|
48
|
+
* the gate prints both, and the app's `CLAUDE.md` sends every printed code here.
|
|
49
|
+
*/
|
|
50
|
+
async function explainOne(code: string, cwd: string): Promise<CommandResult> {
|
|
51
|
+
const explanation = explainErrorCode(code) ?? (await explainGuardCode(code, cwd));
|
|
47
52
|
if (explanation === undefined) {
|
|
48
53
|
const suggestion = nearestName(
|
|
49
54
|
code,
|
|
@@ -108,7 +113,9 @@ export const errorsCommand: CliCommand = {
|
|
|
108
113
|
});
|
|
109
114
|
}
|
|
110
115
|
// `--recent`: what THIS app has seen of the code — groups and the bundles `x repro` replays.
|
|
111
|
-
if (flagBool(ctx.args, 'recent'))
|
|
112
|
-
|
|
116
|
+
if (flagBool(ctx.args, 'recent')) {
|
|
117
|
+
return withRecent(ctx, code, await explainOne(code, ctx.cwd));
|
|
118
|
+
}
|
|
119
|
+
return explainOne(code, ctx.cwd);
|
|
113
120
|
},
|
|
114
121
|
};
|
package/src/cmd-exercise.ts
CHANGED
|
@@ -175,8 +175,9 @@ async function exercisePass(
|
|
|
175
175
|
...(whole ? entityTenantFindings(describeEntities()) : []),
|
|
176
176
|
...subjectStatic,
|
|
177
177
|
...subjectProofs,
|
|
178
|
-
// The fix pastes into the file the app has,
|
|
179
|
-
|
|
178
|
+
// The fix pastes into the file the app has, hands it the file it lacks, or — for an entry the
|
|
179
|
+
// file already holds — edits that entry: a second key is TS1117.
|
|
180
|
+
...exerciseFindings(records, overrides),
|
|
180
181
|
...floor.findings,
|
|
181
182
|
];
|
|
182
183
|
return {
|
package/src/cmd-new-spec.ts
CHANGED
|
@@ -35,6 +35,11 @@ export const newSpec: CommandSpec = {
|
|
|
35
35
|
default: true,
|
|
36
36
|
},
|
|
37
37
|
{ name: 'dry-run', type: 'boolean', summary: 'print the file list, write nothing' },
|
|
38
|
-
{
|
|
38
|
+
{
|
|
39
|
+
name: 'force',
|
|
40
|
+
type: 'boolean',
|
|
41
|
+
// Never over an app: `cmd-new-target.ts` refuses a directory holding `app.config.ts` (D1).
|
|
42
|
+
summary: 'write into a directory that already exists and holds no app.config.ts',
|
|
43
|
+
},
|
|
39
44
|
],
|
|
40
45
|
};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// `x new`'s refusal of a target directory that already exists. Its fix names a FREE directory —
|
|
2
|
+
// never `--force`: a fix is pasted with no diff in front of it, and `--force` over an existing app
|
|
3
|
+
// reset its `api/index.ts` and `roles.ts` to the template (D1, 2026-11-16).
|
|
4
|
+
|
|
5
|
+
// why: the target is a DIRECTORY, which `Bun.file().exists()` answers false for.
|
|
6
|
+
import { existsSync } from 'node:fs';
|
|
7
|
+
// why: Bun ships no path API; `dirname`/`join` place the sibling the fix names.
|
|
8
|
+
import { dirname, join } from 'node:path';
|
|
9
|
+
import { ERROR_DOCS_URL } from '@ultimat3/core';
|
|
10
|
+
import { appNameIssue } from './app-name';
|
|
11
|
+
import { msg } from './messages';
|
|
12
|
+
import type { CommandResult } from './output';
|
|
13
|
+
import { quoteArg } from './shell-quote';
|
|
14
|
+
|
|
15
|
+
/** How far `-2`, `-3`, … is walked before the fix falls back to a placeholder. */
|
|
16
|
+
const SUFFIX_LIMIT = 100;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* The first `<slug>-<n>` beside `target` that is not on disk and that core's `defineConfig`
|
|
20
|
+
* accepts — a free name, so the fix cannot land on a second existing directory.
|
|
21
|
+
*/
|
|
22
|
+
export function freeSibling(target: string, slug: string): string | undefined {
|
|
23
|
+
for (let n = 2; n <= SUFFIX_LIMIT; n += 1) {
|
|
24
|
+
const suffix = `-${n}`;
|
|
25
|
+
const candidate = `${slug.slice(0, 64 - suffix.length)}${suffix}`;
|
|
26
|
+
if (appNameIssue(candidate) !== undefined) continue;
|
|
27
|
+
if (!existsSync(join(dirname(target), candidate))) return candidate;
|
|
28
|
+
}
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface NewTarget {
|
|
33
|
+
readonly target: string;
|
|
34
|
+
readonly slug: string;
|
|
35
|
+
readonly force: boolean;
|
|
36
|
+
/** `invocationOf(ctx, 'new')`: `x new` or `bunx create-ultimate`. */
|
|
37
|
+
readonly invocation: string;
|
|
38
|
+
/** The caller's flags as `reproducedFlags` spells them; `--force` is dropped here. */
|
|
39
|
+
readonly flags: readonly string[];
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* The refusal of an existing target, before a byte is written — `undefined` when the run may go on.
|
|
44
|
+
* `--force` lifts it only for a directory that holds no `app.config.ts` — a fresh clone the
|
|
45
|
+
* platform scaffolds into; over an app it would reset every file the template also writes, so it
|
|
46
|
+
* is refused whatever the flags say. A result, not a throw, so the summary says which it was.
|
|
47
|
+
*/
|
|
48
|
+
export function targetConflict(input: NewTarget): CommandResult | undefined {
|
|
49
|
+
const { target, slug, force, invocation, flags } = input;
|
|
50
|
+
if (!existsSync(target)) return undefined;
|
|
51
|
+
const holdsApp = existsSync(join(target, 'app.config.ts'));
|
|
52
|
+
if (force && !holdsApp) return undefined;
|
|
53
|
+
return {
|
|
54
|
+
ok: false,
|
|
55
|
+
command: 'new',
|
|
56
|
+
summary: msg(holdsApp ? 'cli.new.existsApp' : 'cli.new.exists', { dir: target }),
|
|
57
|
+
findings: [
|
|
58
|
+
{
|
|
59
|
+
code: 'X_GENERATE_CONFLICT',
|
|
60
|
+
cause: holdsApp
|
|
61
|
+
? `${target} already exists and holds an app (app.config.ts): scaffolding into it, --force included, would reset its registrations and grants to the template, so x new refuses it`
|
|
62
|
+
: `${target} already exists and holds no app.config.ts — --force adds the scaffold beside its files, a free name writes a fresh app`,
|
|
63
|
+
fix: [
|
|
64
|
+
invocation,
|
|
65
|
+
quoteArg(freeSibling(target, slug) ?? '<another-name>'),
|
|
66
|
+
...flags.filter((flag) => flag !== '--force'),
|
|
67
|
+
].join(' '),
|
|
68
|
+
docs: ERROR_DOCS_URL,
|
|
69
|
+
at: target,
|
|
70
|
+
},
|
|
71
|
+
],
|
|
72
|
+
};
|
|
73
|
+
}
|
package/src/cmd-new.ts
CHANGED
|
@@ -6,10 +6,11 @@
|
|
|
6
6
|
// path API, and `isAbsolute`/`join`/`relative`/`resolve` place the new app.
|
|
7
7
|
import { existsSync } from 'node:fs';
|
|
8
8
|
import { isAbsolute, join, relative, resolve } from 'node:path';
|
|
9
|
-
import {
|
|
9
|
+
import { renderThrowable } from '@ultimat3/core';
|
|
10
10
|
import { AppNameInvalidError, appNameIssue } from './app-name';
|
|
11
11
|
import { dedupe } from './cmd-generate';
|
|
12
12
|
import { newSpec } from './cmd-new-spec';
|
|
13
|
+
import { targetConflict } from './cmd-new-target';
|
|
13
14
|
import type { CliCommand, CommandContext } from './command';
|
|
14
15
|
import { invocationOf } from './command';
|
|
15
16
|
import { AppNameEmptyError, AppNameIsPathError, MissingPositionalError } from './errors';
|
|
@@ -306,24 +307,16 @@ export const newCommand: CliCommand = {
|
|
|
306
307
|
),
|
|
307
308
|
};
|
|
308
309
|
}
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
// second app into the cwd, and the literal `x` is not installed under create-ultimate.
|
|
320
|
-
fix: `${[invocationOf(ctx, 'new'), quoteArg(app.kebab), ...callerFlags(ctx), '--force'].join(' ')} # or choose another name`,
|
|
321
|
-
docs: ERROR_DOCS_URL,
|
|
322
|
-
at: target,
|
|
323
|
-
},
|
|
324
|
-
],
|
|
325
|
-
};
|
|
326
|
-
}
|
|
310
|
+
// The invocation the caller ran, with every flag it set: dropping `--dir` wrote a second app
|
|
311
|
+
// into the cwd, and the literal `x` is not installed under create-ultimate.
|
|
312
|
+
const conflict = targetConflict({
|
|
313
|
+
target,
|
|
314
|
+
slug: app.kebab,
|
|
315
|
+
force: flagBool(ctx.args, 'force'),
|
|
316
|
+
invocation: invocationOf(ctx, 'new'),
|
|
317
|
+
flags: callerFlags(ctx),
|
|
318
|
+
});
|
|
319
|
+
if (conflict !== undefined) return conflict;
|
|
327
320
|
// Read BEFORE writing: `--force` into a directory that already held files must never
|
|
328
321
|
// `git add -A && git commit` them — they are the user's, and `x new` did not write them.
|
|
329
322
|
const existed = existsSync(target);
|
package/src/cmd-repro.ts
CHANGED
|
@@ -89,7 +89,8 @@ async function answer(
|
|
|
89
89
|
return { ok: true, command: 'repro', summary: summaryOf(subject), data: base };
|
|
90
90
|
}
|
|
91
91
|
const file = reproFile(subject);
|
|
92
|
-
|
|
92
|
+
// An empty `BUILD_ID` is an unstamped image, never a build named `""`.
|
|
93
|
+
const runningBuild = ctx.env['BUILD_ID'] || null;
|
|
93
94
|
await writeRepro(root, file, await reproSource(root, subject, id, runningBuild), ctx.runner);
|
|
94
95
|
const lines = [msg('cli.repro.written', { file })];
|
|
95
96
|
if (!verify) {
|
|
@@ -19,6 +19,9 @@ const START = lines(
|
|
|
19
19
|
' docker compose -f docker/docker-compose.test.yml up -d --wait',
|
|
20
20
|
' cat docker/test-services.env >> "$GITHUB_ENV"',
|
|
21
21
|
);
|
|
22
|
+
/** The line the inserted step writes: present, the edit is carried whatever surrounds it. */
|
|
23
|
+
const E2E_REQUIRED = 'E2E_BROWSER_REQUIRED=1';
|
|
24
|
+
|
|
22
25
|
const NEXT =
|
|
23
26
|
' # Under $RUNNER_TEMP, never in the checkout, where `lint` would walk the open file.';
|
|
24
27
|
|
|
@@ -30,7 +33,7 @@ export const CI_E2E_EDITS: readonly SnippetEdit[] = [
|
|
|
30
33
|
' # ubuntu-latest ships Chrome, and the `e2e` step finds it. Required here, so a runner that',
|
|
31
34
|
' # has none (a `CI_RUNNER` label) is red with the command that locates one — never a skip.',
|
|
32
35
|
" - if: contains(matrix.only, 'e2e')",
|
|
33
|
-
|
|
36
|
+
` run: echo "${E2E_REQUIRED}" >> "$GITHUB_ENV"`,
|
|
34
37
|
NEXT,
|
|
35
38
|
),
|
|
36
39
|
},
|
|
@@ -58,6 +61,9 @@ export const codemod: Codemod = {
|
|
|
58
61
|
async run(app) {
|
|
59
62
|
const held = await readText(app, CI);
|
|
60
63
|
if (held === undefined) return { changed: [], skipped: [] };
|
|
64
|
+
// Carried already: its anchor's `cat` line is `ci-services-env`'s (31.40) to change, so a newer
|
|
65
|
+
// workflow no longer holds the text this edit is spelled against — the step it adds says enough.
|
|
66
|
+
if (held.text.includes(E2E_REQUIRED)) return { changed: [], skipped: [] };
|
|
61
67
|
return (await wholeFile(app, held)) ?? editSnippets(app, CI, CI_E2E_EDITS);
|
|
62
68
|
},
|
|
63
69
|
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// 31.40.0: the services part appends only the env file's `TEST_` assignments to $GITHUB_ENV.
|
|
2
|
+
// `cat docker/test-services.env` handed GitHub the file's `#` header, and GitHub refuses the whole
|
|
3
|
+
// file ("Invalid format"), so every services part went red. One line swapped; an app that appends
|
|
4
|
+
// its own way is reported with the diff.
|
|
5
|
+
|
|
6
|
+
import { CI_WORKFLOW_PATH } from '../templates/github/ci.yml';
|
|
7
|
+
import type { Codemod } from './codemod';
|
|
8
|
+
import type { SnippetEdit } from './engine-edits';
|
|
9
|
+
import { editSnippets } from './engine-edits';
|
|
10
|
+
|
|
11
|
+
const CI = CI_WORKFLOW_PATH;
|
|
12
|
+
|
|
13
|
+
export const CI_SERVICES_ENV_EDITS: readonly SnippetEdit[] = [
|
|
14
|
+
{
|
|
15
|
+
from: ' cat docker/test-services.env >> "$GITHUB_ENV"',
|
|
16
|
+
to: ` grep -E '^TEST_[A-Z0-9_]+=' docker/test-services.env >> "$GITHUB_ENV"`,
|
|
17
|
+
},
|
|
18
|
+
];
|
|
19
|
+
|
|
20
|
+
export const codemod: Codemod = {
|
|
21
|
+
id: 'ci-services-env',
|
|
22
|
+
since: '31.40.0',
|
|
23
|
+
summary: `${CI}: the services part appends only TEST_ lines to $GITHUB_ENV, never the env file's # header GitHub refuses`,
|
|
24
|
+
run: (app) => editSnippets(app, CI, CI_SERVICES_ENV_EDITS),
|
|
25
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// 31.40.0: the `undeclared-env` guard ships, so CLAUDE.md's table names it on an Env row,
|
|
2
|
+
// under the Runtime row. Prose: it lands where that row stands as `x new` wrote it, and is skipped
|
|
3
|
+
// silently where the app reworded it or already wrote one.
|
|
4
|
+
|
|
5
|
+
import type { Codemod } from './codemod';
|
|
6
|
+
import type { SnippetEdit } from './engine-edits';
|
|
7
|
+
import { editSnippets } from './engine-edits';
|
|
8
|
+
|
|
9
|
+
const CLAUDE = 'CLAUDE.md';
|
|
10
|
+
|
|
11
|
+
const RUNTIME =
|
|
12
|
+
"| Runtime | every Bun pin — `packageManager`, `.bun-version`, CI's `bun-version:`, the image's `FROM oven/bun:` — names the version `engines.bun` declares, and an image builds on a digest | `runtime-pin` |";
|
|
13
|
+
|
|
14
|
+
/** Terse on purpose: a shaped app's CLAUDE.md sits within bytes of `AGENTS_MD_MAX_BYTES`. */
|
|
15
|
+
export const ENVIRONMENT_ROW = '| Env | declared in `envSchema` | `undeclared-env` |';
|
|
16
|
+
|
|
17
|
+
export const DOCS_ENV_GUARD_EDITS: readonly SnippetEdit[] = [
|
|
18
|
+
{ from: RUNTIME, to: `${RUNTIME}\n${ENVIRONMENT_ROW}`, optional: true },
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
export const codemod: Codemod = {
|
|
22
|
+
id: 'docs-env-guard',
|
|
23
|
+
since: '31.40.0',
|
|
24
|
+
summary: "CLAUDE.md's table names the undeclared-env guard on an Env row",
|
|
25
|
+
async run(app) {
|
|
26
|
+
if (((await app.read(CLAUDE)) ?? '').includes('`undeclared-env`')) {
|
|
27
|
+
return { changed: [], skipped: [] };
|
|
28
|
+
}
|
|
29
|
+
return editSnippets(app, CLAUDE, DOCS_ENV_GUARD_EDITS);
|
|
30
|
+
},
|
|
31
|
+
};
|
package/src/codemods/index.ts
CHANGED
|
@@ -8,9 +8,11 @@ import { codemod as biomeNoDefaultExport } from './biome-no-default-export';
|
|
|
8
8
|
import { codemod as bunfigIslandCoverage } from './bunfig-island-coverage';
|
|
9
9
|
import { codemod as chartDashboard } from './chart-dashboard';
|
|
10
10
|
import { codemod as ciE2eBrowser } from './ci-e2e-browser';
|
|
11
|
+
import { codemod as ciServicesEnv } from './ci-services-env';
|
|
11
12
|
import type { Codemod } from './codemod';
|
|
12
13
|
import { codemod as defineErrorLeaf } from './define-error-leaf';
|
|
13
14
|
import { codemod as docsCiParts } from './docs-ci-parts';
|
|
15
|
+
import { codemod as docsEnvGuard } from './docs-env-guard';
|
|
14
16
|
import { codemod as docsGateProse } from './docs-gate-prose';
|
|
15
17
|
import { codemod as docsIslandRows } from './docs-island-rows';
|
|
16
18
|
import { codemod as docsShippedGuards } from './docs-shipped-guards';
|
|
@@ -57,4 +59,6 @@ export const CODEMODS: readonly Codemod[] = [
|
|
|
57
59
|
verifyFloorSteps,
|
|
58
60
|
helmAlertsDeploy,
|
|
59
61
|
migrateJobOrdered,
|
|
62
|
+
ciServicesEnv,
|
|
63
|
+
docsEnvGuard,
|
|
60
64
|
];
|
package/src/dev-boot.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
import { devShellStyle } from '@ultimat3/admin/dev';
|
|
7
7
|
import type { Role } from '@ultimat3/core';
|
|
8
8
|
import { subscribe, subscribeSemconvMetrics, systemClock } from '@ultimat3/core';
|
|
9
|
+
import { installBuildId } from '@ultimat3/core/adapter';
|
|
9
10
|
import type { OverlayNotice, RequestContext } from '@ultimat3/http';
|
|
10
11
|
import { asCtx, subscribeRequestTimings } from '@ultimat3/http';
|
|
11
12
|
import { loadSignInPath } from './app-auth';
|
|
@@ -240,6 +241,8 @@ async function bootDev(
|
|
|
240
241
|
const rawStamp = options.env['BUILD_ID'];
|
|
241
242
|
const stamped = rawStamp !== undefined && rawStamp !== '' ? rawStamp : undefined;
|
|
242
243
|
const buildId = stamped ?? state.manifest.buildId;
|
|
244
|
+
// The pinned id is core's too, so `ctx.buildId` and `/healthz` name what the header names.
|
|
245
|
+
acquired.push(installBuildId(buildId));
|
|
243
246
|
|
|
244
247
|
let server: DevServer;
|
|
245
248
|
// Read at request time, never captured at boot: `/_x/services` must report the reload counter
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// What `x dev`'s rebuild does to the ISR store on a save: every stored page goes, so the next
|
|
2
|
+
// request renders with the new module.
|
|
3
|
+
|
|
4
|
+
import { markAllInvalidated } from '@ultimat3/cache';
|
|
5
|
+
import type { IsrStore } from '@ultimat3/render/server';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Empty the store a save made stale — after voiding every fill in flight. A render that began with
|
|
9
|
+
* the OLD module before the save samples its fence first; deleted paths alone left that fence
|
|
10
|
+
* valid, so the pre-save HTML landed after the clear as a fresh page (audit round 2). Never
|
|
11
|
+
* `flushProcessTiers`: that also purges a CDN tier, the real CDN when its keys are in `.env`.
|
|
12
|
+
*/
|
|
13
|
+
export async function clearIsrForRebuild(store: IsrStore): Promise<void> {
|
|
14
|
+
markAllInvalidated();
|
|
15
|
+
// Awaited one by one: a shared store answers over the network, and a dev save is rare.
|
|
16
|
+
for (const path of await store.paths()) await store.delete(path);
|
|
17
|
+
}
|
package/src/dev-rebuild.ts
CHANGED
|
@@ -12,6 +12,7 @@ import type { AppManifest } from './app-manifest';
|
|
|
12
12
|
import { appManifest } from './app-manifest';
|
|
13
13
|
import type { StalePin } from './app-reload-graph';
|
|
14
14
|
import { takeStalePins } from './app-reload-graph';
|
|
15
|
+
import { clearIsrForRebuild } from './dev-rebuild-isr';
|
|
15
16
|
import { remountFinding, remountLine, remountReason } from './dev-rebuild-remount';
|
|
16
17
|
import { schemaAheadFindings } from './dev-rebuild-schema';
|
|
17
18
|
import type { ReloadTrigger } from './dev-reload';
|
|
@@ -122,6 +123,7 @@ export function devRebuilder(
|
|
|
122
123
|
state: DevState,
|
|
123
124
|
isr: IsrController,
|
|
124
125
|
refreshDevices: () => Promise<readonly string[]>,
|
|
126
|
+
build: GenerationBuilders = BUILDERS,
|
|
125
127
|
): ReloadTrigger {
|
|
126
128
|
// What the route table was built from: the boot's generation, for the life of this process. Each
|
|
127
129
|
// save is compared with IT, not with the save before — a route added two saves ago is still a 404.
|
|
@@ -131,25 +133,29 @@ export function devRebuilder(
|
|
|
131
133
|
// (the watcher's second event for one write, a no-op save) is still a restart: it reported
|
|
132
134
|
// "reloaded" over the old read, and an unsupervised `/_x` lost its X_DEV_RESTART_REQUIRED.
|
|
133
135
|
let held: readonly StalePin[] = [];
|
|
136
|
+
/** This rebuild's pins, taken and added to `held`; a pin already held is not added twice. */
|
|
137
|
+
const takeHeld = (): readonly StalePin[] => {
|
|
138
|
+
const reached = takeStalePins();
|
|
139
|
+
held = [...held, ...reached.filter((pin) => !held.some((was) => was.pinned === pin.pinned))];
|
|
140
|
+
return reached;
|
|
141
|
+
};
|
|
134
142
|
// One rebuild at a time, and the last save wins: a tick arriving mid-build coalesces into ONE
|
|
135
143
|
// trailing rebuild instead of racing the one in flight for `state.manifest` and `state.islands`.
|
|
136
144
|
return coalesceReloads(
|
|
137
145
|
async (file) => {
|
|
138
146
|
const started = performance.now();
|
|
139
147
|
beginDeviceSocketGeneration();
|
|
140
|
-
const { manifest, findings, islands } = await buildGeneration(options.root);
|
|
148
|
+
const { manifest, findings, islands } = await buildGeneration(options.root, build);
|
|
141
149
|
const remount = remountReason(mounted, { manifest, findings });
|
|
142
150
|
state.manifest = manifest;
|
|
143
151
|
state.appFindings = findings;
|
|
144
152
|
state.islands = islands;
|
|
145
153
|
const unserved = await refreshDevices();
|
|
146
|
-
|
|
147
|
-
for (const path of await isr.store().paths()) await isr.store().delete(path);
|
|
154
|
+
await clearIsrForRebuild(isr.store());
|
|
148
155
|
state.reloads += 1;
|
|
149
156
|
// Read on EVERY rebuild, so a pin one save reached is never reported against the next save:
|
|
150
157
|
// this save's own pins name it, and only a save that reached none inherits the held ones.
|
|
151
|
-
const reached =
|
|
152
|
-
held = [...held, ...reached.filter((pin) => !held.some((was) => was.pinned === pin.pinned))];
|
|
158
|
+
const reached = takeHeld();
|
|
153
159
|
const stale = reached.length > 0 ? reached : held;
|
|
154
160
|
// A generation this process cannot mount is a restart named after the saved file — never
|
|
155
161
|
// "reloaded" over a route table built for the generation before it.
|
|
@@ -177,6 +183,9 @@ export function devRebuilder(
|
|
|
177
183
|
// Same rule as a module that will not import: a save the manifest cannot be rebuilt from is
|
|
178
184
|
// a finding on `/_x`, never an unhandled rejection that takes the dev server down.
|
|
179
185
|
(error: unknown, file: string) => {
|
|
186
|
+
// Its pins are taken all the same — the rescan ran before the throw, and the process holds
|
|
187
|
+
// what it pinned. Left in the graph they were read as the NEXT save's own (audit round 2).
|
|
188
|
+
takeHeld();
|
|
180
189
|
state.reloadFinding = { ...findingFrom(error), at: file };
|
|
181
190
|
},
|
|
182
191
|
);
|
package/src/error-contract.ts
CHANGED
|
@@ -152,9 +152,12 @@ export async function checkErrorFixReport(root: string): Promise<ErrorFixReport>
|
|
|
152
152
|
// At its point of use, like the catalog: `app-load.ts` imports this module for
|
|
153
153
|
// `collectDeclaredCodes`, and a gate-only rule must not ride into every serving role's graph
|
|
154
154
|
// (`serve-graph.test.ts`'s `SERVING_ROLE_CEILING`).
|
|
155
|
-
const {
|
|
156
|
-
|
|
157
|
-
|
|
155
|
+
const {
|
|
156
|
+
FIX_SEQUENCE_BASELINE,
|
|
157
|
+
fixSequenceProblem,
|
|
158
|
+
generatorForceProblem,
|
|
159
|
+
interpolatedForceProblem,
|
|
160
|
+
} = await import('./fix-sequence');
|
|
158
161
|
const imports = createHelperResolver(root);
|
|
159
162
|
let checked = 0;
|
|
160
163
|
let unreadable = 0;
|
|
@@ -172,8 +175,12 @@ export async function checkErrorFixReport(root: string): Promise<ErrorFixReport>
|
|
|
172
175
|
// The interpolation-blanked form for both rules: `x ${name}` names no command this can
|
|
173
176
|
// resolve, and reading `<value>` as one would be a finding nobody can act on.
|
|
174
177
|
const fix = staticFix(site.fix);
|
|
178
|
+
// The --force rule twice: on the blanked text, and inside the interpolations it blanks.
|
|
175
179
|
const problem =
|
|
176
|
-
fixProblem(site.fix) ??
|
|
180
|
+
fixProblem(site.fix) ??
|
|
181
|
+
generatorForceProblem(fix) ??
|
|
182
|
+
interpolatedForceProblem(site.fix) ??
|
|
183
|
+
citedCommandProblem(fix, catalog);
|
|
177
184
|
if (problem !== undefined) {
|
|
178
185
|
findings.push(fixFinding(site, problem));
|
|
179
186
|
continue;
|