design-clone 2.1.0 → 3.0.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 (177) hide show
  1. package/README.md +13 -34
  2. package/SKILL.md +69 -45
  3. package/bin/cli.js +22 -4
  4. package/bin/commands/clone-site.js +31 -171
  5. package/bin/commands/help.js +19 -6
  6. package/bin/commands/init.js +9 -86
  7. package/bin/commands/uninstall.js +105 -0
  8. package/bin/commands/update.js +70 -0
  9. package/bin/commands/verify.js +7 -14
  10. package/bin/utils/paths.js +28 -0
  11. package/bin/utils/validate.js +2 -22
  12. package/bin/utils/version.js +23 -0
  13. package/docs/code-standards.md +789 -0
  14. package/docs/codebase-summary.md +533 -286
  15. package/docs/index.md +74 -0
  16. package/docs/project-overview-pdr.md +797 -0
  17. package/docs/system-architecture.md +718 -0
  18. package/package.json +14 -17
  19. package/src/ai/prompts/design-tokens/basic.md +80 -0
  20. package/src/ai/prompts/design-tokens/section-with-css.md +41 -0
  21. package/src/ai/prompts/design-tokens/section.md +48 -0
  22. package/src/ai/prompts/design-tokens/with-css.md +87 -0
  23. package/src/ai/prompts/structure-analysis/basic.md +55 -0
  24. package/src/ai/prompts/structure-analysis/with-context.md +59 -0
  25. package/src/ai/prompts/structure-analysis/with-dimensions.md +63 -0
  26. package/src/ai/prompts/structure-analysis/with-hierarchy.md +73 -0
  27. package/src/ai/prompts/ux-audit/aggregation.md +42 -0
  28. package/src/ai/prompts/ux-audit/desktop.md +92 -0
  29. package/src/ai/prompts/ux-audit/mobile.md +93 -0
  30. package/src/ai/prompts/ux-audit/tablet.md +92 -0
  31. package/src/core/animation/animation-extractor-ast.js +183 -0
  32. package/src/core/animation/animation-extractor-output.js +152 -0
  33. package/src/core/animation/animation-extractor.js +178 -0
  34. package/src/core/animation/state-capture-detection.js +200 -0
  35. package/src/core/animation/state-capture.js +193 -0
  36. package/src/core/capture/browser-context-pool.js +96 -0
  37. package/src/core/capture/multi-page-screenshot-page.js +110 -0
  38. package/src/core/capture/multi-page-screenshot.js +208 -0
  39. package/src/core/capture/screenshot-extraction.js +186 -0
  40. package/src/core/capture/screenshot-helpers.js +175 -0
  41. package/src/core/capture/screenshot-orchestrator.js +174 -0
  42. package/src/core/capture/screenshot-viewport.js +93 -0
  43. package/src/core/capture/screenshot.js +192 -0
  44. package/src/core/content/content-counter-dom.js +191 -0
  45. package/src/core/content/content-counter.js +76 -0
  46. package/src/core/css/breakpoint-detector.js +66 -0
  47. package/src/core/css/chromium-defaults.json +23 -0
  48. package/src/core/css/computed-style-extractor.js +102 -0
  49. package/src/core/css/css-chunker.js +103 -0
  50. package/src/core/css/filter-css-dead-code.js +120 -0
  51. package/src/core/css/filter-css-html-analyzer.js +110 -0
  52. package/src/core/css/filter-css-selector-matcher.js +172 -0
  53. package/src/core/css/filter-css.js +206 -0
  54. package/src/core/css/merge-css-atrule-processor.js +158 -0
  55. package/src/core/css/merge-css-file-io.js +68 -0
  56. package/src/core/css/merge-css.js +148 -0
  57. package/src/core/detection/framework-detector-routing.js +68 -0
  58. package/src/core/detection/framework-detector-signals.js +65 -0
  59. package/src/core/detection/framework-detector.js +198 -0
  60. package/src/core/dimension/dimension-extractor-card-detector.js +82 -0
  61. package/src/core/dimension/dimension-extractor.js +317 -0
  62. package/src/core/dimension/dimension-output-ai-summary.js +111 -0
  63. package/src/core/dimension/dimension-output.js +173 -0
  64. package/src/core/dimension/dom-tree-analyzer-tree-builders.js +95 -0
  65. package/src/core/dimension/dom-tree-analyzer.js +191 -0
  66. package/src/core/discovery/app-state-snapshot-capture.js +195 -0
  67. package/src/core/discovery/app-state-snapshot-utils.js +178 -0
  68. package/src/core/discovery/app-state-snapshot.js +131 -0
  69. package/src/core/discovery/discover-pages-routes.js +84 -0
  70. package/src/core/discovery/discover-pages-utils.js +177 -0
  71. package/src/core/discovery/discover-pages.js +191 -0
  72. package/src/core/html/html-extractor-inline-styler.js +70 -0
  73. package/src/core/html/html-extractor.js +147 -0
  74. package/src/core/html/semantic-enhancer-mappings.js +200 -0
  75. package/src/core/html/semantic-enhancer-page.js +148 -0
  76. package/src/core/html/semantic-enhancer.js +135 -0
  77. package/src/core/links/rewrite-links-css-rewriter.js +53 -0
  78. package/src/core/links/rewrite-links.js +173 -0
  79. package/src/core/media/asset-validator.js +118 -0
  80. package/src/core/media/extract-assets-downloader.js +187 -0
  81. package/src/core/media/extract-assets-page-scraper.js +115 -0
  82. package/src/core/media/extract-assets.js +159 -0
  83. package/src/core/media/video-capture-convert.js +200 -0
  84. package/src/core/media/video-capture.js +201 -0
  85. package/src/core/{lazy-loader.js → page-prep/lazy-loader.js} +37 -39
  86. package/src/core/section/section-cropper-helpers.js +43 -0
  87. package/src/core/{section-cropper.js → section/section-cropper.js} +11 -88
  88. package/src/core/section/section-detector-strategies.js +139 -0
  89. package/src/core/section/section-detector-utils.js +100 -0
  90. package/src/core/section/section-detector.js +88 -0
  91. package/src/core/tests/test-section-cropper.js +2 -2
  92. package/src/core/tests/test-section-detector.js +2 -2
  93. package/src/post-process/enhance-assets.js +29 -4
  94. package/src/post-process/fetch-images-unsplash-client.js +123 -0
  95. package/src/post-process/fetch-images.js +60 -263
  96. package/src/post-process/inject-gosnap.js +88 -0
  97. package/src/post-process/inject-icons-svg-replacer.js +76 -0
  98. package/src/post-process/inject-icons.js +47 -200
  99. package/src/route-discoverers/base-discoverer-utils.js +137 -0
  100. package/src/route-discoverers/base-discoverer.js +29 -118
  101. package/src/route-discoverers/index.js +1 -1
  102. package/src/shared/config.js +38 -0
  103. package/src/shared/error-codes.js +31 -0
  104. package/src/shared/viewports.js +46 -0
  105. package/src/utils/browser.js +0 -7
  106. package/src/utils/helpers.js +4 -0
  107. package/src/utils/log.js +12 -0
  108. package/src/utils/playwright-loader.js +76 -0
  109. package/src/utils/playwright.js +3 -69
  110. package/src/utils/progress.js +32 -0
  111. package/src/verification/generate-audit-report-css-fixes.js +52 -0
  112. package/src/verification/generate-audit-report-sections.js +158 -0
  113. package/src/verification/generate-audit-report.js +5 -281
  114. package/src/verification/quality-scorer.js +92 -0
  115. package/src/verification/verify-footer-checks.js +103 -0
  116. package/src/verification/verify-footer-helpers.js +178 -0
  117. package/src/verification/verify-footer.js +23 -381
  118. package/src/verification/verify-header-checks.js +104 -0
  119. package/src/verification/verify-header-helpers.js +156 -0
  120. package/src/verification/verify-header.js +23 -365
  121. package/src/verification/verify-layout-report.js +101 -0
  122. package/src/verification/verify-layout.js +13 -259
  123. package/src/verification/verify-menu-checks.js +104 -0
  124. package/src/verification/verify-menu-helpers.js +112 -0
  125. package/src/verification/verify-menu.js +17 -285
  126. package/src/verification/verify-slider-checks.js +115 -0
  127. package/src/verification/verify-slider-constants.js +65 -0
  128. package/src/verification/verify-slider-helpers.js +164 -0
  129. package/src/verification/verify-slider.js +23 -414
  130. package/.env.example +0 -14
  131. package/docs/basic-clone.md +0 -63
  132. package/docs/cli-reference.md +0 -316
  133. package/docs/design-clone-architecture.md +0 -492
  134. package/docs/pixel-perfect.md +0 -117
  135. package/docs/project-roadmap.md +0 -382
  136. package/docs/troubleshooting.md +0 -170
  137. package/requirements.txt +0 -5
  138. package/src/ai/__pycache__/analyze-structure.cpython-313.pyc +0 -0
  139. package/src/ai/__pycache__/extract-design-tokens.cpython-313.pyc +0 -0
  140. package/src/ai/analyze-structure.py +0 -375
  141. package/src/ai/extract-design-tokens.py +0 -782
  142. package/src/ai/prompts/__init__.py +0 -2
  143. package/src/ai/prompts/__pycache__/__init__.cpython-313.pyc +0 -0
  144. package/src/ai/prompts/__pycache__/design_tokens.cpython-313.pyc +0 -0
  145. package/src/ai/prompts/__pycache__/structure_analysis.cpython-313.pyc +0 -0
  146. package/src/ai/prompts/__pycache__/ux_audit.cpython-313.pyc +0 -0
  147. package/src/ai/prompts/design_tokens.py +0 -316
  148. package/src/ai/prompts/structure_analysis.py +0 -592
  149. package/src/ai/prompts/ux_audit.py +0 -198
  150. package/src/ai/ux-audit.js +0 -596
  151. package/src/core/animation-extractor.js +0 -526
  152. package/src/core/app-state-snapshot.js +0 -511
  153. package/src/core/content-counter.js +0 -342
  154. package/src/core/design-tokens.js +0 -103
  155. package/src/core/dimension-extractor.js +0 -438
  156. package/src/core/dimension-output.js +0 -305
  157. package/src/core/discover-pages.js +0 -542
  158. package/src/core/dom-tree-analyzer.js +0 -298
  159. package/src/core/extract-assets.js +0 -468
  160. package/src/core/filter-css.js +0 -499
  161. package/src/core/framework-detector.js +0 -538
  162. package/src/core/html-extractor.js +0 -212
  163. package/src/core/merge-css.js +0 -407
  164. package/src/core/multi-page-screenshot.js +0 -380
  165. package/src/core/rewrite-links.js +0 -226
  166. package/src/core/screenshot.js +0 -701
  167. package/src/core/section-detector.js +0 -386
  168. package/src/core/semantic-enhancer.js +0 -492
  169. package/src/core/state-capture.js +0 -598
  170. package/src/core/video-capture.js +0 -546
  171. package/src/utils/__init__.py +0 -16
  172. package/src/utils/__pycache__/__init__.cpython-313.pyc +0 -0
  173. package/src/utils/__pycache__/env.cpython-313.pyc +0 -0
  174. package/src/utils/env.py +0 -134
  175. /package/src/core/{css-extractor.js → css/css-extractor.js} +0 -0
  176. /package/src/core/{cookie-handler.js → page-prep/cookie-handler.js} +0 -0
  177. /package/src/core/{page-readiness.js → page-prep/page-readiness.js} +0 -0
