designlang 7.0.0 → 7.2.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 (77) hide show
  1. package/.github/og-preview.png +0 -0
  2. package/.github/workflows/manavarya-bot.yml +17 -0
  3. package/.vercel/README.txt +11 -0
  4. package/.vercel/project.json +1 -0
  5. package/CHANGELOG.md +29 -0
  6. package/CONTRIBUTING.md +25 -0
  7. package/README.md +38 -11
  8. package/bin/design-extract.js +41 -2
  9. package/chrome-extension/README.md +41 -0
  10. package/chrome-extension/icons/favicon.svg +7 -0
  11. package/chrome-extension/icons/icon-128.png +0 -0
  12. package/chrome-extension/icons/icon-16.png +0 -0
  13. package/chrome-extension/icons/icon-32.png +0 -0
  14. package/chrome-extension/icons/icon-48.png +0 -0
  15. package/chrome-extension/manifest.json +26 -0
  16. package/chrome-extension/popup.html +167 -0
  17. package/chrome-extension/popup.js +59 -0
  18. package/docs/superpowers/specs/2026-04-18-website-redesign-design.md +120 -0
  19. package/docs/superpowers/specs/2026-04-19-designlang-v7-1-design.md +111 -0
  20. package/package.json +1 -1
  21. package/src/config.js +5 -1
  22. package/src/crawler.js +361 -2
  23. package/src/extractors/interaction-states.js +57 -0
  24. package/src/extractors/modern-css.js +100 -0
  25. package/src/extractors/token-sources.js +65 -0
  26. package/src/extractors/wide-gamut.js +47 -0
  27. package/src/formatters/routes-reconciliation.js +160 -0
  28. package/src/index.js +29 -0
  29. package/src/utils/color-gamut.js +82 -0
  30. package/src/utils-cookies.js +73 -0
  31. package/tests/cookies.test.js +98 -0
  32. package/tests/interaction-states.test.js +62 -0
  33. package/tests/modern-css.test.js +104 -0
  34. package/tests/routes-reconciliation.test.js +120 -0
  35. package/tests/wide-gamut.test.js +90 -0
  36. package/website/app/api/extract/route.js +216 -56
  37. package/website/app/components/A11ySlider.js +369 -0
  38. package/website/app/components/Comparison.js +286 -0
  39. package/website/app/components/CssHealth.js +243 -0
  40. package/website/app/components/HeroExtractor.js +455 -0
  41. package/website/app/components/Marginalia.js +3 -0
  42. package/website/app/components/McpSection.js +223 -0
  43. package/website/app/components/PlatformTabs.js +250 -0
  44. package/website/app/components/RegionsComponents.js +429 -0
  45. package/website/app/components/Rule.js +13 -0
  46. package/website/app/components/Specimens.js +237 -0
  47. package/website/app/components/StructuredData.js +144 -0
  48. package/website/app/components/TokenBrowser.js +344 -0
  49. package/website/app/components/token-browser-sample.js +65 -0
  50. package/website/app/globals.css +415 -633
  51. package/website/app/icon.svg +7 -0
  52. package/website/app/layout.js +113 -6
  53. package/website/app/opengraph-image.js +170 -0
  54. package/website/app/page.js +372 -148
  55. package/website/app/robots.js +15 -0
  56. package/website/app/seo-config.js +82 -0
  57. package/website/app/sitemap.js +18 -0
  58. package/website/lib/cache.js +73 -0
  59. package/website/lib/rate-limit.js +30 -0
  60. package/website/lib/rate-limit.test.js +55 -0
  61. package/website/lib/specimens.json +86 -0
  62. package/website/lib/token-helpers.js +70 -0
  63. package/website/lib/url-safety.js +103 -0
  64. package/website/lib/url-safety.test.js +116 -0
  65. package/website/lib/zip-files.js +15 -0
  66. package/website/package-lock.json +85 -0
  67. package/website/package.json +1 -0
  68. package/website/public/favicon.svg +7 -0
  69. package/website/public/logo-specimen.svg +76 -0
  70. package/website/public/mark.svg +12 -0
  71. package/website/public/site.webmanifest +13 -0
  72. package/website/app/favicon.ico +0 -0
  73. package/website/public/file.svg +0 -1
  74. package/website/public/globe.svg +0 -1
  75. package/website/public/next.svg +0 -1
  76. package/website/public/vercel.svg +0 -1
  77. package/website/public/window.svg +0 -1
