@timbal-ai/timbal-react 0.8.2 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/app.cjs CHANGED
@@ -40,6 +40,7 @@ __export(app_exports, {
40
40
  Breadcrumbs: () => Breadcrumbs,
41
41
  Button: () => Button,
42
42
  CHART_PALETTE: () => CHART_PALETTE,
43
+ COLOR_UTILITY_PREFIXES: () => COLOR_UTILITY_PREFIXES,
43
44
  ChartArtifactView: () => ChartArtifactView,
44
45
  ChartPanel: () => ChartPanel,
45
46
  ConnectionRow: () => ConnectionRow,
@@ -59,6 +60,7 @@ __export(app_exports, {
59
60
  FilterBar: () => FilterBar,
60
61
  FloatingUnsavedChangesBar: () => FloatingUnsavedChangesBar,
61
62
  FormSection: () => FormSection,
63
+ HOUSE_RULES: () => HOUSE_RULES,
62
64
  INTEGRATION_CATALOG_CARD_HEIGHT_CLASS: () => INTEGRATION_CATALOG_CARD_HEIGHT_CLASS,
63
65
  InfoCard: () => InfoCard,
64
66
  IntegrationCard: () => IntegrationCard,
@@ -70,7 +72,10 @@ __export(app_exports, {
70
72
  Page: () => Page,
71
73
  PageHeader: () => PageHeader,
72
74
  PlanBadge: () => PlanBadge,
75
+ RESERVED_GRADIENT_TOKENS: () => RESERVED_GRADIENT_TOKENS,
73
76
  ResourceCard: () => ResourceCard,
77
+ SEMANTIC_COLOR_TOKENS: () => SEMANTIC_COLOR_TOKENS,
78
+ SLOP_BUDGETS: () => SLOP_BUDGETS,
74
79
  SearchInput: () => SearchInput,
75
80
  Section: () => Section,
76
81
  SettingsSection: () => SettingsSection,
@@ -81,11 +86,13 @@ __export(app_exports, {
81
86
  StatusDot: () => StatusDot,
82
87
  SubNav: () => SubNav,
83
88
  SurfaceCard: () => SurfaceCard,
89
+ TAILWIND_PALETTE_COLORS: () => TAILWIND_PALETTE_COLORS,
84
90
  THEME_AGENT_INSTRUCTIONS: () => THEME_AGENT_INSTRUCTIONS,
85
91
  TIMBAL_THEME_PRESETS: () => TIMBAL_THEME_PRESETS,
86
92
  ThemePresetGallery: () => ThemePresetGallery,
87
93
  TimbalChat: () => TimbalChat,
88
94
  TimbalThemeStyle: () => TimbalThemeStyle,
95
+ UI_REVIEW_AGENT_INSTRUCTIONS: () => UI_REVIEW_AGENT_INSTRUCTIONS,
89
96
  appFilterBarClass: () => appFilterBarClass,
90
97
  appPageColumnClass: () => appPageColumnClass,
91
98
  appSearchInputClass: () => appSearchInputClass,
@@ -99,15 +106,202 @@ __export(app_exports, {
99
106
  connectionRowListClass: () => connectionRowListClass,
100
107
  createTimbalTheme: () => createTimbalTheme,
101
108
  ensureThemeFontLink: () => ensureThemeFontLink,
109
+ formatLintReport: () => formatLintReport,
102
110
  getStoredThemePreset: () => getStoredThemePreset,
103
111
  getThemePreset: () => getThemePreset,
112
+ lintGeneratedUi: () => lintGeneratedUi,
113
+ reviewGeneratedUi: () => reviewGeneratedUi,
104
114
  themeToCss: () => themeToCss,
105
115
  useAppCopilotContext: () => useAppCopilotContext,
106
116
  useAppShellChat: () => useAppShellChat
107
117
  });
108
118
  module.exports = __toCommonJS(app_exports);
109
119
 
120
+ // src/design/ui-vocabulary.ts
121
+ var SEMANTIC_COLOR_TOKENS = [
122
+ // shadcn-style base tokens
123
+ "background",
124
+ "foreground",
125
+ "card",
126
+ "card-foreground",
127
+ "popover",
128
+ "popover-foreground",
129
+ "primary",
130
+ "primary-foreground",
131
+ "secondary",
132
+ "secondary-foreground",
133
+ "muted",
134
+ "muted-foreground",
135
+ "accent",
136
+ "accent-foreground",
137
+ "destructive",
138
+ "destructive-foreground",
139
+ "border",
140
+ "input",
141
+ "ring",
142
+ // sidebar scope
143
+ "sidebar",
144
+ "sidebar-foreground",
145
+ "sidebar-primary",
146
+ "sidebar-primary-foreground",
147
+ "sidebar-accent",
148
+ "sidebar-accent-foreground",
149
+ "sidebar-border",
150
+ "sidebar-ring",
151
+ // timbal chrome extensions
152
+ "elevated-from",
153
+ "elevated-to",
154
+ "modal-from",
155
+ "modal-to",
156
+ "playground-from",
157
+ "playground-via",
158
+ "playground-to",
159
+ "composer-bg",
160
+ "composer-border",
161
+ "composer-border-focus",
162
+ "bubble-user",
163
+ "bubble-user-foreground",
164
+ "code-block-bg",
165
+ "code-header-bg"
166
+ ];
167
+ var RESERVED_GRADIENT_TOKENS = [
168
+ "primary-fill-from",
169
+ "primary-fill-to",
170
+ "primary-fill-hover-from",
171
+ "primary-fill-hover-to",
172
+ "primary-fill-active-from",
173
+ "primary-fill-active-to",
174
+ "secondary-fill-hover-from",
175
+ "secondary-fill-hover-to",
176
+ "secondary-fill-active-from",
177
+ "secondary-fill-active-to",
178
+ "destructive-fill-hover-from",
179
+ "destructive-fill-hover-to",
180
+ "destructive-fill-active-from",
181
+ "destructive-fill-active-to",
182
+ "ghost-fill-hover",
183
+ "ghost-fill-active",
184
+ "elevated-from",
185
+ "elevated-to",
186
+ "modal-from",
187
+ "modal-to",
188
+ "playground-from",
189
+ "playground-via",
190
+ "playground-to"
191
+ ];
192
+ var TAILWIND_PALETTE_COLORS = [
193
+ "slate",
194
+ "gray",
195
+ "zinc",
196
+ "neutral",
197
+ "stone",
198
+ "red",
199
+ "orange",
200
+ "amber",
201
+ "yellow",
202
+ "lime",
203
+ "green",
204
+ "emerald",
205
+ "teal",
206
+ "cyan",
207
+ "sky",
208
+ "blue",
209
+ "indigo",
210
+ "violet",
211
+ "purple",
212
+ "fuchsia",
213
+ "pink",
214
+ "rose"
215
+ ];
216
+ var COLOR_UTILITY_PREFIXES = [
217
+ "bg",
218
+ "text",
219
+ "border",
220
+ "ring",
221
+ "from",
222
+ "via",
223
+ "to",
224
+ "fill",
225
+ "stroke",
226
+ "decoration",
227
+ "outline",
228
+ "shadow",
229
+ "divide",
230
+ "accent",
231
+ "caret"
232
+ ];
233
+ var SLOP_BUDGETS = {
234
+ /** Max decorative/standalone icons rendered in a single generated file. */
235
+ maxIconsPerView: 6,
236
+ /** Max consecutive list rows separated by an explicit border/divider before
237
+ * it reads as a "ruled table" — prefer spacing or zebra instead. */
238
+ maxRowDividers: 2
239
+ };
240
+ var HOUSE_RULES = [
241
+ {
242
+ id: "semantic-color",
243
+ rule: "Color only through semantic tokens \u2014 never a raw palette color, hex, or oklch literal.",
244
+ why: "The theme generator owns every color; hardcoding breaks dark mode and rebranding.",
245
+ slop: `<span className="text-blue-600 bg-green-50">`,
246
+ good: `<span className="text-primary bg-muted">`
247
+ },
248
+ {
249
+ id: "no-decorative-icons",
250
+ rule: "Icons must earn their place (action, nav, or status). Never add an icon beside a label that already says the thing.",
251
+ why: "An icon on every tile/card is the #1 tell of generated slop.",
252
+ slop: `<StatTile label={<><BarChart2 /> Revenue</>} value="$95k" />`,
253
+ good: `<StatTile label="Revenue" value="$95k" />`
254
+ },
255
+ {
256
+ id: "neutral-trend",
257
+ rule: "Don't put a colored trend pill on every metric. Use a trend only when the delta is the point, and keep it muted.",
258
+ why: "Loud green/red pills everywhere are noise, not signal.",
259
+ slop: `<MetricTile trend="+8%" className="text-green-500" />`,
260
+ good: `<MetricTile label="Win rate" value="50%" />`
261
+ },
262
+ {
263
+ id: "values-normal-weight",
264
+ rule: "Metric values use normal font weight, not bold.",
265
+ why: "Giant bold numbers read as a template; normal weight reads as a product.",
266
+ slop: `<span className="text-3xl font-bold tabular-nums">$322k</span>`,
267
+ good: `<span className="text-2xl font-normal tabular-nums">$322k</span>`
268
+ },
269
+ {
270
+ id: "no-card-in-card",
271
+ rule: "Don't nest a bordered card inside another bordered card. Group with spacing or a Section instead.",
272
+ why: "Card-in-card doubles borders and shadows for no information gain."
273
+ },
274
+ {
275
+ id: "no-row-dividers",
276
+ rule: "Don't put a divider between every list row. Use spacing or zebra striping.",
277
+ why: "A rule under every row turns a clean list into a dense ledger."
278
+ },
279
+ {
280
+ id: "no-data-gradient",
281
+ rule: "Gradients are reserved for chrome (composer, elevated surface, playground). Never on a data card, tile, or table.",
282
+ why: "Gradient stat cards are the canonical 'AI dashboard' look."
283
+ },
284
+ {
285
+ id: "compose-from-blocks",
286
+ rule: "Build from premade blocks (MetricRow, MetricChartCard, DataTable, IntegrationCard). Drop to raw primitives only when no block fits.",
287
+ why: "Slop appears the moment generation falls below the curated block layer."
288
+ },
289
+ {
290
+ id: "use-kit-controls",
291
+ rule: "Use the kit's controls (SearchInput, Select, DropdownMenu, FieldInput, FieldSelect) \u2014 never hand-roll an input/trigger surface (`border-input rounded-* bg-\u2026`).",
292
+ why: "Hand-rolled controls drift from the shared control-surface skin and look foreign next to kit controls.",
293
+ slop: `<button className="rounded-lg border border-input bg-transparent px-3 h-9">`,
294
+ good: `<SelectTrigger><SelectValue /></SelectTrigger>`
295
+ }
296
+ ];
297
+
110
298
  // src/app/agent-instructions.ts
299
+ var ANTI_SLOP_CHECKLIST = HOUSE_RULES.map((r) => {
300
+ const pair = r.slop && r.good ? `
301
+ - slop: \`${r.slop}\`
302
+ - good: \`${r.good}\`` : "";
303
+ return `- **${r.id}** \u2014 ${r.rule} (${r.why})${pair}`;
304
+ }).join("\n");
111
305
  var APP_KIT_AGENT_INSTRUCTIONS = `
112
306
  ## App kit (@timbal-ai/timbal-react/app)
113
307
 
@@ -155,7 +349,15 @@ Theming helpers (import from the package root or \`/app\`): \`createTimbalTheme\
155
349
  | **Modals** | Use \`AppConfirmDialog\` for destructive/export confirmations. |
156
350
  | **Metrics** | Overview KPIs \u2192 \`MetricRow\` or \`MetricChartCard\` (not four separate heavy cards). Values use **normal** font weight, not bold. |
157
351
  | **Integrations** | Catalog \u2192 \`IntegrationCard\` grid; connected list \u2192 \`ConnectionRow\` inside \`ConnectionRowList\`. Footer CTAs: \`Button variant="secondary"\`. |
158
- | **Anti-slop** | No loud green/red trend pills on every tile; no \`bg-card\` flat grids when platform chrome exists; avoid recycling demo names ("Operations", mock workforce lists). |
352
+ | **Anti-slop** | Follow the **anti-slop checklist** below. No loud green/red trend pills on every tile; no \`bg-card\` flat grids when platform chrome exists; avoid recycling demo names ("Operations", mock workforce lists). |
353
+
354
+ ### Anti-slop checklist (required \u2014 output is linted against this)
355
+
356
+ Generated UIs are checked by \`lintGeneratedUi\` and rejected on any error. Self-review against these before returning code (icon budget: ${SLOP_BUDGETS.maxIconsPerView} per view; at most ${SLOP_BUDGETS.maxRowDividers} ruled rows before it reads as a ledger):
357
+
358
+ ${ANTI_SLOP_CHECKLIST}
359
+
360
+ The cause of slop is dropping **below** the curated block layer into raw primitives + free Tailwind. Stay on the blocks; reach for primitives only when no block fits, and even then keep colors on semantic tokens.
159
361
 
160
362
  ### Accessibility (required)
161
363
 
@@ -181,7 +383,8 @@ Theming helpers (import from the package root or \`/app\`): \`createTimbalTheme\
181
383
  | \`useAppShellChat\` | Custom open/close trigger when \`hideChatTrigger\` on shell. |
182
384
  | \`Page\` | Page title, description, \`breadcrumbs\`, \`actions\`, children. |
183
385
  | \`Section\` | Titled block inside a page. |
184
- | \`SubNav\` | In-page tabs: \`items\`, \`activeId\`, \`onChange\`. |
386
+ | \`SubNav\` | **Section switcher** (Overview / Reports pill bar): \`items\`, \`activeId\`, \`onChange\`. Never use Radix/shadcn \`Tabs\` \u2014 it is not in this package. Switch panels with state or the router. |
387
+ | **Menus** | **Select** = short list, no search. **Combobox** = searchable (same trigger as Select). **Command** only inside \`PopoverContent variant="list"\` or Combobox \u2014 never padded default Popover. See \`examples/app-kit/src/recipes/primitives-catalog.ts\`. |
185
388
  | \`Breadcrumbs\` | Trail: \`items: [{ label, href? }]\`. |
186
389
  | \`Button\` | Actions \u2014 \`variant="secondary"\` for catalog/secondary CTAs; \`variant="default"\` for primary. |
187
390
  | \`StatTile\` | Single KPI in its own card (grid of scattered stats). Prefer \`MetricRow\` for a unified overview strip. |
@@ -237,19 +440,36 @@ Theming helpers (import from the package root or \`/app\`): \`createTimbalTheme\
237
440
 
238
441
  Studio chrome (\`StudioSidebar\`, \`ModeToggle\`, \u2026) lives in \`@timbal-ai/timbal-react/studio\` \u2014 optional, not required for every dashboard.
239
442
 
240
- ### Recipe index (\`examples/app-kit/recipes/\`)
443
+ ### Block recipes \u2014 compose these (don't clone wholesale)
444
+
445
+ Ready-made **section patterns** assembled from the components above. Each is a composition to rebuild in your own domain with your data \u2014 **not** an importable component. Reach for a block before dropping to raw primitives.
446
+
447
+ **Settings**
448
+ - **Project settings** \u2014 General / Usage / Danger sections; the floating save bar appears on first edit. Compose \`SettingsSection\` + \`FieldInput\`/\`FieldSwitch\` + \`FieldRow\` + \`InfoCard\` + \`DangerZone\` + \`FloatingUnsavedChangesBar\`.
449
+ - **Settings form** \u2014 compact stacked form for one concern (profile, billing). Compose \`FormSection\` + \`FieldInput\`/\`FieldSelect\`/\`FieldTextarea\`.
241
450
 
242
- | Recipe file | Components to study |
243
- |-------------|---------------------|
244
- | \`metrics-row.tsx\` | \`Page\`, \`MetricRow\` |
245
- | \`analytics-card.tsx\` | \`MetricChartCard\`, \`Button\` |
246
- | \`integrations-grid.tsx\` | \`IntegrationCard\`, \`ConnectionRowList\`, \`PlanBadge\` |
247
- | \`table-with-filters.tsx\` | \`FilterBar\`, \`DataTable\` |
248
- | \`settings-page.tsx\` | \`SettingsSection\`, \`DangerZone\`, \`FloatingUnsavedChangesBar\` |
249
- | \`resource-gallery.tsx\` | \`ResourceCard\`, \`StatusDot\`, \`Sparkline\` |
250
- | \`charts-panel.tsx\` | \`ChartPanel\`, \`ChartArtifact\` |
251
- | \`copilot-overlay.tsx\` | \`AppShell\`, \`AppChatPanel\` |
252
- | \`theme-presets.tsx\` | \`ThemePresetGallery\`, \`applyTimbalTheme\` |
451
+ **Data & metrics**
452
+ - **Metrics row** \u2014 KPI strip in one elevated card. Compose \`MetricRow\` + \`MetricTile\`.
453
+ - **Analytics card** \u2014 selectable KPI tiles driving a shared chart. Compose \`MetricChartCard\` + \`LineAreaChart\`.
454
+ - **Charts panel** \u2014 embedded chart artifact. Compose \`ChartPanel\` + \`ChartArtifactView\`.
455
+ - **Table + filters** \u2014 \`FilterBar\` above a sortable \`DataTable\` (+ \`StatusBadge\` in cells).
456
+
457
+ **Collections**
458
+ - **Integrations grid** \u2014 connector catalog + connected list. Compose \`IntegrationCard\` + \`PlanBadge\` + \`ConnectionRowList\` (\`IntegrationsEmptyState\` when empty).
459
+ - **Resource gallery** \u2014 project / agent / dataset cards. Compose \`ResourceCard\` + \`StatusDot\` + \`Sparkline\`.
460
+
461
+ **Overlays & flows** (animate automatically)
462
+ - **Confirm & destructive** \u2014 confirm/cancel modal or destructive alert. Compose \`AppConfirmDialog\` (or \`AlertDialog\`) + \`Button\`; never hand-roll a \`Dialog\` for confirms.
463
+ - **Detail sheet** \u2014 slide-over edit panel without leaving the list. Compose \`Sheet\` + \`Field*\` + \`Button\` + \`Separator\`.
464
+
465
+ **States & auth**
466
+ - **Empty states** \u2014 no-data / no-results / first-run. Compose \`EmptyState\` + \`Card\` + \`Button\`.
467
+ - **Sign-in card** \u2014 centered auth entry. Compose \`Card\` + \`Input\` + \`Label\` + \`Button\`.
468
+
469
+ **Shells & theming**
470
+ - **Minimal shell** \u2014 \`AppShell\` + \`Page\` (no sidebar/chat).
471
+ - **Copilot overlay** \u2014 \`AppShell\` + floating \`AppChatPanel\`.
472
+ - **Theme presets** \u2014 \`ThemePresetGallery\` + \`applyTimbalTheme\` (never hand-author OKLCH).
253
473
 
254
474
  ### Typical compositions
255
475
 
@@ -260,6 +480,7 @@ Studio chrome (\`StudioSidebar\`, \`ModeToggle\`, \u2026) lives in \`@timbal-ai/
260
480
  - **Integrations** \u2014 grid of \`IntegrationCard\`; \`ConnectionRowList\` for connected providers; \`IntegrationsEmptyState\` when empty.
261
481
  - **Resource gallery** \u2014 grid of \`ResourceCard\`.
262
482
  - **Copilot-assisted app** \u2014 \`AppCopilotProvider\` + \`AppShell\` with \`chat={<AppChatPanel workforceId="\u2026" />}\`.
483
+ - **Motion is automatic** \u2014 Dialog, AlertDialog, Sheet, Popover, DropdownMenu, Select, Tooltip, Toast, and Accordion/Collapsible animate out of the box (fade/zoom/slide/height) via the engine inlined in \`styles.css\`. Do not add a separate animation library or hand-write \`@keyframes\`.
263
484
 
264
485
  ### Example imports
265
486
 
@@ -295,6 +516,211 @@ import {
295
516
  - For rich in-chat widgets, use **artifacts** (\`ARTIFACT_AGENT_INSTRUCTIONS\`) \u2014 app kit is for the **host application shell**.
296
517
  `.trim();
297
518
 
519
+ // src/design/ui-lint.ts
520
+ var PALETTE_GROUP = TAILWIND_PALETTE_COLORS.join("|");
521
+ var PREFIX_GROUP = COLOR_UTILITY_PREFIXES.join("|");
522
+ var RAW_COLOR_RE = new RegExp(
523
+ `(?:^|[\\s"'\`:])(?:[a-z-]+:)*(?:${PREFIX_GROUP})-(?:${PALETTE_GROUP})-\\d{2,3}(?:/\\d{1,3})?`,
524
+ "g"
525
+ );
526
+ var COLOR_LITERAL_RE = /#[0-9a-fA-F]{3,8}\b|\b(?:oklch|rgba?|hsla?)\s*\(/g;
527
+ var INLINE_STYLE_COLOR_RE = /style=\{\{[^}]*\b(?:color|background|backgroundColor|borderColor|fill|stroke)\b/;
528
+ var BOLD_VALUE_RE = /text-(?:xl|2xl|3xl|4xl|5xl|6xl)[^"'`]*\bfont-(?:bold|extrabold|black|semibold)|font-(?:bold|extrabold|black|semibold)[^"'`]*text-(?:xl|2xl|3xl|4xl|5xl|6xl)/;
529
+ var GRADIENT_RE = /\bbg-(?:gradient|linear|radial|conic)-/;
530
+ var GRADIENT_DIRECTIONS = /* @__PURE__ */ new Set([
531
+ "t",
532
+ "tr",
533
+ "r",
534
+ "br",
535
+ "b",
536
+ "bl",
537
+ "l",
538
+ "tl"
539
+ ]);
540
+ var ICON_IMPORT_RE = /from\s+["']lucide-react["']/;
541
+ var RAW_CONTROL_SURFACE_RE = /\bborder-input\b/;
542
+ var RESERVED_GRADIENT_SET = new Set(RESERVED_GRADIENT_TOKENS);
543
+ function stripVariants(util) {
544
+ return util.replace(/^(?:[a-z-]+:)*/, "");
545
+ }
546
+ function isCommentOrImport(line) {
547
+ const t = line.trim();
548
+ return t.startsWith("//") || t.startsWith("*") || t.startsWith("/*") || t.startsWith("import ") || t.startsWith("export ");
549
+ }
550
+ function lintGeneratedUi(source, options = {}) {
551
+ const maxIcons = options.maxIconsPerView ?? SLOP_BUDGETS.maxIconsPerView;
552
+ const maxRowDividers = options.maxRowDividers ?? SLOP_BUDGETS.maxRowDividers;
553
+ const findings = [];
554
+ const lines = source.split("\n");
555
+ let usesLucide = false;
556
+ let iconUsageCount = 0;
557
+ let dividerRunCount = 0;
558
+ const lucideNames = /* @__PURE__ */ new Set();
559
+ for (let i = 0; i < lines.length; i++) {
560
+ const line = lines[i];
561
+ const lineNo = i + 1;
562
+ if (ICON_IMPORT_RE.test(line)) {
563
+ usesLucide = true;
564
+ const named = line.match(/\{([^}]*)\}/);
565
+ if (named) {
566
+ for (const raw of named[1].split(",")) {
567
+ const name = raw.trim().split(/\s+as\s+/)[0].trim();
568
+ if (name) lucideNames.add(name);
569
+ }
570
+ }
571
+ continue;
572
+ }
573
+ if (isCommentOrImport(line)) continue;
574
+ const rawColors = line.match(RAW_COLOR_RE);
575
+ if (rawColors) {
576
+ for (const m of rawColors) {
577
+ findings.push({
578
+ rule: "raw-color",
579
+ severity: "error",
580
+ line: lineNo,
581
+ message: "Hardcoded palette color. Use a semantic token (text-primary, bg-muted, border-border, text-muted-foreground, \u2026) so dark mode and rebranding work.",
582
+ snippet: m.trim().replace(/^["'`:\s]+/, "")
583
+ });
584
+ }
585
+ }
586
+ const literals = line.match(COLOR_LITERAL_RE);
587
+ if (literals) {
588
+ findings.push({
589
+ rule: "color-literal",
590
+ severity: "error",
591
+ line: lineNo,
592
+ message: "Hardcoded color literal. Colors must come from the theme generator (createTimbalTheme) and semantic tokens \u2014 never inline hex/oklch/rgb.",
593
+ snippet: line.trim().slice(0, 120)
594
+ });
595
+ }
596
+ if (INLINE_STYLE_COLOR_RE.test(line)) {
597
+ findings.push({
598
+ rule: "inline-style-color",
599
+ severity: "error",
600
+ line: lineNo,
601
+ message: "Inline style color. Move color to a semantic Tailwind token on className.",
602
+ snippet: line.trim().slice(0, 120)
603
+ });
604
+ }
605
+ if (RAW_CONTROL_SURFACE_RE.test(line)) {
606
+ findings.push({
607
+ rule: "raw-control-surface",
608
+ severity: "warn",
609
+ line: lineNo,
610
+ message: "Hand-rolled control surface (border-input). Use a kit control \u2014 SearchInput, Select, DropdownMenu, FieldInput, FieldSelect \u2014 so it matches every other control.",
611
+ snippet: line.trim().slice(0, 120)
612
+ });
613
+ }
614
+ if (BOLD_VALUE_RE.test(line)) {
615
+ findings.push({
616
+ rule: "bold-metric",
617
+ severity: "warn",
618
+ line: lineNo,
619
+ message: "Bold large value. House style: metric values use font-normal, not bold \u2014 bold giant numbers read as a template.",
620
+ snippet: line.trim().slice(0, 120)
621
+ });
622
+ }
623
+ if (GRADIENT_RE.test(line)) {
624
+ const fromTo = line.match(
625
+ new RegExp(`(?:from|via|to)-([a-z-]+)`, "g")
626
+ );
627
+ const colorStops = (fromTo ?? []).map((u) => stripVariants(u).replace(/^(?:from|via|to)-/, "")).filter((token) => !GRADIENT_DIRECTIONS.has(token));
628
+ const allReserved = colorStops.length > 0 && colorStops.every((token) => RESERVED_GRADIENT_SET.has(token));
629
+ if (!allReserved) {
630
+ findings.push({
631
+ rule: "data-gradient",
632
+ severity: "warn",
633
+ line: lineNo,
634
+ message: "Gradient outside chrome. Gradients are reserved for buttons / elevated / modal / playground \u2014 never a data card, tile, or table.",
635
+ snippet: line.trim().slice(0, 120)
636
+ });
637
+ }
638
+ }
639
+ if (/\b(?:border-t|border-b|divide-y)\b/.test(line)) {
640
+ dividerRunCount++;
641
+ if (dividerRunCount === maxRowDividers + 1) {
642
+ findings.push({
643
+ rule: "row-divider",
644
+ severity: "warn",
645
+ line: lineNo,
646
+ message: "Divider on every row. Prefer spacing (gap-*) or zebra striping over a rule under each list item.",
647
+ snippet: line.trim().slice(0, 120)
648
+ });
649
+ }
650
+ } else if (line.trim() !== "" && !line.includes("className")) {
651
+ if (!/^\s*[)>}/]/.test(line)) dividerRunCount = 0;
652
+ }
653
+ if (usesLucide && lucideNames.size > 0) {
654
+ for (const name of lucideNames) {
655
+ const usage = new RegExp(`<${name}\\b`, "g");
656
+ const hits = line.match(usage);
657
+ if (hits) iconUsageCount += hits.length;
658
+ }
659
+ }
660
+ }
661
+ if (usesLucide && iconUsageCount > maxIcons) {
662
+ findings.push({
663
+ rule: "icon-spam",
664
+ severity: "warn",
665
+ line: 1,
666
+ message: `Too many icons (${iconUsageCount} > ${maxIcons}). Icons should mark actions/nav/status \u2014 not decorate every label, tile, and card.`,
667
+ snippet: `${iconUsageCount} lucide-react icon usages`
668
+ });
669
+ }
670
+ const effectiveErrors = findings.filter(
671
+ (f) => f.severity === "error" || options.strict && f.severity === "warn"
672
+ ).length;
673
+ return {
674
+ findings,
675
+ errorCount: findings.filter((f) => f.severity === "error").length,
676
+ warnCount: findings.filter((f) => f.severity === "warn").length,
677
+ ok: effectiveErrors === 0
678
+ };
679
+ }
680
+ function formatLintReport(findings) {
681
+ if (findings.length === 0) return "";
682
+ const lines = findings.slice().sort((a, b) => a.line - b.line).map((f) => {
683
+ const tag = f.severity === "error" ? "ERROR" : "warn ";
684
+ return ` ${tag} L${f.line} [${f.rule}] ${f.message}
685
+ \u2192 ${f.snippet}`;
686
+ });
687
+ const errs = findings.filter((f) => f.severity === "error").length;
688
+ const warns = findings.filter((f) => f.severity === "warn").length;
689
+ return `Anti-slop review: ${errs} error(s), ${warns} warning(s)
690
+ ${lines.join("\n")}`;
691
+ }
692
+
693
+ // src/design/ui-review.ts
694
+ function reviewGeneratedUi(source, options = {}) {
695
+ const lint = lintGeneratedUi(source, options);
696
+ const report = formatLintReport(lint.findings);
697
+ if (lint.ok) {
698
+ return { lint, passed: true, report, revisionPrompt: null };
699
+ }
700
+ const revisionPrompt = [
701
+ "The generated UI failed the Timbal anti-slop review. Fix every issue below, then return the corrected code only.",
702
+ "",
703
+ report,
704
+ "",
705
+ "Rules: colors come only from semantic tokens (text-primary, bg-muted, border-border, text-muted-foreground, \u2026) \u2014 never palette colors, hex, or oklch. Icons mark actions/nav/status, not decoration. Metric values use font-normal. No gradients on data surfaces. No divider under every row. Do not change anything that already passed."
706
+ ].join("\n");
707
+ return { lint, passed: false, report, revisionPrompt };
708
+ }
709
+ var UI_REVIEW_AGENT_INSTRUCTIONS = `
710
+ ## Self-review before returning UI (anti-slop)
711
+
712
+ Before you output any generated UI code, silently re-read it and fix anything that matches the slop checklist \u2014 this is the same rubric an automated linter applies, so output that fails it will be rejected and sent back:
713
+
714
+ - **No hardcoded colors.** Every color is a semantic token (\`text-primary\`, \`bg-muted\`, \`border-border\`, \`text-muted-foreground\`, \`bg-destructive\`, \u2026). No \`text-blue-600\`, no \`#hex\`, no \`oklch(...)\`, no \`style={{ color }}\`.
715
+ - **No decorative icons.** An icon must mark an action, nav target, or status. Remove icons that sit beside a label that already says the thing. Aim for very few icons per view.
716
+ - **Muted, sparse trends.** No colored up/down pill on every metric. Show a trend only when the change is the point.
717
+ - **Normal-weight values.** Metric numbers use \`font-normal\`, never \`font-bold\` at large sizes.
718
+ - **No card-in-card, no per-row dividers, no gradients on data surfaces.** Group with spacing/Sections; reserve gradients for chrome.
719
+ - **Compose from blocks.** Prefer \`MetricRow\` / \`MetricChartCard\` / \`DataTable\` / \`IntegrationCard\` over hand-assembled primitives.
720
+
721
+ If a check fails, fix it and re-read once more. Only return code that would pass clean.
722
+ `.trim();
723
+
298
724
  // src/design/oklch.ts
299
725
  var clamp = (n, min, max) => Math.min(max, Math.max(min, n));
300
726
  var round = (n, digits) => {
@@ -1615,6 +2041,38 @@ var ThemePresetGallery = ({
1615
2041
  var import_react3 = require("motion/react");
1616
2042
  var import_react4 = require("react");
1617
2043
 
2044
+ // src/design/control-surface.ts
2045
+ var CONTROL_SIZE = {
2046
+ sm: "h-9 px-3",
2047
+ default: "h-10 px-3"
2048
+ };
2049
+ var CONTROL_SHAPE = {
2050
+ field: "rounded-lg",
2051
+ pill: "rounded-full"
2052
+ };
2053
+ var controlSurfaceClass = cn(
2054
+ TIMBAL_V2_SECONDARY_CHROME,
2055
+ "text-sm text-foreground outline-none",
2056
+ "placeholder:text-muted-foreground/70",
2057
+ "focus-visible:ring-2 focus-visible:ring-foreground/10",
2058
+ "focus-within:ring-2 focus-within:ring-foreground/10",
2059
+ "disabled:cursor-not-allowed disabled:opacity-50",
2060
+ "data-[placeholder]:text-muted-foreground"
2061
+ );
2062
+ function controlClass(options = {}, className) {
2063
+ const { size = "default", shape = "field" } = options;
2064
+ return cn(controlSurfaceClass, CONTROL_SIZE[size], CONTROL_SHAPE[shape], className);
2065
+ }
2066
+ var overlayAnimationClass = "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2";
2067
+ var overlaySurfaceClass = cn(
2068
+ "z-[80] border border-border bg-popover text-popover-foreground shadow-card",
2069
+ overlayAnimationClass
2070
+ );
2071
+ var overlayListPanelClass = cn(
2072
+ overlaySurfaceClass,
2073
+ "overflow-hidden rounded-lg p-0 outline-hidden"
2074
+ );
2075
+
1618
2076
  // src/design/app-classes.ts
1619
2077
  var appPageColumnClass = "mx-auto w-full max-w-6xl px-4 md:px-6";
1620
2078
  var appShellTopbarInsetClass = "w-full px-4 md:px-6";
@@ -1648,18 +2106,13 @@ var appFilterBarClass = cn(
1648
2106
  "flex flex-wrap items-center gap-2",
1649
2107
  studioTopbarPillHeightClass
1650
2108
  );
1651
- var appSearchInputClass = cn(studioSearchChromeClass, "text-sm");
2109
+ var appSearchInputClass = controlClass({}, "inline-flex items-center gap-2");
1652
2110
  var appBreadcrumbsClass = "flex flex-wrap items-center gap-1.5 text-sm text-muted-foreground";
1653
2111
  var appBreadcrumbLinkClass = "transition-colors hover:text-foreground";
1654
2112
  var appFieldClass = "flex flex-col gap-1.5";
1655
2113
  var appFieldLabelClass = "text-sm font-medium text-foreground";
1656
2114
  var appFieldHintClass = "text-xs text-muted-foreground";
1657
- var appInputClass = cn(
1658
- studioSecondaryChromeClass,
1659
- "h-10 w-full rounded-lg px-3 text-sm text-foreground outline-none",
1660
- "placeholder:text-muted-foreground/70",
1661
- "focus-visible:ring-2 focus-visible:ring-foreground/10"
1662
- );
2115
+ var appInputClass = controlClass({}, "w-full");
1663
2116
  var appEmptyStateClass = cn(
1664
2117
  appSurfaceCardClass,
1665
2118
  "flex flex-col items-center justify-center gap-2 py-12 text-center"
@@ -7572,6 +8025,7 @@ function TimbalChat({
7572
8025
  Breadcrumbs,
7573
8026
  Button,
7574
8027
  CHART_PALETTE,
8028
+ COLOR_UTILITY_PREFIXES,
7575
8029
  ChartArtifactView,
7576
8030
  ChartPanel,
7577
8031
  ConnectionRow,
@@ -7591,6 +8045,7 @@ function TimbalChat({
7591
8045
  FilterBar,
7592
8046
  FloatingUnsavedChangesBar,
7593
8047
  FormSection,
8048
+ HOUSE_RULES,
7594
8049
  INTEGRATION_CATALOG_CARD_HEIGHT_CLASS,
7595
8050
  InfoCard,
7596
8051
  IntegrationCard,
@@ -7602,7 +8057,10 @@ function TimbalChat({
7602
8057
  Page,
7603
8058
  PageHeader,
7604
8059
  PlanBadge,
8060
+ RESERVED_GRADIENT_TOKENS,
7605
8061
  ResourceCard,
8062
+ SEMANTIC_COLOR_TOKENS,
8063
+ SLOP_BUDGETS,
7606
8064
  SearchInput,
7607
8065
  Section,
7608
8066
  SettingsSection,
@@ -7613,11 +8071,13 @@ function TimbalChat({
7613
8071
  StatusDot,
7614
8072
  SubNav,
7615
8073
  SurfaceCard,
8074
+ TAILWIND_PALETTE_COLORS,
7616
8075
  THEME_AGENT_INSTRUCTIONS,
7617
8076
  TIMBAL_THEME_PRESETS,
7618
8077
  ThemePresetGallery,
7619
8078
  TimbalChat,
7620
8079
  TimbalThemeStyle,
8080
+ UI_REVIEW_AGENT_INSTRUCTIONS,
7621
8081
  appFilterBarClass,
7622
8082
  appPageColumnClass,
7623
8083
  appSearchInputClass,
@@ -7631,8 +8091,11 @@ function TimbalChat({
7631
8091
  connectionRowListClass,
7632
8092
  createTimbalTheme,
7633
8093
  ensureThemeFontLink,
8094
+ formatLintReport,
7634
8095
  getStoredThemePreset,
7635
8096
  getThemePreset,
8097
+ lintGeneratedUi,
8098
+ reviewGeneratedUi,
7636
8099
  themeToCss,
7637
8100
  useAppCopilotContext,
7638
8101
  useAppShellChat