designlang 5.0.0 → 7.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.
Files changed (51) hide show
  1. package/.github/FUNDING.yml +1 -0
  2. package/.github/ISSUE_TEMPLATE/bug_report.yml +62 -0
  3. package/.github/ISSUE_TEMPLATE/config.yml +8 -0
  4. package/.github/ISSUE_TEMPLATE/feature_request.yml +28 -0
  5. package/CHANGELOG.md +43 -0
  6. package/README.md +177 -6
  7. package/bin/design-extract.js +302 -92
  8. package/docs/superpowers/plans/2026-04-18-designlang-v7.md +1121 -0
  9. package/docs/superpowers/specs/2026-04-18-designlang-v7-design.md +150 -0
  10. package/package.json +13 -7
  11. package/src/config.js +59 -0
  12. package/src/crawler.js +297 -95
  13. package/src/extractors/a11y-remediation.js +47 -0
  14. package/src/extractors/animations.js +37 -5
  15. package/src/extractors/borders.js +40 -5
  16. package/src/extractors/component-clusters.js +39 -0
  17. package/src/extractors/components.js +77 -1
  18. package/src/extractors/css-health.js +151 -0
  19. package/src/extractors/gradients.js +25 -5
  20. package/src/extractors/scoring.js +20 -1
  21. package/src/extractors/semantic-regions.js +44 -0
  22. package/src/extractors/shadows.js +60 -17
  23. package/src/extractors/spacing.js +31 -2
  24. package/src/extractors/stack-fingerprint.js +88 -0
  25. package/src/extractors/variables.js +20 -1
  26. package/src/formatters/_token-ref.js +44 -0
  27. package/src/formatters/agent-rules.js +116 -0
  28. package/src/formatters/android-compose.js +164 -0
  29. package/src/formatters/dtcg-tokens.js +175 -0
  30. package/src/formatters/figma.js +66 -47
  31. package/src/formatters/flutter-dart.js +130 -0
  32. package/src/formatters/ios-swiftui.js +161 -0
  33. package/src/formatters/markdown.js +25 -0
  34. package/src/formatters/preview.js +65 -22
  35. package/src/formatters/svelte-theme.js +40 -0
  36. package/src/formatters/tailwind.js +57 -4
  37. package/src/formatters/theme.js +134 -0
  38. package/src/formatters/vue-theme.js +44 -0
  39. package/src/formatters/wordpress.js +267 -0
  40. package/src/history.js +8 -1
  41. package/src/index.js +76 -20
  42. package/src/mcp/resources.js +64 -0
  43. package/src/mcp/server.js +110 -0
  44. package/src/mcp/tools.js +149 -0
  45. package/src/utils.js +68 -0
  46. package/tests/cli.test.js +84 -0
  47. package/tests/extractors.test.js +792 -0
  48. package/tests/formatters.test.js +709 -0
  49. package/tests/mcp.test.js +68 -0
  50. package/tests/utils.test.js +413 -0
  51. package/website/app/globals.css +11 -11
