@carto/meridian-ds 3.0.2-alpha.e34a00a.237 → 3.0.2-alpha.f30ac88.245

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/README.md +34 -0
  2. package/dist/bin/meridian-ds-mcp.js +53 -17
  3. package/dist/metadata.json +715 -0
  4. package/dist/types/components/Autocomplete/Autocomplete/Autocomplete.d.ts +1 -0
  5. package/dist/types/components/Autocomplete/Autocomplete/Autocomplete.d.ts.map +1 -1
  6. package/dist/types/components/Autocomplete/Autocomplete/Autocomplete.metadata.d.ts +26 -0
  7. package/dist/types/components/Autocomplete/Autocomplete/Autocomplete.metadata.d.ts.map +1 -0
  8. package/dist/types/components/Autocomplete/Autocomplete/Autocomplete.stories.d.ts.map +1 -1
  9. package/dist/types/components/Autocomplete/types.d.ts +2 -1
  10. package/dist/types/components/Autocomplete/types.d.ts.map +1 -1
  11. package/dist/types/components/Button/Button.d.ts +1 -3
  12. package/dist/types/components/Button/Button.d.ts.map +1 -1
  13. package/dist/types/components/Button/Button.metadata.d.ts +17 -11
  14. package/dist/types/components/Button/Button.metadata.d.ts.map +1 -1
  15. package/dist/types/components/Dialog/Dialog/Dialog.d.ts +1 -0
  16. package/dist/types/components/Dialog/Dialog/Dialog.d.ts.map +1 -1
  17. package/dist/types/components/Dialog/Dialog/Dialog.metadata.d.ts +26 -0
  18. package/dist/types/components/Dialog/Dialog/Dialog.metadata.d.ts.map +1 -0
  19. package/dist/types/components/Dialog/types.d.ts +3 -8
  20. package/dist/types/components/Dialog/types.d.ts.map +1 -1
  21. package/dist/types/components/IconButton/IconButton.d.ts +10 -18
  22. package/dist/types/components/IconButton/IconButton.d.ts.map +1 -1
  23. package/dist/types/components/IconButton/IconButton.metadata.d.ts +5 -6
  24. package/dist/types/components/IconButton/IconButton.metadata.d.ts.map +1 -1
  25. package/dist/types/components/IconButton/IconButton.stories.d.ts +13 -0
  26. package/dist/types/components/IconButton/IconButton.stories.d.ts.map +1 -1
  27. package/dist/types/components/SelectField/SelectField/SelectField.d.ts +1 -0
  28. package/dist/types/components/SelectField/SelectField/SelectField.d.ts.map +1 -1
  29. package/dist/types/components/SelectField/SelectField/SelectField.metadata.d.ts +26 -0
  30. package/dist/types/components/SelectField/SelectField/SelectField.metadata.d.ts.map +1 -0
  31. package/dist/types/components/SelectField/SelectField/SelectField.stories.d.ts.map +1 -1
  32. package/dist/types/components/SelectField/types.d.ts +6 -0
  33. package/dist/types/components/SelectField/types.d.ts.map +1 -1
  34. package/dist/types/components/SplitButton/SplitButton.d.ts +2 -6
  35. package/dist/types/components/SplitButton/SplitButton.d.ts.map +1 -1
  36. package/dist/types/components/SplitButton/SplitButton.metadata.d.ts +8 -4
  37. package/dist/types/components/SplitButton/SplitButton.metadata.d.ts.map +1 -1
  38. package/dist/types/components/Typography/Typography.d.ts +3 -0
  39. package/dist/types/components/Typography/Typography.d.ts.map +1 -1
  40. package/dist/types/components/Typography/Typography.metadata.d.ts +26 -0
  41. package/dist/types/components/Typography/Typography.metadata.d.ts.map +1 -0
  42. package/package.json +5 -7
  43. package/ai-metadata/generated/metadata.json +0 -261
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.
@@ -13,16 +13,11 @@ function resolveBundlePath() {
13
13
  } catch {
14
14
  let dir = __dirname;
15
15
  for (let i = 0; i < 6; i++) {
16
- const candidate = path.join(
17
- dir,
18
- "ai-metadata",
19
- "generated",
20
- "metadata.json"
21
- );
16
+ const candidate = path.join(dir, "dist", "metadata.json");
22
17
  if (fs.existsSync(candidate)) return candidate;
23
18
  dir = path.dirname(dir);
24
19
  }
25
- return path.resolve(__dirname, "..", "generated", "metadata.json");
20
+ return path.resolve(__dirname, "..", "..", "dist", "metadata.json");
26
21
  }
