@1money/component-ui 0.0.23 → 0.0.24

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 (97) hide show
  1. package/es/stories/docs/ComponentDocsPage.js +234 -0
  2. package/es/stories/docs/componentDocMeta.js +97 -0
  3. package/es/stories/docs/storybook-docs.css +79 -0
  4. package/lib/stories/docs/ComponentDocsPage.js +244 -0
  5. package/lib/stories/docs/componentDocMeta.js +104 -0
  6. package/lib/stories/docs/storybook-docs.css +79 -0
  7. package/package.json +23 -8
  8. package/scripts/mcp-server/README.md +267 -0
  9. package/scripts/mcp-server/bin.mjs +2 -0
  10. package/scripts/mcp-server/drift.json +5 -0
  11. package/scripts/mcp-server/examples.generated.json +2651 -0
  12. package/scripts/mcp-server/index.generated.json +18098 -0
  13. package/scripts/mcp-server/index.mjs +308 -26
  14. package/scripts/mcp-server/tools/get-examples.mjs +125 -0
  15. package/scripts/mcp-server/tools/get-library-info.mjs +25 -0
  16. package/scripts/mcp-server/tools/get-symbol.mjs +232 -0
  17. package/scripts/mcp-server/tools/get-token.mjs +60 -0
  18. package/scripts/mcp-server/tools/list-icons.mjs +38 -0
  19. package/scripts/mcp-server/tools/list-symbols.mjs +46 -0
  20. package/scripts/mcp-server/tools/resolve-import.mjs +125 -0
  21. package/scripts/mcp-server/tools/search-symbols.mjs +79 -0
  22. package/.agents/skills/1money-component-dev/SKILL.md +0 -224
  23. package/.agents/skills/1money-component-dev/checklist.md +0 -159
  24. package/.agents/skills/1money-component-dev/references/ComponentPatterns.md +0 -478
  25. package/.agents/skills/1money-component-dev/references/FigmaExtractionChecklist.md +0 -144
  26. package/.agents/skills/1money-component-dev/references/HooksGuide.md +0 -360
  27. package/.agents/skills/1money-component-dev/references/SemanticColors.md +0 -215
  28. package/.agents/skills/1money-component-dev/references/StyleSystemAPI.md +0 -389
  29. package/.claude/settings.local.json +0 -120
  30. package/.claude/skills/1money-component-dev/SKILL.md +0 -229
  31. package/.claude/skills/1money-component-dev/checklist.md +0 -159
  32. package/.claude/skills/1money-component-dev/references/ComponentPatterns.md +0 -478
  33. package/.claude/skills/1money-component-dev/references/FigmaExtractionChecklist.md +0 -144
  34. package/.claude/skills/1money-component-dev/references/HooksGuide.md +0 -360
  35. package/.claude/skills/1money-component-dev/references/SemanticColors.md +0 -215
  36. package/.claude/skills/1money-component-dev/references/StyleSystemAPI.md +0 -389
  37. package/.claude/skills/1money-component-review/SKILL.md +0 -316
  38. package/.claude/skills/component-pipeline/SKILL.md +0 -116
  39. package/.claude/skills/component-pipeline/checklist.md +0 -125
  40. package/.hintrc +0 -13
  41. package/@types/global.d.ts +0 -28
  42. package/AGENTS.md +0 -546
  43. package/CLAUDE.md +0 -1
  44. package/jest.setup.d.ts +0 -1
  45. package/jest.setup.ts +0 -1
  46. package/patches/primereact.patch +0 -323
  47. package/patches/react-pro-sidebar.patch +0 -6421
  48. package/public/favicon.ico +0 -0
  49. package/public/fonts/Aeonik/Aeonik-Air.ttf +0 -0
  50. package/public/fonts/Aeonik/Aeonik-AirItalic.ttf +0 -0
  51. package/public/fonts/Aeonik/Aeonik-Black.ttf +0 -0
  52. package/public/fonts/Aeonik/Aeonik-BlackItalic.ttf +0 -0
  53. package/public/fonts/Aeonik/Aeonik-Bold.ttf +0 -0
  54. package/public/fonts/Aeonik/Aeonik-BoldItalic.ttf +0 -0
  55. package/public/fonts/Aeonik/Aeonik-Light.ttf +0 -0
  56. package/public/fonts/Aeonik/Aeonik-LightItalic.ttf +0 -0
  57. package/public/fonts/Aeonik/Aeonik-Medium.ttf +0 -0
  58. package/public/fonts/Aeonik/Aeonik-MediumItalic.ttf +0 -0
  59. package/public/fonts/Aeonik/Aeonik-Regular.ttf +0 -0
  60. package/public/fonts/Aeonik/Aeonik-RegularItalic.ttf +0 -0
  61. package/public/fonts/Aeonik/Aeonik-Thin.ttf +0 -0
  62. package/public/fonts/Aeonik/Aeonik-ThinItalic.ttf +0 -0
  63. package/public/fonts/Inter/Inter-Black.ttf +0 -0
  64. package/public/fonts/Inter/Inter-BlackItalic.ttf +0 -0
  65. package/public/fonts/Inter/Inter-Bold.ttf +0 -0
  66. package/public/fonts/Inter/Inter-BoldItalic.ttf +0 -0
  67. package/public/fonts/Inter/Inter-ExtraBold.ttf +0 -0
  68. package/public/fonts/Inter/Inter-ExtraBoldItalic.ttf +0 -0
  69. package/public/fonts/Inter/Inter-ExtraLight.ttf +0 -0
  70. package/public/fonts/Inter/Inter-ExtraLightItalic.ttf +0 -0
  71. package/public/fonts/Inter/Inter-Italic.ttf +0 -0
  72. package/public/fonts/Inter/Inter-Light.ttf +0 -0
  73. package/public/fonts/Inter/Inter-LightItalic.ttf +0 -0
  74. package/public/fonts/Inter/Inter-Medium.ttf +0 -0
  75. package/public/fonts/Inter/Inter-MediumItalic.ttf +0 -0
  76. package/public/fonts/Inter/Inter-Regular.ttf +0 -0
  77. package/public/fonts/Inter/Inter-SemiBold.ttf +0 -0
  78. package/public/fonts/Inter/Inter-SemiBoldItalic.ttf +0 -0
  79. package/public/fonts/Inter/Inter-Thin.ttf +0 -0
  80. package/public/fonts/Inter/Inter-ThinItalic.ttf +0 -0
  81. package/public/fonts/Outfit/Outfit-Black.ttf +0 -0
  82. package/public/fonts/Outfit/Outfit-Bold.ttf +0 -0
  83. package/public/fonts/Outfit/Outfit-ExtraBold.ttf +0 -0
  84. package/public/fonts/Outfit/Outfit-ExtraLight.ttf +0 -0
  85. package/public/fonts/Outfit/Outfit-Light.ttf +0 -0
  86. package/public/fonts/Outfit/Outfit-Medium.ttf +0 -0
  87. package/public/fonts/Outfit/Outfit-Regular.ttf +0 -0
  88. package/public/fonts/Outfit/Outfit-SemiBold.ttf +0 -0
  89. package/public/fonts/Outfit/Outfit-Thin.ttf +0 -0
  90. package/public/github-mark.svg +0 -3
  91. package/public/tokens/GYEN.svg +0 -9
  92. package/public/tokens/PYUSD.svg +0 -9
  93. package/public/tokens/USDT.svg +0 -6
  94. package/scripts/mcp-server/resources.d.mts +0 -1
  95. package/scripts/mcp-server/resources.mjs +0 -102
  96. package/test/jsdom-global-register.d.ts +0 -1
  97. package/test/jsdom-global-register.js +0 -1