@@ -0,0 +1 @@
1
+ github: [Manavarya09]
@@ -0,0 +1,62 @@
1
+ name: Bug report
2
+ description: Something in designlang is broken or produces wrong output.
3
+ title: "[Bug]: "
4
+ labels: ["bug"]
5
+ body:
6
+ - type: input
7
+ id: url
8
+ attributes:
9
+ label: URL extracted
10
+ description: The site you ran designlang against.
11
+ placeholder: https://example.com
12
+ validations:
13
+ required: true
14
+ - type: input
15
+ id: command
16
+ attributes:
17
+ label: Command used
18
+ description: The exact command you ran.
19
+ placeholder: npx designlang https://example.com --full
20
+ validations:
21
+ required: true
22
+ - type: textarea
23
+ id: expected
24
+ attributes:
25
+ label: What you expected
26
+ validations:
27
+ required: true
28
+ - type: textarea
29
+ id: actual
30
+ attributes:
31
+ label: What actually happened
32
+ description: Include stack traces, log output, or relevant snippets from output files.
33
+ validations:
34
+ required: true
35
+ - type: input
36
+ id: version
37
+ attributes:
38
+ label: designlang version
39
+ description: Output of `npx designlang --version` (or the version in package.json)
40
+ placeholder: 7.0.0
41
+ validations:
42
+ required: true
43
+ - type: input
44
+ id: node
45
+ attributes:
46
+ label: Node.js version
47
+ description: Output of `node --version`
48
+ placeholder: v20.11.0
49
+ validations:
50
+ required: true
51
+ - type: input
52
+ id: os
53
+ attributes:
54
+ label: OS
55
+ placeholder: macOS 14.5 / Ubuntu 22.04 / Windows 11
56
+ validations:
57
+ required: true
58
+ - type: textarea
59
+ id: extra
60
+ attributes:
61
+ label: Anything else
62
+ description: Screenshots, env variables, network constraints, auth requirements, etc.
@@ -0,0 +1,8 @@
1
+ blank_issues_enabled: false
2
+ contact_links:
3
+ - name: Question or discussion
4
+ url: https://github.com/Manavarya09/design-extract/discussions
5
+ about: Ask a question, share an extraction, or discuss ideas.
6
+ - name: designlang website
7
+ url: https://website-five-lime-65.vercel.app
8
+ about: Read more about what designlang does.
@@ -0,0 +1,28 @@
1
+ name: Feature request
2
+ description: Suggest a new extraction, output format, or CLI capability.
3
+ title: "[Feature]: "
4
+ labels: ["enhancement"]
5
+ body:
6
+ - type: textarea
7
+ id: problem
8
+ attributes:
9
+ label: Problem
10
+ description: What are you trying to do that designlang doesn't support today?
11
+ validations:
12
+ required: true
13
+ - type: textarea
14
+ id: proposal
15
+ attributes:
16
+ label: Proposal
17
+ description: What should designlang do? CLI flag, command, new extractor, new output format?
18
+ validations:
19
+ required: true
20
+ - type: textarea
21
+ id: alternatives
22
+ attributes:
23
+ label: Alternatives you've considered
24
+ - type: textarea
25
+ id: context
26
+ attributes:
27
+ label: Additional context
28
+ description: Example sites, example outputs, links to similar tools, screenshots.
package/CHANGELOG.md ADDED
@@ -0,0 +1,43 @@
1
+ # Changelog
2
+
3
+ ## [7.0.0] — 2026-04-18
4
+
5
+ ### Breaking
6
+
7
+ - **Design token JSON format** — the default `*-design-tokens.json` now follows the W3C Design Tokens Community Group (DTCG) v1 spec: every leaf is `{ "$value": ..., "$type": ... }`, with two layers (`primitive.*` and `semantic.*`) and composite tokens for typography, shadow, border, and gradient. If a downstream consumer expects the pre-v7 flat shape, pass `--tokens-legacy` to preserve it.
8
+
9
+ Before (v6):
10
+ ```json
11
+ { "color": { "primary": "#3b82f6" }, "fontFamily": { "sans": "Inter" } }
12
+ ```
13
+
14
+ After (v7, default):
15
+ ```json
16
+ {
17
+ "$metadata": { "generator": "designlang", "version": "7.0.0" },
18
+ "primitive": { "color": { "brand": { "primary": { "$value": "#3b82f6", "$type": "color" } } } },
19
+ "semantic": { "color": { "action": { "primary": { "$value": "{primitive.color.brand.primary}", "$type": "color" } } } }
20
+ }
21
+ ```
22
+
23
+ Migration: either (a) update consumers to read the DTCG shape (recommended — long-term stable, ecosystem-compatible), or (b) add `--tokens-legacy` to the CLI invocation.
24
+
25
+ ### Added
26
+
27
+ - **MCP server** — new `designlang mcp --output-dir <dir>` subcommand. Stdio JSON-RPC. Resources: `designlang://tokens/primitive`, `designlang://tokens/semantic`, `designlang://regions`, `designlang://components`, `designlang://health`. Tools: `search_tokens`, `find_nearest_color`, `get_region`, `get_component`, `list_failing_contrast_pairs`.
28
+ - **Agent rules emitter** — `--emit-agent-rules` writes `.cursor/rules/designlang.mdc`, `.claude/skills/designlang/SKILL.md`, `CLAUDE.md.fragment`, and `agents.md`. All four template from the resolved semantic tokens.
29
+ - **Multi-platform emitters** — `--platforms <csv>` (values `web`, `ios`, `android`, `flutter`, `wordpress`, `all`). Additive to default web output. Emits iOS SwiftUI, Android Compose + XML, Flutter Dart + ThemeData, and a full WordPress block-theme skeleton (`theme.json` v3, `style.css`, `functions.php`, `index.php`, `templates/index.html`).
30
+ - **Stack + Tailwind fingerprint** — framework detection, Tailwind utility-class frequency map, analytics stack inventory. Surfaced on `design.stack`.
31
+ - **CSS health audit** — specificity distribution, `!important` count, duplicate declarations, unused CSS via Playwright Coverage API, `@keyframes` catalog, vendor-prefix audit. Surfaced on `design.cssHealth` and added as an additive `cssHealth` dimension in the design score.
32
+ - **A11y remediation** — for every failing WCAG contrast pair, suggests the nearest palette color that passes AA (4.5:1 / 3:1) or AAA (7:1 / 4.5:1). Surfaced on `design.accessibility.remediation`.
33
+ - **Semantic regions** — classifies page sections into `nav`, `hero`, `features`, `pricing`, `testimonials`, `cta`, `footer`, `sidebar`, `content`. Surfaced on `design.regions`.
34
+ - **Reusable component detection** — DOM subtree structural hash + cosine-similarity style vector clustering with variant detection. Surfaced on `design.componentClusters` and rendered in the markdown output.
35
+ - **MCP companion file** — `*-mcp.json` written at extract time so later `designlang mcp` invocations can serve regions / components / health / remediation from disk, not just memory.
36
+
37
+ ### Dependencies
38
+
39
+ - Added `@modelcontextprotocol/sdk` (runtime).
40
+
41
+ ### Tests
42
+
43
+ - 241/241 passing (baseline 186 + 55 new tests).
package/README.md CHANGED
@@ -45,7 +45,9 @@ npx designlang https://stripe.com --full
45
45
  | `*-theme.js` | React/CSS-in-JS theme (Chakra, Stitches, Vanilla Extract) |
