@fragments-sdk/cli 0.5.2 → 0.7.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.
Files changed (124) hide show
  1. package/dist/bin.js +996 -79
  2. package/dist/bin.js.map +1 -1
  3. package/dist/{chunk-ICAIQ57V.js → chunk-6JBGU74P.js} +5 -3
  4. package/dist/chunk-6JBGU74P.js.map +1 -0
  5. package/dist/chunk-7OPWMLOE.js +1625 -0
  6. package/dist/chunk-7OPWMLOE.js.map +1 -0
  7. package/dist/{chunk-2H2JAA3U.js → chunk-CVXKXVOY.js} +3 -3
  8. package/dist/{chunk-2H2JAA3U.js.map → chunk-CVXKXVOY.js.map} +1 -1
  9. package/dist/{chunk-IOJE35DZ.js → chunk-NWQ4CJOQ.js} +3 -3
  10. package/dist/{chunk-2DJH4F4P.js → chunk-RVRTRESS.js} +3 -3
  11. package/dist/{chunk-V7YLRR4C.js → chunk-TJ34N7C7.js} +41 -4
  12. package/dist/{chunk-V7YLRR4C.js.map → chunk-TJ34N7C7.js.map} +1 -1
  13. package/dist/{chunk-XNWDI6UT.js → chunk-XHUDJNN3.js} +5 -5
  14. package/dist/{core-DKHB7FYV.js → core-W2HYIQW6.js} +4 -4
  15. package/dist/{generate-KL24VZVD.js → generate-LMTISDIJ.js} +5 -5
  16. package/dist/index.d.ts +1 -0
  17. package/dist/index.js +15 -7
  18. package/dist/index.js.map +1 -1
  19. package/dist/{init-NION5S3M.js → init-7CHRKQ7P.js} +5 -5
  20. package/dist/mcp-bin.js +8 -220
  21. package/dist/mcp-bin.js.map +1 -1
  22. package/dist/scan-WY23TJCP.js +12 -0
  23. package/dist/{service-RWUMZ3EW.js → service-T2L7VLTE.js} +5 -5
  24. package/dist/static-viewer-GBR7YNF3.js +12 -0
  25. package/dist/{test-ECPEXFDN.js → test-OJRXNDO2.js} +4 -4
  26. package/dist/{tokens-ITADYVPF.js → tokens-3BWDESVM.js} +6 -6
  27. package/dist/viewer-SUFOISZM.js +1822 -0
  28. package/dist/viewer-SUFOISZM.js.map +1 -0
  29. package/package.json +6 -5
  30. package/src/bin.ts +31 -0
  31. package/src/build.ts +147 -13
  32. package/src/cli-commands.ts +18 -0
  33. package/src/commands/__tests__/a11y-scoring.test.ts +278 -0
  34. package/src/commands/a11y-report.ts +625 -0
  35. package/src/commands/a11y.ts +168 -14
  36. package/src/commands/build.ts +16 -0
  37. package/src/commands/graph.ts +274 -0
  38. package/src/core/auto-props.ts +464 -0
  39. package/src/core/composition.ts +64 -1
  40. package/src/core/graph-extractor.test.ts +542 -0
  41. package/src/core/graph-extractor.ts +601 -0
  42. package/src/core/importAnalyzer.ts +5 -0
  43. package/src/core/schema.ts +2 -0
  44. package/src/core/types.ts +3 -1
  45. package/src/index.ts +4 -0
  46. package/src/mcp/server.ts +13 -220
  47. package/src/theme/__tests__/component-contrast.test.ts +338 -0
  48. package/src/theme/__tests__/contrast-validation.test.ts +326 -0
  49. package/src/theme/contrast.test.ts +331 -0
  50. package/src/theme/contrast.ts +246 -0
  51. package/src/theme/generator.ts +213 -1
  52. package/src/theme/index.ts +16 -0
  53. package/src/theme/types.ts +51 -0
  54. package/src/viewer/__tests__/a11y-fixes.test.ts +358 -0
  55. package/src/viewer/__tests__/viewer-integration.test.ts +2 -7
  56. package/src/viewer/components/AccessibilityPanel.tsx +493 -433
  57. package/src/viewer/components/ActionCapture.tsx +1 -1
  58. package/src/viewer/components/ActionsPanel.tsx +142 -183
  59. package/src/viewer/components/App.tsx +276 -183
  60. package/src/viewer/components/BottomPanel.tsx +40 -80
  61. package/src/viewer/components/CodePanel.tsx +9 -87
  62. package/src/viewer/components/CommandPalette.tsx +117 -74
  63. package/src/viewer/components/ComponentGraph.tsx +143 -126
  64. package/src/viewer/components/ComponentHeader.tsx +46 -43
  65. package/src/viewer/components/ContractPanel.tsx +124 -117
  66. package/src/viewer/components/ErrorBoundary.tsx +47 -35
  67. package/src/viewer/components/FigmaEmbed.tsx +18 -13
  68. package/src/viewer/components/FragmentEditor.tsx +126 -63
  69. package/src/viewer/components/HealthDashboard.tsx +146 -171
  70. package/src/viewer/components/HmrStatusIndicator.tsx +31 -41
  71. package/src/viewer/components/Icons.tsx +151 -98
  72. package/src/viewer/components/InteractionsPanel.tsx +317 -264
  73. package/src/viewer/components/IsolatedPreviewFrame.tsx +52 -27
  74. package/src/viewer/components/IsolatedRender.tsx +12 -6
  75. package/src/viewer/components/KeyboardShortcutsHelp.tsx +34 -70
  76. package/src/viewer/components/LandingPage.tsx +285 -305
  77. package/src/viewer/components/Layout.tsx +12 -10
  78. package/src/viewer/components/LeftSidebar.tsx +103 -155
  79. package/src/viewer/components/MultiViewportPreview.tsx +254 -63
  80. package/src/viewer/components/PreviewArea.tsx +113 -44
  81. package/src/viewer/components/PreviewFrameHost.tsx +36 -6
  82. package/src/viewer/components/PreviewPane.tsx +2 -3
  83. package/src/viewer/components/PreviewToolbar.tsx +109 -105
  84. package/src/viewer/components/PropsEditor.tsx +154 -74
  85. package/src/viewer/components/PropsTable.tsx +95 -82
  86. package/src/viewer/components/RelationsSection.tsx +71 -40
  87. package/src/viewer/components/ResizablePanel.tsx +158 -55
  88. package/src/viewer/components/RightSidebar.tsx +46 -56
  89. package/src/viewer/components/ScreenshotButton.tsx +12 -12
  90. package/src/viewer/components/SkeletonLoader.tsx +99 -83
  91. package/src/viewer/components/StoryRenderer.tsx +4 -11
  92. package/src/viewer/components/Toast.tsx +3 -67
  93. package/src/viewer/components/TokenStylePanel.tsx +136 -118
  94. package/src/viewer/components/UsageSection.tsx +26 -26
  95. package/src/viewer/components/VariantMatrix.tsx +140 -47
  96. package/src/viewer/components/VariantTabs.tsx +24 -68
  97. package/src/viewer/components/ViewportSelector.tsx +121 -114
  98. package/src/viewer/constants/ui.ts +23 -22
  99. package/src/viewer/entry.tsx +8 -3
  100. package/src/viewer/index.ts +3 -6
  101. package/src/viewer/preview-frame.html +43 -18
  102. package/src/viewer/server.ts +7 -16
  103. package/src/viewer/styles/globals.css +46 -85
  104. package/src/viewer/utils/a11y-fixes.ts +53 -30
  105. package/dist/chunk-ICAIQ57V.js.map +0 -1
  106. package/dist/chunk-U4GQ2JTD.js +0 -832
  107. package/dist/chunk-U4GQ2JTD.js.map +0 -1
  108. package/dist/scan-ESEXV7LF.js +0 -12
  109. package/dist/static-viewer-O37MJ5B6.js +0 -12
  110. package/dist/viewer-YDGFDTK5.js +0 -11104
  111. package/dist/viewer-YDGFDTK5.js.map +0 -1
  112. package/src/viewer/postcss.config.js +0 -6
  113. package/src/viewer/tailwind.config.js +0 -37
  114. /package/dist/{chunk-IOJE35DZ.js.map → chunk-NWQ4CJOQ.js.map} +0 -0
  115. /package/dist/{chunk-2DJH4F4P.js.map → chunk-RVRTRESS.js.map} +0 -0
  116. /package/dist/{chunk-XNWDI6UT.js.map → chunk-XHUDJNN3.js.map} +0 -0
  117. /package/dist/{core-DKHB7FYV.js.map → core-W2HYIQW6.js.map} +0 -0
  118. /package/dist/{generate-KL24VZVD.js.map → generate-LMTISDIJ.js.map} +0 -0
  119. /package/dist/{init-NION5S3M.js.map → init-7CHRKQ7P.js.map} +0 -0
  120. /package/dist/{scan-ESEXV7LF.js.map → scan-WY23TJCP.js.map} +0 -0
  121. /package/dist/{service-RWUMZ3EW.js.map → service-T2L7VLTE.js.map} +0 -0
  122. /package/dist/{static-viewer-O37MJ5B6.js.map → static-viewer-GBR7YNF3.js.map} +0 -0
  123. /package/dist/{test-ECPEXFDN.js.map → test-OJRXNDO2.js.map} +0 -0
  124. /package/dist/{tokens-ITADYVPF.js.map → tokens-3BWDESVM.js.map} +0 -0
