@ramme-io/ui 4.2.10 → 5.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.
Files changed (48) hide show
  1. package/README.md +3 -9
  2. package/bin/ramme-ui.mjs +364 -0
  3. package/dist/blocks/iot/DeviceCard.d.ts +5 -0
  4. package/dist/blocks/iot/DeviceCard.js +29 -28
  5. package/dist/component-registry.js +384 -409
  6. package/dist/components/ai/AIChatThread/AIChatThread.d.ts +10 -2
  7. package/dist/components/ai/AIChatThread/AIChatThread.js +106 -119
  8. package/dist/components/ai/cardState.d.ts +19 -0
  9. package/dist/components/data-display/DocumentScanView.d.ts +81 -0
  10. package/dist/components/data-display/DocumentScanView.js +79 -0
  11. package/dist/components/data-display/Gallery.d.ts +49 -0
  12. package/dist/components/data-display/Gallery.js +95 -0
  13. package/dist/components/theme/ThemeSynthesizer.d.ts +2 -0
  14. package/dist/components/theme/ThemeSynthesizer.js +16 -15
  15. package/dist/components/ui/icon-loader.d.ts +1 -1
  16. package/dist/contexts/ThemeContext.d.ts +3 -0
  17. package/dist/contexts/ThemeContext.js +32 -30
  18. package/dist/index.d.ts +4 -9
  19. package/dist/index.js +252 -265
  20. package/dist/wizardManifest.js +123 -166
  21. package/package.json +7 -3
  22. package/src/wizardManifest.ts +123 -166
  23. package/tailwind.preset.js +17 -0
  24. package/dist/blocks/engines/WatchlistEngine.d.ts +0 -37
  25. package/dist/blocks/engines/WatchlistEngine.js +0 -130
  26. package/dist/components/ai/ArchitectureReferenceCard/ArchitectureReferenceCard.d.ts +0 -28
  27. package/dist/components/ai/ArchitectureReferenceCard/ArchitectureReferenceCard.js +0 -71
  28. package/dist/components/ai/ArchitectureReferenceCard/index.d.ts +0 -2
  29. package/dist/components/ai/CompanyProfileCard/CompanyProfileCard.d.ts +0 -15
  30. package/dist/components/ai/CompanyProfileCard/CompanyProfileCard.js +0 -110
  31. package/dist/components/ai/CompanyProfileCard/index.d.ts +0 -1
  32. package/dist/components/ai/CounterpartyGraphCard/CounterpartyGraphCard.d.ts +0 -30
  33. package/dist/components/ai/CounterpartyGraphCard/CounterpartyGraphCard.js +0 -83
  34. package/dist/components/ai/CounterpartyGraphCard/index.d.ts +0 -2
  35. package/dist/components/ai/DivergenceMetricsCard/DivergenceMetricsCard.d.ts +0 -29
  36. package/dist/components/ai/DivergenceMetricsCard/DivergenceMetricsCard.js +0 -70
  37. package/dist/components/ai/DivergenceMetricsCard/index.d.ts +0 -2
  38. package/dist/components/ai/LiveQuoteCard/LiveQuoteCard.d.ts +0 -27
  39. package/dist/components/ai/LiveQuoteCard/LiveQuoteCard.js +0 -73
  40. package/dist/components/ai/LiveQuoteCard/index.d.ts +0 -2
  41. package/dist/components/ai/NewsSummaryCard/NewsSummaryCard.d.ts +0 -27
  42. package/dist/components/ai/NewsSummaryCard/NewsSummaryCard.js +0 -78
  43. package/dist/components/ai/NewsSummaryCard/index.d.ts +0 -2
  44. package/dist/components/ai/StockChart/StockChart.d.ts +0 -34
  45. package/dist/components/ai/StockChart/StockChart.js +0 -199
  46. package/dist/components/ai/StockChart/index.d.ts +0 -2
  47. package/dist/utils/apiBaseUrl.d.ts +0 -1
  48. package/dist/utils/apiBaseUrl.js +0 -10
package/README.md CHANGED
@@ -174,7 +174,7 @@ Props, variants and live examples are in Storybook (`pnpm run storybook`) and at
174
174
 
175
175
  <!-- BEGIN GENERATED REFERENCE — do not edit by hand -->
176
176
 
177
- ### Components (83)
177
+ ### Components (77)
178
178
 
179
179
  | Name | SKU | What it is |
180
180
  | --- | --- | --- |
@@ -182,7 +182,6 @@ Props, variants and live examples are in Storybook (`pnpm run storybook`) and at
182
182
  | `ActivityFeed` | `@atom/templates-patterns/activity-feed` | Displays a chronological list of recent activities, typically with a timeline indicator. |
183
183
  | `AIChatThread` | `@molecule/ai/aichat-thread` | A complete chat surface — message history, streaming indicator, error banner, provider/model attribution, and the composer. |