46
46
  | `*-shadcn-theme.css` | shadcn/ui globals.css variables |
47
47
 
48
- The markdown output has **14 sections**: Color Palette, Typography, Spacing, Border Radii, Box Shadows, CSS Custom Properties, Breakpoints, Transitions & Animations, Component Patterns, Layout System, Responsive Design, Interaction States, Accessibility (WCAG 2.1), and Quick Start.
48
+ The markdown output has **19 sections**: Color Palette, Typography, Spacing, Border Radii, Box Shadows, CSS Custom Properties, Breakpoints, Transitions & Animations, Component Patterns (with full CSS snippets), Layout System, Responsive Design, Interaction States, Accessibility (WCAG 2.1), Gradients, Z-Index Map, SVG Icons, Font Files, Image Style Patterns, and Quick Start.
49
+
50
+ In v7 a companion `*-mcp.json` file is also written alongside the 8 outputs so that `designlang mcp` can serve regions, components, and health data from disk on later invocations. Opting into `--platforms <csv>` additively emits `ios/`, `android/`, `flutter/`, and/or `wordpress-theme/` directories in the output folder, and `--emit-agent-rules` adds a `.cursor/`, `.claude/`, `CLAUDE.md.fragment`, and `agents.md` set.
49
51
 
50
52
  ## Install
51
53
 
@@ -169,6 +171,147 @@ designlang watch https://stripe.com --interval 60
169
171
 
170
172
  Checks hourly and alerts when colors, fonts, or accessibility scores change.
171
173
 