@@ -0,0 +1,120 @@
1
+ # designlang website redesign — Wave 2
2
+
3
+ **Date:** 2026-04-18
4
+ **Status:** Approved for implementation
5
+ **Direction:** Live Design DNA — the site embodies what designlang does.
6
+
7
+ ## Non-negotiables (from user)
8
+
9
+ - No "AI slop" aesthetic. No purple/blue gradients. No glassmorphism. No floating hero cards.
10
+ - **No emoji. No icon libraries** (Lucide, Heroicons, Phosphor). Iconography only as intent-drawn inline SVG, numerals, or letterforms.
11
+ - No Framer Motion bloat, no fade-up-on-every-element scroll theatrics.
12
+ - Copy must be earned, not templated.
13
+ - Designer voice visible — marginalia, footnotes, document-feel.
14
+
15
+ ## Visual system
16
+
17
+ **Base:** warm paper `#F3F1EA`, ink `#0A0908`, accent `#FF4800` (used once per screen, maximum).
18
+ **Grays (warm):** `#D8D3C5`, `#8B8778`, `#403C34`.
19
+ **Type:** Fraunces (display, optical 9pt, massive sizes), Instrument Sans (body), JetBrains Mono (mono/tokens).
20
+ **Grid:** 12-col, 24px gutters, deliberately broken by marginalia and side notes.
21
+ **Rules:** 1px solid ink hairlines everywhere (document feel), no soft dividers.
22
+ **Shadow:** one hard offset shadow (`6px 6px 0 #FF4800`) on the primary CTA only.
23
+ **Dark mode:** deferred. Paper-first matches design-system/archival feel.
24
+ **Motion:** prefers-reduced-motion strict. All motion is content-matched (see §Signature Interactions).
25
+
26
+ ## Page structure
27
+
28
+ Single-page scroll. Numbered sections like a monograph: `§00`…`§09`.
29
+
30
+ - §00 `HERO` — URL input + live extraction stream; tokens paint on screen as they compute.
31
+ - §01 `DTCG BROWSER` — interactive alias resolver. Click a semantic token, the line flies to its primitive.
32
+ - §02 `MCP` — split: Cursor/Claude Code rule panel on left, real terminal transcript on right.
33
+ - §03 `MULTI-PLATFORM` — tabs Web / iOS / Android / Flutter / WordPress; same token in 5 languages.
34
+ - §04 `CSS HEALTH` — big numerals (unused %, `!important` count, duplicates) set against real specificity plot.
35
+ - §05 `A11Y REMEDIATION` — before/after contrast slider with live ratio.
36
+ - §06 `REGIONS + COMPONENTS` — annotated screenshot; button cluster animates into variants.
37
+ - §07 `FEATURED SPECIMENS` — stripe / vercel / linear / github / figma / apple; each extracted and displayed like a museum specimen. Page accent shifts as you scroll between them.
38
+ - §08 `COMPARISON` — transparent, opinionated table vs. v0, Builder.io, Style Dictionary, Subframe, Project Wallace.
39
+ - §09 `INSTALL & FOOTER` — `npx designlang`, MCP config, Cursor rule install, GitHub/npm/Discussions/sponsor.
40
+
41
+ ## Signature interactions (motion only where content-matched)
42
+
43
+ 1. **Hero stream** — user submits URL, server streams back tokens in extraction order; swatches paint from left to right as server events arrive.
44
+ 2. **DTCG alias flight** — click `{primitive.color.brand.primary}` string, an SVG line animates from the semantic token to the primitive, primitive highlights, hex resolves inline.
45
+ 3. **Accent shift scroll** — as the Featured Specimens section scrolls, page accent CSS var transitions to each specimen's extracted primary.
46
+ 4. **A11y slider** — handle drag shows contrast ratio updating live above the color pair.
47
+ 5. **MCP terminal transcript** — real JSON-RPC lines, typed at realistic speed, showing `search_tokens` → result.
48
+ 6. **Component cluster unfold** — a single button card unfolds into its detected variants on scroll-into-view.
49
+
50
+ No other motion.
51
+
52
+ ## Backend
53
+
54
+ **Existing:** `/api/extract` route using `@sparticuz/chromium` + `playwright-core` + designlang `extractDesignLanguage`.
55
+
56
+ **Changes required:**
57
+
58
+ 1. **v7.0 output parity** — currently the API returns v6 shape. Add DTCG tokens, agent rules, MCP companion JSON, multi-platform outputs.
59
+ 2. **Streaming response** — the extraction produces tokens progressively; stream them over an HTTP stream (Next.js 16 streaming response) so the hero demo paints live. If extraction is atomic today (single `page.evaluate`), we stream the *stages*: crawl → colors → typography → spacing → components → a11y → done.
60
+ 3. **Rate limiting** — Vercel Edge Config or in-memory map keyed by IP. 3 extractions per IP per day for anonymous, soft 429 with helpful copy. No login.
61
+ 4. **URL validation** — reject `localhost`, `127.x`, `169.254.x`, `10.x`, `172.16–31.x`, `192.168.x`, `file://`, non-http(s). Reject URLs whose DNS resolves to private ranges.
62
+ 5. **Timeout cap** — hard 45s; abort Playwright if exceeded.
63
+ 6. **Caching** — cache extraction result by URL in Vercel Blob for 24h. Collision: same URL within 24h returns cached zip + a small "cached" annotation.
64
+ 7. **Bot detection** — Vercel BotID (free, platform-native).
65
+ 8. **Output:** downloadable `.zip` of all generated files (same set the CLI would produce for `--platforms all --emit-agent-rules`) plus a JSON summary for the on-screen preview.
66
+
67
+ **New/changed files:**
68
+ - `website/app/api/extract/route.js` — streaming + rate limit + caching + v7.0 outputs
69
+ - `website/lib/rate-limit.js` (new)
70
+ - `website/lib/url-safety.js` (new)
71
+ - `website/lib/cache.js` (new, Vercel Blob-backed)
72
+
73
+ ## Frontend components (new)
74
+
75
+ Kept flat in `website/app/components/`. Each is a self-contained section:
76
+
77
+ - `Hero.js` — URL input + live stream renderer
78
+ - `TokenBrowser.js` — DTCG alias resolver
79
+ - `McpSection.js` — split editor + terminal
80
+ - `PlatformTabs.js` — multi-platform code viewer
81
+ - `CssHealth.js` — numerals + specificity plot (hand-drawn SVG scatter)
82
+ - `A11ySlider.js` — contrast before/after
83
+ - `RegionsComponents.js` — annotated image + cluster unfold
84
+ - `Specimens.js` — featured site grid; orchestrates accent shift
85
+ - `Comparison.js` — opinionated feature matrix
86
+ - `InstallFooter.js` — closing section
87
+ - `Marginalia.js` — shared side-column component for footnotes and command labels
88
+ - `Rule.js` — 1px hairline divider with section label
89
+
90
+ New lib:
91
+ - `website/lib/token-helpers.js` — DTCG alias resolution shared with components
92
+ - `website/lib/specimens.json` — pre-extracted data for the featured section (generated at build time from the CLI so specimens are real)
93
+
94
+ ## Deferred (explicit non-goals for Wave 2)
95
+
96
+ - Login / user accounts / saved extractions
97
+ - Paid tiers
98
+ - Dark mode
99
+ - Blog / changelog page
100
+ - i18n
101
+ - Sharable `/x/<slug>` permalinks (nice-to-have but not Wave 2)
102
+
103
+ ## Test / verification plan
104
+
105
+ - Lighthouse: LCP ≤ 2.0s on the hero at 3G-Fast, CLS 0, accessibility ≥ 95.
106
+ - `prefers-reduced-motion: reduce` — verify all motion stops or substitutes with non-motion reveal.
107
+ - Keyboard navigation through every interactive element.
108
+ - Extractor end-to-end: submit real URL, receive streamed tokens, download zip, verify zip contains v7.0 shape.
109
+ - Rate limit: 4th request from same IP returns 429 with copy.
110
+ - URL safety: localhost, private IPs, `file://` all rejected with 400.
111
+
112
+ ## Implementation chunks (PR per chunk)
113
+
114
+ Each chunk is one PR. Merge before starting the next, same pattern as v7.0 release.
115
+
116
+ - **PR A: Foundation** — fonts, base CSS, grid primitives, `Rule`, `Marginalia`, new `globals.css`, `layout.js`, clean `page.js` scaffold.
117
+ - **PR B: Hero + streaming extraction API** — hero component, API streaming, URL safety, rate limit, basic Blob cache.
118
+ - **PR C: Core showcase sections** — DTCG browser, MCP section, multi-platform tabs.
119
+ - **PR D: Analytics sections** — CSS health, a11y slider, regions + components.
120
+ - **PR E: Specimens + comparison + install + footer + deploy** — pre-extract data at build time, accent-shift scroll, comparison table, final polish, Vercel deploy.
@@ -0,0 +1,111 @@
1
+ # designlang v7.1 — Designer Toolkit
2
+
3
+ **Date:** 2026-04-19
4
+ **Status:** Approved for implementation
5
+
6
+ ## Theme
7
+
8
+ *From extractor to designer's toolkit.* v7.0 shipped the full extraction surface. v7.1 makes the output composable, auditable, and complete — pull one component at a time, get every brand asset alongside the tokens, drop into any stack (Tailwind v4, Emotion, Stitches, Vanilla Extract, Panda), and fail your CI when production drifts from your design system.
9
+
10
+ ## Scope (7 features)
11
+
12
+ ### 1. Single-component extraction
13
+ New flag: `designlang <url> --component <css-selector>`.
14
+ - Playwright walks to the matched element, captures its own computed styles + its children's styles + its bounding box + its text content.
15
+ - Emits a tiny extraction: `*-component.md` (a specimen-style card), `*-component.json` (the DTCG subset actually used by this component), `*-component.tsx` / `*-component.vue` / `*-component.svelte` based on `--framework` (or all three by default).
16
+ - `--component` can be combined with `--platforms all` and `--emit-agent-rules`.
17
+
18
+ ### 2. Asset / brand-kit extraction
19
+ New flag: `designlang <url> --assets` (also implied by `--full`).
20
+ - Crawler enumerates every `<img>`, `<picture>`, `<source>`, `<svg>` (reuse existing icons work), `<link rel="icon">`, `<meta property="og:image">`, and CSS `background-image` URLs.
21
+ - Downloads each asset with a timeout and size cap (50MB total per extraction).
22
+ - Classifies: `logo`, `icon`, `illustration`, `photo`, `hero`, `og`, `favicon`, `avatar`, `screenshot`, `other`.
23
+ - Emits to `<out>/assets/<kind>/<original-filename-or-hash.ext>` plus `assets-manifest.json` with the type, source URL, dimensions, byte size, and an `srcset`-style variant list for `<picture>` elements.
24
+ - Size-aware: don't download a 20MB hero if it exceeds a per-asset cap (default 5MB). Log skipped assets in the manifest with a `skipped: reason` field.
25
+
26
+ ### 3. Illustration detection (folded into #2)
27
+ - SVGs ≥ 200px or with >30 path elements → classified `illustration`, not `icon`.
28
+ - Inline-SVG illustrations captured alongside external file references.
29
+ - Raster illustrations (transparent PNG with flat-color regions) classified separately from photos via dominant-color entropy heuristic.
30
+
31
+ ### 4. Tailwind v4 `@theme` formatter
32
+ New output file `<prefix>-tailwind.css` (separate from the existing `*-tailwind.config.js`, which stays for v3 users).
33
+ - Uses the Tailwind v4 `@theme { … }` block syntax inside a `@import "tailwindcss"` wrapper.
34
+ - Maps DTCG semantic tokens → Tailwind v4 CSS custom properties.
35
+ - Respects `--tokens-legacy` (v4 file still emitted but from primitive-only JSON).
36
+
37
+ ### 5. CSS-in-JS emitters
38
+ Four new formatters under `src/formatters/css-in-js/`:
39
+ - `emotion.js` → `<prefix>-emotion.theme.ts`
40
+ - `stitches.js` → `<prefix>-stitches.config.ts`
41
+ - `vanilla-extract.js` → `<prefix>-vanilla.css.ts`
42
+ - `panda.js` → `<prefix>-panda.config.ts`
43
+
44
+ Selectable via new flag: `--framework emotion|stitches|vanilla-extract|panda|tailwind4`. Multi-select: `--framework emotion,stitches`. Default behavior unchanged: emit React theme + shadcn theme.
45
+
46
+ ### 6. Drift detection + GitHub Action
47
+ New command: `designlang drift <url> <tokens-path> [--out <report-path>] [--fail-on <category>] [--tolerance <n>]`.
48
+ - Extracts from `<url>`, loads DTCG JSON at `<tokens-path>`, walks both trees, and produces a report:
49
+ - `added` tokens (in extraction, not in file)
50
+ - `removed` (in file, not in extraction)
51
+ - `changed` (path matches, `$value` differs beyond tolerance)
52
+ - Tolerance: colors use ΔE threshold (default 3), dimensions use px delta (default 1), others exact match.
53
+ - `--fail-on color|dimension|typography|all` controls exit code (default exits 0 for a report-only run; exit 1 when any matching drift found with `--fail-on`).
54
+ - Emits `drift-report.md` + `drift-report.json`.
55
+ - **GitHub Action:** new `.github/workflows/designlang-drift.yml` template committed to this repo under `templates/github-action/designlang-drift.yml` with a README snippet. Runs on PR + daily cron, posts the report as a PR comment when drift is detected.
56
+
57
+ ### 7. Release
58
+ - Bump to `7.1.0`, CHANGELOG entry, README updates, npm publish, git tag.
59
+
60
+ ## Non-goals (deferred to v7.2+)
61
+
62
+ - **Remix Mode** / interactive web editor — substantial Next.js work; needs its own spec.
63
+ - **Figma plugin**, **Chrome extension**, **VS Code extension** — each is a separate package with its own store/review cycle.
64
+ - **Brand-voice extraction** (tone, reading level) — out of scope for a token release.
65
+ - **Token marketplace / shared workspaces** — hosted SaaS territory.
66
+
67
+ ## Architecture
68
+
69
+ ### New files
70
+ - `src/extractors/component.js` — selector-scoped extraction
71
+ - `src/extractors/assets.js` — classifier + downloader for images and illustrations
72
+ - `src/formatters/tailwind-v4.js`
73
+ - `src/formatters/css-in-js/emotion.js`
74
+ - `src/formatters/css-in-js/stitches.js`
75
+ - `src/formatters/css-in-js/vanilla-extract.js`
76
+ - `src/formatters/css-in-js/panda.js`
77
+ - `src/formatters/component-snippet.js` — emits JSX / Vue / Svelte / HTML snippet from a component extraction
78
+ - `src/formatters/drift.js` — produces drift-report.md + drift-report.json
79
+ - `src/drift.js` — orchestrator for the `drift` subcommand
80
+ - `templates/github-action/designlang-drift.yml`
81
+ - `templates/github-action/README.md`
82
+
83
+ ### Modified files
84
+ - `src/crawler.js` — add `fetchAssets()` with per-asset timeout + cap; add `page.$(selector).then(el => el.evaluate(...))` path for `--component`
85
+ - `src/index.js` — wire new extractors + output files
86
+ - `bin/design-extract.js` — new flags + `drift` subcommand
87
+ - `src/config.js` — thread new options (`component`, `assets`, `framework`, driftTolerance)
88
+ - `tests/extractors.test.js` + `tests/formatters.test.js` — new tests per extractor/formatter
89
+ - `package.json` — version bump, potentially add `sharp` for optional raster resize (deferred decision — only if it stays zero-runtime-cost)
90
+ - `README.md`
91
+ - `CHANGELOG.md`
92
+
93
+ ### Dependencies
94
+ - No new runtime deps. Image downloads use Node 20's native `fetch`. Classifier is heuristic only (no ML).
95
+
96
+ ### Security / safety
97
+ - Asset downloader respects the same URL-safety layer as the website API (no private IPs, http(s) only, byte cap).
98
+ - Same-origin preferred; cross-origin assets downloaded with an `Accept` header and a 10s timeout each.
99
+
100
+ ## Tests
101
+
102
+ - Unit tests per extractor and formatter, snapshot-style for golden outputs.
103
+ - Integration smoke: `designlang <url> --component "header nav" --assets --framework emotion,stitches,vanilla-extract,panda,tailwind4` produces all expected files.
104
+ - Drift integration test: run against a fixture tokens file and a live URL, confirm report contents.
105
+
106
+ ## Release plan
107
+
108
+ 1. Implement via subagents in 3 parallel chunks (component+assets, emitters, drift+action).
109
+ 2. Tests green.
110
+ 3. README + CHANGELOG.
111
+ 4. Version bump → PR → merge → npm publish → tag.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "designlang",
3
- "version": "7.0.0",
3
+ "version": "7.2.0",
4
4
  "description": "Extract the complete design language from any website — colors, typography, spacing, shadows, and more. Outputs AI-optimized markdown, W3C design tokens, Tailwind config, and CSS variables.",