@@ -1,309 +1,556 @@
1
- # Codebase Summary
1
+ # Design Clone Codebase Summary
2
+
3
+ **Version:** 3.0.0 (v3.0 Improvement Roadmap Complete)
4
+ **Last Updated:** February 23, 2026
2
5
 
3
6
  ## Overview
4
7
 
5
- Design Clone is a comprehensive design extraction toolkit that captures website designs through multi-viewport screenshots, extracts HTML/CSS, analyzes structure with AI, and enhances semantic HTML for WordPress compatibility.
8
+ Design Clone is a comprehensive design extraction and code generation tool for Claude Code. It captures website designs with multi-viewport screenshots, extracts clean HTML/CSS, and can convert Figma designs to production-ready code.
9
+
10
+ **v3.0 Achievement:** 13 performance and UX improvements across 5 phases: parallel viewport capture fast-path, download concurrency tuning, progress reporting, error diagnostics, dry-run mode, responsive breakpoint detection, asset integrity verification, two-pass CSS filtering, parallel multi-page capture with memory guards, streaming CSS processing, computed style extraction, output quality scoring, and test framework upgrade (c8 coverage).
6
11
 
7
- ## Core Architecture
12
+ ## Key Capabilities
8
13
 
9
- ### Directory Structure
14
+ | Feature | Status | Description |
15
+ |---------|--------|-------------|
16
+ | Multi-viewport screenshots | Active | Desktop (1920px), tablet (768px), mobile (375px), parallel fast-path for headless |
17
+ | HTML/CSS extraction | Active | Clean source with unused CSS removal, streaming processing for 50MB+ |
18
+ | Design token extraction | Active | Automatic color, typography, spacing detection, computed style gap-fill |
19
+ | Figma-to-code conversion | v3.0 | Convert Figma designs to HTML/CSS or Tailwind |
20
+ | Responsive breakpoint detection | v3.0 | Auto-detect @media queries, capture at actual breakpoints |
21
+ | Asset integrity verification | v3.0 | Magic byte validation, SVG sanitization |
22
+ | Dead code CSS filtering | v3.0 | Two-pass removal of @media/@keyframes/unused vars |
23
+ | Hover state capture | Active | Interactive element state documentation |
24
+ | AI structure analysis | Active | Built-in Claude Code vision |
25
+ | Asset extraction | v3.0 | Images, fonts, icons with concurrency tuning (5→10) |
26
+ | Multi-page cloning | v3.0 | Parallel capture with browser context pool, memory guards |
27
+ | Progress reporting | v3.0 | TTY-aware stderr output, discovery + estimate in dry-run |
28
+ | Error diagnostics | v3.0 | Structured error catalog with actionable suggestions |
29
+ | Output quality scoring | v3.0 | 5-metric weighted system (CSS, assets, responsive, HTML, A11y) |
30
+
31
+ ## Architecture Overview
10
32
 