27
22
  }
28
23
  var DOCS = [];
@@ -31,7 +26,7 @@ var VERSION = "0.0.0";
31
26
  var TOOLS = [
32
27
  {
33
28
  name: "meridian_list_components",
34
- description: "List all Meridian components with their description, search keywords, and example count. Start here: the catalog is small, so read it and pick the component whose description/keywords match your need.",
29
+ description: "List all Meridian components with their description, keywords, and example count. Start here: the catalog is small, so read it and pick the component whose description/keywords match your need.",
35
30
  inputSchema: {
36
31
  type: "object",
37
32
  properties: {},
@@ -40,7 +35,7 @@ var TOOLS = [
40
35
  },
41
36
  {
42
37
  name: "meridian_get_component",
43
- description: "Curation for one component \u2014 when to use it, alternatives, gotchas, the high-value inherited MUI props worth knowing (curation.mui), and its example story ids. Props & exact types come from the package .d.ts (import the component; your IDE/tsc has them). Call meridian_get_examples for example code.",
38
+ description: "Curation for one component: when to use it, its decisionTree (when to reach for a different component), and the high-value inherited MUI props (curation.mui, some with an aiHint). Props, types, and JSDoc are NOT here \u2014 import the component and let your IDE/tsc show them.",
44
39
  inputSchema: {
45
40
  type: "object",
46
41
  properties: {
@@ -52,11 +47,15 @@ var TOOLS = [
52
47
  },
53
48
  {
54
49
  name: "meridian_get_examples",
55
- description: "Real, copy-able example code for a component (one entry per Storybook story: name, id, source), shipped in the package.",
50
+ description: "Real, copy-able example code for a component (one entry per Storybook story: name, id, source), shipped in the package. With no storyId, returns every story's code \u2014 or, when that would be too large for one response, an index of {name, id} to fetch individually. Pass a storyId (from the index or meridian_get_component) to get a single story's full code.",
56
51
  inputSchema: {
57
52
  type: "object",
58
53
  properties: {
59
- name: { type: "string", description: 'Component name, e.g. "Button"' }
54
+ name: { type: "string", description: 'Component name, e.g. "Button"' },
55
+ storyId: {
56
+ type: "string",
57
+ 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."
58
+ }
60
59
  },
61
60
  required: ["name"],
62
61
  additionalProperties: false
@@ -64,7 +63,7 @@ var TOOLS = [
64
63
  },
65
64
  {
66
65
  name: "meridian_get_conventions",
67
- description: "System-wide Meridian usage conventions an agent should apply when generating code (selection, a11y, props, examples).",
66
+ 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.",
68
67
  inputSchema: {
69
68
  type: "object",
70
69
  properties: {},
@@ -90,21 +89,43 @@ function getComponent(name) {
90
89
  return {
91
90
  name: doc.name,
92
91
  description: doc.description,
92
+ reminder: "Apply the session conventions when using this \u2014 call meridian_get_conventions first if you have not this session.",
93
93
  curation: doc.curation,
94
94
  props: {
95
95
  note: "Own props + exact types/JSDoc come from the package's type declarations \u2014 `import { " + doc.name + " } from '@carto/meridian-ds/components'` and your IDE/tsc shows the full signature. High-value inherited MUI props are in `curation.mui` (e.g. color, variant, size).",
96
96
  promotedMuiProps: doc.curation.mui ?? []
97
97
  },
98
98
  examples: {
99
- note: "Call meridian_get_examples for the source code of these stories.",
99
+ note: "Call meridian_get_examples for the source of these stories (pass a storyId for one at a time if the full set is large).",
100
100
  storyIds: doc.examples.map((e) => e.id)
101
101
  }
102
102
  };
103
103
  }
104
- function getComponentExamples(name) {
104
+ var EXAMPLES_INLINE_LIMIT = 3e4;
105
+ function getComponentExamples(name, storyId) {
105
106
  const doc = find(name);
106
107
  if (!doc) return notFound(name);
107
- return { component: doc.name, examples: doc.examples };
108
+ if (storyId) {
109
+ const ex = doc.examples.find((e) => e.id === storyId || e.name === storyId);
110
+ if (!ex)
111
+ return {
112
+ error: `Unknown story "${storyId}" for ${doc.name}. Available: ${doc.examples.map((e) => e.id).join(", ")}`
113
+ };
114
+ return { component: doc.name, example: ex };
115
+ }
116
+ const total = doc.examples.reduce((n, e) => n + e.code.length, 0);
117
+ if (total <= EXAMPLES_INLINE_LIMIT) {
118
+ return { component: doc.name, examples: doc.examples };
119
+ }
120
+ return {
121
+ component: doc.name,
122
+ note: `${doc.examples.length} examples (~${Math.round(total / 1024)} KB) \u2014 too large to return at once. Call meridian_get_examples again with a storyId from the list below for one story's full code.`,
123
+ examples: doc.examples.map((e) => ({
124
+ name: e.name,
125
+ id: e.id,
126
+ bytes: e.code.length
127
+ }))
128
+ };
108
129
  }
109
130
  function callTool(name, args) {
110
131
  switch (name) {
@@ -113,13 +134,27 @@ function callTool(name, args) {
113
134
  case "meridian_get_component":
114
135
  return getComponent(String(args.name ?? ""));
115
136
  case "meridian_get_examples":
116
- return getComponentExamples(String(args.name ?? ""));
137
+ return getComponentExamples(
138
+ String(args.name ?? ""),
139
+ args.storyId ? String(args.storyId) : void 0
140
+ );
117
141
  case "meridian_get_conventions":
118
142
  return { conventions: CONVENTIONS };
119
143
  default:
120
144
  throw new Error(`Unknown tool: ${name}`);
121
145
  }
122
146
  }
147
+ var SERVER_INSTRUCTIONS = `Meridian Design System knowledge for writing React UI in an app that depends on @carto/meridian-ds.
148
+
149
+ 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.
150
+
151
+ Flow:
152
+ 1. meridian_get_conventions \u2014 read first; apply throughout the session.
153
+ 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").
154
+ 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.
155
+ 4. meridian_get_examples(name[, storyId]) \u2014 real, copy-able example code. For large sets it returns an index of story ids instead of all code; pass a storyId to fetch one story.
156
+
157
+ Exact props, types, and JSDoc are NOT served here: import the component from '@carto/meridian-ds/components' and let your IDE/tsc show the full, version-correct signature. Prefer a Meridian component over a bare MUI one whenever one exists.`;
123
158
  function send(msg) {
124
159
  process.stdout.write(JSON.stringify(msg) + "\n");
125
160
  }
@@ -131,7 +166,8 @@ function handle(req) {
131
166
  return reply({
132
167
  protocolVersion: "2024-11-05",
133
168
  capabilities: { tools: {} },
134
- serverInfo: { name: "meridian-design-system", version: VERSION }
169
+ serverInfo: { name: "meridian-design-system", version: VERSION },
170
+ instructions: SERVER_INSTRUCTIONS
135
171
  });
136
172
  case "notifications/initialized":
137
173
  return;