5
5
  "type": "module",
6
6
  "bin": {
package/src/config.js CHANGED
@@ -27,7 +27,8 @@ export function mergeConfig(cliOpts, config) {
27
27
  screenshots: cliOpts.screenshots || config.screenshots || false,
28
28
  framework: cliOpts.framework || config.framework,
29
29
  responsive: cliOpts.responsive || config.responsive || false,
30
- interactions: cliOpts.interactions || config.interactions || false,
30
+ interactions: cliOpts.interactions || cliOpts.deepInteract || config.interactions || false,
31
+ deepInteract: cliOpts.deepInteract || config.deepInteract || false,
31
32
  full: cliOpts.full || config.full || false,
32
33
  cookie: cliOpts.cookie || config.cookies,
33
34
  header: cliOpts.header || config.headers,
@@ -35,6 +36,9 @@ export function mergeConfig(cliOpts, config) {
35
36
  tokensLegacy: cliOpts.tokensLegacy || config.tokensLegacy || false,
36
37
  platforms: parsePlatforms(cliOpts.platforms ?? config.platforms ?? 'web'),
37
38
  emitAgentRules: cliOpts.emitAgentRules || config.emitAgentRules || false,
39
+ cookieFile: cliOpts.cookieFile || config.cookieFile,
40
+ insecure: cliOpts.insecure || config.insecure || false,
41
+ userAgent: cliOpts.userAgent || config.userAgent,
38
42
  };
39
43
  }
40
44