11
33
  ```
12
34
  design-clone/
35
+ ├── bin/ # CLI entry points
36
+ │ ├── cli.js # Main CLI router
37
+ │ └── commands/ # Command implementations
38
+ │ ├── clone-site.js # Multi-page site cloning
39
+ │ ├── init.js # Installation setup
40
+ │ └── verify.js # Verification checks
13
41
  ├── src/
14
- │ ├── core/ # Core extraction & processing modules
15
- │ │ ├── screenshot.js # Multi-viewport screenshot capture
16
- │ │ ├── html-extractor.js # HTML extraction + semantic enhancement
17
- │ │ ├── semantic-enhancer.js # WordPress semantic HTML injection (Phase 3)
18
- │ │ ├── css-extractor.js # CSS extraction & property tracking
19
- │ │ ├── filter-css.js # Unused CSS selector removal
20
- │ │ ├── animation-extractor.js # @keyframes & transition extraction
21
- │ │ ├── state-capture.js # Hover state capture
22
- │ │ ├── extract-assets.js # Image/font/icon downloading
23
- │ │ ├── design-tokens.js # Design token extraction
24
- │ │ ├── dom-tree-analyzer.js # DOM hierarchy for structure analysis
25
- │ │ ├── dimension-extractor.js # Component dimension measurement
26
- │ │ ├── section-cropper.js # Section extraction for AI analysis
27
- │ │ ├── page-readiness.js # Page stability detection
28
- │ │ ├── lazy-loader.js # Lazy loading trigger & wait
29
- ├── cookie-handler.js # Cookie banner dismissal
30
- │ │ ├── content-counter.js # Content statistics
31
- │ │ ├── video-capture.js # Scroll animation recording
32
- │ │ └── app-state-snapshot.js # App state persistence
33
- │ ├── ai/ # AI analysis modules
34
- │ │ ├── ux-audit.js # UX audit runner
35
- │ │ └── prompts/ # AI prompts
36
- │ ├── verification/ # Verification scripts
37
- │ └── utils/ # Shared utilities
38
- │ ├── browser.js # Browser abstraction facade
39
- │ ├── env.js # Environment resolution
40
- │ └── helpers.js # CLI utilities
41
- ├── tests/ # Unit tests
42
- │ ├── test-semantic-enhancer.js # Semantic enhancer tests (59 tests)
43
- └── [other test files]
44
- └── package.json
42
+ │ ├── core/ # Core extraction engines (11 semantic subdirectories)
43
+ │ │ ├── capture/ # Screenshot pipeline (7 modules + index)
44
+ │ │ ├── css/ # CSS processing (7 modules + index)
45
+ │ │ ├── html/ # HTML extraction (5 modules + index)
46
+ │ │ ├── animation/ # Animation & hover states (5 modules + index)
47
+ │ │ ├── discovery/ # Page discovery (6 modules + index)
48
+ │ │ ├── detection/ # Framework detection (3 modules)
49
+ │ │ ├── dimension/ # DOM structure analysis (6 modules + index)
50
+ │ │ ├── section/ # Section detection (5 modules + index)
51
+ │ │ ├── media/ # Video & asset extraction (5 modules + index)
52
+ │ │ ├── page-prep/ # Page readiness (3 modules + index)
53
+ │ │ ├── content/ # Content analysis (2 modules + index)
54
+ │ │ ├── links/ # URL rewriting (2 modules + index)
55
+ │ │ └── tests/ # Core tests (2 modules)
56
+ │ │
57
+ │ ├── figma/ # Figma-to-code integration (Phase 3)
58
+ │ │ ├── parse-url.js # Figma URL parser (Phase 1)
59
+ │ │ ├── figma-client.py # Figma API client (Phase 1)
60
+ │ │ ├── extract-figma.py # Token extraction (Phase 2)
61
+ ├── generate-css.py # BEM CSS generator (Phase 3)
62
+ │ │ └── generate-tailwind.py # Tailwind generator (Phase 3)
63
+ │ │
64
+ │ ├── ai/ # AI analysis (Claude Code vision)
65
+ └── prompts/ # Prompt templates (markdown)
66
+ ├── structure-analysis/ # Layout analysis prompts
67
+ ├── design-tokens/ # Token extraction prompts
68
+ └── ux-audit/ # UX audit prompts
69
+ │ │
70
+ │ ├── verification/ # Quality assurance
71
+ │ ├── verify-menu.js # Navigation validation
72
+ │ │ ├── verify-layout.js # Layout consistency
73
+ │ │ ├── verify-header.js # Header structure
74
+ │ │ ├── verify-footer.js # Footer structure
75
+ │ │ └── [more verifications]
76
+ │ │
77
+ │ ├── post-process/ # Asset enhancement
78
+ │ │ ├── fetch-images.js # Image downloading
79
+ │ │ ├── inject-icons.js # Font Awesome injection
80
+ │ │ ├── inject-gosnap.js # GoSnap widget injection
81
+ │ │ └── enhance-assets.js # Asset optimization (3 steps)
82
+ │ │
83
+ │ ├── route-discoverers/ # Framework-aware routing
84
+ │ │ ├── base-discoverer.js
85
+ │ │ ├── react-discoverer.js
86
+ │ │ ├── vue-discoverer.js
87
+ │ │ ├── angular-discoverer.js
88
+ │ │ ├── svelte-discoverer.js
89
+ │ │ ├── next-discoverer.js
90
+ │ │ ├── nuxt-discoverer.js
91
+ │ │ ├── astro-discoverer.js
92
+ │ │ └── universal-discoverer.js
93
+ │ │
94
+ │ └── utils/ # Shared utilities
95
+ │ ├── browser.js # Playwright browser management
96
+ │ ├── playwright.js # Playwright configuration
97
+ │ ├── env.js / env.py # Environment variable handling
98
+ │ ├── helpers.js
99
+ │ ├── log.js # Centralized logging (NEW Feb 23)
100
+
101
+ ├── templates/ # HTML/CSS base templates
102
+ │ ├── base.html # HTML scaffold
103
+ │ └── base.css # CSS foundation
104
+
105
+ ├── tests/ # Test suite (50+ tests)
106
+ ├── docs/ # Documentation site (VitePress)
107
+ ├── prd/ # Project requirements docs
108
+ ├── landing-page/ # Landing page HTML
109
+ └── SKILL.md # Skill definition for Claude Code
45
110
  ```