184
184
  | `Alert` | `@molecule/feedback/alert` | Displays static, in-page messages to convey important information like success, warnings, or errors. |
185
- | `ArchitectureReferenceCard` | `@molecule/ai/architecture-reference-card` | AI-generated card summarizing this platform's own data architecture — stack, data model, AI pipelines, and sentinel fleet |
186
185
  | `AreaChart` | `@atom/charts/area-chart` | A theme-aware area chart component powered by Recharts, ideal for showing trends and volume over time. |
187
186
  | `Avatar` | `@atom/primitive/avatar` | Displays a user's profile picture or initials as a fallback, with different size options. |
188
187
  | `Badge` | `@atom/primitive/badge` | A small component to display a status, count, or label. |
@@ -198,19 +197,18 @@ Props, variants and live examples are in Storybook (`pnpm run storybook`) and at
198
197
  | `CircularDial` | `@atom/hardware/circular-dial` | A 270-degree arc gauge for a single live telemetry value, styled like a physical instrument dial. |
199
198
  | `CodeBlock` | `@atom/primitive/code-block` | The one way to show code. |
200
199
  | `ComboBox` | `@atom/form/combo-box` | A text input with an integrated dropdown list of selectable options, allowing both typing and selection. |
201
- | `CompanyProfileCard` | `@molecule/ai/company-profile-card` | A company summary for a ticker — sector, industry, and description — fetched on demand and cached. |
202
200
  | `ConnectorOverlay` | `@molecule/feedback/connector-overlay` | Covers a panel while its data source is connecting, and explains itself when the connection fails. |
203
201
  | `Conversation` | `@molecule/ai/conversation` | A container component that holds a series of Message components and manages the layout and scrolling of the chat history. |
204
- | `CounterpartyGraphCard` | `@molecule/ai/counterparty-graph-card` | AI-generated counterparty relationship card showing suppliers, customers, partners, and competitors inferred from alternative signals |
205
202
  | `DataCard` | `@molecule/data/data-card` | A Card that owns its own loading, error, and content states. |
206
203
  | `DataTable` | `@molecule/data/data-table` | A "Smart" data grid that renders data based on a simple JSON schema. |
207
204
  | `DatePicker` | `@atom/form/date-picker` | A theme-aware calendar input for selecting dates. |
208
205
  | `DenseMetricRibbon` | `@molecule/data/dense-metric-ribbon` | A compact horizontal strip of KPIs with optional trend arrows. |
209
- | `DivergenceMetricsCard` | `@molecule/ai/divergence-metrics-card` | AI-generated card showing operational and customer divergence scores — a signed delta between expected and observed performance |
206
+ | `DocumentScanView` | `@molecule/data/document-scan-view` | A document page with a scanning sweep while a parser reads it, and the regions it found outlined where they sit on the page. |
210
207
  | `EdgeInsightTerminal` | `@atom/hardware/edge-insight-terminal` | A terminal-styled panel that streams an AI analysis of live edge telemetry as it arrives. |
211
208
  | `EmptyState` | `@molecule/feedback/empty-state` | A component for displaying a message when there is no data or content to show. |
212
209
  | `FileUpload` | `@atom/form/file-upload` | A modern drag-and-drop file upload area with visual feedback and file listing. |
213
210
  | `FormTemplate` | `@atom/form/form-template` | A data-driven form builder that renders a grid of input fields from a configuration array. |
211
+ | `Gallery` | `@molecule/data/gallery` | A main image with a row of thumbnails beneath it. |
214
212
  | `HardwareCommandButton` | `@atom/hardware/hardware-command-button` | A command trigger that shows the full round trip to a physical device — transmitting, awaiting acknowledgement, then success or failure. |
215
213
  | `Icon` | `@atom/primitive/icon` | A dynamic component that renders scalable vector icons from the Lucide library. |
216
214
  | `Input` | `@atom/form/input` | A theme-aware text input with label, icon, helper text, and validation state support. |
@@ -218,7 +216,6 @@ Props, variants and live examples are in Storybook (`pnpm run storybook`) and at
218
216
  | `KpiGrid` | `@atom/templates-patterns/kpi-grid` | A framework-level abstraction that takes raw data and metric configurations to auto-calculate values and render a grid of StatCards. |
219
217
  | `Label` | `@molecule/form/label` | The accessible caption for a form control. |
220
218
  | `LineChart` | `@atom/charts/line-chart` | A theme-aware line chart component... |
221
- | `LiveQuoteCard` | `@molecule/ai/live-quote-card` | AI-generated live stock quote card with real-time price data |
222
219
  | `Loader` | `@molecule/ai/loader` | A compact, theme-aware animation for indicating AI processing states. |
