dembrandt 0.27.1 → 0.29.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 (122) hide show
  1. package/README.md +60 -369
  2. package/dist/index.js +100 -26
  3. package/dist/index.js.map +1 -1
  4. package/dist/lib/colors.d.ts +38 -2
  5. package/dist/lib/colors.js +64 -16
  6. package/dist/lib/colors.js.map +1 -1
  7. package/dist/lib/drift.js +159 -23
  8. package/dist/lib/drift.js.map +1 -1
  9. package/dist/lib/exit-codes.d.ts +3 -1
  10. package/dist/lib/exit-codes.js +3 -2
  11. package/dist/lib/exit-codes.js.map +1 -1
  12. package/dist/lib/extractors/colors.d.ts +1 -0
  13. package/dist/lib/extractors/colors.js +29 -1
  14. package/dist/lib/extractors/colors.js.map +1 -1
  15. package/dist/lib/extractors/index.js +31 -1
  16. package/dist/lib/extractors/index.js.map +1 -1
  17. package/dist/lib/extractors/typography.d.ts +18 -1
  18. package/dist/lib/extractors/typography.js +104 -2
  19. package/dist/lib/extractors/typography.js.map +1 -1
  20. package/dist/lib/extractors/voice.d.ts +12 -0
  21. package/dist/lib/extractors/voice.js +247 -0
  22. package/dist/lib/extractors/voice.js.map +1 -0
  23. package/dist/lib/formatters/html.js +23 -3
  24. package/dist/lib/formatters/html.js.map +1 -1
  25. package/dist/lib/formatters/markdown.d.ts +19 -0
  26. package/dist/lib/formatters/markdown.js +22 -0
  27. package/dist/lib/formatters/markdown.js.map +1 -1
  28. package/dist/lib/formatters/tailwind.d.ts +67 -0
  29. package/dist/lib/formatters/tailwind.js +529 -0
  30. package/dist/lib/formatters/tailwind.js.map +1 -0
  31. package/dist/lib/formatters/terminal.d.ts +4 -1
  32. package/dist/lib/formatters/terminal.js +134 -136
  33. package/dist/lib/formatters/terminal.js.map +1 -1
  34. package/dist/lib/mcp/jobs.d.ts +66 -0
  35. package/dist/lib/mcp/jobs.js +133 -0
  36. package/dist/lib/mcp/jobs.js.map +1 -0
  37. package/dist/lib/mcp/options.d.ts +58 -0
  38. package/dist/lib/mcp/options.js +76 -0
  39. package/dist/lib/mcp/options.js.map +1 -0
  40. package/dist/lib/merger.js +11 -1
  41. package/dist/lib/merger.js.map +1 -1
  42. package/dist/lib/types.d.ts +114 -3
  43. package/dist/lib/version.d.ts +28 -1
  44. package/dist/lib/version.js +28 -1
  45. package/dist/lib/version.js.map +1 -1
  46. package/dist/lib/voice/index.d.ts +11 -0
  47. package/dist/lib/voice/index.js +46 -0
  48. package/dist/lib/voice/index.js.map +1 -0
  49. package/dist/lib/voice/metrics.d.ts +14 -0
  50. package/dist/lib/voice/metrics.js +153 -0
  51. package/dist/lib/voice/metrics.js.map +1 -0
  52. package/dist/lib/voice/page-type.d.ts +12 -0
  53. package/dist/lib/voice/page-type.js +28 -0
  54. package/dist/lib/voice/page-type.js.map +1 -0
  55. package/dist/mcp-server.js +101 -139
  56. package/dist/mcp-server.js.map +1 -1
  57. package/dist/package.json +13 -3
  58. package/dist/test/cli.test.js +25 -0
  59. package/dist/test/cli.test.js.map +1 -1
  60. package/dist/test/color-format-display.test.d.ts +1 -0
  61. package/dist/test/color-format-display.test.js +234 -0
  62. package/dist/test/color-format-display.test.js.map +1 -0
  63. package/dist/test/color-format-drift.test.d.ts +1 -0
  64. package/dist/test/color-format-drift.test.js +175 -0
  65. package/dist/test/color-format-drift.test.js.map +1 -0
  66. package/dist/test/color-roundtrip.test.d.ts +1 -0
  67. package/dist/test/color-roundtrip.test.js +96 -0
  68. package/dist/test/color-roundtrip.test.js.map +1 -0
  69. package/dist/test/color-serialize.test.d.ts +1 -0
  70. package/dist/test/color-serialize.test.js +157 -0
  71. package/dist/test/color-serialize.test.js.map +1 -0
  72. package/dist/test/colors.test.js +18 -0
  73. package/dist/test/colors.test.js.map +1 -1
  74. package/dist/test/design-md-lint.test.d.ts +1 -0
  75. package/dist/test/design-md-lint.test.js +99 -0
  76. package/dist/test/design-md-lint.test.js.map +1 -0
  77. package/dist/test/drift.test.js +25 -0
  78. package/dist/test/drift.test.js.map +1 -1
  79. package/dist/test/exit-codes.test.js +9 -1
  80. package/dist/test/exit-codes.test.js.map +1 -1
  81. package/dist/test/fixtures/extractions/anthropic.com.v0.17.0.json +1070 -0
  82. package/dist/test/fixtures/extractions/apple.com.unversioned.json +1391 -0
  83. package/dist/test/fixtures/extractions/bmw.de.v0.22.0.json +1177 -0
  84. package/dist/test/fixtures/extractions/stripe.com.v0.26.0.json +3677 -0
  85. package/dist/test/helpers/tailwind-compile.d.ts +1 -0
  86. package/dist/test/helpers/tailwind-compile.js +41 -0
  87. package/dist/test/helpers/tailwind-compile.js.map +1 -0
  88. package/dist/test/mcp-jobs.test.d.ts +1 -0
  89. package/dist/test/mcp-jobs.test.js +167 -0
  90. package/dist/test/mcp-jobs.test.js.map +1 -0
  91. package/dist/test/mcp-options.test.d.ts +1 -0
  92. package/dist/test/mcp-options.test.js +136 -0
  93. package/dist/test/mcp-options.test.js.map +1 -0
  94. package/dist/test/merger.test.js +177 -0
  95. package/dist/test/merger.test.js.map +1 -1
  96. package/dist/test/tailwind-compile.test.d.ts +1 -0
  97. package/dist/test/tailwind-compile.test.js +121 -0
  98. package/dist/test/tailwind-compile.test.js.map +1 -0
  99. package/dist/test/tailwind-e2e.test.d.ts +1 -0
  100. package/dist/test/tailwind-e2e.test.js +102 -0
  101. package/dist/test/tailwind-e2e.test.js.map +1 -0
  102. package/dist/test/tailwind-fixtures.test.d.ts +1 -0
  103. package/dist/test/tailwind-fixtures.test.js +60 -0
  104. package/dist/test/tailwind-fixtures.test.js.map +1 -0
  105. package/dist/test/tailwind.test.d.ts +1 -0
  106. package/dist/test/tailwind.test.js +278 -0
  107. package/dist/test/tailwind.test.js.map +1 -0
  108. package/dist/test/terminal-display.test.d.ts +1 -0
  109. package/dist/test/terminal-display.test.js +158 -0
  110. package/dist/test/terminal-display.test.js.map +1 -0
  111. package/dist/test/typography.test.js +106 -1
  112. package/dist/test/typography.test.js.map +1 -1
  113. package/dist/test/voice-collect.test.d.ts +1 -0
  114. package/dist/test/voice-collect.test.js +175 -0
  115. package/dist/test/voice-collect.test.js.map +1 -0
  116. package/dist/test/voice-fixture.test.d.ts +1 -0
  117. package/dist/test/voice-fixture.test.js +141 -0
  118. package/dist/test/voice-fixture.test.js.map +1 -0
  119. package/dist/test/voice-metrics.test.d.ts +1 -0
  120. package/dist/test/voice-metrics.test.js +134 -0
  121. package/dist/test/voice-metrics.test.js.map +1 -0
  122. package/package.json +13 -3