46
111
 
47
- ## Key Modules
48
-
49
- ### 1. semantic-enhancer.js (Phase 3)
50
-
51
- **Purpose**: Inject WordPress-compatible semantic IDs, classes, and ARIA roles into extracted HTML while preserving original styling.
52
-
53
- **Key Exports**:
54
- - `SEMANTIC_MAPPINGS` - Mapping definitions for header, nav, main, sidebar, footer, hero
55
- - `detectSectionType(element)` - Detect section type via semantic tags (priority 1), ARIA roles (priority 2), class patterns (priority 3)
56
- - `applySemanticAttributes(element, sectionType, options)` - Add ID/classes/roles to element
57
- - `handleMultipleNavs(navElements, usedIds)` - Handle multiple nav elements with aria-label
58
- - `enhanceSemanticHTML(html, domHierarchy)` - Browser-context enhancement (uses DOMParser)
59
- - `enhanceSemanticHTMLInPage(page, html)` - Playwright-context enhancement (recommended for Node.js)
60
-
61
- **Semantic Mappings**:
62
- ```javascript
63
- header: { id: 'site-header', classes: ['site-header'], role: 'banner' }
64
- nav: { id: 'site-navigation', classes: ['main-navigation', 'nav-menu'], role: 'navigation' }
65
- main: { id: 'main-content', classes: ['site-main', 'content-area'], role: 'main' }
66
- sidebar: { id: 'primary-sidebar', classes: ['widget-area', 'sidebar'], role: 'complementary' }
67
- footer: { id: 'site-footer', classes: ['site-footer'], role: 'contentinfo' }
68
- hero: { id: 'hero-section', classes: ['hero'], role: null }
112
+ ## Phase Overview
113
+
114
+ ### Phase 1: Figma URL Parsing & API Access
115
+ - Parse Figma URLs to extract file_key and node_id
116
+ - Figma REST API authentication and base client
117
+ - Low-level node and style data fetching
118
+
119
+ ### Phase 2: Design Token Extraction
120
+ - Extract colors, typography, spacing, shadows from Figma
121
+ - Download design screenshots
122
+ - Normalize tokens to standard scales
123
+ - Generate CSS custom properties (tokens.css)
124
+
125
+ ### Phase 3: Code Generation (Current)
126
+ - **CSS Mode (default):** BEM naming convention, fully typed CSS
127
+ - **Tailwind Mode:** Utility class mapping, arbitrary value support
128
+ - Design token integration in both modes
129
+ - Output: Production-ready HTML + styling
130
+
131
+ ## Core Modules (Organized by Feature Domain)
132
+
133
+ ### capture/ - Screenshot Pipeline
134
+ Multi-viewport screenshot capture with Playwright (8 modules + browser context pool).
135
+
136
+ **Key Modules:**
137
+ - `screenshot.js` - Multi-viewport capture orchestrator (v3.0: viewport fast-path, breakpoint detection, quality score)
138
+ - `screenshot-helpers.js` - Viewport setup and utilities (v3.0: new CLI flags)
139
+ - `screenshot-extraction.js` - HTML/CSS extraction (v3.0: progress reporting, computed gap-fill, aggressive filter)
140
+ - `screenshot-viewport.js` - Individual viewport capture
141
+ - `screenshot-orchestrator.js` - Batch processing
142
+ - `multi-page-screenshot.js` - Multi-page orchestration (v3.0: context pool parallel, dry-run)
143
+ - `multi-page-screenshot-page.js` - Per-page capture logic
144
+ - `browser-context-pool.js` - Context reuse with memory guards (v3.0 NEW)
145
+
146
+ **Key Functions:**
147
+ - `captureViewports()` - Capture at 3 viewports, fast-path for headless
148
+ - `extractHTML()` - Preserve semantic HTML, remove scripts
149
+ - `extractCSS()` - Full stylesheet extraction, streaming for 50MB+
150
+
151
+ **v3.0 New Flags:**
152
+ - `--detect-breakpoints` - Auto-detect @media queries, capture at breakpoints
153
+ - `--extract-computed` - Fill gaps via getComputedStyle() diffed vs Chromium defaults
154
+ - `--aggressive-filter` - Two-pass CSS dead code removal
155
+ - `--quality-score` - Output 5-metric quality score
156
+ - `--dry-run` - Show discovery + estimate, no capture
157
+
158
+ **Output:** `desktop.png`, `tablet.png`, `mobile.png`, `source.html`, `source.css`, `quality-score.json` (optional)
159
+
160
+ ### css/ - CSS Processing
161
+ Remove unused CSS rules and handle stylesheet optimization (10 modules).
162
+
163
+ **Key Modules:**
164
+ - `filter-css.js` - Main CSS filtering orchestrator (v3.0: error codes, chunked processing, aggressive filter pass)
165
+ - `merge-css.js` - CSS deduplication
166
+ - `filter-css-selector-matcher.js` - Selector matching logic (v3.0: async filterCssRules, dead code pass)
167
+ - `filter-css-html-analyzer.js` - HTML selector extraction
168
+ - `filter-css-atrule-processor.js` - @media/@keyframe handling
169
+ - `filter-css-file-io.js` - File I/O utilities
170
+ - `breakpoint-detector.js` - Parse @media queries, detect actual breakpoints (v3.0 NEW)
171
+ - `filter-css-dead-code.js` - Two-pass removal of unused @media, @keyframes, CSS vars (v3.0 NEW)
172
+ - `css-chunker.js` - Chunk-based streaming for large stylesheets (v3.0 NEW)
173
+ - `computed-style-extractor.js` - getComputedStyle() gap-fill with Chromium defaults (v3.0 NEW)
174
+
175
+ **v3.0 Streaming & Performance:**
176
+ - MAX_CSS_INPUT raised to 50MB (from 500KB)
177
+ - Chunk threshold: 5MB per operation
178
+ - Streaming parser for stylesheets
179
+
180
+ **Process (v3.0):**
181
+ 1. Chunk input CSS if >5MB
182
+ 2. Parse HTML for used selectors
183
+ 3. Analyze CSS rules
184
+ 4. Pass 1: Remove unused declarations
185
+ 5. Pass 2 (if --aggressive-filter): Remove dead @media/@keyframes/unused vars
186
+ 6. (If --extract-computed): Fill gaps via computed styles
187
+ 7. Preserve critical animations
188
+ 8. Output deduplicated CSS
189
+
190
+ **Impact:** 40-60% CSS size reduction on average, up to 80% with aggressive filter
191
+
192
+ ### media/ - Asset Extraction
193
+ Download images, fonts, and icons from websites with integrity verification (6 modules).
194
+
195
+ **Key Modules:**
196
+ - `extract-assets.js` - Orchestrator (v3.0: concurrency flag, asset validation)
197
+ - `extract-assets-downloader.js` - Download logic (v3.0: maxConcurrent 5→10, adaptive 429 throttling with exponential backoff)
198
+ - `extract-assets-page-scraper.js` - Asset discovery
199
+ - `asset-validator.js` - Magic byte validation, SVG sanitization (v3.0 NEW)
200
+ - `video-capture.js` - Video extraction
201
+ - `video-capture-convert.js` - Video conversion
202
+
203
+ **v3.0 Concurrency & Throttling:**
204
+ - maxConcurrent: 5→10 (configurable via --max-concurrent flag)
205
+ - HTTP 429 handling: Exponential backoff (1s, 2s, 4s, 8s)
206
+ - Asset validation prevents corrupted/malicious files
207
+
208
+ **Asset Types:**
209
+ - Images (WebP, JPG, PNG) - validated via magic bytes
210
+ - Web fonts (WOFF2, TTF)
211
+ - Icon sets (SVG, Font Awesome) - SVG sanitized
212
+ - Data URIs (embedded graphics)
213
+ - Videos (MP4, WebM)
214
+
215
+ **Output:** `assets/images/`, `assets/fonts/`, `assets/icons/`, `assets/videos/`
216
+
217
+ ### discovery/ - Page Discovery
218
+ Discover pages and extract navigation patterns (6 modules).
219
+
220
+ **Key Modules:**
221
+ - `discover-pages.js` - Navigation discovery orchestrator
222
+ - `discover-pages-utils.js` - Discovery utilities
223
+ - `discover-pages-routes.js` - Route extraction
224
+ - `app-state-snapshot.js` - State capture
225
+ - `app-state-snapshot-utils.js` - State utilities
226
+ - `app-state-snapshot-capture.js` - Capture logic
227
+
228
+ ### detection/ - Framework Detection
229
+ Detect JavaScript frameworks via global objects and DOM patterns (3 modules).
230
+
231
+ **Key Modules:**
232
+ - `framework-detector.js` - Framework detection orchestrator
233
+ - `framework-detector-signals.js` - Detection signal analysis
234
+ - `framework-detector-routing.js` - Routing pattern detection
235
+
236
+ **Framework Support:** React, Vue, Angular, Svelte, Next.js, Nuxt.js, Astro
237
+
238
+ ### animation/ - Animation & Hover States
239
+ Extract and manage animations and interactive states (5 modules).
240
+
241
+ **Key Modules:**
242
+ - `animation-extractor.js` - Orchestrator
243
+ - `animation-extractor-ast.js` - AST processing
244
+ - `animation-extractor-output.js` - Output generation
245
+ - `state-capture.js` - State capture orchestrator
246
+ - `state-capture-detection.js` - Interactive element detection
247
+
248
+ ### html/ - HTML Processing
249
+ Extract and enhance HTML semantics (5 modules, refactored).
250
+
251
+ **Key Modules:**
252
+ - `html-extractor.js` - Main extractor
253
+ - `html-extractor-inline-styler.js` - Inline style handling
254
+ - `semantic-enhancer.js` - Orchestrator (refactored Feb 23)
255
+ - `semantic-enhancer-page.js` - Per-page enhancement
256
+ - `semantic-enhancer-mappings.js` - Semantic mapping rules
257
+
258
+ **Change (Feb 23):** semantic-enhancer decomposed into 3 modules to reduce duplication across filter-css.js and other modules.
259
+
260
+ ### dimension/ - DOM Structure Analysis
261
+ Analyze layout and dimensional properties (6 modules, refactored).
262
+
263
+ **Key Modules:**
264
+ - `dimension-extractor.js` - Orchestrator (refactored Feb 23)
265
+ - `dimension-extractor-card-detector.js` - Card/component detection
266
+ - `dimension-output.js` - Output formatting
267
+ - `dimension-output-ai-summary.js` - AI-powered summaries
268
+ - `dom-tree-analyzer.js` - DOM tree analysis
269
+ - `dom-tree-analyzer-tree-builders.js` - Tree building logic
270
+
271
+ **Change (Feb 23):** dimension-extractor decomposed into 4 modules + supporting files to reduce code smell and improve maintainability.
272
+
273
+ ### section/ - Section Detection & Cropping
274
+ Detect page sections and generate section-based crops (5 modules).
275
+
276
+ **Key Modules:**
277
+ - `section-detector.js` - Detection orchestrator
278
+ - `section-detector-strategies.js` - Detection algorithms
279
+ - `section-detector-utils.js` - Utility functions
280
+ - `section-cropper.js` - Cropping logic
281
+ - `section-cropper-helpers.js` - Helper functions
282
+
283
+ ### page-prep/ - Page Readiness
284
+ Prepare pages for extraction (3 modules).
285
+
286
+ **Key Modules:**
287
+ - `page-readiness.js` - Readiness checks
288
+ - `cookie-handler.js` - Cookie management
289
+ - `lazy-loader.js` - Lazy loading triggers
290
+
291
+ ### content/ - Content Analysis
292
+ Analyze page content (2 modules).
293
+
294
+ **Key Modules:**
295
+ - `content-counter.js` - Content metrics
296
+ - `content-counter-dom.js` - DOM-based counting
297
+
298
+ ### links/ - Link Rewriting (dormant)
299
+ Link rewriting utilities, not used by current pipelines (2 modules).
300
+
301
+ **Key Modules:**
302
+ - `rewrite-links.js` - Orchestrator
303
+ - `rewrite-links-css-rewriter.js` - CSS link rewriting
304
+
305
+ ### utils/ - Shared Utilities
306
+ Centralized utilities and helpers (v3.0).
307
+
308
+ **Key Modules:**
309
+ - `progress.js` - ProgressReporter class for TTY-aware output (v3.0 NEW)
310
+ - `log.js` - Centralized logging with TTY detection (existing)
311
+ - `browser.js` - Playwright browser management
312
+ - `playwright.js` - Playwright configuration
313
+ - `env.js / env.py` - Environment variable handling
314
+ - `helpers.js` - General utility functions
315
+
316
+ **v3.0 Progress Reporting:**
317
+ - ProgressReporter: TTY-aware, writes to stderr (keeps stdout clean)
318
+ - Tracks: current step, total steps, operation label
319
+ - Methods: start(), step(), complete()
320
+
321
+ ### shared/ - Shared Code
322
+ Cross-module shared definitions.
323
+
324
+ **Key Modules:**
325
+ - `error-codes.js` - DesignCloneError with structured codes (v3.0 NEW)
326
+ - `config.js` - SIZE_LIMITS, CHUNK_THRESHOLD, BROWSER_POOL constants (v3.0: updated limits)
327
+
328
+ **v3.0 Error Catalog:**
329
+ - ERROR_CODES map: CSS_SIZE_EXCEEDED, CSS_PARSE_FAILED, CSS_CORS_BLOCKED, HTML_EXTRACTION_FAILED, ASSET_DOWNLOAD_FAILED, BROWSER_LAUNCH_FAILED, NAV_TIMEOUT, FILE_IO_FAILED, DISCOVERY_FAILED, SCREENSHOT_FAILED, INVALID_ARGS
330
+ - DesignCloneError class: extends Error, includes code + suggestion + context
331
+
332
+ ### verification/ - Quality Assurance
333
+ Quality checks and scoring (v3.0).
334
+
335
+ **Key Modules:**
336
+ - `quality-scorer.js` - 5-metric weighted scoring (v3.0 NEW)
337
+ - `verify-menu.js` - Navigation validation
338
+ - `verify-layout.js` - Layout consistency
339
+ - `verify-header.js` - Header structure
340
+ - `verify-footer.js` - Footer structure
341
+
342
+ **v3.0 Quality Scoring:**
343
+ - Metrics: cssCoverage (30%), assetCompleteness (25%), responsiveFidelity (20%), htmlSemantics (15%), accessibility (10%)
344
+ - Scale: 0-100
345
+ - Auto-runs for clone-px, opt-in for basic clone
346
+
347
+ ### AI Prompt Templates (src/ai/prompts/)
348
+ Claude Code vision-based design analysis via markdown prompt templates.
349
+
350
+ **Categories:**
351
+ - `structure-analysis/` -- Layout and hierarchy analysis (4 variants by context)
352
+ - `design-tokens/` -- Design system extraction (4 variants)
353
+ - `ux-audit/` -- UX quality assessment (3 viewports + aggregation)
354
+
355
+ **Output:** `structure.md`, `design-tokens.json`, `tokens.css`, `ux-audit.json`, `quality-score.json` (v3.0)
356
+
357
+ ### figma/extract-figma.py (Phase 2)
358
+ Extract design system from Figma files.
359
+
360
+ **Pipeline:**
361
+ 1. Parse Figma URL → extract file_key, node_id
362
+ 2. Authenticate with FIGMA_ACCESS_TOKEN
363
+ 3. Fetch file data via REST API
364
+ 4. Extract nodes, styles, components
365
+ 5. Normalize to design tokens
366
+ 6. Generate design-tokens.json and tokens.css
367
+
368
+ **Output:**
369
+ - `figma-export.png` - Screenshot
370
+ - `figma-nodes.json` - Raw nodes
371
+ - `design-tokens.json` - Structured tokens
372
+ - `tokens.css` - CSS variables
373
+
374
+ ### figma/generate-css.py (Phase 3)
375
+ Generate semantic HTML with BEM CSS.
376
+
377
+ **BEM Convention:**
378
+ - Block: `.component-name`
379
+ - Element: `.component-name__element`
380
+ - Modifier: `.component-name--modifier`
381
+
382
+ **Process:**
383
+ 1. Read figma-nodes.json and design-tokens.json
384
+ 2. Traverse node hierarchy
385
+ 3. Generate semantic HTML with BEM classes
386
+ 4. Create CSS rules using design tokens as variables
387
+ 5. Output index.html and styles.css
388
+
389
+ ### figma/generate-tailwind.py (Phase 3)
390
+ Generate HTML with Tailwind utility classes.
391
+
392
+ **Mapping Strategy:**
393
+ 1. Match values to Tailwind default scale
394
+ 2. Use arbitrary values `[value]` for custom matches
395
+ 3. Generate tailwind.config.js extensions if needed
396
+ 4. Preserve semantic HTML structure
397
+
398
+ **Process:**
399
+ 1. Read figma-nodes.json and design-tokens.json
400
+ 2. Build Tailwind class mapping table
401
+ 3. Generate HTML with utility classes
402
+ 4. Output index.html (optional tailwind.config.js)
403
+
404
+ ### enhance-assets.js (Post-Processing Orchestrator)
405
+ Manages 3-step asset enhancement pipeline.
406
+
407
+ **Steps:**
408
+ 1. **Fetch Images** - Download real images from Unsplash (requires UNSPLASH_ACCESS_KEY)
409
+ 2. **Inject Icons** - Replace placeholders with Japanese-style SVG icons
410
+ 3. **Inject GoSnap** - Add gosnap-widget Web Component (clone-px only)
411
+
412
+ **Flags:**
413
+ - `--skip-images` - Skip image fetching
414
+ - `--skip-icons` - Skip icon injection
415
+ - `--skip-gosnap` - Skip gosnap-widget injection
416
+
417
+ ### inject-gosnap.js
418
+ Injects gosnap-widget Web Component into HTML files.
419
+
420
+ **Features:**
421
+ - Scans HTML directory for HTML files
422
+ - Adds `<go-snap>` element with embed script before `</body>`
423
+ - Idempotent (skips files that already contain widget)
424
+ - Supports position, theme, and persist configuration
425
+
426
+ **Output:**
427
+ - `<script src="https://unpkg.com/gosnap-widget@1.0.1/dist/embed.global.js"></script>`
428
+ - `<go-snap position="bottom-right" theme="dark" persist></go-snap>`
429
+
430
+ ## Workflow Integration
431
+
432
+ ### /design:clone (Basic)
69
433
  ```
