@ultimat3/cli 31.51.0 → 31.53.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 (169) hide show
  1. package/CLAUDE.md +1 -1
  2. package/README.md +9 -9
  3. package/package.json +29 -29
  4. package/src/app-kit-disk.ts +39 -0
  5. package/src/app-kit-forms.ts +27 -0
  6. package/src/app-kit.ts +146 -0
  7. package/src/budgets.ts +3 -1
  8. package/src/catalog-layout.ts +194 -0
  9. package/src/cdp-shot-driver-screen.ts +72 -0
  10. package/src/cdp-shot-driver.ts +17 -1
  11. package/src/cmd-design-capture.ts +210 -0
  12. package/src/cmd-design-errors.ts +50 -0
  13. package/src/cmd-design-paths.ts +47 -0
  14. package/src/cmd-design-publish.ts +64 -0
  15. package/src/cmd-design-run.ts +229 -0
  16. package/src/cmd-design-spec.ts +47 -0
  17. package/src/cmd-design-theme.ts +107 -0
  18. package/src/cmd-design-url.ts +201 -0
  19. package/src/cmd-design.ts +188 -0
  20. package/src/cmd-doctor.ts +3 -0
  21. package/src/cmd-generate-spec.ts +5 -0
  22. package/src/cmd-generate.ts +3 -1
  23. package/src/cmd-i18n-spec.ts +4 -4
  24. package/src/cmd-i18n-split.ts +133 -0
  25. package/src/cmd-i18n.ts +46 -66
  26. package/src/cmd-kit-spec.ts +13 -0
  27. package/src/cmd-kit.ts +133 -0
  28. package/src/cmd-shot-against.ts +275 -0
  29. package/src/cmd-shot-spec.ts +9 -1
  30. package/src/cmd-shot.ts +19 -0
  31. package/src/cmd-upgrade.ts +11 -0
  32. package/src/codemods/agent-kit.ts +130 -0
  33. package/src/codemods/agents-md-budget.ts +47 -0
  34. package/src/codemods/docs-visual-quality.ts +198 -0
  35. package/src/codemods/index.ts +8 -0
  36. package/src/codemods/settings-kit-allow.ts +49 -0
  37. package/src/config-redact.ts +20 -4
  38. package/src/db-rollback-pass.ts +4 -1
  39. package/src/design-extract-script.ts +187 -0
  40. package/src/design-extract.ts +311 -0
  41. package/src/design-map-colors.ts +180 -0
  42. package/src/design-map.ts +288 -0
  43. package/src/dev-child-watch.ts +16 -0
  44. package/src/dev-db-migrate.ts +27 -46
  45. package/src/dev-db-migrator-hold.ts +131 -0
  46. package/src/dev-db-rollback.ts +11 -2
  47. package/src/dev-rebuild-schema.ts +7 -24
  48. package/src/doctor-kit.ts +25 -0
  49. package/src/error-catalog.ts +4 -2
  50. package/src/error-codes-kit.ts +24 -0
  51. package/src/error-codes.ts +12 -10
  52. package/src/generate-catalog-locales.ts +25 -2
  53. package/src/generate-files.ts +31 -1
  54. package/src/generate-follow-ups.ts +8 -3
  55. package/src/guards-shipped-names.ts +5 -0
  56. package/src/i18n-audit.ts +17 -33
  57. package/src/i18n-index.ts +108 -31
  58. package/src/i18n-locale-parity.ts +14 -6
  59. package/src/i18n-new-locale.ts +75 -0
  60. package/src/i18n-registration.ts +52 -27
  61. package/src/island-capture.ts +36 -7
  62. package/src/kit/agent-audit.ts +49 -0
  63. package/src/kit/agent-data.ts +32 -0
  64. package/src/kit/agent-server.ts +34 -0
  65. package/src/kit/agent-shape.ts +61 -0
  66. package/src/kit/agent-web.ts +49 -0
  67. package/src/kit/design-map.ts +106 -0
  68. package/src/kit/managed.ts +12 -0
  69. package/src/kit/registry.ts +89 -0
  70. package/src/kit/skill-design-research.ts +119 -0
  71. package/src/kit/skill-feature.ts +159 -0
  72. package/src/kit/skill-planx.ts +139 -0
  73. package/src/kit/skill-upgrade.ts +94 -0
  74. package/src/kit/skill-verify.ts +80 -0
  75. package/src/mcp-errors.ts +5 -0
  76. package/src/mcp-ui-diff.ts +13 -38
  77. package/src/mcp-ui.ts +30 -1
  78. package/src/merge-state.ts +3 -2
  79. package/src/messages-design.ts +104 -0
  80. package/src/messages-floor.ts +2 -0
  81. package/src/messages-upgrade.ts +9 -0
  82. package/src/messages.ts +4 -0
  83. package/src/registry.ts +4 -0
  84. package/src/serve-boot-telemetry.ts +106 -0
  85. package/src/serve-boot.ts +23 -4
  86. package/src/shot-blank.ts +70 -0
  87. package/src/shot-diff.ts +96 -0
  88. package/src/shot-gpu.ts +17 -5
  89. package/src/templates/catalog-barrel.ts +84 -0
  90. package/src/templates/guard-animated-layout-script.ts +173 -0
  91. package/src/templates/guard-effect-without-fallback.ts +117 -0
  92. package/src/templates/guard-motion-adapter.ts +161 -0
  93. package/src/templates/guard-raw-frame-loop.ts +134 -0
  94. package/src/templates/guard-raw-motion-script.ts +132 -0
  95. package/src/templates/guard-raw-motion-ts-scan.ts +95 -0
  96. package/src/templates/guard-released-forms.ts +12 -1
  97. package/src/templates/guard-untranslated-string.ts +27 -6
  98. package/src/templates/index.ts +1 -2
  99. package/src/templates/island.ts +55 -8
  100. package/src/templates/kit-released-forms.ts +63 -0
  101. package/src/templates/locales.ts +6 -0
  102. package/src/templates/motion-scale.ts +115 -0
  103. package/src/templates/scaffold-claude.ts +39 -26
  104. package/src/templates/scaffold-design.ts +41 -0
  105. package/src/templates/scaffold-docs.ts +31 -7
  106. package/src/templates/scaffold-gitattributes.ts +9 -2
  107. package/src/templates/scaffold-guards.ts +31 -2
  108. package/src/templates/scaffold-i18n.ts +10 -6
  109. package/src/templates/scaffold-verify-floor.ts +3 -0
  110. package/src/templates/shapes/blog-site.ts +15 -0
  111. package/src/templates/shapes/blog.ts +2 -0
  112. package/src/templates/shapes/content-site.ts +13 -0
  113. package/src/templates/shapes/content.ts +2 -0
  114. package/src/templates/shapes/dashboard-detail.ts +2 -0
  115. package/src/templates/shapes/dashboard-motion.ts +284 -0
  116. package/src/templates/shapes/dashboard.ts +19 -1
  117. package/src/templates/shapes/landing-motion.ts +67 -0
  118. package/src/templates/shapes/offline.ts +5 -2
  119. package/src/templates/shapes/saas.ts +4 -0
  120. package/src/test-ignores.ts +3 -2
  121. package/src/upgrade-gate.ts +14 -2
  122. package/src/upgrade-kit.ts +65 -0
  123. package/src/upgrade-report-kit.ts +28 -0
  124. package/src/upgrade-report.ts +3 -0
  125. package/src/verify-checks.ts +9 -1
  126. package/src/verify-floor.ts +9 -1
  127. package/src/verify-local-only.ts +66 -0
  128. package/src/verify-run.ts +17 -2
  129. package/src/workspace-checks.ts +3 -3
  130. package/wiki/Actions.md +1 -1
  131. package/wiki/Agents.md +33 -1
  132. package/wiki/Auth.md +3 -3
  133. package/wiki/Batching-And-Preloading.md +1 -0
  134. package/wiki/CLI-Reference-Data.md +241 -0
  135. package/wiki/CLI-Reference-Gate.md +572 -0
  136. package/wiki/CLI-Reference-Project.md +414 -0
  137. package/wiki/CLI-Reference-Ship.md +348 -0
  138. package/wiki/CLI-Reference-Tools.md +687 -0
  139. package/wiki/CLI-Reference.md +18 -2227
  140. package/wiki/Compared.md +8 -8
  141. package/wiki/Configuration.md +26 -2
  142. package/wiki/Deployment.md +1 -1
  143. package/wiki/Design-Research.md +96 -0
  144. package/wiki/Effects.md +83 -0
  145. package/wiki/Entities-And-Migrations.md +3 -2
  146. package/wiki/FAQ.md +1 -1
  147. package/wiki/Getting-Started.md +1 -1
  148. package/wiki/Home.md +2 -2
  149. package/wiki/I18n.md +39 -5
  150. package/wiki/Installation.md +1 -1
  151. package/wiki/Jobs-And-Workflows.md +29 -1
  152. package/wiki/Known-Gaps.md +6 -2
  153. package/wiki/MCP-And-AI.md +4 -0
  154. package/wiki/Motion.md +85 -0
  155. package/wiki/Observability.md +15 -1
  156. package/wiki/Outbound-HTTP.md +62 -2
  157. package/wiki/PWA-And-Offline.md +1 -1
  158. package/wiki/Policies-And-Authz.md +10 -0
  159. package/wiki/Project-Layout.md +1 -1
  160. package/wiki/Realtime.md +29 -2
  161. package/wiki/Static-Assets.md +1 -1
  162. package/wiki/Testing.md +33 -0
  163. package/wiki/Theming.md +31 -8
  164. package/wiki/Troubleshooting.md +1 -1
  165. package/wiki/Tutorial-02-First-Feature.md +1 -1
  166. package/wiki/UI-Components.md +2 -0
  167. package/wiki/Upgrading.md +9 -3
  168. package/src/templates/scaffold-claude-agents.ts +0 -161
  169. package/src/templates/scaffold-claude-commands.ts +0 -239
