figma-to-code-agent 0.5.0 → 0.6.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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.6.0] - 2026-02-13
4
+
5
+ ### Added
6
+ - Property tests for Property 3 (component identification completeness) and Property 4 (image asset extraction)
7
+ - Real Figma data end-to-end tests: 29 tests covering 4 real design files (MIUI12 Navigation, Homepage, Shopping Cart, Product Page)
8
+ - Cross-design pipeline consistency tests (React vs Vue, css-modules vs css)
9
+ - Full document processing test for large Figma canvas
10
+
11
+ ### Improved
12
+ - Property test coverage now spans Properties 1-4, 5-44 (complete)
13
+ - Total test count: 309 tests across 42 test suites
14
+
3
15
  ## [0.5.0] - 2026-02-13
4
16
 
5
17
  ### Added
package/QUICKSTART.md CHANGED
@@ -85,7 +85,7 @@ npx figma-to-code-agent \
85
85
 
86
86
  ## Generated Output
87
87
 
88
- For a React component, you'll get:
88
+ For a React component with CSS Modules, you'll get:
89
89
 
90
90
  ```
91
91
  output/
@@ -96,6 +96,15 @@ output/
96
96
  └── icon-close.png
97
97
  ```
98
98
 
99
+ For plain CSS mode (`--style css`):
100
+
101
+ ```
102
+ output/
103
+ ├── Component.jsx # React component
104
+ ├── Component.css # Standalone CSS file
105
+ └── assets/
106
+ ```
107
+
99
108
  For Vue, a single `.vue` file with `<template>`, `<script setup>`, and `<style scoped>`.
100
109
 
101
110
  ## What Gets Generated