70
-
71
- **Detection Priority**:
72
- 1. Semantic HTML tags (header, nav, main, aside, footer)
73
- 2. ARIA role attributes (banner, navigation, main, complementary, contentinfo)
74
- 3. Class pattern matching (header, nav, main, sidebar, footer, hero)
75
-
76
- **Rules**:
77
- - Add ID only if none exists (avoid duplicates)
78
- - Append classes (never replace existing)
79
- - Set role only if not present
80
- - Handle multiple navs with proper aria-label (Primary Menu, Footer Menu, etc.)
81
-
82
- ### 2. html-extractor.js (Modified)
83
-
84
- **New Function**: `extractAndEnhanceHtml(page, options)`
85
-
86
- Extracts clean HTML and optionally applies semantic enhancement via semantic-enhancer.js.
87
-
88
- **Options**:
89
- ```javascript
90
- {
91
- enhanceSemantic: true, // Enable semantic enhancement (default: true)
92
- frameworkPatterns: [...] // Custom framework patterns to remove
93
- }
434
+ URL → Screenshot 3 viewports (fast-path for headless) → Extract HTML/CSS (streaming) → Filter CSS (chunked) → Output
94
435
  ```
436
+ **Time:** ~8-12 seconds (v3.0: faster with fast-path)
95
437
 
