@carto/meridian-ds 3.0.2 → 3.0.3-alpha.14acf93.281
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/CHANGELOG.md +2 -0
- package/README.md +34 -0
- package/dist/{ListItem-BOr1gyyO.cjs → ListItem-CLIaUyDV.cjs} +1 -1
- package/dist/{ListItem-CW7C1948.js → ListItem-CRSS7jTs.js} +1 -1
- package/dist/bin/meridian-ds-mcp.js +373 -0
- package/dist/components/index.cjs +208 -13
- package/dist/components/index.js +210 -15
- package/dist/conventions.md +58 -0
- package/dist/metadata.json +3292 -0
- package/dist/{palette-utils-gZwK5wCD.js → palette-utils-B2CZD7oM.js} +1 -0
- package/dist/{palette-utils-CfP0zi6X.cjs → palette-utils-Ou97WiuF.cjs} +1 -0
- package/dist/theme/index.cjs +2 -2
- package/dist/theme/index.js +3 -3
- package/dist/types/components/Alert/Alert.d.ts +20 -0
- package/dist/types/components/Alert/Alert.d.ts.map +1 -1
- package/dist/types/components/Alert/Alert.metadata.d.ts +21 -0
- package/dist/types/components/Alert/Alert.metadata.d.ts.map +1 -0
- package/dist/types/components/Alert/Alert.stories.d.ts +14 -0
- package/dist/types/components/Alert/Alert.stories.d.ts.map +1 -1
- package/dist/types/components/Autocomplete/Autocomplete/Autocomplete.d.ts +1 -0
- package/dist/types/components/Autocomplete/Autocomplete/Autocomplete.d.ts.map +1 -1
- package/dist/types/components/Autocomplete/Autocomplete/Autocomplete.metadata.d.ts +21 -0
- package/dist/types/components/Autocomplete/Autocomplete/Autocomplete.metadata.d.ts.map +1 -0
- package/dist/types/components/Autocomplete/Autocomplete/Autocomplete.stories.d.ts +15 -0
- package/dist/types/components/Autocomplete/Autocomplete/Autocomplete.stories.d.ts.map +1 -1
- package/dist/types/components/Autocomplete/Autocomplete/useAutocomplete.d.ts +1 -0
- package/dist/types/components/Autocomplete/Autocomplete/useAutocomplete.d.ts.map +1 -1
- package/dist/types/components/Autocomplete/AutocompleteList/AutocompleteList.d.ts +1 -0
- package/dist/types/components/Autocomplete/AutocompleteList/AutocompleteList.d.ts.map +1 -1
- package/dist/types/components/Autocomplete/CreatableAutocomplete/CreatableAutocomplete.d.ts +1 -0
- package/dist/types/components/Autocomplete/CreatableAutocomplete/CreatableAutocomplete.d.ts.map +1 -1
- package/dist/types/components/Autocomplete/CreatableAutocomplete/CreatableAutocomplete.metadata.d.ts +22 -0
- package/dist/types/components/Autocomplete/CreatableAutocomplete/CreatableAutocomplete.metadata.d.ts.map +1 -0
- package/dist/types/components/Autocomplete/CreatableAutocomplete/CreatableAutocomplete.stories.d.ts +10 -0
- package/dist/types/components/Autocomplete/CreatableAutocomplete/CreatableAutocomplete.stories.d.ts.map +1 -1
- package/dist/types/components/Autocomplete/MultipleAutocomplete/MultipleAutocomplete.d.ts +1 -0
- package/dist/types/components/Autocomplete/MultipleAutocomplete/MultipleAutocomplete.d.ts.map +1 -1
- package/dist/types/components/Autocomplete/MultipleAutocomplete/MultipleAutocomplete.metadata.d.ts +22 -0
- package/dist/types/components/Autocomplete/MultipleAutocomplete/MultipleAutocomplete.metadata.d.ts.map +1 -0
- package/dist/types/components/Autocomplete/MultipleAutocomplete/MultipleAutocomplete.stories.d.ts +13 -0
- package/dist/types/components/Autocomplete/MultipleAutocomplete/MultipleAutocomplete.stories.d.ts.map +1 -1
- package/dist/types/components/Autocomplete/types.d.ts +5 -4
- package/dist/types/components/Autocomplete/types.d.ts.map +1 -1
- package/dist/types/components/Autocomplete/utils/useAutocompleteRenderOption.d.ts +1 -0
- package/dist/types/components/Autocomplete/utils/useAutocompleteRenderOption.d.ts.map +1 -1
- package/dist/types/components/Avatar/Avatar.d.ts +3 -0
- package/dist/types/components/Avatar/Avatar.d.ts.map +1 -1
- package/dist/types/components/Avatar/Avatar.metadata.d.ts +20 -0
- package/dist/types/components/Avatar/Avatar.metadata.d.ts.map +1 -0
- package/dist/types/components/Avatar/Avatar.stories.d.ts +12 -0
- package/dist/types/components/Avatar/Avatar.stories.d.ts.map +1 -1
- package/dist/types/components/Button/Button.d.ts +8 -0
- package/dist/types/components/Button/Button.d.ts.map +1 -1
- package/dist/types/components/Button/Button.metadata.d.ts +26 -0
- package/dist/types/components/Button/Button.metadata.d.ts.map +1 -0
- package/dist/types/components/Button/Button.stories.d.ts +11 -0
- package/dist/types/components/Button/Button.stories.d.ts.map +1 -1
- package/dist/types/components/ChipGroup/ChipGroup.d.ts +1 -0
- package/dist/types/components/ChipGroup/ChipGroup.d.ts.map +1 -1
- package/dist/types/components/ChipGroup/ChipGroup.metadata.d.ts +22 -0
- package/dist/types/components/ChipGroup/ChipGroup.metadata.d.ts.map +1 -0
- package/dist/types/components/ChipGroup/ChipGroup.stories.d.ts +10 -0
- package/dist/types/components/ChipGroup/ChipGroup.stories.d.ts.map +1 -1
- package/dist/types/components/ChipGroup/types.d.ts +3 -1
- package/dist/types/components/ChipGroup/types.d.ts.map +1 -1
- package/dist/types/components/CodeArea/CodeAreaDialog/CodeAreaDialog.d.ts +1 -0
- package/dist/types/components/CodeArea/CodeAreaDialog/CodeAreaDialog.d.ts.map +1 -1
- package/dist/types/components/CodeArea/CodeAreaDialog/components/CodeAreaDialogConfirmation.d.ts +1 -0
- package/dist/types/components/CodeArea/CodeAreaDialog/components/CodeAreaDialogConfirmation.d.ts.map +1 -1
- package/dist/types/components/CodeArea/CodeAreaDialog/components/CodeAreaDialogContent.d.ts +1 -0
- package/dist/types/components/CodeArea/CodeAreaDialog/components/CodeAreaDialogContent.d.ts.map +1 -1
- package/dist/types/components/CodeArea/CodeAreaDialog/components/CodeAreaDialogError.d.ts +1 -0
- package/dist/types/components/CodeArea/CodeAreaDialog/components/CodeAreaDialogError.d.ts.map +1 -1
- package/dist/types/components/CodeArea/CodeAreaField/CodeAreaField.d.ts +1 -0
- package/dist/types/components/CodeArea/CodeAreaField/CodeAreaField.d.ts.map +1 -1
- package/dist/types/components/CodeArea/CodeAreaFooter/CodeAreaFooter.d.ts +1 -0
- package/dist/types/components/CodeArea/CodeAreaFooter/CodeAreaFooter.d.ts.map +1 -1
- package/dist/types/components/CodeArea/CodeAreaHeader/CodeAreaHeader.d.ts +1 -0
- package/dist/types/components/CodeArea/CodeAreaHeader/CodeAreaHeader.d.ts.map +1 -1
- package/dist/types/components/CodeArea/CodeAreaInput/CodeAreaInput.d.ts +1 -0
- package/dist/types/components/CodeArea/CodeAreaInput/CodeAreaInput.d.ts.map +1 -1
- package/dist/types/components/Dialog/Dialog/Dialog.d.ts +1 -0
- package/dist/types/components/Dialog/Dialog/Dialog.d.ts.map +1 -1
- package/dist/types/components/Dialog/Dialog/Dialog.metadata.d.ts +27 -0
- package/dist/types/components/Dialog/Dialog/Dialog.metadata.d.ts.map +1 -0
- package/dist/types/components/Dialog/Dialog/Dialog.stories.d.ts +15 -0
- package/dist/types/components/Dialog/Dialog/Dialog.stories.d.ts.map +1 -1
- package/dist/types/components/Dialog/DialogAlert/DialogAlert.d.ts +1 -0
- package/dist/types/components/Dialog/DialogAlert/DialogAlert.d.ts.map +1 -1
- package/dist/types/components/Dialog/DialogConfirmation/DialogConfirmation.d.ts +1 -0
- package/dist/types/components/Dialog/DialogConfirmation/DialogConfirmation.d.ts.map +1 -1
- package/dist/types/components/Dialog/DialogConfirmation/DialogConfirmation.metadata.d.ts +11 -0
- package/dist/types/components/Dialog/DialogConfirmation/DialogConfirmation.metadata.d.ts.map +1 -0
- package/dist/types/components/Dialog/DialogConfirmation/DialogConfirmation.stories.d.ts +9 -0
- package/dist/types/components/Dialog/DialogConfirmation/DialogConfirmation.stories.d.ts.map +1 -1
- package/dist/types/components/Dialog/DialogContent/DialogContent.d.ts +2 -0
- package/dist/types/components/Dialog/DialogContent/DialogContent.d.ts.map +1 -1
- package/dist/types/components/Dialog/DialogFooter/DialogFooter.d.ts +2 -0
- package/dist/types/components/Dialog/DialogFooter/DialogFooter.d.ts.map +1 -1
- package/dist/types/components/Dialog/DialogHeader/DialogHeader.d.ts +1 -0
- package/dist/types/components/Dialog/DialogHeader/DialogHeader.d.ts.map +1 -1
- package/dist/types/components/Dialog/DialogPaper/DialogPaper.d.ts +2 -0
- package/dist/types/components/Dialog/DialogPaper/DialogPaper.d.ts.map +1 -1
- package/dist/types/components/Dialog/DialogStepper/DialogStepper.d.ts +1 -0
- package/dist/types/components/Dialog/DialogStepper/DialogStepper.d.ts.map +1 -1
- package/dist/types/components/Dialog/types.d.ts +30 -19
- package/dist/types/components/Dialog/types.d.ts.map +1 -1
- package/dist/types/components/EllipsisWithTooltip/EllipsisWithTooltip.d.ts +2 -6
- package/dist/types/components/EllipsisWithTooltip/EllipsisWithTooltip.d.ts.map +1 -1
- package/dist/types/components/EllipsisWithTooltip/EllipsisWithTooltip.metadata.d.ts +12 -0
- package/dist/types/components/EllipsisWithTooltip/EllipsisWithTooltip.metadata.d.ts.map +1 -0
- package/dist/types/components/EllipsisWithTooltip/EllipsisWithTooltip.stories.d.ts +9 -0
- package/dist/types/components/EllipsisWithTooltip/EllipsisWithTooltip.stories.d.ts.map +1 -1
- package/dist/types/components/FilterDropdown/FilterDropdown.d.ts +1 -0
- package/dist/types/components/FilterDropdown/FilterDropdown.d.ts.map +1 -1
- package/dist/types/components/FilterDropdown/FilterDropdown.metadata.d.ts +11 -0
- package/dist/types/components/FilterDropdown/FilterDropdown.metadata.d.ts.map +1 -0
- package/dist/types/components/FilterDropdown/FilterDropdown.stories.d.ts +14 -0
- package/dist/types/components/FilterDropdown/FilterDropdown.stories.d.ts.map +1 -1
- package/dist/types/components/FilterDropdown/FilterDropdownMenuItem/FilterDropdownMenuItem.d.ts +1 -0
- package/dist/types/components/FilterDropdown/FilterDropdownMenuItem/FilterDropdownMenuItem.d.ts.map +1 -1
- package/dist/types/components/FilterDropdown/types.d.ts +37 -0
- package/dist/types/components/FilterDropdown/types.d.ts.map +1 -1
- package/dist/types/components/IconButton/IconButton.d.ts +39 -4
- package/dist/types/components/IconButton/IconButton.d.ts.map +1 -1
- package/dist/types/components/IconButton/IconButton.metadata.d.ts +15 -0
- package/dist/types/components/IconButton/IconButton.metadata.d.ts.map +1 -0
- package/dist/types/components/IconButton/IconButton.stories.d.ts +22 -0
- package/dist/types/components/IconButton/IconButton.stories.d.ts.map +1 -1
- package/dist/types/components/IconWrapper/IconWrapper.d.ts +149 -0
- package/dist/types/components/IconWrapper/IconWrapper.d.ts.map +1 -0
- package/dist/types/components/IconWrapper/IconWrapper.figma.d.ts +11 -0
- package/dist/types/components/IconWrapper/IconWrapper.figma.d.ts.map +1 -0
- package/dist/types/components/IconWrapper/IconWrapper.metadata.d.ts +11 -0
- package/dist/types/components/IconWrapper/IconWrapper.metadata.d.ts.map +1 -0
- package/dist/types/components/IconWrapper/IconWrapper.stories.d.ts +248 -0
- package/dist/types/components/IconWrapper/IconWrapper.stories.d.ts.map +1 -0
- package/dist/types/components/IconWrapper/IconWrapper.test.d.ts +2 -0
- package/dist/types/components/IconWrapper/IconWrapper.test.d.ts.map +1 -0
- package/dist/types/components/IconWrapper/index.d.ts +3 -0
- package/dist/types/components/IconWrapper/index.d.ts.map +1 -0
- package/dist/types/components/LabelWithIndicator/LabelWithIndicator.d.ts +9 -0
- package/dist/types/components/LabelWithIndicator/LabelWithIndicator.d.ts.map +1 -1
- package/dist/types/components/LabelWithIndicator/LabelWithIndicator.metadata.d.ts +10 -0
- package/dist/types/components/LabelWithIndicator/LabelWithIndicator.metadata.d.ts.map +1 -0
- package/dist/types/components/LabelWithIndicator/LabelWithIndicator.stories.d.ts +9 -0
- package/dist/types/components/LabelWithIndicator/LabelWithIndicator.stories.d.ts.map +1 -1
- package/dist/types/components/Link/Link.d.ts +4 -0
- package/dist/types/components/Link/Link.d.ts.map +1 -1
- package/dist/types/components/Link/Link.metadata.d.ts +19 -0
- package/dist/types/components/Link/Link.metadata.d.ts.map +1 -0
- package/dist/types/components/Link/Link.stories.d.ts +11 -0
- package/dist/types/components/Link/Link.stories.d.ts.map +1 -1
- package/dist/types/components/List/List.d.ts +2 -0
- package/dist/types/components/List/List.d.ts.map +1 -1
- package/dist/types/components/List/List.metadata.d.ts +15 -0
- package/dist/types/components/List/List.metadata.d.ts.map +1 -0
- package/dist/types/components/List/List.stories.d.ts +15 -0
- package/dist/types/components/List/List.stories.d.ts.map +1 -1
- package/dist/types/components/List/ListItem/ListItem.d.ts +1 -0
- package/dist/types/components/List/ListItem/ListItem.d.ts.map +1 -1
- package/dist/types/components/List/ListItem/ListItem.metadata.d.ts +20 -0
- package/dist/types/components/List/ListItem/ListItem.metadata.d.ts.map +1 -0
- package/dist/types/components/List/ListItem/ListItem.stories.d.ts +17 -0
- package/dist/types/components/List/ListItem/ListItem.stories.d.ts.map +1 -1
- package/dist/types/components/List/ListItemButton/ListItemButton.d.ts +1 -0
- package/dist/types/components/List/ListItemButton/ListItemButton.d.ts.map +1 -1
- package/dist/types/components/List/ListItemIcon/ListItemIcon.d.ts +1 -0
- package/dist/types/components/List/ListItemIcon/ListItemIcon.d.ts.map +1 -1
- package/dist/types/components/List/ListItemRightContent/ListItemRightContent.d.ts +1 -3
- package/dist/types/components/List/ListItemRightContent/ListItemRightContent.d.ts.map +1 -1
- package/dist/types/components/List/ListItemText/ListItemText.d.ts +6 -2
- package/dist/types/components/List/ListItemText/ListItemText.d.ts.map +1 -1
- package/dist/types/components/List/ListSubheader/ListSubheader.d.ts +1 -0
- package/dist/types/components/List/ListSubheader/ListSubheader.d.ts.map +1 -1
- package/dist/types/components/Menu/Menu/Menu.d.ts +1 -0
- package/dist/types/components/Menu/Menu/Menu.d.ts.map +1 -1
- package/dist/types/components/Menu/Menu/Menu.metadata.d.ts +16 -0
- package/dist/types/components/Menu/Menu/Menu.metadata.d.ts.map +1 -0
- package/dist/types/components/Menu/Menu/Menu.stories.d.ts +16 -0
- package/dist/types/components/Menu/Menu/Menu.stories.d.ts.map +1 -1
- package/dist/types/components/Menu/MenuItem/MenuItem.d.ts +1 -0
- package/dist/types/components/Menu/MenuItem/MenuItem.d.ts.map +1 -1
- package/dist/types/components/Menu/MenuItemFilter/MenuItemFilter.d.ts +1 -0
- package/dist/types/components/Menu/MenuItemFilter/MenuItemFilter.d.ts.map +1 -1
- package/dist/types/components/Menu/MenuList/MenuList.d.ts +1 -0
- package/dist/types/components/Menu/MenuList/MenuList.d.ts.map +1 -1
- package/dist/types/components/Menu/types.d.ts +19 -0
- package/dist/types/components/Menu/types.d.ts.map +1 -1
- package/dist/types/components/ScreenReaderOnly/ScreenReaderOnly.d.ts +1 -0
- package/dist/types/components/ScreenReaderOnly/ScreenReaderOnly.d.ts.map +1 -1
- package/dist/types/components/ScreenReaderOnly/ScreenReaderOnly.metadata.d.ts +10 -0
- package/dist/types/components/ScreenReaderOnly/ScreenReaderOnly.metadata.d.ts.map +1 -0
- package/dist/types/components/ScreenReaderOnly/ScreenReaderOnly.stories.d.ts +38 -0
- package/dist/types/components/ScreenReaderOnly/ScreenReaderOnly.stories.d.ts.map +1 -0
- package/dist/types/components/SelectField/MultipleSelectField/MultipleSelectField.d.ts +1 -0
- package/dist/types/components/SelectField/MultipleSelectField/MultipleSelectField.d.ts.map +1 -1
- package/dist/types/components/SelectField/MultipleSelectField/MultipleSelectField.metadata.d.ts +27 -0
- package/dist/types/components/SelectField/MultipleSelectField/MultipleSelectField.metadata.d.ts.map +1 -0
- package/dist/types/components/SelectField/MultipleSelectField/MultipleSelectField.stories.d.ts +9 -0
- package/dist/types/components/SelectField/MultipleSelectField/MultipleSelectField.stories.d.ts.map +1 -1
- package/dist/types/components/SelectField/SelectField/SelectField.d.ts +1 -0
- package/dist/types/components/SelectField/SelectField/SelectField.d.ts.map +1 -1
- package/dist/types/components/SelectField/SelectField/SelectField.metadata.d.ts +27 -0
- package/dist/types/components/SelectField/SelectField/SelectField.metadata.d.ts.map +1 -0
- package/dist/types/components/SelectField/SelectField/SelectField.stories.d.ts +11 -0
- package/dist/types/components/SelectField/SelectField/SelectField.stories.d.ts.map +1 -1
- package/dist/types/components/SelectField/types.d.ts +18 -0
- package/dist/types/components/SelectField/types.d.ts.map +1 -1
- package/dist/types/components/Snackbar/Snackbar.d.ts +13 -0
- package/dist/types/components/Snackbar/Snackbar.d.ts.map +1 -1
- package/dist/types/components/Snackbar/Snackbar.metadata.d.ts +20 -0
- package/dist/types/components/Snackbar/Snackbar.metadata.d.ts.map +1 -0
- package/dist/types/components/Snackbar/Snackbar.stories.d.ts +12 -0
- package/dist/types/components/Snackbar/Snackbar.stories.d.ts.map +1 -1
- package/dist/types/components/SplitButton/SplitButton.d.ts +27 -0
- package/dist/types/components/SplitButton/SplitButton.d.ts.map +1 -1
- package/dist/types/components/SplitButton/SplitButton.metadata.d.ts +15 -0
- package/dist/types/components/SplitButton/SplitButton.metadata.d.ts.map +1 -0
- package/dist/types/components/SplitButton/SplitButton.stories.d.ts +9 -0
- package/dist/types/components/SplitButton/SplitButton.stories.d.ts.map +1 -1
- package/dist/types/components/Tag/Tag.d.ts +2 -1
- package/dist/types/components/Tag/Tag.d.ts.map +1 -1
- package/dist/types/components/Tag/Tag.metadata.d.ts +23 -0
- package/dist/types/components/Tag/Tag.metadata.d.ts.map +1 -0
- package/dist/types/components/Tag/Tag.stories.d.ts +11 -0
- package/dist/types/components/Tag/Tag.stories.d.ts.map +1 -1
- package/dist/types/components/ToggleButtonGroup/ToggleButtonGroup.d.ts +1 -0
- package/dist/types/components/ToggleButtonGroup/ToggleButtonGroup.d.ts.map +1 -1
- package/dist/types/components/ToggleButtonGroup/ToggleButtonGroup.metadata.d.ts +19 -0
- package/dist/types/components/ToggleButtonGroup/ToggleButtonGroup.metadata.d.ts.map +1 -0
- package/dist/types/components/ToggleButtonGroup/ToggleButtonGroup.stories.d.ts +9 -0
- package/dist/types/components/ToggleButtonGroup/ToggleButtonGroup.stories.d.ts.map +1 -1
- package/dist/types/components/Typography/Typography.d.ts +5 -0
- package/dist/types/components/Typography/Typography.d.ts.map +1 -1
- package/dist/types/components/Typography/Typography.metadata.d.ts +26 -0
- package/dist/types/components/Typography/Typography.metadata.d.ts.map +1 -0
- package/dist/types/components/Typography/Typography.stories.d.ts +9 -0
- package/dist/types/components/Typography/Typography.stories.d.ts.map +1 -1
- package/dist/types/components/UploadField/UploadFieldBase.d.ts +1 -0
- package/dist/types/components/UploadField/UploadFieldBase.d.ts.map +1 -1
- package/dist/types/components/index.d.ts +2 -0
- package/dist/types/components/index.d.ts.map +1 -1
- package/dist/types/theme/types.d.ts +39 -0
- package/dist/types/theme/types.d.ts.map +1 -1
- package/dist/{utils-CD2XnHzC.js → utils-BnqQIMbU.js} +1 -1
- package/dist/{utils-BfSr53C0.cjs → utils-DtB4pKaP.cjs} +1 -1
- package/dist/widgets/index.cjs +2 -2
- package/dist/widgets/index.js +2 -2
- package/package.json +17 -3
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
- feat(ai-metadata): expose component knowledge to AI agents via the new `meridian-ds-mcp` MCP server — a build-time `dist/metadata.json` bundle (curation, conventions, example code) authored per component via `<Name>.metadata.ts` + JSDoc, validated in CI [#443](https://github.com/CartoDB/meridian-ds/pull/443)
|
|
6
|
+
|
|
5
7
|
## 3.0
|
|
6
8
|
|
|
7
9
|
### 3.0.2
|
package/README.md
CHANGED
|
@@ -42,3 +42,37 @@ Meridian ships CARTO's custom icon set as React components under `@carto/meridia
|
|
|
42
42
|
## Figma integration
|
|
43
43
|
|
|
44
44
|
Meridian publishes `Figma Code Connect` templates for all components, so **AI coding agents using the Figma MCP server can read designs and generate Meridian-conformant code**: the right component, the right import path, only real prop values, and the encoded semantics of Meridian primitives. The same templates surface the matching snippet to developers inspecting an instance in Figma's Dev Mode. See setup, MCP install, and template-authoring details in the [Figma Code Connect documentation](https://meridian.carto.com/?path=/docs/figma-code-connect--docs).
|
|
45
|
+
|
|
46
|
+
## AI readiness
|
|
47
|
+
|
|
48
|
+
Meridian ships structured metadata so **AI coding agents in apps that depend on it generate correct Meridian code** — the right component, real prop values, and Meridian conventions instead of bare MUI. Knowledge splits two ways: exact props and types come from the package's TypeScript declarations (`.d.ts`, which the consumer's IDE/`tsc` already reads), and everything types can't express — which component to use and when, gotchas, the high-value MUI props, and real examples — comes from a metadata bundle served over MCP.
|
|
49
|
+
|
|
50
|
+
### Meridian MCP
|
|
51
|
+
|
|
52
|
+
The package ships an MCP server as the `meridian-ds-mcp` bin. In a repo that has `@carto/meridian-ds` installed, register it with the Claude Code CLI:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
claude mcp add --scope project meridian-design-system -- npx meridian-ds-mcp
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
`--scope project` writes `.mcp.json` at the repo root — Claude Code loads it whether the team commits it (to share the server) or gitignores it:
|
|
59
|
+
|
|
60
|
+
```json
|
|
61
|
+
{
|
|
62
|
+
"mcpServers": {
|
|
63
|
+
"meridian-design-system": {
|
|
64
|
+
"command": "npx",
|
|
65
|
+
"args": ["meridian-ds-mcp"]
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
It's a stdio server (a local command, not a hosted URL), so it needs no network — the bin reads the metadata bundle that ships inside the installed `@carto/meridian-ds`, so the agent's knowledge always matches the installed version.
|
|
72
|
+
|
|
73
|
+
It exposes four tools:
|
|
74
|
+
|
|
75
|
+
- `meridian_list_components` — discover components by description + keywords.
|
|
76
|
+
- `meridian_get_component` — when to use it, alternatives, and the high-value inherited MUI props.
|
|
77
|
+
- `meridian_get_examples` — real, copy-able example code.
|
|
78
|
+
- `meridian_get_conventions` — cross-cutting usage rules.
|
|
@@ -4,7 +4,7 @@ const React = require("react");
|
|
|
4
4
|
const material = require("@mui/material");
|
|
5
5
|
const iconsMaterial = require("@mui/icons-material");
|
|
6
6
|
require("cartocolor");
|
|
7
|
-
const paletteUtils = require("./palette-utils-
|
|
7
|
+
const paletteUtils = require("./palette-utils-Ou97WiuF.cjs");
|
|
8
8
|
const ReactWindow = require("react-window");
|
|
9
9
|
function _interopNamespaceDefault(e) {
|
|
10
10
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
@@ -3,7 +3,7 @@ import React, { forwardRef, useState, createContext, useMemo, useContext } from
|
|
|
3
3
|
import { styled, Link as Link$1, Alert as Alert$1, Fade, AlertTitle, List as List$1, ListItemButton as ListItemButton$1, ListItem as ListItem$1 } from "@mui/material";
|
|
4
4
|
import { OpenInNewOutlined } from "@mui/icons-material";
|
|
5
5
|
import "cartocolor";
|
|
6
|
-
import { c as ICON_SIZE_SMALL, b as ICON_SIZE_MEDIUM, u as useTranslationWithFallback, T as Typography, m as LIST_MAX_SIZE, n as LIST_OVERSCAN_ITEMS_COUNT, h as LIST_ITEM_SIZE_DENSE, i as LIST_ITEM_SIZE_DEFAULT } from "./palette-utils-
|
|
6
|
+
import { c as ICON_SIZE_SMALL, b as ICON_SIZE_MEDIUM, u as useTranslationWithFallback, T as Typography, m as LIST_MAX_SIZE, n as LIST_OVERSCAN_ITEMS_COUNT, h as LIST_ITEM_SIZE_DENSE, i as LIST_ITEM_SIZE_DEFAULT } from "./palette-utils-B2CZD7oM.js";
|
|
7
7
|
import * as ReactWindow from "react-window";
|
|
8
8
|
const ScreenReaderOnly = styled("span")(() => ({
|
|
9
9
|
position: "absolute",
|
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// ai-metadata/mcp/server.ts
|
|
4
|
+
import * as fs from "fs";
|
|
5
|
+
import * as path from "path";
|
|
6
|
+
import { fileURLToPath } from "url";
|
|
7
|
+
import { createRequire } from "module";
|
|
8
|
+
|
|
9
|
+
// ai-metadata/types.ts
|
|
10
|
+
function subName(s) {
|
|
11
|
+
return typeof s === "string" ? s : s.name;
|
|
12
|
+
}
|
|
13
|
+
function relatedName(e) {
|
|
14
|
+
return typeof e === "string" ? e : e.name;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// ai-metadata/mcp/server.ts
|
|
18
|
+
var __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
19
|
+
function resolveBundlePath() {
|
|
20
|
+
if (process.env.MERIDIAN_DS_METADATA) return process.env.MERIDIAN_DS_METADATA;
|
|
21
|
+
try {
|
|
22
|
+
return createRequire(import.meta.url).resolve("@carto/meridian-ds/metadata");
|
|
23
|
+
} catch {
|
|
24
|
+
let dir = __dirname;
|
|
25
|
+
for (let i = 0; i < 6; i++) {
|
|
26
|
+
const candidate = path.join(dir, "dist", "metadata.json");
|
|
27
|
+
if (fs.existsSync(candidate)) return candidate;
|
|
28
|
+
dir = path.dirname(dir);
|
|
29
|
+
}
|
|
30
|
+
return path.resolve(__dirname, "..", "..", "dist", "metadata.json");
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
var DOCS = [];
|
|
34
|
+
var KNOWN = [];
|
|
35
|
+
var CONVENTIONS = "";
|
|
36
|
+
var VERSION = "0.0.0";
|
|
37
|
+
var TOOLS = [
|
|
38
|
+
{
|
|
39
|
+
name: "meridian_list_components",
|
|
40
|
+
description: "List all Meridian components with their description and keywords, plus a family signal where relevant (`subComponents` for a compound component, `variants` for sibling components chosen between \u2014 each with a one-line description). Start here: the catalog is small, so read it and pick the component whose description/keywords match your need. Rows flagged `documented: false` are not yet curated (no when-to-use/decisionTree/prop guidance): most still have example stories via get_examples; a few are known-only \u2014 real, importable components with no stories yet, for which get_component/get_examples just point at the type declarations.",
|
|
41
|
+
inputSchema: {
|
|
42
|
+
type: "object",
|
|
43
|
+
properties: {},
|
|
44
|
+
additionalProperties: false
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: "meridian_get_component",
|
|
49
|
+
description: "Curation for one component: when to use it, its decisionTree (when to reach for a different component), any limitations (capabilities it lacks vs. similar components \u2014 check before downgrading from one), and the high-value inherited MUI props (curation.mui, some with an aiHint). Own props, types, and JSDoc are NOT here \u2014 read the shipped .d.ts (the propTypes field gives the exact command). For a not-yet-curated component (`documented: false`) it returns a note + .d.ts pointer in place of curation \u2014 plus its example stories when any exist (a known-only component has none, so rely on the .d.ts). Sub-components and variants (`DialogHeader`, `MultipleAutocomplete`, \u2026) have no standalone catalog entry \u2014 `meridian_get_component`/`meridian_get_examples` on them return a pointer to the parent (check its `curation.subComponents`/`curation.variants`).",
|
|
50
|
+
inputSchema: {
|
|
51
|
+
type: "object",
|
|
52
|
+
properties: {
|
|
53
|
+
name: { type: "string", description: 'Component name, e.g. "Button"' }
|
|
54
|
+
},
|
|
55
|
+
required: ["name"],
|
|
56
|
+
additionalProperties: false
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
name: "meridian_get_examples",
|
|
61
|
+
description: "Real, copy-able example code (per Storybook story, with imports), shipped in the package. With no storyId: the lead usage story and the notable stories in full, plus an 'Other Stories' list (name + id) of the rest. Pass a storyId (from that list or meridian_get_component) to get just that story's full code. Sub-components and variants (`DialogHeader`, `MultipleAutocomplete`, \u2026) have no standalone catalog entry \u2014 `meridian_get_component`/`meridian_get_examples` on them return a pointer to the parent (check its `curation.subComponents`/`curation.variants`).",
|
|
62
|
+
inputSchema: {
|
|
63
|
+
type: "object",
|
|
64
|
+
properties: {
|
|
65
|
+
name: { type: "string", description: 'Component name, e.g. "Button"' },
|
|
66
|
+
storyId: {
|
|
67
|
+
type: "string",
|
|
68
|
+
description: "Optional. A story id (or name) to fetch just that one example \u2014 use for components whose full set is too large to return at once."
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
required: ["name"],
|
|
72
|
+
additionalProperties: false
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
name: "meridian_get_conventions",
|
|
77
|
+
description: "Mandatory system-wide Meridian rules to apply whenever generating or editing UI (component selection, a11y, i18n, styling/theme tokens, props, examples). Call this once per session BEFORE writing code and follow it \u2014 these rules are not repeated in the per-component data.",
|
|
78
|
+
inputSchema: {
|
|
79
|
+
type: "object",
|
|
80
|
+
properties: {},
|
|
81
|
+
additionalProperties: false
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
];
|
|
85
|
+
var find = (name) => DOCS.find((d) => d.name.toLowerCase() === String(name).toLowerCase());
|
|
86
|
+
function notFound(name) {
|
|
87
|
+
const canonical = KNOWN.find((c) => c.toLowerCase() === String(name).toLowerCase());
|
|
88
|
+
if (canonical)
|
|
89
|
+
return {
|
|
90
|
+
note: `"${canonical}" is a Meridian component but isn't individually documented or listed in this catalog. If it's part of the public API, import it from '@carto/meridian-ds/components' and read its props from its type declarations: ${dtsFindRecipe(canonical)}. Prefer a documented component (see meridian_list_components) when one fits.`
|
|
91
|
+
};
|
|
92
|
+
return {
|
|
93
|
+
error: `No Meridian component named "${name}" (check the spelling). See meridian_list_components for the catalog.`
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
function dtsFindRecipe(...names) {
|
|
97
|
+
const root = "find node_modules/@carto/meridian-ds/dist/types";
|
|
98
|
+
const clauses = names.map((n) => `-name '${n}.d.ts'`);
|
|
99
|
+
return names.length > 1 ? `${root} \\( ${clauses.join(" -o ")} \\)` : `${root} ${clauses[0]}`;
|
|
100
|
+
}
|
|
101
|
+
function familyParent(name) {
|
|
102
|
+
const lc = String(name).toLowerCase();
|
|
103
|
+
for (const d of DOCS) {
|
|
104
|
+
const part = d.curation.subComponents?.map(subName).find((s) => s.toLowerCase() === lc);
|
|
105
|
+
if (part) return { parent: d.name, canonical: part, role: "sub-component" };
|
|
106
|
+
const variant = d.curation.variants?.map(subName).find((v) => v.toLowerCase() === lc);
|
|
107
|
+
if (variant) return { parent: d.name, canonical: variant, role: "variant" };
|
|
108
|
+
}
|
|
109
|
+
return void 0;
|
|
110
|
+
}
|
|
111
|
+
function familyRedirect(name) {
|
|
112
|
+
const f = familyParent(name);
|
|
113
|
+
if (!f) return void 0;
|
|
114
|
+
const note = f.role === "sub-component" ? `"${f.canonical}" is a sub-component of ${f.parent} (a compound component) \u2014 it has no standalone catalog entry. See meridian_get_examples('${f.parent}') for how it's composed, and read its own props from its type declarations: ${dtsFindRecipe(f.canonical)}.` : `"${f.canonical}" is a variant of ${f.parent} \u2014 a full component in its own right, not yet individually documented in this catalog. For now use meridian_get_component('${f.parent}') / meridian_get_examples('${f.parent}'), and read ${f.canonical}'s own props from its type declarations: ${dtsFindRecipe(f.canonical)}.`;
|
|
115
|
+
return { note };
|
|
116
|
+
}
|
|
117
|
+
function partitionExamples(examples) {
|
|
118
|
+
const usage = examples.filter((e) => e.isUsage);
|
|
119
|
+
const summarized = examples.filter((e) => !e.isUsage && e.summary);
|
|
120
|
+
const shown = usage.length ? usage : summarized.length ? summarized : examples.slice(0, 1);
|
|
121
|
+
const inShown = new Set(shown);
|
|
122
|
+
return { shown, rest: examples.filter((e) => !inShown.has(e)) };
|
|
123
|
+
}
|
|
124
|
+
function exampleStories(examples) {
|
|
125
|
+
const { shown, rest } = partitionExamples(examples);
|
|
126
|
+
const leadId = shown[0]?.id;
|
|
127
|
+
const ordered = [
|
|
128
|
+
...shown,
|
|
129
|
+
...rest.filter((e) => e.summary),
|
|
130
|
+
...rest.filter((e) => !e.summary)
|
|
131
|
+
];
|
|
132
|
+
return ordered.map((e) => ({
|
|
133
|
+
id: e.id,
|
|
134
|
+
name: titleize(e.name),
|
|
135
|
+
...e.id === leadId ? { lead: true } : {},
|
|
136
|
+
...e.summary ? { summary: e.summary } : {}
|
|
137
|
+
}));
|
|
138
|
+
}
|
|
139
|
+
function listComponents() {
|
|
140
|
+
return DOCS.map((d) => ({
|
|
141
|
+
name: d.name,
|
|
142
|
+
description: d.description,
|
|
143
|
+
// LISTED-only components (no metadata file): flagged so an agent knows
|
|
144
|
+
// get_component won't carry when-to-use/decisionTree/mui guidance for them —
|
|
145
|
+
// examples + the .d.ts are still available. Documented rows omit the flag.
|
|
146
|
+
...d.documented ? {} : { documented: false },
|
|
147
|
+
keywords: d.curation.keywords ?? [],
|
|
148
|
+
// Family signal: the parts a compound component is composed with, and the
|
|
149
|
+
// sibling variants chosen between — each as { name, description } (same shape
|
|
150
|
+
// as get_component) so an agent can pick a family member while scanning.
|
|
151
|
+
...d.curation.subComponents?.length ? { subComponents: d.curation.subComponents } : {},
|
|
152
|
+
...d.curation.variants?.length ? { variants: d.curation.variants } : {},
|
|
153
|
+
// The public hooks/utils/constants that ship with this component — name,
|
|
154
|
+
// kind, and description (same as subComponents/variants, so an agent can pick
|
|
155
|
+
// one while scanning without a get_component round-trip). get_component adds
|
|
156
|
+
// `import` (the entry point — constant across the family, so omitted here).
|
|
157
|
+
...d.curation.relatedExports?.length ? {
|
|
158
|
+
relatedExports: d.curation.relatedExports.map((e) => ({
|
|
159
|
+
name: relatedName(e),
|
|
160
|
+
...typeof e === "object" && e.kind ? { kind: e.kind } : {},
|
|
161
|
+
...typeof e === "object" && e.description ? { description: e.description } : {}
|
|
162
|
+
}))
|
|
163
|
+
} : {}
|
|
164
|
+
}));
|
|
165
|
+
}
|
|
166
|
+
function getComponent(name) {
|
|
167
|
+
const doc = find(name);
|
|
168
|
+
if (!doc) return familyRedirect(name) ?? notFound(name);
|
|
169
|
+
const parts = (doc.curation.subComponents ?? []).map(subName);
|
|
170
|
+
const dtsGlob = dtsFindRecipe(doc.name, ...parts);
|
|
171
|
+
const compound = parts.length > 0 ? `${doc.name} is a compound component \u2014 compose it with its parts: ${parts.join(", ")}. ` : "";
|
|
172
|
+
const parent = doc.documented ? void 0 : familyParent(doc.name);
|
|
173
|
+
const sourceHint = doc.examples.length ? "Use the examples below and its type declarations" : "No example stories ship for it either \u2014 rely on its type declarations (the propTypes recipe below)";
|
|
174
|
+
const note = doc.documented ? void 0 : `${parent ? `${doc.name} is a ${parent.role} of ${parent.parent} \u2014 compose it within ${parent.parent} (see meridian_get_component('${parent.parent}')). ` : ""}Not yet curated: no when-to-use / decisionTree / keywords / promoted-prop guidance for this component. ${sourceHint} \u2014 and still prefer it over a bare MUI equivalent.`;
|
|
175
|
+
return {
|
|
176
|
+
name: doc.name,
|
|
177
|
+
description: doc.description,
|
|
178
|
+
documented: doc.documented,
|
|
179
|
+
...note ? { note } : {},
|
|
180
|
+
curation: doc.curation,
|
|
181
|
+
// Own props/types/JSDoc aren't in the bundle by design; point a headless
|
|
182
|
+
// agent at the shipped .d.ts (no IDE/hover assumed) — for the root and, for a
|
|
183
|
+
// compound component, every part. Promoted inherited MUI props, when curated,
|
|
184
|
+
// are already in `curation.mui` above.
|
|
185
|
+
propTypes: `${compound}Own props, exact types, and JSDoc are not in this payload \u2014 they ship as TypeScript declarations. Read them from the installed package: \`${dtsGlob}\`. Import from '@carto/meridian-ds/components'.`,
|
|
186
|
+
examples: doc.examples.length ? {
|
|
187
|
+
note: "Stories are ordered by copy-value; the flagged lead is the starting point. Call meridian_get_examples(name) for the lead in full plus an index of the rest; pass a storyId for any specific one.",
|
|
188
|
+
stories: exampleStories(doc.examples)
|
|
189
|
+
} : {
|
|
190
|
+
note: "No example stories ship for this component yet \u2014 read its props from the .d.ts (see propTypes above).",
|
|
191
|
+
stories: []
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
function titleize(name) {
|
|
196
|
+
return name.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1 $2").trim();
|
|
197
|
+
}
|
|
198
|
+
function getComponentExamples(name, storyId) {
|
|
199
|
+
const doc = find(name);
|
|
200
|
+
if (!doc) return familyRedirect(name) ?? notFound(name);
|
|
201
|
+
if (storyId) {
|
|
202
|
+
const ex = doc.examples.find((e) => e.id === storyId || e.name === storyId);
|
|
203
|
+
if (!ex)
|
|
204
|
+
return {
|
|
205
|
+
error: `Unknown story "${storyId}" for ${doc.name}. Available: ${doc.examples.map((e) => e.id).join(", ")}`
|
|
206
|
+
};
|
|
207
|
+
const summary = ex.summary ? `${ex.summary}
|
|
208
|
+
|
|
209
|
+
` : "";
|
|
210
|
+
return `# ${doc.name} - ${titleize(ex.name)}
|
|
211
|
+
|
|
212
|
+
${summary}${ex.code}`;
|
|
213
|
+
}
|
|
214
|
+
if (!doc.examples.length)
|
|
215
|
+
return `# ${doc.name}
|
|
216
|
+
|
|
217
|
+
No example stories ship for ${doc.name} yet. It's a real Meridian component \u2014 import it from '@carto/meridian-ds/components' and read its props from its type declarations: ${dtsFindRecipe(doc.name)}.`;
|
|
218
|
+
const componentId = doc.examples[0].id.split("--")[0];
|
|
219
|
+
const { shown, rest } = partitionExamples(doc.examples);
|
|
220
|
+
let md = `# ${doc.name}
|
|
221
|
+
|
|
222
|
+
ID: ${componentId}
|
|
223
|
+
|
|
224
|
+
## Stories
|
|
225
|
+
`;
|
|
226
|
+
for (const e of shown) {
|
|
227
|
+
md += `
|
|
228
|
+
### ${titleize(e.name)}
|
|
229
|
+
|
|
230
|
+
Story ID: ${e.id}
|
|
231
|
+
|
|
232
|
+
`;
|
|
233
|
+
if (e.summary) md += `${e.summary}
|
|
234
|
+
|
|
235
|
+
`;
|
|
236
|
+
md += `${e.code}
|
|
237
|
+
`;
|
|
238
|
+
}
|
|
239
|
+
if (rest.length) {
|
|
240
|
+
md += `
|
|
241
|
+
### Other Stories
|
|
242
|
+
|
|
243
|
+
Fetch any with meridian_get_examples(storyId):
|
|
244
|
+
|
|
245
|
+
`;
|
|
246
|
+
md += rest.map(
|
|
247
|
+
(e) => `- ${titleize(e.name)} (${e.id})${e.summary ? ` \u2014 ${e.summary}` : ""}`
|
|
248
|
+
).join("\n");
|
|
249
|
+
md += "\n";
|
|
250
|
+
}
|
|
251
|
+
return md;
|
|
252
|
+
}
|
|
253
|
+
function callTool(name, args) {
|
|
254
|
+
switch (name) {
|
|
255
|
+
case "meridian_list_components":
|
|
256
|
+
return listComponents();
|
|
257
|
+
case "meridian_get_component":
|
|
258
|
+
return getComponent(String(args.name ?? ""));
|
|
259
|
+
case "meridian_get_examples":
|
|
260
|
+
return getComponentExamples(
|
|
261
|
+
String(args.name ?? ""),
|
|
262
|
+
args.storyId ? String(args.storyId) : void 0
|
|
263
|
+
);
|
|
264
|
+
case "meridian_get_conventions":
|
|
265
|
+
return CONVENTIONS;
|
|
266
|
+
default:
|
|
267
|
+
throw new Error(`Unknown tool: ${name}`);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
var SERVER_INSTRUCTIONS = `Meridian Design System knowledge for writing React UI in an app that depends on @carto/meridian-ds.
|
|
271
|
+
|
|
272
|
+
REQUIRED FIRST STEP: before writing or editing ANY Meridian UI, call meridian_get_conventions once and follow it for the rest of the session. These are mandatory cross-cutting rules (component selection, a11y, i18n, styling/theme tokens, props, examples) that the per-component data does NOT repeat \u2014 skipping them produces off-spec code.
|
|
273
|
+
|
|
274
|
+
Flow:
|
|
275
|
+
1. meridian_get_conventions \u2014 read first; apply throughout the session.
|
|
276
|
+
2. meridian_list_components \u2014 read the (small) catalog and pick by description + keywords. There is no search tool; match by meaning (the model already knows "picker" \u2248 "dropdown" \u2248 "select").
|
|
277
|
+
3. meridian_get_component(name) \u2014 when to use it, its decisionTree (conditions that point to a different component), and the high-value inherited MUI props worth knowing (curation.mui; some carry an aiHint). It also returns the example story ids.
|
|
278
|
+
4. meridian_get_examples(name[, storyId]) \u2014 real, copy-able example code. With no storyId: the lead usage story and the notable stories in full plus a list of the rest; pass a storyId for one story's full code.
|
|
279
|
+
|
|
280
|
+
Three tiers of components, by how much each carries (all are real and importable \u2014 always prefer one over a bare MUI equivalent): CURATED (most) have full when-to-use / decisionTree / promoted-prop guidance; LISTED (flagged "documented": false, with example stories) carry no curation yet \u2014 lean on get_examples + the .d.ts; KNOWN (flagged "documented": false, no stories) are real components not yet documented \u2014 get_component/get_examples point you at their type declarations (.d.ts).
|
|
281
|
+
|
|
282
|
+
Exact own props, types, and JSDoc are NOT served here \u2014 they ship as TypeScript declarations in the installed package. Read them with: find node_modules/@carto/meridian-ds/dist/types -name '<Component>.d.ts'. Import the component from '@carto/meridian-ds/components'. Prefer a Meridian component over a bare MUI one whenever one exists.`;
|
|
283
|
+
function send(msg) {
|
|
284
|
+
process.stdout.write(JSON.stringify(msg) + "\n");
|
|
285
|
+
}
|
|
286
|
+
function handle(req) {
|
|
287
|
+
const { id, method, params } = req;
|
|
288
|
+
const reply = (result) => send({ jsonrpc: "2.0", id, result });
|
|
289
|
+
switch (method) {
|
|
290
|
+
case "initialize":
|
|
291
|
+
return reply({
|
|
292
|
+
protocolVersion: "2024-11-05",
|
|
293
|
+
capabilities: { tools: {} },
|
|
294
|
+
serverInfo: { name: "meridian-design-system", version: VERSION },
|
|
295
|
+
instructions: SERVER_INSTRUCTIONS
|
|
296
|
+
});
|
|
297
|
+
case "notifications/initialized":
|
|
298
|
+
return;
|
|
299
|
+
// notification, no response
|
|
300
|
+
case "ping":
|
|
301
|
+
return reply({});
|
|
302
|
+
case "tools/list":
|
|
303
|
+
return reply({ tools: TOOLS });
|
|
304
|
+
case "tools/call":
|
|
305
|
+
try {
|
|
306
|
+
const result = callTool(params?.name, params?.arguments ?? {});
|
|
307
|
+
const text = typeof result === "string" ? result : JSON.stringify(result, null, 2);
|
|
308
|
+
return reply({ content: [{ type: "text", text }] });
|
|
309
|
+
} catch (err) {
|
|
310
|
+
return reply({
|
|
311
|
+
content: [{ type: "text", text: `Error: ${err.message}` }],
|
|
312
|
+
isError: true
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
default:
|
|
316
|
+
if (id !== void 0) {
|
|
317
|
+
send({
|
|
318
|
+
jsonrpc: "2.0",
|
|
319
|
+
id,
|
|
320
|
+
error: { code: -32601, message: `Method not found: ${method}` }
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
function load() {
|
|
326
|
+
const bundlePath = resolveBundlePath();
|
|
327
|
+
if (!fs.existsSync(bundlePath)) {
|
|
328
|
+
throw new Error(
|
|
329
|
+
`metadata bundle not found at ${bundlePath}. In the Meridian repo run \`yarn metadata:build\`; in a consumer it ships with @carto/meridian-ds.`
|
|
330
|
+
);
|
|
331
|
+
}
|
|
332
|
+
const bundle = JSON.parse(
|
|
333
|
+
fs.readFileSync(bundlePath, "utf8")
|
|
334
|
+
);
|
|
335
|
+
DOCS = bundle.components;
|
|
336
|
+
KNOWN = bundle.knownComponents ?? [];
|
|
337
|
+
CONVENTIONS = bundle.conventions;
|
|
338
|
+
VERSION = bundle.version;
|
|
339
|
+
process.stderr.write(
|
|
340
|
+
`[meridian-design-system] v${VERSION} ready: ${DOCS.map((d) => d.name).join(", ")}
|
|
341
|
+
`
|
|
342
|
+
);
|
|
343
|
+
}
|
|
344
|
+
function main() {
|
|
345
|
+
load();
|
|
346
|
+
let buf = "";
|
|
347
|
+
process.stdin.setEncoding("utf8");
|
|
348
|
+
process.stdin.on("data", (chunk) => {
|
|
349
|
+
buf += chunk;
|
|
350
|
+
let nl;
|
|
351
|
+
while ((nl = buf.indexOf("\n")) >= 0) {
|
|
352
|
+
const line = buf.slice(0, nl).trim();
|
|
353
|
+
buf = buf.slice(nl + 1);
|
|
354
|
+
if (!line) continue;
|
|
355
|
+
try {
|
|
356
|
+
handle(JSON.parse(line));
|
|
357
|
+
} catch (err) {
|
|
358
|
+
process.stderr.write(
|
|
359
|
+
`[meridian-design-system] bad message: ${err.message}
|
|
360
|
+
`
|
|
361
|
+
);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
});
|
|
365
|
+
process.stdin.on("end", () => process.exit(0));
|
|
366
|
+
}
|
|
367
|
+
try {
|
|
368
|
+
main();
|
|
369
|
+
} catch (err) {
|
|
370
|
+
process.stderr.write(`[meridian-design-system] fatal: ${err}
|
|
371
|
+
`);
|
|
372
|
+
process.exit(1);
|
|
373
|
+
}
|