@muloka/figma-console-mcp 0.5.0 → 0.5.2

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 (111) hide show
  1. package/README.md +3 -1
  2. package/dist/core/port-discovery.d.ts +9 -0
  3. package/dist/core/port-discovery.d.ts.map +1 -1
  4. package/dist/core/port-discovery.js +40 -14
  5. package/dist/core/port-discovery.js.map +1 -1
  6. package/dist/core/websocket-connector.d.ts +2 -1
  7. package/dist/core/websocket-connector.d.ts.map +1 -1
  8. package/dist/core/websocket-connector.js +17 -2
  9. package/dist/core/websocket-connector.js.map +1 -1
  10. package/dist/core/websocket-server.d.ts +8 -1
  11. package/dist/core/websocket-server.d.ts.map +1 -1
  12. package/dist/core/websocket-server.js +18 -2
  13. package/dist/core/websocket-server.js.map +1 -1
  14. package/dist/core/write-tools.d.ts +3 -1
  15. package/dist/core/write-tools.d.ts.map +1 -1
  16. package/dist/core/write-tools.js +34 -14
  17. package/dist/core/write-tools.js.map +1 -1
  18. package/dist/local.d.ts +2 -1
  19. package/dist/local.d.ts.map +1 -1
  20. package/dist/local.js +10 -14
  21. package/dist/local.js.map +1 -1
  22. package/package.json +1 -1
  23. package/dist/apps/design-system-dashboard/mcp-app.html +0 -521
  24. package/dist/apps/token-browser/mcp-app.html +0 -410
  25. package/dist/cloudflare/apps/design-system-dashboard/scoring/accessibility.js +0 -277
  26. package/dist/cloudflare/apps/design-system-dashboard/scoring/component-metadata.js +0 -357
  27. package/dist/cloudflare/apps/design-system-dashboard/scoring/consistency.js +0 -341
  28. package/dist/cloudflare/apps/design-system-dashboard/scoring/coverage.js +0 -230
  29. package/dist/cloudflare/apps/design-system-dashboard/scoring/engine.js +0 -92
  30. package/dist/cloudflare/apps/design-system-dashboard/scoring/naming-semantics.js +0 -308
  31. package/dist/cloudflare/apps/design-system-dashboard/scoring/token-architecture.js +0 -349
  32. package/dist/cloudflare/apps/design-system-dashboard/scoring/types.js +0 -40
  33. package/dist/cloudflare/apps/design-system-dashboard/server.js +0 -159
  34. package/dist/cloudflare/apps/token-browser/server.js +0 -136
  35. package/dist/cloudflare/browser-manager.js +0 -157
  36. package/dist/cloudflare/core/accessibility-tools.js +0 -361
  37. package/dist/cloudflare/core/annotation-tools.js +0 -230
  38. package/dist/cloudflare/core/cloud-websocket-connector.js +0 -419
  39. package/dist/cloudflare/core/cloud-websocket-relay.js +0 -198
  40. package/dist/cloudflare/core/comment-tools.js +0 -292
  41. package/dist/cloudflare/core/config.js +0 -153
  42. package/dist/cloudflare/core/console-monitor.js +0 -427
  43. package/dist/cloudflare/core/deep-component-tools.js +0 -128
  44. package/dist/cloudflare/core/design-code-tools.js +0 -2793
  45. package/dist/cloudflare/core/design-system-manifest.js +0 -265
  46. package/dist/cloudflare/core/design-system-tools.js +0 -882
  47. package/dist/cloudflare/core/diagnose-tool.js +0 -100
  48. package/dist/cloudflare/core/diff/changelog-formatter.js +0 -275
  49. package/dist/cloudflare/core/diff/diff-engine.js +0 -334
  50. package/dist/cloudflare/core/diff/property-compare.js +0 -36
  51. package/dist/cloudflare/core/diff/version-cache.js +0 -74
  52. package/dist/cloudflare/core/enrichment/enrichment-service.js +0 -374
  53. package/dist/cloudflare/core/enrichment/index.js +0 -7
  54. package/dist/cloudflare/core/enrichment/relationship-mapper.js +0 -351
  55. package/dist/cloudflare/core/enrichment/style-resolver.js +0 -346
  56. package/dist/cloudflare/core/figjam-tools.js +0 -547
  57. package/dist/cloudflare/core/figma-api.js +0 -509
  58. package/dist/cloudflare/core/figma-connector.js +0 -7
  59. package/dist/cloudflare/core/figma-reconstruction-spec.js +0 -402
  60. package/dist/cloudflare/core/figma-style-extractor.js +0 -311
  61. package/dist/cloudflare/core/figma-tools.js +0 -3353
  62. package/dist/cloudflare/core/identity.js +0 -96
  63. package/dist/cloudflare/core/library-tools.js +0 -580
  64. package/dist/cloudflare/core/logger.js +0 -53
  65. package/dist/cloudflare/core/port-discovery.js +0 -935
  66. package/dist/cloudflare/core/resolve-package-root.js +0 -11
  67. package/dist/cloudflare/core/slides-tools.js +0 -714
  68. package/dist/cloudflare/core/slot-tools.js +0 -334
  69. package/dist/cloudflare/core/snippet-injector.js +0 -96
  70. package/dist/cloudflare/core/tokens/alias-resolver.js +0 -205
  71. package/dist/cloudflare/core/tokens/config.js +0 -294
  72. package/dist/cloudflare/core/tokens/dialect.js +0 -232
  73. package/dist/cloudflare/core/tokens/figma-converter.js +0 -323
  74. package/dist/cloudflare/core/tokens/formatters/css-vars.js +0 -338
  75. package/dist/cloudflare/core/tokens/formatters/dtcg.js +0 -376
  76. package/dist/cloudflare/core/tokens/formatters/index.js +0 -45
  77. package/dist/cloudflare/core/tokens/formatters/json.js +0 -205
  78. package/dist/cloudflare/core/tokens/formatters/less.js +0 -4
  79. package/dist/cloudflare/core/tokens/formatters/scss.js +0 -258
  80. package/dist/cloudflare/core/tokens/formatters/stubs.js +0 -13
  81. package/dist/cloudflare/core/tokens/formatters/style-dictionary-v3.js +0 -213
  82. package/dist/cloudflare/core/tokens/formatters/tailwind-v3.js +0 -237
  83. package/dist/cloudflare/core/tokens/formatters/tailwind-v4.js +0 -335
  84. package/dist/cloudflare/core/tokens/formatters/tokens-studio.js +0 -256
  85. package/dist/cloudflare/core/tokens/formatters/ts-module.js +0 -198
  86. package/dist/cloudflare/core/tokens/index.js +0 -16
  87. package/dist/cloudflare/core/tokens/parsers/css-vars.js +0 -4
  88. package/dist/cloudflare/core/tokens/parsers/dtcg.js +0 -280
  89. package/dist/cloudflare/core/tokens/parsers/index.js +0 -138
  90. package/dist/cloudflare/core/tokens/parsers/json.js +0 -7
  91. package/dist/cloudflare/core/tokens/parsers/scss.js +0 -4
  92. package/dist/cloudflare/core/tokens/parsers/stubs.js +0 -20
  93. package/dist/cloudflare/core/tokens/parsers/style-dictionary-v3.js +0 -4
  94. package/dist/cloudflare/core/tokens/parsers/tailwind-v3.js +0 -4
  95. package/dist/cloudflare/core/tokens/parsers/tailwind-v4.js +0 -4
  96. package/dist/cloudflare/core/tokens/parsers/tokens-studio.js +0 -4
  97. package/dist/cloudflare/core/tokens/schemas.js +0 -152
  98. package/dist/cloudflare/core/tokens/transforms/color.js +0 -12
  99. package/dist/cloudflare/core/tokens/transforms/index.js +0 -29
  100. package/dist/cloudflare/core/tokens/transforms/size.js +0 -7
  101. package/dist/cloudflare/core/tokens/types.js +0 -18
  102. package/dist/cloudflare/core/tokens-tools.js +0 -1788
  103. package/dist/cloudflare/core/types/design-code.js +0 -4
  104. package/dist/cloudflare/core/types/enriched.js +0 -5
  105. package/dist/cloudflare/core/types/index.js +0 -4
  106. package/dist/cloudflare/core/variable-resolver.js +0 -85
  107. package/dist/cloudflare/core/version-tools.js +0 -1199
  108. package/dist/cloudflare/core/websocket-connector.js +0 -436
  109. package/dist/cloudflare/core/websocket-server.js +0 -1009
  110. package/dist/cloudflare/core/write-tools.js +0 -2506
  111. package/dist/cloudflare/index.js +0 -3010