223
220
  | `LoginPage` | `@atom/auth/login-page` | The standard sign-in screen — email and password, with inline error and loading states already wired. |
224
221
  | `Menu` | `@atom/primitive/menu` | A dropdown menu component, useful for navigation or contextual actions. |
@@ -227,7 +224,6 @@ Props, variants and live examples are in Storybook (`pnpm run storybook`) and at
227
224
  | `Message` | `@molecule/ai/message` | Displays a single message in a conversation, including an avatar, author, content, and optional suggestions. |
228
225
  | `MobileNav` | `@molecule/nav/mobile-nav` | Mobile navigation, in two shapes. |
229
226
  | `MultiSelect` | `@molecule/form/multi-select` | A searchable dropdown for picking several options at once, rendering selections as removable chips. |
230
- | `NewsSummaryCard` | `@molecule/ai/news-summary-card` | AI-generated news summary card with recent headlines |
231
227
  | `PageHeader` | `@atom/templates-patterns/page-header` | Displays the main header section of a page, including a title, optional description, and a slot for action buttons. |
232
228
  | `Pagination` | `@molecule/nav/pagination` | A navigation control for moving between pages of content. |
233
229
  | `PieChart` | `@atom/charts/pie-chart` | A theme-aware pie chart component powered by Recharts, for showing proportional relationships of parts to a whole. |
@@ -246,7 +242,6 @@ Props, variants and live examples are in Storybook (`pnpm run storybook`) and at
246
242
  | `StateMatrix` | `@molecule/data/state-matrix` | A compact grid for cross-referencing entities against attributes, where each cell is a clickable state rather than free text. |
247
243
  | `StatusBadge` | `@molecule/data/status-badge` | A consistent status indicator featuring a color-coded dot and an optional text label. |
248
244
  | `Stepper` | `@molecule/nav/stepper` | Guides users through a sequence of discrete steps, ideal for multi-step forms or onboarding flows. |
249
- | `StockChart` | `@molecule/ai/stock-chart` | AI-generated financial chart component with Bloomberg-style theming |
250
245
  | `Suggestion` | `@molecule/ai/suggestion` | A small, pill-shaped button that offers a quick, suggested reply or follow-up question to the user. |
251
246
  | `Table` | `@molecule/data/table` | A simple, theme-aware HTML table component for displaying tabular data, with support for custom cell rendering and empty states. |
252
247
  | `TabPanel` | `@molecule/nav/tab-panel` | Represents a single tab and its associated content panel within a `Tabs` component. |
@@ -259,7 +254,6 @@ Props, variants and live examples are in Storybook (`pnpm run storybook`) and at
259
254
  | `ToastProvider` | `@molecule/feedback/toast-provider` | Provides a context for displaying transient notifications (toasts). |
260
255
  | `ToggleSwitch` | `@atom/form/toggle-switch` | A theme-aware toggle switch component, offering a boolean input alternative to a checkbox. |
261
256
  | `useToast` | `@molecule/feedback/use-toast` | A React hook to easily add and dismiss toast notifications anywhere within a `ToastProvider`. |
262
- | `WatchlistEngine` | `@molecule/block/watchlist-engine` | A self-contained financial watchlist showing tickers with live price, day change, market cap, and a risk grade. |
263
257
  | `WaterPumpControl` | `@molecule/iot/water-pump-control` | An irrigation control block: choose automatic or manual operation and set the soil-moisture target the controller should hold. |
264
258
 
265
259
  ### Layouts (33)
