@ultimat3/cli 30.9.0 → 31.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +75 -64
- package/README.md +4 -1
- package/package.json +30 -29
- package/src/admin-registration.ts +1 -1
- package/src/affected.ts +5 -1
- package/src/app-boundaries.ts +88 -9
- package/src/app-load-async.ts +133 -0
- package/src/app-load-batch.ts +203 -0
- package/src/app-load-prebuilt.ts +147 -0
- package/src/app-load-register.ts +175 -0
- package/src/app-load.ts +143 -175
- package/src/app-loader-imports.ts +31 -0
- package/src/app-root.ts +13 -0
- package/src/app-runtime.ts +5 -1
- package/src/boundary-findings.ts +12 -0
- package/src/browser-launcher-port.ts +3 -7
- package/src/browser-launcher.ts +1 -1
- package/src/budgets-scan.ts +8 -0
- package/src/budgets.ts +10 -1
- package/src/build-registry-background.ts +59 -0
- package/src/build-registry.ts +207 -0
- package/src/cdp-shot-clock.ts +3 -11
- package/src/cdp-shot-driver.ts +3 -2
- package/src/cdp-shot-element.ts +3 -2
- package/src/cdp-shot-page.ts +2 -2
- package/src/cdp-shot-watch.ts +4 -3
- package/src/cmd-auth.ts +3 -3
- package/src/cmd-db-recount.ts +15 -0
- package/src/cmd-drill.ts +10 -6
- package/src/cmd-exercise.ts +2 -1
- package/src/cmd-generate-spec.ts +6 -0
- package/src/cmd-generate.ts +22 -4
- package/src/cmd-mail.ts +1 -1
- package/src/cmd-routes.ts +2 -2
- package/src/cmd-secrets-spec.ts +4 -1
- package/src/cmd-shot.ts +14 -4
- package/src/cmd-verify-spec.ts +21 -1
- package/src/cmd-verify.ts +16 -4
- package/src/coverage-source.ts +4 -1
- package/src/db-diagnostics.ts +8 -1
- package/src/dev-boot.ts +29 -15
- package/src/dev-dashboard-invalidations.ts +43 -0
- package/src/dev-dashboard.ts +13 -16
- package/src/dev-n-plus-one.ts +7 -3
- package/src/dev-rebuild.ts +2 -1
- package/src/dev-route-table.ts +1 -1
- package/src/dev-traces.ts +16 -15
- package/src/document-options.ts +12 -1
- package/src/drift-store.ts +55 -0
- package/src/error-catalog.ts +8 -3
- package/src/error-codes-boundary.ts +32 -0
- package/src/error-codes.ts +23 -19
- package/src/errors.ts +17 -7
- package/src/exercise-database.ts +13 -1
- package/src/exercise-findings.ts +36 -18
- package/src/exercise-services.ts +84 -0
- package/src/exercise-subject.ts +38 -13
- package/src/failure-capture-boot.ts +9 -5
- package/src/framework-schema.ts +5 -5
- package/src/generate-exercise.ts +1 -1
- package/src/generate-files.ts +27 -7
- package/src/generate-kinds.ts +5 -0
- package/src/generate-refresh.ts +53 -0
- package/src/generate-workspace.ts +169 -0
- package/src/generate-write.ts +8 -2
- package/src/hold.ts +19 -8
- package/src/image-prepare.ts +6 -2
- package/src/index.ts +5 -20
- package/src/island-bundle.ts +7 -3
- package/src/island-capture.ts +2 -2
- package/src/island-harness.ts +1 -1
- package/src/job-registration.ts +43 -6
- package/src/jobs-driver.ts +4 -5
- package/src/mcp-errors.ts +18 -4
- package/src/mcp-host.ts +5 -1
- package/src/mcp-ui-interact.ts +3 -0
- package/src/messages-gate.ts +4 -0
- package/src/new-shapes-generate.ts +1 -1
- package/src/otlp-export.ts +94 -29
- package/src/output.ts +3 -7
- package/src/page-sync.ts +3 -1
- package/src/role-load.ts +17 -11
- package/src/role-start.ts +5 -4
- package/src/role-sync.ts +7 -8
- package/src/route-islands-preload.ts +46 -0
- package/src/route-islands.ts +6 -2
- package/src/runtime-admin.ts +5 -1
- package/src/runtime-bindings.ts +25 -19
- package/src/runtime-boot-ports.ts +66 -0
- package/src/runtime-bus.ts +29 -5
- package/src/runtime-cache-bus.ts +53 -0
- package/src/runtime-cache.ts +43 -13
- package/src/runtime-isr-outcome.ts +5 -4
- package/src/runtime-jobs.ts +2 -2
- package/src/runtime-keys.ts +37 -0
- package/src/runtime-overrides.ts +148 -42
- package/src/runtime-port-bindings-queue.ts +36 -0
- package/src/runtime-port-bindings.ts +117 -0
- package/src/runtime-ports.ts +164 -0
- package/src/runtime-purge.ts +41 -28
- package/src/runtime-push.ts +7 -3
- package/src/runtime-queue.ts +70 -55
- package/src/runtime-realtime.ts +5 -5
- package/src/runtime-render-document.ts +4 -1
- package/src/runtime-services.ts +110 -158
- package/src/runtime-storage-boot.ts +111 -0
- package/src/runtime-storage-upload.ts +9 -7
- package/src/runtime-storage.ts +7 -1
- package/src/serve-boot.ts +8 -4
- package/src/serve-entry.ts +3 -0
- package/src/serve-env.ts +47 -14
- package/src/serve-prebuilt-paths.ts +3 -0
- package/src/serve-prebuilt.ts +15 -4
- package/src/serve.ts +2 -2
- package/src/static-cards.ts +3 -2
- package/src/static-report.ts +2 -2
- package/src/style-bundle.ts +1 -1
- package/src/sync-authenticator.ts +17 -18
- package/src/templates/action-tests.ts +4 -4
- package/src/templates/backfill.ts +5 -8
- package/src/templates/entity.ts +3 -0
- package/src/templates/github/ci.yml.ts +3 -1
- package/src/templates/github/dependabot.yml.ts +73 -0
- package/src/templates/job.ts +13 -22
- package/src/templates/naming.ts +20 -1
- package/src/templates/pinned/docker-compose.yml +1 -1
- package/src/templates/query.ts +7 -8
- package/src/templates/route.ts +5 -3
- package/src/templates/scaffold-api.ts +1 -1
- package/src/templates/scaffold-auth.ts +5 -3
- package/src/templates/scaffold-claude-commands.ts +6 -3
- package/src/templates/scaffold-claude.ts +4 -4
- package/src/templates/scaffold-container-compose.ts +2 -4
- package/src/templates/scaffold-domain-package.ts +1 -1
- package/src/templates/scaffold-entries.ts +6 -1
- package/src/templates/scaffold-helm-fences.ts +3 -2
- package/src/templates/scaffold-helm.ts +35 -6
- package/src/templates/scaffold-repo.ts +47 -135
- package/src/templates/scaffold-runtime-ports.ts +62 -0
- package/src/templates/scaffold-verify-floor.ts +97 -0
- package/src/templates/shapes/overlay.ts +1 -1
- package/src/templates/sign-in-oidc.ts +5 -3
- package/src/templates/sign-in-shared.ts +28 -10
- package/src/templates/workspace.ts +75 -0
- package/src/test-ignores.ts +5 -2
- package/src/test-select.ts +4 -1
- package/src/upgrade-gate.ts +30 -5
- package/src/upgrade-report.ts +7 -1
- package/src/verify-changed-facts.ts +53 -0
- package/src/verify-changed-scope.ts +161 -0
- package/src/verify-changed.ts +174 -0
- package/src/verify-checks.ts +31 -19
- package/src/verify-drift-owner.ts +30 -0
- package/src/verify-e2e.ts +2 -1
- package/src/verify-factories.ts +86 -0
- package/src/verify-run.ts +13 -11
- package/src/verify-step.ts +13 -0
- package/src/verify-tests.ts +58 -6
- package/src/write-line.ts +21 -6
- package/wiki/Actions.md +2 -2
- package/wiki/Adapters.md +400 -0
- package/wiki/Admin-Dashboard.md +1 -1
- package/wiki/Agents.md +9 -9
- package/wiki/Auth.md +78 -2
- package/wiki/Building-Your-Own-Base.md +1 -1
- package/wiki/CLI-Reference.md +34 -7
- package/wiki/Caching-And-Invalidation.md +17 -5
- package/wiki/Compared.md +8 -2
- package/wiki/Configuration.md +14 -14
- package/wiki/Deployment.md +28 -1
- package/wiki/Entities-And-Migrations.md +47 -1
- package/wiki/FAQ.md +8 -2
- package/wiki/Feature-Flags.md +1 -1
- package/wiki/Home.md +3 -2
- package/wiki/Jobs-And-Workflows.md +107 -6
- package/wiki/Known-Gaps.md +4 -3
- package/wiki/MCP-And-AI.md +18 -4
- package/wiki/Mail.md +14 -5
- package/wiki/Migrations-And-Backfills.md +29 -4
- package/wiki/Money.md +2 -0
- package/wiki/N-Plus-One-Detection.md +24 -22
- package/wiki/Notify.md +28 -4
- package/wiki/Observability.md +121 -15
- package/wiki/Queries-And-Live-Queries.md +2 -2
- package/wiki/Realtime.md +9 -4
- package/wiki/Routes-And-Render-Modes.md +5 -0
- package/wiki/Scraping.md +57 -11
- package/wiki/Shapes.md +2 -2
- package/wiki/Stability.md +7 -5
- package/wiki/Storage-And-Uploads.md +56 -4
- package/wiki/Testing.md +65 -52
- package/wiki/Troubleshooting.md +1 -1
- package/wiki/Tutorial-01-First-App.md +1 -1
- package/wiki/Tutorial-04-Jobs-And-Realtime.md +1 -1
- package/wiki/Tutorial-05-Deploy-Free.md +1 -1
- package/wiki/Tutorial-06-Growing-Up.md +8 -8
- package/wiki/Upgrading.md +129 -4
package/CLAUDE.md
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
# @ultimat3/cli — boundary
|
|
2
2
|
|
|
3
3
|
Tier 5. May import tiers 0–4. Declared sideways edges: `cli → admin` (`x dev` mounts the `/_x`
|
|
4
|
-
dashboard), `cli → testing` (islands, the e2e step
|
|
4
|
+
dashboard), `cli → testing` (islands, the e2e step); `x shot` launches via `@ultimat3/scraping/cdp`. Nothing imports
|
|
5
5
|
this except `create-ultimate`. The reasoning behind every rule below, verbatim and dated, is
|
|
6
|
-
[`docs/history/cli.md`](../../docs/history/cli.md)
|
|
6
|
+
[`docs/history/cli.md`](../../docs/history/cli.md) (`‡` marks a row whose rule is there); `†` marks a
|
|
7
|
+
row whose full text is in [`docs/history/cli-file-map.md`](../../docs/history/cli-file-map.md).
|
|
8
|
+
Where they disagree this file wins.
|
|
7
9
|
|
|
8
|
-
Commands: `bun test packages/cli
|
|
10
|
+
Commands: `bun test ./packages/cli/` (repo root: the preload),
|
|
9
11
|
`bunx tsc --noEmit -p packages/cli/tsconfig.json`.
|
|
10
12
|
|
|
11
13
|
## Rules
|
|
12
14
|
|
|
13
15
|
| Rule | Detail |
|
|
14
16
|
|---|---|
|
|
15
|
-
| Entry | `src/bin.ts` — argv, stdout, exit code only
|
|
16
|
-
| Registry | `registry.ts`: every declaration static (`cmd-<name>-spec.ts`), every body `await import()`ed when that command runs
|
|
17
|
+
| Entry | `src/bin.ts` — argv, stdout, exit code only ‡ |
|
|
18
|
+
| Registry | `registry.ts`: every declaration static (`cmd-<name>-spec.ts`), every body `await import()`ed when that command runs ‡ |
|
|
17
19
|
| Startup cost | `sass` loads on the first stylesheet compile (`@ultimat3/render`'s `compileStylesheet`), Babel on the first island transform (`solid-loader.ts`); both pinned by `*-lazy.test.ts` in a child process |
|
|
18
20
|
| Module names | `role-*` / `runtime-*` are booted by `serve.ts` in production; `dev-*` is `x dev`'s alone. Derived from the import graph by `module-naming.test.ts`, never listed |
|
|
19
21
|
| stdout / stderr | `write-line.ts`'s `writeLine` / `writeErrorLine` — synchronous fd writes, never `process.stdout.write` (truncates at the pipe buffer before `process.exit`). A `CommandResult` with `stream: 'stderr'` goes to fd 2 (`x mcp serve --transport stdio`) |
|
|
@@ -32,9 +34,9 @@ Commands: `bun test packages/cli` (from the repo root: the preload),
|
|
|
32
34
|
| Errors | codes + titles in `error-codes.ts`, a runnable line per code in `mcp-errors.ts` (typed over `CliErrorCode`), classes in `errors.ts` or beside their one thrower when `errors.ts` is at its ceiling. Never a bare `Error` |
|
|
33
35
|
| Subprocesses | only through `exec.ts`'s injectable `Runner`; `gh` through `ctx.runner` with a required `fix` |
|
|
34
36
|
| Templates | `templates/*.ts` return strings, pre-formatted for Biome (`wrap.ts`'s `wrapList` / `wrapImport` / `sortSpecifiers`); no fixture files on disk |
|
|
35
|
-
| Strings | rendered output through `messages.ts` (missing key renders `⟦key⟧`)
|
|
37
|
+
| Strings | rendered output through `messages.ts` (missing key renders `⟦key⟧`) ‡ |
|
|
36
38
|
| Facts | load the app (`app-load.ts`), then project a framework package's registry — never parse source for primitives, never re-derive a fact another package owns |
|
|
37
|
-
| Public API | `src/index.ts`, explicit re-exports only
|
|
39
|
+
| Public API | `src/index.ts`, explicit re-exports only ‡ |
|
|
38
40
|
|
|
39
41
|
## File map
|
|
40
42
|
|
|
@@ -43,33 +45,37 @@ Commands: `bun test packages/cli` (from the repo root: the preload),
|
|
|
43
45
|
| File | Job |
|
|
44
46
|
|---|---|
|
|
45
47
|
| `verify-checks.ts` / `verify-step.ts` / `verify-run.ts` / `verify-e2e-lane.ts` | steps, outcome, order (`BESIDE_SERIAL_SUITES`, e2e lane) |
|
|
48
|
+
| `verify-changed*.ts` | `x verify --changed`: file → rule → steps, fail-open; `drift` only when reached † |
|
|
49
|
+
| `verify-drift-owner.ts` | `drift`: an `app.config.ts` under `apps/`/`packages/` is `X_APP_ROOT_NESTED` — one repo, one app, one image, one migration owner |
|
|
46
50
|
| `verify-exercise.ts` / `cmd-exercise.ts` / `exercise-*.ts` | `exercise`: `x exercise --json` as a child, red on its findings |
|
|
47
51
|
| `verify-floor.ts` | `x.verify.json`: a floor step that ran zero tests is `X_VERIFY_SUITE_VANISHED` |
|
|
48
|
-
| `coverage-floor
|
|
49
|
-
| `verify-deadline.ts` / `verify-stalled.ts` / `verify-progress.ts` | a step past its deadline is `X_VERIFY_STEP_TIMEOUT
|
|
52
|
+
| `coverage-{floor,lcov,source}.ts` / `verify-coverage-run.ts` | an app's `unit` coverage floor; `coverage-lcov.ts` is the ONE lcov reader † |
|
|
53
|
+
| `verify-deadline.ts` / `verify-stalled.ts` / `verify-progress.ts` | a step past its deadline is `X_VERIFY_STEP_TIMEOUT`; its children are killed by tag † |
|
|
50
54
|
| `load-findings.ts` | module-load failures are reported once, by `manifest`; other steps point there |
|
|
51
|
-
| `
|
|
52
|
-
| `
|
|
53
|
-
| `
|
|
54
|
-
| `
|
|
55
|
+
| `verify-factories.ts` | `unit` lints `<app>/packages/db/factories.ts` (`X_TEST_FACTORY_INVALID`) |
|
|
56
|
+
| `boundary-findings.ts` / `app-boundaries.ts` / `boundary-cuts.ts` / `package-boundaries.ts` | surface + layer rules, `X_BOUNDARY_PACKAGE_TO_APP`; a `fix:` is the concrete cut † |
|
|
57
|
+
| `app-boundaries.ts` (workspaces) | `@<scope>/<app>/<rest>` resolves onto `apps/<app>/<rest>` when that is an app source, so the surface rules hold across app workspaces |
|
|
58
|
+
| `app-transport.ts` / `browser-transport.ts` / `transport-calls.ts` / `import-closure.ts` / `server-barrels.ts` | `boundaries`, built in: one browser transport; never a `guards/` file † |
|
|
59
|
+
| `guards.ts` / `guard-sources.ts` | an app's `guards/*.ts`, run on `boundaries`; ONE shared walk (`GuardSources`) † |
|
|
60
|
+
| `templates/scaffold-guards.ts` | `SHIPPED`, the one list of shipped guards (`x new`, `x g guard`, `doctor-guards.ts`) † |
|
|
55
61
|
| `error-contract.ts` / `ts-scan.ts` / `fix-scan.ts` / `fix-imports.ts` / `fix-command.ts` / `fix-path.ts` | the `errors` step: every `fix:` names a runnable command, call or existing file |
|
|
56
|
-
| `workspace-checks.ts` / `test-only-shipped.ts` / `workspace-graph.ts` / `tsconfig-references.ts` / `publish-closure.ts` | `package-shape`, `filesize
|
|
57
|
-
| `app-permissions
|
|
62
|
+
| `workspace-checks.ts` / `test-only-shipped.ts` / `workspace-graph.ts` / `tsconfig-references.ts` / `publish-closure.ts` | `package-shape`, `filesize` ‡ |
|
|
63
|
+
| `app-permissions*.ts` / `permission-grants.ts` | `policy`: `X_PERMISSION_UNGRANTED`, `X_PERMISSION_BORROWED` † |
|
|
58
64
|
| `job-registration.ts` | `manifest`: no job or task under a positional `anonymous-*` name (`X_JOB_UNREGISTERED`) |
|
|
59
65
|
| `unscanned-admin.ts` | `manifest`: a `defineAdmin()` outside the app scan (`apps/*/src/`) is `X_ADMIN_UNSCANNED` |
|
|
60
66
|
| `tool-gate-names.ts` · `verify-mcp-mount.ts` | `manifest`: a gate on no tool · `expose` and no `POST /mcp` |
|
|
61
|
-
| `verify-role-load.ts` / `verify-role-load-probe.ts` | `manifest`:
|
|
62
|
-
| `async-pages.ts` / `live-routes.ts` / `budgets.ts` / `budgets-unmeasured.ts` | `budgets` riders:
|
|
63
|
-
| `budgets-freshness.ts` / `verify-budgets-build.ts` |
|
|
64
|
-
| `app-agents-md.ts` / `app-env.ts` / `app-openapi.ts` / `app-manifest.ts` | `manifest` and `contract-diff
|
|
65
|
-
| `schema-drift.ts` / `drift.ts` / `drift-replica-identity.ts` / `db-destructive.ts` / `db-ungeneratable.ts` | `drift`: snapshot vs declarations, the source hash, the header markers
|
|
66
|
-
| `db-rolling.ts` / `doctor-rolling.ts` | `drift`'s
|
|
67
|
-
| `schema-dump-drift.ts` | also the dump-vs-newest-snapshot rail, no database (`X_DB_DRIFT`)
|
|
67
|
+
| `verify-role-load.ts` / `verify-role-load-probe.ts` | `manifest`: what a worker never registers (`X_ROLE_LOAD_INCOMPLETE`) † |
|
|
68
|
+
| `async-pages.ts` / `live-routes.ts` / `budgets.ts` / `budgets-unmeasured.ts` | `budgets` riders: async `Page` with no `load`, unimported live read, bytes per route, unweighed routes † |
|
|
69
|
+
| `budgets-freshness.ts` / `verify-budgets-build.ts` | stale or missing stats: the step builds first (`x build --target static`) † |
|
|
70
|
+
| `app-agents-md.ts` / `app-env.ts` / `app-openapi.ts` / `app-manifest.ts` | `manifest` and `contract-diff` ‡ |
|
|
71
|
+
| `schema-drift.ts` / `drift.ts` / `drift-replica-identity.ts` / `db-destructive.ts` / `db-ungeneratable.ts` | `drift`: snapshot vs declarations, the source hash, the header markers ‡ |
|
|
72
|
+
| `db-rolling.ts` / `doctor-rolling.ts` | `drift`'s rolling rail (`X_MIGRATION_ROLLING_UNSAFE`) † |
|
|
73
|
+
| `schema-dump-drift.ts` | also the dump-vs-newest-snapshot rail, no database (`X_DB_DRIFT`) ‡ |
|
|
68
74
|
| `i18n-registration.ts` / `i18n-audit.ts` / `admin-catalog-keys.ts` | `i18n`; a mounted admin's keys are `AdminApp.catalogKeys()`, asked of every app catalog — never re-derived here (`X_CATALOG_MISSING_KEYS`) |
|
|
69
75
|
| `error-unthrown.ts` / `unthrown-codes.ts` | host check: a registered code nothing throws is listed in `UNTHROWN_CODES` (a row's wording waives nothing); a listed code thrown again is `X_ERROR_CODE_UNTHROWN_STALE` |
|
|
70
76
|
| `lint-findings.ts` | `lint`: `biome check --reporter=json` as one finding per diagnostic |
|
|
71
77
|
| `i18n-app-key-shapes.ts` | every shape whose literal is a catalog key; `i18n-app-key-shapes.test.ts` reads `blocks`, so a new block reds until listed |
|
|
72
|
-
| `job-budget.ts` | `X_JOB_OUTLASTS_DRAIN
|
|
78
|
+
| `job-budget.ts` | `X_JOB_OUTLASTS_DRAIN` (`manifest`): `timeout` vs `workerBudgetMs(drain)`, from the registry † |
|
|
73
79
|
| `output-findings.ts` | render layer only: `runnableFix` (`bunx x`, decided by `dispatch.ts`'s `readerFor`) and `collapseFindings`. Throw sites keep `x …` |
|
|
74
80
|
| `app-load-unresolved.ts` | `X_APP_IMPORT_UNRESOLVED`, read by the scan, `findingFrom` and `x doctor`'s `snapshots` probe |
|
|
75
81
|
| `fix-truth.test.ts` / `fix-truth-fixture.ts` / `db-fix-truth.job.test.ts` | a printed fix, executed: each row breaks a scaffold, asserts the code and runs the line |
|
|
@@ -79,74 +85,79 @@ Commands: `bun test packages/cli` (from the repo root: the preload),
|
|
|
79
85
|
| File | Job |
|
|
80
86
|
|---|---|
|
|
81
87
|
| `cmd-generate.ts` / `generate-files.ts` / `generate-kinds.ts` / `generate-write.ts` | argv → pure file list → writes (conflict-checked, `merge: 'json'` / `'if-absent'`) |
|
|
88
|
+
| `templates/workspace.ts` | `x g app` / `x g package`: a workspace the root globs and the one tsconfig alias (`@<app>/*` → `packages/*/src`, then `apps/*`) already reach |
|
|
82
89
|
| `write-generated.ts` | `x new`'s writer: a `link` file is a relative symlink, a copy only on a refusing win32 |
|
|
83
90
|
| `generate-feature.ts` | a `--feature` naming no slice is `X_FEATURE_UNKNOWN`; nothing invents an entity |
|
|
84
|
-
| `generate-shadow.ts` | a name
|
|
91
|
+
| `generate-shadow.ts` | a name that shadows a type or value in a planned file is `X_CLI_BAD_FLAG` † |
|
|
85
92
|
| `generate-plural.ts` | a planned `entity.ts` in an already-plural slice (`posts` → `postses`) is `X_CLI_BAD_FLAG`; the fix names the singular |
|
|
86
|
-
| `generate-catalog-locales.ts` | `--locales` never starts a catalog
|
|
93
|
+
| `generate-catalog-locales.ts` | `--locales` never starts a catalog; missing locale is `X_CLI_BAD_FLAG` † |
|
|
87
94
|
| `app-name.ts` | `x new`'s slug is asked of core's `defineConfig`, never a copied pattern; refused with a suggested name (`9lives` → `app-9lives`, `a` → `a-app`, cut at 64) |
|
|
88
|
-
| `generate-grants.ts` | a written `policy.ts` or `entity.ts` declares and grants its permissions in `apps/web/shared/roles.ts
|
|
95
|
+
| `generate-grants.ts` | a written `policy.ts` or `entity.ts` declares and grants its permissions in `apps/web/shared/roles.ts` ‡ |
|
|
89
96
|
| `api-registration.ts` | a written job or task is listed in `apps/web/api/index.ts` |
|
|
90
97
|
| `generate-exercise.ts` | a contract test's entry in `apps/web/exercise.ts` (`exercise-entry-edit.ts`) |
|
|
91
|
-
| `handle-registration.ts` / `workspace-dep-edit.ts` / `templates/scaffold-db-client.ts` | a written entity joins `entities`
|
|
92
|
-
| `generated-imports.ts` |
|
|
93
|
-
| `admin-registration.ts` / `templates/admin-catalog.ts` / `source-edit.ts` | `--admin` wires
|
|
98
|
+
| `handle-registration.ts` / `workspace-dep-edit.ts` / `templates/scaffold-db-client.ts` | a written entity joins `entities` (`X_DB_HANDLE_UNREGISTERED`) † |
|
|
99
|
+
| `generated-imports.ts` | a written file's sibling-workspace imports are declared where it landed (`X_WORKSPACE_DEP_UNDECLARED`) † |
|
|
100
|
+
| `admin-registration.ts` / `templates/admin-catalog.ts` / `source-edit.ts` | `--admin` wires its override (`X_ADMIN_RESOURCE_UNWIRED`) † |
|
|
94
101
|
| `app-artifacts.ts` | `x.manifest.json` + `openapi.json`, written together (`x g`, `x manifest`) |
|
|
95
102
|
| `templates/` | every emitted file; `scaffold-*.ts` for `x new`, one per generator otherwise. See history |
|
|
96
103
|
| `generate-feature-required.ts` | `x g query`/`backfill` with no slice holding an `entity.ts` is `X_FEATURE_REQUIRED` |
|
|
97
104
|
| `generate-sign-in*.ts` | `x g sign-in`: one flag, no name; OIDC swaps only `x new`'s bytes |
|
|
98
105
|
| `generate-format-written.ts` | the app's Biome over the TypeScript a run created, best effort; `lint` judges |
|
|
99
|
-
| `templates/scaffold-mcp-{json,endpoint,admin}.ts` | `.mcp.json` (`bunx @ultimat3/cli mcp serve`, never `bunx x`) and the refusing MCP endpoints
|
|
106
|
+
| `templates/scaffold-mcp-{json,endpoint,admin}.ts` | `.mcp.json` (`bunx @ultimat3/cli mcp serve`, never `bunx x`) and the refusing MCP endpoints ‡ |
|
|
100
107
|
|
|
101
108
|
### Boot (`x dev`, the container)
|
|
102
109
|
|
|
103
110
|
| File | Job |
|
|
104
111
|
|---|---|
|
|
105
|
-
| `serve.ts` / `serve-boot.ts` / `serve-entry.ts` / `serve-env.ts` | the production entry:
|
|
106
|
-
| `
|
|
107
|
-
| `
|
|
108
|
-
| `
|
|
109
|
-
| `
|
|
112
|
+
| `serve.ts` / `serve-boot.ts` / `serve-entry.ts` / `serve-env.ts` | the production entry: `ROLE`, env bindings, `ROLE=migrate`; `X_APP_MODULE_LOAD_FAILED` † |
|
|
113
|
+
| `app-load-batch.ts` / `app-load-register.ts` | one hook module per app module, each registered before the next evaluates: serial order kept, top-level await isolated; registration state |
|
|
114
|
+
| `app-load-prebuilt.ts` / `build-registry.ts` / `build-registry-background.ts` | every serving role boots from the prebuilt registry (`node_modules/.cache/ultimate/registry`, `x build`), format 3: the whole app, and the worker/scheduler subset under a stamp; an older format or `X_PREBUILT_REGISTRY_STALE` → scan |
|
|
115
|
+
| `generate-refresh.ts` | `x g` refreshes the manifest only when a written file needs it |
|
|
116
|
+
| `role-load.ts` / `document-graph.ts` / `serve-web.ts` | a role imports what it runs: `ROLE_LOADS` (`X_ROLE_LOAD_INCOMPLETE`) † |
|
|
117
|
+
| `module-imports.ts` | a module's imports, resolved once for both graphs: `referenced` (reload), `evaluated` (document) |
|
|
118
|
+
| `cmd-dev.ts` / `dev-boot.ts` / `dev-rebuild.ts` / `dev-route-table.ts` | `x dev`: every role in one process, `/_x`, the watcher; one save = one generation † |
|
|
119
|
+
| `runtime-bindings.ts` | which service each binding points at (embedded or external); events follow `NATS_URL` |
|
|
110
120
|
| `runtime-queue.ts` / `runtime-services.ts` / `runtime-bus.ts` | db + queue; every other accessor; the bus |
|
|
111
|
-
| `framework-schema-apply.ts` / `framework-schema-stamp.ts` | the framework tables
|
|
121
|
+
| `framework-schema-apply.ts` / `framework-schema-stamp.ts` | the framework tables, applied in one locked transaction † |
|
|
112
122
|
| `runtime-isr.ts` | the ISR controller both boots serve through, ATTACHED to `invalidateTags` and released on stop (`attachedIsr`); `appRoutes` without one builds and attaches its own |
|
|
113
|
-
| `runtime-mfa-warning.ts` / `runtime-idempotency-scope.ts` | boot warnings
|
|
114
|
-
| `app-config-load.ts` | the ONE reader of
|
|
115
|
-
| `theme-brand.ts` | the ONE reader of an app's theme
|
|
116
|
-
| `runtime-jobs
|
|
123
|
+
| `runtime-mfa-warning.ts` / `runtime-idempotency-scope.ts` | boot warnings: unsealed MFA secrets (web role, `x auth seal-mfa`), a per-process idempotency store after the app loaded |
|
|
124
|
+
| `app-config-load.ts` | the ONE reader of `app.config.ts` (`loadAppConfig`) † |
|
|
125
|
+
| `theme-brand.ts` | the ONE reader of an app's theme (`brand` in `apps/web/shared/theme.ts`) † |
|
|
126
|
+
| `runtime-{jobs,realtime,notify-retention,cache,purge,replica}.ts` | the `app.config.ts` sections the boot obeys (`*Of(config)`) † |
|
|
127
|
+
| `runtime-cache-bus.ts` | which bus carries cache/ISR invalidations: transport if it crosses processes, else Redis pub/sub on `REDIS_URL`, else in-process; one `cache.broadcast` boot line † |
|
|
117
128
|
| `runtime-jobs.ts` (queues) | `jobs.queues` ∪ registered; `WORKER_QUEUES` = the EXACT set, each in that union or `X_WORKER_QUEUE_UNKNOWN`; `-unserved.ts`: what no live worker serves |
|
|
118
|
-
| `serve-retire.ts` / `dev-restart-retire.ts` | the worker retire
|
|
119
|
-
| `role-start
|
|
129
|
+
| `serve-retire.ts` / `dev-restart-retire.ts` | the worker retire (SIGUSR2, before an `x dev` restart's drain) † |
|
|
130
|
+
| `role-start*.ts` / `role-realtime.ts` | `--role` selection, start/stop per role, device mounts † |
|
|
120
131
|
| `role-wake.ts` | the worker's LISTEN session (`@ultimat3/jobs`' `startQueueWake`) — worker role only, only over a client that `canListen` — and `queue_wake_live` |
|
|
121
132
|
| `role-sync.ts` / `role-replicator.ts` / `runtime-live-feed.ts` | the sync node, the change feed |
|
|
122
|
-
| `runtime-render
|
|
123
|
-
| `client-{errors,vitals}-*.ts` | `clientErrors` (and `.vitals`): the script on `app/` (vitals: listed) documents, its `POST` route, mounted by BOTH boots
|
|
124
|
-
| `retained-assets.ts` / `-layout.ts` / `-sweep.ts` / `-read.ts` / `-boot.ts` | `assets.retain`: the web boot publishes this build's hashed files before `/readyz
|
|
125
|
-
| `runtime-overrides.ts`
|
|
133
|
+
| `runtime-render*.ts` / `runtime-{isr-outcome,assets,storage,hooks}.ts` / `route-islands.ts` / `api-routes.ts` | the HTTP surface both boots mount † |
|
|
134
|
+
| `client-{errors,vitals}-*.ts` | `clientErrors` (and `.vitals`): the script on `app/` (vitals: listed) documents, its `POST` route, mounted by BOTH boots ‡ |
|
|
135
|
+
| `retained-assets.ts` / `-layout.ts` / `-sweep.ts` / `-read.ts` / `-boot.ts` | `assets.retain`: the web boot publishes this build's hashed files before `/readyz` † |
|
|
136
|
+
| `runtime-overrides.ts` / `runtime-ports.ts` / `runtime-port-bindings.ts` | `runtime.ts`: a field per `ADAPTER_PORTS` row, installed by ONE loop or read where used; unbound row = build error. Plus `routes`. `docs/history/cli-adapter-ports.md` |
|
|
126
137
|
| `plain-routes.ts` | the plain routes both boots mount and `x routes` lists: `runtime.routes`, then every declared `webhookReceiver()`'s, each once |
|
|
127
138
|
| `app-openapi.ts` | `openapi.json` (complete when `defineApi({ openapi })` is declared) and each bearer mount's own document; staleness for all of them |
|
|
128
139
|
| `script-csp.ts` / `style-csp.ts` / `style-bundle.ts` / `page-sync.ts` / `worker-bundle.ts` | CSP hashes, the CSS file, the page's sync target and worker |
|
|
129
140
|
| `page-navigation.ts` | the client router for `navigation.client` surfaces — built, routed and named ONCE for `x dev`, the container and the static export; none opted in builds nothing |
|
|
130
|
-
| `page-speculation.ts` | Speculation Rules for documents WITHOUT the router (`navigation.speculation`): an allow-list of pure-read pages
|
|
131
|
-
| `static-document.ts` | a served `static` page: `304` on
|
|
132
|
-
| `island-bundle
|
|
141
|
+
| `page-speculation.ts` | Speculation Rules for documents WITHOUT the router (`navigation.speculation`): an allow-list of pure-read pages ‡ |
|
|
142
|
+
| `static-document.ts` | a served `static` page: `304` on `If-None-Match`; container keeps the document (never `x dev`) † |
|
|
143
|
+
| `island-{bundle,store,sources,runtime}.ts` / `island-realtime*.ts` / `solid-loader.ts` | islands: one `Bun.build` each, source-addressed † |
|
|
133
144
|
| `local-cli.ts` / `local-cli-handoff.ts` | a global `x` hands over to the app's own CLI (`local-cli.ts` decides whether; `x upgrade` alone stays when the app's is strictly older — `upgrade-handover.test.ts`) |
|
|
134
|
-
| `serve-prebuilt.ts` / `serve-prebuilt-paths.ts` | the image's prebuilt store
|
|
145
|
+
| `serve-prebuilt.ts` / `serve-prebuilt-paths.ts` | the image's prebuilt store; a boot that built anything logs `X_IMAGE_NOT_PREBUILT` † |
|
|
135
146
|
| `dev-*.ts` | `x dev` only: dashboard sources, traces, the N+1 ledger, watcher, reload, lock, port |
|
|
136
|
-
| `cmd-stop.ts` / `cmd-stop-spec.ts` | `x stop`: the lock's pid only
|
|
137
|
-
| `dev-dashboard-guard.ts` / `loopback-host.ts` | `/_x`
|
|
138
|
-
| `doctor-pooler.ts` / `runtime-statement-bound.ts` | the
|
|
147
|
+
| `cmd-stop.ts` / `cmd-stop-spec.ts` | `x stop`: the lock's pid only, SIGTERM, wait; `X_DEV_STOP_TIMEOUT` † |
|
|
148
|
+
| `dev-dashboard-guard.ts` / `loopback-host.ts` | `/_x` loopback `Host` only (`X_DEV_HOST_REFUSED`, 421) † |
|
|
149
|
+
| `doctor-pooler.ts` / `runtime-statement-bound.ts` | the statement bound and a pooler's refusal, one finding, one boot line † |
|
|
139
150
|
|
|
140
151
|
### Build and data
|
|
141
152
|
|
|
142
153
|
| File | Job |
|
|
143
154
|
|---|---|
|
|
144
|
-
| `cmd-build.ts` / `image-prepare.ts` | `x build`: static gate first; `
|
|
145
|
-
| `prerender.ts` / `measure-scope.ts` / `static-report.ts` / `static-*.ts` | the static export;
|
|
155
|
+
| `cmd-build.ts` / `image-prepare.ts` | `x build`: static gate first; `prebuilt` is the Dockerfile's own `RUN` † |
|
|
156
|
+
| `prerender.ts` / `measure-scope.ts` / `static-report.ts` / `static-*.ts` | the static export; weigh-only renders as `measurementActor()` † |
|
|
146
157
|
| `sw-artifacts.ts` / `pwa-artifacts.ts` / `favicon.ts` | the service worker, the web manifest, `/favicon.ico` |
|
|
147
|
-
| `cmd-db.ts` / `migrations.ts` / `db
|
|
148
|
-
| `db-diagnostics.ts` | `x db diagnostics`: `startDb
|
|
149
|
-
| `db-schema-dump.ts` / `db-schema-refresh.ts` / `db-replay-engine.ts` / `migration-extensions.ts` / `db-object-drift.ts` | the schema dump
|
|
158
|
+
| `cmd-db.ts` / `migrations.ts` / `db-*.ts` (generate, branch, seed, backfill, subscribes, accept-created) | one migration engine for `x db` and `ROLE=migrate` † |
|
|
159
|
+
| `db-diagnostics.ts` | `x db diagnostics`: `startDb`, never `startQueue`; exit 0 whatever it says † |
|
|
160
|
+
| `db-schema-dump.ts` / `db-schema-refresh.ts` / `db-replay-engine.ts` / `migration-extensions.ts` / `db-object-drift.ts` | the schema dump, replayed on a scratch database † |
|
|
150
161
|
|
|
151
162
|
### Introspection and tools
|
|
152
163
|
|
|
@@ -154,14 +165,14 @@ Commands: `bun test packages/cli` (from the repo root: the preload),
|
|
|
154
165
|
|---|---|
|
|
155
166
|
| `cmd-registries.ts` / `cmd-jobs.ts` / `cmd-tasks.ts` / `cmd-policy.ts` / `cmd-i18n.ts` | project a framework registry; each pairs CLI wiring with a facts module |
|
|
156
167
|
| `cmd-auth.ts` / `cmd-auth-spec.ts` / `doctor-auth.ts` | `x auth seal-mfa`: seals plaintext `x_users.mfa_secret` through auth's `sealMfaSecrets` |
|
|
157
|
-
| `cmd-mcp.ts` / `mcp-host.ts` / `mcp-errors.ts` / `mcp-db-target.ts` | `x mcp serve`: 19 tools, two transports
|
|
168
|
+
| `cmd-mcp.ts` / `mcp-host.ts` / `mcp-errors.ts` / `mcp-db-target.ts` | `x mcp serve`: 19 tools, two transports † |
|
|
158
169
|
| `cmd-shot*.ts` / `cdp-shot-*.ts` / `browser-launcher*.ts` / `island-*` | `x shot` over raw CDP; `verdict.json` names its own blind spots. Not a gate step |
|
|
159
|
-
| `cmd-pr.ts` / `cmd-ci.ts` / `ci-runs.ts` / `ci-tested.ts` | GitHub through `gh`, parsed
|
|
170
|
+
| `cmd-pr.ts` / `cmd-ci.ts` / `ci-runs.ts` / `ci-tested.ts` | GitHub through `gh`, schema-parsed; not gate steps † |
|
|
160
171
|
| `error-catalog.ts` | imports every `@ultimat3/*` package so `x errors` answers for any code |
|
|
161
|
-
| `cmd-docs.ts` / `docs-sources.ts` / `docs-section.ts` | `x docs`: the app's
|
|
162
|
-
| `cmd-env-init.ts` / `env-production.ts` / `cmd-deploy-preflight.ts` |
|
|
163
|
-
| `cmd-upgrade.ts` / `upgrade-*.ts` | `x upgrade`: one major per run;
|
|
164
|
-
| `cmd-deploy-verify.ts` / `deploy-verify-*.ts` | `x deploy verify`: the wait
|
|
172
|
+
| `cmd-docs.ts` / `docs-sources.ts` / `docs-section.ts` | `x docs`: the app's and the CLI's `@ultimat3` docs; `Page#anchor` prints a section † |
|
|
173
|
+
| `cmd-env-init.ts` / `env-production.ts` / `cmd-deploy-preflight.ts` | the one writer of `.env.production`; compose pre-flight (`X_DEPLOY_ENV_MISSING`) † |
|
|
174
|
+
| `cmd-upgrade.ts` / `upgrade-*.ts` | `x upgrade`: one major per run; no `requiresApp` † |
|
|
175
|
+
| `cmd-deploy-verify.ts` / `deploy-verify-*.ts` | `x deploy verify`: the wait, the pure verdict, lazy real sources † |
|
|
165
176
|
|
|
166
177
|
## Adding a command
|
|
167
178
|
|
package/README.md
CHANGED
|
@@ -192,6 +192,8 @@ that name where there is one (`x new` writes all twenty), the blank template oth
|
|
|
192
192
|
| `app-load.ts` | import an app's modules so the framework registries hold it |
|
|
193
193
|
| `app-mcp.ts` | the app's own MCP endpoint: `apps/<app>/mcp.ts` exports `mcp`, and both boots mount `POST` at each endpoint's own `defineAppMcp({ path })` through this one call |
|
|
194
194
|
| `app-runtime.ts` | the app's `RuntimeOverrides`: `apps/<app>/runtime.ts` exports `runtime`, read by `x dev` and by `runRole` when its caller passed none |
|
|
195
|
+
| `runtime-overrides.ts` / `runtime-ports.ts` / `runtime-port-bindings.ts` | one `RuntimeOverrides` field per `ADAPTER_PORTS` row (`PortValues`), and where the boot honours each: installed by ONE loop over the table (`boot` → `queue` → `services` phases), or read as a value where used — every row, as of 31.0 (a future row may stand `pending`, naming the package that owes an installer). A row core adds without a binding is a build error (`PortBindings` is a `Record` over `AdapterPortName`). `import type { RuntimeOverrides } from '@ultimat3/cli/serve'` types an app's `runtime.ts` |
|
|
196
|
+
| `verify-factories.ts` | the `unit` step's factory lint: `<app>/packages/db/factories.ts` exporting `factories` is linted in a child from the app root (`X_TEST_FACTORY_INVALID`, naming the factory and trait); no file, no lint |
|
|
195
197
|
| `local-cli.ts` | which `x` runs: a global CLI inside an app hands over to the app's own, because a second module instance is an empty registry |
|
|
196
198
|
| `measurement-actor.ts` | the actor a weigh-and-discard render runs as — every permission, never served |
|
|
197
199
|
| `runtime-live-feed.ts` | what feeds the sync node this process booted: the in-process row observer under the embedded database, the WAL decoder with a real one, nothing without the role — `live=` on the ready line |
|
|
@@ -237,7 +239,8 @@ apps/web/{site,app}/<path>/<name>.island.tsx # x g island <name> --at <dir>
|
|
|
237
239
|
apps/admin/app/admin/pages/<name>.tsx # x g admin:page <name> --permission p
|
|
238
240
|
guards/<name>.ts # x g guard <name>
|
|
239
241
|
apps/web/app/auth/{sign-in,actions,…} # x g sign-in --password | --oidc <provider>
|
|
240
|
-
apps/web/runtime.ts # …and the boot guard it calls
|
|
242
|
+
apps/web/runtime.ts # …and the boot guard it calls (x new writes the
|
|
243
|
+
# port-commented one; replaced only while untouched)
|
|
241
244
|
docker/helm/templates/{servicemonitor,alert-rules}.yaml # x g chart-alerts [--print]
|
|
242
245
|
```
|
|
243
246
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ultimat3/cli",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "31.0.0",
|
|
4
4
|
"description": "The `x` binary: new, dev, build, verify, generate, db, mcp, doctor, deploy",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ultimate",
|
|
@@ -52,34 +52,35 @@
|
|
|
52
52
|
"dev": "bun run src/bin.ts dev"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@babel/core": "^8.0.
|
|
56
|
-
"@ultimat3/action": "
|
|
57
|
-
"@ultimat3/admin": "
|
|
58
|
-
"@ultimat3/ai": "
|
|
59
|
-
"@ultimat3/auth": "
|
|
60
|
-
"@ultimat3/cache": "
|
|
61
|
-
"@ultimat3/core": "
|
|
62
|
-
"@ultimat3/db": "
|
|
63
|
-
"@ultimat3/entity": "
|
|
64
|
-
"@ultimat3/flags": "
|
|
65
|
-
"@ultimat3/http": "
|
|
66
|
-
"@ultimat3/i18n": "
|
|
67
|
-
"@ultimat3/jobs": "
|
|
68
|
-
"@ultimat3/mail": "
|
|
69
|
-
"@ultimat3/manifest": "
|
|
70
|
-
"@ultimat3/mcp": "
|
|
71
|
-
"@ultimat3/money": "
|
|
72
|
-
"@ultimat3/notify": "
|
|
73
|
-
"@ultimat3/policy": "
|
|
74
|
-
"@ultimat3/pwa": "
|
|
75
|
-
"@ultimat3/query": "
|
|
76
|
-
"@ultimat3/realtime": "
|
|
77
|
-
"@ultimat3/render": "
|
|
78
|
-
"@ultimat3/schema": "
|
|
79
|
-
"@ultimat3/
|
|
80
|
-
"@ultimat3/
|
|
81
|
-
"@ultimat3/
|
|
82
|
-
"@ultimat3/
|
|
55
|
+
"@babel/core": "^8.0.9",
|
|
56
|
+
"@ultimat3/action": "31.0.0",
|
|
57
|
+
"@ultimat3/admin": "31.0.0",
|
|
58
|
+
"@ultimat3/ai": "31.0.0",
|
|
59
|
+
"@ultimat3/auth": "31.0.0",
|
|
60
|
+
"@ultimat3/cache": "31.0.0",
|
|
61
|
+
"@ultimat3/core": "31.0.0",
|
|
62
|
+
"@ultimat3/db": "31.0.0",
|
|
63
|
+
"@ultimat3/entity": "31.0.0",
|
|
64
|
+
"@ultimat3/flags": "31.0.0",
|
|
65
|
+
"@ultimat3/http": "31.0.0",
|
|
66
|
+
"@ultimat3/i18n": "31.0.0",
|
|
67
|
+
"@ultimat3/jobs": "31.0.0",
|
|
68
|
+
"@ultimat3/mail": "31.0.0",
|
|
69
|
+
"@ultimat3/manifest": "31.0.0",
|
|
70
|
+
"@ultimat3/mcp": "31.0.0",
|
|
71
|
+
"@ultimat3/money": "31.0.0",
|
|
72
|
+
"@ultimat3/notify": "31.0.0",
|
|
73
|
+
"@ultimat3/policy": "31.0.0",
|
|
74
|
+
"@ultimat3/pwa": "31.0.0",
|
|
75
|
+
"@ultimat3/query": "31.0.0",
|
|
76
|
+
"@ultimat3/realtime": "31.0.0",
|
|
77
|
+
"@ultimat3/render": "31.0.0",
|
|
78
|
+
"@ultimat3/schema": "31.0.0",
|
|
79
|
+
"@ultimat3/scraping": "31.0.0",
|
|
80
|
+
"@ultimat3/seo": "31.0.0",
|
|
81
|
+
"@ultimat3/storage": "31.0.0",
|
|
82
|
+
"@ultimat3/testing": "31.0.0",
|
|
83
|
+
"@ultimat3/time": "31.0.0",
|
|
83
84
|
"babel-preset-solid": "^1.9.16"
|
|
84
85
|
}
|
|
85
86
|
}
|
|
@@ -41,7 +41,7 @@ export const adminResourceUnwiredFinding = (
|
|
|
41
41
|
): Finding => ({
|
|
42
42
|
code: 'X_ADMIN_RESOURCE_UNWIRED',
|
|
43
43
|
cause: `${ADMIN_FILE} ${reason}, so the override ${entry.binding} is read by nothing and /admin/${entry.table} keeps its derived defaults`,
|
|
44
|
-
fix: `
|
|
44
|
+
fix: `import { ${entry.binding} } from '${entry.specifier}'; # at the top of ${ADMIN_FILE}, then resources: { ${entry.table}: ${entry.binding} } in its defineAdmin() call`,
|
|
45
45
|
docs: ERROR_DOCS_URL,
|
|
46
46
|
at: ADMIN_FILE,
|
|
47
47
|
});
|
package/src/affected.ts
CHANGED
|
@@ -155,7 +155,11 @@ export function planAffected(
|
|
|
155
155
|
* narrows nothing — so a fix line that dropped it would reproduce its own failure, verbatim.
|
|
156
156
|
*/
|
|
157
157
|
const invocationOf = (command: string): string =>
|
|
158
|
-
command === 'affected'
|
|
158
|
+
command === 'affected'
|
|
159
|
+
? 'x affected'
|
|
160
|
+
: command === 'verify'
|
|
161
|
+
? 'x verify --changed'
|
|
162
|
+
: `x ${command} --affected`;
|
|
159
163
|
|
|
160
164
|
export interface AffectedSelection {
|
|
161
165
|
readonly base: string;
|
package/src/app-boundaries.ts
CHANGED
|
@@ -18,9 +18,10 @@
|
|
|
18
18
|
import { join as joinPath } from 'node:path';
|
|
19
19
|
// The POSIX variants resolve specifiers against import-graph keys, which are POSIX on every host.
|
|
20
20
|
import { dirname, join, normalize, relative } from 'node:path/posix';
|
|
21
|
-
import { ERROR_DOCS_URL } from '@ultimat3/core';
|
|
22
|
-
import type { BoundaryRule, ImportGraph } from '@ultimat3/render';
|
|
23
|
-
import { checkSurfaceBoundary, importGraph,
|
|
21
|
+
import { ADAPTER_PORTS, ERROR_DOCS_URL, SURFACES } from '@ultimat3/core';
|
|
22
|
+
import type { BoundaryRule, ImportGraph, ImportRef } from '@ultimat3/render';
|
|
23
|
+
import { checkSurfaceBoundary, importGraph, surfaceOf } from '@ultimat3/render';
|
|
24
|
+
import { loaderImportFindings } from './app-loader-imports';
|
|
24
25
|
import { commentSafe } from './comment-safe';
|
|
25
26
|
import { scanRuntimeImports, stripShebang } from './import-scan';
|
|
26
27
|
import type { Finding } from './output';
|
|
@@ -35,6 +36,8 @@ export const BOUNDARY_CODES = [
|
|
|
35
36
|
'X_BOUNDARY_ROUTE_TO_DB',
|
|
36
37
|
'X_BOUNDARY_SERVICE_TO_HTTP',
|
|
37
38
|
'X_BOUNDARY_SURFACE_IMPORT',
|
|
39
|
+
'X_BOUNDARY_ADAPTER_IMPORT',
|
|
40
|
+
'X_BOUNDARY_LOADER_IMPORT',
|
|
38
41
|
// `package-boundaries.ts`'s: it reads `packages/`, which this module's surface graph never holds.
|
|
39
42
|
'X_BOUNDARY_PACKAGE_TO_APP',
|
|
40
43
|
] as const;
|
|
@@ -103,7 +106,7 @@ export function resolveSpecifier(
|
|
|
103
106
|
specifier: string,
|
|
104
107
|
keys: ReadonlySet<string>,
|
|
105
108
|
): string {
|
|
106
|
-
if (!specifier.startsWith('.')) return specifier;
|
|
109
|
+
if (!specifier.startsWith('.')) return workspaceKey(specifier, keys) ?? specifier;
|
|
107
110
|
const base = normalize(join(dirname(fromFile), specifier));
|
|
108
111
|
for (const suffix of CANDIDATE_SUFFIXES) {
|
|
109
112
|
if (keys.has(`${base}${suffix}`)) return `${base}${suffix}`;
|
|
@@ -111,6 +114,21 @@ export function resolveSpecifier(
|
|
|
111
114
|
return base;
|
|
112
115
|
}
|
|
113
116
|
|
|
117
|
+
/**
|
|
118
|
+
* `@<scope>/<app>/<rest>` → `apps/<app>/<rest>` when that lands on an app source: the spelling one
|
|
119
|
+
* app workspace reaches another by (`x new`'s root alias `@<app>/*` → `packages/*\/src`, then
|
|
120
|
+
* `apps/*`). Left unresolved, `apps/api/site/` importing `@acme/web/app/…` was an edge to nowhere
|
|
121
|
+
* and `X_BOUNDARY_SITE_TO_APP` never fired. Matched against the graph's own keys — a framework or
|
|
122
|
+
* package specifier lands on none — so a workspace whose package name differs from its directory
|
|
123
|
+
* is the one spelling this cannot see.
|
|
124
|
+
*/
|
|
125
|
+
const workspaceKey = (specifier: string, keys: ReadonlySet<string>): string | undefined => {
|
|
126
|
+
const [, app, rest] = /^@[^/]+\/([^/]+)\/(.+)$/.exec(specifier) ?? [];
|
|
127
|
+
if (app === undefined || rest === undefined) return undefined;
|
|
128
|
+
const base = `apps/${app}/${rest}`;
|
|
129
|
+
return CANDIDATE_SUFFIXES.map((suffix) => `${base}${suffix}`).find((key) => keys.has(key));
|
|
130
|
+
};
|
|
131
|
+
|
|
114
132
|
/**
|
|
115
133
|
* The specifier `fromFile` must write to reach `target` — `resolveSpecifier` run backwards, and
|
|
116
134
|
* what every import of a file has to become once that file moves. Extensionless, because that is
|
|
@@ -138,9 +156,36 @@ function scan(files: readonly SourceFile[]): readonly ScannedFile[] {
|
|
|
138
156
|
}));
|
|
139
157
|
}
|
|
140
158
|
|
|
159
|
+
/** `apps/<ws>/…` → `<ws>`, or `undefined` outside an app workspace. */
|
|
160
|
+
const workspaceOf = (path: string): string | undefined => /^apps\/([^/]+)\//.exec(path)?.[1];
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* An `app/` module reaching a SIBLING app's `api/` registry. `app/ → api/` is types-only inside
|
|
164
|
+
* one app because that app's `api/index.ts` imports its own `app/` slices — a value edge back is a
|
|
165
|
+
* cycle. Across workspaces there is none: `apps/admin` projecting `apps/web`'s actions through its
|
|
166
|
+
* `api` is the documented pattern. Such an edge enters the graph as declaration-only, which the
|
|
167
|
+
* table admits for `app` and still refuses for `site` (`SURFACE_SPECS`).
|
|
168
|
+
*/
|
|
169
|
+
const isSiblingRegistry = (from: string, to: string): boolean => {
|
|
170
|
+
const own = workspaceOf(from);
|
|
171
|
+
const other = workspaceOf(to);
|
|
172
|
+
return (
|
|
173
|
+
own !== undefined &&
|
|
174
|
+
other !== undefined &&
|
|
175
|
+
own !== other &&
|
|
176
|
+
surfaceOf(from) === 'app' &&
|
|
177
|
+
surfaceOf(to) === 'api'
|
|
178
|
+
);
|
|
179
|
+
};
|
|
180
|
+
|
|
141
181
|
function graphOf(scanned: readonly ScannedFile[]): ImportGraph {
|
|
142
|
-
const record: Record<string, readonly
|
|
143
|
-
for (const file of scanned)
|
|
182
|
+
const record: Record<string, readonly ImportRef[]> = {};
|
|
183
|
+
for (const file of scanned) {
|
|
184
|
+
record[file.path] = file.imports.map((to) => ({
|
|
185
|
+
file: to,
|
|
186
|
+
type: isSiblingRegistry(file.path, to),
|
|
187
|
+
}));
|
|
188
|
+
}
|
|
144
189
|
return importGraph(record);
|
|
145
190
|
}
|
|
146
191
|
|
|
@@ -220,6 +265,21 @@ const routeToDbFix = (path: string, specifier: string): string => {
|
|
|
220
265
|
return `x g query ${query} --feature ${quoteArg(slice)} # ${then}`;
|
|
221
266
|
};
|
|
222
267
|
|
|
268
|
+
/** A package's `./adapter` subpath: the installers `runtime.ts` and the boot own, never an app module. */
|
|
269
|
+
const ADAPTER_SUBPATH = /^@ultimat3\/[a-z-]+\/adapter$/;
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* The `runtime.ts` field an import of `specifier` stands in for: the port named after its package
|
|
273
|
+
* (`@ultimat3/jobs/adapter` → `jobs`), else that package's first row. A real field, never a
|
|
274
|
+
* placeholder — the fix's runnable half is pasted as it stands.
|
|
275
|
+
*/
|
|
276
|
+
const portOf = (specifier: string): string => {
|
|
277
|
+
const pkg = specifier.slice(0, -'/adapter'.length);
|
|
278
|
+
const rows = ADAPTER_PORTS.filter((row) => row.pkg === pkg);
|
|
279
|
+
const named = rows.find((row) => `@ultimat3/${row.port}` === pkg);
|
|
280
|
+
return (named ?? rows[0])?.port ?? 'jobs';
|
|
281
|
+
};
|
|
282
|
+
|
|
223
283
|
/**
|
|
224
284
|
* Both fixes are one runnable line, with the rest of the instruction behind a `#` — a fix a
|
|
225
285
|
* caller has to edit before it runs is prose, and prose is what "errors are instructions" bans.
|
|
@@ -228,6 +288,16 @@ function layerFindings(scanned: readonly ScannedFile[]): readonly Finding[] {
|
|
|
228
288
|
const findings: Finding[] = [];
|
|
229
289
|
for (const file of scanned) {
|
|
230
290
|
for (const specifier of file.imports) {
|
|
291
|
+
// `file.imports` is runtime imports only: `import type { Gateway }` from an adapter is fine.
|
|
292
|
+
if (ADAPTER_SUBPATH.test(specifier)) {
|
|
293
|
+
findings.push({
|
|
294
|
+
code: 'X_BOUNDARY_ADAPTER_IMPORT',
|
|
295
|
+
cause: `an app module imports "${specifier}" at runtime — its installers are the boot's, and one called from here races it (X_RUNTIME_DRIVER_SPLIT)`,
|
|
296
|
+
fix: `export const runtime = { ${quoteArg(portOf(specifier))}: yourDriver } satisfies RuntimeOverrides; # in apps/web/runtime.ts, then delete the import from ${commentSafe(file.path)}`,
|
|
297
|
+
docs: ERROR_DOCS_URL,
|
|
298
|
+
at: file.path,
|
|
299
|
+
});
|
|
300
|
+
}
|
|
231
301
|
if (isRoute(file.path) && isDbSpecifier(specifier)) {
|
|
232
302
|
findings.push({
|
|
233
303
|
code: 'X_BOUNDARY_ROUTE_TO_DB',
|
|
@@ -257,7 +327,11 @@ function layerFindings(scanned: readonly ScannedFile[]): readonly Finding[] {
|
|
|
257
327
|
*/
|
|
258
328
|
export function checkImportRules(files: readonly SourceFile[]): readonly Finding[] {
|
|
259
329
|
const scanned = scan(files);
|
|
260
|
-
return [
|
|
330
|
+
return [
|
|
331
|
+
...surfaceFindings(graphOf(scanned)),
|
|
332
|
+
...layerFindings(scanned),
|
|
333
|
+
...loaderImportFindings(files),
|
|
334
|
+
];
|
|
261
335
|
}
|
|
262
336
|
|
|
263
337
|
const APP_GLOBS = ['apps/*/{site,app,api,shared}/**/*.{ts,tsx}'];
|
|
@@ -267,12 +341,17 @@ const APP_GLOBS = ['apps/*/{site,app,api,shared}/**/*.{ts,tsx}'];
|
|
|
267
341
|
* only I/O in this module, and the one definition of "which files are the app's sources" —
|
|
268
342
|
* `appBoundaryFindings` reads through this, and so does `x fix boundary`, never a second glob.
|
|
269
343
|
*/
|
|
270
|
-
export async function readAppSources(
|
|
344
|
+
export async function readAppSources(
|
|
345
|
+
root: string,
|
|
346
|
+
/** `tests`: the same surfaces' `.test.` files instead — read by the loader rule alone. */
|
|
347
|
+
which: 'sources' | 'tests' = 'sources',
|
|
348
|
+
): Promise<readonly SourceFile[]> {
|
|
271
349
|
const files: SourceFile[] = [];
|
|
272
350
|
for (const pattern of APP_GLOBS) {
|
|
273
351
|
const glob = new Bun.Glob(pattern);
|
|
274
352
|
for await (const path of glob.scan({ cwd: root, absolute: false })) {
|
|
275
|
-
if (hasPathSegment(path, 'node_modules')
|
|
353
|
+
if (hasPathSegment(path, 'node_modules')) continue;
|
|
354
|
+
if (path.includes('.test.') !== (which === 'tests')) continue;
|
|
276
355
|
const posix = toPosix(path);
|
|
277
356
|
files.push({ path: posix, source: await Bun.file(joinPath(root, posix)).text() });
|
|
278
357
|
}
|