rudiment-ui 0.5.0 → 0.6.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/README.md +59 -21
- package/dist/components/Alert/Alert.d.ts +28 -1
- package/dist/components/Alert/Alert.d.ts.map +1 -1
- package/dist/components/AppShell/AppShell.d.ts +52 -6
- package/dist/components/AppShell/AppShell.d.ts.map +1 -1
- package/dist/components/Avatar/Avatar.d.ts +21 -1
- package/dist/components/Avatar/Avatar.d.ts.map +1 -1
- package/dist/components/Badge/Badge.d.ts +23 -0
- package/dist/components/Badge/Badge.d.ts.map +1 -1
- package/dist/components/Brand/Brand.d.ts +17 -2
- package/dist/components/Brand/Brand.d.ts.map +1 -1
- package/dist/components/Breadcrumb/Breadcrumb.d.ts +24 -2
- package/dist/components/Breadcrumb/Breadcrumb.d.ts.map +1 -1
- package/dist/components/Button/Button.d.ts +31 -0
- package/dist/components/Button/Button.d.ts.map +1 -1
- package/dist/components/Card/Card.d.ts +34 -0
- package/dist/components/Card/Card.d.ts.map +1 -1
- package/dist/components/Charts/BarChart/BarChart.d.ts +39 -4
- package/dist/components/Charts/BarChart/BarChart.d.ts.map +1 -1
- package/dist/components/Charts/DonutChart/DonutChart.d.ts +31 -0
- package/dist/components/Charts/DonutChart/DonutChart.d.ts.map +1 -1
- package/dist/components/Charts/LineChart/LineChart.d.ts +52 -6
- package/dist/components/Charts/LineChart/LineChart.d.ts.map +1 -1
- package/dist/components/Charts/Sparkline/Sparkline.d.ts +35 -0
- package/dist/components/Charts/Sparkline/Sparkline.d.ts.map +1 -0
- package/dist/components/Checkbox/Checkbox.d.ts +26 -3
- package/dist/components/Checkbox/Checkbox.d.ts.map +1 -1
- package/dist/components/Checkbox/CheckboxGroup.d.ts +20 -0
- package/dist/components/Checkbox/CheckboxGroup.d.ts.map +1 -1
- package/dist/components/CircularProgress/CircularProgress.d.ts +33 -0
- package/dist/components/CircularProgress/CircularProgress.d.ts.map +1 -1
- package/dist/components/ComboBox/ComboBox.d.ts +29 -4
- package/dist/components/ComboBox/ComboBox.d.ts.map +1 -1
- package/dist/components/DatePicker/DatePicker.d.ts +30 -2
- package/dist/components/DatePicker/DatePicker.d.ts.map +1 -1
- package/dist/components/DatePicker/DateRangePicker.d.ts +26 -1
- package/dist/components/DatePicker/DateRangePicker.d.ts.map +1 -1
- package/dist/components/DatePicker/dateUtils.d.ts +1 -0
- package/dist/components/DatePicker/dateUtils.d.ts.map +1 -1
- package/dist/components/DescriptionList/DescriptionList.d.ts +44 -0
- package/dist/components/DescriptionList/DescriptionList.d.ts.map +1 -0
- package/dist/components/Dialog/Dialog.d.ts +39 -0
- package/dist/components/Dialog/Dialog.d.ts.map +1 -1
- package/dist/components/Divider/Divider.d.ts +18 -5
- package/dist/components/Divider/Divider.d.ts.map +1 -1
- package/dist/components/Dot/Dot.d.ts +22 -8
- package/dist/components/Dot/Dot.d.ts.map +1 -1
- package/dist/components/EmptyState/EmptyState.d.ts +23 -2
- package/dist/components/EmptyState/EmptyState.d.ts.map +1 -1
- package/dist/components/Form/Form.d.ts +20 -1
- package/dist/components/Form/Form.d.ts.map +1 -1
- package/dist/components/Icon/Icon.d.ts +17 -0
- package/dist/components/Icon/Icon.d.ts.map +1 -1
- package/dist/components/IconButton/IconButton.d.ts +24 -0
- package/dist/components/IconButton/IconButton.d.ts.map +1 -1
- package/dist/components/Image/Image.d.ts +31 -6
- package/dist/components/Image/Image.d.ts.map +1 -1
- package/dist/components/Input/Input.d.ts +32 -0
- package/dist/components/Input/Input.d.ts.map +1 -1
- package/dist/components/Kanban/KanbanBoard.d.ts +32 -0
- package/dist/components/Kanban/KanbanBoard.d.ts.map +1 -1
- package/dist/components/Kanban/KanbanCard.d.ts +12 -1
- package/dist/components/Kanban/KanbanCard.d.ts.map +1 -1
- package/dist/components/Kanban/KanbanColumn.d.ts +13 -0
- package/dist/components/Kanban/KanbanColumn.d.ts.map +1 -1
- package/dist/components/Kanban/KanbanOverlayContext.d.ts +7 -0
- package/dist/components/Kanban/KanbanOverlayContext.d.ts.map +1 -0
- package/dist/components/Kanban/kanbanMoves.d.ts +18 -0
- package/dist/components/Kanban/kanbanMoves.d.ts.map +1 -0
- package/dist/components/Link/Link.d.ts +24 -3
- package/dist/components/Link/Link.d.ts.map +1 -1
- package/dist/components/Menu/Keyboard.d.ts +9 -0
- package/dist/components/Menu/Keyboard.d.ts.map +1 -1
- package/dist/components/Menu/Menu.d.ts +13 -0
- package/dist/components/Menu/Menu.d.ts.map +1 -1
- package/dist/components/Menu/MenuItem.d.ts +11 -0
- package/dist/components/Menu/MenuItem.d.ts.map +1 -1
- package/dist/components/Menu/MenuSection.d.ts +12 -0
- package/dist/components/Menu/MenuSection.d.ts.map +1 -1
- package/dist/components/Menu/MenuSeparator.d.ts +8 -0
- package/dist/components/Menu/MenuSeparator.d.ts.map +1 -1
- package/dist/components/Menu/MenuTrigger.d.ts +16 -0
- package/dist/components/Menu/MenuTrigger.d.ts.map +1 -1
- package/dist/components/Menu/SubmenuTrigger.d.ts +13 -0
- package/dist/components/Menu/SubmenuTrigger.d.ts.map +1 -1
- package/dist/components/NavItem/NavItem.d.ts +14 -0
- package/dist/components/NavItem/NavItem.d.ts.map +1 -1
- package/dist/components/NumberField/NumberField.d.ts +36 -3
- package/dist/components/NumberField/NumberField.d.ts.map +1 -1
- package/dist/components/PageHeader/PageHeader.d.ts +18 -1
- package/dist/components/PageHeader/PageHeader.d.ts.map +1 -1
- package/dist/components/Pagination/Pagination.d.ts +19 -2
- package/dist/components/Pagination/Pagination.d.ts.map +1 -1
- package/dist/components/ProgressBar/ProgressBar.d.ts +36 -2
- package/dist/components/ProgressBar/ProgressBar.d.ts.map +1 -1
- package/dist/components/RadioGroup/Radio.d.ts +6 -1
- package/dist/components/RadioGroup/Radio.d.ts.map +1 -1
- package/dist/components/RadioGroup/RadioGroup.d.ts +24 -0
- package/dist/components/RadioGroup/RadioGroup.d.ts.map +1 -1
- package/dist/components/Rating/Rating.d.ts +26 -6
- package/dist/components/Rating/Rating.d.ts.map +1 -1
- package/dist/components/RouterProvider/RouterProvider.d.ts +1 -0
- package/dist/components/RouterProvider/RouterProvider.d.ts.map +1 -1
- package/dist/components/SectionHeader/SectionHeader.d.ts +14 -1
- package/dist/components/SectionHeader/SectionHeader.d.ts.map +1 -1
- package/dist/components/Select/Option.d.ts +8 -0
- package/dist/components/Select/Option.d.ts.map +1 -1
- package/dist/components/Select/Select.d.ts +29 -0
- package/dist/components/Select/Select.d.ts.map +1 -1
- package/dist/components/StatCard/StatCard.d.ts +23 -1
- package/dist/components/StatCard/StatCard.d.ts.map +1 -1
- package/dist/components/Stepper/Stepper.d.ts +34 -2
- package/dist/components/Stepper/Stepper.d.ts.map +1 -1
- package/dist/components/Switch/Switch.d.ts +13 -0
- package/dist/components/Switch/Switch.d.ts.map +1 -1
- package/dist/components/Table/Table.d.ts +31 -3
- package/dist/components/Table/Table.d.ts.map +1 -1
- package/dist/components/Table/TableBody.d.ts +7 -0
- package/dist/components/Table/TableBody.d.ts.map +1 -1
- package/dist/components/Table/TableCell.d.ts +11 -0
- package/dist/components/Table/TableCell.d.ts.map +1 -1
- package/dist/components/Table/TableColumn.d.ts +16 -1
- package/dist/components/Table/TableColumn.d.ts.map +1 -1
- package/dist/components/Table/TableHeader.d.ts +8 -1
- package/dist/components/Table/TableHeader.d.ts.map +1 -1
- package/dist/components/Table/TableRow.d.ts +10 -1
- package/dist/components/Table/TableRow.d.ts.map +1 -1
- package/dist/components/Tabs/Tab.d.ts +8 -0
- package/dist/components/Tabs/Tab.d.ts.map +1 -1
- package/dist/components/Tabs/TabList.d.ts +15 -1
- package/dist/components/Tabs/TabList.d.ts.map +1 -1
- package/dist/components/Tabs/TabPanel.d.ts +9 -0
- package/dist/components/Tabs/TabPanel.d.ts.map +1 -1
- package/dist/components/Tabs/Tabs.d.ts +11 -1
- package/dist/components/Tabs/Tabs.d.ts.map +1 -1
- package/dist/components/Tag/Tag.d.ts +27 -0
- package/dist/components/Tag/Tag.d.ts.map +1 -1
- package/dist/components/Textarea/Textarea.d.ts +43 -0
- package/dist/components/Textarea/Textarea.d.ts.map +1 -1
- package/dist/components/Toast/Toast.d.ts +17 -3
- package/dist/components/Toast/Toast.d.ts.map +1 -1
- package/dist/components/Toast/toastQueue.d.ts +20 -1
- package/dist/components/Toast/toastQueue.d.ts.map +1 -1
- package/dist/components/Tooltip/Tooltip.d.ts +32 -0
- package/dist/components/Tooltip/Tooltip.d.ts.map +1 -1
- package/dist/components/TopBar/TopBar.d.ts +17 -2
- package/dist/components/TopBar/TopBar.d.ts.map +1 -1
- package/dist/components.json +7919 -0
- package/dist/hooks/useChartTheme.d.ts +10 -0
- package/dist/hooks/useChartTheme.d.ts.map +1 -1
- package/dist/hooks/useLoadingButton.d.ts +10 -0
- package/dist/hooks/useLoadingButton.d.ts.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1858 -1621
- package/dist/layouts/Box/Box.d.ts +31 -1
- package/dist/layouts/Box/Box.d.ts.map +1 -1
- package/dist/layouts/Center/Center.d.ts +22 -0
- package/dist/layouts/Center/Center.d.ts.map +1 -1
- package/dist/layouts/Cluster/Cluster.d.ts +19 -0
- package/dist/layouts/Cluster/Cluster.d.ts.map +1 -1
- package/dist/layouts/Cover/Cover.d.ts +28 -0
- package/dist/layouts/Cover/Cover.d.ts.map +1 -1
- package/dist/layouts/Grid/Grid.d.ts +18 -0
- package/dist/layouts/Grid/Grid.d.ts.map +1 -1
- package/dist/layouts/Sidebar/Sidebar.d.ts +29 -0
- package/dist/layouts/Sidebar/Sidebar.d.ts.map +1 -1
- package/dist/layouts/Stack/Stack.d.ts +21 -2
- package/dist/layouts/Stack/Stack.d.ts.map +1 -1
- package/dist/layouts/Switcher/Switcher.d.ts +19 -0
- package/dist/layouts/Switcher/Switcher.d.ts.map +1 -1
- package/dist/llms-full.txt +2284 -0
- package/dist/llms.txt +162 -0
- package/dist/typography/Heading/Heading.d.ts +12 -0
- package/dist/typography/Heading/Heading.d.ts.map +1 -1
- package/dist/typography/Prose/Prose.d.ts +21 -0
- package/dist/typography/Prose/Prose.d.ts.map +1 -1
- package/dist/typography/Text/Text.d.ts +28 -1
- package/dist/typography/Text/Text.d.ts.map +1 -1
- package/dist/utils/cn.d.ts +7 -0
- package/dist/utils/cn.d.ts.map +1 -1
- package/mcp/README.md +111 -0
- package/mcp/render.mjs +116 -0
- package/mcp/server.mjs +321 -0
- package/package.json +12 -2
package/mcp/server.mjs
ADDED
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* rudiment-ui MCP server.
|
|
4
|
+
*
|
|
5
|
+
* Serves the API reference of the *installed* rudiment-ui version to coding agents
|
|
6
|
+
* over the Model Context Protocol (stdio transport). It reads `dist/components.json`,
|
|
7
|
+
* which the build generates from the TypeScript source and JSDoc, so its answers
|
|
8
|
+
* always match the code in node_modules.
|
|
9
|
+
*
|
|
10
|
+
* It has no dependencies: stdio MCP is newline-delimited JSON-RPC 2.0, and a UI library
|
|
11
|
+
* shouldn't make every consumer install an SDK for an optional dev tool.
|
|
12
|
+
*
|
|
13
|
+
* Run: `npx rudiment-ui-mcp` (see mcp/README.md for client setup).
|
|
14
|
+
* Override the manifest location with RUDIMENT_UI_MANIFEST=/path/to/components.json.
|
|
15
|
+
*/
|
|
16
|
+
import fs from 'node:fs'
|
|
17
|
+
import path from 'node:path'
|
|
18
|
+
import readline from 'node:readline'
|
|
19
|
+
import { fileURLToPath } from 'node:url'
|
|
20
|
+
import { componentIndex, componentMarkdown, firstSentence, functionMarkdown, typeMarkdown } from './render.mjs'
|
|
21
|
+
|
|
22
|
+
const HERE = path.dirname(fileURLToPath(import.meta.url))
|
|
23
|
+
const MANIFEST = process.env.RUDIMENT_UI_MANIFEST ?? path.join(HERE, '../dist/components.json')
|
|
24
|
+
const SUPPORTED_PROTOCOLS = ['2025-11-25', '2025-06-18', '2025-03-26', '2024-11-05']
|
|
25
|
+
const CATEGORIES = ['component', 'layout', 'typography', 'chart']
|
|
26
|
+
|
|
27
|
+
const INSTRUCTIONS = `Reference for the rudiment-ui React component library, generated from the installed version's source.
|
|
28
|
+
|
|
29
|
+
Workflow:
|
|
30
|
+
1. Call get_conventions once before writing UI code with rudiment-ui. The library has rules that differ from other React libraries: onPress instead of onClick, onChange receives a value, label is a required prop, icons are Iconify name strings, and layout spacing takes CSS lengths.
|
|
31
|
+
2. Call list_components to find candidates, or search when you know the behaviour you need but not the name (for example "drawer", "sortable", "required asterisk").
|
|
32
|
+
3. Call get_component for each component before using it. It returns every prop with its type, default and description, along with examples and compound parts (RudiCard.Header, …).
|
|
33
|
+
|
|
34
|
+
Prefer these answers over memory: they match the installed version exactly.`
|
|
35
|
+
|
|
36
|
+
// ------------------------------------------------------------------ data
|
|
37
|
+
|
|
38
|
+
let cache = null
|
|
39
|
+
function loadApi() {
|
|
40
|
+
if (cache) return cache
|
|
41
|
+
if (!fs.existsSync(MANIFEST)) {
|
|
42
|
+
throw new ToolError(
|
|
43
|
+
`rudiment-ui manifest not found at ${MANIFEST}. In the rudiment-ui repo, run \`npm run build\`. In a consumer project, reinstall rudiment-ui.`,
|
|
44
|
+
)
|
|
45
|
+
}
|
|
46
|
+
const api = JSON.parse(fs.readFileSync(MANIFEST, 'utf8'))
|
|
47
|
+
const entries = []
|
|
48
|
+
for (const c of api.components) {
|
|
49
|
+
entries.push({ kind: 'component', item: c, category: c.category })
|
|
50
|
+
for (const p of c.parts ?? []) entries.push({ kind: 'component', item: p, category: c.category, parent: c.name })
|
|
51
|
+
}
|
|
52
|
+
for (const f of api.functions) entries.push({ kind: 'function', item: f })
|
|
53
|
+
for (const t of api.types) entries.push({ kind: 'type', item: t })
|
|
54
|
+
cache = { api, entries }
|
|
55
|
+
return cache
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** "button", "Button", "RudiButton", "rudi-button" and "card.header" all resolve. */
|
|
59
|
+
const normalise = (name) =>
|
|
60
|
+
String(name)
|
|
61
|
+
.trim()
|
|
62
|
+
.replace(/^<|\/?>$/g, '')
|
|
63
|
+
.replace(/[-_\s]/g, '')
|
|
64
|
+
.toLowerCase()
|
|
65
|
+
.replace(/^rudi(?=.)/, '')
|
|
66
|
+
|
|
67
|
+
function findEntry(name) {
|
|
68
|
+
const { entries } = loadApi()
|
|
69
|
+
const key = normalise(name)
|
|
70
|
+
return entries.find((e) => normalise(e.item.name) === key) ?? null
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** Closest names for a typo, by shared-prefix and substring match. */
|
|
74
|
+
function suggestions(name, limit = 5) {
|
|
75
|
+
const key = normalise(name)
|
|
76
|
+
const { entries } = loadApi()
|
|
77
|
+
return entries
|
|
78
|
+
.map((e) => {
|
|
79
|
+
const n = normalise(e.item.name)
|
|
80
|
+
let score = 0
|
|
81
|
+
if (n.includes(key) || key.includes(n)) score += 10
|
|
82
|
+
let i = 0
|
|
83
|
+
while (i < n.length && i < key.length && n[i] === key[i]) i++
|
|
84
|
+
score += i
|
|
85
|
+
return { name: e.item.name, score }
|
|
86
|
+
})
|
|
87
|
+
.filter((s) => s.score > 2)
|
|
88
|
+
.sort((a, b) => b.score - a.score)
|
|
89
|
+
.slice(0, limit)
|
|
90
|
+
.map((s) => s.name)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// ----------------------------------------------------------------- tools
|
|
94
|
+
|
|
95
|
+
class ToolError extends Error {}
|
|
96
|
+
|
|
97
|
+
const TOOLS = [
|
|
98
|
+
{
|
|
99
|
+
name: 'get_conventions',
|
|
100
|
+
title: 'Get rudiment-ui conventions',
|
|
101
|
+
description:
|
|
102
|
+
'Library-wide rules for writing code with rudiment-ui: setup, the Rudi prefix, onPress/onChange semantics, required labels, Iconify icons, layout primitives, theming with data-theme, and token overrides. Call it once before writing UI code.',
|
|
103
|
+
inputSchema: { type: 'object', properties: {}, additionalProperties: false },
|
|
104
|
+
annotations: { readOnlyHint: true, openWorldHint: false },
|
|
105
|
+
run() {
|
|
106
|
+
const { api } = loadApi()
|
|
107
|
+
return `${api.conventions}\n\n---\n${api.components.length} components. Call list_components to browse them or get_component for props.`
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
name: 'list_components',
|
|
112
|
+
title: 'List rudiment-ui components',
|
|
113
|
+
description:
|
|
114
|
+
'Every rudiment-ui component and compound part with a one-line summary. Filter by category, or by a case-insensitive substring of the name or summary.',
|
|
115
|
+
inputSchema: {
|
|
116
|
+
type: 'object',
|
|
117
|
+
properties: {
|
|
118
|
+
category: { type: 'string', enum: CATEGORIES, description: 'Only components in this group.' },
|
|
119
|
+
query: { type: 'string', description: 'Case-insensitive substring of the name or summary, e.g. "date" or "chart".' },
|
|
120
|
+
},
|
|
121
|
+
additionalProperties: false,
|
|
122
|
+
},
|
|
123
|
+
annotations: { readOnlyHint: true, openWorldHint: false },
|
|
124
|
+
run({ category, query } = {}) {
|
|
125
|
+
const { api } = loadApi()
|
|
126
|
+
if (category && !CATEGORIES.includes(category)) throw new ToolError(`category must be one of: ${CATEGORIES.join(', ')}`)
|
|
127
|
+
const q = query?.toLowerCase()
|
|
128
|
+
const matches = (c) => !q || c.name.toLowerCase().includes(q) || (c.description ?? '').toLowerCase().includes(q)
|
|
129
|
+
const picked = api.components
|
|
130
|
+
.filter((c) => !category || c.category === category)
|
|
131
|
+
.map((c) => (matches(c) ? c : { ...c, parts: (c.parts ?? []).filter(matches), _viaPart: true }))
|
|
132
|
+
.filter((c) => !c._viaPart || c.parts.length)
|
|
133
|
+
if (!picked.length) return `No components match${category ? ` category "${category}"` : ''}${q ? ` and "${query}"` : ''}. Try search for prop-level matches.`
|
|
134
|
+
const header = `${picked.length} component${picked.length === 1 ? '' : 's'}${category ? ` (${category})` : ''}. Call get_component for props.`
|
|
135
|
+
return `${header}\n\n${componentIndex({ components: picked })}`
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
name: 'get_component',
|
|
140
|
+
title: 'Get a rudiment-ui component',
|
|
141
|
+
description:
|
|
142
|
+
'Full reference for one export: summary, examples, a props table (type, default, required, description), compound parts, the element ref forwards to, and props inherited from React Aria. Accepts component names with or without the Rudi prefix ("Button", "RudiCard.Header"), and functions or types (rudiToast, useChartTheme, RudiStepperStep).',
|
|
143
|
+
inputSchema: {
|
|
144
|
+
type: 'object',
|
|
145
|
+
properties: {
|
|
146
|
+
name: { type: 'string', description: 'Export name, e.g. "RudiSelect", "Select", "RudiAppShell.Sidebar", "rudiToast".' },
|
|
147
|
+
includeInherited: {
|
|
148
|
+
type: 'boolean',
|
|
149
|
+
description: 'List inherited React Aria props with their types and summaries rather than names only. Defaults to false.',
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
required: ['name'],
|
|
153
|
+
additionalProperties: false,
|
|
154
|
+
},
|
|
155
|
+
annotations: { readOnlyHint: true, openWorldHint: false },
|
|
156
|
+
run({ name, includeInherited = false } = {}) {
|
|
157
|
+
if (!name || typeof name !== 'string') throw new ToolError('`name` is required, e.g. "RudiButton".')
|
|
158
|
+
const entry = findEntry(name)
|
|
159
|
+
if (!entry) {
|
|
160
|
+
const near = suggestions(name)
|
|
161
|
+
throw new ToolError(`No export named "${name}".${near.length ? ` Did you mean: ${near.join(', ')}?` : ''} Call list_components to see all names.`)
|
|
162
|
+
}
|
|
163
|
+
if (entry.kind === 'function') return functionMarkdown(entry.item, 2)
|
|
164
|
+
if (entry.kind === 'type') return typeMarkdown(entry.item, 2)
|
|
165
|
+
const c = entry.item
|
|
166
|
+
const lines = [componentMarkdown(c, { depth: 2, inheritedDetail: includeInherited })]
|
|
167
|
+
const meta = [`Import: \`import { ${(entry.parent ?? c.name).split('.')[0]} } from 'rudiment-ui'\``]
|
|
168
|
+
if (entry.parent) meta.push(`Part of \`${entry.parent}\`; use it as \`<${c.name}>\`.`)
|
|
169
|
+
if (c.source) meta.push(`Source: \`${c.source}\``)
|
|
170
|
+
return `${lines.join('\n')}\n${meta.join(' \n')}\n`
|
|
171
|
+
},
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
name: 'search',
|
|
175
|
+
title: 'Search the rudiment-ui API',
|
|
176
|
+
description:
|
|
177
|
+
'Find components, props, functions and types by keyword across names and descriptions. Use it when you know the behaviour you need but not which component or prop provides it, e.g. "dismiss", "sticky header", "aria-label required".',
|
|
178
|
+
inputSchema: {
|
|
179
|
+
type: 'object',
|
|
180
|
+
properties: {
|
|
181
|
+
query: { type: 'string', description: 'One or more keywords. All of them must match.' },
|
|
182
|
+
limit: { type: 'integer', minimum: 1, maximum: 100, description: 'Maximum results. Defaults to 20.' },
|
|
183
|
+
},
|
|
184
|
+
required: ['query'],
|
|
185
|
+
additionalProperties: false,
|
|
186
|
+
},
|
|
187
|
+
annotations: { readOnlyHint: true, openWorldHint: false },
|
|
188
|
+
run({ query, limit = 20 } = {}) {
|
|
189
|
+
if (!query || typeof query !== 'string') throw new ToolError('`query` is required.')
|
|
190
|
+
const terms = query.toLowerCase().split(/\s+/).filter(Boolean)
|
|
191
|
+
const { entries } = loadApi()
|
|
192
|
+
const hits = []
|
|
193
|
+
const score = (name, text) => {
|
|
194
|
+
const hay = `${name} ${text}`.toLowerCase()
|
|
195
|
+
if (!terms.every((t) => hay.includes(t))) return 0
|
|
196
|
+
return terms.reduce((s, t) => s + (name.toLowerCase().includes(t) ? 3 : 1), 0)
|
|
197
|
+
}
|
|
198
|
+
for (const e of entries) {
|
|
199
|
+
const it = e.item
|
|
200
|
+
const s = score(it.name, it.description ?? '')
|
|
201
|
+
if (s) hits.push({ s: s + 2, line: `- \`${it.name}\` (${e.kind}) — ${firstSentence(it.description ?? '')}` })
|
|
202
|
+
for (const p of e.kind === 'component' ? it.props.filter((p) => p.origin === 'own') : (it.fields ?? [])) {
|
|
203
|
+
const ps = score(p.name, `${p.type} ${p.description ?? ''}`)
|
|
204
|
+
if (ps) hits.push({ s: ps, line: `- \`${it.name}\` prop \`${p.name}: ${p.type}\` — ${firstSentence(p.description ?? '')}` })
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
if (!hits.length) return `No matches for "${query}". Try fewer or broader keywords, or list_components.`
|
|
208
|
+
hits.sort((a, b) => b.s - a.s)
|
|
209
|
+
const shown = hits.slice(0, limit)
|
|
210
|
+
return `${hits.length} match${hits.length === 1 ? '' : 'es'}${hits.length > shown.length ? `, showing ${shown.length}` : ''}. Call get_component for full details.\n\n${shown.map((h) => h.line).join('\n')}`
|
|
211
|
+
},
|
|
212
|
+
},
|
|
213
|
+
]
|
|
214
|
+
|
|
215
|
+
// ------------------------------------------------------------- resources
|
|
216
|
+
|
|
217
|
+
const RESOURCES = [
|
|
218
|
+
{
|
|
219
|
+
uri: 'rudiment-ui://conventions',
|
|
220
|
+
name: 'conventions',
|
|
221
|
+
title: 'rudiment-ui conventions',
|
|
222
|
+
description: 'Library-wide rules: setup, props semantics, theming, tokens.',
|
|
223
|
+
mimeType: 'text/markdown',
|
|
224
|
+
read: () => loadApi().api.conventions,
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
uri: 'rudiment-ui://components.json',
|
|
228
|
+
name: 'components.json',
|
|
229
|
+
title: 'rudiment-ui API manifest',
|
|
230
|
+
description: 'Every export, prop, default and inherited prop as JSON.',
|
|
231
|
+
mimeType: 'application/json',
|
|
232
|
+
read: () => fs.readFileSync(MANIFEST, 'utf8'),
|
|
233
|
+
},
|
|
234
|
+
]
|
|
235
|
+
|
|
236
|
+
// --------------------------------------------------------------- JSON-RPC
|
|
237
|
+
|
|
238
|
+
const PKG_VERSION = (() => {
|
|
239
|
+
try {
|
|
240
|
+
return JSON.parse(fs.readFileSync(path.join(HERE, '../package.json'), 'utf8')).version
|
|
241
|
+
} catch {
|
|
242
|
+
return '0.0.0'
|
|
243
|
+
}
|
|
244
|
+
})()
|
|
245
|
+
|
|
246
|
+
class RpcError extends Error {
|
|
247
|
+
constructor(code, message) {
|
|
248
|
+
super(message)
|
|
249
|
+
this.code = code
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
const handlers = {
|
|
254
|
+
initialize(params = {}) {
|
|
255
|
+
const requested = params.protocolVersion
|
|
256
|
+
return {
|
|
257
|
+
protocolVersion: SUPPORTED_PROTOCOLS.includes(requested) ? requested : SUPPORTED_PROTOCOLS[0],
|
|
258
|
+
capabilities: { tools: { listChanged: false }, resources: { listChanged: false } },
|
|
259
|
+
serverInfo: { name: 'rudiment-ui', title: 'rudiment-ui component reference', version: PKG_VERSION },
|
|
260
|
+
instructions: INSTRUCTIONS,
|
|
261
|
+
}
|
|
262
|
+
},
|
|
263
|
+
ping: () => ({}),
|
|
264
|
+
'tools/list': () => ({ tools: TOOLS.map(({ run, ...t }) => t) }),
|
|
265
|
+
'tools/call'(params = {}) {
|
|
266
|
+
const tool = TOOLS.find((t) => t.name === params.name)
|
|
267
|
+
if (!tool) throw new RpcError(-32602, `Unknown tool: ${params.name}`)
|
|
268
|
+
try {
|
|
269
|
+
return { content: [{ type: 'text', text: tool.run(params.arguments ?? {}) }] }
|
|
270
|
+
} catch (err) {
|
|
271
|
+
if (err instanceof ToolError) return { content: [{ type: 'text', text: err.message }], isError: true }
|
|
272
|
+
throw err
|
|
273
|
+
}
|
|
274
|
+
},
|
|
275
|
+
'resources/list': () => ({ resources: RESOURCES.map(({ read, ...r }) => r) }),
|
|
276
|
+
'resources/templates/list': () => ({ resourceTemplates: [] }),
|
|
277
|
+
'resources/read'(params = {}) {
|
|
278
|
+
const res = RESOURCES.find((r) => r.uri === params.uri)
|
|
279
|
+
if (!res) throw new RpcError(-32002, `Resource not found: ${params.uri}`)
|
|
280
|
+
try {
|
|
281
|
+
return { contents: [{ uri: res.uri, mimeType: res.mimeType, text: res.read() }] }
|
|
282
|
+
} catch (err) {
|
|
283
|
+
throw new RpcError(-32603, err.message)
|
|
284
|
+
}
|
|
285
|
+
},
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
function send(message) {
|
|
289
|
+
process.stdout.write(JSON.stringify(message) + '\n')
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
function handle(message) {
|
|
293
|
+
if (!message || message.jsonrpc !== '2.0' || typeof message.method !== 'string') {
|
|
294
|
+
if (message && 'id' in message && !('method' in message)) return // a response to us; we send no requests
|
|
295
|
+
return send({ jsonrpc: '2.0', id: message?.id ?? null, error: { code: -32600, message: 'Invalid Request' } })
|
|
296
|
+
}
|
|
297
|
+
const isNotification = !('id' in message)
|
|
298
|
+
const handler = handlers[message.method]
|
|
299
|
+
if (isNotification) return // notifications/initialized, notifications/cancelled, …: nothing to do
|
|
300
|
+
if (!handler) return send({ jsonrpc: '2.0', id: message.id, error: { code: -32601, message: `Method not found: ${message.method}` } })
|
|
301
|
+
try {
|
|
302
|
+
send({ jsonrpc: '2.0', id: message.id, result: handler(message.params) })
|
|
303
|
+
} catch (err) {
|
|
304
|
+
const code = err instanceof RpcError ? err.code : -32603
|
|
305
|
+
send({ jsonrpc: '2.0', id: message.id, error: { code, message: err.message } })
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
const rl = readline.createInterface({ input: process.stdin })
|
|
310
|
+
rl.on('line', (line) => {
|
|
311
|
+
if (!line.trim()) return
|
|
312
|
+
let message
|
|
313
|
+
try {
|
|
314
|
+
message = JSON.parse(line)
|
|
315
|
+
} catch {
|
|
316
|
+
return send({ jsonrpc: '2.0', id: null, error: { code: -32700, message: 'Parse error' } })
|
|
317
|
+
}
|
|
318
|
+
handle(message)
|
|
319
|
+
})
|
|
320
|
+
rl.on('close', () => process.exit(0))
|
|
321
|
+
process.stderr.write(`rudiment-ui MCP server ${PKG_VERSION} ready (manifest: ${MANIFEST})\n`)
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rudiment-ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Accessible React component library built on React Aria, with layout primitives, charts, and a three-tier design token architecture supporting eight built-in themes.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"dev": "storybook dev -p 6006",
|
|
8
|
-
"build": "vite build",
|
|
8
|
+
"build": "vite build && node scripts/component-docs.mjs",
|
|
9
|
+
"build:docs": "node scripts/component-docs.mjs",
|
|
9
10
|
"prepare": "npm run build:tokens && npm run build",
|
|
10
11
|
"prepublishOnly": "npm run build:tokens && npm run build",
|
|
11
12
|
"build-storybook": "storybook build",
|
|
@@ -16,6 +17,9 @@
|
|
|
16
17
|
},
|
|
17
18
|
"module": "dist/index.js",
|
|
18
19
|
"types": "dist/index.d.ts",
|
|
20
|
+
"bin": {
|
|
21
|
+
"rudiment-ui-mcp": "mcp/server.mjs"
|
|
22
|
+
},
|
|
19
23
|
"exports": {
|
|
20
24
|
".": {
|
|
21
25
|
"types": "./dist/index.d.ts",
|
|
@@ -25,10 +29,16 @@
|
|
|
25
29
|
"types": "./styles.d.ts",
|
|
26
30
|
"default": "./dist/index.css"
|
|
27
31
|
},
|
|
32
|
+
"./llms.txt": "./dist/llms.txt",
|
|
33
|
+
"./llms-full.txt": "./dist/llms-full.txt",
|
|
34
|
+
"./components.json": "./dist/components.json",
|
|
28
35
|
"./package.json": "./package.json"
|
|
29
36
|
},
|
|
30
37
|
"files": [
|
|
31
38
|
"dist",
|
|
39
|
+
"mcp/server.mjs",
|
|
40
|
+
"mcp/render.mjs",
|
|
41
|
+
"mcp/README.md",
|
|
32
42
|
"styles.d.ts"
|
|
33
43
|
],
|
|
34
44
|
"peerDependencies": {
|