@hirobius/design-system 0.20.0 → 0.22.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/AGENTS.md +125 -0
- package/CHANGELOG.md +969 -0
- package/CONSUMING.md +27 -11
- package/DESIGN.md +28 -17
- package/MIGRATIONS.md +603 -0
- package/NOTICE.md +1 -1
- package/README.md +39 -5
- package/UPGRADING.md +222 -0
- package/codemods/hds-prefix.mjs +28 -13
- package/codemods/jsx-fold.mjs +28 -13
- package/codemods/lib/atomic-write.mjs +28 -0
- package/codemods/lib/installed-version.mjs +354 -0
- package/codemods/lib/project.mjs +395 -0
- package/codemods/lib/record.mjs +110 -0
- package/codemods/lib/scan.mjs +323 -0
- package/codemods/lib/semver.mjs +57 -0
- package/codemods/not-found-pattern.mjs +3 -3
- package/codemods/patterns-subpath.mjs +28 -12
- package/codemods/registry.mjs +67 -0
- package/codemods/tile-grid.mjs +3 -3
- package/codemods/upgrade.mjs +909 -0
- package/dist/chunks/empty-state-DNoThgfV.js +1227 -0
- package/dist/chunks/form-By82qZcC.js +66 -0
- package/dist/fonts/geist-mono-400.woff2 +0 -0
- package/dist/fonts/satoshi-400.woff2 +0 -0
- package/dist/fonts/satoshi-500.woff2 +0 -0
- package/dist/fonts/satoshi-700.woff2 +0 -0
- package/dist/fonts.css +53 -0
- package/dist/form.js +1 -1
- package/dist/hirobius-ui.js +876 -877
- package/dist/manifest.js +3 -3
- package/dist/patterns.js +189 -170
- package/dist/styles.css +2 -2
- package/dist/tokens.css +1 -1
- package/dist/tokens.js +136 -57
- package/dist/types/src/app/components/alert-dialog.d.ts +5 -0
- package/dist/types/src/app/components/alert.d.ts +1 -1
- package/dist/types/src/app/components/asset-img.d.ts +1 -0
- package/dist/types/src/app/components/avatar-group.d.ts +1 -0
- package/dist/types/src/app/components/avatar.d.ts +1 -1
- package/dist/types/src/app/components/badge.d.ts +2 -2
- package/dist/types/src/app/components/blockquote.d.ts +1 -0
- package/dist/types/src/app/components/breadcrumb.d.ts +1 -1
- package/dist/types/src/app/components/button.d.ts +3 -1
- package/dist/types/src/app/components/callout.d.ts +1 -1
- package/dist/types/src/app/components/card.d.ts +4 -3
- package/dist/types/src/app/components/checkbox.d.ts +1 -1
- package/dist/types/src/app/components/code-block.d.ts +1 -1
- package/dist/types/src/app/components/combobox.d.ts +1 -1
- package/dist/types/src/app/components/data-table-section.d.ts +1 -0
- package/dist/types/src/app/components/destructive-section.d.ts +1 -0
- package/dist/types/src/app/components/dialog.d.ts +2 -1
- package/dist/types/src/app/components/disclosure.d.ts +1 -1
- package/dist/types/src/app/components/divider.d.ts +1 -1
- package/dist/types/src/app/components/empty-state.d.ts +1 -1
- package/dist/types/src/app/components/error-pattern.d.ts +6 -1
- package/dist/types/src/app/components/field.d.ts +1 -1
- package/dist/types/src/app/components/form-actions.d.ts +1 -0
- package/dist/types/src/app/components/form-control.d.ts +10 -0
- package/dist/types/src/app/components/form.d.ts +1 -1
- package/dist/types/src/app/components/grid.d.ts +5 -0
- package/dist/types/src/app/components/hds-tooltip.d.ts +1 -1
- package/dist/types/src/app/components/icon.d.ts +1 -0
- package/dist/types/src/app/components/inline-link.d.ts +1 -1
- package/dist/types/src/app/components/input.d.ts +1 -1
- package/dist/types/src/app/components/kbd.d.ts +1 -0
- package/dist/types/src/app/components/menu.d.ts +1 -1
- package/dist/types/src/app/components/metadata-list.d.ts +1 -0
- package/dist/types/src/app/components/metric-tiles.d.ts +1 -0
- package/dist/types/src/app/components/pagination.d.ts +1 -1
- package/dist/types/src/app/components/popover.d.ts +1 -1
- package/dist/types/src/app/components/progress.d.ts +2 -2
- package/dist/types/src/app/components/radio.d.ts +1 -1
- package/dist/types/src/app/components/select.d.ts +1 -1
- package/dist/types/src/app/components/skeleton.d.ts +2 -2
- package/dist/types/src/app/components/slider.d.ts +1 -1
- package/dist/types/src/app/components/spinner.d.ts +1 -1
- package/dist/types/src/app/components/stat.d.ts +5 -4
- package/dist/types/src/app/components/status-list-item.d.ts +1 -1
- package/dist/types/src/app/components/status-tile.d.ts +4 -3
- package/dist/types/src/app/components/table.d.ts +6 -1
- package/dist/types/src/app/components/tabs.d.ts +1 -1
- package/dist/types/src/app/components/tag.d.ts +1 -1
- package/dist/types/src/app/components/text.d.ts +53 -6
- package/dist/types/src/app/components/textarea.d.ts +1 -1
- package/dist/types/src/app/components/timestamp.d.ts +1 -0
- package/dist/types/src/app/components/toast.d.ts +1 -1
- package/dist/types/src/app/components/toggle.d.ts +1 -1
- package/dist/types/src/app/data/manifest-types.d.ts +4 -0
- package/dist/types/src/app/design-system/generated-token-refs.d.ts +37 -28
- package/dist/types/src/app/design-system/generated-token-values.d.ts +3 -0
- package/dist/types/src/app/design-system/tokens.d.ts +117 -15
- package/dist/types/src/index.d.ts +122 -72
- package/dist/variables.css +41 -33
- package/docs/CONSUMING.md +63 -39
- package/hirobius.tokens.json +163 -112
- package/llms.txt +158 -50
- package/mcp/catalog.mjs +369 -0
- package/mcp/core-set.mjs +66 -0
- package/mcp/guide.mjs +272 -0
- package/mcp/hds-mcp.mjs +49 -0
- package/mcp/server.mjs +94 -0
- package/package.json +53 -11
- package/public/hds-manifest.json +430 -336
- package/public/llms/components.txt +4 -3
- package/public/llms/layout.txt +1 -1
- package/public/llms-full.txt +190 -70
- package/public/llms.txt +158 -50
- package/scripts/eslint-plugin-hds/index.d.mts +29 -0
- package/scripts/eslint-plugin-hds/index.mjs +55 -0
- package/scripts/eslint-plugin-hds/package.json +30 -0
- package/scripts/eslint-plugin-hds/rules/no-raw-controls.mjs +47 -0
- package/scripts/eslint-plugin-hds/rules/no-raw-hex.mjs +70 -0
- package/scripts/eslint-plugin-hds/rules/no-raw-px-spacing.mjs +125 -0
- package/scripts/eslint-plugin-hds/rules/prefer-hds-layout-primitive.mjs +54 -0
- package/scripts/eslint-plugin-hds/rules/sx-token-first.mjs +111 -0
- package/scripts/eslint-plugin-hds/rules/utils.mjs +66 -0
- package/src/app/data/component-api.json +154 -93
- package/upgrade/index.json +208 -0
- package/upgrade/releases/0.17.0.json +962 -0
- package/upgrade/releases/0.18.0.json +8 -0
- package/upgrade/releases/0.19.0.json +233 -0
- package/upgrade/releases/0.19.1.json +8 -0
- package/upgrade/releases/0.20.0.json +5108 -0
- package/upgrade/releases/0.21.0.json +538 -0
- package/upgrade/releases/0.22.0.json +94 -0
- package/upgrade/schema.json +989 -0
- package/dist/chunks/empty-state-BBqhCx0S.js +0 -1217
- package/dist/chunks/form-COP3vK9_.js +0 -66
- package/dist/types/src/app/components/status-dot.d.ts +0 -39
package/llms.txt
CHANGED
|
@@ -1,8 +1,67 @@
|
|
|
1
1
|
# Hirobius Design System
|
|
2
2
|
|
|
3
|
-
Generated: 2026-10-
|
|
3
|
+
Generated: 2026-10-07T16:09:09.631Z
|
|
4
4
|
Primary sources: `public/hds-manifest.json`, `src/app/data/component-api.json`, `hirobius.tokens.json`
|
|
5
5
|
|
|
6
|
+
## Agents Using The Package: Start Here
|
|
7
|
+
|
|
8
|
+
- Read `AGENTS.md` (package root, `node_modules/@hirobius/design-system/AGENTS.md`) first: which component to use for each screen need, the imports, and the rules.
|
|
9
|
+
- MCP server `hds` ships in the package: run `npx hds-mcp` (stdio). Tools: `list_core`, `search_components`, `get_component`, `search_tokens`; each answer is under 2 KB.
|
|
10
|
+
- Lint before you finish: `import hds from '@hirobius/design-system/eslint-plugin'` and spread `hds.configs.recommended` into `eslint.config.mjs`.
|
|
11
|
+
|
|
12
|
+
## Pick By Need
|
|
13
|
+
|
|
14
|
+
One answer per need. Use the components after the arrow; what follows "Not:" is what agents reached for instead, which is the wrong answer for that need even where it has a purpose of its own. Generated from `mcp/guide.mjs`, the same list as `AGENTS.md`.
|
|
15
|
+
|
|
16
|
+
- **Outermost wrapper of a screen** → `Page`, `Stack`. Not: `Container`, `Box`, a bare Stack as the root.
|
|
17
|
+
`<Page><Stack gap="spacious">…one child per section…</Stack></Page>`. `Container` is for a full-bleed surface that is not a page.
|
|
18
|
+
- **Screen title with breadcrumb, status and actions** → `PageHeader`, `Breadcrumb`, `Badge`. Not: Text as the page title, a Stack row of Text and Badge.
|
|
19
|
+
Exactly one per screen: `<PageHeader breadcrumb={<Breadcrumb items={[{ label, href }, { label }]} />} title="…" status={<Badge tone="success">Active</Badge>} />`.
|
|
20
|
+
- **Row of headline numbers (stats, KPIs, counts, totals)** → `MetricTiles`, `MetricTile`. Not: `Stat`, `StatusTile`, `CardMetric`, Card with Text.
|
|
21
|
+
`<MetricTiles><MetricTile label="Open projects" value="5" />…</MetricTiles>`; one MetricTile per number. `Stat` is for a number inside prose or a dense list, `Card.Metric` for one inside an existing `Card`, `StatusTile` for a state with notes (never a number).
|
|
22
|
+
- **Table of records with row actions** → `DataTableSection`, `Badge`, `Button`. Not: Table on its own, Card around a Table.
|
|
23
|
+
`<DataTableSection title="Projects" columns={[{ key, label }]} rows={[{ key, cells: [...], actions: <Stack direction="row" gap="tight">…</Stack> }]} />`; leave the actions column out of `columns`.
|
|
24
|
+
- **Switch between panels of related content** → `Tabs`, `TabsList`, `TabsTrigger`, `TabsContent`. Not: `SegmentedControl`, Button rows.
|
|
25
|
+
`<Tabs defaultValue="a"><TabsList><TabsTrigger value="a">A</TabsTrigger></TabsList><TabsContent value="a">…</TabsContent></Tabs>`.
|
|
26
|
+
- **Status label in a header or table cell** → `Badge`. Not: `Tag`, `Text`.
|
|
27
|
+
`<Badge tone="success|info|warning|danger|neutral|inProgress">…</Badge>`; tone is the only styling input.
|
|
28
|
+
- **Form with fields and a submit button** → `Form`, `Textarea`, `Input`, `FormActions`, `Button`. Not: a raw `<form>`, a Stack of Buttons as the footer.
|
|
29
|
+
`<Form onSubmit={…}><Textarea label="Notes" … /><FormActions primary={<Button type="submit">Save note</Button>} /></Form>`; every field takes its own `label`.
|
|
30
|
+
- **Confirm a destructive or irreversible action (delete, archive, remove)** → `AlertDialog`, `Button`. Not: `Dialog`, `window.confirm`.
|
|
31
|
+
Trigger, title, description, Cancel and Action parts: `<AlertDialog><AlertDialog.Trigger asChild><Button …>Archive</Button></AlertDialog.Trigger><AlertDialog.Content><AlertDialog.Header><AlertDialog.Title>…</AlertDialog.Title><AlertDialog.Description>…</AlertDialog.Description></AlertDialog.Header><AlertDialog.Footer><AlertDialog.Cancel asChild><Button variant="secondary">Cancel</Button></AlertDialog.Cancel><AlertDialog.Action asChild><Button tone="danger" onClick={…}>Archive</Button></AlertDialog.Action></AlertDialog.Footer></AlertDialog.Content></AlertDialog>`. Focus moves in and returns to the trigger for you.
|
|
32
|
+
- **Brief confirmation after an action (saved, archived, sent)** → `ToastProvider`, `useToast`. Not: `Badge`, `Alert`, `Text`.
|
|
33
|
+
Wrap the app root once in `<ToastProvider>`, then `toast({ title: "Note saved", tone: "success" })` from `useToast()`.
|
|
34
|
+
- **Message that stays next to its content (error, warning, info)** → `Alert`. Not: Text in a coloured Surface.
|
|
35
|
+
`<Alert tone="warning">…</Alert>`.
|
|
36
|
+
- **Button or row action** → `Button`. Not: a raw `<button>`, InlineLink for an action.
|
|
37
|
+
Row actions: `<Button variant="tertiary" size="sm" aria-label="View Brand refresh">View</Button>`; the destructive one adds `tone="danger"`.
|
|
38
|
+
- **Space between sections or items** → `Stack`, `Grid`. Not: margins on children, raw px gaps such as px8.
|
|
39
|
+
Stack `gap`: `spacious` between page sections, `normal` inside a section, `tight` between buttons. `Grid` for two-dimensional layout.
|
|
40
|
+
- **Padded background or a titled content object** → `Surface`, `Card`. Not: a Box with background and padding.
|
|
41
|
+
`Surface` for a plain padded background; `Card` only when the content has a title or can be pressed.
|
|
42
|
+
- **Progress bar or ring** → `Progress`. Not: a hand-built bar.
|
|
43
|
+
`<Progress value={60} label="Upload" />`; inside an existing `Card`, `CardProgress`.
|
|
44
|
+
- **Body copy** → `Text`. Not: Text as a section heading.
|
|
45
|
+
Section headings come from the pattern that owns the section (`PageHeader` `title`, `DataTableSection` `title`), not from extra Text.
|
|
46
|
+
- **Empty state for a list or section** → `EmptyState`. Not: Text saying "No items".
|
|
47
|
+
`DataTableSection` shows its own through `emptyTitle`; use `EmptyState` elsewhere.
|
|
48
|
+
- **The one irreversible action of a screen (delete the client, close the account)** → `DestructiveSection`. Not: a danger Button that acts without a confirm.
|
|
49
|
+
Last on the screen: `<DestructiveSection title="Delete client" description="…" actionLabel="Delete" onConfirm={…} />`; it opens its own AlertDialog. A per-row destructive action uses AlertDialog directly.
|
|
50
|
+
- **Read-only details as label and value pairs** → `MetadataList`, `Field`. Not: a Table with two columns, Text pairs in a Stack.
|
|
51
|
+
`<MetadataList items={[{ term: "Owner", description: "Ada" }]} />` for a set; `Field` for one pair.
|
|
52
|
+
- **A person, or a group of people** → `Avatar`, `AvatarGroup`. Not: an image in a rounded Box.
|
|
53
|
+
`<Avatar src alt initials />`; several in a row: `<AvatarGroup max={3}>…Avatars…</AvatarGroup>`.
|
|
54
|
+
- **A date or time** → `Timestamp`. Not: a formatted string in Text.
|
|
55
|
+
`<Timestamp date="2026-10-14" />` renders a `<time dateTime>`; a date in a table cell may stay plain text.
|
|
56
|
+
- **A keyboard key or shortcut hint** → `Kbd`. Not: `InlineCode`, Text in a Box.
|
|
57
|
+
`<Kbd>⌘K</Kbd>`.
|
|
58
|
+
- **A quotation with attribution** → `Blockquote`. Not: Callout for a quote, italic Text.
|
|
59
|
+
`<Blockquote attribution="Ada Lovelace">…</Blockquote>`.
|
|
60
|
+
- **A fixed-width side rail beside fluid content, or a row that stacks when narrow** → `Sidebar`, `Switcher`. Not: a Grid with media queries.
|
|
61
|
+
`Sidebar` (`side`, `sideWidth`) for rail + content; `Switcher` (`threshold`) for a row that flips to a column. Neither needs a media query.
|
|
62
|
+
- **Keep an element stuck while its region scrolls** → `Pin`. Not: position: sticky in style.
|
|
63
|
+
`<Pin top="…">…</Pin>` inside the scrolling region.
|
|
64
|
+
|
|
6
65
|
## System Architecture
|
|
7
66
|
|
|
8
67
|
- Engine: React + TypeScript
|
|
@@ -36,56 +95,105 @@ This file intentionally does not embed prop tables or long-form API docs.
|
|
|
36
95
|
- Detailed prop types, unions, defaults, and descriptions: read `src/app/data/component-api.json`.
|
|
37
96
|
- Runtime behavior: read the actual component source under `src/app/components/` (and associated styles).
|
|
38
97
|
|
|
98
|
+
## Core set
|
|
99
|
+
|
|
100
|
+
The 43 components of the ratified core set (hds#254, ADR-031): brand-neutral, composable, imported from the package root. Build a screen from these first. Each has `core: true` in `public/hds-manifest.json` and is marked `[core]` under "Which one when". Composed pattern modules (page shells, forms, code blocks, page sections) are imported from `@hirobius/design-system/patterns`.
|
|
101
|
+
|
|
102
|
+
- Button (Actions)
|
|
103
|
+
- Avatar (Display)
|
|
104
|
+
- Card (Display)
|
|
105
|
+
- EmptyState (Display)
|
|
106
|
+
- Field (Display)
|
|
107
|
+
- Icon (Display)
|
|
108
|
+
- Kbd (Display)
|
|
109
|
+
- Table (Display)
|
|
110
|
+
- Alert (Feedback)
|
|
111
|
+
- Badge (Feedback)
|
|
112
|
+
- Progress (Feedback)
|
|
113
|
+
- Skeleton (Feedback)
|
|
114
|
+
- Spinner (Feedback)
|
|
115
|
+
- ToastProvider (Feedback)
|
|
116
|
+
- Checkbox (Inputs)
|
|
117
|
+
- Combobox (Inputs)
|
|
118
|
+
- Input (Inputs)
|
|
119
|
+
- Radio (Inputs)
|
|
120
|
+
- SegmentedControl (Inputs)
|
|
121
|
+
- Select (Inputs)
|
|
122
|
+
- Slider (Inputs)
|
|
123
|
+
- Tag (Inputs)
|
|
124
|
+
- Textarea (Inputs)
|
|
125
|
+
- Toggle (Inputs)
|
|
126
|
+
- Box (Layout)
|
|
127
|
+
- Container (Layout)
|
|
128
|
+
- Disclosure (Layout)
|
|
129
|
+
- Divider (Layout)
|
|
130
|
+
- Grid (Layout)
|
|
131
|
+
- Stack (Layout)
|
|
132
|
+
- Surface (Layout)
|
|
133
|
+
- Breadcrumb (Navigation)
|
|
134
|
+
- InlineLink (Navigation)
|
|
135
|
+
- Pagination (Navigation)
|
|
136
|
+
- Tabs (Navigation)
|
|
137
|
+
- Dialog (Overlays)
|
|
138
|
+
- Menu (Overlays)
|
|
139
|
+
- Popover (Overlays)
|
|
140
|
+
- Tooltip (Overlays)
|
|
141
|
+
- HdsRouterProvider (Theming)
|
|
142
|
+
- HdsThemeProvider (Theming)
|
|
143
|
+
- Text (Typography)
|
|
144
|
+
- VisuallyHidden (Utility)
|
|
145
|
+
|
|
39
146
|
## Which one when
|
|
40
147
|
|
|
41
|
-
One line per component that declares when to use it (`@usage` / `@useInstead` in its JSDoc). Full detail, including `usage.whenNot`, `keyboard` and `aiRules`, is in `public/hds-manifest.json` and `src/app/data/component-api.json`.
|
|
42
|
-
|
|
43
|
-
Alert: Show a persistent inline message with a severity, next to the content it concerns. Use instead: ToastProvider, Badge
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
148
|
+
One line per component that declares when to use it (`@usage` / `@useInstead` in its JSDoc); `[core]` marks the core set. Full detail, including `usage.whenNot`, `keyboard` and `aiRules`, is in `public/hds-manifest.json` and `src/app/data/component-api.json`.
|
|
149
|
+
|
|
150
|
+
Alert: [core] Show a persistent inline message with a severity, next to the content it concerns. Use instead: ToastProvider, Badge
|
|
151
|
+
AlertDialog: Confirm a destructive or irreversible action (delete, archive, remove) before it runs, with Cancel and Action buttons. Use instead: Dialog, ToastProvider
|
|
152
|
+
Avatar: [core] Show a person or entity as an image with an initials fallback. Use instead: Icon, Badge
|
|
153
|
+
Badge: [core] Label a status, state or count with a compact neutral or semantic chip, or a dot. Use instead: Tag, Alert
|
|
154
|
+
Box: [core] Build one-off layout that no named layout primitive covers, using token keys through `sx`. Use instead: Stack, Grid, Container
|
|
155
|
+
Breadcrumb: [core] Show where the current page sits in a hierarchy and link back up it. Use instead: Tabs, Pagination
|
|
156
|
+
Button: [core] Trigger an action (submit, save, open a dialog) with a text label and optional icons; for an icon-only control pass iconOnly with iconLeft and label; for an on/off toggle pass pressed. Use instead: InlineLink
|
|
157
|
+
Card: [core] Group related content on a raised surface with header, body, footer and metric slots, or as one selectable option. Use instead: Surface, Card.Metric
|
|
158
|
+
CardMetric: Show one headline figure (a KPI, a count, a total) with its label inside a Card. Use instead: MetricTiles
|
|
159
|
+
Checkbox: [core] Let people tick one or more independent options, or a parent choice that is partly selected. Use instead: Toggle, Radio
|
|
160
|
+
Combobox: [core] Pick one value, or several with `multiple`, from a long list of options, with a search field that filters as you type. Use instead: Select, Menu
|
|
161
|
+
Container: [core] Constrain a page region to the content or maximum width and centre it. Use instead: Stack, Grid, Box
|
|
162
|
+
Dialog: [core] Interrupt the page with a modal that needs a decision or focused input before people continue. Use instead: Tooltip, Alert, ToastProvider, AlertDialog
|
|
163
|
+
Disclosure: [core] Hide optional explanatory content behind a heading that people can expand. Use instead: Tabs
|
|
164
|
+
Divider: [core] Separate two regions of content with a thin semantic rule. Use instead: Stack, Surface
|
|
165
|
+
EmptyState: [core] Say that a list, grid or section has no data yet, with a title and an optional description. Use instead: Skeleton, Alert
|
|
166
|
+
Field: [core] Show a labelled read-only value, such as a name and its value in a detail view. Use instead: Input, Card.Metric
|
|
167
|
+
Grid: [core] Lay out content in responsive columns with token-governed gaps, or align nested content with subgrid. Use instead: Stack, Box
|
|
168
|
+
HdsRouterProvider: [core] Wrap the app root once so HDS links and navigation use your client router; with no provider they stay plain anchors.
|
|
169
|
+
HdsThemeProvider: [core] Wrap an app or region once to set theme, density and other root attributes for everything inside it. Use instead: Surface
|
|
170
|
+
Icon: [core] Draw a Lucide glyph at a size and colour from the design tokens. Use instead: Button, Avatar
|
|
171
|
+
InlineLink: [core] Link to a route or external URL from inside body copy. Use instead: Button, Text
|
|
172
|
+
Input: [core] Collect a single line of text, a number, an email, a password, a date or a time, with label, helper and error slots. Use instead: Textarea, Select, Combobox
|
|
173
|
+
Kbd: [core] Show a keyboard key or shortcut hint inline, as a native kbd element. Use instead: Text
|
|
174
|
+
Menu: [core] Offer a list of actions from a trigger, closed until opened. Use instead: Select
|
|
175
|
+
Pagination: [core] Move between pages of a long result set, with truncated page numbers. Use instead: Breadcrumb
|
|
176
|
+
Popover: [core] Anchor interactive content, such as a short form, a filter set or a picker, to a trigger people click to open. Use instead: Tooltip, Menu, Dialog
|
|
177
|
+
Progress: [core] Show how far a task has got, as a bar or ring that is determinate or indeterminate. Use instead: Spinner, Skeleton
|
|
178
|
+
Radio: [core] Choose exactly one option from a small set that should stay visible together. Use instead: Checkbox, Select, SegmentedControl
|
|
179
|
+
SegmentedControl: [core] Switch between two to five mutually exclusive views or modes in a compact row. Use instead: Radio, Tabs, Select
|
|
180
|
+
Select: [core] Choose one value from a short list of options in a form field. Use instead: Menu, Combobox
|
|
181
|
+
Skeleton: [core] Reserve the shape of content that is still loading, so the layout does not jump. Use instead: Progress, Spinner
|
|
182
|
+
Slider: [core] Pick a number within a known range by dragging, when the exact value matters less than the position. Use instead: Input
|
|
183
|
+
Spinner: [core] Show that something is loading when the wait is short or has no measurable end. Use instead: Progress, Skeleton
|
|
184
|
+
Stack: [core] Space a row or column of content with token gaps and simple flex alignment. Use instead: Grid, Surface
|
|
185
|
+
Stat: Show one headline figure inline, inside prose or a dense list, with its label and an optional sub-line. Use instead: MetricTiles, Card.Metric, StatusTile
|
|
186
|
+
StatusTile: Show a titled status block with optional notes and a trailing badge or affordance. Use instead: MetricTiles, Card.Metric, StatusListItem
|
|
187
|
+
Surface: [core] Wrap content in a padded, background-bearing inset surface with no header or footer anatomy. Use instead: Card, Stack
|
|
188
|
+
Table: [core] Show rows of structured data in aligned columns, with optional sorting. Use instead: Field, Stack
|
|
189
|
+
Tabs: [core] Switch between panels of related content in the same place, one visible at a time. Use instead: SegmentedControl, Disclosure
|
|
190
|
+
Tag: [core] Show an interactive filter or category chip that people can toggle. Use instead: Badge
|
|
191
|
+
Text: [core] Set any text on the type ramp, with the element chosen by `as`. Use instead: InlineLink, Kbd
|
|
192
|
+
Textarea: [core] Collect multi-line free text such as a message, note or description. Use instead: Input
|
|
193
|
+
ToastProvider: [core] Confirm an action with a brief message that appears and dismisses itself, through useToast. Use instead: Alert, Dialog
|
|
194
|
+
Toggle: [core] Switch one setting on or off, with the effect applying immediately. Use instead: Checkbox, Radio
|
|
195
|
+
Tooltip: [core] Name an icon-only control, or add a short hint that appears on hover and keyboard focus. Use instead: Popover, Text
|
|
196
|
+
VisuallyHidden: [core] Give assistive technology a label or description that sighted people do not need to see. Use instead: Text
|
|
89
197
|
|
|
90
198
|
## Tokens (Primary Source Of Truth)
|
|
91
199
|
|
|
@@ -114,7 +222,7 @@ Canonical skeleton, outermost to innermost:
|
|
|
114
222
|
2. `Stack` (vertical rhythm between sections) or `Grid` (two-dimensional/column layout) for the structural skeleton. One section = one Section/Stack — never add a second wrapper to fake a section boundary.
|
|
115
223
|
3. Reach for a named layout primitive before hand-rolling flex/grid math for a common intent: `Stack direction="row" wrap="wrap"` (wrapping row of same-ish things), `Sidebar` (fixed-width rail + fluid content, no media query), `Switcher` (row that flips to a column below a threshold, no media query). A full-height shell with a centered main region, an aspect-ratio-locked media box or a negative margin that escapes a parent padding is a `Box` with `style` (not `sx`, which applies on the client only).
|
|
116
224
|
4. `Surface` for any background-bearing, padded wrapper (card, panel, inset). Never a raw element with backgroundColor + padding hand-rolled inline.
|
|
117
|
-
5. Use the screen patterns (`@hirobius/design-system/patterns`) for the parts every screen repeats: `PageHeader` once at the top (breadcrumb, `heading2` title, status, actions), `MetricTiles` for any row of headline numbers, `FormActions` for a form footer (primary right-most and last in DOM order, destructive on the far left), `DataTableSection` for a titled table (toolbar slot, consumer row actions, empty state, scrolls on narrow widths without a caller `minWidth`), and `DestructiveSection` last for an irreversible action (danger button, then an `AlertDialog` confirm).
|
|
225
|
+
5. Use the screen patterns (`@hirobius/design-system/patterns`) for the parts every screen repeats: `PageHeader` once at the top (breadcrumb, `heading2` title, status, actions), `MetricTiles` for any row of headline numbers, `FormActions` for a form footer (primary right-most and last in DOM order, destructive on the far left), `DataTableSection` for a titled table (toolbar slot, consumer row actions, empty state, scrolls on narrow widths without a caller `minWidth`), and `DestructiveSection` last for an irreversible action (danger button, then an `AlertDialog` confirm). A row of headline numbers is always `MetricTiles`; `Stat`, `Card.Metric` and `StatusTile` answer other needs (see "Pick By Need" in `llms.txt`). Pick between `Card` and `Surface` with the "Which one, when" table in `DESIGN.md`.
|
|
118
226
|
6. `Box` `sx` LAST — only for genuinely one-off layout that no named primitive covers. `sx` spacing/color keys MUST be HDS token keys, never raw hex/px.
|
|
119
227
|
|
|
120
228
|
Negative rules (apply everywhere, checked by `scripts/audit-tokens.mjs --full`, `check-hardcoded-spacing.mjs`, `check-hardcoded-colors.mjs`):
|
package/mcp/catalog.mjs
ADDED
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `hds` MCP server's tools, built from the data the package already ships.
|
|
3
|
+
*
|
|
4
|
+
* Interface: `loadCatalog(packageRoot)` returns `{ instructions, tools }`, where
|
|
5
|
+
* each tool is `{ name, description, inputSchema, run(args) }` and `run` returns
|
|
6
|
+
* a plain object the server serialises. Every result is kept under RESULT_BUDGET
|
|
7
|
+
* bytes as it travels (the JSON text, escaped again inside the JSON-RPC
|
|
8
|
+
* response line): an agent asks a narrow question and gets a narrow answer, never
|
|
9
|
+
* the 400 KB manifest.
|
|
10
|
+
*
|
|
11
|
+
* Sources, all inside the installed package:
|
|
12
|
+
* src/app/data/component-api.json props, descriptions, usage contracts
|
|
13
|
+
* public/hds-manifest.json compound parts, keyboard, tokens (cssVar, light/dark values)
|
|
14
|
+
* codemods/patterns-subpath.names.json which names import from /patterns
|
|
15
|
+
* mcp/guide.mjs which component answers which need
|
|
16
|
+
*/
|
|
17
|
+
import { readFileSync } from 'node:fs';
|
|
18
|
+
import { join } from 'node:path';
|
|
19
|
+
import { CORE_COMPONENTS } from './core-set.mjs';
|
|
20
|
+
import { HOOKS, INTENTS, recommendedComponents } from './guide.mjs';
|
|
21
|
+
|
|
22
|
+
export const RESULT_BUDGET = 1900;
|
|
23
|
+
|
|
24
|
+
/** Bytes a result costs inside a tools/call response: its JSON, escaped as a string. */
|
|
25
|
+
const bytes = (value) => Buffer.byteLength(JSON.stringify(JSON.stringify(value)));
|
|
26
|
+
|
|
27
|
+
const ROOT_IMPORT = '@hirobius/design-system';
|
|
28
|
+
|
|
29
|
+
const STOPWORDS = new Set(
|
|
30
|
+
'a an and as at by for from in into is it of on or the to with without show use'.split(' '),
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
const readJson = (root, rel) => JSON.parse(readFileSync(join(root, rel), 'utf8'));
|
|
34
|
+
|
|
35
|
+
const words = (text) =>
|
|
36
|
+
String(text ?? '')
|
|
37
|
+
.toLowerCase()
|
|
38
|
+
.split(/[^a-z0-9.]+/)
|
|
39
|
+
.filter((w) => w && !STOPWORDS.has(w));
|
|
40
|
+
|
|
41
|
+
function firstSentence(text = '', max = 160) {
|
|
42
|
+
const flat = String(text).replace(/\s+/g, ' ').trim();
|
|
43
|
+
const m = /^(.+?[.!?])(?=\s|$)/.exec(flat);
|
|
44
|
+
const s = m ? m[1] : flat;
|
|
45
|
+
return s.length > max ? `${s.slice(0, max - 1)}…` : s;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** Levenshtein distance, for "did you mean" on a misspelt component name. */
|
|
49
|
+
function editDistance(a, b) {
|
|
50
|
+
let prev = Array.from({ length: b.length + 1 }, (_, j) => j);
|
|
51
|
+
for (let i = 1; i <= a.length; i += 1) {
|
|
52
|
+
const cur = [i];
|
|
53
|
+
for (let j = 1; j <= b.length; j += 1) {
|
|
54
|
+
cur[j] = Math.min(prev[j] + 1, cur[j - 1] + 1, prev[j - 1] + (a[i - 1] === b[j - 1] ? 0 : 1));
|
|
55
|
+
}
|
|
56
|
+
prev = cur;
|
|
57
|
+
}
|
|
58
|
+
return prev[b.length];
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** Drops the entries of `list` from the end until `make(list)` fits the budget. */
|
|
62
|
+
function fitList(list, make) {
|
|
63
|
+
let n = list.length;
|
|
64
|
+
let out = make(list, 0);
|
|
65
|
+
while (n > 0 && bytes(out) > RESULT_BUDGET) {
|
|
66
|
+
n -= 1;
|
|
67
|
+
out = make(list.slice(0, n), list.length - n);
|
|
68
|
+
}
|
|
69
|
+
return out;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export function loadCatalog(root) {
|
|
73
|
+
const api = readJson(root, 'src/app/data/component-api.json').components;
|
|
74
|
+
const manifest = readJson(root, 'public/hds-manifest.json');
|
|
75
|
+
const patternNames = new Set(readJson(root, 'codemods/patterns-subpath.names.json').names);
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* The flags both search_components and get_component put on a component:
|
|
79
|
+
* `core` for the ratified core set, `recommended` for the rest of what the guide prefers, `insteadFor` for each need it is the
|
|
80
|
+
* wrong answer to (the guide names `use` instead).
|
|
81
|
+
*/
|
|
82
|
+
const steer = (name) => {
|
|
83
|
+
const insteadFor = INTENTS.filter((i) => i.avoid.includes(name)).map((i) => ({
|
|
84
|
+
need: i.need,
|
|
85
|
+
use: i.use[0],
|
|
86
|
+
}));
|
|
87
|
+
return {
|
|
88
|
+
...(ratified.has(name) ? { core: true } : recommended.has(name) ? { recommended: true } : {}),
|
|
89
|
+
...(insteadFor.length ? { insteadFor } : {}),
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
const ratified = new Set(CORE_COMPONENTS);
|
|
93
|
+
const recommended = new Set(recommendedComponents());
|
|
94
|
+
const components = Object.keys(api)
|
|
95
|
+
.filter((name) => !api[name].hidden)
|
|
96
|
+
.sort();
|
|
97
|
+
const byLower = new Map(components.map((n) => [n.toLowerCase(), n]));
|
|
98
|
+
const importOf = (name) => (patternNames.has(name) ? `${ROOT_IMPORT}/patterns` : ROOT_IMPORT);
|
|
99
|
+
|
|
100
|
+
const tokens = Object.values(manifest.tokens ?? {}).flat();
|
|
101
|
+
|
|
102
|
+
// Flat aliases of compound parts (DialogContent for Dialog.Content): searchable by
|
|
103
|
+
// exact name only, so a purpose search returns the root component, not its parts.
|
|
104
|
+
const partAliases = new Set();
|
|
105
|
+
for (const [name, spec] of Object.entries(manifest.componentSpecs ?? {})) {
|
|
106
|
+
for (const m of spec.compoundMembers ?? [])
|
|
107
|
+
partAliases.add(`${name}${typeof m === 'string' ? m : m.name}`);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// ── search_components ───────────────────────────────────────────────────
|
|
111
|
+
function rankComponents(query) {
|
|
112
|
+
const q = String(query ?? '').trim();
|
|
113
|
+
const qWords = words(q);
|
|
114
|
+
const compact = q.toLowerCase().replace(/[^a-z0-9]/g, '');
|
|
115
|
+
const scores = new Map(components.map((n) => [n, 0]));
|
|
116
|
+
const add = (name, n) => scores.has(name) && scores.set(name, scores.get(name) + n);
|
|
117
|
+
|
|
118
|
+
const matchedIntents = [];
|
|
119
|
+
for (const intent of INTENTS) {
|
|
120
|
+
const hits =
|
|
121
|
+
q.toLowerCase() === intent.id
|
|
122
|
+
? 3
|
|
123
|
+
: qWords.filter((w) => intent.keywords.includes(w)).length;
|
|
124
|
+
if (!hits) continue;
|
|
125
|
+
matchedIntents.push({ intent, hits });
|
|
126
|
+
intent.use.forEach((name, i) => add(name, 10 * hits + (i === 0 ? 5 : 0)));
|
|
127
|
+
}
|
|
128
|
+
for (const name of components) {
|
|
129
|
+
const lower = name.toLowerCase();
|
|
130
|
+
if (lower === compact) add(name, 100);
|
|
131
|
+
else if (partAliases.has(name) && !recommended.has(name)) continue;
|
|
132
|
+
else if (qWords.some((w) => w.length > 2 && (lower.includes(w) || w.includes(lower))))
|
|
133
|
+
add(name, 20);
|
|
134
|
+
const entry = api[name];
|
|
135
|
+
const text = words(`${entry.description} ${entry.usage?.when ?? ''}`);
|
|
136
|
+
add(name, 2 * qWords.filter((w) => text.includes(w)).length);
|
|
137
|
+
if (scores.get(name) > 0) {
|
|
138
|
+
if (recommended.has(name)) add(name, 1);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
const ranked = components
|
|
142
|
+
.filter((n) => scores.get(n) > 0)
|
|
143
|
+
.sort((a, b) => scores.get(b) - scores.get(a) || (a < b ? -1 : 1));
|
|
144
|
+
matchedIntents.sort((a, b) => b.hits - a.hits);
|
|
145
|
+
return { ranked, intents: matchedIntents.map((m) => m.intent) };
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function searchComponents({ query, limit = 8 }) {
|
|
149
|
+
if (!String(query ?? '').trim()) throw new Error('query is required, e.g. "confirm delete"');
|
|
150
|
+
const { ranked, intents } = rankComponents(query);
|
|
151
|
+
const top = ranked.slice(0, Math.min(Math.max(1, limit), 8)).map((name) => ({
|
|
152
|
+
name,
|
|
153
|
+
import: importOf(name),
|
|
154
|
+
summary: firstSentence(api[name].usage?.when || api[name].description, 120),
|
|
155
|
+
...steer(name),
|
|
156
|
+
}));
|
|
157
|
+
return fitList(top, (results) => ({
|
|
158
|
+
results,
|
|
159
|
+
needs: intents.slice(0, 2).map((i) => ({ need: i.need, use: i.use })),
|
|
160
|
+
}));
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// ── get_component ───────────────────────────────────────────────────────
|
|
164
|
+
function getComponent({ name }) {
|
|
165
|
+
const base = String(name ?? '')
|
|
166
|
+
.trim()
|
|
167
|
+
.split('.')[0];
|
|
168
|
+
const canonical = byLower.get(base.toLowerCase()) ?? (HOOKS[base] ? base : null);
|
|
169
|
+
if (!canonical) {
|
|
170
|
+
const target = base.toLowerCase();
|
|
171
|
+
const close = components
|
|
172
|
+
.map((n) => ({ n, d: editDistance(n.toLowerCase(), target) }))
|
|
173
|
+
.filter((c) => c.d <= Math.max(2, Math.floor(target.length / 3)))
|
|
174
|
+
.sort((a, b) => a.d - b.d || (a.n < b.n ? -1 : 1))
|
|
175
|
+
.slice(0, 3)
|
|
176
|
+
.map((c) => c.n);
|
|
177
|
+
throw new Error(
|
|
178
|
+
`No component named "${name}".${close.length ? ` Did you mean: ${close.join(', ')}?` : ''} Use search_components to find one.`,
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
if (HOOKS[canonical]) return { name: canonical, kind: 'hook', ...HOOKS[canonical] };
|
|
182
|
+
|
|
183
|
+
const entry = api[canonical];
|
|
184
|
+
const spec = manifest.componentSpecs?.[canonical] ?? {};
|
|
185
|
+
const guide = INTENTS.filter((i) => i.use.includes(canonical)).map((i) => ({
|
|
186
|
+
need: i.need,
|
|
187
|
+
how: i.how,
|
|
188
|
+
}));
|
|
189
|
+
const propLine = (p, withDesc, typeMax) => {
|
|
190
|
+
const type = p.type.length > typeMax ? `${p.type.slice(0, typeMax - 1)}…` : p.type;
|
|
191
|
+
const def = p.default !== undefined ? ` = ${p.default}` : '';
|
|
192
|
+
const desc = withDesc && p.description ? ` — ${firstSentence(p.description, 90)}` : '';
|
|
193
|
+
return `${p.name}${p.required ? '' : '?'}: ${type}${def}${desc}`;
|
|
194
|
+
};
|
|
195
|
+
const build = (withDesc, typeMax, withHow) => ({
|
|
196
|
+
name: canonical,
|
|
197
|
+
import: importOf(canonical),
|
|
198
|
+
category: entry.category,
|
|
199
|
+
summary: firstSentence(entry.description, 200),
|
|
200
|
+
...steer(canonical),
|
|
201
|
+
...(entry.usage?.when ? { when: entry.usage.when } : {}),
|
|
202
|
+
...(entry.usage?.whenNot ? { whenNot: entry.usage.whenNot } : {}),
|
|
203
|
+
...(entry.usage?.useInstead?.length
|
|
204
|
+
? { useInstead: entry.usage.useInstead.map((u) => `${u.component}: ${u.reason}`) }
|
|
205
|
+
: {}),
|
|
206
|
+
...(spec.compoundMembers?.length
|
|
207
|
+
? {
|
|
208
|
+
parts: spec.compoundMembers.map(
|
|
209
|
+
(m) => `${canonical}.${typeof m === 'string' ? m : m.name}`,
|
|
210
|
+
),
|
|
211
|
+
}
|
|
212
|
+
: {}),
|
|
213
|
+
props: (entry.props ?? []).map((p) => propLine(p, withDesc, typeMax)),
|
|
214
|
+
...(guide.length ? { guide: withHow ? guide : guide.map((g) => ({ need: g.need })) } : {}),
|
|
215
|
+
});
|
|
216
|
+
for (const [withDesc, typeMax, withHow] of [
|
|
217
|
+
[true, 80, true],
|
|
218
|
+
[false, 80, true],
|
|
219
|
+
[false, 48, true],
|
|
220
|
+
[false, 48, false],
|
|
221
|
+
]) {
|
|
222
|
+
const out = build(withDesc, typeMax, withHow);
|
|
223
|
+
if (bytes(out) <= RESULT_BUDGET) return out;
|
|
224
|
+
}
|
|
225
|
+
const out = build(false, 32, false);
|
|
226
|
+
return fitList(out.props, (props, dropped) => ({
|
|
227
|
+
...out,
|
|
228
|
+
props,
|
|
229
|
+
...(dropped ? { propsOmitted: dropped, propsSource: 'src/app/data/component-api.json' } : {}),
|
|
230
|
+
}));
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// ── search_tokens ───────────────────────────────────────────────────────
|
|
234
|
+
const tokenRow = (t) => ({
|
|
235
|
+
path: t.path,
|
|
236
|
+
cssVar: t.cssVar,
|
|
237
|
+
value: t.resolvedValue ?? t.value ?? t.composite ?? null,
|
|
238
|
+
...(t.dark ? { dark: t.dark.resolvedValue ?? t.dark.value } : {}),
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
function searchTokens({ query, limit = 25 }) {
|
|
242
|
+
const q = String(query ?? '')
|
|
243
|
+
.trim()
|
|
244
|
+
.toLowerCase()
|
|
245
|
+
.replace(/^--/, '')
|
|
246
|
+
.replace(/^var\(--|\)$/g, '');
|
|
247
|
+
if (!q)
|
|
248
|
+
throw new Error(
|
|
249
|
+
'query is required: a path, a prefix ("semantic.space") or a word ("surface")',
|
|
250
|
+
);
|
|
251
|
+
const exact = tokens.find(
|
|
252
|
+
(t) => t.path.toLowerCase() === q || t.cssVar?.toLowerCase() === `--${q}`,
|
|
253
|
+
);
|
|
254
|
+
if (exact) {
|
|
255
|
+
return {
|
|
256
|
+
token: {
|
|
257
|
+
...tokenRow(exact),
|
|
258
|
+
type: exact.type,
|
|
259
|
+
...(exact.alias ? { alias: exact.alias } : {}),
|
|
260
|
+
description: firstSentence(exact.description, 300),
|
|
261
|
+
},
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
const tierRank = { semantic: 0, role: 1, component: 2, primitive: 3 };
|
|
265
|
+
const qWords = q.split(/[\s,]+/).filter(Boolean);
|
|
266
|
+
const matches = tokens
|
|
267
|
+
.map((t) => {
|
|
268
|
+
const path = t.path.toLowerCase();
|
|
269
|
+
let score = 0;
|
|
270
|
+
if (path.startsWith(`${q}.`) || path.startsWith(q)) score = 3;
|
|
271
|
+
else if (qWords.every((w) => path.includes(w))) score = 2;
|
|
272
|
+
else if (qWords.every((w) => `${path} ${t.description ?? ''}`.toLowerCase().includes(w)))
|
|
273
|
+
score = 1;
|
|
274
|
+
return { t, score };
|
|
275
|
+
})
|
|
276
|
+
.filter((m) => m.score > 0)
|
|
277
|
+
.sort(
|
|
278
|
+
(a, b) =>
|
|
279
|
+
b.score - a.score ||
|
|
280
|
+
(tierRank[a.t.path.split('.')[0]] ?? 9) - (tierRank[b.t.path.split('.')[0]] ?? 9) ||
|
|
281
|
+
(a.t.path < b.t.path ? -1 : 1),
|
|
282
|
+
);
|
|
283
|
+
const cap = Math.min(Math.max(1, limit), 40);
|
|
284
|
+
const rows = matches.slice(0, cap).map((m) => tokenRow(m.t));
|
|
285
|
+
return fitList(rows, (results) => ({
|
|
286
|
+
total: matches.length,
|
|
287
|
+
results,
|
|
288
|
+
...(matches.length > results.length ? { more: matches.length - results.length } : {}),
|
|
289
|
+
}));
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
// ── list_core ───────────────────────────────────────────────────────────
|
|
293
|
+
function listCore() {
|
|
294
|
+
const names = [...recommended].filter((n) => api[n]);
|
|
295
|
+
// `id → use`: short enough that every need fits; search_components takes the id.
|
|
296
|
+
const needs = INTENTS.map((i) => `${i.id} → ${i.use.join(', ')}`);
|
|
297
|
+
// Needs are ordered most common first; what does not fit is one search_components away.
|
|
298
|
+
return fitList(needs, (shown, dropped) => ({
|
|
299
|
+
set: 'recommended: the ratified core plus what the needs name',
|
|
300
|
+
root: names.filter((n) => !patternNames.has(n)),
|
|
301
|
+
patterns: names.filter((n) => patternNames.has(n)),
|
|
302
|
+
hooks: Object.keys(HOOKS),
|
|
303
|
+
needs: shown,
|
|
304
|
+
...(dropped ? { moreNeeds: dropped, forMore: 'search_components with the need' } : {}),
|
|
305
|
+
}));
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
const tools = [
|
|
309
|
+
{
|
|
310
|
+
name: 'search_components',
|
|
311
|
+
description:
|
|
312
|
+
'Find HDS components by name or by what you need ("row of headline numbers", "confirm delete"). Returns up to 8 matches with their import path, and the guide entry for the need.',
|
|
313
|
+
inputSchema: {
|
|
314
|
+
type: 'object',
|
|
315
|
+
properties: {
|
|
316
|
+
query: { type: 'string', description: 'A component name or a plain-language need.' },
|
|
317
|
+
limit: { type: 'integer', minimum: 1, maximum: 8 },
|
|
318
|
+
},
|
|
319
|
+
required: ['query'],
|
|
320
|
+
},
|
|
321
|
+
run: searchComponents,
|
|
322
|
+
},
|
|
323
|
+
{
|
|
324
|
+
name: 'get_component',
|
|
325
|
+
description:
|
|
326
|
+
"One component's import path, usage contract (when, when not, use instead), props and compound parts, plus how the guide says to use it. Call before using a component.",
|
|
327
|
+
inputSchema: {
|
|
328
|
+
type: 'object',
|
|
329
|
+
properties: {
|
|
330
|
+
name: {
|
|
331
|
+
type: 'string',
|
|
332
|
+
description: 'Component name, e.g. "MetricTiles" or "AlertDialog".',
|
|
333
|
+
},
|
|
334
|
+
},
|
|
335
|
+
required: ['name'],
|
|
336
|
+
},
|
|
337
|
+
run: getComponent,
|
|
338
|
+
},
|
|
339
|
+
{
|
|
340
|
+
name: 'search_tokens',
|
|
341
|
+
description:
|
|
342
|
+
'Look up design tokens. An exact path or CSS variable returns that token with its description; a prefix ("semantic.space") or words ("surface page") return matching tokens, semantic tier first, with CSS variable and light/dark values.',
|
|
343
|
+
inputSchema: {
|
|
344
|
+
type: 'object',
|
|
345
|
+
properties: {
|
|
346
|
+
query: { type: 'string', description: 'Token path, prefix, CSS variable or words.' },
|
|
347
|
+
limit: { type: 'integer', minimum: 1, maximum: 40 },
|
|
348
|
+
},
|
|
349
|
+
required: ['query'],
|
|
350
|
+
},
|
|
351
|
+
run: searchTokens,
|
|
352
|
+
},
|
|
353
|
+
{
|
|
354
|
+
name: 'list_core',
|
|
355
|
+
description:
|
|
356
|
+
'The core components to prefer, split by import path, the hooks, and one line per screen need (`id → components`; pass an id to search_components for its usage line). Call this first.',
|
|
357
|
+
inputSchema: { type: 'object', properties: {} },
|
|
358
|
+
run: listCore,
|
|
359
|
+
},
|
|
360
|
+
];
|
|
361
|
+
|
|
362
|
+
const instructions = [
|
|
363
|
+
'Lookups for @hirobius/design-system (HDS). Call list_core first, then get_component for each component before you use it.',
|
|
364
|
+
'Import pattern-tier components (Page, PageHeader, MetricTiles, DataTableSection, Form, FormActions) from @hirobius/design-system/patterns, everything else from @hirobius/design-system.',
|
|
365
|
+
'Style with component props and semantic tokens only (search_tokens); no raw hex, px or Tailwind classes. The package AGENTS.md has the full rules.',
|
|
366
|
+
].join(' ');
|
|
367
|
+
|
|
368
|
+
return { instructions, tools };
|
|
369
|
+
}
|