@@ -1,265 +0,0 @@
1
- /**
2
- * Design System Manifest Types
3
- *
4
- * A structured representation of a Figma design system that enables
5
- * high-fidelity AI-assisted design generation.
6
- */
7
- /**
8
- * Cache for design system manifests with TTL-based invalidation.
9
- * Singleton pattern to share cache across tool calls.
10
- */
11
- export class DesignSystemManifestCache {
12
- constructor() {
13
- this.cache = new Map();
14
- this.TTL_MS = 5 * 60 * 1000; // 5 minutes
15
- }
16
- static getInstance() {
17
- if (!DesignSystemManifestCache.instance) {
18
- DesignSystemManifestCache.instance = new DesignSystemManifestCache();
19
- }
20
- return DesignSystemManifestCache.instance;
21
- }
22
- get(fileKey) {
23
- const entry = this.cache.get(fileKey);
24
- if (!entry)
25
- return null;
26
- if (!this.isValid(entry)) {
27
- this.cache.delete(fileKey);
28
- return null;
29
- }
30
- return entry;
31
- }
32
- set(fileKey, manifest, rawComponents) {
33
- this.cache.set(fileKey, {
34
- manifest,
35
- timestamp: Date.now(),
36
- fileKey,
37
- rawComponents,
38
- });
39
- }
40
- invalidate(fileKey) {
41
- this.cache.delete(fileKey);
42
- }
43
- invalidateAll() {
44
- this.cache.clear();
45
- }
46
- isValid(entry) {
47
- return Date.now() - entry.timestamp < this.TTL_MS;
48
- }
49
- getStats() {
50
- const stats = [];
51
- for (const [fileKey, entry] of this.cache) {
52
- stats.push({
53
- fileKey,
54
- age: Math.round((Date.now() - entry.timestamp) / 1000),
55
- componentCount: entry.manifest.summary.totalComponents + entry.manifest.summary.totalComponentSets,
56
- tokenCount: entry.manifest.summary.totalTokens,
57
- });
58
- }
59
- return stats;
60
- }
61
- }
62
- /**
63
- * Search components by name, category, or description
64
- */
65
- export function searchComponents(manifest, query, options) {
66
- const limit = options?.limit ?? 10;
67
- const offset = options?.offset ?? 0;
68
- const queryLower = query.toLowerCase();
69
- const categoryLower = options?.category?.toLowerCase();
70
- const allResults = [];
71
- // Search component sets first (they're typically the main design system components).
72
- // Manifest maps are keyed by component key — always read names from the entry.
73
- for (const compSet of Object.values(manifest.componentSets)) {
74
- const nameLower = compSet.name.toLowerCase();
75
- const descLower = compSet.description?.toLowerCase() || '';
76
- const matchesQuery = !query || nameLower.includes(queryLower) || descLower.includes(queryLower);
77
- const matchesCategory = !categoryLower || inferCategory(compSet.name).toLowerCase().includes(categoryLower);
78
- if (matchesQuery && matchesCategory) {
79
- allResults.push({
80
- name: compSet.name,
81
- key: compSet.key,
82
- nodeId: compSet.nodeId,
83
- type: 'componentSet',
84
- description: compSet.description,
85
- category: inferCategory(compSet.name),
86
- variantCount: compSet.variants?.length || 0,
87
- });
88
- }
89
- }
90
- // Then search standalone components
91
- for (const comp of Object.values(manifest.components)) {
92
- const nameLower = comp.name.toLowerCase();
93
- const descLower = comp.description?.toLowerCase() || '';
94
- const matchesQuery = !query || nameLower.includes(queryLower) || descLower.includes(queryLower);
95
- const matchesCategory = !categoryLower || inferCategory(comp.name).toLowerCase().includes(categoryLower);
96
- if (matchesQuery && matchesCategory) {
97
- allResults.push({
98
- name: comp.name,
99
- key: comp.key,
100
- nodeId: comp.nodeId,
101
- type: 'component',
102
- description: comp.description,
103
- category: inferCategory(comp.name),
104
- defaultSize: comp.defaultSize,
105
- });
106
- }
107
- }
108
- const total = allResults.length;
109
- // Truncate long doc blocks in search hits — full text is available via
110
- // figma_get_component_details.
111
- const paginatedResults = allResults.slice(offset, offset + limit).map((r) => r.description && r.description.length > 200
112
- ? { ...r, description: `${r.description.slice(0, 200)}…`, descriptionTruncated: true }
113
- : r);
114
- const hasMore = offset + limit < total;
115
- return { results: paginatedResults, total, hasMore };
116
- }
117
- /**
118
- * Infer category from component name (e.g., "Button/Primary" -> "Button")
119
- */
120
- function inferCategory(name) {
121
- const parts = name.split('/');
122
- return parts[0] || 'Uncategorized';
123
- }
124
- /**
125
- * Get unique categories from manifest
126
- */
127
- export function getCategories(manifest) {
128
- const categories = new Map();
129
- for (const compSet of Object.values(manifest.componentSets)) {
130
- const cat = inferCategory(compSet.name);
131
- const existing = categories.get(cat) || { componentCount: 0, componentSetCount: 0 };
132
- existing.componentSetCount++;
133
- categories.set(cat, existing);
134
- }
135
- for (const comp of Object.values(manifest.components)) {
136
- const cat = inferCategory(comp.name);
137
- const existing = categories.get(cat) || { componentCount: 0, componentSetCount: 0 };
138
- existing.componentCount++;
139
- categories.set(cat, existing);
140
- }
141
- return Array.from(categories.entries())
142
- .map(([name, counts]) => ({ name, ...counts }))
143
- .sort((a, b) => (b.componentCount + b.componentSetCount) - (a.componentCount + a.componentSetCount));
144
- }
145
- /**
146
- * Get token categories and counts for summary
147
- */
148
- export function getTokenSummary(manifest) {
149
- // Group colors by prefix (e.g., "primary/500" -> "primary")
150
- const colorGroups = new Set();
151
- for (const name of Object.keys(manifest.tokens.colors)) {
152
- const group = name.split('/')[0];
153
- colorGroups.add(group);
154
- }
155
- // Group typography by prefix
156
- const typographyGroups = new Set();
157
- for (const name of Object.keys(manifest.tokens.typography)) {
158
- const group = name.split('/')[0];
159
- typographyGroups.add(group);
160
- }
161
- // Get spacing scale values
162
- const spacingValues = Object.values(manifest.tokens.spacing)
163
- .map(t => t.value)
164
- .filter((v, i, arr) => arr.indexOf(v) === i)
165
- .sort((a, b) => a - b);
166
- return {
167
- colors: {
168
- count: Object.keys(manifest.tokens.colors).length,
169
- groups: Array.from(colorGroups).slice(0, 10),
170
- },
171
- spacing: {
172
- count: Object.keys(manifest.tokens.spacing).length,
173
- scale: spacingValues.slice(0, 15),
174
- },
175
- typography: {
176
- count: Object.keys(manifest.tokens.typography).length,
177
- groups: Array.from(typographyGroups).slice(0, 10),
178
- },
179
- effects: {
180
- count: Object.keys(manifest.tokens.effects).length,
181
- },
182
- collections: manifest.collections.map(c => c.name),
183
- };
184
- }
185
- // ============================================================================
186
- // HELPER FUNCTIONS
187
- // ============================================================================
188
- /**
189
- * Convert RGB color object to hex string
190
- */
191
- export function rgbToHex(color) {
192
- const toHex = (n) => Math.round(n * 255).toString(16).padStart(2, '0');
193
- return `#${toHex(color.r)}${toHex(color.g)}${toHex(color.b)}`.toUpperCase();
194
- }
195
- /**
196
- * Parse a Figma color value to hex
197
- */
198
- export function figmaColorToHex(value) {
199
- if (typeof value === 'string')
200
- return value;
201
- if (value && typeof value === 'object' && 'r' in value) {
202
- return rgbToHex(value);
203
- }
204
- return '#000000';
205
- }
206
- /**
207
- * Generate a human-readable summary of the manifest
208
- */
209
- export function generateManifestSummary(manifest) {
210
- const lines = [
211
- `# Design System Manifest`,
212
- ``,
213
- `**File:** ${manifest.fileName || manifest.fileKey}`,
214
- `**Generated:** ${new Date(manifest.generatedAt).toISOString()}`,
215
- ``,
216
- `## Summary`,
217
- `- **${manifest.summary.totalTokens}** design tokens`,
218
- `- **${manifest.summary.totalComponents}** components`,
219
- `- **${manifest.summary.totalComponentSets}** component sets`,
220
- ``,
221
- `## Color Palette`,
222
- manifest.summary.colorPalette.slice(0, 10).map(c => `- ${c}`).join('\n'),
223
- ``,
224
- `## Spacing Scale`,
225
- `${manifest.summary.spacingScale.join('px, ')}px`,
226
- ``,
227
- `## Typography`,
228
- manifest.summary.typographyScale.slice(0, 10).map(t => `- ${t}`).join('\n'),
229
- ``,
230
- `## Component Categories`,
231
- manifest.summary.componentCategories.map(c => `- ${c}`).join('\n'),
232
- ];
233
- return lines.join('\n');
234
- }
235
- /**
236
- * Create an empty manifest template
237
- */
238
- export function createEmptyManifest(fileKey) {
239
- return {
240
- version: '1.0.0',
241
- generatedAt: Date.now(),
242
- fileKey,
243
- collections: [],
244
- tokens: {
245
- colors: {},
246
- spacing: {},
247
- typography: {},
248
- effects: {},
249
- other: {},
250
- },
251
- components: {},
252
- componentSets: {},
253
- patterns: {},
254
- rules: [],
255
- summary: {
256
- totalTokens: 0,
257
- totalComponents: 0,
258
- totalComponentSets: 0,
259
- colorPalette: [],
260
- spacingScale: [],
261
- typographyScale: [],
262
- componentCategories: [],
263
- },
264
- };
265
- }