@ultimat3/cli 31.31.0 → 31.33.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.
Files changed (170) hide show
  1. package/package.json +29 -29
  2. package/src/admin-registration.ts +6 -5
  3. package/src/affected.ts +3 -2
  4. package/src/api-registration.ts +7 -5
  5. package/src/app-agents-md.ts +1 -1
  6. package/src/app-boundaries.ts +12 -8
  7. package/src/app-layout.ts +6 -5
  8. package/src/app-load.ts +1 -1
  9. package/src/app-manifest.ts +1 -1
  10. package/src/app-mcp.ts +11 -9
  11. package/src/app-openapi.ts +7 -5
  12. package/src/app-reload-graph.ts +9 -7
  13. package/src/app-runtime.ts +9 -6
  14. package/src/async-pages.ts +6 -5
  15. package/src/browser-launcher.ts +9 -5
  16. package/src/browser-transport.ts +8 -5
  17. package/src/budgets.ts +4 -3
  18. package/src/cdp-shot-driver.ts +21 -5
  19. package/src/cdp-shot-errors.ts +7 -5
  20. package/src/cdp-shot-page.ts +6 -5
  21. package/src/cdp-shot-watch.ts +7 -5
  22. package/src/ci-log.ts +6 -5
  23. package/src/ci-runs.ts +7 -3
  24. package/src/cmd-auth.ts +5 -4
  25. package/src/cmd-build.ts +13 -7
  26. package/src/cmd-ci.ts +9 -6
  27. package/src/cmd-clean.ts +9 -6
  28. package/src/cmd-db-backfill.ts +8 -5
  29. package/src/cmd-db-branch.ts +3 -2
  30. package/src/cmd-db.ts +2 -2
  31. package/src/cmd-deploy-compose.ts +8 -5
  32. package/src/cmd-deploy.ts +2 -1
  33. package/src/cmd-dev.ts +1 -0
  34. package/src/cmd-env.ts +1 -1
  35. package/src/cmd-errors.ts +2 -3
  36. package/src/cmd-generate.ts +2 -0
  37. package/src/cmd-i18n.ts +8 -6
  38. package/src/cmd-jobs.ts +3 -2
  39. package/src/cmd-manifest.ts +1 -0
  40. package/src/cmd-new.ts +2 -0
  41. package/src/cmd-planned.ts +2 -1
  42. package/src/cmd-pr.ts +7 -6
  43. package/src/cmd-registries.ts +5 -4
  44. package/src/cmd-repro.ts +8 -2
  45. package/src/cmd-secrets.ts +1 -1
  46. package/src/cmd-shot-island.ts +4 -2
  47. package/src/cmd-shot.ts +1 -0
  48. package/src/cmd-tasks.ts +7 -5
  49. package/src/cmd-test.ts +13 -8
  50. package/src/db-backfill.ts +4 -3
  51. package/src/db-branch.ts +2 -2
  52. package/src/db-generate.ts +1 -1
  53. package/src/db-schema-refresh.ts +5 -4
  54. package/src/db-seed.ts +3 -2
  55. package/src/dev-child-watch.ts +7 -6
  56. package/src/dev-environment.ts +6 -5
  57. package/src/dev-lock.ts +5 -2
  58. package/src/dev-n-plus-one.ts +7 -5
  59. package/src/dev-reload.ts +7 -5
  60. package/src/dev-restart-retire.ts +7 -5
  61. package/src/dev-supervisor.ts +9 -6
  62. package/src/dev-watch-tree.ts +9 -7
  63. package/src/dev-watch.ts +7 -5
  64. package/src/document-styles.ts +7 -5
  65. package/src/drift.ts +9 -5
  66. package/src/duplicate-packages.ts +12 -6
  67. package/src/error-contract.ts +4 -2
  68. package/src/error-fixes.ts +7 -6
  69. package/src/error-unthrown.ts +7 -5
  70. package/src/errors.ts +11 -10
  71. package/src/fix-imports.ts +1 -1
  72. package/src/flag-number.ts +2 -1
  73. package/src/flag-reads.ts +1 -1
  74. package/src/framework-schema-apply.ts +7 -5
  75. package/src/framework-scope.ts +1 -1
  76. package/src/generate-files.ts +1 -1
  77. package/src/generate-follow-ups.ts +8 -5
  78. package/src/generate-kinds.ts +2 -2
  79. package/src/generate-shadow.ts +6 -4
  80. package/src/generate-sibling.ts +6 -4
  81. package/src/gh-target.ts +3 -2
  82. package/src/guards.ts +4 -3
  83. package/src/handle-registration.ts +4 -3
  84. package/src/i18n-audit.ts +4 -4
  85. package/src/i18n-registration.ts +7 -4
  86. package/src/import-closure.ts +7 -6
  87. package/src/island-bundle.ts +7 -6
  88. package/src/island-cache-inputs.ts +2 -1
  89. package/src/island-capture.ts +5 -4
  90. package/src/island-realtime-state.ts +6 -5
  91. package/src/island-realtime.ts +8 -6
  92. package/src/island-shot-errors.ts +2 -1
  93. package/src/island-shot.ts +6 -5
  94. package/src/load-findings.ts +8 -5
  95. package/src/local-cli.ts +8 -6
  96. package/src/mcp-db-target.ts +2 -2
  97. package/src/mcp-errors.ts +3 -1
  98. package/src/mcp-ui-diff.ts +8 -5
  99. package/src/mcp-ui-inspect.ts +8 -6
  100. package/src/mcp-ui-interact.ts +9 -6
  101. package/src/mcp-ui.ts +11 -9
  102. package/src/measure-database.ts +8 -6
  103. package/src/measure-paths.ts +7 -5
  104. package/src/measure-scope.ts +10 -8
  105. package/src/migrations.ts +2 -0
  106. package/src/page-navigation.ts +9 -7
  107. package/src/page-speculation.ts +8 -6
  108. package/src/parse.ts +3 -3
  109. package/src/path-segments.ts +2 -1
  110. package/src/pr-threads.ts +2 -1
  111. package/src/prerender.ts +4 -4
  112. package/src/role-start.ts +3 -2
  113. package/src/role-sync.ts +2 -1
  114. package/src/runtime-assets.ts +8 -6
  115. package/src/runtime-bindings.ts +2 -0
  116. package/src/runtime-cache.ts +7 -5
  117. package/src/runtime-live-feed.ts +7 -5
  118. package/src/runtime-overrides.ts +7 -5
  119. package/src/runtime-queue.ts +6 -5
  120. package/src/schema-drift.ts +11 -14
  121. package/src/script-csp.ts +4 -2
  122. package/src/secrets-rotation.ts +7 -5
  123. package/src/serve-boot.ts +8 -6
  124. package/src/serve.ts +8 -5
  125. package/src/server-barrels.ts +7 -5
  126. package/src/shell-quote.ts +8 -1
  127. package/src/shot-locale.ts +2 -1
  128. package/src/shot-route.ts +2 -1
  129. package/src/shot-theme.ts +8 -6
  130. package/src/site-config.ts +2 -1
  131. package/src/site-llms-pages.ts +8 -2
  132. package/src/source-list-edit.ts +8 -6
  133. package/src/static-cards.ts +2 -2
  134. package/src/static-report.ts +22 -18
  135. package/src/sync-authenticator.ts +6 -5
  136. package/src/templates/admin-page.ts +8 -5
  137. package/src/templates/admin.ts +6 -5
  138. package/src/templates/guard-animated-layout-property.ts +7 -5
  139. package/src/templates/guard-focus-visible.ts +7 -5
  140. package/src/templates/guard-image-dimensions.ts +8 -5
  141. package/src/templates/guard-island-without-states.ts +5 -3
  142. package/src/templates/guard-semantic-interactive.ts +1 -0
  143. package/src/templates/island.ts +9 -6
  144. package/src/templates/resource-form-island.ts +3 -2
  145. package/src/templates/resource-page.ts +8 -6
  146. package/src/templates/route.ts +1 -0
  147. package/src/templates/scaffold-docs.ts +7 -6
  148. package/src/templates/scaffold-entries.ts +7 -5
  149. package/src/templates/scaffold-errors.ts +8 -6
  150. package/src/templates/scaffold-repo.ts +5 -4
  151. package/src/templates/scaffold-shell.ts +7 -5
  152. package/src/templates/scaffold-site.ts +7 -5
  153. package/src/test-housekeeping.ts +3 -6
  154. package/src/test-select.ts +3 -3
  155. package/src/ts-scan.ts +6 -4
  156. package/src/tsconfig-references.ts +6 -6
  157. package/src/verify-checks.ts +9 -9
  158. package/src/verify-e2e.ts +8 -6
  159. package/src/verify-floor.ts +8 -8
  160. package/src/verify-pace.ts +3 -1
  161. package/src/verify-role-load.ts +8 -5
  162. package/src/verify-services.ts +2 -1
  163. package/src/verify-tests.ts +2 -2
  164. package/src/verify-typecheck.ts +7 -5
  165. package/src/version-loader.ts +1 -1
  166. package/src/worker-bundle.ts +7 -5
  167. package/src/workspace-checks.ts +6 -3
  168. package/src/workspace-external-deps.ts +4 -2
  169. package/src/workspace-graph.ts +4 -3
  170. package/src/write-line.ts +1 -1