@@ -0,0 +1,267 @@
1
+ # `@1money/component-ui` MCP Server
2
+
3
+ ## Overview
4
+
5
+ The `@1money/component-ui` package ships an [MCP](https://modelcontextprotocol.io/) stdio
6
+ server so AI coding assistants can answer questions like "which 1money component do I use
7
+ for X?", "what are its props?", and "how do I import it?" without grepping source. It runs
8
+ out of the consumer's `node_modules` via `npx --package=@1money/component-ui 1money-ui-mcp`
9
+ and communicates over stdio — no network, no auth, no hosted service. Because each
10
+ consumer repo pins its own version of `@1money/component-ui`, the server always answers
11
+ against the exact library version that repo is using: upgrade the package, the answers
12
+ upgrade with it.
13
+
14
+ The server loads three committed artifacts at startup — `index.generated.json` (symbols,
15
+ tokens, icons), `examples.generated.json` (content-hashed example bodies), and
16
+ `drift.json` (export-map audit) — then exposes 8 MCP tools. See §3 of
17
+ `docs/plans/2026-04-21-component-library-mcp.md` for the design background.
18
+
19
+ ## Usage — consumer `.mcp.json`
20
+
21
+ Add this to the downstream repo's `.mcp.json` (Claude Code, Cursor, and any other
22
+ MCP-speaking client read the same file):
23
+
24
+ ```json
25
+ {
26
+ "mcpServers": {
27
+ "1money-ui": {
28
+ "command": "npx",
29
+ "args": ["-y", "--package=@1money/component-ui", "1money-ui-mcp"]
30
+ }
31
+ }
32
+ }
33
+ ```
34
+
35
+ `@1money/component-ui` must be resolvable from the consumer repo's `node_modules`
36
+ (direct or transitive dep). `npx` then spawns the `1money-ui-mcp` bin entry shipped in
37
+ the installed tarball — no global install required. The package declares:
38
+
39
+ ```jsonc
40
+ // package.json (publisher side — already wired)
41
+ {
42
+ "bin": { "1money-ui-mcp": "scripts/mcp-server/bin.mjs" }
43
+ }
44
+ ```
45
+
46
+ Verify locally with `pnpm mcp:check` (runs the server's `--selftest` harness against
47
+ every tool with a canned input).
48
+
49
+ ## Tool reference
50
+
51
+ All tools return JSON. Errors surface as MCP tool errors (`isError: true`) with a plain
52
+ message. Successful responses are delivered both as a text block (for human debugging)
53
+ and as `structuredContent` (for programmatic use).
54
+
55
+ ### `list_symbols`
56
+
57
+ Lists top-level exported symbols (components, modules, hooks, functions, types).
58
+ Namespace roots (`ProForm`, `Icons`, `Input`) surface as `kind: "module"`.
59
+
60
+ - Input: `{ kind?: "component" | "module" | "hook" | "function" | "type" | "all", category?: string }`
61
+ - Output: `{ symbols: [{ name, kind, category, summary, importPath }] }`
62
+
63
+ ```jsonc
64
+ // input: { "kind": "module" }
65
+ // output: { "symbols": [
66
+ // { "name": "Icons", "kind": "module", "category": "display", "summary": "...", "importPath": "@1money/component-ui" },
67
+ // { "name": "Input", "kind": "module", "category": "input", ... },
68
+ // { "name": "ProForm", "kind": "module", "category": "form", ... }
69
+ // ] }
70
+ ```
71
+
72
+ ### `search_symbols`
73
+
74
+ Fuzzy search with synonym support. Scores against name, `searchTags` (aliases from
75
+ `synonyms.json`), summary, and prop names.
76
+
77
+ - Input: `{ query: string, limit?: number (default 5) }`
78
+ - Output: `{ hits: [{ name, score, matchedOn }] }`
79
+
80
+ ```jsonc
81
+ // input: { "query": "modal", "limit": 3 }
82
+ // output: { "hits": [{ "name": "Dialog", "score": 70, "matchedOn": "tag" }] }
83
+ ```
84
+
85
+ ### `get_symbol`
86
+
87
+ Structured record for one symbol. Accepts flat names (`ProFormItem`) or dotted paths
88
+ (`ProForm.Item`). Unknown names return `{ kind: "not_exported", hint }`.
89
+
90
+ - Input: `{ name: string, include?: Array<"props"|"examples"|"members"|"notes"|"related"> }`
91
+ - Output: `{ name, kind, category, summary, imports, props, members, canonicalUsage, relatedSymbols, ... }`
92
+
93
+ ```jsonc
94
+ // input: { "name": "ProForm.Item" }
95
+ // output: { "name": "ProFormItem", "inputName": "ProForm.Item", "kind": "component",
96
+ // "imports": { "named": "import { ProFormItem } from '@1money/component-ui';",
97
+ // "namespaceAccess": "ProForm.Item", ... },
98
+ // "props": [...], "canonicalUsage": "<ProFormItem name=\"email\" ... />", ... }
99
+ ```
100
+
101
+ ### `get_examples`
102
+
103
+ Curated usage snippets. Sources: README fenced blocks (`readme`), Storybook `render`
104
+ bodies (`stories`), and canonical snippets (`canonical`). Bodies live in
105
+ `examples.generated.json` and are hydrated at request time.
106
+
107
+ - Input: `{ name: string, limit?: number (default 3), source?: "all"|"readme"|"stories"|"canonical" }`
108
+ - Output: `{ examples: [{ title, code, source, compilable }] }`
109
+
110
+ ```jsonc
111
+ // input: { "name": "Button", "limit": 1, "source": "readme" }
112
+ // output: { "examples": [{ "title": "Basic", "code": "<Button color=\"primary\">Label</Button>",
113
+ // "source": "readme", "compilable": true }] }
114
+ ```
115
+
116
+ ### `list_icons`
117
+
118
+ Icon name catalog for `<Icons name="..." />`. Icon names are string keys, not exported
119
+ symbols — you cannot `import { ChevronDown }`.
120
+
121
+ - Input: `{ query?: string, limit?: number }`
122
+ - Output: `{ total: number, icons: [{ name }] }`
123
+
124
+ ```jsonc
125
+ // input: { "query": "chevron", "limit": 2 }
126
+ // output: { "total": 8, "icons": [{ "name": "chevronDown" }, { "name": "chevronLeft" }] }
127
+ ```
128
+
129
+ ### `get_token`
130
+
131
+ Resolve design tokens by exact name / CSS var / SCSS alias, by `kind`, or by name
132
+ `prefix`. Filters combine with AND.
133
+
134
+ - Input: `{ name?: string, kind?: "color"|"spacing"|"radius"|"shadow"|"sizing"|"opacity"|"typography"|"breakpoint", prefix?: string }`
135
+ - Output: `{ tokens: [{ name, scss, cssVar, value, resolved, kind, layer }] }`
136
+
137
+ ```jsonc
138
+ // input: { "kind": "breakpoint" }
139
+ // output: { "tokens": [{ "name": "breakpoint-md", "cssVar": "--om-breakpoint-md",
140
+ // "value": "1024px", "resolved": "1024px",
141
+ // "kind": "breakpoint", "layer": "primitive" }, ...] }
142
+ ```
143
+
144
+ ### `resolve_import`
145
+
146
+ Given a symbol name (flat or `Owner.Member`), returns the import specifier(s). Rejects
147
+ `Icons.<Name>` with a clear hint because icon names are string keys.
148
+
149
+ - Input: `{ symbol: string }`
150
+ - Output: `{ found: true, name, sources: [{ specifier, style, preferred }], css, notes? }`
151
+ or `{ found: false, inputSymbol, hint }`
152
+
153
+ ```jsonc
154
+ // input: { "symbol": "ProForm.Item" }
155
+ // output: { "found": true, "name": "ProFormItem",
156
+ // "sources": [
157
+ // { "specifier": "@1money/component-ui", "style": "named", "preferred": true },
158
+ // { "specifier": "@1money/component-ui/ProForm", "style": "named", "preferred": false }
159
+ // ],
160
+ // "css": "@1money/component-ui/index.css",
161
+ // "notes": "Also accessible via ProForm.Item namespace." }
162
+ ```
163
+
164
+ ### `get_library_info`
165
+
166
+ Package metadata loaded at startup. Use this to verify schema compatibility and
167
+ discover available subpath imports.
168
+
169
+ - Input: `{}`
170
+ - Output: `{ name, version, peerDependencies, subpathExports, cssEntry, schemaVersion }`
171
+
172
+ ```jsonc
173
+ // output: { "name": "@1money/component-ui", "version": "0.0.21",
174
+ // "peerDependencies": { "react": ">=16.8.0", ... },
175
+ // "subpathExports": ["./Accordion", "./Alert", ...],
176
+ // "cssEntry": "@1money/component-ui/index.css",
177
+ // "schemaVersion": "1" }
178
+ ```
179
+
180
+ ## Contributing — adding synonyms
181
+
182
+ Synonyms power fuzzy matches in `search_symbols` (e.g., "modal" → `Dialog`). They also
183
+ feed the per-symbol `searchTags` array.
184
+
185
+ 1. Edit `scripts/mcp-server/indexer/synonyms.json`.
186
+ 2. Add or extend an entry. Format:
187
+ ```json
188
+ {
189
+ "alias phrase": ["TargetSymbol1", "TargetSymbol2"]
190
+ }
191
+ ```
192
+ Key: lowercase alias a developer might type (spaces OK). Value: exact symbol names
193
+ as exported from `src/index.ts` (case-sensitive).
194
+ 3. Run `pnpm build:mcp-index` to regenerate `index.generated.json` with the new tags.
195
+ 4. Commit both `synonyms.json` and the updated `index.generated.json` together. The CI
196
+ drift guard will fail if they disagree.
197
+
198
+ ## Contributing — adding or improving canonical snippets
199
+
200
+ Every symbol has a `canonicalUsage` string (≤ 240 chars). The generator
201
+ (`indexer/generate-canonical.mjs`) resolves each symbol's snippet in this order:
202
+
203
+ 1. `src/components/<Folder>/<SymbolName>.canonical.md` (specific)
204
+ 2. `src/components/<Folder>/canonical.md` (folder-shared)
205
+ 3. First fenced block in `src/components/<Folder>/README.md`
206
+ 4. Auto-skeleton built from required props (components/hooks/functions only)
207
+
208
+ `module` kind (`ProForm`, `Icons`, `Input`) **skips step 4**: manual canonical is
209
+ required. If missing, the generator prints a diagnostic and the module gets no
210
+ snippet.
211
+
212
+ To add or replace a canonical manually:
213
+
214
+ 1. Create `src/components/<Folder>/canonical.md` (or the `<Name>.canonical.md` variant
215
+ if you want to override just one symbol in a shared folder).
216
+ 2. Put exactly one fenced code block inside. The first fenced block wins; anything
217
+ after it is ignored.
218
+ 3. Keep the body ≤ 240 chars. Use realistic but minimal props. Don't wrap in extra
219
+ markdown commentary — this snippet is consumed raw by assistants.
220
+ 4. Run `pnpm build:mcp-index`. Read the diagnostics — the generator tells you when a
221
+ file is missing, malformed, or too long (it drops too-long blocks rather than
222
+ truncating).
223
+
224
+ Example `canonical.md`:
225
+
226
+ ````markdown
227
+ ```tsx
228
+ <ProForm onFinish={(values) => console.log(values)}>
229
+ <ProForm.Text name="email" label="Email" rules={[{ required: true }]} />
230
+ <ProForm.Submitter />
231
+ </ProForm>
232
+ ```
233
+ ````
234
+
235
+ ## Maintenance — how the index is built
236
+
237
+ - `pnpm build:mcp-index` runs `scripts/mcp-server/indexer/build-index.mjs`. It writes
238
+ three files next to the server: `index.generated.json`, `examples.generated.json`,
239
+ and `drift.json`.
240
+ - All three files are **committed to git**. Consumers install the published tarball
241
+ (the `files` list in `package.json` includes them), not the source — the generator
242
+ never runs on the consumer's machine.
243
+ - A `prebuild` hook (`pnpm prebuild` → `pnpm build:mcp-index`) regenerates them before
244
+ each library build, so the committed snapshot can't drift from source by accident.
245
+ - CI enforces this with `.github/workflows/cicd-mcp-index.yml`: it runs the generator
246
+ and fails the PR if the committed files don't match the re-generated output.
247
+ - `schemaVersion` is currently `"1"`. The server hard-exits at startup on mismatch, so
248
+ bumping the schema requires a coordinated change (generator, server, consumer
249
+ upgrade path) and should go through its own PR.
250
+
251
+ ## Troubleshooting
252
+
253
+ - **"Unknown tool"** in the consumer — upgrade `@1money/component-ui` in the consumer
254
+ repo; the tool was added in a newer version.
255
+ - **`schemaVersion mismatch`** on server startup — the committed `index.generated.json`
256
+ was produced by a different schema revision than the server expects. Run
257
+ `pnpm build:mcp-index` and commit the result, or re-install `@1money/component-ui`
258
+ so the two files come from the same tarball.
259
+ - **`pnpm mcp:check` fails** — the server loaded the index but a handler threw. The
260
+ JSON output lists each tool's `ok` status and error message; usually this means the
261
+ index is stale (`pnpm build:mcp-index`) or a generator change broke a shape
262
+ assumption (check recent edits under `indexer/`).
263
+ - **`get_examples` returns `{ examples: [] }`** even though you know the component has
264
+ stories — the story file's `render` body may not parse as a standalone expression,
265
+ or the symbol name in the story is dotted/namespaced. Check the diagnostics from
266
+ `pnpm build:mcp-index` and, if needed, add a manual `canonical.md` so at least the
267
+ canonical source returns a snippet.
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import './index.mjs';
@@ -0,0 +1,5 @@
1
+ {
2
+ "orphanSubpath": [],
3
+ "orphanSymbol": [],
4
+ "suggestedFixes": []
5
+ }