96
- **Returns**:
97
- ```javascript
98
- {
99
- html: string, // Enhanced HTML
100
- warnings: string[], // Processing warnings
101
- elementCount: number, // DOM element count
102
- semanticStats: { // Only if enhanceSemantic=true
103
- sectionsEnhanced: number,
104
- idsAdded: number,
105
- classesAdded: number,
106
- rolesAdded: number,
107
- warnings: string[]
108
- }
109
- }
438
+ ### /design:clone-px (Pixel-Perfect)
110
439
  ```
111
-
112
- **Existing Functions**:
113
- - `extractCleanHtml(page, frameworkPatterns)` - Remove scripts, event handlers, framework attributes
114
-
115
- ### 3. screenshot.js (Modified)
116
-
117
- **New Flag**: `--no-semantic`
118
-
119
- Disable WordPress semantic HTML enhancement in extracted HTML. By default, semantic enhancement is enabled.
120
-
121
- **Usage**:
122
- ```bash
123
- node src/core/screenshot.js --url https://example.com --output ./out --extract-html --no-semantic
440
+ URL → Screenshot 3 viewports → Extract HTML/CSS → Filter CSS
441
+ Extract assets (concurrency 10) → Asset validation → AI analysis → Design tokens → Verify menu → Quality score → Output
124
442
  ```
