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.
- package/README.md +13 -34
- package/SKILL.md +69 -45
- package/bin/cli.js +22 -4
- package/bin/commands/clone-site.js +31 -171
- package/bin/commands/help.js +19 -6
- package/bin/commands/init.js +9 -86
- package/bin/commands/uninstall.js +105 -0
- package/bin/commands/update.js +70 -0
- package/bin/commands/verify.js +7 -14
- package/bin/utils/paths.js +28 -0
- package/bin/utils/validate.js +2 -22
- package/bin/utils/version.js +23 -0
- package/docs/code-standards.md +789 -0
- package/docs/codebase-summary.md +533 -286
- package/docs/index.md +74 -0
- package/docs/project-overview-pdr.md +797 -0
- package/docs/system-architecture.md +718 -0
- package/package.json +14 -17
- package/src/ai/prompts/design-tokens/basic.md +80 -0
- package/src/ai/prompts/design-tokens/section-with-css.md +41 -0
- package/src/ai/prompts/design-tokens/section.md +48 -0
- package/src/ai/prompts/design-tokens/with-css.md +87 -0
- package/src/ai/prompts/structure-analysis/basic.md +55 -0
- package/src/ai/prompts/structure-analysis/with-context.md +59 -0
- package/src/ai/prompts/structure-analysis/with-dimensions.md +63 -0
- package/src/ai/prompts/structure-analysis/with-hierarchy.md +73 -0
- package/src/ai/prompts/ux-audit/aggregation.md +42 -0
- package/src/ai/prompts/ux-audit/desktop.md +92 -0
- package/src/ai/prompts/ux-audit/mobile.md +93 -0
- package/src/ai/prompts/ux-audit/tablet.md +92 -0
- package/src/core/animation/animation-extractor-ast.js +183 -0
- package/src/core/animation/animation-extractor-output.js +152 -0
- package/src/core/animation/animation-extractor.js +178 -0
- package/src/core/animation/state-capture-detection.js +200 -0
- package/src/core/animation/state-capture.js +193 -0
- package/src/core/capture/browser-context-pool.js +96 -0
- package/src/core/capture/multi-page-screenshot-page.js +110 -0
- package/src/core/capture/multi-page-screenshot.js +208 -0
- package/src/core/capture/screenshot-extraction.js +186 -0
- package/src/core/capture/screenshot-helpers.js +175 -0
- package/src/core/capture/screenshot-orchestrator.js +174 -0
- package/src/core/capture/screenshot-viewport.js +93 -0
- package/src/core/capture/screenshot.js +192 -0
- package/src/core/content/content-counter-dom.js +191 -0
- package/src/core/content/content-counter.js +76 -0
- package/src/core/css/breakpoint-detector.js +66 -0
- package/src/core/css/chromium-defaults.json +23 -0
- package/src/core/css/computed-style-extractor.js +102 -0
- package/src/core/css/css-chunker.js +103 -0
- package/src/core/css/filter-css-dead-code.js +120 -0
- package/src/core/css/filter-css-html-analyzer.js +110 -0
- package/src/core/css/filter-css-selector-matcher.js +172 -0
- package/src/core/css/filter-css.js +206 -0
- package/src/core/css/merge-css-atrule-processor.js +158 -0
- package/src/core/css/merge-css-file-io.js +68 -0
- package/src/core/css/merge-css.js +148 -0
- package/src/core/detection/framework-detector-routing.js +68 -0
- package/src/core/detection/framework-detector-signals.js +65 -0
- package/src/core/detection/framework-detector.js +198 -0
- package/src/core/dimension/dimension-extractor-card-detector.js +82 -0
- package/src/core/dimension/dimension-extractor.js +317 -0
- package/src/core/dimension/dimension-output-ai-summary.js +111 -0
- package/src/core/dimension/dimension-output.js +173 -0
- package/src/core/dimension/dom-tree-analyzer-tree-builders.js +95 -0
- package/src/core/dimension/dom-tree-analyzer.js +191 -0
- package/src/core/discovery/app-state-snapshot-capture.js +195 -0
- package/src/core/discovery/app-state-snapshot-utils.js +178 -0
- package/src/core/discovery/app-state-snapshot.js +131 -0
- package/src/core/discovery/discover-pages-routes.js +84 -0
- package/src/core/discovery/discover-pages-utils.js +177 -0
- package/src/core/discovery/discover-pages.js +191 -0
- package/src/core/html/html-extractor-inline-styler.js +70 -0
- package/src/core/html/html-extractor.js +147 -0
- package/src/core/html/semantic-enhancer-mappings.js +200 -0
- package/src/core/html/semantic-enhancer-page.js +148 -0
- package/src/core/html/semantic-enhancer.js +135 -0
- package/src/core/links/rewrite-links-css-rewriter.js +53 -0
- package/src/core/links/rewrite-links.js +173 -0
- package/src/core/media/asset-validator.js +118 -0
- package/src/core/media/extract-assets-downloader.js +187 -0
- package/src/core/media/extract-assets-page-scraper.js +115 -0
- package/src/core/media/extract-assets.js +159 -0
- package/src/core/media/video-capture-convert.js +200 -0
- package/src/core/media/video-capture.js +201 -0
- package/src/core/{lazy-loader.js → page-prep/lazy-loader.js} +37 -39
- package/src/core/section/section-cropper-helpers.js +43 -0
- package/src/core/{section-cropper.js → section/section-cropper.js} +11 -88
- package/src/core/section/section-detector-strategies.js +139 -0
- package/src/core/section/section-detector-utils.js +100 -0
- package/src/core/section/section-detector.js +88 -0
- package/src/core/tests/test-section-cropper.js +2 -2
- package/src/core/tests/test-section-detector.js +2 -2
- package/src/post-process/enhance-assets.js +29 -4
- package/src/post-process/fetch-images-unsplash-client.js +123 -0
- package/src/post-process/fetch-images.js +60 -263
- package/src/post-process/inject-gosnap.js +88 -0
- package/src/post-process/inject-icons-svg-replacer.js +76 -0
- package/src/post-process/inject-icons.js +47 -200
- package/src/route-discoverers/base-discoverer-utils.js +137 -0
- package/src/route-discoverers/base-discoverer.js +29 -118
- package/src/route-discoverers/index.js +1 -1
- package/src/shared/config.js +38 -0
- package/src/shared/error-codes.js +31 -0
- package/src/shared/viewports.js +46 -0
- package/src/utils/browser.js +0 -7
- package/src/utils/helpers.js +4 -0
- package/src/utils/log.js +12 -0
- package/src/utils/playwright-loader.js +76 -0
- package/src/utils/playwright.js +3 -69
- package/src/utils/progress.js +32 -0
- package/src/verification/generate-audit-report-css-fixes.js +52 -0
- package/src/verification/generate-audit-report-sections.js +158 -0
- package/src/verification/generate-audit-report.js +5 -281
- package/src/verification/quality-scorer.js +92 -0
- package/src/verification/verify-footer-checks.js +103 -0
- package/src/verification/verify-footer-helpers.js +178 -0
- package/src/verification/verify-footer.js +23 -381
- package/src/verification/verify-header-checks.js +104 -0
- package/src/verification/verify-header-helpers.js +156 -0
- package/src/verification/verify-header.js +23 -365
- package/src/verification/verify-layout-report.js +101 -0
- package/src/verification/verify-layout.js +13 -259
- package/src/verification/verify-menu-checks.js +104 -0
- package/src/verification/verify-menu-helpers.js +112 -0
- package/src/verification/verify-menu.js +17 -285
- package/src/verification/verify-slider-checks.js +115 -0
- package/src/verification/verify-slider-constants.js +65 -0
- package/src/verification/verify-slider-helpers.js +164 -0
- package/src/verification/verify-slider.js +23 -414
- package/.env.example +0 -14
- package/docs/basic-clone.md +0 -63
- package/docs/cli-reference.md +0 -316
- package/docs/design-clone-architecture.md +0 -492
- package/docs/pixel-perfect.md +0 -117
- package/docs/project-roadmap.md +0 -382
- package/docs/troubleshooting.md +0 -170
- package/requirements.txt +0 -5
- package/src/ai/__pycache__/analyze-structure.cpython-313.pyc +0 -0
- package/src/ai/__pycache__/extract-design-tokens.cpython-313.pyc +0 -0
- package/src/ai/analyze-structure.py +0 -375
- package/src/ai/extract-design-tokens.py +0 -782
- package/src/ai/prompts/__init__.py +0 -2
- package/src/ai/prompts/__pycache__/__init__.cpython-313.pyc +0 -0
- package/src/ai/prompts/__pycache__/design_tokens.cpython-313.pyc +0 -0
- package/src/ai/prompts/__pycache__/structure_analysis.cpython-313.pyc +0 -0
- package/src/ai/prompts/__pycache__/ux_audit.cpython-313.pyc +0 -0
- package/src/ai/prompts/design_tokens.py +0 -316
- package/src/ai/prompts/structure_analysis.py +0 -592
- package/src/ai/prompts/ux_audit.py +0 -198
- package/src/ai/ux-audit.js +0 -596
- package/src/core/animation-extractor.js +0 -526
- package/src/core/app-state-snapshot.js +0 -511
- package/src/core/content-counter.js +0 -342
- package/src/core/design-tokens.js +0 -103
- package/src/core/dimension-extractor.js +0 -438
- package/src/core/dimension-output.js +0 -305
- package/src/core/discover-pages.js +0 -542
- package/src/core/dom-tree-analyzer.js +0 -298
- package/src/core/extract-assets.js +0 -468
- package/src/core/filter-css.js +0 -499
- package/src/core/framework-detector.js +0 -538
- package/src/core/html-extractor.js +0 -212
- package/src/core/merge-css.js +0 -407
- package/src/core/multi-page-screenshot.js +0 -380
- package/src/core/rewrite-links.js +0 -226
- package/src/core/screenshot.js +0 -701
- package/src/core/section-detector.js +0 -386
- package/src/core/semantic-enhancer.js +0 -492
- package/src/core/state-capture.js +0 -598
- package/src/core/video-capture.js +0 -546
- package/src/utils/__init__.py +0 -16
- package/src/utils/__pycache__/__init__.cpython-313.pyc +0 -0
- package/src/utils/__pycache__/env.cpython-313.pyc +0 -0
- package/src/utils/env.py +0 -134
- /package/src/core/{css-extractor.js → css/css-extractor.js} +0 -0
- /package/src/core/{cookie-handler.js → page-prep/cookie-handler.js} +0 -0
- /package/src/core/{page-readiness.js → page-prep/page-readiness.js} +0 -0
package/docs/codebase-summary.md
CHANGED
|
@@ -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
|
|
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
|
-
##
|
|
12
|
+
## Key Capabilities
|
|
8
13
|
|
|
9
|
-
|
|
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/
|
|
15
|
-
│ │ ├──
|
|
16
|
-
│ │ ├──
|
|
17
|
-
│ │ ├──
|
|
18
|
-
│ │ ├──
|
|
19
|
-
│ │ ├──
|
|
20
|
-
│ │ ├──
|
|
21
|
-
│ │ ├──
|
|
22
|
-
│ │ ├──
|
|
23
|
-
│ │ ├──
|
|
24
|
-
│ │ ├──
|
|
25
|
-
│ │ ├──
|
|
26
|
-
│ │ ├──
|
|
27
|
-
│ │
|
|
28
|
-
│ │
|
|
29
|
-
│
|
|
30
|
-
│ │ ├──
|
|
31
|
-
│ │ ├──
|
|
32
|
-
│ │
|
|
33
|
-
│ ├──
|
|
34
|
-
│ │
|
|
35
|
-
│ │
|
|
36
|
-
│ ├──
|
|
37
|
-
│ └──
|
|
38
|
-
│ ├──
|
|
39
|
-
│ ├──
|
|
40
|
-
│ └──
|
|
41
|
-
|
|
42
|
-
│ ├──
|
|
43
|
-
│
|
|
44
|
-
|
|
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
|
-
##
|
|
48
|
-
|
|
49
|
-
### 1
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
-
|
|
56
|
-
-
|
|
57
|
-
-
|
|
58
|
-
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
**
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
###
|
|
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
|
-
|
|
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
|
-
|
|
190
|
-
|
|
191
|
-
|
|
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
|
-
|
|
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
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
|
228
|
-
|
|
229
|
-
|
|
|
230
|
-
|
|
|
231
|
-
|
|
|
232
|
-
|
|
|
233
|
-
|
|
|
234
|
-
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
-
|
|
255
|
-
-
|
|
256
|
-
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
-
|
|
274
|
-
-
|
|
275
|
-
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
-
|
|
280
|
-
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
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.
|