design-clone 2.1.0 → 2.3.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
|
@@ -1,492 +0,0 @@
|
|
|
1
|
-
# Design Clone Skill Architecture
|
|
2
|
-
|
|
3
|
-
Technical architecture of the design-clone skill for Claude Code.
|
|
4
|
-
|
|
5
|
-
## Overview
|
|
6
|
-
|
|
7
|
-
```
|
|
8
|
-
design-clone/
|
|
9
|
-
├── SKILL.md # Entry point
|
|
10
|
-
├── bin/ # npm CLI tool
|
|
11
|
-
│ ├── cli.js
|
|
12
|
-
│ ├── commands/
|
|
13
|
-
│ │ └── clone-site.js # Multi-page clone with integrated UX audit (Phase 2)
|
|
14
|
-
│ └── utils/
|
|
15
|
-
├── src/
|
|
16
|
-
│ ├── core/ # Core scripts
|
|
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)
|
|
21
|
-
│ ├── verification/ # Verification scripts
|
|
22
|
-
│ ├── post-process/ # Post-processing
|
|
23
|
-
│ └── utils/ # Shared utilities
|
|
24
|
-
├── docs/ # Documentation
|
|
25
|
-
├── templates/ # Output templates
|
|
26
|
-
├── tests/
|
|
27
|
-
│ └── test-ux-audit.js # UX audit module tests (Phase 2)
|
|
28
|
-
└── package.json # Now includes @google/generative-ai optionalDependency
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
## Architecture Diagram
|
|
32
|
-
|
|
33
|
-
```
|
|
34
|
-
┌─────────────────────────────────────────────────────────────────┐
|
|
35
|
-
│ Claude Code │
|
|
36
|
-
│ ┌──────────────────┐ ┌──────────────────┐ │
|
|
37
|
-
│ │ /design:clone │ │ /design:clone-px │ │
|
|
38
|
-
│ └────────┬─────────┘ └────────┬─────────┘ │
|
|
39
|
-
└───────────┼─────────────────────┼───────────────────────────────┘
|
|
40
|
-
│ │
|
|
41
|
-
▼ ▼
|
|
42
|
-
┌─────────────────────────────────────────────────────────────────┐
|
|
43
|
-
│ SKILL.md │
|
|
44
|
-
│ - Activation triggers: clone, copy, replicate website │
|
|
45
|
-
│ - Commands: design:clone, design:clone-px │
|
|
46
|
-
│ - References: progressive disclosure │
|
|
47
|
-
└─────────────────────────────────────────────────────────────────┘
|
|
48
|
-
│
|
|
49
|
-
▼
|
|
50
|
-
┌─────────────────────────────────────────────────────────────────┐
|
|
51
|
-
│ Core Scripts (src/) │
|
|
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
|
-
└───────────┼─────────────────────┼─────────────────────┼─────────┘
|
|
60
|
-
│ │ │
|
|
61
|
-
▼ ▼ ▼
|
|
62
|
-
┌─────────────────────────────────────────────────────────────────┐
|
|
63
|
-
│ src/utils/ (Shared) │
|
|
64
|
-
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
|
|
65
|
-
│ │ browser.js │ │ env.js │ │ env.py │ │
|
|
66
|
-
│ │ (facade) │ │ (Node.js) │ │ (Python) │ │
|
|
67
|
-
│ └──────┬──────┘ └─────────────┘ └─────────────┘ │
|
|
68
|
-
│ │ │
|
|
69
|
-
│ ▼ │
|
|
70
|
-
│ ┌─────────────────────────────────────────────────────────┐ │
|
|
71
|
-
│ │ Browser Provider Selection │ │
|
|
72
|
-
│ │ ┌─────────────────┐ ┌─────────────────────────┐ │ │
|
|
73
|
-
│ │ │ chrome-devtools │ OR │ playwright.js (standalone)│ │ │
|
|
74
|
-
│ │ │ (if exists) │ │ (bundled fallback) │ │ │
|
|
75
|
-
│ │ └─────────────────┘ └─────────────────────────┘ │ │
|
|
76
|
-
│ └─────────────────────────────────────────────────────────┘ │
|
|
77
|
-
└─────────────────────────────────────────────────────────────────┘
|
|
78
|
-
│
|
|
79
|
-
▼
|
|
80
|
-
┌─────────────────────────────────────────────────────────────────┐
|
|
81
|
-
│ Chrome/Chromium │
|
|
82
|
-
│ Auto-detected paths: │
|
|
83
|
-
│ - macOS: /Applications/Google Chrome.app/... │
|
|
84
|
-
│ - Linux: /usr/bin/google-chrome, /usr/bin/chromium │
|
|
85
|
-
│ - Windows: C:\Program Files\Google\Chrome\... │
|
|
86
|
-
└─────────────────────────────────────────────────────────────────┘
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
## Component Details
|
|
90
|
-
|
|
91
|
-
### 1. Browser Abstraction Layer
|
|
92
|
-
|
|
93
|
-
```
|
|
94
|
-
src/utils/
|
|
95
|
-
├── browser.js # Facade - auto-selects provider
|
|
96
|
-
├── playwright.js # Standalone Playwright wrapper
|
|
97
|
-
├── helpers.js # CLI utilities (parseArgs, outputJSON)
|
|
98
|
-
├── env.js # Node.js env resolution
|
|
99
|
-
└── env.py # Python env resolution
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
**browser.js** - Facade pattern for browser automation:
|
|
103
|
-
```javascript
|
|
104
|
-
// Uses Playwright wrapper for browser automation
|
|
105
|
-
async function initProvider() {
|
|
106
|
-
if (browserModule) return;
|
|
107
|
-
|
|
108
|
-
browserModule = await import('./playwright.js');
|
|
109
|
-
providerName = 'playwright';
|
|
110
|
-
console.error('[browser] Using Playwright wrapper');
|
|
111
|
-
}
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
**playwright.js** - Standalone browser wrapper:
|
|
115
|
-
- Cross-platform Chrome detection (macOS, Linux, Windows)
|
|
116
|
-
- Supports both full `playwright` and lighter `playwright-core`
|
|
117
|
-
- Auto-detects Chrome executable path on all platforms
|
|
118
|
-
|
|
119
|
-
### 2. Environment Resolution
|
|
120
|
-
|
|
121
|
-
Both Node.js and Python share same resolution order:
|
|
122
|
-
|
|
123
|
-
```
|
|
124
|
-
1. process.env / os.environ (already set)
|
|
125
|
-
2. .env in current working directory
|
|
126
|
-
3. .env in skill directory
|
|
127
|
-
4. .env in ~/.claude/skills/
|
|
128
|
-
5. .env in ~/.claude/
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
**Cross-platform support:**
|
|
132
|
-
- Windows: Uses `USERPROFILE` when `HOME` unavailable
|
|
133
|
-
- Python 3.9+: Uses `List[Path]` from typing module
|
|
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
|
-
|
|
215
|
-
### 3. Core Scripts
|
|
216
|
-
|
|
217
|
-
| Script | Location | Language | Purpose |
|
|
218
|
-
|--------|----------|----------|---------|
|
|
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) |
|
|
222
|
-
| animation-extractor.js | src/core/ | Node.js | Extract @keyframes, transitions, animation properties |
|
|
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) |
|
|
225
|
-
| filter-css.js | src/core/ | Node.js | Remove unused CSS selectors |
|
|
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 |
|
|
228
|
-
| analyze-structure.py | src/ai/ | Python | Gemini AI structure analysis |
|
|
229
|
-
| extract-design-tokens.py | src/ai/ | Python | Color, typography, spacing extraction |
|
|
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 |
|
|
238
|
-
|
|
239
|
-
### 4. Post-Processing
|
|
240
|
-
|
|
241
|
-
```
|
|
242
|
-
src/post-process/
|
|
243
|
-
├── fetch-images.js # Fetch and optimize images
|
|
244
|
-
├── inject-icons.js # Replace icons with Font Awesome
|
|
245
|
-
└── enhance-assets.js # Enhance extracted assets
|
|
246
|
-
```
|
|
247
|
-
|
|
248
|
-
### 5. Progressive Disclosure
|
|
249
|
-
|
|
250
|
-
SKILL.md kept concise. Detailed docs in docs/:
|
|
251
|
-
|
|
252
|
-
```
|
|
253
|
-
docs/
|
|
254
|
-
├── basic-clone.md # design:clone workflow
|
|
255
|
-
├── pixel-perfect.md # design:clone-px workflow
|
|
256
|
-
├── cli-reference.md # All script options
|
|
257
|
-
├── design-clone-architecture.md # This file
|
|
258
|
-
└── troubleshooting.md # Common issues
|
|
259
|
-
```
|
|
260
|
-
|
|
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
|
|
310
|
-
|
|
311
|
-
```
|
|
312
|
-
bin/
|
|
313
|
-
├── cli.js # Entry point (bin: design-clone)
|
|
314
|
-
├── commands/
|
|
315
|
-
│ ├── init.js # Install skill to ~/.claude/skills/
|
|
316
|
-
│ ├── verify.js # Check installation status
|
|
317
|
-
│ ├── help.js # Usage information
|
|
318
|
-
│ └── clone-site.js # Multi-page clone with UX audit (Phase 2)
|
|
319
|
-
└── utils/
|
|
320
|
-
├── copy.js # Recursive file copy
|
|
321
|
-
└── validate.js # Environment checks
|
|
322
|
-
```
|
|
323
|
-
|
|
324
|
-
## Data Flow
|
|
325
|
-
|
|
326
|
-
### design:clone
|
|
327
|
-
|
|
328
|
-
```
|
|
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)
|
|
340
|
-
```
|
|
341
|
-
|
|
342
|
-
*Enabled with `--capture-hover true` flag
|
|
343
|
-
**Note**: Semantic enhancement enabled by default, disable with `--no-semantic` flag
|
|
344
|
-
|
|
345
|
-
### design:clone-px
|
|
346
|
-
|
|
347
|
-
```
|
|
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
|
|
359
|
-
```
|
|
360
|
-
|
|
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
|
|
382
|
-
|
|
383
|
-
## Output Structure
|
|
384
|
-
|
|
385
|
-
### Single Page Clone (design:clone, design:clone-px)
|
|
386
|
-
|
|
387
|
-
```
|
|
388
|
-
cloned-design/
|
|
389
|
-
├── desktop.png # 1920x1080
|
|
390
|
-
├── tablet.png # 768x1024
|
|
391
|
-
├── mobile.png # 375x812
|
|
392
|
-
├── source.html # Cleaned HTML
|
|
393
|
-
├── source.css # Filtered CSS
|
|
394
|
-
├── source-raw.css # Original CSS
|
|
395
|
-
├── animations.css # Extracted @keyframes definitions
|
|
396
|
-
├── animation-tokens.json # Animation metadata (keyframes, transitions, timings)
|
|
397
|
-
├── hover.css # Generated :hover CSS rules (when --capture-hover)
|
|
398
|
-
├── structure.md # AI analysis (optional)
|
|
399
|
-
├── tokens.json # Design tokens
|
|
400
|
-
├── tokens.css # CSS variables
|
|
401
|
-
├── hover-states/ # Hover state captures (when --capture-hover)
|
|
402
|
-
│ ├── hover-0-normal.png # Element before hover
|
|
403
|
-
│ ├── hover-0-hover.png # Element during hover
|
|
404
|
-
│ ├── hover-1-normal.png # ...
|
|
405
|
-
│ ├── hover-1-hover.png
|
|
406
|
-
│ └── hover-diff.json # Summary of detected and captured elements
|
|
407
|
-
└── assets/
|
|
408
|
-
├── images/
|
|
409
|
-
├── fonts/
|
|
410
|
-
└── icons/
|
|
411
|
-
```
|
|
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
|
-
|
|
452
|
-
**Hover State Output** (when `--capture-hover true`):
|
|
453
|
-
- `hover-states/`: Directory containing hover state captures
|
|
454
|
-
- `hover-N-normal.png`: Screenshot of element in normal state
|
|
455
|
-
- `hover-N-hover.png`: Screenshot of element with hover state applied
|
|
456
|
-
- `hover-diff.json`: Summary with detected count, captured count, and style differences for each element
|
|
457
|
-
- `hover.css`: Generated CSS rules with `:hover` selectors extracted from style diffs
|
|
458
|
-
|
|
459
|
-
## Dependencies
|
|
460
|
-
|
|
461
|
-
### Node.js (package.json)
|
|
462
|
-
- `css-tree`: CSS parsing and filtering
|
|
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)
|
|
467
|
-
|
|
468
|
-
### Python (requirements.txt)
|
|
469
|
-
- `google-genai`: Gemini AI for vision analysis
|
|
470
|
-
- Standard: `os`, `sys`, `json`, `subprocess`, `re`, `pathlib`
|
|
471
|
-
|
|
472
|
-
## Installation Methods
|
|
473
|
-
|
|
474
|
-
### npm (Recommended)
|
|
475
|
-
```bash
|
|
476
|
-
npm install -g design-clone
|
|
477
|
-
design-clone init
|
|
478
|
-
```
|
|
479
|
-
|
|
480
|
-
### Manual
|
|
481
|
-
```bash
|
|
482
|
-
cp -r design-clone ~/.claude/skills/design-clone
|
|
483
|
-
cd ~/.claude/skills/design-clone
|
|
484
|
-
npm install && pip install -r requirements.txt
|
|
485
|
-
```
|
|
486
|
-
|
|
487
|
-
## Security Considerations
|
|
488
|
-
|
|
489
|
-
1. **Path validation**: Prevents directory traversal
|
|
490
|
-
2. **CSS sanitization**: Removes XSS vectors (expression(), javascript:)
|
|
491
|
-
3. **Size limits**: 10MB max CSS input
|
|
492
|
-
4. **No secrets in output**: Scripts don't expose env vars
|
package/docs/pixel-perfect.md
DELETED
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
# Pixel-Perfect Clone Workflow
|
|
2
|
-
|
|
3
|
-
Full design replication with asset extraction, AI analysis, and verification.
|
|
4
|
-
|
|
5
|
-
## When to Use
|
|
6
|
-
|
|
7
|
-
- Production-ready design implementation
|
|
8
|
-
- Complete asset and structure extraction
|
|
9
|
-
- Sites with complex navigation or interactions
|
|
10
|
-
|
|
11
|
-
## Full Workflow
|
|
12
|
-
|
|
13
|
-
### Step 1: Capture + Extract
|
|
14
|
-
|
|
15
|
-
```bash
|
|
16
|
-
node src/core/screenshot.js \
|
|
17
|
-
--url "https://example.com" \
|
|
18
|
-
--output ./clone \
|
|
19
|
-
--extract-html --extract-css \
|
|
20
|
-
--full-page
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
### Step 2: Filter CSS
|
|
24
|
-
|
|
25
|
-
```bash
|
|
26
|
-
node src/core/filter-css.js \
|
|
27
|
-
--html ./clone/source.html \
|
|
28
|
-
--css ./clone/source-raw.css \
|
|
29
|
-
--output ./clone/source.css
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
### Step 3: Extract Assets
|
|
33
|
-
|
|
34
|
-
```bash
|
|
35
|
-
node src/core/extract-assets.js \
|
|
36
|
-
--url "https://example.com" \
|
|
37
|
-
--output ./clone
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
Downloads: images, fonts, icons, SVGs to `./clone/assets/`
|
|
41
|
-
|
|
42
|
-
### Step 4: AI Structure Analysis
|
|
43
|
-
|
|
44
|
-
Requires `GEMINI_API_KEY` in environment.
|
|
45
|
-
|
|
46
|
-
```bash
|
|
47
|
-
python src/ai/analyze-structure.py \
|
|
48
|
-
-s ./clone/desktop.png \
|
|
49
|
-
-o ./clone \
|
|
50
|
-
--html ./clone/source.html \
|
|
51
|
-
--css ./clone/source.css
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
Output: `./clone/structure.md` with section breakdown and BEM suggestions.
|
|
55
|
-
|
|
56
|
-
### Step 5: Extract Design Tokens
|
|
57
|
-
|
|
58
|
-
```bash
|
|
59
|
-
python src/ai/extract-design-tokens.py \
|
|
60
|
-
-s ./clone/desktop.png \
|
|
61
|
-
-o ./clone
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
Output: `./clone/tokens.json` with colors, typography, spacing.
|
|
65
|
-
|
|
66
|
-
### Step 6: Component Verification
|
|
67
|
-
|
|
68
|
-
**Verify Menu**
|
|
69
|
-
```bash
|
|
70
|
-
node src/verification/verify-menu.js --html ./clone/source.html
|
|
71
|
-
```
|
|
72
|
-
Reports: missing links, broken structure, accessibility issues.
|
|
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
|
-
|
|
100
|
-
## Output Structure
|
|
101
|
-
|
|
102
|
-
```
|
|
103
|
-
./clone/
|
|
104
|
-
├── desktop.png, tablet.png, mobile.png
|
|
105
|
-
├── source.html, source.css
|
|
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
|
|
113
|
-
└── assets/
|
|
114
|
-
├── images/
|
|
115
|
-
├── fonts/
|
|
116
|
-
└── icons/
|
|
117
|
-
```
|