@@ -0,0 +1,364 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Serves the three questions an agent has to answer before writing UI in this
4
+ * repo, from the live source rather than from prose:
5
+ *
6
+ * find does this component already exist?
7
+ * tokens what am I allowed to style it with?
8
+ * check does what I wrote violate a rule CI will fail on?
9
+ *
10
+ * Every answer is read from framework/ui at call time — the manifest and the
11
+ * Tailwind preset. Nothing here restates a fact that lives in those files,
12
+ * because a number copied into a script goes stale exactly like a number
13
+ * copied into a document.
14
+ */
15
+ import { readFileSync, existsSync, realpathSync } from 'node:fs';
16
+ import { join, dirname, resolve, relative } from 'node:path';
17
+ import { fileURLToPath } from 'node:url';
18
+ import { createRequire } from 'node:module';
19
+ import { spawnSync } from 'node:child_process';
20
+
21
+ const HERE = dirname(fileURLToPath(import.meta.url));
22
+
23
+ /**
24
+ * The manifest lives in two places and an agent will meet both. Inside this
25
+ * monorepo it is framework/ui source. Inside an app scaffolded from
26
+ * @ramme-io/create-app it is in node_modules, and the monorepo path resolves
27
+ * to nothing — silently, which is how "it doesn't exist" gets reported about a
28
+ * component that does. Try both, from the cwd upward.
29
+ */
30
+ const CANDIDATES = [
31
+ 'framework/ui/src/wizardManifest.ts',
32
+ 'node_modules/@ramme-io/ui/src/wizardManifest.ts',
33
+ 'node_modules/@ramme-io/ui/dist/wizardManifest.js',
34
+ ];
35
+ const PRESETS = [
36
+ 'framework/ui/tailwind.preset.js',
37
+ 'node_modules/@ramme-io/ui/tailwind.preset.js',
38
+ ];
39
+
40
+ const findUp = (rels) => {
41
+ let dir = process.cwd();
42
+ for (let i = 0; i < 8; i++) {
43
+ for (const rel of rels) {
44
+ const full = join(dir, rel);
45
+ if (existsSync(full)) return full;
46
+ }
47
+ const up = resolve(dir, '..');
48
+ if (up === dir) break;
49
+ dir = up;
50
+ }
51
+ // Last resort: walk up from this script, for an agent running elsewhere. As
52
+ // the `ramme-ui` bin it sits in node_modules/@ramme-io/ui/bin, so this finds
53
+ // the copy of the package it shipped with.
54
+ let d = HERE;
55
+ for (let i = 0; i < 8; i++) {
56
+ for (const rel of rels) {
57
+ const full = join(d, rel);
58
+ if (existsSync(full)) return full;
59
+ }
60
+ const up = resolve(d, '..');
61
+ if (up === d) break;
62
+ d = up;
63
+ }
64
+ return null;
65
+ };
66
+
67
+ const loadManifest = () => {
68
+ const path = findUp(CANDIDATES);
69
+ if (!path) {
70
+ console.error(
71
+ 'No wizardManifest found. Looked for:\n ' + CANDIDATES.join('\n ') +
72
+ '\nRun from inside the monorepo, or from an app with @ramme-io/ui installed.',
73
+ );
74
+ process.exit(1);
75
+ }
76
+ const src = readFileSync(path, 'utf8');
77
+ const start = src.indexOf('{', src.indexOf('='));
78
+ const end = src.lastIndexOf('}');
79
+ return { path, manifest: JSON.parse(src.slice(start, end + 1)) };
80
+ };
81
+
82
+ /** Every array, always. Reading `components` alone hides a third of the inventory. */
83
+ const allEntries = (manifest) =>
84
+ Object.entries(manifest).flatMap(([group, list]) =>
85
+ Array.isArray(list) ? list.map((e) => ({ ...e, group })) : [],
86
+ );
87
+
88
+ const cmdFind = (query) => {
89
+ const { path, manifest } = loadManifest();
90
+ const entries = allEntries(manifest);
91
+ const groups = Object.entries(manifest)
92
+ .filter(([, v]) => Array.isArray(v))
93
+ .map(([k, v]) => `${k} ${v.length}`)
94
+ .join(', ');
95
+
96
+ if (!query) {
97
+ console.log(`manifest: ${path}\ngroups: ${groups}\n`);
98
+ for (const e of entries) {
99
+ console.log(`${e.group.padEnd(11)} ${e.name.padEnd(24)} ${(e.description || '').slice(0, 72)}`);
100
+ }
101
+ return;
102
+ }
103
+
104
+ const q = query.toLowerCase();
105
+ const hit = (e) =>
106
+ [e.name, e.id, e.description, e.category, ...(e.tags || [])]
107
+ .filter(Boolean).join(' ').toLowerCase().includes(q);
108
+
109
+ const matches = entries.filter(hit);
110
+ console.log(`manifest: ${path}\ngroups: ${groups}\nquery: "${query}" -> ${matches.length} match(es)\n`);
111
+
112
+ if (!matches.length) {
113
+ console.log(
114
+ 'Nothing matched. Before concluding it does not exist, try a broader term\n' +
115
+ '(the thing you want may be named for its shape, not its use — a slide-over\n' +
116
+ 'panel is a "Sheet", a side panel is a "Drawer"), and list everything with\n' +
117
+ 'no argument. If it genuinely is not there, that is a halt-and-ask, not a\n' +
118
+ 'licence to build it.',
119
+ );
120
+ return;
121
+ }
122
+
123
+ for (const e of matches) {
124
+ console.log(`── ${e.name} [${e.group}/${e.category}]`);
125
+ console.log(` ${e.description || ''}`);
126
+ if (e.importPath) console.log(` import from '@ramme-io/ui' (source: ${e.filePath || e.importPath})`);
127
+ if (e.tags?.length) console.log(` tags: ${e.tags.join(', ')}`);
128
+ for (const p of (e.props || []).slice(0, 12)) {
129
+ console.log(` - ${p.name}: ${p.type}${p.description ? ` — ${p.description.slice(0, 64)}` : ''}`);
130
+ }
131
+ if ((e.props || []).length > 12) console.log(` … ${e.props.length - 12} more props`);
132
+ console.log();
133
+ }
134
+ };
135
+
136
+ const cmdTokens = (group) => {
137
+ const path = findUp(PRESETS);
138
+ if (!path) { console.error('No tailwind.preset.js found.'); process.exit(1); }
139
+
140
+ // Require the preset rather than parsing it. An earlier version read the
141
+ // token names out of the file text and its brace matching bled across
142
+ // sections, so `colors` came back holding `zIndex` and `fontFamily` keys —
143
+ // a token list that is wrong is worse than none, because it reads as
144
+ // authoritative. The module is the only thing that knows its own shape.
145
+ let preset;
146
+ try {
147
+ preset = createRequire(import.meta.url)(path);
148
+ } catch (err) {
149
+ console.error(
150
+ `Could not load ${path}:\n ${err.message}\n\n` +
151
+ 'The preset requires its own plugins, so run this from somewhere they\n' +
152
+ 'resolve — the monorepo root, or an app with @ramme-io/ui installed.',
153
+ );
154
+ process.exit(1);
155
+ }
156
+
157
+ const ext = preset?.theme?.extend ?? {};
158
+ const GROUPS = ['colors', 'fontSize', 'zIndex', 'maxWidth', 'borderRadius', 'spacing'];
159
+
160
+ // Colors nest (primary.DEFAULT, chart.1), and the nested names are what you
161
+ // actually type, so flatten to the utility suffix.
162
+ const flatten = (obj, prefix = '') =>
163
+ Object.entries(obj).flatMap(([k, v]) => {
164
+ const name = k === 'DEFAULT' ? prefix.replace(/-$/, '') : `${prefix}${k}`;
165
+ return v && typeof v === 'object' && !Array.isArray(v)
166
+ ? flatten(v, `${name}-`)
167
+ : [name];
168
+ });
169
+
170
+ console.log(`preset: ${path}\n`);
171
+ for (const g of GROUPS) {
172
+ if (group && group !== g) continue;
173
+ if (!ext[g]) continue;
174
+ const names = [...new Set(flatten(ext[g]))].sort();
175
+ console.log(`${g} (${names.length}):`);
176
+ console.log(' ' + names.join(' ') + '\n');
177
+ }
178
+ console.log(
179
+ 'Colors compose as bg-/text-/border-/ring-<token>. fontSize keys are already\n' +
180
+ 'fluid — text-sm and text-2xl interpolate by viewport, so there is no\n' +
181
+ 'md:text-* pair to write. zIndex names are for anything `fixed`.\n' +
182
+ 'Tailwind\'s default palette is still reachable but banned: see `check`.',
183
+ );
184
+ };
185
+
186
+ /**
187
+ * The rules below are the ones this repo already fails a build over. The point
188
+ * of running them here is speed, not authority: the tests in
189
+ * products/ramme-marketing/src/__tests__/ are what actually decide, and a clean
190
+ * run here is not permission to skip them.
191
+ */
192
+ const RULES = [
193
+ {
194
+ id: 'raw-palette',
195
+ re: /\b(?:bg|text|border|ring|from|to|via|fill|stroke|divide|outline|decoration|shadow|accent|caret)-(?:gray|slate|zinc|neutral|stone|red|orange|amber|yellow|lime|green|emerald|teal|cyan|sky|blue|indigo|violet|purple|fuchsia|pink|rose)-[0-9]+/g,
196
+ say: 'Raw palette utility — adapts to none of the five themes. Use a semantic token (`ramme-ui tokens colors`).',
197
+ },
198
+ {
199
+ id: 'fixed-bare-z',
200
+ re: /className="[^"]*\bfixed\b[^"]*\bz-(?:[2-9]\d|\d{3,})\b[^"]*"/g,
201
+ say: 'Numeric z-index on a `fixed` element — nothing at the call site says what it competes with. Use a named layer (z-nav, z-drawer, z-popover, z-toast…).',
202
+ },
203
+ {
204
+ id: 'arbitrary-font-size',
205
+ re: /\btext-\[[^\]]*(?:px|rem|clamp|vw)[^\]]*\]/g,
206
+ say: 'Arbitrary font size — the fluid scale already covers this. Add a step rather than an arbitrary value.',
207
+ },
208
+ {
209
+ id: 'breakpoint-type-pair',
210
+ re: /\btext-(?:xs|sm|base|lg|xl|[2-9]xl)\b[^"']*\b(?:sm|md|lg|xl|2xl):text-(?:xs|sm|base|lg|xl|[2-9]xl)\b/g,
211
+ say: 'Breakpoint type pair — the fluid scale replaces the jump. `text-2xl` is already responsive.',
212
+ },
213
+ {
214
+ id: 'viewport-height',
215
+ re: /\b(?:h|min-h|max-h)-\[?\d*\.?\d*vh\b/g,
216
+ say: '`vh` is wrong on any mobile browser with a retracting toolbar. Use `dvh` — and only AppShell sets viewport geometry.',
217
+ },
218
+ {
219
+ id: 'hardcoded-hex',
220
+ re: /(?:className|class)="[^"]*#[0-9a-fA-F]{3,8}\b[^"]*"|style=\{\{[^}]*#[0-9a-fA-F]{3,8}/g,
221
+ say: 'Hardcoded hex in markup — same problem as a raw palette class.',
222
+ },
223
+ ];
224
+
225
+ /** Test files quote the classes they ban; the repo's ratchets skip them too. */
226
+ const isExempt = (p) => /(^|\/)__tests__(\/|$)|\.(test|spec|stories)\.[jt]sx?$/.test(p);
227
+ const isUiFile = (p) => /\.(tsx|jsx|ts|css)$/.test(p);
228
+
229
+ /** Every rule hit in a file's text, one per rule per line. */
230
+ const scan = (text) => {
231
+ const hits = [];
232
+ text.split('\n').forEach((line, i) => {
233
+ for (const rule of RULES) {
234
+ rule.re.lastIndex = 0;
235
+ const m = line.match(rule.re);
236
+ if (m) hits.push({ line: i + 1, rule, found: [...new Set(m)].join(', ') });
237
+ }
238
+ });
239
+ return hits;
240
+ };
241
+
242
+ const cmdCheck = (paths) => {
243
+ // `check --changed` is the mode that matters. Pointed at a whole tree this
244
+ // reports every pre-existing finding too, and a report that is mostly other
245
+ // people's debt is one nobody reads twice — the signal you want is what YOU
246
+ // just wrote. The repo's ratchets are what hold the standing debt.
247
+ if (paths[0] === '--changed') {
248
+ const base = paths[1] || 'origin/main';
249
+ const out = spawnSync('git', ['diff', '--name-only', '--diff-filter=d', `${base}...HEAD`], { encoding: 'utf8' });
250
+ const unstaged = spawnSync('git', ['diff', '--name-only', '--diff-filter=d'], { encoding: 'utf8' });
251
+ const untracked = spawnSync('git', ['ls-files', '--others', '--exclude-standard'], { encoding: 'utf8' });
252
+ paths = [...new Set(
253
+ `${out.stdout || ''}\n${unstaged.stdout || ''}\n${untracked.stdout || ''}`
254
+ .split('\n').map((x) => x.trim()).filter((x) => /\.(tsx|jsx|ts|css)$/.test(x)),
255
+ )];
256
+ if (!paths.length) { console.log(`No changed UI files against ${base}.`); process.exit(0); }
257
+ console.log(`${paths.length} changed file(s) against ${base}:`);
258
+ }
259
+ if (!paths.length) { console.error('usage: ramme-ui check <file…> | check --changed [base] | check --hook'); process.exit(1); }
260
+ let total = 0;
261
+ for (const p of paths) {
262
+ if (!existsSync(p)) { console.error(`skipped (not found): ${p}`); continue; }
263
+ // Guards quote the classes they ban, in comments and in assertions. The
264
+ // repo's own ratchet skips __tests__ for this reason; so does this.
265
+ if (isExempt(p)) continue;
266
+ const hits = scan(readFileSync(p, 'utf8'));
267
+ if (hits.length) {
268
+ console.log(`\n${p}`);
269
+ for (const h of hits) {
270
+ console.log(` ${h.line}: [${h.rule.id}] ${h.found}`);
271
+ console.log(` ${h.rule.say}`);
272
+ }
273
+ }
274
+ total += hits.length;
275
+ }
276
+ console.log(total ? `\n${total} finding(s).` : '\nNo findings.');
277
+ console.log('Findings in files you did not write are pre-existing — fix what you touched.');
278
+ console.log('The authority is the repo suite, not this script — run `pnpm verify` before claiming a change is clean.');
279
+ process.exit(total ? 2 : 0);
280
+ };
281
+
282
+ /**
283
+ * `check --hook`: run by a Claude Code PostToolUse hook after every edit.
284
+ *
285
+ * Claude Code passes the tool call as JSON on stdin and feeds stderr back to
286
+ * the agent only when the hook exits 2 — so findings go to stderr, and exit 2
287
+ * is the only way the agent ever sees them. `check` above prints to stdout,
288
+ * which a hook would swallow.
289
+ *
290
+ * Only what the edit ADDED blocks. The file is compared with itself at HEAD,
291
+ * by rule and matched text rather than by line, since an edit shifts lines. A
292
+ * file carrying standing debt would otherwise block every edit to it, however
293
+ * clean, and an agent blocked by findings it did not write learns to ignore
294
+ * the hook. Standing debt belongs to the ratchets.
295
+ */
296
+ const keyOf = (h) => `${h.rule.id}\u0000${h.found}`;
297
+
298
+ const atHead = (file) => {
299
+ const dir = dirname(file);
300
+ const top = spawnSync('git', ['rev-parse', '--show-toplevel'], { cwd: dir, encoding: 'utf8' });
301
+ if (top.status !== 0) return ''; // not in a repo: everything is new
302
+ // git reports the toplevel by its real path, so the file must be too: on
303
+ // macOS /var is a symlink to /private/var, and a symlinked checkout does the
304
+ // same. Mixing the two makes `relative` climb out of the repo, the HEAD
305
+ // lookup fail, and every standing finding read as new.
306
+ const rel = relative(top.stdout.trim(), realpathSync(file)).split('\\').join('/');
307
+ const shown = spawnSync('git', ['show', `HEAD:${rel}`], { cwd: top.stdout.trim(), encoding: 'utf8' });
308
+ return shown.status === 0 ? shown.stdout : ''; // a new file compares against nothing
309
+ };
310
+
311
+ const cmdHook = async () => {
312
+ let raw = '';
313
+ for await (const chunk of process.stdin) raw += chunk;
314
+ let input;
315
+ try {
316
+ input = JSON.parse(raw);
317
+ } catch {
318
+ // Exit 1 is a non-blocking hook error: shown to the person, not the agent.
319
+ console.error('ramme-ui check --hook: stdin was not the hook JSON Claude Code sends.');
320
+ process.exit(1);
321
+ }
322
+
323
+ const given = input?.tool_input?.file_path;
324
+ if (typeof given !== 'string' || !given) process.exit(0);
325
+ const file = resolve(input.cwd || process.cwd(), given);
326
+ if (!isUiFile(file) || isExempt(file) || !existsSync(file)) process.exit(0);
327
+
328
+ const before = new Map();
329
+ for (const h of scan(atHead(file))) before.set(keyOf(h), (before.get(keyOf(h)) || 0) + 1);
330
+
331
+ const now = scan(readFileSync(file, 'utf8'));
332
+ const counts = new Map();
333
+ for (const h of now) counts.set(keyOf(h), (counts.get(keyOf(h)) || 0) + 1);
334
+
335
+ const added = [...counts].filter(([k, n]) => n > (before.get(k) || 0)).map(([k]) => k);
336
+ if (!added.length) process.exit(0);
337
+
338
+ console.error(`ramme-ui: this edit added ${added.length} design-rule finding(s) in ${given}:`);
339
+ for (const k of added) {
340
+ const hits = now.filter((h) => keyOf(h) === k);
341
+ const { rule, found } = hits[0];
342
+ console.error(` [${rule.id}] ${found} (line ${hits.map((h) => h.line).join(', ')})`);
343
+ console.error(` ${rule.say}`);
344
+ }
345
+ console.error('Fix these before moving on. Findings that were already in the file are not counted.');
346
+ process.exit(2);
347
+ };
348
+
349
+ const [cmd, ...rest] = process.argv.slice(2);
350
+ if (cmd === 'find') cmdFind(rest.join(' '));
351
+ else if (cmd === 'tokens') cmdTokens(rest[0]);
352
+ else if (cmd === 'check' && rest[0] === '--hook') await cmdHook();
353
+ else if (cmd === 'check') cmdCheck(rest);
354
+ else {
355
+ console.log(`ramme-ui — read this repo's design system from source.
356
+
357
+ ramme-ui find [query] search every manifest group for an existing component
358
+ ramme-ui tokens [group] list styling tokens from the live Tailwind preset
359
+ ramme-ui check <file…> flag the violations CI already fails on
360
+ ramme-ui check --changed same, limited to what this branch touched
361
+ ramme-ui check --hook a Claude Code hook: tool JSON on stdin, added findings on stderr, exit 2
362
+
363
+ 'find' with no query lists the whole inventory.`);
364
+ }
@@ -28,6 +28,9 @@ export type DeviceStatus = keyof typeof statusColorMap;
28
28
  * type: 'online' | 'offline' | 'error' | 'warning' | 'active'
