design-clone 1.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/.env.example +14 -0
- package/LICENSE +21 -0
- package/README.md +166 -0
- package/SKILL.md +239 -0
- package/bin/cli.js +45 -0
- package/bin/commands/help.js +29 -0
- package/bin/commands/init.js +126 -0
- package/bin/commands/verify.js +99 -0
- package/bin/utils/copy.js +65 -0
- package/bin/utils/validate.js +122 -0
- package/docs/basic-clone.md +63 -0
- package/docs/cli-reference.md +94 -0
- package/docs/design-clone-architecture.md +247 -0
- package/docs/pixel-perfect.md +86 -0
- package/docs/troubleshooting.md +97 -0
- package/package.json +57 -0
- package/requirements.txt +5 -0
- package/src/ai/analyze-structure.py +305 -0
- package/src/ai/extract-design-tokens.py +439 -0
- package/src/ai/prompts/__init__.py +2 -0
- package/src/ai/prompts/design_tokens.py +183 -0
- package/src/ai/prompts/structure_analysis.py +273 -0
- package/src/core/cookie-handler.js +76 -0
- package/src/core/css-extractor.js +107 -0
- package/src/core/dimension-extractor.js +366 -0
- package/src/core/dimension-output.js +208 -0
- package/src/core/extract-assets.js +468 -0
- package/src/core/filter-css.js +499 -0
- package/src/core/html-extractor.js +102 -0
- package/src/core/lazy-loader.js +188 -0
- package/src/core/page-readiness.js +161 -0
- package/src/core/screenshot.js +380 -0
- package/src/post-process/enhance-assets.js +157 -0
- package/src/post-process/fetch-images.js +398 -0
- package/src/post-process/inject-icons.js +311 -0
- package/src/utils/__init__.py +16 -0
- package/src/utils/__pycache__/__init__.cpython-313.pyc +0 -0
- package/src/utils/__pycache__/env.cpython-313.pyc +0 -0
- package/src/utils/browser.js +103 -0
- package/src/utils/env.js +153 -0
- package/src/utils/env.py +134 -0
- package/src/utils/helpers.js +71 -0
- package/src/utils/puppeteer.js +281 -0
- package/src/verification/verify-layout.js +424 -0
- package/src/verification/verify-menu.js +422 -0
- package/templates/base.css +705 -0
- package/templates/base.html +293 -0
package/.env.example
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Design Clone Skill - Environment Variables
|
|
2
|
+
# Copy to .env and fill in your values
|
|
3
|
+
|
|
4
|
+
# Gemini API Key (optional but recommended)
|
|
5
|
+
# Get from: https://aistudio.google.com/apikey
|
|
6
|
+
# Enables AI structure analysis and design token extraction
|
|
7
|
+
GEMINI_API_KEY=your-api-key-here
|
|
8
|
+
|
|
9
|
+
# Chrome Path (optional - auto-detected on most systems)
|
|
10
|
+
# Set if Chrome is installed in non-standard location
|
|
11
|
+
# CHROME_PATH=/path/to/chrome
|
|
12
|
+
|
|
13
|
+
# Puppeteer Options (optional)
|
|
14
|
+
# PUPPETEER_NO_SANDBOX=1 # Required for Docker/CI
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
# Design Clone Skill for Claude Code
|
|
2
|
+
|
|
3
|
+
Clone website designs with multi-viewport screenshots, HTML/CSS extraction, and Gemini AI analysis.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/design-clone)
|
|
6
|
+
[](LICENSE)
|
|
7
|
+
[](https://nodejs.org)
|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
- **Multi-viewport screenshots**: Desktop (1920px), Tablet (768px), Mobile (375px)
|
|
12
|
+
- **HTML/CSS extraction**: Clean source files with unused CSS removal
|
|
13
|
+
- **AI structure analysis**: Gemini Vision analyzes page layout (optional)
|
|
14
|
+
- **Asset extraction**: Downloads images, fonts, icons
|
|
15
|
+
- **Menu verification**: Tests responsive navigation functionality
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
### Option 1: npm (Recommended)
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm install -g design-clone
|
|
23
|
+
design-clone init
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### Option 2: Manual
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
git clone https://github.com/bienhoang/design-clone.git
|
|
30
|
+
cp -r design-clone ~/.claude/skills/design-clone
|
|
31
|
+
cd ~/.claude/skills/design-clone
|
|
32
|
+
npm install
|
|
33
|
+
pip install -r requirements.txt
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Verify Installation
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
design-clone verify
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Quick Start
|
|
43
|
+
|
|
44
|
+
In Claude Code, use:
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
/design:clone https://example.com
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
For pixel-perfect clone with full asset extraction:
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
/design:clone-px https://example.com
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Commands
|
|
57
|
+
|
|
58
|
+
### design:clone
|
|
59
|
+
|
|
60
|
+
Basic design capture:
|
|
61
|
+
- Screenshots at 3 viewports (desktop, tablet, mobile)
|
|
62
|
+
- HTML extraction (scripts removed, cleaned)
|
|
63
|
+
- CSS extraction with unused selector removal
|
|
64
|
+
|
|
65
|
+
### design:clone-px
|
|
66
|
+
|
|
67
|
+
Full pixel-perfect clone:
|
|
68
|
+
- All basic clone features
|
|
69
|
+
- Asset extraction (images, fonts, icons)
|
|
70
|
+
- AI structure analysis (requires GEMINI_API_KEY)
|
|
71
|
+
- Menu verification
|
|
72
|
+
- Design token extraction
|
|
73
|
+
|
|
74
|
+
## Output Structure
|
|
75
|
+
|
|
76
|
+
```
|
|
77
|
+
cloned-design/
|
|
78
|
+
├── desktop.png # 1920x1080 screenshot
|
|
79
|
+
├── tablet.png # 768x1024 screenshot
|
|
80
|
+
├── mobile.png # 375x812 screenshot
|
|
81
|
+
├── source.html # Cleaned HTML
|
|
82
|
+
├── source.css # Filtered CSS
|
|
83
|
+
├── source-raw.css # Original CSS (unfiltered)
|
|
84
|
+
├── structure.md # AI analysis (if GEMINI_API_KEY set)
|
|
85
|
+
├── tokens.json # Extracted design tokens
|
|
86
|
+
└── assets/
|
|
87
|
+
├── images/
|
|
88
|
+
├── fonts/
|
|
89
|
+
└── icons/
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Environment Variables
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
# Optional: enables AI structure analysis
|
|
96
|
+
GEMINI_API_KEY=your-api-key
|
|
97
|
+
|
|
98
|
+
# Add to ~/.claude/.env for persistent config
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Get your API key at: https://aistudio.google.com/apikey
|
|
102
|
+
|
|
103
|
+
## Requirements
|
|
104
|
+
|
|
105
|
+
- Node.js 18+
|
|
106
|
+
- Python 3.9+ (for AI analysis)
|
|
107
|
+
- Chrome or Chromium (auto-detected)
|
|
108
|
+
|
|
109
|
+
## CLI Commands
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
design-clone init [--force] # Install skill to ~/.claude/skills/
|
|
113
|
+
design-clone verify # Check installation status
|
|
114
|
+
design-clone help # Show usage help
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## Troubleshooting
|
|
118
|
+
|
|
119
|
+
### Chrome not found
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
# macOS
|
|
123
|
+
brew install --cask google-chrome
|
|
124
|
+
|
|
125
|
+
# Ubuntu
|
|
126
|
+
sudo apt install chromium-browser
|
|
127
|
+
|
|
128
|
+
# Or set path manually
|
|
129
|
+
export CHROME_PATH="/path/to/chrome"
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### Python dependencies fail
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
pip install google-genai
|
|
136
|
+
# Or with Python 3
|
|
137
|
+
pip3 install -r requirements.txt
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Puppeteer issues
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
# Install Puppeteer if not present
|
|
144
|
+
npm install puppeteer
|
|
145
|
+
|
|
146
|
+
# For Docker/CI environments
|
|
147
|
+
export PUPPETEER_NO_SANDBOX=1
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
See full troubleshooting guide: [docs/troubleshooting.md](docs/troubleshooting.md)
|
|
151
|
+
|
|
152
|
+
## Contributing
|
|
153
|
+
|
|
154
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md)
|
|
155
|
+
|
|
156
|
+
## Changelog
|
|
157
|
+
|
|
158
|
+
See [CHANGELOG.md](CHANGELOG.md)
|
|
159
|
+
|
|
160
|
+
## License
|
|
161
|
+
|
|
162
|
+
MIT - See [LICENSE](LICENSE)
|
|
163
|
+
|
|
164
|
+
## Credits
|
|
165
|
+
|
|
166
|
+
Built for use with [Claude Code](https://claude.ai/code) by Anthropic.
|
package/SKILL.md
ADDED
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: design-clone
|
|
3
|
+
description: Clone website designs via multi-viewport screenshots, HTML/CSS extraction, and Gemini AI analysis. Generates production HTML/CSS with Font Awesome icons, direct Unsplash images, and Japanese design principles. Commands - design:clone (basic), design:clone-px (pixel-perfect).
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Design Clone Skill
|
|
7
|
+
|
|
8
|
+
Clone website designs with multi-viewport screenshots, HTML/CSS extraction, CSS filtering, and Gemini AI structure analysis.
|
|
9
|
+
|
|
10
|
+
## Features
|
|
11
|
+
|
|
12
|
+
- **Font Awesome 6 Icons** - All icons use Font Awesome CDN (no inline SVG)
|
|
13
|
+
- **Direct Unsplash Images** - Real images without API key needed
|
|
14
|
+
- **Japanese Design Principles** - Ma, Kanso, Shibui, Seijaku for elegant designs
|
|
15
|
+
- **Multi-viewport Screenshots** - Desktop, tablet, mobile captures
|
|
16
|
+
- **Gemini Vision Analysis** - AI-powered design token extraction
|
|
17
|
+
- **ui-ux-pro-max Quality Check** - Accessibility, hover states, contrast validation
|
|
18
|
+
|
|
19
|
+
## Prerequisites
|
|
20
|
+
|
|
21
|
+
- Node.js 18+ with npm
|
|
22
|
+
- Python 3.9+ (for AI analysis)
|
|
23
|
+
- Chrome/Chromium browser
|
|
24
|
+
|
|
25
|
+
## Quick Setup
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npm install
|
|
29
|
+
pip install -r requirements.txt
|
|
30
|
+
# Optional: Set GEMINI_API_KEY in .env for AI analysis
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Project Structure
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
design-clone/
|
|
37
|
+
├── bin/ # CLI entry point
|
|
38
|
+
│ ├── cli.js
|
|
39
|
+
│ ├── commands/ # CLI commands
|
|
40
|
+
│ └── utils/ # CLI utilities
|
|
41
|
+
├── src/
|
|
42
|
+
│ ├── core/ # Core extraction scripts
|
|
43
|
+
│ │ ├── screenshot.js # Multi-viewport screenshots
|
|
44
|
+
│ │ ├── filter-css.js # CSS filtering
|
|
45
|
+
│ │ └── extract-assets.js
|
|
46
|
+
│ ├── ai/ # AI analysis scripts
|
|
47
|
+
│ │ ├── analyze-structure.py
|
|
48
|
+
│ │ └── extract-design-tokens.py
|
|
49
|
+
│ ├── verification/ # Verification scripts
|
|
50
|
+
│ │ ├── verify-menu.js
|
|
51
|
+
│ │ └── verify-layout.js
|
|
52
|
+
│ ├── utils/ # Shared utilities
|
|
53
|
+
│ │ ├── browser.js
|
|
54
|
+
│ │ ├── puppeteer.js
|
|
55
|
+
│ │ ├── env.js
|
|
56
|
+
│ │ └── env.py
|
|
57
|
+
│ └── post-process/ # Post-processing
|
|
58
|
+
│ ├── fetch-images.js
|
|
59
|
+
│ ├── inject-icons.js
|
|
60
|
+
│ └── enhance-assets.js
|
|
61
|
+
├── tests/ # Test files
|
|
62
|
+
├── templates/ # HTML/CSS templates
|
|
63
|
+
├── docs/ # Documentation
|
|
64
|
+
└── package.json
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Commands
|
|
68
|
+
|
|
69
|
+
### design:clone
|
|
70
|
+
|
|
71
|
+
Basic design capture with Font Awesome icons and Unsplash images.
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
/design:clone https://example.com
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
**Workflow:**
|
|
78
|
+
```bash
|
|
79
|
+
# Step 1: Capture screenshots + HTML/CSS
|
|
80
|
+
node src/core/screenshot.js \
|
|
81
|
+
--url "URL" \
|
|
82
|
+
--output ./output \
|
|
83
|
+
--extract-html \
|
|
84
|
+
--extract-css
|
|
85
|
+
|
|
86
|
+
# Step 2: Filter unused CSS
|
|
87
|
+
node src/core/filter-css.js \
|
|
88
|
+
--html ./output/source.html \
|
|
89
|
+
--css ./output/source-raw.css \
|
|
90
|
+
--output ./output/source.css
|
|
91
|
+
|
|
92
|
+
# Step 3: Quality Check with ui-ux-pro-max (REQUIRED)
|
|
93
|
+
python3 $HOME/.claude/skills/ui-ux-pro-max/scripts/search.py "accessibility" --domain ux
|
|
94
|
+
python3 $HOME/.claude/skills/ui-ux-pro-max/scripts/search.py "animation hover" --domain ux
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
**Key Features:**
|
|
98
|
+
- Screenshots + HTML/CSS extraction
|
|
99
|
+
- Font Awesome 6 CDN icons
|
|
100
|
+
- Direct Unsplash image URLs (no API)
|
|
101
|
+
- Japanese design principles (Ma, Kanso, Shibui, Seijaku)
|
|
102
|
+
- Mobile-first responsive CSS
|
|
103
|
+
- **ui-ux-pro-max quality validation**
|
|
104
|
+
|
|
105
|
+
**Output:** desktop.png, tablet.png, mobile.png, source.html, source.css, source-raw.css
|
|
106
|
+
|
|
107
|
+
### design:clone-px
|
|
108
|
+
|
|
109
|
+
Pixel-perfect clone with full asset extraction and AI analysis.
|
|
110
|
+
|
|
111
|
+
**Full Workflow:**
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
# Step 1: Capture + Extract
|
|
115
|
+
node src/core/screenshot.js \
|
|
116
|
+
--url "URL" \
|
|
117
|
+
--output ./output \
|
|
118
|
+
--extract-html --extract-css \
|
|
119
|
+
--full-page
|
|
120
|
+
|
|
121
|
+
# Step 2: Filter CSS
|
|
122
|
+
node src/core/filter-css.js \
|
|
123
|
+
--html ./output/source.html \
|
|
124
|
+
--css ./output/source-raw.css \
|
|
125
|
+
--output ./output/source.css
|
|
126
|
+
|
|
127
|
+
# Step 3: Extract Assets (images, fonts, icons)
|
|
128
|
+
node src/core/extract-assets.js \
|
|
129
|
+
--url "URL" \
|
|
130
|
+
--output ./output
|
|
131
|
+
|
|
132
|
+
# Step 4: AI Structure Analysis (requires GEMINI_API_KEY)
|
|
133
|
+
python src/ai/analyze-structure.py \
|
|
134
|
+
-s ./output/desktop.png \
|
|
135
|
+
-o ./output \
|
|
136
|
+
--html ./output/source.html \
|
|
137
|
+
--css ./output/source.css
|
|
138
|
+
|
|
139
|
+
# Step 5: Extract Design Tokens
|
|
140
|
+
python src/ai/extract-design-tokens.py \
|
|
141
|
+
-s ./output/desktop.png \
|
|
142
|
+
-o ./output
|
|
143
|
+
|
|
144
|
+
# Step 6: Verify Menu
|
|
145
|
+
node src/verification/verify-menu.js \
|
|
146
|
+
--html ./output/source.html
|
|
147
|
+
|
|
148
|
+
# Step 7: Quality Check with ui-ux-pro-max (REQUIRED)
|
|
149
|
+
python3 $HOME/.claude/skills/ui-ux-pro-max/scripts/search.py "accessibility" --domain ux
|
|
150
|
+
python3 $HOME/.claude/skills/ui-ux-pro-max/scripts/search.py "animation hover" --domain ux
|
|
151
|
+
python3 $HOME/.claude/skills/ui-ux-pro-max/scripts/search.py "z-index" --domain ux
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
## Quality Checklist (ui-ux-pro-max)
|
|
155
|
+
|
|
156
|
+
After generating HTML/CSS, verify these items using `ui-ux-pro-max` skill:
|
|
157
|
+
|
|
158
|
+
### Visual Quality
|
|
159
|
+
- [ ] No emojis used as icons (use Font Awesome instead)
|
|
160
|
+
- [ ] All icons from Font Awesome 6 (consistent sizing)
|
|
161
|
+
- [ ] Hover states don't cause layout shift
|
|
162
|
+
|
|
163
|
+
### Interaction
|
|
164
|
+
- [ ] All clickable elements have `cursor-pointer`
|
|
165
|
+
- [ ] Hover states provide clear visual feedback
|
|
166
|
+
- [ ] Transitions are smooth (150-300ms)
|
|
167
|
+
|
|
168
|
+
### Accessibility
|
|
169
|
+
- [ ] All images have alt text
|
|
170
|
+
- [ ] Form inputs have labels
|
|
171
|
+
- [ ] Color is not the only indicator
|
|
172
|
+
- [ ] Sufficient text contrast (4.5:1 minimum)
|
|
173
|
+
|
|
174
|
+
### Layout
|
|
175
|
+
- [ ] Floating elements have proper spacing
|
|
176
|
+
- [ ] No content hidden behind fixed navbars
|
|
177
|
+
- [ ] Responsive at 320px, 768px, 1024px, 1440px
|
|
178
|
+
|
|
179
|
+
## Icon Usage (Font Awesome 6)
|
|
180
|
+
|
|
181
|
+
```html
|
|
182
|
+
<!-- CDN in <head> -->
|
|
183
|
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
|
|
184
|
+
|
|
185
|
+
<!-- Icons -->
|
|
186
|
+
<i class="fa-solid fa-house"></i>
|
|
187
|
+
<i class="fa-solid fa-envelope"></i>
|
|
188
|
+
<i class="fa-brands fa-x-twitter"></i>
|
|
189
|
+
<i class="fa-brands fa-line"></i>
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
## Image Usage (Direct Unsplash)
|
|
193
|
+
|
|
194
|
+
```html
|
|
195
|
+
<!-- No API needed - direct URL format -->
|
|
196
|
+
<img src="https://images.unsplash.com/photo-{PHOTO_ID}?w={WIDTH}&h={HEIGHT}&fit=crop&q=80" alt="Description">
|
|
197
|
+
|
|
198
|
+
<!-- Example -->
|
|
199
|
+
<img src="https://images.unsplash.com/photo-1523050854058-8df90110c9f1?w=800&h=600&fit=crop&q=80" alt="Students">
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
## Japanese Design Principles
|
|
203
|
+
|
|
204
|
+
| Principle | Description | CSS Implementation |
|
|
205
|
+
|-----------|-------------|-------------------|
|
|
206
|
+
| Ma (間) | Negative space | Generous padding/margins |
|
|
207
|
+
| Kanso (簡素) | Simplicity | Limited colors, clean typography |
|
|
208
|
+
| Shibui (渋い) | Subtle elegance | Soft shadows, gentle transitions |
|
|
209
|
+
| Seijaku (静寂) | Tranquility | Calm colors, visual harmony |
|
|
210
|
+
|
|
211
|
+
## Environment Variables
|
|
212
|
+
|
|
213
|
+
Create `.env` file (see `.env.example`):
|
|
214
|
+
|
|
215
|
+
```bash
|
|
216
|
+
GEMINI_API_KEY=your-key # Optional: enables AI structure analysis
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
## Script Reference
|
|
220
|
+
|
|
221
|
+
| Script | Location | Purpose |
|
|
222
|
+
|--------|----------|---------|
|
|
223
|
+
| screenshot.js | src/core/ | Capture screenshots + extract HTML/CSS |
|
|
224
|
+
| filter-css.js | src/core/ | Filter unused CSS rules |
|
|
225
|
+
| extract-assets.js | src/core/ | Download images, fonts, icons |
|
|
226
|
+
| analyze-structure.py | src/ai/ | AI-powered structure analysis |
|
|
227
|
+
| extract-design-tokens.py | src/ai/ | Extract colors, typography, spacing |
|
|
228
|
+
| verify-menu.js | src/verification/ | Validate navigation structure |
|
|
229
|
+
| verify-layout.js | src/verification/ | Verify layout consistency |
|
|
230
|
+
| fetch-images.js | src/post-process/ | Fetch and optimize images |
|
|
231
|
+
| inject-icons.js | src/post-process/ | Replace icons with Font Awesome |
|
|
232
|
+
| enhance-assets.js | src/post-process/ | Enhance extracted assets |
|
|
233
|
+
|
|
234
|
+
## References
|
|
235
|
+
|
|
236
|
+
- [Basic Clone](docs/basic-clone.md) - Step-by-step basic workflow
|
|
237
|
+
- [Pixel Perfect](docs/pixel-perfect.md) - Full pixel-perfect workflow
|
|
238
|
+
- [CLI Reference](docs/cli-reference.md) - All script options
|
|
239
|
+
- [Troubleshooting](docs/troubleshooting.md) - Common issues and fixes
|
package/bin/cli.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Design Clone Skill CLI
|
|
4
|
+
*
|
|
5
|
+
* Usage:
|
|
6
|
+
* design-clone init [--force] Install skill to ~/.claude/skills/
|
|
7
|
+
* design-clone verify Check installation status
|
|
8
|
+
* design-clone help Show help
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { init } from './commands/init.js';
|
|
12
|
+
import { verify } from './commands/verify.js';
|
|
13
|
+
import { help } from './commands/help.js';
|
|
14
|
+
|
|
15
|
+
const [,, command, ...args] = process.argv;
|
|
16
|
+
|
|
17
|
+
async function main() {
|
|
18
|
+
try {
|
|
19
|
+
switch (command) {
|
|
20
|
+
case 'init':
|
|
21
|
+
case 'install':
|
|
22
|
+
await init(args);
|
|
23
|
+
break;
|
|
24
|
+
case 'verify':
|
|
25
|
+
case 'check':
|
|
26
|
+
await verify();
|
|
27
|
+
break;
|
|
28
|
+
case 'help':
|
|
29
|
+
case '--help':
|
|
30
|
+
case '-h':
|
|
31
|
+
case undefined:
|
|
32
|
+
help();
|
|
33
|
+
break;
|
|
34
|
+
default:
|
|
35
|
+
console.error(`Unknown command: ${command}`);
|
|
36
|
+
console.error('Run "design-clone help" for usage');
|
|
37
|
+
process.exit(1);
|
|
38
|
+
}
|
|
39
|
+
} catch (error) {
|
|
40
|
+
console.error(`Error: ${error.message}`);
|
|
41
|
+
process.exit(1);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
main();
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Help command - display usage information
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export function help() {
|
|
6
|
+
console.log(`
|
|
7
|
+
design-clone - Claude Code skill for website design cloning
|
|
8
|
+
|
|
9
|
+
Usage:
|
|
10
|
+
design-clone init [options] Install skill to ~/.claude/skills/
|
|
11
|
+
design-clone verify Check installation status
|
|
12
|
+
design-clone help Show this help
|
|
13
|
+
|
|
14
|
+
Options:
|
|
15
|
+
--force, -f Overwrite existing installation
|
|
16
|
+
--skip-deps Skip dependency installation
|
|
17
|
+
|
|
18
|
+
Examples:
|
|
19
|
+
design-clone init # Install skill
|
|
20
|
+
design-clone init --force # Reinstall, overwrite existing
|
|
21
|
+
design-clone verify # Check if installed correctly
|
|
22
|
+
|
|
23
|
+
After installation:
|
|
24
|
+
1. Set GEMINI_API_KEY in ~/.claude/.env (optional, for AI analysis)
|
|
25
|
+
2. Use /design:clone or /design:clone-px in Claude Code
|
|
26
|
+
|
|
27
|
+
For more info: https://github.com/bienhoang/design-clone
|
|
28
|
+
`);
|
|
29
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Init command - install skill to ~/.claude/skills/
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import fs from 'fs/promises';
|
|
6
|
+
import path from 'path';
|
|
7
|
+
import { fileURLToPath } from 'url';
|
|
8
|
+
import { exec as execCallback } from 'child_process';
|
|
9
|
+
import { promisify } from 'util';
|
|
10
|
+
import { copyRecursive, exists } from '../utils/copy.js';
|
|
11
|
+
import { runAllChecks } from '../utils/validate.js';
|
|
12
|
+
|
|
13
|
+
const exec = promisify(execCallback);
|
|
14
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
15
|
+
|
|
16
|
+
// Source: package root (where SKILL.md is)
|
|
17
|
+
const SKILL_SOURCE = path.resolve(__dirname, '../..');
|
|
18
|
+
// Destination: ~/.claude/skills/design-clone
|
|
19
|
+
const getSkillDest = () => path.join(process.env.HOME || process.env.USERPROFILE || '', '.claude/skills/design-clone');
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Install skill to Claude Code skills directory
|
|
23
|
+
* @param {string[]} args - CLI arguments
|
|
24
|
+
*/
|
|
25
|
+
export async function init(args) {
|
|
26
|
+
const force = args.includes('--force') || args.includes('-f');
|
|
27
|
+
const skipDeps = args.includes('--skip-deps');
|
|
28
|
+
const SKILL_DEST = getSkillDest();
|
|
29
|
+
|
|
30
|
+
console.log('design-clone skill installer\n');
|
|
31
|
+
|
|
32
|
+
// Pre-flight checks
|
|
33
|
+
console.log('Checking requirements...');
|
|
34
|
+
const checks = await runAllChecks();
|
|
35
|
+
|
|
36
|
+
console.log(` Node.js: ${checks.node.ok ? '✓' : '✗'} ${checks.node.message}`);
|
|
37
|
+
console.log(` Python: ${checks.python.ok ? '✓' : '✗'} ${checks.python.message}`);
|
|
38
|
+
console.log(` Chrome: ${checks.chrome.ok ? '✓' : '✗'} ${checks.chrome.message}`);
|
|
39
|
+
console.log('');
|
|
40
|
+
|
|
41
|
+
if (!checks.node.ok) {
|
|
42
|
+
console.error('Error: Node.js 18+ is required');
|
|
43
|
+
process.exit(1);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (!checks.python.ok) {
|
|
47
|
+
console.warn('Warning: Python 3.9+ not found. AI analysis features will be unavailable.');
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (!checks.chrome.ok) {
|
|
51
|
+
console.warn('Warning: Chrome not found. Screenshots may not work without Puppeteer\'s bundled Chromium.');
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Check existing installation
|
|
55
|
+
const alreadyExists = await exists(SKILL_DEST);
|
|
56
|
+
if (alreadyExists && !force) {
|
|
57
|
+
console.log(`Skill already installed at: ${SKILL_DEST}`);
|
|
58
|
+
console.log('Use --force to overwrite existing installation.');
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Copy skill files
|
|
63
|
+
console.log('Installing skill files...');
|
|
64
|
+
try {
|
|
65
|
+
// Ensure parent directory exists
|
|
66
|
+
await fs.mkdir(path.dirname(SKILL_DEST), { recursive: true });
|
|
67
|
+
|
|
68
|
+
// Remove existing if force
|
|
69
|
+
if (alreadyExists && force) {
|
|
70
|
+
await fs.rm(SKILL_DEST, { recursive: true, force: true });
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Copy files (excluding test files and node_modules)
|
|
74
|
+
await copyRecursive(SKILL_SOURCE, SKILL_DEST, {
|
|
75
|
+
exclude: [
|
|
76
|
+
'node_modules',
|
|
77
|
+
'.git',
|
|
78
|
+
'__pycache__',
|
|
79
|
+
'test-*.js',
|
|
80
|
+
'test-*.py',
|
|
81
|
+
'run-all-tests.js',
|
|
82
|
+
'.DS_Store',
|
|
83
|
+
'*.log',
|
|
84
|
+
'cloned-designs',
|
|
85
|
+
'test-output',
|
|
86
|
+
'icons'
|
|
87
|
+
]
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
console.log(` Copied to: ${SKILL_DEST}`);
|
|
91
|
+
} catch (error) {
|
|
92
|
+
console.error(`Error copying files: ${error.message}`);
|
|
93
|
+
process.exit(1);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Install dependencies
|
|
97
|
+
if (!skipDeps) {
|
|
98
|
+
// Node.js dependencies
|
|
99
|
+
console.log('Installing Node.js dependencies...');
|
|
100
|
+
try {
|
|
101
|
+
await exec('npm install --omit=dev', { cwd: SKILL_DEST });
|
|
102
|
+
console.log(' npm packages installed');
|
|
103
|
+
} catch (error) {
|
|
104
|
+
console.warn(` Warning: npm install failed: ${error.message}`);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// Python dependencies
|
|
108
|
+
if (checks.python.ok) {
|
|
109
|
+
console.log('Installing Python dependencies...');
|
|
110
|
+
try {
|
|
111
|
+
await exec('pip install -r requirements.txt', { cwd: SKILL_DEST });
|
|
112
|
+
console.log(' Python packages installed');
|
|
113
|
+
} catch (error) {
|
|
114
|
+
console.warn(` Warning: pip install failed: ${error.message}`);
|
|
115
|
+
console.warn(' Try: pip install google-genai');
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// Success
|
|
121
|
+
console.log('\n✓ design-clone skill installed successfully!\n');
|
|
122
|
+
console.log('Next steps:');
|
|
123
|
+
console.log(' 1. (Optional) Set GEMINI_API_KEY in ~/.claude/.env for AI analysis');
|
|
124
|
+
console.log(' 2. Use /design:clone or /design:clone-px in Claude Code');
|
|
125
|
+
console.log('\nRun "design-clone verify" to check installation status.');
|
|
126
|
+
}
|