@ultimat3/cli 31.52.0 → 31.53.1

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 (111) hide show
  1. package/CLAUDE.md +1 -1
  2. package/package.json +29 -29
  3. package/src/app-kit-disk.ts +39 -0
  4. package/src/app-kit-forms.ts +27 -0
  5. package/src/app-kit.ts +146 -0
  6. package/src/budgets.ts +3 -1
  7. package/src/cdp-shot-driver-screen.ts +72 -0
  8. package/src/cdp-shot-driver.ts +17 -1
  9. package/src/cmd-design-capture.ts +210 -0
  10. package/src/cmd-design-errors.ts +50 -0
  11. package/src/cmd-design-paths.ts +47 -0
  12. package/src/cmd-design-publish.ts +64 -0
  13. package/src/cmd-design-run.ts +229 -0
  14. package/src/cmd-design-spec.ts +47 -0
  15. package/src/cmd-design-theme.ts +107 -0
  16. package/src/cmd-design-url.ts +201 -0
  17. package/src/cmd-design.ts +188 -0
  18. package/src/cmd-doctor.ts +3 -0
  19. package/src/cmd-generate-spec.ts +5 -0
  20. package/src/cmd-generate.ts +3 -1
  21. package/src/cmd-kit-spec.ts +13 -0
  22. package/src/cmd-kit.ts +133 -0
  23. package/src/cmd-shot-against.ts +275 -0
  24. package/src/cmd-shot-spec.ts +9 -1
  25. package/src/cmd-shot.ts +19 -0
  26. package/src/cmd-upgrade.ts +11 -0
  27. package/src/codemods/agent-kit.ts +130 -0
  28. package/src/codemods/agents-md-budget.ts +47 -0
  29. package/src/codemods/docs-visual-quality.ts +198 -0
  30. package/src/codemods/index.ts +8 -0
  31. package/src/codemods/settings-kit-allow.ts +49 -0
  32. package/src/design-extract-script.ts +187 -0
  33. package/src/design-extract.ts +311 -0
  34. package/src/design-map-colors.ts +180 -0
  35. package/src/design-map.ts +288 -0
  36. package/src/doctor-kit.ts +25 -0
  37. package/src/error-catalog.ts +4 -2
  38. package/src/error-codes-kit.ts +24 -0
  39. package/src/error-codes.ts +12 -10
  40. package/src/generate-files.ts +31 -1
  41. package/src/guards-shipped-names.ts +5 -0
  42. package/src/kit/agent-audit.ts +56 -0
  43. package/src/kit/agent-data.ts +32 -0
  44. package/src/kit/agent-server.ts +34 -0
  45. package/src/kit/agent-shape.ts +61 -0
  46. package/src/kit/agent-web.ts +49 -0
  47. package/src/kit/design-map.ts +106 -0
  48. package/src/kit/managed.ts +12 -0
  49. package/src/kit/registry.ts +89 -0
  50. package/src/kit/skill-design-research.ts +119 -0
  51. package/src/kit/skill-feature.ts +166 -0
  52. package/src/kit/skill-planx.ts +140 -0
  53. package/src/kit/skill-upgrade.ts +94 -0
  54. package/src/kit/skill-verify.ts +80 -0
  55. package/src/mcp-errors.ts +5 -0
  56. package/src/mcp-ui-diff.ts +13 -38
  57. package/src/mcp-ui.ts +30 -1
  58. package/src/messages-design.ts +104 -0
  59. package/src/messages-upgrade.ts +9 -0
  60. package/src/messages.ts +2 -0
  61. package/src/registry.ts +4 -0
  62. package/src/shot-diff.ts +96 -0
  63. package/src/shot-gpu.ts +17 -5
  64. package/src/templates/guard-animated-layout-script.ts +173 -0
  65. package/src/templates/guard-effect-without-fallback.ts +117 -0
  66. package/src/templates/guard-motion-adapter.ts +161 -0
  67. package/src/templates/guard-raw-frame-loop.ts +134 -0
  68. package/src/templates/guard-raw-motion-script.ts +132 -0
  69. package/src/templates/guard-raw-motion-ts-scan.ts +95 -0
  70. package/src/templates/guard-released-forms.ts +10 -0
  71. package/src/templates/index.ts +1 -2
  72. package/src/templates/island.ts +55 -8
  73. package/src/templates/kit-released-forms.ts +64 -0
  74. package/src/templates/motion-scale.ts +115 -0
  75. package/src/templates/scaffold-claude.ts +39 -26
  76. package/src/templates/scaffold-design.ts +41 -0
  77. package/src/templates/scaffold-docs.ts +31 -7
  78. package/src/templates/scaffold-guards.ts +31 -2
  79. package/src/templates/scaffold-verify-floor.ts +3 -0
  80. package/src/templates/shapes/blog-site.ts +15 -0
  81. package/src/templates/shapes/blog.ts +2 -0
  82. package/src/templates/shapes/content-site.ts +13 -0
  83. package/src/templates/shapes/content.ts +2 -0
  84. package/src/templates/shapes/dashboard-detail.ts +2 -0
  85. package/src/templates/shapes/dashboard-motion.ts +284 -0
  86. package/src/templates/shapes/dashboard.ts +19 -1
  87. package/src/templates/shapes/landing-motion.ts +67 -0
  88. package/src/templates/shapes/saas.ts +4 -0
  89. package/src/upgrade-gate.ts +14 -2
  90. package/src/upgrade-kit.ts +65 -0
  91. package/src/upgrade-report-kit.ts +28 -0
  92. package/src/upgrade-report.ts +3 -0
  93. package/src/verify-checks.ts +9 -1
  94. package/src/workspace-checks.ts +3 -3
  95. package/wiki/Agents.md +33 -1
  96. package/wiki/CLI-Reference-Tools.md +24 -3
  97. package/wiki/CLI-Reference.md +4 -2
  98. package/wiki/Design-Research.md +96 -0
  99. package/wiki/Effects.md +83 -0
  100. package/wiki/FAQ.md +1 -1
  101. package/wiki/Getting-Started.md +1 -1
  102. package/wiki/Home.md +2 -2
  103. package/wiki/Known-Gaps.md +3 -2
  104. package/wiki/MCP-And-AI.md +4 -0
  105. package/wiki/Motion.md +85 -0
  106. package/wiki/Project-Layout.md +1 -1
  107. package/wiki/Tutorial-02-First-Feature.md +1 -1
  108. package/wiki/UI-Components.md +2 -0
  109. package/wiki/Upgrading.md +4 -2
  110. package/src/templates/scaffold-claude-agents.ts +0 -161
  111. package/src/templates/scaffold-claude-commands.ts +0 -239