174
+ ### 9. Apply Command (NEW in v5)
175
+
176
+ Extract a site's design and write tokens directly into your project — auto-detects your framework:
177
+
178
+ ```bash
179
+ designlang apply https://stripe.com --dir ./my-app
180
+ ```
181
+
182
+ Detects Tailwind, shadcn/ui, or plain CSS and writes to the right config files automatically.
183
+
184
+ ### 10. Auth Extraction (NEW in v5)
185
+
186
+ Extract from authenticated or protected pages with cookies and custom headers:
187
+
188
+ ```bash
189
+ designlang https://internal-app.com --cookie "session=abc123" --header "Authorization:Bearer token"
190
+ ```
191
+
192
+ ### 11. Gradient Extraction (NEW in v5)
193
+
194
+ Detects all CSS gradients — type (linear/radial/conic), direction, color stops, and classifies them as subtle, brand, bold, or complex.
195
+
196
+ ### 12. Z-Index Map (NEW in v5)
197
+
198
+ Builds a layer hierarchy from all z-index values, groups them into layers (base, sticky, dropdown, modal, etc.), and flags z-index wars or excessive values (>9999).
199
+
200
+ ### 13. SVG Icon Extraction (NEW in v5)
201
+
202
+ Finds and deduplicates all inline SVGs, classifies them by size and style (outline/solid/duotone), and extracts the icon color palette.
203
+
204
+ ### 14. Font File Detection (NEW in v5)
205
+
206
+ Identifies every font source — Google Fonts, self-hosted, CDN, or system — and generates ready-to-use `@font-face` CSS.
207
+
208
+ ### 15. Image Style Patterns (NEW in v5)
209
+
210
+ Detects image aspect ratios, border treatments, filters, and classifies patterns like avatar, hero, thumbnail, and gallery.
211
+
212
+ ### 16. Dark Mode Diffing (NEW in v5)
213
+
214
+ Compare light and dark mode side-by-side — see exactly which colors change and which CSS variables are overridden:
215
+
216
+ ```bash
217
+ designlang https://vercel.com --dark
218
+ ```
219
+
220
+ ### 17. MCP Server (NEW in v7)
221
+
222
+ One-command integration with any MCP-aware AI agent (Cursor, Claude Code, Windsurf, and more):
223
+
224
+ ```bash
225
+ designlang mcp --output-dir ./design-extract-output
226
+ ```
227
+
228
+ Launches a stdio JSON-RPC server that exposes the extracted design as MCP resources and tools.
229
+
230
+ **Resources:**
231
+
232
+ - `designlang://tokens/primitive` — primitive token layer
233
+ - `designlang://tokens/semantic` — semantic token layer (with DTCG alias references)
234
+ - `designlang://regions` — classified page regions (nav, hero, pricing, etc.)
235
+ - `designlang://components` — reusable component clusters with variants
236
+ - `designlang://health` — CSS health audit
237
+
238
+ **Tools:**
239
+
240
+ - `search_tokens` — query tokens by name, value, or type
241
+ - `find_nearest_color` — snap any color to the nearest palette token
242
+ - `get_region` — fetch a classified region by name
243
+ - `get_component` — fetch a component cluster by id
244
+ - `list_failing_contrast_pairs` — list every WCAG-failing fg/bg pair with remediation suggestions
245
+
246
+ ### 18. Multi-Platform Output (NEW in v7)
247
+
248
+ Emit iOS SwiftUI, Android Compose, Flutter, and WordPress block-theme files in a single run, in addition to the default web output:
249
+
250
+ ```bash
251
+ designlang https://stripe.com --platforms all
252
+ ```
253
+
254
+ Resulting tree:
255
+
256
+ ```
257
+ design-extract-output/
258
+ ├── stripe-com-*.{md,json,css,js,html} (default web output)
259
+ ├── ios/
260
+ │ └── DesignTokens.swift
261
+ ├── android/
262
+ │ ├── Theme.kt
263
+ │ ├── colors.xml
264
+ │ └── dimens.xml
265
+ ├── flutter/
266
+ │ └── design_tokens.dart (+ buildDesignlangTheme())
267
+ └── wordpress-theme/
268
+ ├── theme.json
269
+ ├── style.css
270
+ ├── functions.php
271
+ ├── index.php
272
+ └── templates/index.html
273
+ ```
274
+
275
+ Values for `--platforms` are any comma-separated subset of `web,ios,android,flutter,wordpress,all`. The flag is additive — the default web output is always emitted.
276
+
277
+ ### 19. Agent Rules Emitter (NEW in v7)
278
+
279
+ Write agent-facing rule files generated from the resolved semantic tokens:
280
+
281
+ ```bash
282
+ designlang https://stripe.com --emit-agent-rules
283
+ ```
284
+
285
+ Writes:
286
+
287
+ - `.cursor/rules/designlang.mdc` — Cursor rule
288
+ - `.claude/skills/designlang/SKILL.md` — Claude Code skill
289
+ - `CLAUDE.md.fragment` — snippet you can paste into your project's CLAUDE.md
290
+ - `agents.md` — generic, vendor-neutral agent guidance
291
+
292
+ Each file is templated from the semantic layer of the extracted token set, so the agent sees real token names and values — not placeholders.
293
+
294
+ ### 20. Stack + Tailwind Fingerprint (NEW in v7)
295
+
296
+ Automatic framework, utility-class, and analytics detection surfaced on `design.stack`:
297
+
298
+ - **Framework**: Next.js, Nuxt, Gatsby, Remix, Astro, Shopify, WordPress, Framer, Webflow, and more.
299
+ - **Tailwind**: when Tailwind is in use, records utility-class frequency so you see which utilities drive the design.
300
+ - **Analytics**: inventory of analytics scripts — GA4, Plausible, PostHog, Segment, Mixpanel, Amplitude, and friends.
301
+
302
+ ### 21. CSS Health Audit (NEW in v7)
303
+
304
+ A dedicated audit pass surfaced on `design.cssHealth`:
305
+
306
+ - Specificity graph (distribution, hotspots)
307
+ - `!important` count
308
+ - Duplicate declarations
309
+ - Unused CSS via the Playwright Coverage API
310
+ - `@keyframes` catalog
311
+ - Vendor-prefix audit
312
+
313
+ Also contributes a `cssHealth` dimension to the overall design score.
314
+
172
315
  ## All Features