443
+ **Time:** ~50-90 seconds (v3.0: improved with parallel context pool, optimized download)
125
444
 
126
- ### 4. multi-page-screenshot.js (Modified)
127
-
128
- Uses `extractAndEnhanceHtml()` instead of separate extraction steps.
129
-
130
- ## Processing Pipeline
131
-
132
- ### Multi-Viewport Screenshot Flow
133
-
445
+ ### /design:clone-site (Multi-Page)
134
446
  ```
135
- Input URL
136
- ├─ Desktop (1440x900)
137
- ├─ Tablet (768x1024)
138
- └─ Mobile (375x812)
139
-
140
- ├── Wait for page readiness (DOM stable, fonts loaded, styles stable)
141
- ├── Dismiss cookie banners
142
- ├── Trigger lazy loading
143
- ├── Force lazy images visible
144
- ├── Capture screenshots
145
-
146
- ├── Optional: Extract HTML
147
- │ ├─ Clean HTML (remove scripts, framework attrs)
148
- │ └─ Semantic enhance (add WordPress IDs/classes/roles)
149
-
150
- ├── Optional: Extract CSS
151
- │ ├─ Collect all stylesheet rules
152
- │ ├─ Extract @keyframes & transitions
153
- │ └─ Filter unused selectors
154
-
155
- ├── Optional: Capture hover states
156
- │ ├─ Identify interactive elements
157
- │ ├─ Screenshot before/during hover
158
- │ └─ Generate :hover CSS rules
159
-
160
- └── Output: Screenshots + metadata
161
-
162
- Output Files
163
- ├── desktop.png, tablet.png, mobile.png
164
- ├── source.html (cleaned + optionally semantically enhanced)
165
- ├── source.css, source-raw.css
166
- ├── animations.css, animation-tokens.json
167
- ├── hover.css (if --capture-hover)
168
- ├── structure.md (if GEMINI_API_KEY set)
169
- └── tokens.json
170
- ```
171
-
172
- ## Testing
173
-
174
- ### Test Files
175
-
176
- - `tests/test-semantic-enhancer.js` - 59 unit tests covering:
177
- - SEMANTIC_MAPPINGS exports
178
- - Section type detection (header, nav, main, sidebar, footer, hero)
179
- - Semantic attribute application
180
- - Multiple nav handling with aria-labels
181
- - HTML enhancement stats
182
- - Page.evaluate integration
183
-
184
- **Run Tests**:
185
- ```bash
186
- node tests/test-semantic-enhancer.js
447
+ URL → Discover pages (with progress) → Parallel context pool capture → Merge CSS → Generate manifest → Output
187
448
  ```
449
+ **Time:** ~1-3 minutes (v3.0: faster with parallel contexts, memory guards)
188
450
 
189
- ## Data Flow
190
-
191
- ### Semantic Enhancement Data Flow
451
+ **v3.0 Additions (Opt-In):**
452
+ - `--detect-breakpoints` - Detect @media queries, capture at actual breakpoints
453
+ - `--aggressive-filter` - Two-pass CSS dead code removal
454
+ - `--extract-computed` - Gap-fill via computed styles
455
+ - `--quality-score` - Output quality metrics
456
+ - `--dry-run` - Show discovery + estimate (no capture)
192
457
 
458
+ ### /design:figma-to-code (Figma Conversion)
193
459
  ```
194
- extractAndEnhanceHtml()
195
- ├─ extractCleanHtml(page)
196
- │ └─ page.evaluate()
197
- │ ├─ Clone document
198
- │ ├─ Remove scripts/noscript
199
- │ ├─ Remove malicious CSS links
200
- │ ├─ Remove event handlers
201
- │ ├─ Remove framework attributes
202
- │ ├─ Inline critical layout styles
203
- │ └─ Return cleaned HTML + warnings
204
-
205
- └─ enhanceSemanticHTMLInPage(page, html)
206
- └─ page.evaluate(enhancementLogic)
207
- ├─ Parse HTML with DOMParser
208
- ├─ Detect sections (semantic tags → ARIA roles → class patterns)
209
- ├─ Apply IDs/classes/roles
210
- ├─ Handle multiple navs with aria-labels
211
- ├─ Detect hero sections
212
- └─ Return enhanced HTML + stats
460
+ Figma URL → Parse URL → Extract nodes & tokens → Generate HTML+CSS/Tailwind → Output
213
461
  ```