package/README.md CHANGED
@@ -5,7 +5,9 @@
5
5
  [![license](https://img.shields.io/npm/l/dembrandt.svg)](https://github.com/dembrandt/dembrandt/blob/main/LICENSE)
6
6
  [![GitHub Sponsors](https://img.shields.io/badge/Sponsor-me-pink?style=flat&logo=github-sponsors)](https://github.com/sponsors/dembrandt)
7
7
 
8
- Extract a website's design system into design tokens in a few seconds: logo, colors, typography, borders, and more. One command.
8
+ Extract any website's design system in one command. Enforce it in CI.
9
+
10
+ Logo, colors, typography, spacing, borders, shadows, motion, components. W3C design tokens in seconds.
9
11
 
10
12
  ![Dembrandt: Any website to design tokens](https://raw.githubusercontent.com/dembrandt/dembrandt/main/docs/images/banner.png)
11
13
 
@@ -22,60 +24,15 @@ which ships no browser binaries, so a fresh install has nothing to launch until
22
24
  run it. Skipping it fails with `browser engine not available`.
23
25
 
24
26
  Or use npx without installing: `npx dembrandt dembrandt.com`. The browser step applies
25
- here too run `npx dembrandt install-browser` first. Browsers land in a shared
27
+ here too: run `npx dembrandt install-browser` first. Browsers land in a shared
26
28
  Playwright cache, so either route only needs it once.
27
29
 
28
30
  Requires Node.js 18+
29
31
 
30
- ## AI Agent Integration (MCP)
31
-
32
- Use Dembrandt as a tool in Claude Code, Cursor, Windsurf, or any MCP-compatible client. Ask your agent to "extract the color palette from dembrandt.com" and it calls Dembrandt automatically.
33
-
34
- ```bash
35
- claude mcp add --transport stdio dembrandt -- npx -y --package dembrandt dembrandt-mcp
36
- ```
37
-
38
- Or add to your project's `.mcp.json`:
39
-
40
- ```json
41
- {
42
- "mcpServers": {
43
- "dembrandt": {
44
- "command": "npx",
45
- "args": ["-y", "--package", "dembrandt", "dembrandt-mcp"]
46
- }
47
- }
48
- }
49
- ```
50
-
51
- Available tools include `get_design_tokens`, `get_color_palette`, `get_typography`, `get_component_styles`, `get_surfaces`, `get_spacing`, and `get_brand_identity`, plus pure analysis tools (`compute_drift`, `get_findings`, `export_dtcg`, `generate_design_md`, `render_report`) and job-control tools. Extraction tools accept `mobile`, `cookie` (for authenticated pages), and `wcag` options.
52
-
53
- Pair with **[dembrandt-skills](https://github.com/dembrandt/dembrandt-skills)** to give your agent UX intelligence on top of extracted tokens — hierarchy, accessibility, interaction states, and a full 6-stage design pipeline orchestrator.
54
-
55
- ```bash
56
- npx skills add dembrandt/dembrandt-skills
57
- ```
58
-
59
- ## Dembrandt App (Beta)
60
-
61
- Load extractions, track token drift, and compare snapshots. **[dembrandt.com/app](https://www.dembrandt.com/app)**
62
-
63
- * **Automatic drift tracking from CI.** Generate an API key at [dembrandt.com/app/api-keys](https://www.dembrandt.com/app/api-keys), then pass `--key` to the CLI. Every run uploads a snapshot to your account and scores it against the previous one for that domain. Wire into GitHub Actions or any CI runner and every deploy records itself.
64
- * **Pin a baseline.** Mark any snapshot as your reference. Every subsequent extraction is automatically scored against it.
65
- * **Visual diff.** Color swatches, before/after values, delta scores per category: colors, typography, spacing, radius, shadows.
66
- * **Snapshot timeline.** Proportional timeline per domain — scrub across any date range from days to years.
67
- * **Compare side by side.** Load multiple extractions into one view: two releases, two sites, or two surfaces.
68
- * **Copy tokens.** Paste values straight into Copilot, Claude, or Cursor.
69
- * **No login required for local use.** Data stays in the browser. Sign in with GitHub to enable cloud sync.
70
-
71
- ## Recipe library
72
-
73
- **[dembrandt.com/recipes](https://www.dembrandt.com/recipes)** — ready-to-run workflows. Copy a command, paste a prompt, get a result. Covers competitor benchmarking, WCAG audits, CI/CD drift detection, Figma token push, and agentic design system builds. Filterable by role.
74
-
75
- ## What to expect from extraction?
32
+ ## What you get
76
33
 
77
34
  - Colors (semantic, palette, CSS variables, gradients)
78
- - Typography (fonts, sizes, weights, sources)
35
+ - Typography (fonts, sizes, weights, sources, font file URLs)
79
36
  - Spacing (margin/padding scales)
80
37
  - Borders (radius, widths, styles, colors)
81
38
  - Shadows
@@ -84,363 +41,90 @@ Load extractions, track token drift, and compare snapshots. **[dembrandt.com/app
84
41
  - Breakpoints
85
42
  - Icons & frameworks
86
43
 
87
- ## Usage
88
-
89
- ```bash
90
- dembrandt <url> # Basic extraction (terminal display only)
91
- dembrandt dembrandt.com --json-only # Output raw JSON to terminal (no formatted display, no file save)
92
- dembrandt dembrandt.com --save-output # Save JSON to output/dembrandt.com/YYYY-MM-DDTHH-MM-SS.json
93
- dembrandt dembrandt.com --dtcg # Export in W3C Design Tokens (DTCG) format (auto-saves as .tokens.json)
94
- dembrandt dembrandt.com --dark-mode # Extract colors from dark mode variant
95
- dembrandt dembrandt.com --mobile # Use mobile viewport (390x844) for responsive analysis
96
- dembrandt dembrandt.com --slow # 3x longer timeouts (24s hydration) for JavaScript-heavy sites
97
- dembrandt dembrandt.com --brand-guide # Generate a brand guide PDF
98
- dembrandt dembrandt.com --design-md # Generate a DESIGN.md file for AI agents
99
- dembrandt dembrandt.com /pricing /docs # Extract specific paths and merge results into one output
100
- dembrandt dembrandt.com --crawl 5 # Analyze 5 pages (homepage + 4 discovered pages), merges results
101
- dembrandt dembrandt.com --sitemap # Discover pages from sitemap.xml instead of DOM links
102
- dembrandt dembrandt.com --crawl 10 --sitemap # Combine: up to 10 pages discovered via sitemap
103
- dembrandt dembrandt.com --no-sandbox # Disable Chromium sandbox (required for Docker/CI)
104
- dembrandt dembrandt.com --key dmb_··· # Push snapshot to your Dembrandt account; auto-scored against the previous snapshot for that domain
105
- # DEMBRANDT_API_URL env var overrides the upload endpoint (default: https://www.dembrandt.com)
106
- dembrandt dembrandt.com --browser=firefox # Use Firefox instead of Chromium (better for Cloudflare bypass)
107
- dembrandt dembrandt.com --wcag # WCAG 2.1 contrast analysis — real DOM pairs, AA/AAA grades
108
- dembrandt dembrandt.com --stealth # Opt-in anti-detection: navigator spoofing + human mouse simulation (use only when authorized)
109
- dembrandt dembrandt.com --locale fi-FI --timezone Europe/Helsinki # Browser fingerprint: locale and timezone
110
- dembrandt dembrandt.com --user-agent "Mozilla/5.0 ..." # Custom user agent string
111
- dembrandt dembrandt.com --accept-language "fi,en;q=0.9" # Custom Accept-Language header
112
- dembrandt dembrandt.com --screen-size 2560x1440 # Physical screen resolution to report
113
- ```
114
-
115
- Default: formatted terminal display only. Use `--save-output` to persist results as JSON files. Browser automatically retries in visible mode if headless extraction fails.
44
+ Playwright renders the page, dembrandt reads computed styles from the DOM, analyzes color usage and confidence, groups similar typography, detects spacing patterns, and returns design tokens.
116
45
 
117
- All flags combine unless noted otherwise: see [docs/FLAGS.md](docs/FLAGS.md) for the flag compatibility tables (interactions, ignored combinations, multi-page propagation).
118
-
119
- ### Multi-Page Extraction
120
-
121
- Analyze multiple pages to get a more complete picture of a site's design system. Results are merged into a single unified output with cross-page confidence boosting: tokens appearing on multiple pages get higher confidence scores.
46
+ ## Common flags
122
47
 
123
48
  ```bash
124
- # Analyze homepage + 4 auto-discovered pages (default: 5 total)
125
- dembrandt dembrandt.com --crawl 5
126
-
127
- # Use sitemap.xml for page discovery instead of DOM link scraping
128
- dembrandt dembrandt.com --sitemap
129
-
130
- # Combine both: up to 10 pages from sitemap
131
- dembrandt dembrandt.com --crawl 10 --sitemap
132
- ```
133
-
134
- **Page discovery** works two ways:
135
- - **DOM links** (default): Reads navigation, header, and footer links from the homepage, prioritizing key pages like /pricing, /about, /features
136
- - **Sitemap** (`--sitemap`): Parses sitemap.xml (checks robots.txt first), follows sitemapindex references, and scores URLs by importance
137
-
138
- Pages are fetched sequentially with polite delays. Failed pages are skipped without aborting the run.
139
-
140
- ### Browser Selection
141
-
142
- By default, dembrandt uses Chromium. If you encounter bot detection or timeouts (especially on sites behind Cloudflare), try Firefox which is often more successful at bypassing these protections:
143
-
144
- ```bash
145
- # One-time: install-browser defaults to chromium, so fetch firefox explicitly
146
- dembrandt install-browser firefox
147
-
148
- # Use Firefox instead of Chromium
149
- dembrandt dembrandt.com --browser=firefox
150
-
151
- # Combine with other flags
152
- dembrandt dembrandt.com --browser=firefox --save-output --dtcg
153
- ```
154
-
155
- **When to use Firefox:**
156
- - Sites behind Cloudflare or other bot detection systems
157
- - Timeout issues on heavily protected sites
158
- - WSL environments where headless Chromium may struggle
159
-
160
- **Installation:**
161
- Browsers are installed on demand, not by `npm install` (dembrandt depends on the lean `playwright-core`, which carries no browser binaries). Fetch the engine you need, matched to the installed `playwright-core`:
162
-
163
- ```bash
164
- dembrandt install-browser # chromium (default)
165
- dembrandt install-browser firefox # a specific engine
166
- ```
167
-
168
- This resolves the browser revision from the `playwright-core` dembrandt actually drives, so the two cannot drift apart. Prefer it over calling Playwright directly: a bare `npx playwright install` fetches whatever version the registry serves, and a mismatch fails with `Executable doesn't exist`.
169
-
170
- On Linux and in CI, system libraries are installed separately:
171
-
172
- ```bash
173
- npx playwright@$(node -p "require('playwright-core/package.json').version") install --with-deps chromium
49
+ dembrandt dembrandt.com --save-output # Save JSON to output/dembrandt.com/TIMESTAMP.json
50
+ dembrandt dembrandt.com --dtcg # W3C Design Tokens (DTCG) export, for Style Dictionary or Tokens Studio
51
+ dembrandt dembrandt.com --design-md # DESIGN.md for AI agents
52
+ dembrandt dembrandt.com --tailwind # Tailwind v4 @theme CSS, observed values only
53
+ dembrandt dembrandt.com --wcag # WCAG 2.1 contrast, real DOM pairs with AA/AAA grades
54
+ dembrandt dembrandt.com --crawl 10 # Merge 10 pages into one output, cross-page confidence boosting
55
+ dembrandt dembrandt.com --slow # 3x timeouts for JavaScript-heavy sites
174
56
  ```
175
57
 
176
- ### Connect to an existing browser (CDP)
177
-
178
- Skip the bundled browser entirely and drive an already-running Chromium over the DevTools Protocol. Useful in CI or containers where a browser is already up, and it needs no local browser download at all:
179
-
180
- ```bash
181
- BROWSER_CDP_ENDPOINT=http://localhost:9222 dembrandt dembrandt.com --browser chromium
182
- ```
58
+ Default is formatted terminal output only. Full flag reference in **[docs/usage.md](docs/usage.md)**: mobile and dark mode, browser selection and CDP, brand guide PDF, motion tokens, fingerprint options.
183
59
 
184
- CDP is supported only with `--browser chromium`.
60
+ ## Catch design drift in CI
185
61
 
186
- ### W3C Design Tokens (DTCG) Format
187
-
188
- Use `--dtcg` to export in the standardized [W3C Design Tokens Community Group](https://www.designtokens.org/) format:
189
-
190
- ```bash
191
- dembrandt dembrandt.com --dtcg
192
- # Saves to: output/dembrandt.com/TIMESTAMP.tokens.json
193
- ```
194
-
195
- The DTCG format is an industry-standard JSON schema that can be consumed by design tools and token transformation libraries like [Style Dictionary](https://styledictionary.com).
196
-
197
- ### DESIGN.md
198
-
199
- Use `--design-md` to generate a [DESIGN.md](https://stitch.withgoogle.com/docs/design-md) file, a plain-text design system document readable by AI agents. The export follows Google's DESIGN.md draft format: YAML design tokens in front matter plus ordered Markdown guidance sections.
200
-
201
- ```bash
202
- dembrandt dembrandt.com --design-md
203
- # Saves to: output/dembrandt.com/DESIGN.md
204
- ```
205
-
206
- DESIGN.md reports only what Dembrandt observed on the source site. Exact values (colors, typography, spacing, radii, shadows) live in the YAML front matter when available, and the Markdown body adds human-readable context. Sections with no extracted evidence are omitted rather than filled with invented defaults. For example, the elevation section is dropped when the site uses no box-shadow tokens.
207
-
208
- ### WCAG Contrast Analysis
209
-
210
- Use `--wcag` to check accessibility contrast ratios across the page. Unlike palette-based checkers, dembrandt walks the actual DOM and finds what color is rendered on top of what background — per element.
211
-
212
- ```bash
213
- dembrandt dembrandt.com --wcag
214
- ```
215
-
216
- Returns every text/background pair with contrast ratio and WCAG 2.1 grade (AA, AA-Large, AAA, or fail), sorted by how often each pair appears. Results are shown in terminal and included in JSON output as `wcag`.
217
-
218
- Also captures **interactive state contrast**: dembrandt simulates hover, focus, and disabled states on buttons, links, and inputs and checks contrast on each state. State pairs are tagged `[hover]`, `[focus]`, or `[disabled]` in output so you can catch contrast failures that only appear on interaction.
219
-
220
- ### Motion Tokens
221
-
222
- Motion tokens are extracted automatically on every run — no flag needed. Dembrandt analyzes CSS transitions and animations across the page and returns a structured motion profile.
223
-
224
- ```bash
225
- dembrandt dembrandt.com
226
- ```
227
-
228
- Returns:
229
- - **Duration scale**: all unique animation durations found on the page
230
- - **Easing curves**: named easing types (ease-out, spring, custom cubic-bezier) with usage counts
231
- - **Per-context profiles**: motion behavior by component type (button, nav, card, modal, hero)
232
- - **Hover interaction deltas**: which properties animate on hover (transform, opacity, background, color) and the pattern (scale-up, fade-in, color-shift, slide-y)
233
-
234
- Motion data is included in JSON output as `motion` and printed in terminal under a dedicated Motion section.
235
-
236
- ### ML-powered brand color detection (experimental)
237
-
238
- ```bash
239
- dembrandt dembrandt.com --ai
240
- # ⚡ ML primary → #533afd (score 0.93 · 68% acc)
241
- ```
242
-
243
- Replaces the heuristic with a trained model — 2× more accurate (68% vs 32%). Requires the optional `onnxruntime-node` dep (`npm install onnxruntime-node`). Without the flag nothing changes.
244
-
245
- ### Brand Guide PDF
246
-
247
- Use `--brand-guide` to generate a printable PDF summarizing the extracted design system: colors, typography, components, and logo on a single document.
248
-
249
- ```bash
250
- dembrandt dembrandt.com --brand-guide
251
- # Saves to: output/dembrandt.com/TIMESTAMP.brand-guide.pdf
252
- ```
253
-
254
- ## Continuous integration
255
-
256
- ### GitHub Action
257
-
258
- The official action wraps extract → compare → gate into one step: it installs a matching Chromium, runs a pinned CLI version, fails the job on drift, and renders the drifted tokens as inline annotations on the PR.
62
+ Extract a preview deployment, compare against a committed baseline, fail the job when tokens moved:
259
63
 
260
64
  ```yaml
261
- - uses: dembrandt/dembrandt@v0.27.1
65
+ - uses: dembrandt/dembrandt@v0.29.0
262
66
  with:
263
67
  url: https://preview.example.com
264
68
  baseline: .dembrandt/baseline.json
265
69
  ```
266
70
 
267
- Gating a Vercel preview needs no extra wiring trigger on the deployment event and pass its URL:
268
-
269
- ```yaml
270
- on:
271
- deployment_status:
272
-
273
- jobs:
274
- drift:
275
- if: github.event.deployment_status.state == 'success'
276
- runs-on: ubuntu-latest
277
- steps:
278
- - uses: actions/checkout@v4
279
- - uses: dembrandt/dembrandt@v0.27.1
280
- with:
281
- url: ${{ github.event.deployment_status.environment_url }}
282
- baseline: .dembrandt/baseline.json
283
- key: ${{ secrets.DEMBRANDT_KEY }}
284
- ```
285
-
286
- | Input | Required | Description |
287
- |---|---|---|
288
- | `url` | yes | URL to extract — typically the PR's preview deployment |
289
- | `baseline` | no | Committed baseline JSON path, or an App baseline id. Omit to extract without gating |
290
- | `key` | no | API key for cloud snapshot sync ([dembrandt.com/app/api-keys](https://www.dembrandt.com/app/api-keys)) |
291
- | `args` | no | Extra CLI flags, e.g. `--wcag` or `--crawl 3` |
292
-
293
- Outputs: `report` (path to the drift/extraction JSON) and `score` (drift score, empty without a baseline). The action pins the CLI version per release, so a version-tagged gate never changes behavior under you. For a fully hand-rolled workflow (per-page PR comment, preview vs production, report artifact), see [`examples/drift-gate.yml`](examples/drift-gate.yml).
294
-
295
- ### Running the CLI directly
296
-
297
- Dembrandt drives a real browser, so the browser revision must match `playwright-core`.
298
-
299
- If you are not using the Playwright container image, install the browser revision that matches `playwright-core`:
300
-
301
- ```bash
302
- # matches the bundled playwright-core automatically
303
- dembrandt install-browser
304
- # on a bare Linux runner, add the system libraries too
305
- npx playwright@$(node -p "require('playwright-core/package.json').version") install --with-deps chromium
306
- ```
307
-
308
- A mismatched version fails with "Executable doesn't exist". The container image avoids this entirely — just match its tag (`v1.60.0`) to the `playwright-core` version.
309
-
310
- ### Drift gate
311
-
312
- Compare an extraction against a committed baseline and fail the job on drift:
313
-
314
- ```bash
315
- # capture a baseline once (same environment you will check against)
316
- dembrandt https://app.example.com --json-only > baseline.json
317
-
318
- # in CI — exits non-zero on drift; writes a report artifact
319
- dembrandt https://app.example.com --compare baseline.json --html report.html
320
- ```
321
-
322
- When the change is intended, accept it as the new baseline — `--approve` overwrites the local baseline file and passes instead of failing:
323
-
324
- ```bash
325
- dembrandt https://app.example.com --compare baseline.json --approve
326
- ```
327
-
328
- Add `--json-only` to a `--compare` run to get the drift report as machine-readable JSON under a `drift` key — `score`, `status`, `summary`, and per-token `changes[]` (each with `category`, `kind`, `before`, `after`, `delta`). A CI gate can render exactly which tokens moved (e.g. in a PR comment) from this instead of parsing the HTML report:
329
-
330
- ```bash
331
- dembrandt https://app.example.com --compare baseline.json --json-only
332
- ```
333
-
334
- **Any CI.** The gate is platform-neutral — it is just the exit code plus the drift JSON, so it drops into any runner:
335
-
336
- ```bash
337
- dembrandt "$PREVIEW/checkout" --compare base.json --json-only > drift.json
338
- # exit 1 = drift. Read drift.json (.drift.changes) and surface it however your
339
- # platform does: a GitLab MR note, an Azure DevOps PR thread, a Jenkins status,
340
- # a Slack message, or an auto-filed Jira/Linear ticket.
341
- ```
342
-
343
- A ready-to-use **GitHub Actions** workflow (preview vs production, per-page PR comment with the exact tokens that changed, run summary, report artifact, host-auth bypass) is in [`examples/drift-gate.yml`](examples/drift-gate.yml) as one full reference. The result-surfacing step (annotations, PR comment) is the only platform-specific part; the extract → compare → branch-on-exit-code core is identical on GitLab CI, Jenkins, and Azure DevOps.
71
+ The action annotates the PR with the drifted tokens. On any other runner the gate is just an exit code plus JSON: `dembrandt URL --compare baseline.json --json-only` exits 1 on drift and prints per-token `changes[]`. See **[docs/ci.md](docs/ci.md)** for the Action inputs, the platform-neutral gate, and the exit code table.
344
72
 
345
- ### Exit codes
346
-
347
- A pipeline can branch on the exit code; "design drifted" and "extraction broke" are distinct:
73
+ ## Recipes
348
74
 
349
- | Code | Meaning |
350
- |---|---|
351
- | `0` | Success, or stable (no drift) under `--compare` |
352
- | `1` | Drift detected (`--compare`) |
353
- | `2` | Extraction failure (`EXTRACTION_FAILED`, `BROWSER_UNAVAILABLE`) |
354
- | `67` | Navigation/connection timeout (`NAVIGATION_TIMEOUT`) — retryable, try `--slow` |
75
+ Copy a command, paste a prompt, get a result. Competitor benchmarking, WCAG audits, Figma token push, agentic design system builds. Filterable by role at **[dembrandt.com/recipes](https://www.dembrandt.com/recipes)**, with the basics in [docs/recipes.md](docs/recipes.md).
355
76
 
356
- With `--json-only`, a failure also prints a machine-readable `{ "error": { "code", "message" } }` to stdout.
77
+ ## AI Agent Integration (MCP)
357
78
 
358
- ## Recipes
79
+ Use Dembrandt as a tool in Claude Code, Cursor, Windsurf, or any MCP-compatible client. Ask your agent to "extract the color palette from dembrandt.com" and it calls Dembrandt automatically.
359
80
 
360
- **Quick brand scan**
361
81
  ```bash
362
- dembrandt dembrandt.com
82
+ claude mcp add --transport stdio dembrandt -- npx -y --package dembrandt dembrandt-mcp
363
83
  ```
364
84
 
365
- **Compare two sites**
366
- ```bash
367
- dembrandt dembrandt.com --save-output
368
- dembrandt braintree.com --save-output
369
- # Compare output/dembrandt.com and output/braintree.com side by side
370
- ```
85
+ Or add to your project's `.mcp.json`:
371
86
 
372
- **Multi-page audit** — get a fuller picture across the whole site
373
- ```bash
374
- dembrandt dembrandt.com --crawl 10 --sitemap --save-output
87
+ ```json
88
+ {
89
+ "mcpServers": {
90
+ "dembrandt": {
91
+ "command": "npx",
92
+ "args": ["-y", "--package", "dembrandt", "dembrandt-mcp"]
93
+ }
94
+ }
95
+ }
375
96
  ```
376
97
 
377
- **Spot-check a value** verify a specific token fast
378
- ```bash
379
- dembrandt dembrandt.com --json-only | grep -i "border-radius"
380
- ```
98
+ Available tools include `get_design_tokens`, `get_color_palette`, `get_typography`, `get_component_styles`, `get_surfaces`, `get_spacing`, and `get_brand_identity`, plus pure analysis tools (`compute_drift`, `get_findings`, `export_dtcg`, `generate_design_md`, `render_report`) and job-control tools.
381
99
 
382
- **Export for Tailwind** get spacing and color values into your config
383
- ```bash
384
- dembrandt dembrandt.com --dtcg --save-output
385
- # Use the .tokens.json with Style Dictionary to generate tailwind.config.js
386
- ```
100
+ Extraction tools accept `slow`, `mobile`, `darkMode`, `wcag`, `cookie` and `header` (for authenticated pages), `userAgent`, and `noSandbox` (Docker and most CI containers). Set `pages` above 1 to crawl and merge several pages, which produces a markedly stronger token set than one page; `paths` names them explicitly and `sitemap` discovers them from sitemap.xml.
387
101
 
388
- **Export for Tokens Studio / Figma**
389
- ```bash
390
- dembrandt dembrandt.com --dtcg --save-output
391
- # Import the .tokens.json directly into Tokens Studio
392
- ```
102
+ Extraction returns a `job_id`. Poll it with `get_job_status`, then hand that same id to the pure tools instead of passing the extraction back as an argument:
393
103
 
394
- **Generate DESIGN.md for your AI agent**
395
- ```bash
396
- dembrandt dembrandt.com --design-md
397
- # Point your agent at the output DESIGN.md
398
104
  ```
399
-
400
- **Accessibility audit** — check contrast on any live URL
401
- ```bash
402
- dembrandt dembrandt.com --wcag
105
+ get_design_tokens(url: "example.com", pages: 5) -> job_id
106
+ get_job_status(job_id) -> tokens
107
+ get_findings(job_id) -> contrast and consistency issues
108
+ export_dtcg(job_id) -> W3C design tokens
403
109
  ```
404
110
 
405
- **Regression baseline** snapshot now, catch drift later
406
- ```bash
407
- dembrandt myapp.com --save-output --dtcg
408
- # Store output as baseline, re-run after deploys and diff
409
- ```
111
+ Pair with **[dembrandt-skills](https://github.com/dembrandt/dembrandt-skills)** to give your agent UX intelligence on top of extracted tokens: hierarchy, accessibility, interaction states, and a full 6-stage design pipeline orchestrator.
410
112
 
411
- **CI / headless environments**
412
113
  ```bash
413
- dembrandt myapp.com --no-sandbox --save-output
114
+ npx skills add dembrandt/dembrandt-skills
414
115
  ```
415
116
 
416
- ## Use Cases
417
-
418
- - Design system documentation
419
- - Multi-site design consolidation
420
- - Internal design audits on your own properties
421
- - Learning how design tokens map to real CSS
422
-
423
- ## How It Works
424
-
425
- Uses Playwright to render the page, reads computed styles from the DOM, analyzes color usage and confidence, groups similar typography, detects spacing patterns, and returns design tokens.
426
-
427
- ### Extraction Process
428
-
429
- 1. Browser Launch - Launches browser (Chromium by default, Firefox optional) with stealth configuration
430
- 2. Anti-Detection - Injects scripts to bypass bot detection
431
- 3. Navigation - Navigates to target URL with retry logic
432
- 4. Hydration - Waits for SPAs to fully load (8s initial + 4s stabilization)
433
- 5. Content Validation - Verifies page content is substantial (>500 chars)
434
- 6. Parallel Extraction - Runs all extractors concurrently for speed
435
- 7. Analysis - Analyzes computed styles, DOM structure, and CSS variables
436
- 8. Scoring - Assigns confidence scores based on context and usage
117
+ ## Dembrandt App (Beta)
437
118
 
438
- ### Color Confidence
119
+ Load extractions, track token drift, and compare snapshots. **[dembrandt.com/app](https://www.dembrandt.com/app)**
439
120
 
440
- - High: Logo, primary interactive elements
441
- - Medium: Secondary interactive elements, icons, navigation
442
- - Low: Generic UI components (filtered from display)
443
- - Only shows high and medium confidence colors in terminal. Full palette in JSON.
121
+ * **Automatic drift tracking from CI.** Generate an API key at [dembrandt.com/app/api-keys](https://www.dembrandt.com/app/api-keys), then pass `--key` to the CLI. Every run uploads a snapshot to your account and scores it against the previous one for that domain. Wire into GitHub Actions or any CI runner and every deploy records itself.
122
+ * **Pin a baseline.** Mark any snapshot as your reference. Every subsequent extraction is automatically scored against it.
123
+ * **Visual diff.** Color swatches, before/after values, delta scores per category: colors, typography, spacing, radius, shadows.
124
+ * **Snapshot timeline.** Proportional timeline per domain, scrub across any date range from days to years.
125
+ * **Compare side by side.** Load multiple extractions into one view: two releases, two sites, or two surfaces.
126
+ * **Copy tokens.** Paste values straight into Copilot, Claude, or Cursor.
127
+ * **No login required for local use.** Data stays in the browser. Sign in with GitHub to enable cloud sync.
444
128
 
445
129
  ## Limitations
446
130
 
@@ -469,6 +153,13 @@ The CLI is MIT-licensed and free. Sponsorship funds the enforcement layer: a com
469
153
  <!-- Backer ($25+) and Lead sponsor ($500+) logos appear here. -->
470
154
  <!-- sponsors -->
471
155
 
156
+ ## Documentation
157
+
158
+ - [docs/usage.md](docs/usage.md): every flag, multi-page extraction, browser selection, CDP, DTCG, DESIGN.md, Tailwind theme, WCAG, motion, brand guide PDF
159
+ - [docs/ci.md](docs/ci.md): GitHub Action, drift gate, exit codes
160
+ - [docs/recipes.md](docs/recipes.md): copy-paste workflows
161
+ - [docs/FLAGS.md](docs/FLAGS.md): flag interactions, ignored combinations, multi-page propagation
162
+
472
163
  ## Contributing
473
164
 
474
165
  Bugs, weird sites, pull requests. All welcome.