design-clone 1.2.0 → 2.1.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 +26 -12
- package/bin/commands/clone-site.js +75 -10
- package/bin/commands/init.js +33 -1
- package/bin/commands/verify.js +5 -3
- package/bin/utils/validate.js +24 -8
- package/docs/cli-reference.md +200 -2
- package/docs/codebase-summary.md +309 -0
- package/docs/design-clone-architecture.md +259 -42
- package/docs/pixel-perfect.md +35 -4
- package/docs/project-roadmap.md +382 -0
- package/docs/troubleshooting.md +5 -4
- package/package.json +10 -8
- 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 +73 -3
- package/src/ai/extract-design-tokens.py +356 -13
- 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 +133 -0
- package/src/ai/prompts/structure_analysis.py +329 -10
- package/src/ai/prompts/ux_audit.py +198 -0
- package/src/ai/ux-audit.js +596 -0
- package/src/core/app-state-snapshot.js +511 -0
- package/src/core/content-counter.js +342 -0
- package/src/core/cookie-handler.js +1 -1
- package/src/core/css-extractor.js +4 -4
- package/src/core/dimension-extractor.js +93 -21
- package/src/core/dimension-output.js +103 -6
- package/src/core/discover-pages.js +242 -14
- package/src/core/dom-tree-analyzer.js +298 -0
- package/src/core/extract-assets.js +1 -1
- package/src/core/framework-detector.js +538 -0
- package/src/core/html-extractor.js +45 -4
- package/src/core/lazy-loader.js +7 -7
- package/src/core/multi-page-screenshot.js +9 -6
- package/src/core/page-readiness.js +8 -8
- package/src/core/screenshot.js +138 -9
- package/src/core/section-cropper.js +209 -0
- package/src/core/section-detector.js +386 -0
- package/src/core/semantic-enhancer.js +492 -0
- package/src/core/state-capture.js +18 -22
- package/src/core/tests/test-section-cropper.js +177 -0
- package/src/core/tests/test-section-detector.js +55 -0
- package/src/core/video-capture.js +152 -146
- package/src/route-discoverers/angular-discoverer.js +157 -0
- package/src/route-discoverers/astro-discoverer.js +123 -0
- package/src/route-discoverers/base-discoverer.js +242 -0
- package/src/route-discoverers/index.js +106 -0
- package/src/route-discoverers/next-discoverer.js +130 -0
- package/src/route-discoverers/nuxt-discoverer.js +138 -0
- package/src/route-discoverers/react-discoverer.js +139 -0
- package/src/route-discoverers/svelte-discoverer.js +109 -0
- package/src/route-discoverers/universal-discoverer.js +227 -0
- package/src/route-discoverers/vue-discoverer.js +118 -0
- package/src/utils/__init__.py +1 -1
- package/src/utils/__pycache__/__init__.cpython-313.pyc +0 -0
- package/src/utils/browser.js +11 -37
- package/src/utils/playwright.js +213 -0
- package/src/verification/generate-audit-report.js +398 -0
- package/src/verification/verify-footer.js +493 -0
- package/src/verification/verify-header.js +486 -0
- package/src/verification/verify-layout.js +2 -2
- package/src/verification/verify-menu.js +4 -20
- package/src/verification/verify-slider.js +533 -0
- package/src/utils/puppeteer.js +0 -281
|
@@ -10,16 +10,22 @@ design-clone/
|
|
|
10
10
|
├── bin/ # npm CLI tool
|
|
11
11
|
│ ├── cli.js
|
|
12
12
|
│ ├── commands/
|
|
13
|
+
│ │ └── clone-site.js # Multi-page clone with integrated UX audit (Phase 2)
|
|
13
14
|
│ └── utils/
|
|
14
15
|
├── src/
|
|
15
16
|
│ ├── core/ # Core scripts
|
|
16
17
|
│ ├── ai/ # AI analysis
|
|
18
|
+
│ │ ├── prompts/
|
|
19
|
+
│ │ │ └── ux_audit.py # UX audit prompts (Phase 2)
|
|
20
|
+
│ │ └── ux-audit.js # UX audit runner with Gemini Vision (Phase 2)
|
|
17
21
|
│ ├── verification/ # Verification scripts
|
|
18
22
|
│ ├── post-process/ # Post-processing
|
|
19
23
|
│ └── utils/ # Shared utilities
|
|
20
24
|
├── docs/ # Documentation
|
|
21
25
|
├── templates/ # Output templates
|
|
22
|
-
|
|
26
|
+
├── tests/
|
|
27
|
+
│ └── test-ux-audit.js # UX audit module tests (Phase 2)
|
|
28
|
+
└── package.json # Now includes @google/generative-ai optionalDependency
|
|
23
29
|
```
|
|
24
30
|
|
|
25
31
|
## Architecture Diagram
|
|
@@ -43,12 +49,14 @@ design-clone/
|
|
|
43
49
|
▼
|
|
44
50
|
┌─────────────────────────────────────────────────────────────────┐
|
|
45
51
|
│ Core Scripts (src/) │
|
|
46
|
-
│
|
|
47
|
-
│ │ core/
|
|
48
|
-
│ │ screenshot.js
|
|
49
|
-
│
|
|
50
|
-
│
|
|
51
|
-
|
|
52
|
+
│ ┌──────────────────┐ ┌──────────────────┐ ┌──────────────┐ │
|
|
53
|
+
│ │ core/ │ │ core/ │ │ core/ │ │
|
|
54
|
+
│ │ screenshot.js │ │ filter-css.js │ │ framework- │ │
|
|
55
|
+
│ │ animation- │ │ state-capture.js │ │ detector.js │ │
|
|
56
|
+
│ │ extractor.js │ │ extract-assets │ └──────┬───────┘ │
|
|
57
|
+
│ └────────┬─────────┘ │ .js │ │ │
|
|
58
|
+
│ │ └────────┬─────────┘ │ │
|
|
59
|
+
└───────────┼─────────────────────┼─────────────────────┼─────────┘
|
|
52
60
|
│ │ │
|
|
53
61
|
▼ ▼ ▼
|
|
54
62
|
┌─────────────────────────────────────────────────────────────────┐
|
|
@@ -62,8 +70,8 @@ design-clone/
|
|
|
62
70
|
│ ┌─────────────────────────────────────────────────────────┐ │
|
|
63
71
|
│ │ Browser Provider Selection │ │
|
|
64
72
|
│ │ ┌─────────────────┐ ┌─────────────────────────┐ │ │
|
|
65
|
-
│ │ │ chrome-devtools │ OR │
|
|
66
|
-
│ │ │ (if exists) │ │ (bundled fallback)
|
|
73
|
+
│ │ │ chrome-devtools │ OR │ playwright.js (standalone)│ │ │
|
|
74
|
+
│ │ │ (if exists) │ │ (bundled fallback) │ │ │
|
|
67
75
|
│ │ └─────────────────┘ └─────────────────────────┘ │ │
|
|
68
76
|
│ └─────────────────────────────────────────────────────────┘ │
|
|
69
77
|
└─────────────────────────────────────────────────────────────────┘
|
|
@@ -85,7 +93,7 @@ design-clone/
|
|
|
85
93
|
```
|
|
86
94
|
src/utils/
|
|
87
95
|
├── browser.js # Facade - auto-selects provider
|
|
88
|
-
├──
|
|
96
|
+
├── playwright.js # Standalone Playwright wrapper
|
|
89
97
|
├── helpers.js # CLI utilities (parseArgs, outputJSON)
|
|
90
98
|
├── env.js # Node.js env resolution
|
|
91
99
|
└── env.py # Python env resolution
|
|
@@ -93,22 +101,20 @@ src/utils/
|
|
|
93
101
|
|
|
94
102
|
**browser.js** - Facade pattern for browser automation:
|
|
95
103
|
```javascript
|
|
96
|
-
//
|
|
104
|
+
// Uses Playwright wrapper for browser automation
|
|
97
105
|
async function initProvider() {
|
|
98
|
-
if (
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
providerName = 'standalone';
|
|
104
|
-
}
|
|
106
|
+
if (browserModule) return;
|
|
107
|
+
|
|
108
|
+
browserModule = await import('./playwright.js');
|
|
109
|
+
providerName = 'playwright';
|
|
110
|
+
console.error('[browser] Using Playwright wrapper');
|
|
105
111
|
}
|
|
106
112
|
```
|
|
107
113
|
|
|
108
|
-
**
|
|
114
|
+
**playwright.js** - Standalone browser wrapper:
|
|
109
115
|
- Cross-platform Chrome detection (macOS, Linux, Windows)
|
|
110
|
-
-
|
|
111
|
-
-
|
|
116
|
+
- Supports both full `playwright` and lighter `playwright-core`
|
|
117
|
+
- Auto-detects Chrome executable path on all platforms
|
|
112
118
|
|
|
113
119
|
### 2. Environment Resolution
|
|
114
120
|
|
|
@@ -126,19 +132,109 @@ Both Node.js and Python share same resolution order:
|
|
|
126
132
|
- Windows: Uses `USERPROFILE` when `HOME` unavailable
|
|
127
133
|
- Python 3.9+: Uses `List[Path]` from typing module
|
|
128
134
|
|
|
135
|
+
### 2.3 Semantic HTML Enhancement (Phase 3)
|
|
136
|
+
|
|
137
|
+
**Purpose**: Inject WordPress-compatible semantic IDs, classes, and ARIA roles into extracted HTML while preserving original styling.
|
|
138
|
+
|
|
139
|
+
**Location**: `src/core/semantic-enhancer.js`
|
|
140
|
+
|
|
141
|
+
**Key Functions**:
|
|
142
|
+
|
|
143
|
+
1. **detectSectionType(element)** - Detect section type via priority:
|
|
144
|
+
- Priority 1: Semantic HTML tags (`<header>`, `<nav>`, `<main>`, `<aside>`, `<footer>`)
|
|
145
|
+
- Priority 2: ARIA role attributes (`banner`, `navigation`, `main`, `complementary`, `contentinfo`)
|
|
146
|
+
- Priority 3: Class pattern matching (header, nav, main, sidebar, footer, hero)
|
|
147
|
+
|
|
148
|
+
2. **applySemanticAttributes(element, sectionType, options)** - Apply enhancements:
|
|
149
|
+
- Add ID only if none exists (avoid duplicates)
|
|
150
|
+
- Append classes (preserve existing)
|
|
151
|
+
- Set role only if not present
|
|
152
|
+
|
|
153
|
+
3. **handleMultipleNavs(navElements, usedIds)** - Label multiple navigations:
|
|
154
|
+
- Primary nav in header: `aria-label="Primary Menu"`
|
|
155
|
+
- Footer navs: `aria-label="Footer Menu"`
|
|
156
|
+
- Other navs: `aria-label="Navigation 2"`, etc.
|
|
157
|
+
|
|
158
|
+
4. **enhanceSemanticHTML(html, domHierarchy)** - Browser-context enhancement:
|
|
159
|
+
- Uses DOMParser (requires browser environment)
|
|
160
|
+
- Optimized selector combining 8 queries → 1
|
|
161
|
+
- Detects hero sections via class patterns
|
|
162
|
+
|
|
163
|
+
5. **enhanceSemanticHTMLInPage(page, html)** - Playwright-context enhancement:
|
|
164
|
+
- Recommended for Node.js/Playwright workflows
|
|
165
|
+
- Uses page.evaluate() for secure execution
|
|
166
|
+
- Returns enhancement stats (sections enhanced, IDs/classes/roles added)
|
|
167
|
+
|
|
168
|
+
**Semantic Mappings**:
|
|
169
|
+
```javascript
|
|
170
|
+
{
|
|
171
|
+
header: { id: 'site-header', classes: ['site-header'], role: 'banner' },
|
|
172
|
+
nav: { id: 'site-navigation', classes: ['main-navigation', 'nav-menu'], role: 'navigation' },
|
|
173
|
+
main: { id: 'main-content', classes: ['site-main', 'content-area'], role: 'main' },
|
|
174
|
+
sidebar: { id: 'primary-sidebar', classes: ['widget-area', 'sidebar'], role: 'complementary' },
|
|
175
|
+
footer: { id: 'site-footer', classes: ['site-footer'], role: 'contentinfo' },
|
|
176
|
+
hero: { id: 'hero-section', classes: ['hero'], role: null }
|
|
177
|
+
}
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
**Integration**: Used by `extractAndEnhanceHtml()` in html-extractor.js when `enhanceSemantic=true`
|
|
181
|
+
|
|
182
|
+
### 2.5 DOM Tree Analyzer
|
|
183
|
+
|
|
184
|
+
**Purpose**: Extract DOM tree hierarchy with semantic landmarks and heading structure.
|
|
185
|
+
|
|
186
|
+
**Location**: `src/core/dom-tree-analyzer.js`
|
|
187
|
+
|
|
188
|
+
**Key Features**:
|
|
189
|
+
- PreOrder DOM traversal (parent before children)
|
|
190
|
+
- W3C landmark detection (`<header>`, `<main>`, `<footer>`, `<nav>`, `<aside>`)
|
|
191
|
+
- Section context mapping (hero, header, content, sidebar, footer)
|
|
192
|
+
- Heading tree with section context and Y-position
|
|
193
|
+
- Configurable max depth (default: 8 levels)
|
|
194
|
+
- Hidden element filtering (optional inclusion)
|
|
195
|
+
- Performance tracking with warnings for extraction >500ms
|
|
196
|
+
|
|
197
|
+
**API**:
|
|
198
|
+
```javascript
|
|
199
|
+
export async function extractDOMHierarchy(page, options = {})
|
|
200
|
+
// @param {Object} options - { maxDepth: 8, includeHidden: false }
|
|
201
|
+
// @returns {Promise<Object>} - { root, landmarks, headingTree, stats }
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
**Output Structure**:
|
|
205
|
+
- `root`: Complete DOM tree starting from `<body>`
|
|
206
|
+
- `landmarks`: Object with header, main, footer, nav[], aside[]
|
|
207
|
+
- `headingTree`: Array of headings with level, section, text, fontSize, Y-position
|
|
208
|
+
- `stats`: Metrics (totalNodes, maxDepth, landmarkCount, pageHeight, pageWidth, extractionTimeMs)
|
|
209
|
+
|
|
210
|
+
**Detection Priority**:
|
|
211
|
+
- **Role**: ARIA role attribute > semantic tag > class pattern
|
|
212
|
+
- **Section**: Semantic tag (header/footer/aside/nav) > Y-position > computed style
|
|
213
|
+
- **Landmarks**: Only top-level header/footer elements marked as "-landmark" role
|
|
214
|
+
|
|
129
215
|
### 3. Core Scripts
|
|
130
216
|
|
|
131
217
|
| Script | Location | Language | Purpose |
|
|
132
218
|
|--------|----------|----------|---------|
|
|
133
219
|
| screenshot.js | src/core/ | Node.js | Screenshot capture, HTML/CSS extraction |
|
|
220
|
+
| html-extractor.js | src/core/ | Node.js | Extract and clean HTML, optionally enhance with semantic structure |
|
|
221
|
+
| semantic-enhancer.js | src/core/ | Node.js | WordPress semantic HTML enhancement (Phase 3) |
|
|
134
222
|
| animation-extractor.js | src/core/ | Node.js | Extract @keyframes, transitions, animation properties |
|
|
135
223
|
| state-capture.js | src/core/ | Node.js | Capture hover states for interactive elements |
|
|
224
|
+
| framework-detector.js | src/core/ | Node.js | Detect framework (Next.js, Nuxt, Vue, React, Angular, Svelte, Astro) |
|
|
136
225
|
| filter-css.js | src/core/ | Node.js | Remove unused CSS selectors |
|
|
137
226
|
| extract-assets.js | src/core/ | Node.js | Download images, fonts, icons |
|
|
227
|
+
| dom-tree-analyzer.js | src/core/ | Node.js | DOM hierarchy extraction with semantic landmarks and heading tree |
|
|
138
228
|
| analyze-structure.py | src/ai/ | Python | Gemini AI structure analysis |
|
|
139
229
|
| extract-design-tokens.py | src/ai/ | Python | Color, typography, spacing extraction |
|
|
140
|
-
|
|
|
141
|
-
|
|
|
230
|
+
| ux-audit.js | src/ai/ | Node.js | UX quality assessment via Gemini Vision (Phase 2) |
|
|
231
|
+
| ux_audit.py | src/ai/prompts/ | Python | UX audit prompts for viewport-specific analysis (Phase 2) |
|
|
232
|
+
| verify-header.js | src/verification/ | Node.js | Verify header components (logo, nav, CTA, sticky behavior) |
|
|
233
|
+
| verify-footer.js | src/verification/ | Node.js | Verify footer layout, links, copyright, social icons |
|
|
234
|
+
| verify-slider.js | src/verification/ | Node.js | Detect slider library, test navigation and autoplay |
|
|
235
|
+
| verify-menu.js | src/verification/ | Node.js | Test responsive navigation functionality |
|
|
236
|
+
| verify-layout.js | src/verification/ | Node.js | Verify layout consistency across viewports |
|
|
237
|
+
| generate-audit-report.js | src/verification/ | Node.js | Aggregate verification results into markdown report |
|
|
142
238
|
|
|
143
239
|
### 4. Post-Processing
|
|
144
240
|
|
|
@@ -162,7 +258,55 @@ docs/
|
|
|
162
258
|
└── troubleshooting.md # Common issues
|
|
163
259
|
```
|
|
164
260
|
|
|
165
|
-
### 6.
|
|
261
|
+
### 6. AI Analysis - UX Audit (Phase 2)
|
|
262
|
+
|
|
263
|
+
**Purpose**: Automated UX quality assessment across multiple viewports using Gemini Vision AI.
|
|
264
|
+
|
|
265
|
+
**Architecture**:
|
|
266
|
+
```
|
|
267
|
+
src/ai/ux-audit.js # Main runner (Node.js)
|
|
268
|
+
├── parseArgs() # CLI argument parsing
|
|
269
|
+
├── analyzeViewport() # Gemini Vision analysis per viewport
|
|
270
|
+
├── aggregateResults() # Weighted score aggregation
|
|
271
|
+
├── generateReport() # Markdown report generation
|
|
272
|
+
└── runUXAudit() [export] # Main async function
|
|
273
|
+
|
|
274
|
+
src/ai/prompts/ux_audit.py # Prompt templates (Python)
|
|
275
|
+
├── UX_AUDIT_PROMPT # Base 6-category evaluation
|
|
276
|
+
├── VIEWPORT_CONTEXT{} # Mobile/tablet/desktop specific checks
|
|
277
|
+
├── AGGREGATION_PROMPT # Viewport result combining
|
|
278
|
+
├── build_ux_audit_prompt() # Build viewport-specific prompt
|
|
279
|
+
└── build_aggregation_prompt() # Build aggregation prompt
|
|
280
|
+
|
|
281
|
+
bin/commands/clone-site.js # Integration point
|
|
282
|
+
├── parseArgs() --ux-audit # New flag support
|
|
283
|
+
└── cloneSite() # Step 5: Run UX audit if enabled
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
**Evaluation Model**:
|
|
287
|
+
- **Categories** (0-100 each): Visual Hierarchy, Navigation, Typography, Spacing, Interactive Elements, Responsive
|
|
288
|
+
- **Viewports**: Desktop (1920×1080), Tablet (768×1024), Mobile (375×812)
|
|
289
|
+
- **Weighting**: Desktop 40%, Tablet 30%, Mobile 30%
|
|
290
|
+
- **Severity Levels**: Critical (0-30), Major (31-60), Minor (61-80)
|
|
291
|
+
- **Output**: Markdown report + JSON results with aggregated scores, per-viewport breakdown, prioritized issues
|
|
292
|
+
|
|
293
|
+
**Integration with clone-site Workflow**:
|
|
294
|
+
```
|
|
295
|
+
clone-site workflow (7 steps):
|
|
296
|
+
Step 1: Discover pages
|
|
297
|
+
Step 2: Capture screenshots
|
|
298
|
+
Step 3: Merge CSS
|
|
299
|
+
Step 4: Extract tokens (--ai)
|
|
300
|
+
Step 5: Run UX audit (--ux-audit) ← NEW
|
|
301
|
+
Step 6: Rewrite links
|
|
302
|
+
Step 7: Generate manifest
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
**Dependencies**:
|
|
306
|
+
- `@google/generative-ai`: Gemini API client (added to optionalDependencies)
|
|
307
|
+
- `GEMINI_API_KEY` or `GOOGLE_API_KEY` environment variable required
|
|
308
|
+
|
|
309
|
+
### 7. CLI Tool
|
|
166
310
|
|
|
167
311
|
```
|
|
168
312
|
bin/
|
|
@@ -170,7 +314,8 @@ bin/
|
|
|
170
314
|
├── commands/
|
|
171
315
|
│ ├── init.js # Install skill to ~/.claude/skills/
|
|
172
316
|
│ ├── verify.js # Check installation status
|
|
173
|
-
│
|
|
317
|
+
│ ├── help.js # Usage information
|
|
318
|
+
│ └── clone-site.js # Multi-page clone with UX audit (Phase 2)
|
|
174
319
|
└── utils/
|
|
175
320
|
├── copy.js # Recursive file copy
|
|
176
321
|
└── validate.js # Environment checks
|
|
@@ -181,35 +326,64 @@ bin/
|
|
|
181
326
|
### design:clone
|
|
182
327
|
|
|
183
328
|
```
|
|
184
|
-
URL → src/core/screenshot.js
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
→ src/core/
|
|
191
|
-
|
|
329
|
+
URL → src/core/screenshot.js → Screenshots (3 viewports)
|
|
330
|
+
→ source-raw.css
|
|
331
|
+
→ src/core/html-extractor.js → source.html (cleaned + enhanced)
|
|
332
|
+
├─ extractCleanHtml() → Remove scripts, framework attrs
|
|
333
|
+
└─ enhanceSemanticHTMLInPage() → Add WordPress semantic IDs/classes/roles
|
|
334
|
+
(via semantic-enhancer.js)
|
|
335
|
+
→ src/core/filter-css.js → source.css (filtered)
|
|
336
|
+
→ src/core/animation-extractor.js → animations.css
|
|
337
|
+
→ animation-tokens.json
|
|
338
|
+
→ src/core/state-capture.js* → hover-states/ (hover screenshots)
|
|
339
|
+
→ hover.css (generated :hover rules)
|
|
192
340
|
```
|
|
193
341
|
|
|
194
342
|
*Enabled with `--capture-hover true` flag
|
|
343
|
+
**Note**: Semantic enhancement enabled by default, disable with `--no-semantic` flag
|
|
195
344
|
|
|
196
345
|
### design:clone-px
|
|
197
346
|
|
|
198
347
|
```
|
|
199
|
-
URL → src/core/screenshot.js
|
|
200
|
-
→ src/core/
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
→ src/core/
|
|
204
|
-
→ src/
|
|
205
|
-
→ src/
|
|
206
|
-
→ src/
|
|
348
|
+
URL → src/core/screenshot.js → Screenshots + HTML/CSS
|
|
349
|
+
→ src/core/html-extractor.js → Clean + semantic enhancement
|
|
350
|
+
├─ extractCleanHtml() → Remove scripts, framework attrs
|
|
351
|
+
└─ enhanceSemanticHTMLInPage() → Add WordPress semantic structure
|
|
352
|
+
→ src/core/filter-css.js → Filtered CSS
|
|
353
|
+
→ src/core/animation-extractor.js → animations.css, animation-tokens.json
|
|
354
|
+
→ src/core/state-capture.js* → hover-states/, hover.css
|
|
355
|
+
→ src/core/extract-assets.js → assets/ (images, fonts, icons)
|
|
356
|
+
→ src/ai/analyze-structure.py → structure.md (AI analysis)
|
|
357
|
+
→ src/ai/extract-design-tokens.py → tokens.json, tokens.css
|
|
358
|
+
→ src/verification/verify-menu.js → Menu validation report
|
|
207
359
|
```
|
|
208
360
|
|
|
209
361
|
*Hover state capture enabled by default in design:clone-px workflow
|
|
362
|
+
**Note**: Semantic enhancement enabled by default, disable with `--no-semantic` flag
|
|
363
|
+
|
|
364
|
+
### clone-site (with --ux-audit, Phase 2)
|
|
365
|
+
|
|
366
|
+
```
|
|
367
|
+
URL → discover pages
|
|
368
|
+
→ capture multi-page screenshots (all viewports)
|
|
369
|
+
→ merge CSS
|
|
370
|
+
→ extract design tokens (--ai)
|
|
371
|
+
→ src/ai/ux-audit.js → analysis/ux-audit.md
|
|
372
|
+
(analyzes homepage screenshots) → analysis/ux-audit.json
|
|
373
|
+
├─ desktop.png → Gemini Vision → Overall UX score
|
|
374
|
+
├─ tablet.png → Gemini Vision → Per-category scores
|
|
375
|
+
└─ mobile.png → Gemini Vision → Viewport breakdown
|
|
376
|
+
→ Issues & recommendations
|
|
377
|
+
→ rewrite links
|
|
378
|
+
→ generate manifest
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
**Requires**: GEMINI_API_KEY environment variable, `--ux-audit` flag
|
|
210
382
|
|
|
211
383
|
## Output Structure
|
|
212
384
|
|
|
385
|
+
### Single Page Clone (design:clone, design:clone-px)
|
|
386
|
+
|
|
213
387
|
```
|
|
214
388
|
cloned-design/
|
|
215
389
|
├── desktop.png # 1920x1080
|
|
@@ -236,6 +410,45 @@ cloned-design/
|
|
|
236
410
|
└── icons/
|
|
237
411
|
```
|
|
238
412
|
|
|
413
|
+
### Multi-Page Clone (clone-site, Phase 2)
|
|
414
|
+
|
|
415
|
+
```
|
|
416
|
+
cloned-site/
|
|
417
|
+
├── screenshots/
|
|
418
|
+
│ ├── index-desktop.png
|
|
419
|
+
│ ├── index-tablet.png
|
|
420
|
+
│ ├── index-mobile.png
|
|
421
|
+
│ ├── about-desktop.png
|
|
422
|
+
│ ├── about-tablet.png
|
|
423
|
+
│ ├── about-mobile.png
|
|
424
|
+
│ └── ... (more pages)
|
|
425
|
+
├── html/
|
|
426
|
+
│ ├── index.html
|
|
427
|
+
│ ├── about.html
|
|
428
|
+
│ └── ... (source HTML files)
|
|
429
|
+
├── pages/
|
|
430
|
+
│ ├── index.html # Rewritten with proper links
|
|
431
|
+
│ ├── about.html
|
|
432
|
+
│ └── ... (final HTML with nav working)
|
|
433
|
+
├── styles.css # Merged and optimized CSS
|
|
434
|
+
├── tokens.json # Design tokens (with --ai)
|
|
435
|
+
├── tokens.css # CSS variables (with --ai)
|
|
436
|
+
├── manifest.json # Page manifest and metadata
|
|
437
|
+
├── analysis/ # UX Audit output (with --ux-audit, Phase 2)
|
|
438
|
+
│ ├── ux-audit.md # Markdown report with scores & recommendations
|
|
439
|
+
│ └── ux-audit.json # Structured audit results
|
|
440
|
+
│ ├── overall_scores (6 categories)
|
|
441
|
+
│ ├── overall_ux_score (0-100)
|
|
442
|
+
│ ├── accessibility_score (0-100)
|
|
443
|
+
│ ├── viewport_breakdown {desktop, tablet, mobile}
|
|
444
|
+
│ ├── top_issues (with severity)
|
|
445
|
+
│ └── prioritized_recommendations
|
|
446
|
+
└── assets/ # Extracted images, fonts, icons
|
|
447
|
+
├── images/
|
|
448
|
+
├── fonts/
|
|
449
|
+
└── icons/
|
|
450
|
+
```
|
|
451
|
+
|
|
239
452
|
**Hover State Output** (when `--capture-hover true`):
|
|
240
453
|
- `hover-states/`: Directory containing hover state captures
|
|
241
454
|
- `hover-N-normal.png`: Screenshot of element in normal state
|
|
@@ -247,10 +460,14 @@ cloned-design/
|
|
|
247
460
|
|
|
248
461
|
### Node.js (package.json)
|
|
249
462
|
- `css-tree`: CSS parsing and filtering
|
|
250
|
-
- `
|
|
463
|
+
- `sharp`: Image processing and optimization
|
|
464
|
+
- `playwright` or `playwright-core`: Browser automation (peerDep, optional)
|
|
465
|
+
- `@google/generative-ai`: Gemini API client (optionalDep, required for UX audit, Phase 2)
|
|
466
|
+
- `fluent-ffmpeg` + `@ffmpeg-installer/ffmpeg`: Video/animation processing (optional)
|
|
251
467
|
|
|
252
468
|
### Python (requirements.txt)
|
|
253
469
|
- `google-genai`: Gemini AI for vision analysis
|
|
470
|
+
- Standard: `os`, `sys`, `json`, `subprocess`, `re`, `pathlib`
|
|
254
471
|
|
|
255
472
|
## Installation Methods
|
|
256
473
|
|
package/docs/pixel-perfect.md
CHANGED
|
@@ -63,22 +63,53 @@ python src/ai/extract-design-tokens.py \
|
|
|
63
63
|
|
|
64
64
|
Output: `./clone/tokens.json` with colors, typography, spacing.
|
|
65
65
|
|
|
66
|
-
### Step 6:
|
|
66
|
+
### Step 6: Component Verification
|
|
67
67
|
|
|
68
|
+
**Verify Menu**
|
|
68
69
|
```bash
|
|
69
70
|
node src/verification/verify-menu.js --html ./clone/source.html
|
|
70
71
|
```
|
|
71
|
-
|
|
72
72
|
Reports: missing links, broken structure, accessibility issues.
|
|
73
73
|
|
|
74
|
+
**Verify Header** (Phase 1)
|
|
75
|
+
```bash
|
|
76
|
+
node src/verification/verify-header.js --html ./clone/source.html
|
|
77
|
+
```
|
|
78
|
+
Tests: logo, navigation, CTA buttons, sticky behavior, z-index, height consistency.
|
|
79
|
+
|
|
80
|
+
**Verify Footer** (Phase 1)
|
|
81
|
+
```bash
|
|
82
|
+
node src/verification/verify-footer.js --html ./clone/source.html
|
|
83
|
+
```
|
|
84
|
+
Tests: position, layout, link sections, copyright, social icons, contrast.
|
|
85
|
+
|
|
86
|
+
**Verify Slider** (Phase 1)
|
|
87
|
+
```bash
|
|
88
|
+
node src/verification/verify-slider.js --html ./clone/source.html
|
|
89
|
+
```
|
|
90
|
+
Tests: library detection (Swiper, Slick, Owl), navigation, pagination, autoplay.
|
|
91
|
+
|
|
92
|
+
### Step 7: Generate Audit Report
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
node src/verification/generate-audit-report.js --dir ./clone
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Aggregates all verification results into `component-audit.md` with summary table, side-by-side screenshots, and CSS fix suggestions.
|
|
99
|
+
|
|
74
100
|
## Output Structure
|
|
75
101
|
|
|
76
102
|
```
|
|
77
103
|
./clone/
|
|
78
104
|
├── desktop.png, tablet.png, mobile.png
|
|
79
105
|
├── source.html, source.css
|
|
80
|
-
├── structure.md
|
|
81
|
-
├── tokens.json
|
|
106
|
+
├── structure.md # AI analysis
|
|
107
|
+
├── tokens.json # Design tokens
|
|
108
|
+
├── component-audit.md # Verification report (Phase 1)
|
|
109
|
+
├── header-results.json # Header verification details
|
|
110
|
+
├── footer-results.json # Footer verification details
|
|
111
|
+
├── slider-results.json # Slider verification details
|
|
112
|
+
├── menu-results.json # Menu verification details
|
|
82
113
|
└── assets/
|
|
83
114
|
├── images/
|
|
84
115
|
├── fonts/
|