173
316
 
174
317
  | Feature | Flag / Command | Description |
@@ -177,12 +320,19 @@ Checks hourly and alerts when colors, fonts, or accessibility scores change.
177
320
  | Layout system | automatic | Grid patterns, flex usage, container widths, gap values |
178
321
  | Accessibility | automatic | WCAG 2.1 contrast ratios for all fg/bg pairs |
179
322
  | Design scoring | automatic | 7-category quality rating (A-F) with actionable issues |
180
- | Dark mode | `--dark` | Extracts dark color scheme |
323
+ | Gradients | automatic | Gradient type, direction, stops, classification |
324
+ | Z-index map | automatic | Layer hierarchy, z-index wars detection |
325
+ | SVG icons | automatic | Deduplicated icons, size/style classification, color palette |
326
+ | Font files | automatic | Source detection (Google/self-hosted/CDN/system), @font-face CSS |
327
+ | Image styles | automatic | Aspect ratios, shapes, filters, pattern classification |
328
+ | Dark mode | `--dark` | Extracts dark color scheme + light/dark diff |
329
+ | Auth pages | `--cookie`, `--header` | Extract from authenticated/protected pages |
181
330
  | Multi-page | `--depth <n>` | Crawl N internal pages for site-wide tokens |
182
331
  | Screenshots | `--screenshots` | Capture buttons, cards, inputs, nav, hero, full page |
183
332
  | Responsive | `--responsive` | Crawl at 4 viewports, map breakpoint changes |
184
333
  | Interactions | `--interactions` | Capture hover/focus/active state transitions |
185
334
  | Everything | `--full` | Enable screenshots + responsive + interactions |
335
+ | Apply | `designlang apply <url>` | Auto-detect framework and write tokens to your project |
186
336
  | Clone | `designlang clone <url>` | Generate a working Next.js starter with extracted design |
187
337
  | Score | `designlang score <url>` | Rate design quality with visual bar chart breakdown |
188
338
  | Watch | `designlang watch <url>` | Monitor for design changes on interval |
@@ -190,6 +340,15 @@ Checks hourly and alerts when colors, fonts, or accessibility scores change.
190
340
  | Multi-brand | `designlang brands <urls...>` | N-site comparison matrix |
191
341
  | Sync | `designlang sync <url>` | Update local tokens from live site |
192
342
  | History | `designlang history <url>` | Track design changes over time |