@@ -119,6 +128,7 @@ For Vue, a single `.vue` file with `<template>`, `<script setup>`, and `<style s
119
128
  | `--style` | `css-modules`, `tailwind`, or `css` | `css-modules` |
120
129
  | `--typescript` | Enable TypeScript output | `false` |
121
130
  | `--output <dir>` | Output directory | `./output` |
131
+ | `--extract-tokens <fmt>` | Extract design tokens: `css`, `scss`, `json`, `js` | — |
122
132
  | `--preview` | Preview in browser after generation | — |
123
133
 
124
134
  ## AI Enhancements (Optional)
package/README.md CHANGED
@@ -34,11 +34,20 @@ Convert Figma designs to production-ready React/Vue components. Supports CSS Mod
34
34
 
35
35
  - 🎨 Extract designs from Figma API with caching and rate-limit handling
36
36
  - ⚛️ Generate React (.jsx/.tsx) and Vue (.vue) components
37
- - 🎭 CSS Modules, Tailwind, or plain CSS
37
+ - 🎭 CSS Modules, Tailwind CSS (arbitrary values), or plain CSS with separate stylesheet
38
38
  - 📐 Absolute positioning with responsive scaling (auto-fits viewport)
39
39
  - 🖼️ Image export at 2x resolution, vector icon auto-detection and PNG export
40
40
  - 🔤 Full typography support (font family, size, weight, line-height, letter-spacing, color)
41
41
  - 👁️ Figma layer filtering (hidden layers, mask shapes)
42
+ - 🎯 Design token extraction (CSS variables, SCSS, JSON, JS)
43
+ - 🧩 Component splitting (auto-split large designs >50 nodes, max depth 4)
44
+ - 📁 File organizer (PascalCase/kebab-case naming, directory structure, Props interface)
45
+ - 🖼️ Asset management (image dedup, SVG-first, semantic naming, import generation)
46
+ - 🔍 Visual validation (Puppeteer rendering, pixel comparison, similarity scoring)
47
+ - ♿ Accessibility enhancement (ARIA roles, alt text, landmark detection)
48
+ - ⚡ Performance optimization (lazy loading, code splitting hints, redundant wrapper removal)
49
+ - 🎨 Style deduplication (merge identical CSS rules across components)
50
+ - 📱 Responsive code generation (media queries from breakpoint metadata)
42
51
  - 🤖 Optional AI enhancements (semantic naming, component splitting, code optimization)
43
52
 
44
53
  ## Install
@@ -79,10 +88,12 @@ npx figma-to-code-agent \
79
88
  1. Fetches the Figma file data via API (with local caching)
80
89
  2. Parses the design tree into an intermediate AST
81
90
  3. Filters invisible layers, mask shapes, and transparent fills
82
- 4. Detects vector-only containers and exports them as PNG icons
83
- 5. Downloads images at 2x resolution
84
- 6. Generates framework-specific components with CSS Modules
85
- 7. Wraps output in a responsive scale container (no horizontal scrollbar)
91
+ 4. Applies transformation pipeline (flatten, extract components, optimize layout, semantic naming, style merging, accessibility, performance)
92
+ 5. Detects vector-only containers and exports them as PNG icons
93
+ 6. Downloads images at 2x resolution
94
+ 7. Generates framework-specific components with chosen style mode
95
+ 8. Deduplicates identical CSS rules and generates responsive media queries
96
+ 9. Wraps output in a responsive scale container (no horizontal scrollbar)
86
97
 
87
98
  ## CLI Options
88
99
 
@@ -95,6 +106,7 @@ npx figma-to-code-agent \
95
106
  | `--style` | `css-modules`, `tailwind`, or `css` | `css-modules` |
96
107
  | `--typescript` | Enable TypeScript output | `false` |
97
108
  | `--output <dir>` | Output directory | `./output` |
109
+ | `--extract-tokens <fmt>` | Extract design tokens: `css`, `scss`, `json`, `js` | — |
98
110
  | `--preview` | Preview in browser after generation | — |
99
111
 
100
112
  ### AI Options (optional)
@@ -103,9 +115,12 @@ npx figma-to-code-agent \
103
115
  |--------|-------------|
104
116
  | `--llm-provider` | `bedrock`, `openai`, or `anthropic` |
105
117
  | `--llm-model` | Model name |
118
+ | `--llm-region` | AWS region for Bedrock (default: `us-east-1`) |
119
+ | `--llm-api-key` | API key for OpenAI/Anthropic (or `LLM_API_KEY` env) |
106
120
  | `--ai-naming` | AI-powered semantic component naming |
107
121
  | `--ai-splitting` | AI-powered component splitting |
108
122
  | `--ai-optimization` | AI-powered code optimization |
123
+ | `--ai-layout` | AI-powered layout analysis |
109
124
 
110
125
  ## Programmatic API
111
126
 
@@ -119,6 +134,7 @@ const agent = new FigmaToCodeAgent({
119
134
  styleMode: 'css-modules',
120
135
  typescript: false,
121
136
  outputDir: './output',
137
+ extractTokens: 'css', // optional: 'css' | 'scss' | 'json' | 'js'
122
138
  })
123
139
 
124
140
  const files = await agent.convert()
@@ -130,10 +146,16 @@ const files = await agent.convert()
130
146
  src/
131
147
  ├── extraction/ # Figma API client, MCP protocol, caching
132
148
  ├── transformation/ # AST parsing, layout optimization, transformers
133
- │ └── transformers/ # Component extraction, semantic naming, etc.
134
- ├── generation/ # React and Vue code generators
149
+ │ └── transformers/ # Flatten, component extraction, semantic naming,
150
+ # style merger, responsive merger, accessibility,
151
+ │ # performance optimizer, AI-powered transformers
152
+ ├── generation/ # React and Vue code generators, file organizer
153
+ ├── tokens/ # Design token extraction and export
154
+ ├── assets/ # Asset management (image extraction, dedup)
155
+ ├── validation/ # Visual validation (Puppeteer, pixel comparison)
156
+ ├── config/ # Configuration management
157
+ ├── errors/ # Error handling and recovery
135
158
  ├── llm/ # LLM providers (Bedrock, OpenAI)
136
- ├── validation/ # Visual validation
137
159
  └── cli.ts # CLI entry point
138
160
  ```
139
161
 
@@ -144,7 +166,7 @@ git clone https://github.com/lewiscutey/figma-to-code-agent.git
144
166
  cd figma-to-code-agent
145
167
  npm install
146
168
  npm run build # Compile TypeScript
147
- npm test # Run all tests (129 tests)
169
+ npm test # Run all tests (222 tests)
148
170
  npm run lint # ESLint
149
171
  npm run format # Prettier
150
172
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "figma-to-code-agent",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "AI Agent that converts Figma designs to production-ready code with optional LLM enhancements",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",