@ultimat3/cli 31.27.0 → 31.29.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 +4 -1
- package/README.md +14 -4
- package/package.json +29 -29
- package/src/app-manifest.ts +6 -1
- package/src/app-migrations-verdict.ts +84 -0
- package/src/cmd-doctor.ts +11 -3
- package/src/cmd-drill.ts +23 -9
- package/src/cmd-repro-spec.ts +13 -1
- package/src/cmd-repro.ts +37 -5
- package/src/cmd-upgrade-codemods.ts +71 -0
- package/src/cmd-upgrade-spec.ts +19 -5
- package/src/cmd-upgrade.ts +91 -34
- package/src/codemods/agents-dev-mcp.ts +50 -0
- package/src/codemods/authenticator-session-refusal.ts +214 -0
- package/src/codemods/biome-no-default-export.ts +58 -0
- package/src/codemods/bunfig-island-coverage.ts +33 -0
- package/src/codemods/chart-dashboard.ts +73 -0
- package/src/codemods/ci-e2e-browser-stock.ts +75 -0
- package/src/codemods/ci-e2e-browser.ts +63 -0
- package/src/codemods/codemod.ts +58 -0
- package/src/codemods/define-error-leaf.ts +73 -0
- package/src/codemods/docs-ci-parts.ts +65 -0
- package/src/codemods/docs-gate-prose.ts +53 -0
- package/src/codemods/docs-island-rows.ts +31 -0
- package/src/codemods/docs-shipped-guards.ts +100 -0
- package/src/codemods/docs-test-services.ts +62 -0
- package/src/codemods/engine-diff.ts +104 -0
- package/src/codemods/engine-edits.ts +111 -0
- package/src/codemods/engine-fs.ts +95 -0
- package/src/codemods/engine.ts +191 -0
- package/src/codemods/format-edited-hook-3122.ts +28 -0
- package/src/codemods/format-edited-hook.ts +152 -0
- package/src/codemods/helm-alerts-deploy.ts +85 -0
- package/src/codemods/helm-alerts-objective.ts +105 -0
- package/src/codemods/helm-alerts-stock.ts +108 -0
- package/src/codemods/index.ts +60 -0
- package/src/codemods/metrics-probe-healthz.ts +47 -0
- package/src/codemods/migrate-job-ordered.ts +81 -0
- package/src/codemods/migrate-job-stock.ts +41 -0
- package/src/codemods/pending.ts +36 -0
- package/src/codemods/repro-gitignore.ts +40 -0
- package/src/codemods/runtime-pin-lines.ts +109 -0
- package/src/codemods/runtime-pin.ts +116 -0
- package/src/codemods/solid-floor.ts +63 -0
- package/src/codemods/test-ports.ts +86 -0
- package/src/codemods/test-suites.ts +37 -0
- package/src/codemods/theme-toggle-mount-over.ts +70 -0
- package/src/codemods/vendored-guards.ts +186 -0
- package/src/codemods/verify-floor-skips.ts +88 -0
- package/src/codemods/verify-floor-steps.ts +90 -0
- package/src/doctor-advisory-floors.ts +113 -0
- package/src/doctor-guards.ts +39 -86
- package/src/doctor-superseded.ts +67 -0
- package/src/drill-schema-behind.ts +26 -0
- package/src/error-codes-doctor.ts +12 -4
- package/src/error-codes.ts +9 -0
- package/src/exercise-database.ts +7 -2
- package/src/framework-schema-apply.ts +7 -19
- package/src/framework-schema-stamp.ts +38 -3
- package/src/framework-schema-verify.ts +120 -0
- package/src/framework-schema-wait.ts +125 -0
- package/src/generate-files.ts +6 -5
- package/src/guards-built-in-codes.ts +36 -0
- package/src/guards-built-in-refusal.ts +25 -0
- package/src/guards-built-in.ts +134 -0
- package/src/guards-materialize.ts +42 -0
- package/src/guards-paths.ts +37 -0
- package/src/guards-shipped-names.ts +38 -0
- package/src/guards-vendored.ts +73 -0
- package/src/guards.ts +90 -34
- package/src/index.ts +10 -0
- package/src/lint-findings.ts +3 -3
- package/src/mcp-errors.ts +12 -1
- package/src/measure-scope.ts +23 -3
- package/src/messages-repro.ts +16 -2
- package/src/messages-upgrade.ts +15 -0
- package/src/messages.ts +1 -1
- package/src/repro-archive-collect.ts +161 -0
- package/src/repro-archive-write.ts +96 -0
- package/src/repro-archive.ts +161 -0
- package/src/repro-bundle.ts +8 -16
- package/src/repro-errors.ts +14 -2
- package/src/repro-framework.ts +53 -0
- package/src/repro-parse.ts +87 -0
- package/src/repro-redact.ts +218 -0
- package/src/repro-scrub.ts +257 -0
- package/src/role-pg-stats.ts +21 -0
- package/src/role-start.ts +4 -0
- package/src/runtime-queue.ts +27 -6
- package/src/serve-boot-probe.ts +97 -0
- package/src/serve-boot.ts +26 -1
- package/src/serve-retire.ts +16 -3
- package/src/superseded-match.ts +87 -0
- package/src/superseded.ts +84 -0
- package/src/templates/bun-image.ts +48 -0
- package/src/templates/chart-dashboard-panels.ts +178 -0
- package/src/templates/chart-dashboard.ts +9 -135
- package/src/templates/github/ci.yml.ts +1 -1
- package/src/templates/guard-released-forms.ts +112 -0
- package/src/templates/guard-runtime-pin-test.ts +54 -0
- package/src/templates/guard-runtime-pin.ts +189 -0
- package/src/templates/scaffold-claude-agents.ts +6 -6
- package/src/templates/scaffold-claude-commands.ts +1 -1
- package/src/templates/scaffold-claude-hook.ts +18 -8
- package/src/templates/scaffold-claude.ts +2 -2
- package/src/templates/scaffold-container.ts +2 -2
- package/src/templates/scaffold-docs.ts +26 -24
- package/src/templates/scaffold-guards.ts +73 -39
- package/src/templates/scaffold-helm-alert-deploy.ts +105 -0
- package/src/templates/scaffold-helm-alert-rules.ts +7 -1
- package/src/templates/scaffold-helm-alerts.ts +3 -0
- package/src/templates/scaffold-helm-migrate.ts +85 -0
- package/src/templates/scaffold-helm-templates.ts +2 -36
- package/src/templates/scaffold-helm.ts +1 -0
- package/src/templates/scaffold-repo.ts +2 -1
- package/src/unthrown-codes.ts +2 -0
- package/src/upgrade-bun-floor.ts +4 -0
- package/src/upgrade-clean-tree.ts +54 -0
- package/src/upgrade-gate-codemods-install.ts +40 -0
- package/src/upgrade-gate-codemods.ts +151 -0
- package/src/upgrade-gate.ts +38 -6
- package/src/upgrade-lock.ts +118 -0
- package/src/upgrade-plan.ts +2 -1
- package/src/upgrade-report-codemods.ts +54 -0
- package/src/upgrade-report.ts +52 -27
- package/src/upgrade-signals.ts +91 -0
- package/src/upgrade-unfinished.ts +61 -0
- package/wiki/CLI-Reference.md +70 -5
- package/wiki/Deployment.md +2 -1
- package/wiki/Interface-Rules.md +17 -8
- package/wiki/Known-Gaps.md +1 -1
- package/wiki/Observability.md +1 -0
- package/wiki/Project-Layout.md +4 -4
- package/wiki/Upgrading.md +6 -0
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// `.github/workflows/ci.yml` as `x new` wrote it from 31.4.0 through 31.15.x — one job, the whole
|
|
2
|
+
// gate on one runner — kept byte for byte (the app's name as `<APP>`) so a workflow still exactly
|
|
3
|
+
// that is recognised and replaced whole by today's, and an edited one is not.
|
|
4
|
+
|
|
5
|
+
// biome-ignore-all lint/suspicious/noTemplateCurlyInString: GitHub Actions' own ${{ … }}, never a JS template
|
|
6
|
+
|
|
7
|
+
/** The app's name stands where the scaffold wrote it; every `bun-version:` line is compared apart. */
|
|
8
|
+
export const CI_31_15_LINES: readonly string[] = [
|
|
9
|
+
'name: ci',
|
|
10
|
+
'',
|
|
11
|
+
'# The gate for <APP>: the same two commands `README.md` tells a human to run, in the same',
|
|
12
|
+
'# order, on a machine that has never seen this repository. A check that exists only in CI is one',
|
|
13
|
+
"# nobody can reproduce locally, and a CI file that restates the gate's steps is a second gate.",
|
|
14
|
+
'#',
|
|
15
|
+
'# `bun run verify` is `x verify`, the whole gate. Its `budgets` step runs',
|
|
16
|
+
'# `x build --target static` itself when `.x/build-stats.json` is missing or older than the source,',
|
|
17
|
+
'# which on a fresh runner it always is, so no build step comes first.',
|
|
18
|
+
'#',
|
|
19
|
+
'# `bun run setup` brings up embedded Postgres in-process; the TEST services come from',
|
|
20
|
+
'# `docker/docker-compose.test.yml` — Postgres 18, Redis, NATS and S3 in RAM, durability and logs',
|
|
21
|
+
'# off — started by the same two lines a laptop runs, never a `services:` block that restates them.',
|
|
22
|
+
'',
|
|
23
|
+
"# EVERY push, not just the default branch's. `x new` runs a plain `git init` and takes whatever",
|
|
24
|
+
'# `init.defaultBranch` this machine already agreed on, so a `branches: [main]` filter silently',
|
|
25
|
+
'# runs nothing on a repository whose branch is called something else — and `CLAUDE.md` promises a',
|
|
26
|
+
'# run on every push, which a filter would make untrue for the app that read it.',
|
|
27
|
+
'on:',
|
|
28
|
+
' push:',
|
|
29
|
+
' pull_request:',
|
|
30
|
+
'',
|
|
31
|
+
'# A newer push to a branch makes the run already in flight for it worthless, so it is cancelled —',
|
|
32
|
+
'# except on the default branch, where every commit keeps its own verdict: that group is keyed by',
|
|
33
|
+
'# SHA, so nothing there can supersede anything.',
|
|
34
|
+
'concurrency:',
|
|
35
|
+
" group: ci-${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) && github.sha || github.ref }}",
|
|
36
|
+
' cancel-in-progress: true',
|
|
37
|
+
'',
|
|
38
|
+
'permissions:',
|
|
39
|
+
' contents: read',
|
|
40
|
+
'',
|
|
41
|
+
'jobs:',
|
|
42
|
+
' check:',
|
|
43
|
+
' # A branch in THIS repository with an open pull request fires both events for one commit, and',
|
|
44
|
+
' # the push run already gates that exact tree — so the pull_request run is skipped, not paid for',
|
|
45
|
+
' # twice. A pull request from a FORK fires no push here, and it still runs.',
|
|
46
|
+
" if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository",
|
|
47
|
+
' # A free GitHub-hosted runner unless the repository variable `CI_RUNNER` names another label.',
|
|
48
|
+
" runs-on: ${{ vars.CI_RUNNER || 'ubuntu-latest' }}",
|
|
49
|
+
" # A bound on a HANG, not on cost: a step that never returns holds a runner until GitHub's",
|
|
50
|
+
' # six-hour default expires, and the failure is invisible for all six of them.',
|
|
51
|
+
' timeout-minutes: 20',
|
|
52
|
+
' steps:',
|
|
53
|
+
' - uses: actions/checkout@v7',
|
|
54
|
+
' - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0',
|
|
55
|
+
' with:',
|
|
56
|
+
" # `package.json`'s `engines.bun` floor, exactly — the OLDEST runtime this app declares",
|
|
57
|
+
' # it supports, so a call that needs a newer Bun fails here rather than in the install of',
|
|
58
|
+
' # whoever took the app at its word. Never `latest`: a Bun minor landing unannounced is a',
|
|
59
|
+
' # runtime change nobody chose.',
|
|
60
|
+
" bun-version: '1.4.4'",
|
|
61
|
+
" # Bun's download cache, keyed on the lockfile: `bun run setup`'s install then links from",
|
|
62
|
+
' # disk instead of fetching every package again on every run.',
|
|
63
|
+
' - uses: actions/cache@v6',
|
|
64
|
+
' with:',
|
|
65
|
+
' path: ~/.bun/install/cache',
|
|
66
|
+
" key: bun-${{ runner.os }}-${{ hashFiles('bun.lock') }}",
|
|
67
|
+
' restore-keys: bun-${{ runner.os }}-',
|
|
68
|
+
' # Two steps rather than one `&&`, so the log names which half failed and times each.',
|
|
69
|
+
' - run: bun run setup',
|
|
70
|
+
' # `--wait` returns once every healthcheck passes; the env file points the suites at them.',
|
|
71
|
+
' - run: docker compose -f docker/docker-compose.test.yml up -d --wait',
|
|
72
|
+
' - run: cat docker/test-services.env >> "$GITHUB_ENV"',
|
|
73
|
+
' - run: bun run verify',
|
|
74
|
+
'',
|
|
75
|
+
];
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// 31.27.0: the CI part that runs `e2e` requires a browser (`E2E_BROWSER_REQUIRED=1`), so a runner
|
|
2
|
+
// with no Chrome is red with the command that locates one — never a step that skipped and passed.
|
|
3
|
+
// One step inserted after the test services start; the one-job workflow of 31.4–31.15, still
|
|
4
|
+
// byte for byte, is replaced whole by today's. An edited workflow is reported with the diff.
|
|
5
|
+
|
|
6
|
+
import { CI_WORKFLOW_PATH, githubFiles } from '../templates/github/ci.yml';
|
|
7
|
+
import { names } from '../templates/naming';
|
|
8
|
+
import { appName } from './agents-dev-mcp';
|
|
9
|
+
import { CI_31_15_LINES } from './ci-e2e-browser-stock';
|
|
10
|
+
import type { Codemod, CodemodApp, CodemodResult } from './codemod';
|
|
11
|
+
import type { FileText, SnippetEdit } from './engine-edits';
|
|
12
|
+
import { editSnippets, readText } from './engine-edits';
|
|
13
|
+
|
|
14
|
+
const CI = CI_WORKFLOW_PATH;
|
|
15
|
+
|
|
16
|
+
const lines = (...text: readonly string[]): string => text.join('\n');
|
|
17
|
+
|
|
18
|
+
const START = lines(
|
|
19
|
+
' docker compose -f docker/docker-compose.test.yml up -d --wait',
|
|
20
|
+
' cat docker/test-services.env >> "$GITHUB_ENV"',
|
|
21
|
+
);
|
|
22
|
+
const NEXT =
|
|
23
|
+
' # Under $RUNNER_TEMP, never in the checkout, where `lint` would walk the open file.';
|
|
24
|
+
|
|
25
|
+
export const CI_E2E_EDITS: readonly SnippetEdit[] = [
|
|
26
|
+
{
|
|
27
|
+
from: lines(START, NEXT),
|
|
28
|
+
to: lines(
|
|
29
|
+
START,
|
|
30
|
+
' # ubuntu-latest ships Chrome, and the `e2e` step finds it. Required here, so a runner that',
|
|
31
|
+
' # has none (a `CI_RUNNER` label) is red with the command that locates one — never a skip.',
|
|
32
|
+
" - if: contains(matrix.only, 'e2e')",
|
|
33
|
+
' run: echo "E2E_BROWSER_REQUIRED=1" >> "$GITHUB_ENV"',
|
|
34
|
+
NEXT,
|
|
35
|
+
),
|
|
36
|
+
},
|
|
37
|
+
];
|
|
38
|
+
|
|
39
|
+
/** Every `bun-version:` line alike: a runtime-pin codemod may have moved it already. */
|
|
40
|
+
const pinless = (text: string): string => text.replace(/^(\s*bun-version:).*$/gm, '$1');
|
|
41
|
+
|
|
42
|
+
/** Today's workflow, when the app's is still the 31.4–31.15 one-job workflow exactly. */
|
|
43
|
+
async function wholeFile(app: CodemodApp, held: FileText): Promise<CodemodResult | undefined> {
|
|
44
|
+
const name = appName((await readText(app, 'package.json'))?.text ?? '');
|
|
45
|
+
if (name === undefined) return undefined;
|
|
46
|
+
const stock = CI_31_15_LINES.map((line) => line.replace('<APP>', name)).join('\n');
|
|
47
|
+
if (pinless(held.text) !== pinless(stock)) return undefined;
|
|
48
|
+
const today = githubFiles(names(name)).find((file) => file.path === CI)?.contents;
|
|
49
|
+
if (typeof today !== 'string') return undefined;
|
|
50
|
+
await app.write(CI, held.restore(today));
|
|
51
|
+
return { changed: [CI], skipped: [] };
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export const codemod: Codemod = {
|
|
55
|
+
id: 'ci-e2e-browser',
|
|
56
|
+
since: '31.27.0',
|
|
57
|
+
summary: `${CI}: the part that runs e2e requires a browser, so a runner with none is red, never skipped`,
|
|
58
|
+
async run(app) {
|
|
59
|
+
const held = await readText(app, CI);
|
|
60
|
+
if (held === undefined) return { changed: [], skipped: [] };
|
|
61
|
+
return (await wholeFile(app, held)) ?? editSnippets(app, CI, CI_E2E_EDITS);
|
|
62
|
+
},
|
|
63
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// The codemod contract: a template change an app keeps, carried across by a pure function over an
|
|
2
|
+
// app it can read and write but never touch directly — so the engine can dry-run, report and diff.
|
|
3
|
+
// Every migration is one `codemods/<id>.ts` exporting `const codemod: Codemod`; `index.ts` lists them.
|
|
4
|
+
|
|
5
|
+
/** The app a codemod sees. Paths are app-root relative, posix separators. */
|
|
6
|
+
export interface CodemodApp {
|
|
7
|
+
readonly root: string;
|
|
8
|
+
read(path: string): Promise<string | undefined>;
|
|
9
|
+
write(path: string, source: string): Promise<void>;
|
|
10
|
+
remove(path: string): Promise<void>;
|
|
11
|
+
exists(path: string): Promise<boolean>;
|
|
12
|
+
glob(pattern: string): Promise<readonly string[]>;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** A file a codemod would not overwrite (app-edited, unrecognised), with the change it wanted. */
|
|
16
|
+
export interface CodemodSkip {
|
|
17
|
+
readonly path: string;
|
|
18
|
+
readonly reason: string;
|
|
19
|
+
readonly diff?: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface CodemodResult {
|
|
23
|
+
readonly changed: string[];
|
|
24
|
+
readonly skipped: CodemodSkip[];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface Codemod {
|
|
28
|
+
readonly id: string;
|
|
29
|
+
/** The framework version whose template change this carries an app across. */
|
|
30
|
+
readonly since: string;
|
|
31
|
+
readonly summary: string;
|
|
32
|
+
run(app: CodemodApp): Promise<CodemodResult>;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** An in-memory `CodemodApp` for tests: `files` is the app, mutated in place. */
|
|
36
|
+
export function memoryCodemodApp(
|
|
37
|
+
files: Record<string, string>,
|
|
38
|
+
root = '/app',
|
|
39
|
+
): CodemodApp & { readonly files: Record<string, string> } {
|
|
40
|
+
return {
|
|
41
|
+
root,
|
|
42
|
+
files,
|
|
43
|
+
read: async (path) => (Object.hasOwn(files, path) ? files[path] : undefined),
|
|
44
|
+
write: async (path, source) => {
|
|
45
|
+
files[path] = source;
|
|
46
|
+
},
|
|
47
|
+
remove: async (path) => {
|
|
48
|
+
delete files[path];
|
|
49
|
+
},
|
|
50
|
+
exists: async (path) => Object.hasOwn(files, path),
|
|
51
|
+
glob: async (pattern) => {
|
|
52
|
+
const glob = new Bun.Glob(pattern);
|
|
53
|
+
return Object.keys(files)
|
|
54
|
+
.filter((path) => glob.match(path))
|
|
55
|
+
.sort();
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// 31.4.1: `defineError` comes from the `@ultimat3/core/page` leaf, which every bundle can load; the
|
|
2
|
+
// shipped `error-declared` guard refuses it from the `@ultimat3/core` barrel. A mechanical import
|
|
3
|
+
// rewrite over every app source file (the rest of an import stays put), and the prose that names it.
|
|
4
|
+
|
|
5
|
+
import type { Codemod, CodemodApp, CodemodResult } from './codemod';
|
|
6
|
+
import type { SnippetEdit } from './engine-edits';
|
|
7
|
+
import { editSnippets, mergeResults } from './engine-edits';
|
|
8
|
+
|
|
9
|
+
const IMPORT = /^import \{([^}]*)\} from '@ultimat3\/core';$/gm;
|
|
10
|
+
const LEAF = "import { defineError } from '@ultimat3/core/page';";
|
|
11
|
+
|
|
12
|
+
/** The rows that name where `defineError` comes from, in CLAUDE.md, the server agent and /feature. */
|
|
13
|
+
export const DEFINE_ERROR_PROSE: Readonly<Record<string, readonly SnippetEdit[]>> = {
|
|
14
|
+
'CLAUDE.md': [
|
|
15
|
+
{
|
|
16
|
+
from: '| Errors | never `throw new Error` — declare each code once, `defineError({ code, title, status, cause, fix })` from `@ultimat3/core`, and throw its class; never a handwritten `UltimateError` subclass | `guards/bare-error.ts`, `guards/error-declared.ts` |',
|
|
17
|
+
to: '| Errors | never `throw new Error` — declare each code once, `defineError({ code, title, status, cause, fix })` from `@ultimat3/core/page`, and throw its class; never a handwritten `UltimateError` subclass | `guards/bare-error.ts`, `guards/error-declared.ts` |',
|
|
18
|
+
optional: true,
|
|
19
|
+
},
|
|
20
|
+
],
|
|
21
|
+
'.claude/agents/server.md': [
|
|
22
|
+
{
|
|
23
|
+
from: '| Errors are instructions | never `throw new Error` — declare each code once with `defineError({ code, title, status, cause, fix })` from `@ultimat3/core`: a stable `X_SCREAMING_SNAKE` code, a cause and a `fix:` a caller can actually run. `guards/error-declared.ts` refuses a handwritten `UltimateError` subclass |',
|
|
24
|
+
to: '| Errors are instructions | never `throw new Error` — declare each code once with `defineError({ code, title, status, cause, fix })` from `@ultimat3/core/page`: a stable `X_SCREAMING_SNAKE` code, a cause and a `fix:` a caller can actually run. `guards/error-declared.ts` refuses a handwritten `UltimateError` subclass |',
|
|
25
|
+
optional: true,
|
|
26
|
+
},
|
|
27
|
+
],
|
|
28
|
+
'.claude/commands/feature.md': [
|
|
29
|
+
{
|
|
30
|
+
from: 'Never a bare `throw new Error` — declare each code once with `defineError` from `@ultimat3/core`:',
|
|
31
|
+
to: 'Never a bare `throw new Error` — declare each code once with `defineError` from `@ultimat3/core/page`:',
|
|
32
|
+
optional: true,
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/** The import with `defineError` taken out to the leaf; unchanged when it does not name it. */
|
|
38
|
+
const rewrite = (whole: string, list: string): string => {
|
|
39
|
+
const names = list
|
|
40
|
+
.split(',')
|
|
41
|
+
.map((name) => name.trim())
|
|
42
|
+
.filter((name) => name !== '');
|
|
43
|
+
if (!names.includes('defineError')) return whole;
|
|
44
|
+
const rest = names.filter((name) => name !== 'defineError');
|
|
45
|
+
return rest.length === 0 ? LEAF : `import { ${rest.join(', ')} } from '@ultimat3/core';\n${LEAF}`;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
async function sources(app: CodemodApp): Promise<CodemodResult> {
|
|
49
|
+
const changed: string[] = [];
|
|
50
|
+
for (const path of await app.glob('{apps,packages}/**/*.{ts,tsx}')) {
|
|
51
|
+
if (path.includes('node_modules/')) continue;
|
|
52
|
+
const source = (await app.read(path)) ?? '';
|
|
53
|
+
if (!source.includes('defineError')) continue;
|
|
54
|
+
const next = source.replace(IMPORT, rewrite);
|
|
55
|
+
if (next === source) continue;
|
|
56
|
+
await app.write(path, next);
|
|
57
|
+
changed.push(path);
|
|
58
|
+
}
|
|
59
|
+
return { changed, skipped: [] };
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export const codemod: Codemod = {
|
|
63
|
+
id: 'define-error-leaf',
|
|
64
|
+
since: '31.4.1',
|
|
65
|
+
summary: "defineError is imported from '@ultimat3/core/page', never the '@ultimat3/core' barrel",
|
|
66
|
+
async run(app) {
|
|
67
|
+
const results = [await sources(app)];
|
|
68
|
+
for (const [path, edits] of Object.entries(DEFINE_ERROR_PROSE)) {
|
|
69
|
+
results.push(await editSnippets(app, path, edits));
|
|
70
|
+
}
|
|
71
|
+
return mergeResults(results);
|
|
72
|
+
},
|
|
73
|
+
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// 31.17.0: CI runs the gate cut into parts (`verify plan`, a runner per part, `verify merge`), so
|
|
2
|
+
// the app's CLAUDE.md, README.md and /feature say so, and CLAUDE.md gains the Fan-out row. Prose:
|
|
3
|
+
// each edit lands where the text stands as `x new` wrote it, and is skipped silently elsewhere.
|
|
4
|
+
|
|
5
|
+
import type { Codemod } from './codemod';
|
|
6
|
+
import type { SnippetEdit } from './engine-edits';
|
|
7
|
+
import { editSnippets, mergeResults } from './engine-edits';
|
|
8
|
+
|
|
9
|
+
const lines = (...text: readonly string[]): string => text.join('\n');
|
|
10
|
+
|
|
11
|
+
const REPOS =
|
|
12
|
+
'| Repos | a `repo.ts` reads through the typed handle, never a `sql` literal the handle can express | `guards/repo-raw-sql.ts` |';
|
|
13
|
+
|
|
14
|
+
export const DOCS_CI_PARTS_EDITS: Readonly<Record<string, readonly SnippetEdit[]>> = {
|
|
15
|
+
'CLAUDE.md': [
|
|
16
|
+
{
|
|
17
|
+
from: '| One gate | `bun run verify` — `bunx x verify`, which builds what its `budgets` step weighs. Green means shippable; never merge red. CI runs the same two commands as your terminal: `bun run setup && bun run verify` | the gate itself, and `.github/workflows/ci.yml` on every push and pull request; `.github/workflows/image.yml` publishes only a commit it passed |',
|
|
18
|
+
to: '| One gate | `bun run verify` — `bunx x verify`, which builds what its `budgets` step weighs. Green means shippable; never merge red. CI runs the same gate, cut into parts: `bun run verify plan --json` names them, each runner runs `bun run setup && bun run verify --only <steps>`, and `bun run verify merge` is the verdict | the gate itself, and `.github/workflows/ci.yml` on every push and pull request; `.github/workflows/image.yml` publishes only a commit it passed |',
|
|
19
|
+
optional: true,
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
from: REPOS,
|
|
23
|
+
to: lines(
|
|
24
|
+
REPOS,
|
|
25
|
+
'| Fan-out | a database call per element of a list runs through `mapBounded(rows, fn, { width })` from `@ultimat3/core` — never `Promise.all(rows.map(async …))`, one statement per row at once; a `// why:` on the line admits a list bounded where it is built | `guards/unbounded-fanout.ts` |',
|
|
26
|
+
),
|
|
27
|
+
optional: true,
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
'README.md': [
|
|
31
|
+
{
|
|
32
|
+
from: '| `.github/workflows/ci.yml` | `bun run setup` then `bun run verify`, on push and pull request |',
|
|
33
|
+
to: '| `.github/workflows/ci.yml` | on push and pull request: `bun run verify plan` cuts the gate into parts, each runner runs `bun run setup` then its `bun run verify --only …`, and `bun run verify merge` folds them into the one verdict |',
|
|
34
|
+
optional: true,
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
'.claude/commands/feature.md': [
|
|
38
|
+
{
|
|
39
|
+
from: lines(
|
|
40
|
+
'`.x/build-stats.json` is missing or older than the source. CI runs this same script —',
|
|
41
|
+
'`.github/workflows/ci.yml` is `bun run setup` and then `bun run verify`, nothing else.',
|
|
42
|
+
),
|
|
43
|
+
to: lines(
|
|
44
|
+
'`.x/build-stats.json` is missing or older than the source. CI runs this same script, cut into',
|
|
45
|
+
'parts — `.github/workflows/ci.yml` asks `bun run verify plan` for them, runs `bun run setup` and',
|
|
46
|
+
"each part's `bun run verify --only …`, and `bun run verify merge` is the verdict.",
|
|
47
|
+
),
|
|
48
|
+
optional: true,
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export const codemod: Codemod = {
|
|
54
|
+
id: 'docs-ci-parts',
|
|
55
|
+
since: '31.17.0',
|
|
56
|
+
summary:
|
|
57
|
+
'CLAUDE.md, README.md and /feature describe CI as the gate cut into parts; CLAUDE.md gains Fan-out',
|
|
58
|
+
async run(app) {
|
|
59
|
+
const results = [];
|
|
60
|
+
for (const [path, edits] of Object.entries(DOCS_CI_PARTS_EDITS)) {
|
|
61
|
+
results.push(await editSnippets(app, path, edits));
|
|
62
|
+
}
|
|
63
|
+
return mergeResults(results);
|
|
64
|
+
},
|
|
65
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// 31.22.0: the app's CLAUDE.md states the refusal rule in one line, the Repos row names the two
|
|
2
|
+
// repo guards that report, and the paragraph `bunx x verify` already says of itself is gone.
|
|
3
|
+
// Prose the app may have reworded: each edit lands where the text stands as `x new` wrote it.
|
|
4
|
+
|
|
5
|
+
import type { Codemod } from './codemod';
|
|
6
|
+
import type { SnippetEdit } from './engine-edits';
|
|
7
|
+
import { editSnippets } from './engine-edits';
|
|
8
|
+
|
|
9
|
+
const lines = (...text: readonly string[]): string => text.join('\n');
|
|
10
|
+
|
|
11
|
+
const COMMANDS =
|
|
12
|
+
'Commands: `bun run setup`, `bun run dev`, `bun run verify`, `bunx x g <primitive>`,';
|
|
13
|
+
|
|
14
|
+
export const DOCS_GATE_EDITS: readonly SnippetEdit[] = [
|
|
15
|
+
{
|
|
16
|
+
from: lines(
|
|
17
|
+
'Every row below names what refuses it. A rule with nothing in the last column is a rule that does',
|
|
18
|
+
'not exist — five of these had an empty column and were each measured green on `bunx x verify`.',
|
|
19
|
+
),
|
|
20
|
+
to: lines(
|
|
21
|
+
'Every row below names what refuses it. A rule with nothing in the last column does not exist.',
|
|
22
|
+
),
|
|
23
|
+
optional: true,
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
from: lines(
|
|
27
|
+
'| Repos | a `repo.ts` reads through the typed handle, never a `sql` literal the handle can express | `guards/repo-raw-sql.ts` |',
|
|
28
|
+
),
|
|
29
|
+
to: lines(
|
|
30
|
+
"| Repos | a `repo.ts` reads through the typed handle, never a `sql` literal it can express; reported, not refused: an `await` per loop turn outside `expectedQueryLoop('<why>', fn)`, a bare `.all()` (it stops at 50 rows: say `.limit(n)`) | `guards/repo-raw-sql.ts`, `guards/repo-await-in-loop.ts`, `guards/repo-unbounded.ts` |",
|
|
31
|
+
),
|
|
32
|
+
optional: true,
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
from: lines(
|
|
36
|
+
'`bun run verify` is `bunx x verify`, the whole gate: its `budgets` step runs',
|
|
37
|
+
'`bunx x build --target static` itself when `.x/build-stats.json` is missing or older than the',
|
|
38
|
+
'source, so nothing has to be built first.',
|
|
39
|
+
'',
|
|
40
|
+
COMMANDS,
|
|
41
|
+
),
|
|
42
|
+
// Matched with the line after it: an empty `to` would read as already done.
|
|
43
|
+
to: COMMANDS,
|
|
44
|
+
optional: true,
|
|
45
|
+
},
|
|
46
|
+
];
|
|
47
|
+
|
|
48
|
+
export const codemod: Codemod = {
|
|
49
|
+
id: 'docs-gate-prose',
|
|
50
|
+
since: '31.22.0',
|
|
51
|
+
summary: 'CLAUDE.md: the refusal rule in one line, the Repos row with its reporting guards',
|
|
52
|
+
run: (app) => editSnippets(app, 'CLAUDE.md', DOCS_GATE_EDITS),
|
|
53
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// 31.14.0–31.15.0: an island re-reads a query on a timer through `useQuery`'s `poll`, and a mount
|
|
2
|
+
// replaces server markup through `mountOver` — two CLAUDE.md rows. Prose: each lands where the
|
|
3
|
+
// text stands as `x new` wrote it, and is skipped silently where the app reworded it.
|
|
4
|
+
|
|
5
|
+
import type { Codemod } from './codemod';
|
|
6
|
+
import type { SnippetEdit } from './engine-edits';
|
|
7
|
+
import { editSnippets } from './engine-edits';
|
|
8
|
+
|
|
9
|
+
const ISLANDS =
|
|
10
|
+
'| Islands | every `*.island.tsx` has a sibling `*.island.states.ts`, so `bunx x shot --island` can photograph its failures | `guards/island-without-states.ts` |';
|
|
11
|
+
|
|
12
|
+
export const DOCS_ISLAND_EDITS: readonly SnippetEdit[] = [
|
|
13
|
+
{
|
|
14
|
+
from: '| Polling | an island re-reads on a timer with `visibleInterval(run, ms)` from `@ultimat3/core/page` — no call while the tab is hidden, none after a lost session — never a bare `setInterval(`; a `// why:` on the line admits a tick that is not a read | `guards/raw-interval.ts` |',
|
|
15
|
+
to: '| Polling | an island re-reads a query on a timer with `useQuery(ref, input, { poll: pollEvery(ms) })` (`@ultimat3/realtime`), anything else with `visibleInterval(run, ms)` from `@ultimat3/core/page` — no call while the tab is hidden, none after a lost session — never a bare `setInterval(`; a `// why:` on the line admits a tick that is not a read | `guards/raw-interval.ts` |',
|
|
16
|
+
optional: true,
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
from: ISLANDS,
|
|
20
|
+
to: `${ISLANDS}\n| Island mounts | a \`mount\` replaces its server markup through \`mountOver\`, so a render that throws shows the server's HTML, not a blank box | \`guards/island-mount-clears.ts\` |`,
|
|
21
|
+
optional: true,
|
|
22
|
+
},
|
|
23
|
+
];
|
|
24
|
+
|
|
25
|
+
export const codemod: Codemod = {
|
|
26
|
+
id: 'docs-island-rows',
|
|
27
|
+
since: '31.15.0',
|
|
28
|
+
summary:
|
|
29
|
+
"CLAUDE.md's Polling row names useQuery's poll, and an Island mounts row joins the table",
|
|
30
|
+
run: (app) => editSnippets(app, 'CLAUDE.md', DOCS_ISLAND_EDITS),
|
|
31
|
+
};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
// 31.28.0: shipped guards run from the installed framework, never a `guards/` copy, so the app's
|
|
2
|
+
// CLAUDE.md names each by its guard name (`raw-fetch`, not `guards/raw-fetch.ts`), lists the
|
|
3
|
+
// runtime-pin rule, and says how a guard is set; the agents say the same. Prose: each edit lands
|
|
4
|
+
// where the text stands as `x new` wrote it, and is skipped silently where the app reworded it.
|
|
5
|
+
|
|
6
|
+
import { SHIPPED_GUARD_NAMES } from '../templates/scaffold-guards';
|
|
7
|
+
import type { Codemod, CodemodApp, CodemodResult } from './codemod';
|
|
8
|
+
import type { SnippetEdit } from './engine-edits';
|
|
9
|
+
import { editSnippets, mergeResults } from './engine-edits';
|
|
10
|
+
|
|
11
|
+
const CLAUDE = 'CLAUDE.md';
|
|
12
|
+
const lines = (...text: readonly string[]): string => text.join('\n');
|
|
13
|
+
|
|
14
|
+
const VENDORS =
|
|
15
|
+
"| Vendors | a server `fetch(` carries a `signal` in its own options — better, it is `outbound()` from `@ultimat3/core/outbound`: a deadline, the caller's signal, safe-only retry | `raw-fetch` |";
|
|
16
|
+
const RUNTIME =
|
|
17
|
+
"| 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` |";
|
|
18
|
+
|
|
19
|
+
export const SHIPPED_GUARDS_EDITS: Readonly<Record<string, readonly SnippetEdit[]>> = {
|
|
20
|
+
[CLAUDE]: [
|
|
21
|
+
{ from: VENDORS, to: lines(VENDORS, RUNTIME), optional: true },
|
|
22
|
+
{
|
|
23
|
+
from: lines(
|
|
24
|
+
'`guards/` is yours: each file is one rule, discovered by `bunx x verify` and run inside its',
|
|
25
|
+
'`boundaries` step. Delete one to drop the rule, and `bunx x g guard <name>` writes the next.',
|
|
26
|
+
),
|
|
27
|
+
to: lines(
|
|
28
|
+
"Each lowercase name is a guard the framework ships, run on `bunx x verify`'s `boundaries` step",
|
|
29
|
+
'from the installed version. `guards/shipped.json` sets one\'s severity (`"warning"`, `"off"`);',
|
|
30
|
+
"`bunx x g guard <name>` writes this app's own into `guards/`.",
|
|
31
|
+
),
|
|
32
|
+
optional: true,
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
'.claude/agents/server.md': [
|
|
36
|
+
{
|
|
37
|
+
from: lines(
|
|
38
|
+
'| Errors are instructions | never `throw new Error` — declare each code once with `defineError({ code, title, status, cause, fix })` from `@ultimat3/core/page`: a stable `X_SCREAMING_SNAKE` code, a cause and a `fix:` a caller can actually run. `guards/error-declared.ts` refuses a handwritten `UltimateError` subclass |',
|
|
39
|
+
),
|
|
40
|
+
to: lines(
|
|
41
|
+
'| Errors are instructions | never `throw new Error` — declare each code once with `defineError({ code, title, status, cause, fix })` from `@ultimat3/core/page`: a stable `X_SCREAMING_SNAKE` code, a cause and a `fix:` a caller can actually run. the `error-declared` guard refuses a handwritten `UltimateError` subclass |',
|
|
42
|
+
),
|
|
43
|
+
optional: true,
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
'.claude/agents/web.md': [
|
|
47
|
+
{
|
|
48
|
+
from: lines(
|
|
49
|
+
"Every one of the last five is a build error, not a preference — `guards/` holds them and `bunx x verify`'s",
|
|
50
|
+
'`boundaries` step runs them. Read the guard rather than guessing at the rule.',
|
|
51
|
+
),
|
|
52
|
+
to: lines(
|
|
53
|
+
'Every one of the last five is a build error, not a preference — a guard the framework ships, run by',
|
|
54
|
+
"`bunx x verify`'s `boundaries` step. Read the guard's finding rather than guessing at the rule.",
|
|
55
|
+
),
|
|
56
|
+
optional: true,
|
|
57
|
+
},
|
|
58
|
+
],
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const SHIPPED = new Set(SHIPPED_GUARD_NAMES);
|
|
62
|
+
|
|
63
|
+
/** A table row's `guards/<name>.ts` cell, for a guard the framework ships, as its bare name. */
|
|
64
|
+
const renamed = (source: string): string =>
|
|
65
|
+
source
|
|
66
|
+
.split('\n')
|
|
67
|
+
.map((line) =>
|
|
68
|
+
line.startsWith('| ')
|
|
69
|
+
? line.replace(/`guards\/([a-z0-9-]+)\.ts`/g, (cell, name: string) =>
|
|
70
|
+
SHIPPED.has(name) ? `\`${name}\`` : cell,
|
|
71
|
+
)
|
|
72
|
+
: line,
|
|
73
|
+
)
|
|
74
|
+
.join('\n');
|
|
75
|
+
|
|
76
|
+
async function table(app: CodemodApp): Promise<CodemodResult> {
|
|
77
|
+
const source = await app.read(CLAUDE);
|
|
78
|
+
if (source === undefined) return { changed: [], skipped: [] };
|
|
79
|
+
const next = renamed(source);
|
|
80
|
+
if (next === source) return { changed: [], skipped: [] };
|
|
81
|
+
await app.write(CLAUDE, next);
|
|
82
|
+
return { changed: [CLAUDE], skipped: [] };
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export const codemod: Codemod = {
|
|
86
|
+
id: 'docs-shipped-guards',
|
|
87
|
+
since: '31.28.0',
|
|
88
|
+
summary:
|
|
89
|
+
'CLAUDE.md and .claude/agents name each shipped guard as the framework runs it, not as a guards/ copy',
|
|
90
|
+
async run(app) {
|
|
91
|
+
const results = [await table(app)];
|
|
92
|
+
// A runtime row only where none is: the insert matches the Vendors row, which stays.
|
|
93
|
+
const runtime = ((await app.read(CLAUDE)) ?? '').includes('| Runtime |');
|
|
94
|
+
for (const [path, edits] of Object.entries(SHIPPED_GUARDS_EDITS)) {
|
|
95
|
+
const todo = path === CLAUDE && runtime ? edits.slice(1) : edits;
|
|
96
|
+
results.push(await editSnippets(app, path, todo));
|
|
97
|
+
}
|
|
98
|
+
return mergeResults(results);
|
|
99
|
+
},
|
|
100
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// 31.27.0: the app's CLAUDE.md and README.md say what the live and e2e suites run on, and that
|
|
2
|
+
// `bun run verify` starts the test services itself. Prose the app may have reworded: each edit
|
|
3
|
+
// lands where the text stands as `x new` wrote it, and is skipped silently where it does not.
|
|
4
|
+
|
|
5
|
+
import type { Codemod } from './codemod';
|
|
6
|
+
import type { SnippetEdit } from './engine-edits';
|
|
7
|
+
import { editSnippets, mergeResults } from './engine-edits';
|
|
8
|
+
|
|
9
|
+
const lines = (...text: readonly string[]): string => text.join('\n');
|
|
10
|
+
|
|
11
|
+
export const DOCS_TEST_SERVICES_EDITS: Readonly<Record<string, readonly SnippetEdit[]>> = {
|
|
12
|
+
'CLAUDE.md': [
|
|
13
|
+
{
|
|
14
|
+
from: lines(
|
|
15
|
+
'Every test the scaffold and the generators write is the idiom to copy. All of them run on the',
|
|
16
|
+
'`unit` step — in process, on the in-memory driver, with no database, browser or server.',
|
|
17
|
+
'',
|
|
18
|
+
'A suite that needs a real server reads it from `docker/test-services.env`: Postgres 18, Redis, NATS',
|
|
19
|
+
'and S3 from `docker/docker-compose.test.yml`, in RAM, with durability and logging off — CI starts',
|
|
20
|
+
'it before `bun run verify`, a laptop with `docker compose -f docker/docker-compose.test.yml up -d',
|
|
21
|
+
'--wait` then `set -a; . docker/test-services.env; set +a`. A resource a test opens is held with',
|
|
22
|
+
),
|
|
23
|
+
to: lines(
|
|
24
|
+
'Every test the scaffold and the generators write is the idiom to copy. A `*.live.test.ts` runs',
|
|
25
|
+
'on a real Postgres, a `*.e2e.test.ts` in a real browser; the rest on `unit`, in memory.',
|
|
26
|
+
'',
|
|
27
|
+
'A suite that needs a real server reads it from `docker/test-services.env`: Postgres 18, Redis, NATS',
|
|
28
|
+
'and S3 from `docker/docker-compose.test.yml`, in RAM, with durability and logging off.',
|
|
29
|
+
'`bun run verify` starts it itself when nothing answers at `TEST_DATABASE_URL` and Docker is',
|
|
30
|
+
'there; by hand it is `docker compose -f docker/docker-compose.test.yml up -d --wait` then',
|
|
31
|
+
'`set -a; . docker/test-services.env; set +a`. A resource a test opens is held with',
|
|
32
|
+
),
|
|
33
|
+
optional: true,
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
'README.md': [
|
|
37
|
+
{
|
|
38
|
+
from: lines(
|
|
39
|
+
'Tests against real servers — Postgres 18, Redis, NATS, S3, in RAM and silent, as CI runs them:',
|
|
40
|
+
),
|
|
41
|
+
to: lines(
|
|
42
|
+
'Tests against real servers — Postgres 18, Redis, NATS, S3, in RAM and silent, as CI runs them.',
|
|
43
|
+
'`bun run verify` starts them when nothing answers and Docker is there; by hand:',
|
|
44
|
+
),
|
|
45
|
+
optional: true,
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export const codemod: Codemod = {
|
|
51
|
+
id: 'docs-test-services',
|
|
52
|
+
since: '31.27.0',
|
|
53
|
+
summary:
|
|
54
|
+
'CLAUDE.md and README.md: the live and e2e suites, and the test services verify starts itself',
|
|
55
|
+
async run(app) {
|
|
56
|
+
const results = [];
|
|
57
|
+
for (const [path, edits] of Object.entries(DOCS_TEST_SERVICES_EDITS)) {
|
|
58
|
+
results.push(await editSnippets(app, path, edits));
|
|
59
|
+
}
|
|
60
|
+
return mergeResults(results);
|
|
61
|
+
},
|
|
62
|
+
};
|