343
+ | MCP server | `designlang mcp` | Expose extraction as MCP resources + tools |
344
+ | Multi-platform | `--platforms <csv>` | Emit iOS / Android / Flutter / WordPress outputs |
345
+ | Agent rules | `--emit-agent-rules` | Cursor, Claude Code, generic agent rule files |
346
+ | Stack fingerprint | automatic | Framework + Tailwind + analytics detection |
347
+ | CSS health | automatic | Specificity, !important, unused CSS, keyframes |
348
+ | A11y remediation | automatic | Nearest palette color passing AA / AAA for every failing pair |
349
+ | Semantic regions | automatic | nav / hero / pricing / testimonials / cta / footer classification |
350
+ | Reusable components | automatic | DOM subtree + style-vector clustering with variants |
351
+ | DTCG tokens | default | W3C Design Tokens v1 with semantic + composite layers (`--tokens-legacy` for pre-v7) |
193
352
 
194
353
  ## Full CLI Reference
195
354
 
@@ -208,11 +367,17 @@ Options:
208
367
  --responsive Capture at multiple breakpoints
209
368
  --interactions Capture hover/focus/active states
210
369
  --full Enable all captures
370
+ --cookie <cookies...> Cookies for authenticated pages (name=value)
371
+ --header <headers...> Custom headers (name:value)
211
372
  --framework <type> Only generate specific theme (react, shadcn)
373
+ --platforms <csv> Additional platforms: web,ios,android,flutter,wordpress,all (additive)
374
+ --emit-agent-rules Emit Cursor / Claude Code / CLAUDE.md / agents.md rule files
375
+ --tokens-legacy Emit pre-v7 flat design-tokens.json shape (backward compat)
212
376
  --no-history Skip saving to history
213
377
  --verbose Detailed progress output
214
378
 
215
379
  Commands:
380
+ apply <url> Extract and apply design directly to your project
216
381
  clone <url> Generate a working Next.js starter from extracted design
217
382
  score <url> Rate design quality (7 categories, A-F, bar chart)
218
383
  watch <url> Monitor for design changes on interval
@@ -220,6 +385,7 @@ Commands:
220
385
  brands <urls...> Multi-brand comparison matrix
221
386
  sync <url> Sync local tokens with live site
222
387
  history <url> View design change history
388
+ mcp Launch stdio MCP server (--output-dir <dir>)
223
389
  ```
224
390
 
225
391
  ## Example Output
@@ -252,9 +418,14 @@ Running `designlang https://vercel.com --full`:
252
418
  Shadows: 11 unique shadows
253
419
  Radii: 10 unique values
254
420
  Breakpoints: 45 breakpoints
255
- Components: 11 types detected
421
+ Components: 11 types detected (with CSS snippets)
256
422
  CSS Vars: 407 custom properties
257
423
  Layout: 55 grids, 492 flex containers
424
+ Gradients: 4 unique gradients
425
+ Z-Index: 8 layers mapped
426
+ Icons: 23 unique SVGs
427
+ Font Files: 4 font sources detected
428
+ Images: 6 style patterns
258
429
  Responsive: 4 viewports, 3 breakpoint changes
259
430
  Interactions: 8 state changes captured
260
431
  A11y: 94% WCAG score (7 failing pairs)
@@ -264,8 +435,8 @@ Running `designlang https://vercel.com --full`:
264
435
  ## How It Works
265
436
 
266
437
  1. **Crawl** — Launches headless Chromium via Playwright, waits for network idle and fonts
267
- 2. **Extract** — Single `page.evaluate()` walks up to 5,000 DOM elements collecting 25+ computed style properties including layout (grid, flex, container) data
268
- 3. **Process** — 12 extractor modules parse, deduplicate, cluster, and classify the raw data
438
+ 2. **Extract** — Single `page.evaluate()` walks up to 5,000 DOM elements collecting 25+ computed style properties, layout data, inline SVGs, font sources, and image metadata
439
+ 3. **Process** — 17 extractor modules parse, deduplicate, cluster, and classify the raw data (including gradients, z-index layers, icons, fonts, and image patterns)
269
440
  4. **Format** — 8 formatter modules generate output files
270
441
  5. **Score** — Accessibility extractor calculates WCAG contrast ratios for all color pairs
271
442
  6. **Capture** — Optional: screenshots, responsive viewport crawling, interaction state recording
@@ -290,4 +461,4 @@ See [CONTRIBUTING.md](CONTRIBUTING.md). PRs welcome!
290
461
 
291
462
  ## License
292
463
 
293
- [MIT](LICENSE) - Manavarya Singh
464
+ [MIT](LICENSE) - Manav Arya Singh