29
29
  * description: The current operational state of the device. Changes the badge color.
30
30
  * default: 'offline'
31
+ * - name: statusLabel
32
+ * type: string
33
+ * description: Words for the badge in place of the status name — "Checked in recently" rather than "active". The status still sets the colour.
31
34
  * - name: value
32
35
  * type: string | number
33
36
  * description: The primary "live" metric to display (e.g., "72°", "1,240 rpm").
@@ -47,6 +50,8 @@ export interface DeviceCardProps {
47
50
  description?: string;
48
51
  icon?: IconName;
49
52
  status?: DeviceStatus;
53
+ /** Words for the badge; the status name when absent. */
54
+ statusLabel?: string;
50
55
  value?: string | number;
51
56
  trend?: string;
52
57
  children?: React.ReactNode;
@@ -1,45 +1,46 @@
1
1
  import { jsxs as r, jsx as e } from "react/jsx-runtime";
2
- import { Icon as c } from "../../components/ui/Icon.js";
3
- import { cn as f } from "../../utils/cn.js";
4
- import { Card as x } from "../../components/layout/Card.js";
5
- import { Badge as p } from "../../components/ui/Badge.js";
6
- const u = {
2
+ import { Icon as f } from "../../components/ui/Icon.js";
3
+ import { cn as x } from "../../utils/cn.js";
4
+ import { Card as p } from "../../components/layout/Card.js";
5
+ import { Badge as u } from "../../components/ui/Badge.js";
6
+ const h = {
7
7
  online: "success",
8
8
  offline: "secondary",
9
9
  error: "danger",
10
10
  warning: "outline",
11
11
  active: "primary"
12
12
  }, y = ({
13
- title: i,
14
- description: a,
15
- icon: s,
16
- status: n = "offline",
17
- value: o,
18
- trend: t,
19
- children: d,
20
- className: l,
21
- onClick: m
13
+ title: d,
14
+ description: o,
15
+ icon: n,
16
+ status: t = "offline",
17
+ statusLabel: l,
18
+ value: a,
19
+ trend: s,
20
+ children: i,
21
+ className: m,
22
+ onClick: c
22
23
  }) => /* @__PURE__ */ r(
23
- x,
24
+ p,
24
25
  {
25
- className: f("p-5 flex flex-col justify-between h-full transition-all hover:border-primary/50", l),
26
- onClick: m,
26
+ className: x("p-5 flex flex-col justify-between h-full transition-all hover:border-primary/50", m),
27
+ onClick: c,
27
28
  children: [
28
- /* @__PURE__ */ r("div", { className: "flex justify-between items-start mb-4", children: [
29
- /* @__PURE__ */ r("div", { className: "flex gap-3", children: [
30
- s && /* @__PURE__ */ e("div", { className: "p-2 rounded-md bg-muted text-muted-foreground", children: /* @__PURE__ */ e(c, { name: s, size: 20 }) }),
31
- /* @__PURE__ */ r("div", { children: [
32
- /* @__PURE__ */ e("h3", { className: "font-semibold text-foreground leading-none mb-1", children: i }),
33
- a && /* @__PURE__ */ e("p", { className: "text-xs text-muted-foreground", children: a })
29
+ /* @__PURE__ */ r("div", { className: "flex justify-between items-start gap-3 mb-4", children: [
30
+ /* @__PURE__ */ r("div", { className: "flex min-w-0 gap-3", children: [
31
+ n && /* @__PURE__ */ e("div", { className: "p-2 rounded-md bg-muted text-muted-foreground", children: /* @__PURE__ */ e(f, { name: n, size: 20 }) }),
32
+ /* @__PURE__ */ r("div", { className: "min-w-0", children: [
33
+ /* @__PURE__ */ e("h3", { className: "font-semibold text-foreground leading-none mb-1 break-words", children: d }),
34
+ o && /* @__PURE__ */ e("p", { className: "text-xs text-muted-foreground", children: o })
34
35
  ] })
35
36
  ] }),
36
- /* @__PURE__ */ e(p, { variant: u[n] || "secondary", children: n })
37
+ /* @__PURE__ */ e(u, { variant: h[t] || "secondary", className: "shrink-0", children: l ?? t })
37
38
  ] }),
38
- (o || t) && /* @__PURE__ */ e("div", { className: "mb-4", children: /* @__PURE__ */ r("div", { className: "flex items-baseline gap-2", children: [
39
- o && /* @__PURE__ */ e("span", { className: "text-2xl font-bold text-foreground", children: o }),
40
- t && /* @__PURE__ */ e("span", { className: "text-xs font-medium text-muted-foreground", children: t })
39
+ (a || s) && /* @__PURE__ */ e("div", { className: "mb-4", children: /* @__PURE__ */ r("div", { className: "flex items-baseline gap-2", children: [
40
+ a && /* @__PURE__ */ e("span", { className: "text-2xl font-bold text-foreground", children: a }),
41
+ s && /* @__PURE__ */ e("span", { className: "text-xs font-medium text-muted-foreground", children: s })
41
42
  ] }) }),
42
- d && /* @__PURE__ */ e("div", { className: "mt-auto pt-4 border-t border-border", children: d })
43
+ i && /* @__PURE__ */ e("div", { className: "mt-auto pt-4 border-t border-border", children: i })
43
44
  ]
44
45
  }
45
46
  );