@@ -1,8 +1,10 @@
1
- // Which cache tiers this process reads through, and the hop that tells the other replicas what it
2
- // just dropped. The ladder is exactly what `cache.tiers` names: a rung the config lists is built or
3
- // the boot refuses, and a rung it does not list is never built — this file used to register memo
4
- // and lru unconditionally, redis on `REDIS_URL` and cdn on any real purge driver, so the key was
5
- // declared, validated at boot, documented, and read by nothing.
1
+ // Which cache tiers this process reads through, and the hop that tells the other replicas what
2
+ // it just dropped.
3
+ //
4
+ // The ladder is exactly what `cache.tiers` names: a rung the config lists is built or the boot
5
+ // refuses, and a rung it does not list is never built — this file used to register memo and lru
6
+ // unconditionally, redis on `REDIS_URL` and cdn on any real purge driver, so the key was declared,
7
+ // validated at boot, documented, and read by nothing.
6
8
 
7
9
  import type {
8
10
  CacheTier,
@@ -1,8 +1,10 @@
1
- // Where a `sync` node's changes come from when this process boots one. Production decodes the
2
- // write-ahead log (`x dev --role replicator`, `postgresChangeFeed()`, a real `DATABASE_URL`).
3
- // The embedded database has no walsender, and until 2026-09-05 nothing stood in for it: a live
4
- // subscription under `x dev` took its snapshot and then heard nothing, so every `--live` query in
5
- // every scaffolded app was dead in development — which is where an author first tries one.
1
+ // Where a `sync` node's changes come from when this process boots one.
2
+ //
3
+ // Production decodes the write-ahead log (`x dev --role replicator`, `postgresChangeFeed()`, a real
4
+ // `DATABASE_URL`). The embedded database has no walsender, and until 2026-09-05 nothing stood in
5
+ // for it: a live subscription under `x dev` took its snapshot and then heard nothing, so every
6
+ // `--live` query in every scaffolded app was dead in development — which is where an author first
7
+ // tries one.
6
8
  //
7
9
  // The bridge is `@ultimat3/realtime/server`'s `startLiveReplicator`, the same in-process row observer the
8
10
  // framework's own live tests run on: a repository write in THIS process becomes a `ChangeEvent`
@@ -1,8 +1,10 @@
1
- // The one place a host hands the framework a driver. `ServeOptions` had `{ root, env, role, port,
2
- // metricsPort }` and nothing else, so the ONLY way to install a driver was to call an ambient
3
- // setter from an app module — which `loadApp` imports *after* `startServices` has already captured
4
- // its own. This type is the seam that removes the need to, and every field is read exactly once,
5
- // as the first arm of `overrides?.x ?? <the env-selected default>`.
1
+ // The one place a host hands the framework a driver: `RuntimeOverrides`.
2
+ //
3
+ // `ServeOptions` had `{ root, env, role, port, metricsPort }` and nothing else, so the ONLY way to
4
+ // install a driver was to call an ambient setter from an app module — which `loadApp` imports
5
+ // *after* `startServices` has already captured its own. This type is the seam that removes the need
6
+ // to, and every field is read exactly once, as the first arm of
7
+ // `overrides?.x ?? <the env-selected default>`.
6
8
 
7
9
  import type { IdempotencyStore, MeterStore } from '@ultimat3/action/adapter';
8
10
  import type { Embedder, Gateway, SemanticCacheFactory } from '@ultimat3/ai/adapter';
@@ -1,8 +1,9 @@
1
- // The database and the job queue, started together and released together. Split from
2
- // `runtime-services.ts` because `x jobs` needs exactly this pair and nothing else — and because a
3
- // process that installs ambient accessors (`db()`, `jobDriver()`, the jobs facade, the event bus)
4
- // must have one place that takes them all back, or the next command in the same process inherits
5
- // a driver over a closed socket.
1
+ // The database and the job queue, started together and released together.
2
+ //
3
+ // Split from `runtime-services.ts` because `x jobs` needs exactly this pair and nothing else — and
4
+ // because a process that installs ambient accessors (`db()`, `jobDriver()`, the jobs facade, the
5
+ // event bus) must have one place that takes them all back, or the next command in the same process
6
+ // inherits a driver over a closed socket.
6
7
 
7
8
  import {
8
9
  type PostgresIdempotencyStore,
@@ -15,13 +15,7 @@ import { existsSync } from 'node:fs';
15
15
  import { join } from 'node:path';
16
16
  import { ERROR_DOCS_URL } from '@ultimat3/core';
17
17
  import type { EntityDescriptionLike, UnrenderedDeclaration } from '@ultimat3/db';
18
- import {
19
- declaredSchema,
20
- recordRetired,
21
- shellInertIdentifier,
22
- snapshotOf,
23
- unrenderedOf,
24
- } from '@ultimat3/db';
18
+ import { declaredSchema, recordRetired, snapshotOf, unrenderedOf } from '@ultimat3/db';
25
19
  import { registeredEntities } from '@ultimat3/entity';
26
20
  import { loadApp } from './app-load';
27
21
  import { checkSourceDrift, DB_PACKAGE } from './drift';
@@ -35,6 +29,7 @@ import type { Finding } from './output';
35
29
  import { settledDescriptions } from './redundant-indexes';
36
30
  import { appRowSecurity, type RowSecurityWanted, rowSecurityFindings } from './row-security-wanted';
37
31
  import { diffDeclaredSchema, type SchemaDifference } from './schema-diff';
32
+ import { quoteArg } from './shell-quote';
38
33
 
39
34
  /**
40
35
  * What the app declares, or `undefined` when the app would not load. Injected so this module's
@@ -104,14 +99,16 @@ function repairFix(
104
99
  // the DROP, and the other branch — the declaration may have been LOST rather than removed, which
105
100
  // is the whole reason this direction is its own finding — rides in the cause: a `fix:` is one
106
101
  // command, and a `# or …` after it was a shell comment nobody's paste would run.
107
- if (difference.direction === 'unmigrated') return { fix: `x db gen "record ${difference.name}"` };
108
- // The name was read off a sidecar on disk and lands inside double quotes, where `$(…)` and a
109
- // backtick still run: one the shell would act on is named in the cause only, never the command.
110
- const inert = shellInertIdentifier(difference.name) !== null;
102
+ // The name can be read off a sidecar on disk, so the description is SINGLE-quoted: inside
103
+ // double quotes `$(…)` and a backtick still run, inside single quotes nothing does, and the line
104
+ // stays the one runnable command naming the real object.
105
+ if (difference.direction === 'unmigrated') {
106
+ const recorded = quoteArg(`record ${difference.name}`);
107
+ return { fix: `x db gen ${recorded}` };
108
+ }
109
+ const dropped = quoteArg(`drop ${difference.name}`);
111
110
  return {
112
- fix: inert
113
- ? `x db gen "drop ${difference.name}"`
114
- : 'x db gen "drop what the entities no longer declare"',
111
+ fix: `x db gen ${dropped}`,
115
112
  why: `if ${difference.name} was lost rather than removed, re-declare it on the entity instead — this command drops it`,
116
113
  };
117
114
  }
package/src/script-csp.ts CHANGED
@@ -1,5 +1,7 @@
1
- // Every inline `<script>` body a served process can put in a document, as the `script-src` sources
2
- // that admit it. The mirror of `style-csp.ts`, and needed for the same reason: `script-src` was
1
+ // Every inline `<script>` body a served process can put in a document, as the `script-src`
2
+ // sources that admit it.
3
+ //
4
+ // The mirror of `style-csp.ts`, and needed for the same reason: `script-src` was
3
5
  // `'self' 'wasm-unsafe-eval'` while every document carrying an island shipped the hydration runtime
4
6
  // INLINE, so under the enforced policy a container serves (`dev: false`) no island ever booted —
5
7
  // invisible in `x dev`, where the policy is report-only.
@@ -1,8 +1,10 @@
1
- // A master-key rotation in an order a crash cannot turn into data loss. The new key is STAGED at
2
- // `<key>.next` (owner-only: 0600, and an ACL on Windows) before anything is sealed with it, the committed file is sealed second, and
3
- // the rename that makes the new key live is last. Interrupted anywhere, some key on disk opens the
4
- // committed file — and `recoverRotation`, which every `x secrets` command runs first, finishes or
5
- // abandons the move by asking the file which key it answers to.
1
+ // A master-key rotation in an order a crash cannot turn into data loss.
2
+ //
3
+ // The new key is STAGED at `<key>.next` (owner-only: 0600, and an ACL on Windows) before anything
4
+ // is sealed with it, the committed file is sealed second, and the rename that makes the new key
5
+ // live is last. Interrupted anywhere, some key on disk opens the committed file — and
6
+ // `recoverRotation`, which every `x secrets` command runs first, finishes or abandons the move by
7
+ // asking the file which key it answers to.
6
8
 
7
9
  import { existsSync, readFileSync, rmSync } from 'node:fs'; // why: Bun has no sync exists/remove; the key is WRITTEN and RENAMED only by core's owner-only writers.
8
10
  import type { MasterKeyRef, SecretValues } from '@ultimat3/core';
package/src/serve-boot.ts CHANGED
@@ -1,9 +1,11 @@
1
- // The serving roles' boot: the services started, the app loaded, its route table built, the roles
2
- // started. Behind ONE `await import()` in `serve.ts` (the entry points), so `ROLE=migrate` loads
3
- // none of it; the rules that file's header states — the SAME boot `x dev` runs, minus the watcher,
4
- // `/_x` and `dev: true` — are this file's. A role imports what it runs: the web surface
5
- // (`serve-web.ts`) and the manifest projection are behind `await import()` in turn, so a worker's
6
- // module graph holds neither.
1
+ // The serving roles' boot: the services started, the app loaded, its route table built, the
2
+ // roles started.
3
+ //
4
+ // Behind ONE `await import()` in `serve.ts` (the entry points), so `ROLE=migrate` loads none of it;
5
+ // the rules that file's header states — the SAME boot `x dev` runs, minus the watcher, `/_x` and
6
+ // `dev: true` — are this file's. A role imports what it runs: the web surface (`serve-web.ts`) and
7
+ // the manifest projection are behind `await import()` in turn, so a worker's module graph holds
8
+ // neither.
7
9
 
8
10
  import type { DrainConfig, LifecycleOptions, Role } from '@ultimat3/core';
9
11
  import { configureLifecycle, logger, UltimateError } from '@ultimat3/core';
package/src/serve.ts CHANGED
@@ -1,8 +1,11 @@
1
- // What a container starts. `apps/web/server.ts` is three lines that call `runRole`, so the boot a
2
- // production process performs is framework code with tests rather than app code the author has to
3
- // get right — and it is the SAME code `x dev` runs, minus the watcher, minus `/_x`, minus
4
- // `dev: true`. The only production-shaped decisions live here: which role, which port, and which
5
- // interface — every one by default, because a container is reached through a port mapping.
1
+ // What a container starts: the role, the port and the interface — the same boot `x dev` runs,
2
+ // minus the watcher, `/_x` and `dev: true`.
3
+ //
4
+ // `apps/web/server.ts` is three lines that call `runRole`, so the boot a production process
5
+ // performs is framework code with tests rather than app code the author has to get right — and it
6
+ // is the SAME code `x dev` runs, minus the watcher, minus `/_x`, minus `dev: true`. The only
7
+ // production-shaped decisions live here: which role, which port, and which interface — every one by
8
+ // default, because a container is reached through a port mapping.
6
9
 
7
10
  import { assertNoDevSecretsOutsideLocal, frameworkVersion, logger } from '@ultimat3/core';
8
11
  import { assertNoSchemaDrift, checkDrift, migrate } from '@ultimat3/db';
@@ -1,8 +1,10 @@
1
- // A package barrel a browser must not import, and the entry it imports instead. `@ultimat3/entity`'s
2
- // barrel reaches the SQL renderer and `@ultimat3/db` — about a megabyte in an island — while
3
- // `@ultimat3/entity/record` is the browser half. DERIVED from each manifest's `exports`: a package
4
- // that publishes a `./record`, `./browser` or `./client` subpath has said its barrel is the server
5
- // half, so a new browser entry enters this rule by being published, never by being listed here.
1
+ // A package barrel a browser must not import, and the entry it imports instead.
2
+ //
3
+ // `@ultimat3/entity`'s barrel reaches the SQL renderer and `@ultimat3/db` — about a megabyte in an
4
+ // island — while `@ultimat3/entity/record` is the browser half. DERIVED from each manifest's
5
+ // `exports`: a package that publishes a `./record`, `./browser` or `./client` subpath has said its
6
+ // barrel is the server half, so a new browser entry enters this rule by being published, never by
7
+ // being listed here.
6
8
 
7
9
  import { stripComments } from '@ultimat3/core';
8
10
  import { lineIndex } from './ts-scan';
@@ -11,5 +11,12 @@ const SHELL_SAFE = /^[\w@%+=:,./-]+$/;
11
11
  * `'\''` is the only escape a single-quoted string has. A shell-safe value is left alone, so the
12
12
  * common case stays readable.
13
13
  */
14
- export const quoteArg = (value: string): string =>
14
+ const quoteOne = (value: string): string =>
15
15
  SHELL_SAFE.test(value) ? value : `'${value.split("'").join("'\\''")}'`;
16
+
17
+ /**
18
+ * A word list is an INVOCATION (`['g', 'route', name]`): each word quoted on its own and joined,
19
+ * because quoting it whole made `x 'g route posts'`, one word no command answers to.
20
+ */
21
+ export const quoteArg = (value: string | readonly string[]): string =>
22
+ typeof value === 'string' ? quoteOne(value) : value.map(quoteOne).join(' ');
@@ -5,6 +5,7 @@
5
5
 
6
6
  import type { AppLocaleSet } from '@ultimat3/i18n/app-catalogs';
7
7
  import { BadFlagError } from './errors';
8
+ import { quoteArg } from './shell-quote';
8
9
 
9
10
  /**
10
11
  * `@ultimat3/i18n/app-catalogs`'s `appLocaleSet(root)` — the one reader, and its one answer for an
@@ -20,7 +21,7 @@ export function readLocaleFlag(value: string | undefined, app: ShotLocales): str
20
21
  flag: 'locale',
21
22
  command: 'shot',
22
23
  reason: `"${value}" is not one of the app's locales (${app.locales.join(', ')})`,
23
- fix: `x shot / --locale ${app.defaultLocale} --json`,
24
+ fix: `x shot / --locale ${quoteArg(app.defaultLocale)} --json`,
24
25
  });
25
26
  }
26
27
 
package/src/shot-route.ts CHANGED
@@ -3,6 +3,7 @@
3
3
  // `allowHosts` exists to refuse is refused here, at the argument, where the reader can see why.
4
4
 
5
5
  import { BadFlagError, MissingPositionalError } from './errors';
6
+ import { quoteArg } from './shell-quote';
6
7
 
7
8
  /** A directory name a route can never escape: everything that is not a letter or digit is a dash. */
8
9
  export function shotSlug(route: string): string {
@@ -75,7 +76,7 @@ export function readRoute(raw: string | undefined): string {
75
76
  reason: `"${route}" is an absolute URL; x shot photographs a route of the app under test`,
76
77
  // The path out of the URL when it parses — the refusal's own fix line has to be runnable,
77
78
  // and `new URL('http://')` throws, so the fallback is the route every app has.
78
- fix: `x shot ${pathOf(route)} --json`,
79
+ fix: `x shot ${quoteArg(pathOf(route))} --json`,
79
80
  });
80
81
  }
81
82
  const path = route.startsWith('/') ? route : `/${route}`;
package/src/shot-theme.ts CHANGED
@@ -1,9 +1,11 @@
1
- // The script a capture runs ahead of the document when a theme was ASKED for. Since 20.2.0 the
2
- // boot inlines a theme script (`@ultimat3/render`'s `themeScriptBody`) whose fallback is the app's
3
- // `theme.defaultMode`, and only a stored choice under `THEME_STORAGE_KEY` beats it — so emulating
4
- // `prefers-color-scheme` alone photographs a `defaultMode: 'dark'` app dark whatever was requested
5
- // (issue #489). A requested theme is therefore stored as the visitor's CHOICE, on the page's origin,
6
- // before the boot reads it: the picture is then what a visitor who chose that theme sees.
1
+ // The script a capture runs ahead of the document when a theme was ASKED for.
2
+ //
3
+ // Since 20.2.0 the boot inlines a theme script (`@ultimat3/render`'s `themeScriptBody`) whose
4
+ // fallback is the app's `theme.defaultMode`, and only a stored choice under `THEME_STORAGE_KEY`
5
+ // beats it — so emulating `prefers-color-scheme` alone photographs a `defaultMode: 'dark'` app dark
6
+ // whatever was requested (issue #489). A requested theme is therefore stored as the visitor's
7
+ // CHOICE, on the page's origin, before the boot reads it: the picture is then what a visitor who
8
+ // chose that theme sees.
7
9
 
8
10
  import { THEME_STORAGE_KEY } from '@ultimat3/core';
9
11
  import type { ShotColorScheme } from './browser-launcher-port';
@@ -4,6 +4,7 @@
4
4
  // loader (`app-config-load.ts`).
5
5
 
6
6
  import type { Environment, SeoRobotsGroup, SeoSitemapConfig, SiteFavicon } from '@ultimat3/core';
7
+ import { trimTrailingSlashes } from '@ultimat3/core';
7
8
  import { loadAppConfig } from './app-config-load';
8
9
 
9
10
  export interface SiteSettings {
@@ -39,7 +40,7 @@ export const NO_SITE_SETTINGS: SiteSettings = {
39
40
  llms: true,
40
41
  };
41
42
 
42
- const trimSlash = (origin: string): string => origin.replace(/\/+$/, '');
43
+ const trimSlash = (origin: string): string => trimTrailingSlashes(origin);
43
44
 
44
45
  export async function loadSiteSettings(root: string): Promise<SiteSettings> {
45
46
  const config = await loadAppConfig(root);
@@ -3,7 +3,13 @@
3
3
  // `siteLlms` never runs a page's `load` after the build stopped answering the app's own queries.
4
4
 
5
5
  import type { Environment } from '@ultimat3/core';
6
- import { ctxOf, DEFAULT_ENVIRONMENT, runWithContext, tryResolveEnvironment } from '@ultimat3/core';
6
+ import {
7
+ ctxOf,
8
+ DEFAULT_ENVIRONMENT,
9
+ runWithContext,
10
+ trimTrailingSlashes,
11
+ tryResolveEnvironment,
12
+ } from '@ultimat3/core';
7
13
  import type { PrerenderEntry, RouteEntry } from '@ultimat3/render';
8
14
  import { metaContextFor, routeDataFor, routeEntries } from '@ultimat3/render';
9
15
  import { enumeratePrerenderEntries, fillPath } from '@ultimat3/render/server';
@@ -60,7 +66,7 @@ export async function pageRecords(
60
66
  const records: RouteRecord[] = [];
61
67
  for (const page of await (options.enumerate ?? enumeratePrerenderEntries)(entry)) {
62
68
  const path = fillPath(entry.pattern.source, page.params);
63
- const ctx = { url: `${options.baseUrl.replace(/\/+$/, '')}${path}`, params: page.params };
69
+ const ctx = { url: `${trimTrailingSlashes(options.baseUrl)}${path}`, params: page.params };
64
70
  const meta = await runWithContext(
65
71
  ctxOf({ role: 'web', locale: options.defaultLocale }),
66
72
  async () => entry.config.meta(metaContextFor(ctx, await routeDataFor(entry.config, ctx))),
@@ -1,9 +1,11 @@
1
- // Adding an entry to an array literal in a file the app owns, read off the MASKED source. Every
2
- // generator that grows a list — a role's `grants`, `definePermissions([…])`, a `defineApi` list —
3
- // found its `]` with `indexOf` and its entries with a quote regex, so an apostrophe in a comment
4
- // was a string delimiter and a `]` in one closed the list: `x g entity` rewrote a role map's
5
- // comments into permissions. Here a comment and a literal's contents are never read as code, and
6
- // an edit that does not read back as "the same list plus the new entries" is refused, not written.
1
+ // Adding an entry to an array literal in a file the app owns, read off the MASKED source.
2
+ //
3
+ // Every generator that grows a list — a role's `grants`, `definePermissions([…])`, a `defineApi`
4
+ // list — found its `]` with `indexOf` and its entries with a quote regex, so an apostrophe in a
5
+ // comment was a string delimiter and a `]` in one closed the list: `x g entity` rewrote a role
6
+ // map's comments into permissions. Here a comment and a literal's contents are never read as code,
7
+ // and an edit that does not read back as "the same list plus the new entries" is refused, not
8
+ // written.
7
9
 
8
10
  import { maskLiterals, stripComments } from '@ultimat3/core';
9
11
  import { wrapList } from './templates/wrap';
@@ -5,7 +5,7 @@
5
5
 
6
6
  // why: Bun exposes no path-join primitive, and every card path is relative to the export root.
7
7
  import { join } from 'node:path';
8
- import { probeImage, transformImageBytes } from '@ultimat3/core';
8
+ import { probeImage, transformImageBytes, trimTrailingSlashes } from '@ultimat3/core';
9
9
  import { systemClock } from '@ultimat3/core/adapter';
10
10
  import type { OpenGraphImage } from '@ultimat3/seo';
11
11
  import type { ShotDriver } from './browser-launcher-port';
@@ -20,7 +20,7 @@ export const STATIC_CARD_DIR = '_og';
20
20
 
21
21
  /** `/og/post/hello` → `/_og/og/post/hello.png`; `/` → `/_og/index.png`. */
22
22
  export function cardUrl(capturePath: string): string {
23
- const trimmed = capturePath.replace(/\/+$/, '');
23
+ const trimmed = trimTrailingSlashes(capturePath);
24
24
  return `/${STATIC_CARD_DIR}${trimmed === '' ? '/index' : trimmed}.png`;
25
25
  }
26
26
 
@@ -3,9 +3,10 @@
3
3
  // state the same thing. A skipped route with no reason is what turned "the island did not mount"
4
4
  // into a bug report about a page that had never been in `.x/static/` at all (#242).
5
5
 
6
- // `node:` twice, and only where Bun answers nothing: Bun ships no path API, and `rm(…, { force })`
7
- // deletes a report that may not be there without a branch. `existsSync` was a third and is gone —
8
- // `Bun.file(path).json()` already rejects on a missing file, into the catch that answers `undefined`.
6
+ // why: `node:` twice, and only where Bun answers nothing: Bun ships no path API, and
7
+ // `rm(…, { force })` deletes a report that may not be there without a branch. `existsSync` was a
8
+ // third and is gone — `Bun.file(path).json()` already rejects on a missing file, into the catch
9
+ // that answers `undefined`.
9
10
  import { rm } from 'node:fs/promises';
10
11
  import { join } from 'node:path';
11
12
  import type { RenderMode } from '@ultimat3/core';
@@ -145,21 +146,24 @@ export function skipReasonFor(route: RouteFacts): SkipReason | null {
145
146
  * English rather than `t()`, for the reason every `cause:`/`fix:` in this repo is English: this is
146
147
  * a diagnostic an agent pastes into a report, and `wiki/Error-Codes.md` is the same surface.
147
148
  */
148
- const WHY = Object.freeze<Record<SkipReason, (route: RouteFacts) => string>>({
149
- 'surface-forbids-static': (route) =>
150
- `${route.surface}/ surface — server-rendered, not prerendered; ` +
151
- `${route.surface}/ allows ${SURFACE_SPECS[route.surface].allowedModes.join(' | ') || 'no render mode'}, ` +
152
- 'so no route on it can ever reach the artifact',
153
- 'mode-revalidates': (route) =>
154
- `render: '${route.render}' regenerates on a tag or ttl and a published file cannot, ` +
155
- "so it is served by the app — change it to render: 'static' to emit it",
156
- 'mode-per-request': (route) =>
157
- `render: '${route.render}' is rendered per request, so it is served by the app — ` +
158
- "change it to render: 'static' to emit it",
159
- 'no-prerender-paths': (route) =>
160
- `render: '${route.render}' with dynamic params and no prerender() paths, so the build ` +
161
- 'enumerated nothing to write — add prerender() to the route',
162
- });
149
+ // Null-prototype: a reason that is not one of these reads `undefined`, never an `Object` member.
150
+ const WHY: Readonly<Record<SkipReason, (route: RouteFacts) => string>> = Object.freeze(
151
+ Object.assign(Object.create(null) as object, {
152
+ 'surface-forbids-static': (route) =>
153
+ `${route.surface}/ surface — server-rendered, not prerendered; ` +
154
+ `${route.surface}/ allows ${SURFACE_SPECS[route.surface].allowedModes.join(' | ') || 'no render mode'}, ` +
155
+ 'so no route on it can ever reach the artifact',
156
+ 'mode-revalidates': (route) =>
157
+ `render: '${route.render}' regenerates on a tag or ttl and a published file cannot, ` +
158
+ "so it is served by the app — change it to render: 'static' to emit it",
159
+ 'mode-per-request': (route) =>
160
+ `render: '${route.render}' is rendered per request, so it is served by the app — ` +
161
+ "change it to render: 'static' to emit it",
162
+ 'no-prerender-paths': (route) =>
163
+ `render: '${route.render}' with dynamic params and no prerender() paths, so the build ` +
164
+ 'enumerated nothing to write — add prerender() to the route',
165
+ } satisfies Record<SkipReason, (route: RouteFacts) => string>),
166
+ );
163
167
 
164
168
  /** The reason as a row: the code a machine keys off, and the sentence a human reads. */
165
169
  export function skippedRoute(
@@ -1,8 +1,9 @@
1
- // The app's HTTP authenticator, seen as the `sync` node's. Until this file `sync-node.ts` was
2
- // handed no `authenticate` by any host, so every socket the framework ever opened carried
3
- // `actorId: null` — and the channel guard, the live-query gate, the presence entry and the
4
- // per-tenant subscription cap all decided against an anonymous actor. Realtime was single-tenant
5
- // by wiring, not by design.
1
+ // The app's HTTP authenticator, seen as the `sync` node's.
2
+ //
3
+ // Until this file `sync-node.ts` was handed no `authenticate` by any host, so every socket the
4
+ // framework ever opened carried `actorId: null` — and the channel guard, the live-query gate, the
5
+ // presence entry and the per-tenant subscription cap all decided against an anonymous actor.
6
+ // Realtime was single-tenant by wiring, not by design.
6
7
 
7
8
  import type { Actor, Clock } from '@ultimat3/core';
8
9
  import { finiteCount, systemClock } from '@ultimat3/core';
@@ -1,9 +1,12 @@
1
1
  // `x g admin:page <name>` — a screen the admin derives from nothing: a reconciliation fixer, a
2
- // proxy health board, a deploy button. What the template has to get right is what it does NOT
3
- // emit: no `defineRoute`, because `pages:` is the one thing that puts a page in the admin's route
4
- // table and `guardedPage()` is the one thing that decides it. A scaffold that wrote a route
5
- // declaration here would hand back the unguarded second way in that seam exists to close.
2
+ // proxy health board, a deploy button.
3
+ //
4
+ // What the template has to get right is what it does NOT emit: no `defineRoute`, because `pages:`
5
+ // is the one thing that puts a page in the admin's route table and `guardedPage()` is the one thing
6
+ // that decides it. A scaffold that wrote a route declaration here would hand back the unguarded
7
+ // second way in that seam exists to close.
6
8
 
9
+ import { trimTrailingSlashes } from '@ultimat3/core';
7
10
  import { ADMIN_FILE } from '../admin-registration';
8
11
  import { catalogJson } from './catalog-json';
9
12
  import { sortedImports } from './imports';
@@ -208,7 +211,7 @@ export function adminPageFiles(
208
211
  ): readonly GeneratedFile[] {
209
212
  const name = kebab(rawName);
210
213
  // Trailing slashes trimmed exactly as `islandFiles` does — one `--at`, one normalization.
211
- const dir = (options.dir ?? DEFAULT_ADMIN_PAGE_DIR).replace(/\/+$/, '');
214
+ const dir = trimTrailingSlashes(options.dir ?? DEFAULT_ADMIN_PAGE_DIR);
212
215
  return [
213
216
  {
214
217
  path: `${dir}/${name}.tsx`,
@@ -1,8 +1,9 @@
1
- // `x g resource <name> --admin` — the per-entity admin override. `defineAdmin()` already serves
2
- // list/detail/create/edit for the entity with nothing written; this file is only what an app
3
- // author would otherwise hand-write on top — the list columns, a page size, and from there scopes,
4
- // a row scope and computed columns. `admin-registration.ts` lists it under `resources:` in the
5
- // app's `defineAdmin()` call in the same run, so nothing is left to wire.
1
+ // `x g resource <name> --admin` — the per-entity admin override.
2
+ //
3
+ // `defineAdmin()` already serves list/detail/create/edit for the entity with nothing written; this
4
+ // file is only what an app author would otherwise hand-write on top — the list columns, a page
5
+ // size, and from there scopes, a row scope and computed columns. `admin-registration.ts` lists it
6
+ // under `resources:` in the app's `defineAdmin()` call in the same run, so nothing is left to wire.
6
7
 
7
8
  import type { FeatureTarget } from './entity';
8
9
  import { entityFiles } from './entity';
@@ -1,8 +1,10 @@
1
- // The `animated-layout-property` guard `x new` ships: only `transform` and `opacity` animate for
2
- // free. Everything else — a `top`, a `width`, a `margin`, a `box-shadow` — costs the browser a
3
- // layout or a paint on EVERY frame, on the same main thread the app's own JavaScript is on, and
4
- // feeds the layout-shift metric while it does it. `transition: all` is worse than any single one of
5
- // them: it animates properties nobody chose, including the ones that have not been written yet.
1
+ // The `animated-layout-property` guard `x new` ships: only `transform` and `opacity` animate
2
+ // for free.
3
+ //
4
+ // Everything else — a `top`, a `width`, a `margin`, a `box-shadow` — costs the browser a layout or
5
+ // a paint on EVERY frame, on the same main thread the app's own JavaScript is on, and feeds the
6
+ // layout-shift metric while it does it. `transition: all` is worse than any single one of them: it
7
+ // animates properties nobody chose, including the ones that have not been written yet.
6
8
 
7
9
  import { guardCode } from './guard';
8
10
  import type { GeneratedFile } from './naming';
@@ -1,8 +1,10 @@
1
- // The `focus-visible` guard `x new` ships: a stylesheet never takes the focus ring away and leaves
2
- // nothing in its place. `outline: none` is the single most-copied line on the web and it deletes
3
- // the only thing telling a keyboard user where they are — WCAG 2.2 SC 2.4.11 and 2.4.13 ask for an
4
- // indicator at least 2px around the control at 3:1 against what is behind it. Nothing in the gate
5
- // could see it: `x verify`'s `seo` and `i18n` steps read pages, and lint reads TypeScript.
1
+ // The `focus-visible` guard `x new` ships: a stylesheet never takes the focus ring away and
2
+ // leaves nothing in its place.
3
+ //
4
+ // `outline: none` is the single most-copied line on the web and it deletes the only thing telling a
5
+ // keyboard user where they are — WCAG 2.2 SC 2.4.11 and 2.4.13 ask for an indicator at least 2px
6
+ // around the control at 3:1 against what is behind it. Nothing in the gate could see it:
7
+ // `x verify`'s `seo` and `i18n` steps read pages, and lint reads TypeScript.
6
8
 
7
9
  import { guardCode } from './guard';
8
10
  import type { GeneratedFile } from './naming';
@@ -1,8 +1,11 @@
1
- // The `image-dimensions` guard `x new` ships: an image reserves its box before its bytes arrive.
2
- // An unsized `<img>` is the largest single contributor to Cumulative Layout Shift — the page reflows
3
- // under the reader's finger the moment the bytes land — and the second half is its mirror image: a
4
- // `loading="lazy"` on the image the page is judged by is a deliberate delay on the one paint the
5
- // metric measures. Both are decidable from the attributes and nothing in the gate could see either.
1
+ // The `image-dimensions` guard `x new` ships: an image reserves its box before its bytes
2
+ // arrive, and the image a page is judged by is never `loading="lazy"`.
3
+ //
4
+ // An unsized `<img>` is the largest single contributor to Cumulative Layout Shift — the page
5
+ // reflows under the reader's finger the moment the bytes land — and the second half is its mirror
6
+ // image: a `loading="lazy"` on the image the page is judged by is a deliberate delay on the one
7
+ // paint the metric measures. Both are decidable from the attributes and nothing in the gate could
8
+ // see either.
6
9
 
7
10
  import { guardCode } from './guard';
8
11
  import type { GeneratedFile } from './naming';
@@ -1,6 +1,8 @@
1
- // The `island-without-states` guard `x new` ships, and it closes a loop the framework already built
2
- // half of. `x shot --island <name>` photographs an island in every state its sibling
3
- // `<name>.island.states.ts` declares — including the ones nobody can reach by clicking: a save the
1
+ // The `island-without-states` guard `x new` ships: an island with no sibling
2
+ // `<name>.island.states.ts` has never been seen in the states `x shot --island` photographs.
3
+ //
4
+ // It closes a loop the framework already built half of: `x shot --island <name>` photographs every
5
+ // state the states file declares — including the ones nobody can reach by clicking: a save the
4
6
  // server refused, a read that came back empty, a label three times as long in the next locale. An
5
7
  // island with no states file has never been seen in any of them, by a reviewer or by a model.
6
8
 
@@ -1,4 +1,5 @@
1
1
  // The `semantic-interactive` guard `x new` ships: an element that answers a click IS a control.
2
+ //
2
3
  // The cheapest a11y win there is, and the one an agent undoes by reflex — WebAIM's annual survey of
3
4
  // a million home pages finds pages using ARIA average ~41% MORE detected errors than pages using
4
5
  // none, because `role="button"` is a PROMISE (Space, Enter, focus, disabled) and only the native
@@ -1,9 +1,12 @@
1
- // `x g island <name>` — the one file on a route that ships JavaScript. Not a ninth primitive and
2
- // not a component generator: an island is a client ENTRY POINT, so what the scaffold has to get
3
- // right is the filename (the bundler discovers by it), the `mount` export (the hydration runtime
4
- // calls it by name) and what `mount` DOES — Solid's `render`, the one client shape the island build
5
- // compiles. All three are pinned by the emitted test, which builds the chunk and mounts it.
1
+ // `x g island <name>` — the one file on a route that ships JavaScript.
2
+ //
3
+ // Not a ninth primitive and not a component generator: an island is a client ENTRY POINT, so what
4
+ // the scaffold has to get right is the filename (the bundler discovers by it), the `mount` export
5
+ // (the hydration runtime calls it by name) and what `mount` DOES — Solid's `render`, the one client
6
+ // shape the island build compiles. All three are pinned by the emitted test, which builds the chunk
7
+ // and mounts it.
6
8
 
9
+ import { trimTrailingSlashes } from '@ultimat3/core';
7
10
  import type { GeneratedFile } from './naming';
8
11
  import { camel, kebab, pascal } from './naming';
9
12
 
@@ -198,7 +201,7 @@ export const ${camel(name)}States = defineIslandStates({
198
201
 
199
202
  export function islandFiles(rawName: string, options: IslandOptions): readonly GeneratedFile[] {
200
203
  const name = kebab(rawName);
201
- const dir = options.dir.replace(/\/+$/, '');
204
+ const dir = trimTrailingSlashes(options.dir);
202
205
  return [
203
206
  { path: `${dir}/${name}.island.tsx`, contents: islandSource(name) },
204
207
  { path: `${dir}/${name}.module.scss`, contents: islandStyle() },