@dannote/figma-use 0.1.4 → 0.2.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/CHANGELOG.md ADDED
@@ -0,0 +1,123 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ## [0.2.0] - 2025-01-17
11
+
12
+ ### Added
13
+
14
+ - **Subcommand structure** — commands reorganized into logical groups:
15
+ - `node get|tree|children|move|resize|rename|clone|delete`
16
+ - `create rect|ellipse|line|polygon|star|frame|text|component|instance|section|page`
17
+ - `set fill|stroke|radius|opacity|rotation|visible|text|font|effect|layout|blend|constraints|image`
18
+ - `get pages|components|styles`
19
+ - `export node|selection|screenshot`
20
+ - `selection get|set`
21
+ - `page list|set`
22
+ - `viewport get|set|zoom-to-fit`
23
+ - `variable list|get|create|set|delete|bind`
24
+ - `collection list|get|create|delete`
25
+ - `style list|create-paint|create-text|create-effect`
26
+ - `boolean union|subtract|intersect|exclude`
27
+ - `group create|ungroup|flatten`
28
+ - `find`, `import`, `eval`, `status`, `proxy`, `plugin`
29
+ - **Variables support** — full CRUD for Figma variables and collections
30
+ - **`node tree` command** — formatted hierarchy view with properties inline
31
+ - **Export size guards** — prevents oversized exports (max 4096px, 16MP)
32
+ - **Tree node limit** — `node tree` limits to 500 nodes by default
33
+ - `--force` flag to override size/node limits
34
+ - `--timeout` flag for heavy operations (export, screenshot, eval)
35
+
36
+ ### Changed
37
+
38
+ - **BREAKING**: Command syntax changed from flat to nested (e.g., `create-rectangle` → `create rect`)
39
+ - Renamed args: `--parentId` → `--parent`, `--itemSpacing` → `--gap`, `--layoutMode` → `--layout`
40
+ - Tests reorganized into separate files by command group (80 tests)
41
+
42
+ ### Fixed
43
+
44
+ - TypeScript strict mode compliance
45
+ - Figma API compatibility (BlurEffect, ExportSettings)
46
+
47
+ ## [0.1.5] - 2025-01-17
48
+
49
+ ### Added
50
+
51
+ - CHANGELOG.md
52
+ - SKILL.md included in npm package
53
+ - `--timeout` flag documentation
54
+
55
+ ## [0.1.4] - 2025-01-17
56
+
57
+ ### Added
58
+
59
+ - CONTRIBUTING.md with setup and PR guidelines
60
+
61
+ ### Changed
62
+
63
+ - Updated package description and keywords
64
+
65
+ ## [0.1.3] - 2025-01-17
66
+
67
+ ### Added
68
+
69
+ - AGENTS.md for contributors
70
+ - Git tags for all versions
71
+
72
+ ## [0.1.2] - 2025-01-17
73
+
74
+ ### Added
75
+
76
+ - `eval` command to execute arbitrary JavaScript in Figma plugin context
77
+ - `figma-use plugin` auto-installs plugin to Figma settings.json
78
+ - `--force` flag for plugin install while Figma is running
79
+ - `--uninstall` flag to remove plugin
80
+ - Architecture diagram in README
81
+ - Comparison table: official Figma MCP (read-only) vs figma-use (full control)
82
+
83
+ ### Changed
84
+
85
+ - All `proxy` and `plugin` commands now use citty for consistency
86
+ - README examples show inline styling (one command does fill + stroke + radius)
87
+
88
+ ## [0.1.1] - 2025-01-17
89
+
90
+ ### Added
91
+
92
+ - Human-readable CLI output by default (agent-browser style)
93
+ - `--json` flag for machine parsing on all commands
94
+ - 69 integration tests
95
+
96
+ ### Changed
97
+
98
+ - Renamed from figma-bridge to @dannote/figma-use
99
+
100
+ ## [0.1.0] - 2025-01-17
101
+
102
+ ### Added
103
+
104
+ - Initial release
105
+ - 60+ CLI commands for Figma control
106
+ - WebSocket proxy server (Elysia)
107
+ - Figma plugin with all command handlers
108
+ - Create commands: rectangle, ellipse, line, polygon, star, vector, frame, section, text, component, instance
109
+ - Style commands: fill, stroke, corner radius, opacity, effects, blend mode
110
+ - Layout commands: auto-layout, constraints, min/max
111
+ - Transform commands: move, resize, rotate, set parent
112
+ - Query commands: get node, children, selection, pages, components, styles
113
+ - Export commands: PNG/SVG/PDF export, screenshot
114
+ - Inline styling: `--fill`, `--stroke`, `--radius` etc. on create commands
115
+
116
+ [unreleased]: https://github.com/dannote/figma-use/compare/v0.2.0...HEAD
117
+ [0.2.0]: https://github.com/dannote/figma-use/compare/v0.1.5...v0.2.0
118
+ [0.1.5]: https://github.com/dannote/figma-use/compare/v0.1.4...v0.1.5
119
+ [0.1.4]: https://github.com/dannote/figma-use/compare/v0.1.3...v0.1.4
120
+ [0.1.3]: https://github.com/dannote/figma-use/compare/v0.1.2...v0.1.3
121
+ [0.1.2]: https://github.com/dannote/figma-use/compare/v0.1.1...v0.1.2
122
+ [0.1.1]: https://github.com/dannote/figma-use/compare/v0.1.0...v0.1.1
123
+ [0.1.0]: https://github.com/dannote/figma-use/releases/tag/v0.1.0
package/README.md CHANGED
@@ -6,22 +6,23 @@ Inspired by [agent-browser](https://github.com/vercel-labs/agent-browser) (brows
6
6
 
7
7
  ## Why not the official Figma MCP?
8
8
 
9
- The [official Figma MCP server](https://developers.figma.com/docs/figma-mcp-server/) is **read-only** — it can extract design context and take screenshots, but cannot create or modify anything.
9
+ The [official Figma MCP server](https://developers.figma.com/docs/figma-mcp-server/) is focused on **design-to-code** — extracting structure and variables for code generation. It cannot create or modify designs.
10
10
 
11
11
  | Feature | Official MCP | figma-use |
12
12
  |---------|-------------|-----------|
13
13
  | Read node properties | ✓ | ✓ |
14
14
  | Take screenshots | ✓ | ✓ |
15
- | Extract variables/styles | ✓ | ✓ |
15
+ | Extract variables | ✓ | ✓ |
16
16
  | **Create shapes** | ✗ | ✓ |
17
17
  | **Create text** | ✗ | ✓ |
18
18
  | **Create frames & components** | ✗ | ✓ |
19
19
  | **Modify properties** | ✗ | ✓ |
20
20
  | **Set fills, strokes, effects** | ✗ | ✓ |
21
21
  | **Auto-layout** | ✗ | ✓ |
22
+ | **Create/modify variables** | ✗ | ✓ |
22
23
  | **Execute arbitrary code** | ✗ | ✓ |
23
24
 
24
- figma-use gives AI agents full control over Figma — not just reading, but **creating and editing** designs.
25
+ figma-use gives AI agents **full read/write control** over Figma.
25
26
 
26
27
  ## How it works
27
28
 
@@ -57,14 +58,10 @@ figma-use proxy
57
58
  # Quit Figma first, then:
58
59
  figma-use plugin
59
60
 
60
- # Or force install while Figma is running (restart required):
61
- figma-use plugin --force
62
-
63
- # Show plugin path only:
64
- figma-use plugin --path
65
-
66
- # Uninstall:
67
- figma-use plugin --uninstall
61
+ # Or with options:
62
+ figma-use plugin --force # Force install while Figma is running
63
+ figma-use plugin --path # Show plugin path only
64
+ figma-use plugin --uninstall # Uninstall
68
65
  ```
69
66
 
70
67
  Start Figma and find the plugin in **Plugins → Development → Figma Use**.
@@ -72,165 +69,223 @@ Start Figma and find the plugin in **Plugins → Development → Figma Use**.
72
69
  ### 3. Run commands
73
70
 
74
71
  ```bash
75
- # Create a styled button in one command (fill + stroke + radius + layout)
76
- figma-use create-frame --x 0 --y 0 --width 200 --height 48 \
77
- --fill "#3B82F6" --stroke "#1D4ED8" --radius 8 \
78
- --layoutMode HORIZONTAL --itemSpacing 8 --padding "12,24,12,24" \
72
+ # Create a styled button
73
+ figma-use create frame --x 0 --y 0 --width 200 --height 48 \
74
+ --fill "#3B82F6" --radius 8 \
75
+ --layout HORIZONTAL --gap 8 --padding "12,24,12,24" \
79
76
  --name "Button"
80
77
 
81
- # Add text with font styling
82
- figma-use create-text --x 0 --y 0 --text "Click me" \
78
+ # Add text
79
+ figma-use create text --x 0 --y 0 --text "Click me" \
83
80
  --fontSize 16 --fontFamily "Inter" --fontStyle "Medium" --fill "#FFFFFF" \
84
- --parentId "1:23"
81
+ --parent "1:23"
85
82
 
86
83
  # Export to PNG
87
- figma-use export-node --id "1:23" --format PNG --scale 2 --output button.png
84
+ figma-use export node "1:23" --format PNG --scale 2 --output button.png
88
85
  ```
89
86
 
90
- All create commands support inline styling — no need for separate `set-*` calls.
87
+ All create commands support inline styling — no need for separate `set` calls.
91
88
 
92
- ## Output Format
89
+ ## Commands
93
90
 
94
- Human-readable by default:
91
+ ### Node Operations
95
92
 
96
93
  ```bash
97
- $ figma-use create-rectangle --x 0 --y 0 --width 100 --height 50 --fill "#FF0000"
98
- Created rect "Rectangle"
99
- id: 1:23
100
- box: 100x50 at (0, 0)
101
- fill: #FF0000
94
+ figma-use node get <id> # Get node properties
95
+ figma-use node tree [id] # Get formatted tree (default: current page)
96
+ figma-use node tree --depth 2 # Limit tree depth
97
+ figma-use node tree -i # Only interactive elements
98
+ figma-use node children <id> # Get child nodes
99
+ figma-use node delete <id> # Delete node
100
+ figma-use node clone <id> # Clone node
101
+ figma-use node rename <id> <name> # Rename node
102
+ figma-use node move <id> --x <x> --y <y> # Move node
103
+ figma-use node resize <id> --width <w> --height <h>
104
+ ```
102
105
 
103
- $ figma-use get-children --id "1:2"
104
- [0] frame "Header" (1:3)
105
- box: 1200x80 at (0, 0)
106
- fill: #FFFFFF
106
+ The `tree` command outputs a human-readable hierarchy:
107
107
 
108
- [1] text "Title" (1:4)
109
- box: 200x32 at (20, 24)
110
- font: 24px
108
+ ```
109
+ [0] frame "Card" (1:23)
110
+ 400×300 at (0, 0) | fill: #FFFFFF | layout: col gap=16
111
+ [0] text "Title" (1:24)
112
+ 200×32 at (24, 24) | fill: #000000 | "Hello World" | font: 24px Inter Bold
113
+ [1] frame "Content" (1:25)
114
+ 352×200 at (24, 72) | fill: #F5F5F5 | radius: 8
111
115
  ```
112
116
 
113
- Add `--json` for machine-readable output:
117
+ ### Create Shapes
114
118
 
115
119
  ```bash
116
- $ figma-use get-node --id "1:2" --json
117
- {
118
- "id": "1:2",
119
- "name": "Frame",
120
- "type": "FRAME",
121
- ...
122
- }
120
+ figma-use create rect --x 0 --y 0 --width 100 --height 50 [--fill --stroke --radius]
121
+ figma-use create ellipse --x 0 --y 0 --width 100 --height 100 [--fill]
122
+ figma-use create line --x 0 --y 0 --length 100 [--stroke]
123
+ figma-use create polygon --x 0 --y 0 --size 60 --sides 6 [--fill]
124
+ figma-use create star --x 0 --y 0 --size 60 --points 5 [--fill]
125
+ figma-use create vector --x 0 --y 0 --path "M0,0 L100,100"
123
126
  ```
124
127
 
125
- ## Commands
128
+ ### Create Containers
129
+
130
+ ```bash
131
+ figma-use create frame --x 0 --y 0 --width 400 --height 300 \
132
+ [--fill --radius --layout HORIZONTAL --gap 12 --padding "16,16,16,16"]
133
+ figma-use create component --x 0 --y 0 --width 200 --height 100
134
+ figma-use create instance --component <id> --x 100 --y 100
135
+ figma-use create section --x 0 --y 0 --width 800 --height 600 --name "Hero"
136
+ figma-use create page "Page Name"
137
+ ```
138
+
139
+ ### Create Text
140
+
141
+ ```bash
142
+ figma-use create text --x 0 --y 0 --text "Hello" \
143
+ [--fontSize 24 --fontFamily "Inter" --fontStyle "Bold" --fill "#000"]
144
+ ```
145
+
146
+ ### Set Properties
147
+
148
+ ```bash
149
+ figma-use set fill <id> "#FF0000"
150
+ figma-use set stroke <id> "#000" [--weight 2]
151
+ figma-use set radius <id> --radius 12
152
+ figma-use set radius <id> --topLeft 16 --bottomRight 16
153
+ figma-use set opacity <id> 0.5
154
+ figma-use set rotation <id> 45
155
+ figma-use set visible <id> false
156
+ figma-use set text <id> "New text"
157
+ figma-use set font <id> --family "Inter" --style "Bold" --size 20
158
+ figma-use set effect <id> --type DROP_SHADOW --radius 10 --offsetY 4 --color "#00000040"
159
+ figma-use set layout <id> --mode VERTICAL --gap 12 --padding 16
160
+ figma-use set blend <id> MULTIPLY
161
+ figma-use set constraints <id> --horizontal CENTER --vertical MAX
162
+ figma-use set image <id> image.png [--mode FILL]
163
+ ```
126
164
 
127
- ### Shapes
128
-
129
- | Command | Description |
130
- |---------|-------------|
131
- | `create-rectangle` | Create rectangle with optional fill, stroke, radius |
132
- | `create-ellipse` | Create ellipse/circle |
133
- | `create-line` | Create line |
134
- | `create-polygon` | Create polygon |
135
- | `create-star` | Create star |
136
- | `create-vector` | Create vector path |
137
-
138
- ### Containers
139
-
140
- | Command | Description |
141
- |---------|-------------|
142
- | `create-frame` | Create frame with optional auto-layout |
143
- | `create-component` | Create component |
144
- | `create-instance` | Create component instance |
145
- | `create-section` | Create section |
146
- | `group-nodes` | Group nodes |
147
- | `ungroup-node` | Ungroup |
148
-
149
- ### Text
150
-
151
- | Command | Description |
152
- |---------|-------------|
153
- | `create-text` | Create text with font, size, color |
154
- | `set-text` | Update text content |
155
- | `set-font` | Change font family, size, weight |
156
- | `set-text-properties` | Line height, letter spacing, alignment |
157
-
158
- ### Styling
159
-
160
- | Command | Description |
161
- |---------|-------------|
162
- | `set-fill-color` | Set fill color |
163
- | `set-stroke-color` | Set stroke color and weight |
164
- | `set-corner-radius` | Set corner radius (uniform or individual) |
165
- | `set-opacity` | Set opacity |
166
- | `set-effect` | Add shadow or blur |
167
- | `set-blend-mode` | Set blend mode |
168
-
169
- ### Layout
170
-
171
- | Command | Description |
172
- |---------|-------------|
173
- | `set-layout` | Enable auto-layout (horizontal/vertical) |
174
- | `set-layout-child` | Set child sizing (fill/fixed/hug) |
175
- | `set-constraints` | Set resize constraints |
176
- | `set-min-max` | Set min/max width/height |
177
-
178
- ### Transform
179
-
180
- | Command | Description |
181
- |---------|-------------|
182
- | `move-node` | Move to x, y |
183
- | `resize-node` | Resize to width, height |
184
- | `set-rotation` | Rotate by angle |
185
- | `set-parent` | Move to different parent |
165
+ ### Variables (Design Tokens)
166
+
167
+ ```bash
168
+ figma-use variable list [--type COLOR|FLOAT|STRING|BOOLEAN]
169
+ figma-use variable get <id>
170
+ figma-use variable create "Primary" --collection <id> --type COLOR --value "#FF0000"
171
+ figma-use variable set <id> --mode <modeId> --value "#00FF00"
172
+ figma-use variable delete <id>
173
+ figma-use variable bind --node <nodeId> --field fills --variable <varId>
174
+
175
+ figma-use collection list
176
+ figma-use collection get <id>
177
+ figma-use collection create "Colors"
178
+ figma-use collection delete <id>
179
+ ```
180
+
181
+ ### Styles
182
+
183
+ ```bash
184
+ figma-use style list
185
+ figma-use style create-paint "Brand/Primary" --color "#E11D48"
186
+ figma-use style create-text "Heading/H1" --family "Inter" --style "Bold" --size 32
187
+ figma-use style create-effect "Shadow/Medium" --type DROP_SHADOW --radius 8 --offsetY 4
188
+ ```
186
189
 
187
190
  ### Export
188
191
 
189
- | Command | Description |
190
- |---------|-------------|
191
- | `export-node` | Export node as PNG/SVG/PDF |
192
- | `screenshot` | Screenshot current viewport |
192
+ ```bash
193
+ figma-use export node <id> [--format PNG|SVG|PDF] [--scale 2] [--output file.png]
194
+ figma-use export selection [--format PNG] [--scale 2] [--output file.png]
195
+ figma-use export screenshot [--output viewport.png]
196
+ ```
193
197
 
194
- ### Query
198
+ Export commands have built-in guards against oversized exports (max 4096px dimension, 16MP total). Override with `--force`:
195
199
 
196
- | Command | Description |
197
- |---------|-------------|
198
- | `get-node` | Get node properties |
199
- | `get-children` | Get child nodes |
200
- | `get-selection` | Get selected nodes |
201
- | `get-pages` | List all pages |
202
- | `find-by-name` | Find nodes by name |
200
+ ```bash
201
+ figma-use export node <id> --scale 10 --force
202
+ ```
203
203
 
204
- ### Navigation
204
+ Heavy operations support `--timeout` (seconds):
205
+ ```bash
206
+ figma-use export node <id> --scale 2 --output large.png --timeout 300
207
+ ```
205
208
 
206
- | Command | Description |
207
- |---------|-------------|
208
- | `set-current-page` | Switch to page |
209
- | `zoom-to-fit` | Zoom to fit nodes |
210
- | `set-viewport` | Set viewport position and zoom |
209
+ ### Selection & Navigation
211
210
 
212
- ### Advanced
211
+ ```bash
212
+ figma-use selection get
213
+ figma-use selection set "1:2,1:3,1:4"
214
+
215
+ figma-use page list
216
+ figma-use page set <id|name>
217
+
218
+ figma-use viewport get
219
+ figma-use viewport set --x 100 --y 200 --zoom 0.5
220
+ figma-use viewport zoom-to-fit <ids...>
221
+ ```
213
222
 
214
- | Command | Description |
215
- |---------|-------------|
216
- | `eval` | Execute arbitrary JavaScript in Figma |
223
+ ### Find & Query
217
224
 
218
- #### eval
225
+ ```bash
226
+ figma-use find --name "Button"
227
+ figma-use find --name "Icon" --type FRAME
228
+ figma-use get pages
229
+ figma-use get components
230
+ figma-use get styles
231
+ ```
219
232
 
220
- Run any JavaScript code in the Figma plugin context:
233
+ ### Boolean & Group
221
234
 
222
235
  ```bash
223
- # Simple expression
224
- figma-use eval "return 2 + 2"
236
+ figma-use boolean union "1:2,1:3"
237
+ figma-use boolean subtract "1:2,1:3"
238
+ figma-use boolean intersect "1:2,1:3"
239
+ figma-use boolean exclude "1:2,1:3"
240
+
241
+ figma-use group create "1:2,1:3"
242
+ figma-use group ungroup <id>
243
+ figma-use group flatten "1:2,1:3"
244
+ ```
225
245
 
226
- # Access Figma API
227
- figma-use eval "return figma.currentPage.name"
246
+ ### Advanced
228
247
 
229
- # Create nodes
248
+ ```bash
249
+ # Execute arbitrary JavaScript in Figma
250
+ figma-use eval "return figma.currentPage.name"
230
251
  figma-use eval "const r = figma.createRectangle(); r.resize(100, 100); return r.id"
252
+ figma-use eval "await figma.loadFontAsync({family: 'Inter', style: 'Bold'})"
253
+
254
+ # Import SVG
255
+ figma-use import --svg "<svg>...</svg>" --x 0 --y 0
256
+ ```
257
+
258
+ ## Output Format
259
+
260
+ Human-readable by default:
261
+
262
+ ```bash
263
+ $ figma-use create rect --x 0 --y 0 --width 100 --height 50 --fill "#FF0000"
264
+ ✓ Created rect "Rectangle"
265
+ id: 1:23
266
+ box: 100x50 at (0, 0)
267
+ fill: #FF0000
268
+
269
+ $ figma-use node children "1:2"
270
+ [0] frame "Header" (1:3)
271
+ box: 1200x80 at (0, 0)
272
+ fill: #FFFFFF
231
273
 
232
- # Async code (top-level await supported)
233
- figma-use eval "const node = await figma.getNodeByIdAsync('1:2'); return node.name"
274
+ [1] text "Title" (1:4)
275
+ box: 200x32 at (20, 24)
276
+ font: 24px
277
+ ```
278
+
279
+ Add `--json` for machine-readable output:
280
+
281
+ ```bash
282
+ $ figma-use node get "1:2" --json
283
+ {
284
+ "id": "1:2",
285
+ "name": "Frame",
286
+ "type": "FRAME",
287
+ ...
288
+ }
234
289
  ```
235
290
 
236
291
  ## Environment Variables
@@ -250,10 +305,10 @@ Copy the included skill to teach your agent how to use figma-use:
250
305
 
251
306
  ```bash
252
307
  # From npm package
253
- cp node_modules/@dannote/figma-use/SKILL.md ~/.claude/skills/figma-use/SKILL.md
308
+ mkdir -p ~/.claude/skills/figma-use
309
+ cp node_modules/@dannote/figma-use/SKILL.md ~/.claude/skills/figma-use/
254
310
 
255
311
  # Or download directly
256
- mkdir -p ~/.claude/skills/figma-use
257
312
  curl -o ~/.claude/skills/figma-use/SKILL.md \
258
313
  https://raw.githubusercontent.com/dannote/figma-use/main/SKILL.md
259
314
  ```
@@ -271,13 +326,13 @@ For agents that don't support skills, add to your project's `CLAUDE.md` or `AGEN
271
326
  ```markdown
272
327
  ## Figma Automation
273
328
 
274
- Use `figma-use` for Figma control. Run `figma-use --help` for all 73 commands.
329
+ Use `figma-use` for Figma control. Run `figma-use --help` for commands.
275
330
 
276
- Quick workflow:
331
+ Workflow:
277
332
  1. `figma-use status` - Check plugin connection
278
- 2. `figma-use create-frame --x 0 --y 0 --width 400 --height 300 --fill "#FFF" --name "Card"`
279
- 3. `figma-use create-text --x 20 --y 20 --text "Title" --fontSize 24 --fill "#000" --parentId "1:2"`
280
- 4. `figma-use screenshot --output preview.png` - Verify result
333
+ 2. `figma-use create frame --x 0 --y 0 --width 400 --height 300 --fill "#FFF" --name "Card"`
334
+ 3. `figma-use create text --x 20 --y 20 --text "Title" --fontSize 24 --fill "#000" --parent "1:2"`
335
+ 4. `figma-use export screenshot --output preview.png` - Verify result
281
336
  ```
282
337
 
283
338
  ## License