package/src/serve-boot.ts CHANGED
@@ -10,6 +10,7 @@
10
10
  import type { DrainConfig, LifecycleOptions, Role } from '@ultimat3/core';
11
11
  import { configureLifecycle, logger, UltimateError } from '@ultimat3/core';
12
12
  import { installBuildId } from '@ultimat3/core/adapter';
13
+ import { configureOutboundProxy } from '@ultimat3/core/outbound';
13
14
  import { loadAppConfig } from './app-config-load';
14
15
  import { armFailureCapture } from './failure-capture-boot';
15
16
  import type { MetricsEndpoint } from './metrics-endpoint';
@@ -28,6 +29,7 @@ import { releaseOrThrow, startServices } from './runtime-services';
28
29
  import type { BootTimeline } from './serve-boot-phases';
29
30
  import { bootTimeline } from './serve-boot-phases';
30
31
  import { type BootProbe, openBootProbe } from './serve-boot-probe';
32
+ import { configureServiceIdentity, type ServiceIdentityBoot } from './serve-boot-telemetry';
31
33
  import { bootWarningConcerns, warnAtBoot } from './serve-boot-warnings';
32
34
  import { loadDrainConfig, loadHealthConfig } from './serve-drain';
33
35
  import {
@@ -103,9 +105,19 @@ export async function bootServing(boot: {
103
105
  readonly metrics: MetricsEndpoint;
104
106
  }): Promise<ServedApp> {
105
107
  const { options } = boot;
108
+ // Before the config loads, from the env alone (#1361): a span the app's config opens already
109
+ // names the service the deploy named. The app's `name` and the build id fill in below.
110
+ // FIRST in the unwind list, so it is released last: the exporter's final flush still names it.
111
+ const identity = configureServiceIdentity(options.env);
112
+ boot.acquired.unshift(identity.release);
106
113
  // Before anything is started or created: a role `app.config.ts` does not list is refused while
107
114
  // there is nothing to unwind but the scrape listener.
108
- assertRoleDeclared(boot.role, await loadAppConfig(options.root));
115
+ const appConfig = await loadAppConfig(options.root);
116
+ identity.named(appConfig?.name);
117
+ assertRoleDeclared(boot.role, appConfig);
118
+ // `outbound.proxy`, before any service or app module can send: every `outbound()` call that
119
+ // names no proxy of its own — APNs, FCM, OAuth, a webhook — goes through it from here on.
120
+ boot.acquired.push(configureOutboundProxy(appConfig?.outbound));
109
121
  // The role's own grace FIRST, before the services: the schema wait runs inside them, and a worker
110
122
  // SIGTERMed mid-wait sat through web's readiness grace. `app.config.ts`'s `drain` section is
111
123
  // applied over this once the app is loaded (`bootRoles`).
@@ -136,6 +148,7 @@ export async function bootServing(boot: {
136
148
  timeline.phase('services');
137
149
  return bootRoles({
138
150
  ...boot,
151
+ identity,
139
152
  runtime,
140
153
  timeline,
141
154
  ...(tls === undefined ? {} : { tls }),
@@ -170,6 +183,8 @@ export function refuseHalfLoadedApp(role: Role, findings: readonly Finding[]): v
170
183
  async function bootRoles(boot: {
171
184
  readonly options: ServeOptions;
172
185
  readonly role: Role;
186
+ /** The service identity `bootServing` named from the env and the config; the build id is ours. */
187
+ readonly identity: ServiceIdentityBoot;
173
188
  readonly runtime: RunningServices;
174
189
  readonly acquired: (() => void | Promise<void>)[];
175
190
  /** The scrape listener `serveApp` opened before any of this work; `startRoles` adopts it. */
@@ -187,11 +202,14 @@ async function bootRoles(boot: {
187
202
  // shipped chart and nothing read it, so every deployment that configured a collector got an empty
188
203
  // dashboard. `x dev` keeps its own recorder — the `/_x` timeline is a different sink with a
189
204
  // different lifetime — so this is the production boot's alone (axiom 6).
190
- // At the FRONT of the unwind list, so the stop and a failed boot's rollback alike release it
191
- // last: the drain's own spans and the final counter snapshot still have somewhere to go.
205
+ // At the FRONT of the unwind list (behind only the service identity), so the stop and a failed
206
+ // boot's rollback alike release it last but one: the drain's own spans and the final counter
207
+ // snapshot still have somewhere to go, under the service's own name.
192
208
  // The config first, for `database.slowStatementMs`: `app.config.ts` declares, it registers no hook.
193
209
  const appConfig = await loadAppConfig(options.root);
194
- acquired.unshift(
210
+ acquired.splice(
211
+ acquired.indexOf(boot.identity.release) + 1,
212
+ 0,
195
213
  startOtlpExport(options.env, { slowStatementMs: appConfig?.database.slowStatementMs }),
196
214
  );
197
215
  // The image's compiled stylesheets, before the first page is imported — importing one IS
@@ -223,6 +241,7 @@ async function bootRoles(boot: {
223
241
  // Core's one copy: `ctx.buildId` (a job's audit row), `/healthz` and `/readyz` read this, never
224
242
  // `BUILD_ID` — an unstamped image's `''` would otherwise disagree with `x-ultimate-build`.
225
243
  acquired.push(installBuildId(buildId));
244
+ boot.identity.built(buildId);
226
245
  timeline.phase('build-id');
227
246
  // Before the first socket opens: everything above this line fails loudly into the container's
228
247
  // own logs, everything below it is a served request, a claimed job or a routed frame.
@@ -0,0 +1,70 @@
1
+ // Is a captured picture a picture of anything? Judged by its PIXELS, never its byte count: a flat
2
+ // 36 px button is a few hundred honest bytes, and a blank 1280x800 crop compresses to about as few.
3
+ // One pure verdict over the decoded raster, so a test can hand it both and see them told apart.
4
+
5
+ import type { Raster } from '@ultimat3/core';
6
+ import { decodeImage, transformImageBytes } from '@ultimat3/core';
7
+
8
+ /**
9
+ * The widest spread, per channel, a crop may have and still be ONE colour. Not 0: a GPU
10
+ * compositor dithers a flat fill by a level or two, and that noise is not content. A hairline
11
+ * border, a glyph or a focus ring against the page is tens of levels — an order of magnitude past it.
12
+ */
13
+ export const BLANK_CHANNEL_SPREAD = 2;
14
+
15
+ /** The bytes as 8-bit RGBA: whatever PNG flavour the browser wrote, Bun re-encodes it to one. */
16
+ async function rasterOf(bytes: Uint8Array): Promise<Raster | null> {
17
+ try {
18
+ return decodeImage(await transformImageBytes(bytes, { format: 'png' }));
19
+ } catch {
20
+ // The caller's refusal is the report: bytes no decoder reads are "not an image", whichever
21
+ // `X_IMAGE_*` code the decoder named.
22
+ return null;
23
+ }
24
+ }
25
+
26
+ export interface BlankShot {
27
+ readonly reason: string;
28
+ /** No decoder read the bytes: the browser's fault, not the crop's. */
29
+ readonly undecodable: boolean;
30
+ }
31
+
32
+ /**
33
+ * Why the picture shows nothing, or `undefined` when it shows something. Three refusals: bytes no
34
+ * decoder reads, a crop with no opaque pixel, and a crop every pixel of which is one colour (within
35
+ * `BLANK_CHANNEL_SPREAD`). Anything with two colours in it — a border on a background, a glyph —
36
+ * passes, however few bytes it took.
37
+ */
38
+ export async function blankShotReason(bytes: Uint8Array): Promise<BlankShot | undefined> {
39
+ const raster = await rasterOf(bytes);
40
+ if (raster === null) {
41
+ return {
42
+ reason: `produced ${bytes.byteLength} bytes no image decoder reads — that is not an image`,
43
+ undecodable: true,
44
+ };
45
+ }
46
+ const { pixels, width, height } = raster;
47
+ const low = [255, 255, 255, 255];
48
+ const high = [0, 0, 0, 0];
49
+ for (let i = 0; i < pixels.length; i += 4) {
50
+ for (let c = 0; c < 4; c += 1) {
51
+ const value = pixels[i + c] ?? 0;
52
+ if (value < (low[c] ?? 0)) low[c] = value;
53
+ if (value > (high[c] ?? 0)) high[c] = value;
54
+ }
55
+ }
56
+ if ((high[3] ?? 0) === 0) {
57
+ return {
58
+ reason: `produced a ${width}x${height} picture every pixel of which is fully transparent`,
59
+ undecodable: false,
60
+ };
61
+ }
62
+ const spread = Math.max(...high.map((value, c) => value - (low[c] ?? 0)));
63
+ if (spread <= BLANK_CHANNEL_SPREAD) {
64
+ return {
65
+ reason: `produced a ${width}x${height} picture every pixel of which is one colour (rgba ${low.join(',')}) — nothing was painted in the crop`,
66
+ undecodable: false,
67
+ };
68
+ }
69
+ return undefined;
70
+ }
@@ -0,0 +1,96 @@
1
+ // Two captures compared, the shared half of `ui.diff` and `x shot --against`: decode both PNGs
2
+ // through `@ultimat3/core`'s raw-pixel seam, count what changed by `ui-diff.ts`'s rule, and encode the
3
+ // diff picture. No file paths and no error codes — each caller gates its own paths and sizes.
4
+
5
+ import type { Raster } from '@ultimat3/core';
6
+ import {
7
+ decodeImage,
8
+ encodeImage,
9
+ ImageUnsupportedError,
10
+ transformImageBytes,
11
+ } from '@ultimat3/core';
12
+ import type { UiInspectBox } from '@ultimat3/mcp';
13
+ import { changedPercent, diffPixels } from './ui-diff';
14
+
15
+ /**
16
+ * The seam reads 8-bit RGBA and nothing else. A PNG in any other shape — Chrome's RGB when the page
17
+ * is opaque, a palette from an optimiser — goes once through Bun's codecs, which always write the
18
+ * shape the seam reads. Only `imageUnsupported` is retried that way: a truncated file is a
19
+ * truncated file in either decoder.
20
+ */
21
+ export async function decodeCapture(bytes: Uint8Array): Promise<Raster> {
22
+ try {
23
+ return decodeImage(bytes);
24
+ } catch (error) {
25
+ if (!(error instanceof ImageUnsupportedError)) throw error;
26
+ return decodeImage(await transformImageBytes(bytes, { format: 'png' }));
27
+ }
28
+ }
29
+
30
+ /** Eight hex digits of the path's 64-bit hash: enough to keep two diffs of one `after` apart. */
31
+ export const hash8 = (text: string): string =>
32
+ Bun.hash(text).toString(16).padStart(16, '0').slice(0, 8);
33
+
34
+ /**
35
+ * `raster` on a `width`×`height` canvas, top-left, the rest transparent. A reference shot and a
36
+ * route shot are both full-page and almost never one height: the part only one of them covers is
37
+ * a difference, so it is compared as one rather than cropped away.
38
+ */
39
+ export function padRaster(raster: Raster, width: number, height: number): Raster {
40
+ if (raster.width === width && raster.height === height) return raster;
41
+ const pixels = new Uint8ClampedArray(width * height * 4);
42
+ const rows = Math.min(raster.height, height);
43
+ const rowBytes = Math.min(raster.width, width) * 4;
44
+ for (let y = 0; y < rows; y += 1) {
45
+ const from = y * raster.width * 4;
46
+ pixels.set(raster.pixels.subarray(from, from + rowBytes), y * width * 4);
47
+ }
48
+ return { width, height, pixels };
49
+ }
50
+
51
+ /** The unchanged share of the canvas, four decimals; an empty canvas is identical to itself. */
52
+ export function similarityOf(changed: number, width: number, height: number): number {
53
+ const total = width * height;
54
+ if (total === 0) return 1;
55
+ return Math.round((1 - changed / total) * 10_000) / 10_000;
56
+ }
57
+
58
+ export interface CaptureDiff {
59
+ readonly width: number;
60
+ readonly height: number;
61
+ readonly changedPixels: number;
62
+ readonly changedPercent: number;
63
+ readonly changedBox: UiInspectBox | null;
64
+ /** `1` is identical, `0` is every pixel changed. */
65
+ readonly similarity: number;
66
+ /** The diff picture: the faded `after` with every changed pixel red. */
67
+ readonly diffPng: Uint8Array;
68
+ }
69
+
70
+ /** Two decoded captures, compared on the larger of their two canvases. */
71
+ export function compareRasters(before: Raster, after: Raster, threshold: number): CaptureDiff {
72
+ const width = Math.max(before.width, after.width);
73
+ const height = Math.max(before.height, after.height);
74
+ const a = padRaster(before, width, height);
75
+ const b = padRaster(after, width, height);
76
+ const result = diffPixels(a.pixels, b.pixels, width, height, threshold);
77
+ return {
78
+ width,
79
+ height,
80
+ changedPixels: result.changedPixels,
81
+ changedPercent: changedPercent(result.changedPixels, width, height),
82
+ changedBox: result.changedBox,
83
+ similarity: similarityOf(result.changedPixels, width, height),
84
+ diffPng: encodeImage({ width, height, pixels: result.diffRgba }),
85
+ };
86
+ }
87
+
88
+ /** Two PNGs' bytes, decoded and compared. */
89
+ export async function compareCaptures(
90
+ before: Uint8Array,
91
+ after: Uint8Array,
92
+ threshold: number,
93
+ ): Promise<CaptureDiff> {
94
+ const [a, b] = await Promise.all([decodeCapture(before), decodeCapture(after)]);
95
+ return compareRasters(a, b, threshold);
96
+ }
package/src/shot-gpu.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  // The GPU backend the photographed page could reach, read from `navigator.gpu` inside the page.
2
+ // The same page is asked for WebGL2 beside it, because `@ultimat3/effects` picks its backend on it.
2
3
  // A WebGPU canvas that came out blank on a headless machine with no adapter is a fact about the
3
4
  // machine, not the app — and a picture alone cannot tell the two apart. Recorded, never gating.
4
5
 
@@ -7,6 +8,8 @@ import { t, validate } from '@ultimat3/schema';
7
8
  import type { JsonValue } from './output';
8
9
 
9
10
  export interface ShotGpu {
11
+ /** A `webgl2` context could be made on a canvas and was not lost — the shader tier of an effect. */
12
+ readonly webgl2: boolean;
10
13
  /** `navigator.gpu` exists — the browser exposes WebGPU at all. */
11
14
  readonly api: boolean;
12
15
  /** `requestAdapter()` answered an adapter: WebGPU is usable on this page, on this machine. */
@@ -24,17 +27,20 @@ export interface ShotGpu {
24
27
  * spell the flag `isFallbackAdapter` on the adapter, which is why both are read.
25
28
  */
26
29
  export const GPU_PROBE =
27
- '(async function(){var g=navigator.gpu;' +
28
- 'if(!g)return{api:false,available:false,adapter:null,fallback:false};var a=null;' +
30
+ '(async function(){var w=false;' +
31
+ 'try{var c=document.createElement("canvas").getContext("webgl2");' +
32
+ 'w=!!c&&!c.isContextLost();}catch(e){w=false;}var g=navigator.gpu;' +
33
+ 'if(!g)return{api:false,webgl2:w,available:false,adapter:null,fallback:false};var a=null;' +
29
34
  'try{a=await Promise.race([g.requestAdapter(),' +
30
35
  'new Promise(function(r){setTimeout(function(){r(null);},2000);})]);}catch(e){a=null;}' +
31
- 'if(!a)return{api:true,available:false,adapter:null,fallback:false};var i=a.info||{};' +
36
+ 'if(!a)return{api:true,webgl2:w,available:false,adapter:null,fallback:false};var i=a.info||{};' +
32
37
  'var n=[i.vendor,i.architecture,i.device,i.description].filter(function(s){return !!s;})' +
33
- '.join(" ");return{api:true,available:true,adapter:n===""?null:n,' +
38
+ '.join(" ");return{api:true,webgl2:w,available:true,adapter:n===""?null:n,' +
34
39
  'fallback:!!(a.isFallbackAdapter||i.isFallbackAdapter)};})()';
35
40
 
36
41
  const gpuProbeSchema: StandardSchemaV1<unknown, ShotGpu> = t.object({
37
42
  api: t.boolean,
43
+ webgl2: t.boolean,
38
44
  available: t.boolean,
39
45
  adapter: t.nullable(t.string),
40
46
  fallback: t.boolean,
@@ -58,4 +64,10 @@ export const readShotGpu = (page: {
58
64
  export const gpuJson = (gpu: ShotGpu | null | undefined): JsonValue =>
59
65
  gpu === null || gpu === undefined
60
66
  ? null
61
- : { api: gpu.api, available: gpu.available, adapter: gpu.adapter, fallback: gpu.fallback };
67
+ : {
68
+ api: gpu.api,
69
+ webgl2: gpu.webgl2,
70
+ available: gpu.available,
71
+ adapter: gpu.adapter,
72
+ fallback: gpu.fallback,
73
+ };
@@ -0,0 +1,84 @@
1
+ // The module a split locale's directory holds beside its namespace files: each file imported and
2
+ // set at the key path its name stands for, so `packages/i18n/src/index.ts` imports one locale as
3
+ // one object and `typeof` it is still the typed key space. Derived from the file list alone, so
4
+ // every writer re-derives it and none can drift from another.
5
+
6
+ import { catalogFilePrefix } from '@ultimat3/i18n';
7
+ import { pascal } from './naming';
8
+
9
+ /** The export every barrel declares — `import { catalog as en } from '../catalogs/en'`. */
10
+ export const BARREL_EXPORT = 'catalog';
11
+
12
+ interface Node {
13
+ binding?: string;
14
+ readonly children: Map<string, Node>;
15
+ }
16
+
17
+ const IDENTIFIER = /^[A-Za-z_$][\w$]*$/;
18
+
19
+ /** `'my-ns'` where a segment is not an identifier; bare where it is, as Biome formats it. */
20
+ const property = (segment: string): string => (IDENTIFIER.test(segment) ? segment : `'${segment}'`);
21
+
22
+ /**
23
+ * One binding per file, `ns` + its prefix in PascalCase: `site/home.json` → `nsSiteHome`. The
24
+ * prefix keeps every binding clear of a reserved word (`default.json`, `new.json`) and of a leading
25
+ * digit (`404.json`); a second file reshaped to the same name takes a counter.
26
+ */
27
+ function bindingsOf(prefixes: readonly string[]): ReadonlyMap<string, string> {
28
+ const taken = new Set<string>();
29
+ const bindings = new Map<string, string>();
30
+ for (const prefix of prefixes) {
31
+ const base = `ns${pascal(prefix.replaceAll('.', '-'))}`;
32
+ let binding = base;
33
+ for (let n = 2; taken.has(binding); n += 1) binding = `${base}${n}`;
34
+ taken.add(binding);
35
+ bindings.set(prefix, binding);
36
+ }
37
+ return bindings;
38
+ }
39
+
40
+ /** A node as an expression: a file alone is its binding; children make an expanded object. */
41
+ function render(node: Node, indent: string): string {
42
+ if (node.children.size === 0) return node.binding ?? '{}';
43
+ const inner = `${indent} `;
44
+ const lines = node.binding === undefined ? [] : [`${inner}...${node.binding},`];
45
+ for (const [segment, child] of node.children) {
46
+ lines.push(`${inner}${property(segment)}: ${render(child, inner)},`);
47
+ }
48
+ return `{\n${lines.join('\n')}\n${indent}}`;
49
+ }
50
+
51
+ /**
52
+ * The barrel for a locale directory holding `files` (names relative to it: `billing.json`,
53
+ * `site/home.json`). Imports in file-name order — Biome's import sort is told to leave them, as
54
+ * it puts `site/home.json` before `site.json` by a rule no writer here restates — and every object
55
+ * expanded one entry per line: the shape Biome's formatter keeps, and the one `x merge-driver`
56
+ * merges when two branches each add a namespace.
57
+ */
58
+ export function catalogBarrel(files: readonly string[]): string {
59
+ const names = [...new Set(files)].sort();
60
+ const prefixes = names.map(catalogFilePrefix);
61
+ const bindings = bindingsOf(prefixes);
62
+ const root: Node = { children: new Map() };
63
+ for (const prefix of [...prefixes].sort()) {
64
+ let node = root;
65
+ for (const segment of prefix.split('.')) {
66
+ const child = node.children.get(segment) ?? { children: new Map() };
67
+ node.children.set(segment, child);
68
+ node = child;
69
+ }
70
+ const binding = bindings.get(prefix);
71
+ if (binding !== undefined) node.binding = binding;
72
+ }
73
+ const imports = names.map((name, index) => {
74
+ const prefix = prefixes[index] ?? '';
75
+ return `import ${bindings.get(prefix) ?? ''} from './${name}';`;
76
+ });
77
+ const block = imports.length === 0 ? '' : `${imports.join('\n')}\n\n`;
78
+ return `// Generated from the namespace files beside it — never hand-edited: \`bunx x i18n split\` and
79
+ // every x i18n command re-derive it. Each file sits at the key path its name stands for.
80
+ // biome-ignore-all assist/source/organizeImports: in file-name order, the order every writer derives
81
+
82
+ ${block}export const ${BARREL_EXPORT} = ${render(root, '')};
83
+ `;
84
+ }
@@ -0,0 +1,173 @@
1
+ // The `animated-layout-script` guard: `animated-layout-property`'s rule for TypeScript. A layout
2
+ // property handed to `.animate(` costs a layout or paint pass per frame; a box that must move
3
+ // through the layout is `layout()` from `@ultimat3/ui/motion`. A guard of its own, REPORT ONLY
4
+ // (`severity: 'warning'`), because `animated-layout-property` gates and a stricter rule on `main`
5
+ //
6
+ // is a break; `x new` writes the `"error"` row.
7
+
8
+ import { guardCode } from './guard';
9
+ import { TS_ANIMATE_SCAN_SOURCE } from './guard-raw-motion-ts-scan';
10
+ import type { GeneratedFile } from './naming';
11
+
12
+ /** Derived from the guard's name, never a literal: an `X_*` literal here is a FRAMEWORK code. */
13
+ const NAME = 'animated-layout-script';
14
+ const CODE = guardCode(NAME);
15
+
16
+ const source =
17
+ (): string => `// animated-layout-script: an animation moves transform and opacity, never the layout.
18
+ // \`x verify\` discovers every file in \`guards/\` and runs its \`guard\` inside the \`boundaries\`
19
+ // step — nothing registers this file, so nothing can forget to. Delete it to drop the rule.
20
+ //
21
+ // Read: a layout property (\`width\`, \`marginLeft\`, \`'box-shadow'\`) as a KEY of the keyframes a
22
+ // \`.animate(\` call is given (its first argument), in a script outside tests. REPORT ONLY (\`severity: 'warning'\`).
23
+
24
+ import type { Finding, Guard } from '@ultimat3/cli';
25
+
26
+ /** The app owns the codes its own conventions raise — this one is named for the guard. */
27
+ const CODE = '${CODE}';
28
+
29
+ /** What each layout property should have been, so the fix is an edit and not a category. */
30
+ const INSTEAD = new Map([
31
+ ['top', 'transform: translateY(…)'],
32
+ ['bottom', 'transform: translateY(…)'],
33
+ ['left', 'transform: translateX(…)'],
34
+ ['right', 'transform: translateX(…)'],
35
+ ['inset', 'transform: translate(…)'],
36
+ ['width', 'transform: scaleX(…)'],
37
+ ['height', 'transform: scaleY(…)'],
38
+ ['box-shadow', 'opacity on a shadow layer that is already painted'],
39
+ ]);
40
+
41
+ /** A property whose change the browser cannot composite: it re-lays-out or re-paints the frame. */
42
+ const isLayoutProperty = (property: string): boolean =>
43
+ INSTEAD.has(property) ||
44
+ property.startsWith('margin') ||
45
+ property.startsWith('padding') ||
46
+ /^(?:min|max)-(?:width|height)$/.test(property);
47
+
48
+ ${TS_ANIMATE_SCAN_SOURCE}
49
+ /**
50
+ * A keyframe key: \`width\`, \`'margin-left'\`, \`marginLeft\` — spelled either way in a script, and
51
+ * only in KEY position (after \`{\` or \`,\`): \`up ? top : bottom\` is a value, not a key.
52
+ */
53
+ const KEYFRAME_KEY = /(?<=[{,]\\s*)(['"]?)([A-Za-z][\\w-]*)\\1\\s*:(?!:)/g;
54
+
55
+ /** The text up to a call's first top-level comma: the keyframes, never the options object. */
56
+ const firstArgument = (body: string): string => {
57
+ let depth = 0;
58
+ let quote = '';
59
+ for (let i = 0; i < body.length; i += 1) {
60
+ const ch = body[i] ?? '';
61
+ if (quote !== '') {
62
+ if (ch === '\\\\') i += 1;
63
+ else if (ch === quote) quote = '';
64
+ } else if (ch === "'" || ch === '"' || ch === '\`') quote = ch;
65
+ else if ('([{'.includes(ch)) depth += 1;
66
+ else if (')]}'.includes(ch)) depth -= 1;
67
+ else if (ch === ',' && depth === 0) return body.slice(0, i);
68
+ }
69
+ return body;
70
+ };
71
+
72
+ /** Whether \`index\` sits inside a string literal; a quoted key's opening quote does not. */
73
+ const insideString = (text: string, index: number): boolean => {
74
+ let quote = '';
75
+ for (let i = 0; i < index; i += 1) {
76
+ const ch = text[i] ?? '';
77
+ if (quote !== '') {
78
+ if (ch === '\\\\') i += 1;
79
+ else if (ch === quote) quote = '';
80
+ } else if (ch === "'" || ch === '"' || ch === '\`') quote = ch;
81
+ }
82
+ return quote !== '';
83
+ };
84
+ const kebab = (key: string): string => key.replaceAll(/[A-Z]/g, (ch) => \`-\${ch.toLowerCase()}\`);
85
+
86
+ /** Pure — the caller does the I/O — so the rule is testable without a filesystem. */
87
+ export function animatedLayoutScripts(files: readonly ScriptFile[]): readonly Finding[] {
88
+ const findings: Finding[] = [];
89
+ for (const file of files) {
90
+ if (!isAppScript(file.path)) continue;
91
+ const text = blankScriptComments(file.source);
92
+ for (const call of animateCalls(text)) {
93
+ const keyframes = firstArgument(call.body);
94
+ for (const match of keyframes.matchAll(KEYFRAME_KEY)) {
95
+ if (insideString(keyframes, match.index)) continue;
96
+ const property = kebab(match[2] ?? '');
97
+ if (!isLayoutProperty(property)) continue;
98
+ const at = \`\${file.path}:\${scriptLineOf(text, call.start + match.index)}\`;
99
+ findings.push({
100
+ code: CODE,
101
+ cause: \`\${at} animates \${property} in a keyframe object — only transform and opacity are compositor-only, so every frame of this costs a full layout or paint pass on the same main thread the app runs on\`,
102
+ fix: \`animate the box with layout() — import { layout } from '@ultimat3/ui/motion' — or \${INSTEAD.get(property) ?? 'transform or opacity'} instead of \${property} at \${at}, then: x verify --only boundaries\`,
103
+ at,
104
+ });
105
+ }
106
+ }
107
+ }
108
+ return findings;
109
+ }
110
+
111
+ export const guard: Guard = {
112
+ summary: 'a script animation moves transform and opacity, never the layout',
113
+ severity: 'warning',
114
+ async check(_root, sources) {
115
+ const scripts = await sources.files('{apps,packages}/**/*.{ts,tsx}');
116
+ return animatedLayoutScripts(scripts.map((file) => ({ path: file.path, source: file.text })));
117
+ },
118
+ };
119
+ `;
120
+
121
+ const test =
122
+ (): string => `// The rule, driven directly. Failure case first: a guard whose rule silently stopped matching is
123
+ // a green gate over the convention it was written to enforce.
124
+
125
+ import { expect, unitTest } from '@ultimat3/testing';
126
+ import { animatedLayoutScripts } from './animated-layout-script';
127
+
128
+ const script = (source: string) => [{ path: 'apps/web/app/feed/card.island.tsx', source }];
129
+
130
+ unitTest('a layout key in .animate( is refused in any spelling, and layout() is named', () => {
131
+ const findings = animatedLayoutScripts(
132
+ script('el.animate({ width: [0], marginLeft: 4, "box-shadow": x }, { duration: t });'),
133
+ );
134
+ expect(findings).toHaveLength(3);
135
+ expect(findings[0]?.code).toBe('${CODE}');
136
+ expect(findings[0]?.fix).toStartWith('animate the box with layout() — ');
137
+ expect(findings[0]?.at).toBe('apps/web/app/feed/card.island.tsx:1');
138
+ });
139
+
140
+ unitTest('only keyframe keys count: values, strings and the options object are silent', () => {
141
+ const silent = [
142
+ 'el.animate({ transform: up ? top : bottom }, { duration: t });',
143
+ "el.animate({ id: 'width: grow' }, { duration: t });",
144
+ 'el.animate({ opacity: 1 }, { duration: t, top: 1, width: 2 });',
145
+ "el.animate({ label: 'a, left: 1' }, o);",
146
+ ];
147
+ for (const source of silent) expect(animatedLayoutScripts(script(source))).toEqual([]);
148
+ const array = script('el.animate([{ left: 0 }, { left: 9 }], { duration: t });');
149
+ expect(animatedLayoutScripts(array)).toHaveLength(2);
150
+ });
151
+
152
+ unitTest('a comment-like string does not hide the call after it', () => {
153
+ const source = "const g = 'dist/*'; el.animate({ width: 1 }, o); /** doc */";
154
+ expect(animatedLayoutScripts(script(source))).toHaveLength(1);
155
+ });
156
+
157
+ unitTest('transform, opacity, other calls, a comment and a test file are silent', () => {
158
+ expect(
159
+ animatedLayoutScripts(script('el.animate({ transform: "none" }, { duration: t });')),
160
+ ).toEqual([]);
161
+ expect(animatedLayoutScripts(script('place({ width: 10, left: 4 });'))).toEqual([]);
162
+ expect(animatedLayoutScripts(script('// el.animate({ width: 1 });'))).toEqual([]);
163
+ expect(
164
+ animatedLayoutScripts([{ path: 'apps/web/card.test.ts', source: 'el.animate({ width: 1 });' }]),
165
+ ).toEqual([]);
166
+ });
167
+ `;
168
+
169
+ /** `guards/animated-layout-script.ts` and its test. The directory registers it. */
170
+ export const animatedLayoutScriptGuardFiles = (): readonly GeneratedFile[] => [
171
+ { path: `guards/${NAME}.ts`, contents: source() },
172
+ { path: `guards/${NAME}.test.ts`, contents: test() },
173
+ ];