@noemuch/bridge-ds 2.2.0 → 2.5.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.
- package/.claude-plugin/plugin.json +31 -0
- package/.cursor-plugin/plugin.json +26 -0
- package/.mcp.json +12 -0
- package/CHANGELOG.md +66 -0
- package/CLAUDE.md +84 -0
- package/README.md +7 -3
- package/lib/cli.js +107 -134
- package/lib/mcp-setup.js +32 -28
- package/lib/scaffold.js +6 -3
- package/package.json +10 -3
- package/skills/design-workflow/SKILL.md +70 -17
- package/skills/design-workflow/references/actions/design.md +108 -11
- package/skills/design-workflow/references/actions/done.md +21 -3
- package/skills/design-workflow/references/actions/learn.md +147 -0
- package/skills/design-workflow/references/actions/quick.md +78 -0
- package/skills/design-workflow/references/actions/review.md +14 -3
- package/skills/design-workflow/references/actions/spec.md +58 -0
- package/skills/design-workflow/references/actions/sync.md +176 -0
- package/skills/design-workflow/references/figma-api-rules.md +116 -0
- package/skills/design-workflow/references/knowledge-base/README.md +18 -1
- package/skills/design-workflow/references/knowledge-base/schemas/assets.md +6 -0
- package/skills/design-workflow/references/knowledge-base/schemas/components.md +6 -0
- package/skills/design-workflow/references/knowledge-base/schemas/learnings.md +250 -0
- package/skills/design-workflow/references/knowledge-base/schemas/text-styles.md +6 -0
- package/skills/design-workflow/references/knowledge-base/schemas/validation.md +6 -0
- package/skills/design-workflow/references/knowledge-base/schemas/variables.md +6 -0
- package/skills/design-workflow/references/onboarding.md +51 -9
- package/skills/design-workflow/references/quality-gates.md +51 -2
- package/skills/design-workflow/references/templates/screen-template.md +37 -3
- package/skills/design-workflow/references/templates/spec-template.md +12 -0
- package/skills/design-workflow/references/transport-adapter.md +210 -0
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
# Transport Adapter — Dual MCP Transport Support
|
|
2
|
+
|
|
3
|
+
> **Single source of truth for transport detection, tool mapping, and script adaptation.**
|
|
4
|
+
> All other reference files point here instead of duplicating transport logic.
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## A. Transport Detection
|
|
9
|
+
|
|
10
|
+
Before any Figma operation, determine which transport is active:
|
|
11
|
+
|
|
12
|
+
1. **Check for console transport:** Is `figma_execute` available?
|
|
13
|
+
2. **Check for official transport:** Is `use_figma` available?
|
|
14
|
+
|
|
15
|
+
| Result | Transport | Action |
|
|
16
|
+
|--------|-----------|--------|
|
|
17
|
+
| `figma_execute` available | **Console** (preferred) | Use console tool names throughout |
|
|
18
|
+
| `use_figma` available (no console) | **Official** | Use official tool names, apply adaptation rules below |
|
|
19
|
+
| Both available | **Console** (preferred) | Console is more capable, no response limits |
|
|
20
|
+
| Neither available | **Blocked** | Show setup instructions for both options (see below) |
|
|
21
|
+
|
|
22
|
+
**Block message when neither is available:**
|
|
23
|
+
```
|
|
24
|
+
No Figma MCP transport detected. Configure one of these:
|
|
25
|
+
|
|
26
|
+
Option A — figma-console-mcp (recommended, full Plugin API access):
|
|
27
|
+
claude mcp add figma-console -s user -e FIGMA_ACCESS_TOKEN=figd_YOUR_TOKEN -- npx -y figma-console-mcp@latest
|
|
28
|
+
|
|
29
|
+
Option B — Official Figma MCP (cloud-based, cross-library search):
|
|
30
|
+
Configure via Claude settings or Figma's MCP integration.
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## B. Tool Mapping Table
|
|
36
|
+
|
|
37
|
+
| Bridge Operation | Console (preferred) | Official Figma MCP | Notes |
|
|
38
|
+
|---|---|---|---|
|
|
39
|
+
| Execute Plugin API code | `figma_execute` | `use_figma` | Different wrapper format (see Section C) |
|
|
40
|
+
| Take screenshot | `figma_take_screenshot` | `get_screenshot` | Official requires `nodeId` + `fileKey` |
|
|
41
|
+
| Full DS extraction | `figma_get_design_system_kit` | Composite strategy (see Section D) | |
|
|
42
|
+
| Get variables | `figma_get_variables` | `get_variable_defs` | |
|
|
43
|
+
| Get styles | `figma_get_styles` | `search_design_system` (includeStyles) | |
|
|
44
|
+
| Connection check | `figma_get_status` | `whoami` + test `use_figma` call | See Section F |
|
|
45
|
+
| Search components | `figma_search_components` | `search_design_system` (includeComponents) | Official searches cross-library |
|
|
46
|
+
| Get component | `figma_get_component` | `get_design_context` or `get_metadata` | |
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## C. Script Adaptation Rules
|
|
51
|
+
|
|
52
|
+
### Console transport (figma_execute)
|
|
53
|
+
|
|
54
|
+
IIFE wrapper is **mandatory**. The `return` before the IIFE is required.
|
|
55
|
+
|
|
56
|
+
```javascript
|
|
57
|
+
// Console: figma_execute({ code: "..." })
|
|
58
|
+
return (async function() {
|
|
59
|
+
await figma.loadFontAsync({ family: "Inter", style: "Regular" });
|
|
60
|
+
// ... Plugin API code ...
|
|
61
|
+
return { success: true };
|
|
62
|
+
})();
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Official transport (use_figma)
|
|
66
|
+
|
|
67
|
+
Top-level `await` — **no IIFE wrapper**. Requires `fileKey` and `description` parameters.
|
|
68
|
+
|
|
69
|
+
```javascript
|
|
70
|
+
// Official: use_figma({ fileKey: "...", description: "...", code: "..." })
|
|
71
|
+
await figma.loadFontAsync({ family: "Inter", style: "Regular" });
|
|
72
|
+
// ... Plugin API code ...
|
|
73
|
+
return { success: true };
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Key differences
|
|
77
|
+
|
|
78
|
+
| Aspect | Console | Official |
|
|
79
|
+
|--------|---------|----------|
|
|
80
|
+
| Wrapper | `return (async function() { ... })();` | Top-level `await`, no IIFE |
|
|
81
|
+
| Parameters | `{ code }` | `{ fileKey, description, code }` |
|
|
82
|
+
| `figma.notify()` | Allowed | **Forbidden** (no UI access) |
|
|
83
|
+
| `getPluginData()` | Allowed | **Forbidden** (use `getSharedPluginData()`) |
|
|
84
|
+
| Response size | Unlimited | **20KB limit** — chunk large extractions |
|
|
85
|
+
| Document access | Current file via plugin | Specified file via `fileKey` |
|
|
86
|
+
|
|
87
|
+
### Transformation example
|
|
88
|
+
|
|
89
|
+
**Same script in both formats:**
|
|
90
|
+
|
|
91
|
+
Console:
|
|
92
|
+
```javascript
|
|
93
|
+
return (async function() {
|
|
94
|
+
await figma.loadFontAsync({ family: "Inter", style: "Regular" });
|
|
95
|
+
var frame = figma.createFrame();
|
|
96
|
+
frame.name = "Test";
|
|
97
|
+
frame.resize(400, 300);
|
|
98
|
+
figma.currentPage.appendChild(frame);
|
|
99
|
+
return { id: frame.id, name: frame.name };
|
|
100
|
+
})();
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Official:
|
|
104
|
+
```javascript
|
|
105
|
+
await figma.loadFontAsync({ family: "Inter", style: "Regular" });
|
|
106
|
+
var frame = figma.createFrame();
|
|
107
|
+
frame.name = "Test";
|
|
108
|
+
frame.resize(400, 300);
|
|
109
|
+
figma.currentPage.appendChild(frame);
|
|
110
|
+
return { id: frame.id, name: frame.name };
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Called as: `use_figma({ fileKey: "YOUR_FILE_KEY", description: "Create a test frame", code: "..." })`
|
|
114
|
+
|
|
115
|
+
---
|
|
116
|
+
|
|
117
|
+
## D. DS Extraction Composite Strategy
|
|
118
|
+
|
|
119
|
+
When `figma_get_design_system_kit` is unavailable (official transport), extract DS data using multiple tools:
|
|
120
|
+
|
|
121
|
+
### 1. Variables
|
|
122
|
+
|
|
123
|
+
```
|
|
124
|
+
get_variable_defs({ fileKey }) → collection/variable structure
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
If `get_variable_defs` does not return keys suitable for `importVariableByKeyAsync`, supplement with a `use_figma` extraction script (same script as in `schemas/variables.md`, without the IIFE wrapper).
|
|
128
|
+
|
|
129
|
+
### 2. Components
|
|
130
|
+
|
|
131
|
+
```
|
|
132
|
+
search_design_system({ query: "*", includeComponents: true }) → component list
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Run broad queries per category (e.g., "Button", "Input", "Card") to cover the DS. For detailed component properties, use `use_figma` with the extraction script from `schemas/components.md` (without IIFE wrapper).
|
|
136
|
+
|
|
137
|
+
### 3. Styles
|
|
138
|
+
|
|
139
|
+
```
|
|
140
|
+
search_design_system({ query: "*", includeStyles: true }) → text/color/effect styles
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
If keys are not returned, supplement with a `use_figma` extraction script (from `schemas/text-styles.md`, without IIFE wrapper).
|
|
144
|
+
|
|
145
|
+
### 4. Assembly
|
|
146
|
+
|
|
147
|
+
Assemble extracted data into the same registry JSON format defined in the schemas. The output registries must be identical regardless of which transport was used for extraction.
|
|
148
|
+
|
|
149
|
+
---
|
|
150
|
+
|
|
151
|
+
## E. Screenshot Adaptation
|
|
152
|
+
|
|
153
|
+
### Console
|
|
154
|
+
|
|
155
|
+
```
|
|
156
|
+
figma_take_screenshot({ node_id: "123:456" })
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
`node_id` is optional — omitting it captures the current viewport.
|
|
160
|
+
|
|
161
|
+
### Official
|
|
162
|
+
|
|
163
|
+
```
|
|
164
|
+
get_screenshot({ nodeId: "123:456", fileKey: "abc123" })
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
Both `nodeId` and `fileKey` are **required**. Track these values throughout the workflow:
|
|
168
|
+
- `fileKey`: obtained when the user provides the Figma file URL
|
|
169
|
+
- `nodeId`: returned by script execution (root frame ID from generation steps)
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
## F. Connection Check Adaptation
|
|
174
|
+
|
|
175
|
+
### Console
|
|
176
|
+
|
|
177
|
+
```
|
|
178
|
+
figma_get_status() → { setup: { valid: true }, ... }
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
Success: `setup.valid === true` means Figma Desktop is connected.
|
|
182
|
+
|
|
183
|
+
### Official
|
|
184
|
+
|
|
185
|
+
```
|
|
186
|
+
whoami() → { name: "...", email: "..." }
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
Success means the user is authenticated. Then test actual file access:
|
|
190
|
+
```
|
|
191
|
+
use_figma({ fileKey: "...", description: "Connection test", code: "return { page: figma.currentPage.name };" })
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
If both succeed, the official transport is operational.
|
|
195
|
+
|
|
196
|
+
---
|
|
197
|
+
|
|
198
|
+
## G. Official Transport Bonus Capabilities
|
|
199
|
+
|
|
200
|
+
These tools are only available on the official transport and provide additional functionality:
|
|
201
|
+
|
|
202
|
+
| Tool | Capability |
|
|
203
|
+
|------|------------|
|
|
204
|
+
| `search_design_system` | **Cross-library search** — finds components/styles across all team libraries, not just the current file |
|
|
205
|
+
| `get_code_connect_map` | Retrieve Code Connect mappings between Figma components and code |
|
|
206
|
+
| `add_code_connect_map` | Create Code Connect mappings |
|
|
207
|
+
| `create_design_system_rules` | Export design system rules |
|
|
208
|
+
| `generate_figma_design` | Capture a web page into Figma (web-to-Figma) |
|
|
209
|
+
| `get_design_context` | Rich component context with code hints |
|
|
210
|
+
| `get_metadata` | File-level metadata and structure |
|