@@ -0,0 +1,288 @@
1
+ // A reference's measurements as framework vocabulary: `tokens.proposal.json` (a `defineTheme`
2
+ // argument) and `motion-map.json` (each animation as a `@ultimat3/ui/motion` call or effects entry).
3
+ //
4
+ // Durations and easings snap through the motion scale the shipped guards use
5
+ // (`templates/motion-scale.ts`), so research and the gate agree on what "base" means. Pure.
6
+
7
+ import type { Extraction, ObservedMotion } from './design-extract';
8
+ import {
9
+ clusterPalette,
10
+ type PaletteCluster,
11
+ proposeColors,
12
+ type ThemeTables,
13
+ withNearestRoles,
14
+ } from './design-map-colors';
15
+ import type { DurationToken, EasingToken } from './templates/motion-scale';
16
+ import { snapDuration, snapEasing } from './templates/motion-scale';
17
+
18
+ export type { PaletteCluster, ThemeTables } from './design-map-colors';
19
+ export { clusterPalette } from './design-map-colors';
20
+
21
+ /**
22
+ * `@ultimat3/ui`'s radius rungs in px, the ones a measured corner can mean. Not imported: the CLI
23
+ * does not depend on `@ultimat3/ui`, and its barrel exports no radius table. `design-map.test.ts`
24
+ * holds these to the canonical `_radius.scss`.
25
+ */
26
+ export const RADIUS_RUNGS = { sm: 4, md: 8, lg: 12, xl: 16 } as const;
27
+ type RadiusRung = keyof typeof RADIUS_RUNGS;
28
+
29
+ /** The `defineTheme` argument `tokens.proposal.json` holds. */
30
+ export interface DesignProposal {
31
+ readonly colors?: {
32
+ readonly light?: Record<string, string>;
33
+ readonly dark?: Record<string, string>;
34
+ };
35
+ readonly radius?: Partial<Record<RadiusRung, string>>;
36
+ readonly motion?: MotionProposal;
37
+ }
38
+
39
+ export interface MotionProposal {
40
+ readonly duration?: Partial<Record<Exclude<DurationToken, 'instant'>, string>>;
41
+ readonly easing?: Partial<Record<EasingToken, string>>;
42
+ }
43
+
44
+ /** Corners past a rung's reach (a pill, a circle) are not a radius scale. */
45
+ const RADIUS_MAX = 64;
46
+
47
+ export function proposeRadius(
48
+ radii: readonly { readonly px: number; readonly count: number }[],
49
+ ): Partial<Record<RadiusRung, string>> {
50
+ const best = new Map<RadiusRung, { px: number; count: number }>();
51
+ for (const radius of radii) {
52
+ if (radius.px <= 0 || radius.px > RADIUS_MAX) continue;
53
+ let rung: RadiusRung = 'sm';
54
+ let gap = Number.POSITIVE_INFINITY;
55
+ for (const [name, px] of Object.entries(RADIUS_RUNGS) as [RadiusRung, number][]) {
56
+ if (Math.abs(px - radius.px) < gap) {
57
+ rung = name;
58
+ gap = Math.abs(px - radius.px);
59
+ }
60
+ }
61
+ const held = best.get(rung);
62
+ if (held === undefined || radius.count > held.count) best.set(rung, radius);
63
+ }
64
+ return Object.fromEntries([...best].map(([rung, radius]) => [rung, `${String(radius.px)}px`]));
65
+ }
66
+
67
+ /** CSS's easing keywords as the control points they are. */
68
+ /** A Map: the key is a page's easing string, and `'constructor'` must miss, not hit a prototype. */
69
+ const KEYWORD_CURVES: ReadonlyMap<string, readonly number[]> = new Map([
70
+ ['ease', [0.25, 0.1, 0.25, 1]],
71
+ ['ease-in', [0.42, 0, 1, 1]],
72
+ ['ease-out', [0, 0, 0.58, 1]],
73
+ ['ease-in-out', [0.42, 0, 0.58, 1]],
74
+ ]);
75
+
76
+ /** A curve's four control points, or `undefined` for `linear`, `steps()`, `linear()` and `other`. */
77
+ export function easingPoints(easing: string): readonly number[] | undefined {
78
+ const keyword = KEYWORD_CURVES.get(easing);
79
+ if (keyword !== undefined) return keyword;
80
+ const match = /^cubic-bezier\(([^)]*)\)$/.exec(easing);
81
+ if (match === null) return undefined;
82
+ const points = (match[1] ?? '').split(',').map((part) => Number(part.trim()));
83
+ return points.length === 4 && points.every(Number.isFinite) ? points : undefined;
84
+ }
85
+
86
+ /** A `linear()` with many stops is how a spring is written in CSS. */
87
+ const isSpring = (easing: string): boolean =>
88
+ easing.startsWith('linear(') && easing.split(',').length >= 4;
89
+
90
+ const curveText = (points: readonly number[]): string => `cubic-bezier(${points.join(', ')})`;
91
+
92
+ /** How far a curve may overshoot: past it a `y` is a page's typo or a probe, not a tempo. */
93
+ const CURVE_Y_LIMIT = 10;
94
+ const PLAIN_DECIMAL = /^-?\d+(?:\.\d+)?$/;
95
+
96
+ /**
97
+ * A curve `defineTheme` will take as written: x values in [0, 1], every point a plain decimal (a
98
+ * page's `1.23e+23` prints as exponent notation, which no CSS curve pattern accepts) and no `y`
99
+ * past `CURVE_Y_LIMIT`. Anything else is dropped from the proposal, never repaired.
100
+ */
101
+ const isProposableCurve = (points: readonly number[]): boolean => {
102
+ const [x1, y1, x2, y2] = points;
103
+ if (x1 === undefined || y1 === undefined || x2 === undefined || y2 === undefined) return false;
104
+ if (x1 < 0 || x1 > 1 || x2 < 0 || x2 > 1) return false;
105
+ if (Math.abs(y1) > CURVE_Y_LIMIT || Math.abs(y2) > CURVE_Y_LIMIT) return false;
106
+ return points.every((point) => PLAIN_DECIMAL.test(String(point)));
107
+ };
108
+
109
+ /** The weighted median: what most of the page actually waits. */
110
+ function median(values: readonly { readonly value: number; readonly weight: number }[]): number {
111
+ const sorted = [...values].sort((a, b) => a.value - b.value);
112
+ const half = sorted.reduce((sum, entry) => sum + entry.weight, 0) / 2;
113
+ let seen = 0;
114
+ for (const entry of sorted) {
115
+ seen += entry.weight;
116
+ if (seen >= half) return entry.value;
117
+ }
118
+ return sorted.at(-1)?.value ?? 0;
119
+ }
120
+
121
+ /**
122
+ * The tempo: each rung the page's durations snap to, set to their weighted median; each easing
123
+ * token, set to the curve the page used most for it. A loop's period is not a tempo, and a curve
124
+ * whose x values leave [0, 1] is one CSS — and `defineTheme` — refuses.
125
+ */
126
+ export function proposeMotion(motion: readonly ObservedMotion[]): MotionProposal {
127
+ const timed = motion.filter((m) => m.trigger !== 'loop' && m.durationMs > 0);
128
+ const durations = new Map<string, { value: number; weight: number }[]>();
129
+ const curves = new Map<string, Map<string, number>>();
130
+ for (const m of timed) {
131
+ const rung = snapDuration(m.durationMs);
132
+ durations.set(rung, [...(durations.get(rung) ?? []), { value: m.durationMs, weight: m.count }]);
133
+ const points = easingPoints(m.easing);
134
+ if (points === undefined) continue;
135
+ if (!isProposableCurve(points)) continue;
136
+ const token = snapEasing(points);
137
+ const text = curveText(points);
138
+ const counts = curves.get(token) ?? new Map<string, number>();
139
+ counts.set(text, (counts.get(text) ?? 0) + m.count);
140
+ curves.set(token, counts);
141
+ }
142
+ const duration = Object.fromEntries(
143
+ [...durations].map(([rung, values]) => [rung, `${String(Math.round(median(values)))}ms`]),
144
+ );
145
+ const easing = Object.fromEntries(
146
+ [...curves].map(([token, counts]) => [
147
+ token,
148
+ [...counts].sort((a, b) => b[1] - a[1])[0]?.[0] ?? '',
149
+ ]),
150
+ );
151
+ return {
152
+ ...(Object.keys(duration).length === 0 ? {} : { duration }),
153
+ ...(Object.keys(easing).length === 0 ? {} : { easing }),
154
+ };
155
+ }
156
+
157
+ export interface MotionMapEntry {
158
+ readonly module: '@ultimat3/ui/motion' | '@ultimat3/effects';
159
+ /** A name the module exports — `animate`, `inView`, `Marquee`, … */
160
+ readonly name: string;
161
+ readonly observed: (Omit<ObservedMotion, 'count'> & { readonly count: number }) | null;
162
+ readonly duration?: Exclude<DurationToken, 'instant'> | undefined;
163
+ readonly easing?: EasingToken | undefined;
164
+ readonly why: string;
165
+ }
166
+
167
+ const LAYOUT_PROPERTIES = new Set([
168
+ 'width',
169
+ 'height',
170
+ 'top',
171
+ 'left',
172
+ 'right',
173
+ 'bottom',
174
+ 'margin',
175
+ 'padding',
176
+ ]);
177
+
178
+ function entryFor(m: ObservedMotion): Omit<MotionMapEntry, 'observed' | 'duration' | 'easing'> {
179
+ if (isSpring(m.easing)) {
180
+ return {
181
+ module: '@ultimat3/ui/motion',
182
+ name: 'springLinear',
183
+ why: 'a linear() curve is a spring',
184
+ };
185
+ }
186
+ if (m.trigger === 'loop') {
187
+ const marquee = m.properties.some((p) => p === 'transform' || p.startsWith('translate'));
188
+ return marquee
189
+ ? { module: '@ultimat3/effects', name: 'Marquee', why: 'an endless transform is a marquee' }
190
+ : { module: '@ultimat3/effects', name: 'Shimmer', why: 'an endless paint loop is a shimmer' };
191
+ }
192
+ if (m.trigger === 'scroll') {
193
+ return m.durationMs === 0
194
+ ? { module: '@ultimat3/ui/motion', name: 'scrollLinked', why: 'driven by a scroll timeline' }
195
+ : { module: '@ultimat3/ui/motion', name: 'inView', why: 'started as it scrolled into view' };
196
+ }
197
+ if (m.properties.some((p) => LAYOUT_PROPERTIES.has(p))) {
198
+ return {
199
+ module: '@ultimat3/ui/motion',
200
+ name: 'layout',
201
+ why: 'animates a layout property: FLIP it with transforms instead',
202
+ };
203
+ }
204
+ if (m.trigger === 'hover' || m.trigger === 'state') {
205
+ return {
206
+ module: '@ultimat3/ui/motion',
207
+ name: 'motionTiming',
208
+ why: `a ${m.trigger} transition`,
209
+ };
210
+ }
211
+ return { module: '@ultimat3/ui/motion', name: 'animate', why: 'an entrance animation' };
212
+ }
213
+
214
+ /** Every distinct observed animation, then the effects the page's paint implies. */
215
+ export function motionMap(extraction: Extraction): MotionMapEntry[] {
216
+ const entries: MotionMapEntry[] = extraction.motion.map((m) => {
217
+ const points = easingPoints(m.easing);
218
+ return {
219
+ ...entryFor(m),
220
+ observed: m,
221
+ ...(m.durationMs > 0 && m.trigger !== 'loop' ? { duration: snapDuration(m.durationMs) } : {}),
222
+ ...(points === undefined ? {} : { easing: snapEasing(points) }),
223
+ };
224
+ });
225
+ if (extraction.backdrop.count > 0) {
226
+ entries.push({
227
+ module: '@ultimat3/effects',
228
+ name: 'GlassSurface',
229
+ observed: null,
230
+ why: `${String(extraction.backdrop.count)} element(s) use backdrop-filter`,
231
+ });
232
+ }
233
+ if (extraction.canvases > 0) {
234
+ entries.push({
235
+ module: '@ultimat3/effects',
236
+ name: 'EffectCanvas',
237
+ observed: null,
238
+ why: `${String(extraction.canvases)} visible canvas element(s) — a drawn background`,
239
+ });
240
+ }
241
+ return entries;
242
+ }
243
+
244
+ export interface DesignMapping {
245
+ readonly proposal: DesignProposal;
246
+ readonly palette: { readonly light: PaletteCluster[]; readonly dark: PaletteCluster[] };
247
+ readonly motionMap: MotionMapEntry[];
248
+ }
249
+
250
+ /**
251
+ * Both schemes' captures as one mapping. Colours need `tables` — without them (no `@ultimat3/ui`
252
+ * to resolve) the proposal carries no colours, because nothing could check their contrast.
253
+ */
254
+ export function mapDesign(
255
+ captures: { readonly light: Extraction; readonly dark: Extraction },
256
+ tables: ThemeTables | undefined,
257
+ ): DesignMapping {
258
+ const palette = {
259
+ light: clusterPalette(captures.light.colors),
260
+ dark: clusterPalette(captures.dark.colors),
261
+ };
262
+ const light = tables === undefined ? {} : proposeColors(palette.light, 'light', tables);
263
+ const dark = tables === undefined ? {} : proposeColors(palette.dark, 'dark', tables);
264
+ const colors = {
265
+ ...(Object.keys(light).length === 0 ? {} : { light }),
266
+ ...(Object.keys(dark).length === 0 ? {} : { dark }),
267
+ };
268
+ const radius = proposeRadius([...captures.light.radii, ...captures.dark.radii]);
269
+ const motion = proposeMotion(captures.light.motion);
270
+ return {
271
+ proposal: {
272
+ ...(Object.keys(colors).length === 0 ? {} : { colors }),
273
+ ...(Object.keys(radius).length === 0 ? {} : { radius }),
274
+ ...(Object.keys(motion).length === 0 ? {} : { motion }),
275
+ },
276
+ palette: {
277
+ light:
278
+ tables === undefined
279
+ ? palette.light.slice(0, 16)
280
+ : withNearestRoles(palette.light, 'light', tables),
281
+ dark:
282
+ tables === undefined
283
+ ? palette.dark.slice(0, 16)
284
+ : withNearestRoles(palette.dark, 'dark', tables),
285
+ },
286
+ motionMap: motionMap(captures.light),
287
+ };
288
+ }
@@ -0,0 +1,25 @@
1
+ // `x doctor`'s agent-kit fact: the managed skills and agents against the disk (`app-kit.ts`), as
2
+ // warnings with the fix. Never the verdict — `x verify` is where the kit is an error, and only once
3
+ // `.claude/kit.json` has opted the app in (`X_BREAKING_ON_MAIN`).
4
+
5
+ import { ERROR_DOCS_URL } from '@ultimat3/core';
6
+ import { KIT_FIX } from './app-kit';
7
+ import { kitVerdict } from './app-kit-disk';
8
+ import { KIT_MARKER } from './kit/registry';
9
+ import type { Finding } from './output';
10
+
11
+ export async function kitWarnings(root: string): Promise<readonly Finding[]> {
12
+ const verdict = await kitVerdict(root);
13
+ return [
14
+ ...verdict.findings,
15
+ ...verdict.warnings.map(
16
+ (cause): Finding => ({
17
+ code: 'X_KIT_DRIFT',
18
+ cause,
19
+ fix: KIT_FIX,
20
+ docs: ERROR_DOCS_URL,
21
+ at: KIT_MARKER,
22
+ }),
23
+ ),
24
+ ];
25
+ }
@@ -21,6 +21,7 @@ export const CATALOG_PACKAGES = [
21
21
  '@ultimat3/cache',
22
22
  '@ultimat3/core',
23
23
  '@ultimat3/db',
24
+ '@ultimat3/effects',
24
25
  '@ultimat3/entity',
25
26
  '@ultimat3/flags',
26
27
  '@ultimat3/http',
@@ -50,14 +51,15 @@ export const CATALOG_PACKAGES = [
50
51
  * declare (`error-catalog.test.ts`), which is why `admin` is not here: `x dev` imports it and
51
52
  * `package.json` depends on it. `ui` reaches the CLI only as `admin`'s own dependency, so an
52
53
  * installer that keeps transitive packages private reports its codes `unavailable` rather than
53
- * the CLI declaring a package no command imports. `scraping` left this list in 31.0.0: the boot
54
+ * the CLI declaring a package no command imports. `effects` is an app's optional package that no
55
+ * command imports, for the same reason. `scraping` left this list in 31.0.0: the boot
54
56
  * imports its `./adapter` when `runtime.ts` supplies a `scrapeDriver`, so it is declared. Every other
55
57
  * entry above is a real runtime import and must be a declared dependency — `error-catalog.test.ts`
56
58
  * holds the list to exactly that, because an undeclared one resolves through workspace symlinks
57
59
  * here and through nothing in an installed app, where `x errors explain X_FLAG_EXPIRED` then
58
60
  * refuses a code the wiki promises.
59
61
  */
60
- export const CATALOG_OPTIONAL_HOSTS: readonly string[] = ['@ultimat3/ui'];
62
+ export const CATALOG_OPTIONAL_HOSTS: readonly string[] = ['@ultimat3/effects', '@ultimat3/ui'];
61
63
 
62
64
  export interface ErrorCatalog {
63
65
  /** Packages whose codes are now registered. */
@@ -0,0 +1,24 @@
1
+ // The X_* codes of the design-research surface (`x design research`, `x shot --against`) and the
2
+ // managed agent kit (`x kit`, the gate's kit check) — split out of `error-codes.ts` at its 500-line
3
+ // ceiling, as `error-codes-shot.ts` was. `error-codes.ts` folds these into the CLI's one owned union
4
+ // and registers them in its one call; nothing else imports this file.
5
+
6
+ /** Codes the design-research commands and the agent kit declare and own. */
7
+ export const CLI_KIT_ERROR_CODES = [
8
+ 'X_DESIGN_URL_REFUSED',
9
+ 'X_DESIGN_REFERENCE_UNREACHABLE',
10
+ 'X_SHOT_AGAINST_MISSING',
11
+ 'X_KIT_DRIFT',
12
+ 'X_KIT_SHADOWED',
13
+ ] as const;
14
+
15
+ export type CliKitErrorCode = (typeof CLI_KIT_ERROR_CODES)[number];
16
+
17
+ /** Their titles, typed over the list above so a code without one is a build error. */
18
+ export const CLI_KIT_ERROR_TITLES: Readonly<Record<CliKitErrorCode, string>> = {
19
+ X_DESIGN_URL_REFUSED: 'design reference URL refused',
20
+ X_DESIGN_REFERENCE_UNREACHABLE: 'design reference unreachable',
21
+ X_SHOT_AGAINST_MISSING: 'no reference shot to compare against',
22
+ X_KIT_DRIFT: 'agent kit file drifted',
23
+ X_KIT_SHADOWED: 'agent kit name shadowed',
24
+ };
@@ -9,6 +9,8 @@ import type { CliBoundaryErrorCode } from './error-codes-boundary';
9
9
  import { CLI_BOUNDARY_ERROR_CODES, CLI_BOUNDARY_ERROR_TITLES } from './error-codes-boundary';
10
10
  import type { CliDoctorErrorCode } from './error-codes-doctor';
11
11
  import { CLI_DOCTOR_ERROR_CODES, CLI_DOCTOR_ERROR_TITLES } from './error-codes-doctor';
12
+ import type { CliKitErrorCode } from './error-codes-kit';
13
+ import { CLI_KIT_ERROR_CODES, CLI_KIT_ERROR_TITLES } from './error-codes-kit';
12
14
  import type { CliPackageErrorCode } from './error-codes-package';
13
15
  import { CLI_PACKAGE_ERROR_CODES, CLI_PACKAGE_ERROR_TITLES } from './error-codes-package';
14
16
  import type { CliProcessesErrorCode } from './error-codes-processes';
@@ -241,10 +243,9 @@ export const CLI_OWNED_ERROR_CODES = [
241
243
  ] as const;
242
244
 
243
245
  /**
244
- * `X_NOT_IMPLEMENTED` is `@ultimat3/core`'s — every planned command throws it through core's
245
- * own `NotImplementedError`, and none of them may declare a title for it. The CLI is the process that imports every
246
- * package (`error-catalog.ts`), so a title declared twice here is the one that would win by load
247
- * order rather than by ownership.
246
+ * `X_NOT_IMPLEMENTED` is `@ultimat3/core`'s — every planned command throws it through core's own
247
+ * `NotImplementedError`, and none may declare a title for it. The CLI imports every package
248
+ * (`error-catalog.ts`), so a title declared twice here would win by load order, not ownership.
248
249
  *
249
250
  * The three env codes are core's for the same reason: `defineEnv`, `checkEnv` and the
250
251
  * `.env.example` projection all live in `@ultimat3/core`, and `x env` is the surface that reports
@@ -276,6 +277,7 @@ export const CLI_ERROR_CODES = [
276
277
  ...CLI_AGENTS_ERROR_CODES,
277
278
  ...CLI_BOUNDARY_ERROR_CODES,
278
279
  ...CLI_DOCTOR_ERROR_CODES,
280
+ ...CLI_KIT_ERROR_CODES,
279
281
  ...CLI_PACKAGE_ERROR_CODES,
280
282
  ...CLI_PROCESSES_ERROR_CODES,
281
283
  ...CLI_SHOT_ERROR_CODES,
@@ -291,6 +293,7 @@ export type CliOwnedErrorCode =
291
293
  | CliAgentsErrorCode
292
294
  | CliBoundaryErrorCode
293
295
  | CliDoctorErrorCode
296
+ | CliKitErrorCode
294
297
  | CliPackageErrorCode
295
298
  | CliProcessesErrorCode
296
299
  | CliShotErrorCode
@@ -482,6 +485,7 @@ registerErrorCodes(
482
485
  ...CLI_PACKAGE_ERROR_TITLES,
483
486
  ...CLI_PROCESSES_ERROR_TITLES,
484
487
  ...CLI_SHOT_ERROR_TITLES,
488
+ ...CLI_KIT_ERROR_TITLES,
485
489
  ...CLI_TOOLING_ERROR_TITLES,
486
490
  ...CLI_VERIFY_ERROR_TITLES,
487
491
  }).map(([code, title]) => [code, { title }]),
@@ -490,9 +494,7 @@ registerErrorCodes(
490
494
 
491
495
  // This file exports NO `docsFor(code)`, and adding one back is the defect. A CLI error passes no
492
496
  // `docs:` at all — `UltimateError` fills it from `describeErrorCode(code).docs`, which is
493
- // `@ultimat3/core`'s `ERROR_DOCS_URL`: one page for every code, never one per code, because `wiki/`
494
- // is the framework's only public documentation surface and a code lives there in a TABLE ROW, which
495
- // has no anchor. A `Finding` is a plain object with no constructor to fill it, so it carries
496
- // `ERROR_DOCS_URL` imported from core — the same constant, not a second copy of it. The
497
- // `https://ultimate.dev/errors/<code>` links `docsFor` built until 9.x answered 404, host included,
498
- // on every error the CLI has ever thrown.
497
+ // `@ultimat3/core`'s `ERROR_DOCS_URL`: one page for every code, because `wiki/` is the only public
498
+ // documentation surface and a code lives there in a TABLE ROW, which has no anchor. A `Finding` has
499
+ // no constructor to fill it, so it carries `ERROR_DOCS_URL` imported from core — the same constant.
500
+ // The `https://ultimate.dev/errors/<code>` links `docsFor` built until 9.x answered 404 on every error.
@@ -34,6 +34,8 @@ import { importRowsFiles } from './templates/generate-import-rows';
34
34
  import { purgeFiles } from './templates/generate-purge';
35
35
  import { webhookReceiverFiles } from './templates/generate-webhook-receiver';
36
36
  import { inviteFiles } from './templates/invite';
37
+ import type { EffectEntry } from './templates/island';
38
+ import { EFFECT_ENTRIES } from './templates/island';
37
39
  import { helmMonitoringFiles } from './templates/scaffold-helm-alerts';
38
40
  import { oidcSignInFiles } from './templates/sign-in-oidc';
39
41
  import { passwordSignInFiles } from './templates/sign-in-password';
@@ -55,6 +57,8 @@ export interface GenerateOptions {
55
57
  * the path a page's `src` resolved to, and an app's admin is wherever its `defineAdmin` is.
56
58
  */
57
59
  readonly at?: string;
60
+ /** `island` only: wrap the panel in this `@ultimat3/effects` entry (`readEffect` has checked it). */
61
+ readonly effect?: EffectEntry;
58
62
  /** `admin:page` only: the permission the page's own work needs, on top of `admin:read`. */
59
63
  readonly permission?: string;
60
64
  /**
@@ -262,7 +266,12 @@ export function generate(options: GenerateOptions): readonly GeneratedFile[] {
262
266
  }),
263
267
  );
264
268
  case 'island':
265
- return dedupe(islandFiles(options.name, { dir: options.at ?? `${surfaceDir}/${feature}` }));
269
+ return dedupe(
270
+ islandFiles(options.name, {
271
+ dir: options.at ?? `${surfaceDir}/${feature}`,
272
+ effect: options.effect,
273
+ }),
274
+ );
266
275
  // No `--at`, no surface, no feature: `guards/` is the one directory the gate discovers, and a
267
276
  // guard that lived anywhere else would need an app-side registration to be found.
268
277
  // A name the framework ships a guard under is refused: that guard already runs, built in, and
@@ -344,3 +353,24 @@ export function generate(options: GenerateOptions): readonly GeneratedFile[] {
344
353
  }
345
354
  }
346
355
  }
356
+
357
+ const isEffectEntry = (value: string): value is EffectEntry => Object.hasOwn(EFFECT_ENTRIES, value);
358
+
359
+ /**
360
+ * `--effect`, against the closed set of entries that can wrap a panel: any other value, and the flag
361
+ * on a kind that has no panel, is refused before a file is planned (`X_CLI_BAD_FLAG`).
362
+ */
363
+ export function readEffect(raw: string | undefined, kind: Generator): EffectEntry | undefined {
364
+ if (raw === undefined) return undefined;
365
+ const entries = Object.keys(EFFECT_ENTRIES);
366
+ if (kind === 'island' && isEffectEntry(raw)) return raw;
367
+ throw new BadFlagError({
368
+ flag: 'effect',
369
+ command: 'g',
370
+ reason:
371
+ kind === 'island'
372
+ ? `"${raw}" is no entry that wraps a panel — one of: ${entries.join(', ')}`
373
+ : `only an island has a panel to wrap, and this is a ${kind}`,
374
+ fix: 'x g island <name> --effect aurora',
375
+ });
376
+ }
@@ -4,19 +4,24 @@
4
4
 
5
5
  export const SHIPPED_GUARD_NAMES = [
6
6
  'animated-layout-property',
7
+ 'animated-layout-script',
7
8
  'bare-error',
9
+ 'effect-without-fallback',
8
10
  'error-declared',
9
11
  'focus-visible',
10
12
  'image-dimensions',
11
13
  'island-mount-clears',
12
14
  'island-without-states',
15
+ 'motion-adapter',
13
16
  'native-confirm',
14
17
  'raw-breakpoint',
15
18
  'raw-colour',
16
19
  'raw-fetch',
20
+ 'raw-frame-loop',
17
21
  'raw-interval',
18
22
  'raw-length',
19
23
  'raw-motion',
24
+ 'raw-motion-script',
20
25
  'raw-shadow',
21
26
  'raw-z-index',
22
27
  'repo-await-in-loop',
@@ -0,0 +1,56 @@
1
+ // The managed `audit` agent: read-only, scoped to the paths it is handed, and its every finding is
2
+ // a `file:line` with the scenario that fails — so a coordinator can act on it without re-auditing.
3
+
4
+ import type { NameSet } from '../templates/naming';
5
+ import { managedNote } from './managed';
6
+
7
+ export const auditAgent = (app: NameSet): string => `---
8
+ name: audit
9
+ description: Use to review a change or an area of ${app.kebab} without touching it — authz holes, data written outside repo.ts, N+1 reads, unbounded queries, missing tests, rules the gate cannot see. Read-only and scoped to the paths it is given; every finding is a file:line with the scenario that fails. Not for fixing.
10
+ tools: Read, Glob, Grep, Bash, mcp__${app.kebab}__*
11
+ ---
12
+
13
+ ${managedNote('agent', 'audit')}
14
+
15
+ You audit **only the paths you are given** in ${app.kebab}. You edit nothing, you run nothing that
16
+ writes, and you never run the gate — that is the coordinator's.
17
+
18
+ ## What a finding is
19
+
20
+ \`\`\`
21
+ <file>:<line> <severity: block | fix | note>
22
+ Scenario: <the concrete input, actor or sequence that fails>
23
+ Because: <the rule or invariant it breaks>
24
+ Evidence: <the command you ran, or the line you read>
25
+ \`\`\`
26
+
27
+ No scenario, no finding. "Could be cleaner" is not one; "an \`editor\` of org A updates org B's post
28
+ through the posts \`update\` action, because its policy trusts the \`orgId\` in the input" is.
29
+
30
+ ## Where to look
31
+
32
+ | Risk | Read | Ask |
33
+ |---|---|---|
34
+ | authz | each \`policy.ts\`, every action's \`policy\` | \`bunx x policy explain <subject> --json\` |
35
+ | data outside the door | any database call not in \`repo.ts\` | \`bunx x impact <file> --json\` |
36
+ | N+1, unbounded reads | queries and repos | dev MCP \`requests.statements\` for one request's SQL, \`db.explain\` for one plan |
37
+ | jobs that are not idempotent | handlers that increment, append or send | \`bunx x jobs show <name> --json\` |
38
+ | untested branches | the source beside its \`<file>.test.ts\` | \`bunx x affected --json\` |
39
+ | rendering rules | \`apps/web/site/\`, islands, styles | \`bunx x shot <route> --json\` |
40
+
41
+ Read-only commands only: the registries (\`bunx x routes\`, \`bunx x actions\`, \`bunx x queries\`,
42
+ \`bunx x entities\`), \`bunx x impact\`, \`bunx x graph\`, \`bunx x errors explain <CODE>\`. Never
43
+ \`bun test\`: a test on the branch under review is that branch's code, and running it executes it
44
+ with this checkout writable. Your evidence is static — the file:line, the input, the path through
45
+ the code. A failing test you propose goes in the report; the coordinator runs it only in a
46
+ disposable sandbox that shares nothing with the host: no host mount (read-only ones and service
47
+ sockets such as the Docker socket included), no credentials and no network route to the host or an
48
+ outside service (isolated test fixtures only), never the working checkout. If no such sandbox is
49
+ available, skip execution and report the gap. Never \`bunx x db migrate\`, never a
50
+ \`--write\`.
51
+
52
+ ## Report
53
+
54
+ Findings sorted by severity, then the paths you covered and the ones you did not reach. A clean
55
+ area says so in one line, with what you checked.
56
+ `;
@@ -0,0 +1,32 @@
1
+ // The managed `data` agent.
2
+
3
+ import type { NameSet } from '../templates/naming';
4
+ import { managedNote } from './managed';
5
+
6
+ export const dataAgent = (app: NameSet): string => `---
7
+ name: data
8
+ description: Use for anything about what is stored — entity definitions, invariants, indexes, repositories, migrations and seed data in ${app.kebab}. Owns \`packages/db/\` and every \`entity.ts\` and \`repo.ts\`. Not for actions, queries or UI.
9
+ tools: Read, Write, Edit, Glob, Grep, Bash, mcp__${app.kebab}__*
10
+ ---
11
+
12
+ ${managedNote('agent', 'data')}
13
+
14
+ You own the data boundary of ${app.kebab}: \`packages/db/\` plus every \`entity.ts\` and \`repo.ts\` in a
15
+ feature slice. Nothing else. A change outside that set is a collision — report it, do not make it.
16
+
17
+ | Rule | Detail |
18
+ |---|---|
19
+ | The entity is the schema | columns, invariants, indexes and tenancy are declared there, never in SQL |
20
+ | Migrations are generated | edit \`entity.ts\`, then \`bunx x db gen "what changed"\`. Never hand-write a file into \`packages/db/migrations/\` |
21
+ | Destructive is declared | a migration that drops, truncates or retypes carries \`-- destructive: true\`, or the gate refuses it |
22
+ | \`repo.ts\` is the only door | every read and write goes through it; a raw statement anywhere else is authz bypassed |
23
+ | Branch before you break things | \`bunx x db branch create <name>\`, never the shared dev database |
24
+ | Money | \`{ minor, currency }\` — integer minor units and an ISO code, both, always. Never a float |
25
+ | Time | store UTC; a formatted date always names an explicit IANA time zone |
26
+
27
+ Inspect before you change: \`bunx x entities list\`, \`bunx x entities show <name>\`, both with \`--json\`.
28
+
29
+ Checks: \`bun test <path>/entity.test.ts\`, \`bunx @biomejs/biome check --write <paths>\`, and
30
+ \`bunx x verify --only typecheck\` once when you are otherwise done: it queues for the machine's memory.
31
+ Never the whole \`bunx x verify\` — that belongs to whoever coordinates you.
32
+ `;
@@ -0,0 +1,34 @@
1
+ // The managed `server` agent.
2
+
3
+ import type { NameSet } from '../templates/naming';
4
+ import { managedNote } from './managed';
5
+
6
+ export const serverAgent = (app: NameSet): string => `---
7
+ name: server
8
+ description: Use for server-authoritative behaviour in ${app.kebab} — actions, mutators, queries, jobs, tasks and policies, plus the HTTP surface under \`apps/web/api/\`. Not for entities, migrations or anything that renders.
9
+ tools: Read, Write, Edit, Glob, Grep, Bash, mcp__${app.kebab}__*
10
+ ---
11
+
12
+ ${managedNote('agent', 'server')}
13
+
14
+ You own the server boundary of ${app.kebab}: \`policy.ts\`, actions, mutators, queries, jobs and tasks
15
+ inside a feature slice, plus \`apps/web/api/\`. Not \`entity.ts\`, not \`repo.ts\`, not anything that
16
+ renders. A change outside that set is a collision — report it, do not make it.
17
+
18
+ | Rule | Detail |
19
+ |---|---|
20
+ | Generate, then edit | \`bunx x g <kind> <name> --feature <slice>\` for every one of them — a hand-written primitive is missing from every registry that projects it |
21
+ | One authz object | the policy decides; a route or a UI that re-checks is a second answer that will drift |
22
+ | Data through the repo | an action calls \`repo.ts\`, never the database |
23
+ | Errors are instructions | never \`throw new Error\` — declare each code once with \`defineError({ code, title, status, cause, fix })\` from \`@ultimat3/core/page\`: a stable upper-snake code with the \`X_\` prefix, a cause and a \`fix:\` a caller can actually run. the \`error-declared\` guard refuses a handwritten \`UltimateError\` subclass |
24
+ | Jobs run at least once | a handler must be idempotent — an upsert or a statement whose second run changes nothing, never \`count + 1\` |
25
+ | Tasks name a time zone | a cron schedule with an ambient zone is a different time twice a year |
26
+ | No \`any\` | \`unknown\` plus a schema parse |
27
+
28
+ Inspect before you change: \`bunx x actions show <name>\`, \`bunx x queries show <name>\`, \`bunx x jobs list\`,
29
+ \`bunx x tasks list\`, \`bunx x policy explain <subject>\` — every one takes \`--json\`.
30
+
31
+ Checks: \`bun test <path>/<file>.test.ts\`, \`bunx @biomejs/biome check --write <paths>\`, and
32
+ \`bunx x verify --only typecheck\` once when you are otherwise done: it queues for the machine's memory.
33
+ Never the whole \`bunx x verify\` — that belongs to whoever coordinates you.
34
+ `;