real-prototypes-skill 0.1.3 → 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/.claude/skills/real-prototypes-skill/examples/CLAUDE.md.example +36 -16
- package/CLAUDE.md.example +93 -0
- package/bin/cli.js +12 -1
- package/package.json +2 -1
- package/.claude/skills/real-prototypes-skill/INSTALL.md +0 -259
- package/.claude/skills/real-prototypes-skill/PUBLISH.md +0 -310
- package/.claude/skills/real-prototypes-skill/references/accessibility-fixes.md +0 -298
- package/.claude/skills/real-prototypes-skill/references/accessibility-report.json +0 -253
- package/.claude/skills/real-prototypes-skill/scripts/CAPTURE-ENHANCEMENTS.md +0 -344
- package/.claude/skills/real-prototypes-skill/scripts/IMPLEMENTATION-SUMMARY.md +0 -517
- package/.claude/skills/real-prototypes-skill/scripts/QUICK-START.md +0 -229
- package/.claude/skills/real-prototypes-skill/scripts/QUICKSTART-layout-analysis.md +0 -148
- package/.claude/skills/real-prototypes-skill/scripts/README-analyze-layout.md +0 -407
|
@@ -1,407 +0,0 @@
|
|
|
1
|
-
# Layout & Component Structure Analysis
|
|
2
|
-
|
|
3
|
-
## Overview
|
|
4
|
-
|
|
5
|
-
`analyze-layout.js` is a comprehensive script that analyzes captured web pages to extract:
|
|
6
|
-
|
|
7
|
-
1. **Layout Patterns**: Grid systems, flexbox usage, positioning, container widths
|
|
8
|
-
2. **Component Patterns**: Buttons, forms, cards, modals, navigation, tables
|
|
9
|
-
3. **HTML Structure**: Semantic HTML with bounding boxes and element hierarchy
|
|
10
|
-
4. **UI Library Detection**: Material-UI, Ant Design, Bootstrap, Tailwind, Chakra UI, etc.
|
|
11
|
-
5. **Landmarks**: Header, navigation, main, aside, footer elements
|
|
12
|
-
|
|
13
|
-
## Installation
|
|
14
|
-
|
|
15
|
-
Requires Playwright:
|
|
16
|
-
|
|
17
|
-
```bash
|
|
18
|
-
npm install playwright
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
## Usage
|
|
22
|
-
|
|
23
|
-
### Basic Usage
|
|
24
|
-
|
|
25
|
-
```bash
|
|
26
|
-
# Analyze all captured pages in references directory
|
|
27
|
-
node analyze-layout.js
|
|
28
|
-
|
|
29
|
-
# Specify custom paths
|
|
30
|
-
node analyze-layout.js /path/to/references /path/to/output.json
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
### Arguments
|
|
34
|
-
|
|
35
|
-
1. **references-dir** (optional): Path to references directory containing `html/` and `screenshots/` folders
|
|
36
|
-
- Default: `../../../references`
|
|
37
|
-
|
|
38
|
-
2. **output-file** (optional): Path to output structure manifest JSON file
|
|
39
|
-
- Default: `{references-dir}/structure-manifest.json`
|
|
40
|
-
|
|
41
|
-
## Output Files
|
|
42
|
-
|
|
43
|
-
### 1. structure-manifest.json
|
|
44
|
-
|
|
45
|
-
Main output file containing aggregated analysis from all pages:
|
|
46
|
-
|
|
47
|
-
```json
|
|
48
|
-
{
|
|
49
|
-
"generatedAt": "2026-01-26T10:00:00Z",
|
|
50
|
-
"pagesAnalyzed": 14,
|
|
51
|
-
"layout": {
|
|
52
|
-
"type": "sidebar-main",
|
|
53
|
-
"sidebar": {
|
|
54
|
-
"width": "240px",
|
|
55
|
-
"position": "fixed",
|
|
56
|
-
"top": "0px",
|
|
57
|
-
"left": "0px",
|
|
58
|
-
"boundingBox": {
|
|
59
|
-
"x": 0,
|
|
60
|
-
"y": 0,
|
|
61
|
-
"width": 240,
|
|
62
|
-
"height": 1080
|
|
63
|
-
}
|
|
64
|
-
},
|
|
65
|
-
"grid": {
|
|
66
|
-
"columns": "repeat(12, 1fr)",
|
|
67
|
-
"gap": "24px"
|
|
68
|
-
},
|
|
69
|
-
"flex": {
|
|
70
|
-
"direction": "row",
|
|
71
|
-
"justifyContent": "space-between",
|
|
72
|
-
"alignItems": "center",
|
|
73
|
-
"gap": "16px"
|
|
74
|
-
},
|
|
75
|
-
"containers": {
|
|
76
|
-
"maxWidth": "1600px"
|
|
77
|
-
}
|
|
78
|
-
},
|
|
79
|
-
"components": {
|
|
80
|
-
"button": {
|
|
81
|
-
"totalCount": 45,
|
|
82
|
-
"variants": {
|
|
83
|
-
"primary": {
|
|
84
|
-
"count": 20,
|
|
85
|
-
"example": { ... }
|
|
86
|
-
},
|
|
87
|
-
"secondary": {
|
|
88
|
-
"count": 15,
|
|
89
|
-
"example": { ... }
|
|
90
|
-
},
|
|
91
|
-
"ghost": {
|
|
92
|
-
"count": 10,
|
|
93
|
-
"example": { ... }
|
|
94
|
-
}
|
|
95
|
-
},
|
|
96
|
-
"examples": [ ... ]
|
|
97
|
-
},
|
|
98
|
-
"card": { ... },
|
|
99
|
-
"input": { ... }
|
|
100
|
-
},
|
|
101
|
-
"library": "material-ui",
|
|
102
|
-
"commonPatterns": {}
|
|
103
|
-
}
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
### 2. component-map-{page}.json
|
|
107
|
-
|
|
108
|
-
Per-page component mapping files:
|
|
109
|
-
|
|
110
|
-
```json
|
|
111
|
-
{
|
|
112
|
-
"page": "dashboard",
|
|
113
|
-
"layout": {
|
|
114
|
-
"type": "sidebar-main",
|
|
115
|
-
"sidebar": { ... },
|
|
116
|
-
"header": { ... },
|
|
117
|
-
"footer": { ... }
|
|
118
|
-
},
|
|
119
|
-
"components": {
|
|
120
|
-
"button": {
|
|
121
|
-
"count": 5,
|
|
122
|
-
"variants": [ ... ],
|
|
123
|
-
"examples": [ ... ]
|
|
124
|
-
}
|
|
125
|
-
},
|
|
126
|
-
"library": {
|
|
127
|
-
"primary": "material-ui",
|
|
128
|
-
"detected": ["material-ui"]
|
|
129
|
-
},
|
|
130
|
-
"landmarks": {
|
|
131
|
-
"header": { ... },
|
|
132
|
-
"navigation": [ ... ],
|
|
133
|
-
"main": { ... },
|
|
134
|
-
"aside": [ ... ],
|
|
135
|
-
"footer": { ... }
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
## Features
|
|
141
|
-
|
|
142
|
-
### Layout Detection
|
|
143
|
-
|
|
144
|
-
- **Layout Type**: Detects common patterns (sidebar-main, single-main)
|
|
145
|
-
- **Grid Systems**: Extracts grid-template-columns, gap, etc.
|
|
146
|
-
- **Flexbox**: Extracts direction, justify-content, align-items, gap
|
|
147
|
-
- **Positioning**: Detects fixed, sticky, absolute elements with coordinates
|
|
148
|
-
- **Containers**: Finds max-width, padding, margin patterns
|
|
149
|
-
- **Sidebar/Header/Footer**: Extracts dimensions and positioning
|
|
150
|
-
|
|
151
|
-
### Component Detection
|
|
152
|
-
|
|
153
|
-
Detects and analyzes:
|
|
154
|
-
- **Buttons**: Variants (primary, secondary, ghost), sizes (sm, md, lg)
|
|
155
|
-
- **Inputs**: Text inputs, textareas, selects, contenteditable
|
|
156
|
-
- **Cards**: Panel components with padding, borders, shadows
|
|
157
|
-
- **Modals**: Dialog components with overlay positioning
|
|
158
|
-
- **Navigation**: Nav bars, sidebars, dropdown menus
|
|
159
|
-
- **Tables**: Data tables with headers, rows, sorting
|
|
160
|
-
- **Forms**: Form elements with labels, validation
|
|
161
|
-
|
|
162
|
-
For each component type:
|
|
163
|
-
- **Count**: Total instances found
|
|
164
|
-
- **Variants**: Different style variants detected
|
|
165
|
-
- **Styles**: Padding, margin, border, colors, fonts, shadows
|
|
166
|
-
- **Bounding Box**: Position and dimensions
|
|
167
|
-
- **Attributes**: ARIA labels, roles, data attributes
|
|
168
|
-
|
|
169
|
-
### UI Library Detection
|
|
170
|
-
|
|
171
|
-
Detects popular UI frameworks:
|
|
172
|
-
- **Material-UI**: Looks for `Mui*` classes, `@mui/` imports
|
|
173
|
-
- **Ant Design**: Looks for `ant-*` classes, `anticon`
|
|
174
|
-
- **Bootstrap**: Looks for `btn`, `card`, `container`, `row`, `col-*`
|
|
175
|
-
- **Tailwind CSS**: Looks for utility classes (`flex`, `grid`, `p-*`, `m-*`)
|
|
176
|
-
- **Chakra UI**: Looks for `chakra-*` classes
|
|
177
|
-
- **Semantic UI**: Looks for `ui *` classes
|
|
178
|
-
- **Custom**: If no framework detected
|
|
179
|
-
|
|
180
|
-
### HTML Structure Extraction
|
|
181
|
-
|
|
182
|
-
- Preserves semantic HTML tags
|
|
183
|
-
- Captures class names and IDs
|
|
184
|
-
- Extracts ARIA attributes
|
|
185
|
-
- Extracts data attributes
|
|
186
|
-
- Maps element hierarchy (up to 10 levels deep)
|
|
187
|
-
- Includes bounding boxes for all elements
|
|
188
|
-
|
|
189
|
-
### Landmark Extraction
|
|
190
|
-
|
|
191
|
-
Identifies key page regions:
|
|
192
|
-
- **Header**: `<header>` or `role="banner"`
|
|
193
|
-
- **Navigation**: `<nav>` or `role="navigation"`
|
|
194
|
-
- **Main**: `<main>` or `role="main"`
|
|
195
|
-
- **Aside**: `<aside>` or `role="complementary"`
|
|
196
|
-
- **Footer**: `<footer>` or `role="contentinfo"`
|
|
197
|
-
|
|
198
|
-
## Example Output
|
|
199
|
-
|
|
200
|
-
### Console Output
|
|
201
|
-
|
|
202
|
-
```
|
|
203
|
-
🔍 Analyzing layout and component structure...
|
|
204
|
-
References: /path/to/references
|
|
205
|
-
Output: /path/to/references/structure-manifest.json
|
|
206
|
-
|
|
207
|
-
📄 Found 14 pages to analyze
|
|
208
|
-
|
|
209
|
-
Analyzing: dashboard...
|
|
210
|
-
✓ Layout: sidebar-main
|
|
211
|
-
✓ Library: material-ui
|
|
212
|
-
✓ Components: 7 types detected
|
|
213
|
-
✓ Component map saved: /path/to/references/component-map-dashboard.json
|
|
214
|
-
|
|
215
|
-
Analyzing: settings...
|
|
216
|
-
✓ Layout: sidebar-main
|
|
217
|
-
✓ Library: material-ui
|
|
218
|
-
✓ Components: 5 types detected
|
|
219
|
-
✓ Component map saved: /path/to/references/component-map-settings.json
|
|
220
|
-
|
|
221
|
-
...
|
|
222
|
-
|
|
223
|
-
📦 Generating structure manifest...
|
|
224
|
-
|
|
225
|
-
✅ Analysis complete!
|
|
226
|
-
|
|
227
|
-
Structure manifest: /path/to/references/structure-manifest.json
|
|
228
|
-
Pages analyzed: 14
|
|
229
|
-
Primary layout: sidebar-main
|
|
230
|
-
UI library: material-ui
|
|
231
|
-
Component types: button, input, card, modal, navigation, table, form
|
|
232
|
-
|
|
233
|
-
📊 Component Summary:
|
|
234
|
-
button: 45 instances
|
|
235
|
-
Variants: primary, secondary, ghost
|
|
236
|
-
input: 28 instances
|
|
237
|
-
Variants: default
|
|
238
|
-
card: 12 instances
|
|
239
|
-
Variants: default
|
|
240
|
-
navigation: 2 instances
|
|
241
|
-
Variants: default
|
|
242
|
-
table: 5 instances
|
|
243
|
-
Variants: default
|
|
244
|
-
|
|
245
|
-
💡 Next steps:
|
|
246
|
-
1. Review structure-manifest.json for layout patterns
|
|
247
|
-
2. Review component-map-*.json for per-page component details
|
|
248
|
-
3. Use this data to generate pixel-perfect prototypes
|
|
249
|
-
```
|
|
250
|
-
|
|
251
|
-
## Use Cases
|
|
252
|
-
|
|
253
|
-
### 1. Prototype Generation
|
|
254
|
-
|
|
255
|
-
Use the structure manifest to generate components that match the original platform:
|
|
256
|
-
|
|
257
|
-
```javascript
|
|
258
|
-
// Read structure manifest
|
|
259
|
-
const manifest = JSON.parse(fs.readFileSync('references/structure-manifest.json', 'utf-8'));
|
|
260
|
-
|
|
261
|
-
// Get button variants
|
|
262
|
-
const buttonVariants = manifest.components.button.variants;
|
|
263
|
-
|
|
264
|
-
// Generate matching Button component
|
|
265
|
-
generateButtonComponent(buttonVariants);
|
|
266
|
-
```
|
|
267
|
-
|
|
268
|
-
### 2. Design System Extraction
|
|
269
|
-
|
|
270
|
-
Extract design tokens from component styles:
|
|
271
|
-
|
|
272
|
-
```javascript
|
|
273
|
-
const manifest = JSON.parse(fs.readFileSync('references/structure-manifest.json', 'utf-8'));
|
|
274
|
-
|
|
275
|
-
// Extract colors from primary buttons
|
|
276
|
-
const primaryButton = manifest.components.button.variants.primary.example;
|
|
277
|
-
const primaryColor = primaryButton.styles.backgroundColor;
|
|
278
|
-
|
|
279
|
-
// Extract spacing from cards
|
|
280
|
-
const card = manifest.components.card.examples[0];
|
|
281
|
-
const cardPadding = card.styles.padding;
|
|
282
|
-
```
|
|
283
|
-
|
|
284
|
-
### 3. Layout Recreation
|
|
285
|
-
|
|
286
|
-
Recreate the exact layout structure:
|
|
287
|
-
|
|
288
|
-
```javascript
|
|
289
|
-
const manifest = JSON.parse(fs.readFileSync('references/structure-manifest.json', 'utf-8'));
|
|
290
|
-
|
|
291
|
-
// Get layout configuration
|
|
292
|
-
const layout = manifest.layout;
|
|
293
|
-
|
|
294
|
-
// Generate layout component
|
|
295
|
-
if (layout.type === 'sidebar-main') {
|
|
296
|
-
generateSidebarLayout(layout.sidebar, layout.containers);
|
|
297
|
-
}
|
|
298
|
-
```
|
|
299
|
-
|
|
300
|
-
### 4. Component Library Detection
|
|
301
|
-
|
|
302
|
-
Determine what UI library to use:
|
|
303
|
-
|
|
304
|
-
```javascript
|
|
305
|
-
const manifest = JSON.parse(fs.readFileSync('references/structure-manifest.json', 'utf-8'));
|
|
306
|
-
|
|
307
|
-
if (manifest.library === 'material-ui') {
|
|
308
|
-
console.log('Use @mui/material components');
|
|
309
|
-
} else if (manifest.library === 'custom') {
|
|
310
|
-
console.log('Build custom components from scratch');
|
|
311
|
-
}
|
|
312
|
-
```
|
|
313
|
-
|
|
314
|
-
## Integration with Prototype Generation
|
|
315
|
-
|
|
316
|
-
This script is designed to work with the Platform Prototype Skill:
|
|
317
|
-
|
|
318
|
-
1. **Capture Phase**: Run `full-site-capture.js` to capture platform pages
|
|
319
|
-
2. **Analysis Phase**: Run `analyze-layout.js` to analyze structure ← **YOU ARE HERE**
|
|
320
|
-
3. **Generation Phase**: Use structure manifest to generate prototypes
|
|
321
|
-
|
|
322
|
-
## Troubleshooting
|
|
323
|
-
|
|
324
|
-
### Error: References directory not found
|
|
325
|
-
|
|
326
|
-
```bash
|
|
327
|
-
❌ Error: References directory not found at /path/to/references
|
|
328
|
-
Run full-site-capture.js first to capture pages.
|
|
329
|
-
```
|
|
330
|
-
|
|
331
|
-
**Solution**: Run `full-site-capture.js` first to capture platform pages.
|
|
332
|
-
|
|
333
|
-
### Error: No HTML files found to analyze
|
|
334
|
-
|
|
335
|
-
```bash
|
|
336
|
-
❌ Error: No HTML files found to analyze
|
|
337
|
-
```
|
|
338
|
-
|
|
339
|
-
**Solution**: Ensure the `html/` subdirectory exists and contains `.html` files.
|
|
340
|
-
|
|
341
|
-
### Browser Launch Errors
|
|
342
|
-
|
|
343
|
-
If Playwright fails to launch:
|
|
344
|
-
|
|
345
|
-
```bash
|
|
346
|
-
# Install browsers
|
|
347
|
-
npx playwright install chromium
|
|
348
|
-
```
|
|
349
|
-
|
|
350
|
-
## Advanced Configuration
|
|
351
|
-
|
|
352
|
-
### Custom Component Patterns
|
|
353
|
-
|
|
354
|
-
Modify `COMPONENT_PATTERNS` in the script to detect custom component types:
|
|
355
|
-
|
|
356
|
-
```javascript
|
|
357
|
-
const COMPONENT_PATTERNS = {
|
|
358
|
-
// Add custom pattern
|
|
359
|
-
dropdown: {
|
|
360
|
-
selectors: ['.dropdown', '[role="listbox"]'],
|
|
361
|
-
attributes: ['aria-expanded', 'aria-controls'],
|
|
362
|
-
},
|
|
363
|
-
// ... other patterns
|
|
364
|
-
};
|
|
365
|
-
```
|
|
366
|
-
|
|
367
|
-
### Custom UI Library Detection
|
|
368
|
-
|
|
369
|
-
Add custom library patterns to `UI_LIBRARY_PATTERNS`:
|
|
370
|
-
|
|
371
|
-
```javascript
|
|
372
|
-
const UI_LIBRARY_PATTERNS = {
|
|
373
|
-
// Add custom library
|
|
374
|
-
'my-ui-lib': [
|
|
375
|
-
/myui-/,
|
|
376
|
-
/@myui\//,
|
|
377
|
-
],
|
|
378
|
-
// ... other libraries
|
|
379
|
-
};
|
|
380
|
-
```
|
|
381
|
-
|
|
382
|
-
## Performance
|
|
383
|
-
|
|
384
|
-
- **Speed**: ~2-3 seconds per page
|
|
385
|
-
- **Memory**: ~100MB per page
|
|
386
|
-
- **Output Size**: ~50-200KB per page JSON
|
|
387
|
-
|
|
388
|
-
For large sites (50+ pages), expect:
|
|
389
|
-
- Runtime: 2-5 minutes
|
|
390
|
-
- Total output: 5-10MB
|
|
391
|
-
|
|
392
|
-
## Next Steps
|
|
393
|
-
|
|
394
|
-
After running this script:
|
|
395
|
-
|
|
396
|
-
1. Review `structure-manifest.json` to understand overall platform patterns
|
|
397
|
-
2. Review individual `component-map-*.json` files for page-specific details
|
|
398
|
-
3. Use the data to inform prototype generation
|
|
399
|
-
4. Run `extract-tokens.js` to extract detailed design tokens
|
|
400
|
-
5. Generate Tailwind config with `generate-tailwind-config.js`
|
|
401
|
-
|
|
402
|
-
## See Also
|
|
403
|
-
|
|
404
|
-
- `full-site-capture.js` - Capture platform pages
|
|
405
|
-
- `extract-tokens.js` - Extract design tokens
|
|
406
|
-
- `generate-tailwind-config.js` - Generate Tailwind configuration
|
|
407
|
-
- `create-manifest.js` - Create page manifest
|