package/dist/mcp-bin.js CHANGED
@@ -1,12 +1,12 @@
1
1
  #!/usr/bin/env node
2
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import { createRequire as __banner_createRequire } from 'module'; const require = __banner_createRequire(import.meta.url);
3
3
  import {
4
4
  generateContext
5
- } from "./chunk-V7YLRR4C.js";
5
+ } from "./chunk-TJ34N7C7.js";
6
6
  import {
7
7
  BRAND,
8
8
  DEFAULTS
9
- } from "./chunk-ICAIQ57V.js";
9
+ } from "./chunk-6JBGU74P.js";
10
10
 
11
11
  // src/mcp/server.ts
12
12
  import { Server } from "@modelcontextprotocol/sdk/server/index.js";
@@ -15,6 +15,7 @@ import {
15
15
  CallToolRequestSchema,
16
16
  ListToolsRequestSchema
17
17
  } from "@modelcontextprotocol/sdk/types.js";
18
+ import { buildMcpTools, buildToolNames, CLI_TOOL_EXTENSIONS } from "@fragments-sdk/context/mcp-tools";
18
19
  import { readFile } from "fs/promises";
19
20
  import { existsSync, readFileSync, readdirSync } from "fs";
20
21
  import { join, dirname, resolve } from "path";
@@ -57,7 +58,7 @@ var _service = null;
57
58
  async function getService() {
58
59
  if (!_service) {
59
60
  try {
60
- _service = await import("./service-RWUMZ3EW.js");
61
+ _service = await import("./service-T2L7VLTE.js");
61
62
  } catch {
62
63
  throw new Error(
63
64
  "Visual tools require playwright. Install it with: npm install playwright"
@@ -66,15 +67,7 @@ async function getService() {
66
67
  }
67
68
  return _service;
68
69
  }
69
- var TOOL_NAMES = {
70
- discover: `${BRAND.nameLower}_discover`,
71
- inspect: `${BRAND.nameLower}_inspect`,
72
- blocks: `${BRAND.nameLower}_blocks`,
73
- tokens: `${BRAND.nameLower}_tokens`,
74
- implement: `${BRAND.nameLower}_implement`,
75
- render: `${BRAND.nameLower}_render`,
76
- fix: `${BRAND.nameLower}_fix`
77
- };
70
+ var TOOL_NAMES = buildToolNames(BRAND.nameLower);
78
71
  var PLACEHOLDER_PATTERNS = [
79
72
  /^\w+ component is needed$/i,
80
73
  /^Alternative component is more appropriate$/i,
@@ -224,212 +217,7 @@ function findFragmentsJson(startDir) {
224
217
  }
225
218
  return found;
226
219
  }
227
- var TOOLS = [
228
- {
229
- name: TOOL_NAMES.discover,
230
- description: `Discover components in the design system. Use with no params to list all components. Use 'useCase' for AI-powered suggestions. Use 'component' to find alternatives. Use 'compact' for a token-efficient overview.`,
231
- inputSchema: {
232
- type: "object",
233
- properties: {
234
- useCase: {
235
- type: "string",
236
- description: 'Description of what you want to build \u2014 returns ranked suggestions (e.g., "form for user email input", "button to submit data")'
237
- },
238
- component: {
239
- type: "string",
240
- description: 'Component name to find alternatives for (e.g., "Button")'
241
- },
242
- category: {
243
- type: "string",
244
- description: 'Filter by category (e.g., "actions", "forms", "layout")'
245
- },
246
- search: {
247
- type: "string",
248
- description: "Search term to filter by name, description, or tags"
249
- },
250
- status: {
251
- type: "string",
252
- enum: ["stable", "beta", "deprecated", "experimental"],
253
- description: "Filter by component status"
254
- },
255
- format: {
256
- type: "string",
257
- enum: ["markdown", "json"],
258
- description: "Output format for context mode (default: markdown)"
259
- },
260
- compact: {
261
- type: "boolean",
262
- description: "If true, returns minimal output (just component names and categories)"
263
- },
264
- includeCode: {
265
- type: "boolean",
266
- description: "If true, includes code examples for each variant"
267
- },
268
- includeRelations: {
269
- type: "boolean",
270
- description: "If true, includes component relationships"
271
- }
272
- }
273
- }
274
- },
275
- {
276
- name: TOOL_NAMES.inspect,
277
- description: `Get detailed information about a specific component: props, usage guidelines, code examples, accessibility \u2014 all in one call. Use 'fields' to request only specific data for token efficiency.`,
278
- inputSchema: {
279
- type: "object",
280
- properties: {
281
- component: {
282
- type: "string",
283
- description: 'Component name (e.g., "Button", "Input")'
284
- },
285
- fields: {
286
- type: "array",
287
- items: { type: "string" },
288
- description: 'Specific fields to return (e.g., ["meta", "usage.when", "contract.propsSummary", "props", "examples", "guidelines"]). If omitted, returns everything. Supports dot notation.'
289
- },
290
- variant: {
291
- type: "string",
292
- description: 'Filter examples to a specific variant name (e.g., "Default", "Primary")'
293
- },
294
- maxExamples: {
295
- type: "number",
296
- description: "Maximum number of code examples to return (default: all)"
297
- },
298
- maxLines: {
299
- type: "number",
300
- description: "Maximum lines per code example (truncates longer examples)"
301
- }
302
- },
303
- required: ["component"]
304
- }
305
- },
306
- {
307
- name: TOOL_NAMES.blocks,
308
- description: `Search and retrieve composition blocks \u2014 named patterns showing how design system components wire together for common use cases (e.g., "Login Form", "Settings Page"). Returns the block with its code pattern.`,
309
- inputSchema: {
310
- type: "object",
311
- properties: {
312
- name: {
313
- type: "string",
314
- description: 'Exact block name to retrieve (e.g., "Login Form")'
315
- },
316
- search: {
317
- type: "string",
318
- description: "Free-text search across block names, descriptions, tags, and components"
319
- },
320
- component: {
321
- type: "string",
322
- description: 'Filter blocks that use a specific component (e.g., "Button")'
323
- },
324
- category: {
325
- type: "string",
326
- description: 'Filter by category (e.g., "authentication", "marketing", "dashboard", "settings", "ecommerce", "ai")'
327
- }
328
- }
329
- }
330
- },
331
- {
332
- name: TOOL_NAMES.tokens,
333
- description: `List available CSS design tokens (custom properties) by category. Use this when you need to style custom elements or override defaults \u2014 no more guessing variable names. Filter by category or search by keyword.`,
334
- inputSchema: {
335
- type: "object",
336
- properties: {
337
- category: {
338
- type: "string",
339
- description: 'Filter by category (e.g., "colors", "spacing", "typography", "surfaces", "shadows", "radius", "borders", "text", "focus", "layout", "code", "component-sizing")'
340
- },
341
- search: {
342
- type: "string",
343
- description: 'Search token names (e.g., "accent", "hover", "padding")'
344
- }
345
- }
346
- }
347
- },
348
- {
349
- name: TOOL_NAMES.implement,
350
- description: `One-shot implementation helper. Describe what you want to build and get everything needed in a single call: best-matching component(s) with full props and code examples, relevant composition blocks, and applicable CSS tokens. Saves multiple round-trips.`,
351
- inputSchema: {
352
- type: "object",
353
- properties: {
354
- useCase: {
355
- type: "string",
356
- description: 'What you want to implement (e.g., "login form", "data table with sorting", "streaming chat messages")'
357
- }
358
- },
359
- required: ["useCase"]
360
- }
361
- },
362
- {
363
- name: TOOL_NAMES.render,
364
- description: `Render a component and return a screenshot. Optionally compare against a stored baseline ('baseline: true') or against a Figma design ('figmaUrl'). Use this to verify your implementation looks correct.`,
365
- inputSchema: {
366
- type: "object",
367
- properties: {
368
- component: {
369
- type: "string",
370
- description: 'Component name (e.g., "Button", "Card", "Input")'
371
- },
372
- variant: {
373
- type: "string",
374
- description: "Variant name for baseline/compare modes"
375
- },
376
- props: {
377
- type: "object",
378
- description: 'Props to pass to the component (e.g., { "variant": "primary", "children": "Click me" })'
379
- },
380
- viewport: {
381
- type: "object",
382
- properties: {
383
- width: { type: "number", description: "Viewport width (default: 800)" },
384
- height: { type: "number", description: "Viewport height (default: 600)" }
385
- },
386
- description: "Optional viewport size for the render"
387
- },
388
- baseline: {
389
- type: "boolean",
390
- description: "If true, compares the render against the stored baseline screenshot (requires variant)"
391
- },
392
- figmaUrl: {
393
- type: "string",
394
- description: "Figma frame URL \u2014 if provided, compares the render against the Figma design"
395
- },
396
- theme: {
397
- type: "string",
398
- enum: ["light", "dark"],
399
- description: "Theme for baseline verification (default: light)"
400
- },
401
- threshold: {
402
- type: "number",
403
- description: "Diff threshold percentage (default: 5 for baseline, 1 for Figma)"
404
- }
405
- },
406
- required: ["component"]
407
- }
408
- },
409
- {
410
- name: TOOL_NAMES.fix,
411
- description: `Generate patches to fix token compliance issues in a component. Returns unified diff patches that replace hardcoded CSS values with design token references. Use this after fragments_render identifies issues to automatically fix them.`,
412
- inputSchema: {
413
- type: "object",
414
- properties: {
415
- component: {
416
- type: "string",
417
- description: 'Component name to generate fixes for (e.g., "Button", "Card")'
418
- },
419
- variant: {
420
- type: "string",
421
- description: "Specific variant to fix (optional, fixes all variants if omitted)"
422
- },
423
- fixType: {
424
- type: "string",
425
- enum: ["token", "all"],
426
- description: 'Type of fixes to generate: "token" for hardcoded\u2192token replacements, "all" for all available fixes (default: "all")'
427
- }
428
- },
429
- required: ["component"]
430
- }
431
- }
432
- ];
220
+ var TOOLS = buildMcpTools(BRAND.nameLower, CLI_TOOL_EXTENSIONS);
433
221
  function createMcpServer(config) {
434
222
  const server = new Server(
435
223
  {
@@ -1009,7 +797,7 @@ function createMcpServer(config) {
1009
797
  }]
1010
798
  };
1011
799
  }
1012
- let filteredCategories = {};
800
+ const filteredCategories = {};
1013
801
  let filteredTotal = 0;
1014
802
  for (const [cat, tokens] of Object.entries(tokenData.categories)) {
1015
803
  if (category && cat !== category) continue;