214
-
215
- ## Configuration & Environment
216
-
217
- ### CLI Options (screenshot.js)
218
-
219
- | Option | Default | Phase | Description |
220
- |--------|---------|-------|-------------|
221
- | --url | required | - | Target URL |
222
- | --output | required | - | Output directory |
223
- | --viewports | all | - | Comma-separated viewport names |
224
- | --full-page | true | - | Capture full page height |
225
- | --max-size | 5 | - | Max file size (MB) before compression |
226
- | --headless | false | - | Run in headless mode |
227
- | --scroll-delay | 1500 | - | Pause time (ms) between scroll steps |
228
- | --extract-html | false | - | Extract cleaned HTML |
229
- | --extract-css | false | - | Extract CSS |
230
- | --filter-unused | true | - | Filter unused CSS selectors |
231
- | --capture-hover | false | 2 | Capture hover states |
232
- | --section-mode | false | - | Enable section-based capture |
233
- | --no-semantic | false | 3 | Disable semantic HTML enhancement |
234
- | --video | false | - | Record scroll animation |
235
-
236
- ### Environment Variables
237
-
238
- ```bash
239
- GEMINI_API_KEY=... # For AI structure analysis
240
- ```
241
-
242
- ## Design Patterns
243
-
244
- ### Error Handling
245
-
246
- All modules use try-catch with warning accumulation. Failed processing steps return partial results rather than throwing.
247
-
248
- ### Idempotency
249
-
250
- Semantic enhancement is idempotent—running on already-enhanced HTML produces same result (IDs/classes/roles already present are skipped).
251
-
252
- ### Performance
253
-
254
- - Combined landmark selector reduces querySelectorAll calls (8 → 1)
255
- - Processed element tracking prevents double-counting from overlapping selectors
256
- - Index-based element matching for reliability during DOM cloning
257
-
258
- ### Validation
259
-
260
- - Input validation on HTML strings (non-empty, valid string type)
261
- - Browser context validation (DOMParser vs page.evaluate)
262
- - ID uniqueness tracking with usedIds Set
263
- - DOM size warnings (>50k elements)
264
-
265
- ## Version History
266
-
267
- ### Phase 1
268
- - Multi-viewport screenshots
269
- - HTML/CSS extraction
270
- - Asset extraction
271
-
272
- ### Phase 2
273
- - Hover state capture
274
- - UX audit with Gemini
275
- - Design token extraction
276
- - DOM tree analysis
277
-
278
- ### Phase 3
279
- - WordPress semantic HTML enhancement (CURRENT)
280
- - Semantic ID/class/role injection
281
- - ARIA landmark support
282
- - Multiple nav handling
283
-
284
- ## Integration Points
285
-
286
- ### With screenshot.js
287
- - New `--no-semantic` flag to disable enhancement
288
- - Automatic semantic enhancement when extracting HTML (unless disabled)
289
-
290
- ### With html-extractor.js
291
- - New `extractAndEnhanceHtml()` function wraps extraction + enhancement
292
- - `enhanceSemantic` option controls semantic injection
293
-
294
- ### With multi-page-screenshot.js
295
- - Uses `extractAndEnhanceHtml()` for HTML extraction
296
-
297
- ## Dependencies
298
-
299
- - **playwright** - Browser automation
300
- - **sharp** - Image compression (optional)
301
- - **google-genai** - AI analysis (optional, for Phase 2 features)
302
-
303
- ## Limitations & Considerations
304
-
305
- 1. **Browser Context Required**: `enhanceSemanticHTML()` requires DOMParser (browser). Use `enhanceSemanticHTMLInPage()` for Playwright.
306
- 2. **Non-Invasive**: Semantic enhancement never removes existing attributes, only adds/appends.
307
- 3. **False Positive Prevention**: Class pattern detection limited to container elements (div, section, article) to avoid false positives.
308
- 4. **Multiple Landing Pages**: Each nav gets unique aria-label (Primary Menu, Footer Menu, Navigation 2, etc.)
309
- 5. **Hero Section Detection**: Only top-level hero elements (not within header/footer) are detected.
462
+ **Time:** ~5-10 seconds
463
+
464
+ ## Environment Variables
465
+
466
+ **Required:**
467
+ - `FIGMA_ACCESS_TOKEN` - Figma API access (Phase 3)
468
+
469
+ **Optional:**
470
+ - `CHROME_PATH` - Chrome/Chromium binary path
471
+ - `PLAYWRIGHT_BROWSERS_PATH` - Playwright browser cache location
472
+
473
+ ## Technology Stack
474
+
475
+ | Layer | Technology | Purpose |
476
+ |-------|-----------|---------|
477
+ | CLI | Node.js, yargs | Command-line interface |
478
+ | Browsers | Playwright (dependency) | Multi-browser automation |
479
+ | Parsing | cheerio, jsdom | HTML/DOM manipulation |
480
+ | CSS | PostCSS, PurgeCSS | CSS processing |
481
+ | AI | Claude Code Vision (built-in) | Design analysis |
482
+ | Python | Python 3.9+ | Figma processing |
483
+ | Templates | HTML5, CSS3 | Output templates |
484
+ | Logging | log.js (TTY-aware) | Centralized output (NEW Feb 23) |
485
+
486
+ ## Quality Standards
487
+
488
+ ### Code Quality
489
+ - Modular architecture (single responsibility)
490
+ - Comprehensive error handling
491
+ - Environment variable validation
492
+ - Type hints in Python, JSDoc in JavaScript
493
+
494
+ ### Output Quality
495
+ - Semantic HTML5 structure
496
+ - Valid CSS (no vendor prefixes unless needed)
497
+ - Responsive design patterns (mobile-first)
498
+ - Accessibility compliance (WCAG 2.1)
499
+ - Japanese design principles (Ma, Kanso, Shibui, Seijaku)
500
+
501
+ ### Testing
502
+ - 50+ unit and integration tests
503
+ - Screenshot regression testing
504
+ - HTML/CSS validation
505
+ - Accessibility checks (axe-core)
506
+
507
+ ## Performance Characteristics
508
+
509
+ | Operation | Time | Variables |
510
+ |-----------|------|-----------|
511
+ | Single screenshot | 3-5s | Network latency, page size |
512
+ | Multi-viewport (3x) | 8-12s | Asset count, JavaScript |
513
+ | CSS filtering | 1-2s | Stylesheet size |
514
+ | Asset extraction | 15-45s | Image count, sizes |
515
+ | AI analysis | 10-20s | Screenshot quality, API latency |
516
+ | Figma extraction | 5-10s | Design complexity |
517
+
518
+ ## Maintenance & Updates
519
+
520
+ **Regular Updates:**
521
+ - Font Awesome 6 CDN (hardcoded, update quarterly)
522
+ - Unsplash API (direct URL format, no auth needed)
523
+ - Tailwind CSS scale mappings (update with major versions)
524
+
525
+ **Breaking Changes:**
526
+ - Phase 3 added `generate-css.py` and `generate-tailwind.py`
527
+ - Figma output structure now includes `analysis/` subdirectory
528
+ - FIGMA_ACCESS_TOKEN now required for /design:figma-to-code
529
+
530
+ ## Known Limitations
531
+
532
+ 1. **Figma:** Only works with public links or files user has access to
533
+ 2. **Screenshots:** Limited by browser automation capabilities
534
+ 3. **CSS:** Cannot extract stylesheet origin (external vs inline)
535
+ 4. **Assets:** Some CDN images may be blocked by CORS
536
+ 5. **JavaScript:** Dynamic content may not be fully captured
537
+
538
+ ## Future Roadmap
539
+
540
+ - [ ] Phase 4: Component library generation from Figma
541
+ - [ ] Storybook integration for component documentation
542
+ - [ ] Real-time Figma file synchronization
543
+ - [ ] Design system validation and enforcement
544
+ - [ ] Advanced CSS variable mapping for complex designs
545
+ - [ ] Video animation extraction and documentation
546
+
547
+ ## Contributing
548
+
549
+ The codebase follows these principles:
550
+ - **Modularity:** Each script has single responsibility
551
+ - **Error Handling:** Graceful failures with clear messages
552
+ - **Documentation:** Code comments for complex logic
553
+ - **Testing:** New features include tests
554
+ - **Performance:** Optimize for speed without sacrificing quality
555
+
556
+ See contributing guidelines in root CONTRIBUTING.md.