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.
- package/.github/FUNDING.yml +1 -0
- package/.github/ISSUE_TEMPLATE/bug_report.yml +62 -0
- package/.github/ISSUE_TEMPLATE/config.yml +8 -0
- package/.github/ISSUE_TEMPLATE/feature_request.yml +28 -0
- package/CHANGELOG.md +43 -0
- package/README.md +177 -6
- package/bin/design-extract.js +302 -92
- package/docs/superpowers/plans/2026-04-18-designlang-v7.md +1121 -0
- package/docs/superpowers/specs/2026-04-18-designlang-v7-design.md +150 -0
- package/package.json +13 -7
- package/src/config.js +59 -0
- package/src/crawler.js +297 -95
- package/src/extractors/a11y-remediation.js +47 -0
- package/src/extractors/animations.js +37 -5
- package/src/extractors/borders.js +40 -5
- package/src/extractors/component-clusters.js +39 -0
- package/src/extractors/components.js +77 -1
- package/src/extractors/css-health.js +151 -0
- package/src/extractors/gradients.js +25 -5
- package/src/extractors/scoring.js +20 -1
- package/src/extractors/semantic-regions.js +44 -0
- package/src/extractors/shadows.js +60 -17
- package/src/extractors/spacing.js +31 -2
- package/src/extractors/stack-fingerprint.js +88 -0
- package/src/extractors/variables.js +20 -1
- package/src/formatters/_token-ref.js +44 -0
- package/src/formatters/agent-rules.js +116 -0
- package/src/formatters/android-compose.js +164 -0
- package/src/formatters/dtcg-tokens.js +175 -0
- package/src/formatters/figma.js +66 -47
- package/src/formatters/flutter-dart.js +130 -0
- package/src/formatters/ios-swiftui.js +161 -0
- package/src/formatters/markdown.js +25 -0
- package/src/formatters/preview.js +65 -22
- package/src/formatters/svelte-theme.js +40 -0
- package/src/formatters/tailwind.js +57 -4
- package/src/formatters/theme.js +134 -0
- package/src/formatters/vue-theme.js +44 -0
- package/src/formatters/wordpress.js +267 -0
- package/src/history.js +8 -1
- package/src/index.js +76 -20
- package/src/mcp/resources.js +64 -0
- package/src/mcp/server.js +110 -0
- package/src/mcp/tools.js +149 -0
- package/src/utils.js +68 -0
- package/tests/cli.test.js +84 -0
- package/tests/extractors.test.js +792 -0
- package/tests/formatters.test.js +709 -0
- package/tests/mcp.test.js +68 -0
- package/tests/utils.test.js +413 -0
- package/website/app/globals.css +11 -11
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
# designlang v7.0 — Design Spec
|
|
2
|
+
|
|
3
|
+
**Date:** 2026-04-18
|
|
4
|
+
**Status:** Approved for implementation
|
|
5
|
+
**Author:** Manav Arya Singh
|
|
6
|
+
|
|
7
|
+
## Theme
|
|
8
|
+
|
|
9
|
+
*The design context layer for AI agents, across every platform.*
|
|
10
|
+
|
|
11
|
+
v7.0 turns designlang from a web-only token extractor into (a) the default MCP/agent context source for AI IDEs, (b) a real multi-platform design system output (web + iOS + Android + Flutter + WordPress), (c) a CSS auditor, not just an extractor.
|
|
12
|
+
|
|
13
|
+
## Scope — 10 features
|
|
14
|
+
|
|
15
|
+
### 1. MCP server
|
|
16
|
+
New command: `designlang mcp [--output-dir <path>]`. Launches a stdio MCP server built on `@modelcontextprotocol/sdk`. Exposes:
|
|
17
|
+
- **Resources:** `tokens://primitive`, `tokens://semantic`, `tokens://components`, `regions://map`, `health://score`.
|
|
18
|
+
- **Tools:** `search_tokens(query)`, `find_nearest_color(hex, level: AA|AAA)`, `get_region(name)`, `get_component(name)`, `list_failing_contrast_pairs()`.
|
|
19
|
+
- No live extraction tool (deferred to v7.1 with hosted backend).
|
|
20
|
+
|
|
21
|
+
### 2. Agent rules emitter
|
|
22
|
+
New flag: `--emit-agent-rules` (and on by default when `--full`). Writes:
|
|
23
|
+
- `.cursor/rules/designlang.mdc` — Cursor project rules referencing tokens.
|
|
24
|
+
- `.claude/skills/designlang/SKILL.md` — Claude Code skill folder with frontmatter.
|
|
25
|
+
- `CLAUDE.md.fragment` — append-ready fragment for root CLAUDE.md.
|
|
26
|
+
- `agents.md` — generic agent prompt.
|
|
27
|
+
|
|
28
|
+
All four files read from the same source-of-truth JSON.
|
|
29
|
+
|
|
30
|
+
### 3. DTCG strict mode + semantic layer + composite tokens
|
|
31
|
+
Rewrites `*-design-tokens.json` to W3C DTCG v1 format:
|
|
32
|
+
- Every leaf is `{ "$value": ..., "$type": "color|dimension|fontFamily|shadow|...", "$extensions": {...} }`.
|
|
33
|
+
- Two-layer structure: `primitive.*` (raw values) and `semantic.*` (alias references like `"{primitive.color.blue.500}"`).
|
|
34
|
+
- Composite types for `typography`, `shadow`, `border`, `gradient` (single object with family/size/weight/lineHeight, etc.).
|
|
35
|
+
- Auto-infers semantic roles from usage: `semantic.color.action.primary`, `semantic.color.surface.default`, `semantic.text.body`, `semantic.radius.control`, etc.
|
|
36
|
+
- **Default ON.** `--tokens-legacy` preserves pre-v7 shape. Breaking change — documented in CHANGELOG and migration guide.
|
|
37
|
+
|
|
38
|
+
### 4. Multi-platform emitters
|
|
39
|
+
New flag: `--platforms <csv>` (values: `web,ios,android,flutter,wordpress,all`; default `web`).
|
|
40
|
+
- **iOS (SwiftUI):** `*-ios.swift` with `Color.primaryAction`, `CGFloat` spacing/radius, `Font` registrations.
|
|
41
|
+
- **Android (Compose):** `*-colors.xml`, `*-dimens.xml`, `*-Theme.kt` with Compose `val`s.
|
|
42
|
+
- **Flutter (Dart):** `*-theme.dart` exporting a `ThemeData` + color/typography extensions.
|
|
43
|
+
- **WordPress:** `theme.json` (Gutenberg block theme tokens), `style.css` with CSS custom props, minimal `functions.php` + `index.php`/`templates/index.html` skeleton so output is a drop-in block theme.
|
|
44
|
+
|
|
45
|
+
All emitters consume the DTCG semantic layer, not primitives — they stay consistent.
|
|
46
|
+
|
|
47
|
+
### 5. Tech-stack + Tailwind fingerprint
|
|
48
|
+
New extractor `stack-fingerprint`:
|
|
49
|
+
- Detects framework from window globals, script URLs, meta tags, DOM signatures (React/Vue/Svelte/Next/Nuxt/Remix/Astro/Shopify/WooCommerce/Webflow/Framer).
|
|
50
|
+
- Detects CSS layer (Tailwind v3/v4, styled-components, CSS Modules, vanilla).
|
|
51
|
+
- Detects analytics, CDN, fonts host, A/B tools.
|
|
52
|
+
- When Tailwind is detected: scrapes class-name frequency, extracts utility classes in use, and emits `*-tailwind-diff.md` (what classes are used, config delta vs. default preset) instead of only a fresh `tailwind.config.js`.
|
|
53
|
+
|
|
54
|
+
### 6. CSS health audit
|
|
55
|
+
New extractor `css-health`:
|
|
56
|
+
- Runs Playwright `coverage.startCSSCoverage()` → reports unused bytes per stylesheet.
|
|
57
|
+
- Parses all stylesheets for specificity distribution, `!important` count, duplicate declarations, selector-per-rule averages, vendor-prefix and obsolete-property audit.
|
|
58
|
+
- Enumerates `@keyframes` with name/duration/easing/steps.
|
|
59
|
+
- Emits `*-css-health.json` and `*-css-health.md`.
|
|
60
|
+
- Adds three new dimensions to the design score: `cssHealth`, `animationCatalog`, `specificity`. Old score fields remain for backward compat.
|
|
61
|
+
|
|
62
|
+
### 7. A11y remediation suggestions
|
|
63
|
+
Extends a11y extractor:
|
|
64
|
+
- For each failing WCAG fg/bg pair, searches the extracted palette for the nearest color that passes AA (4.5:1) and AAA (7:1).
|
|
65
|
+
- Emits suggestions in `*-a11y.md` and as fixable entries in `*-design-language.md`.
|
|
66
|
+
- MCP tool `find_nearest_color(hex, level)` reuses this engine.
|
|
67
|
+
|
|
68
|
+
### 8. Semantic component segmentation
|
|
69
|
+
New extractor `semantic-regions`:
|
|
70
|
+
- Heuristic classifier using ARIA landmarks (`<nav>`, `<main>`, `<header>`, `<footer>`, `role=banner|contentinfo|complementary`), layout properties (sticky header, footer at page end), and class-name hints (`.hero`, `.pricing`, `.cta`).
|
|
71
|
+
- Labels detected regions: `nav`, `hero`, `features`, `pricing`, `testimonials`, `cta`, `footer`, `content`.
|
|
72
|
+
- Emits `*-regions.json` with bounds, computed styles, and region role.
|
|
73
|
+
- MCP tool `get_region(name)` returns the full region block.
|
|
74
|
+
|
|
75
|
+
### 9. Reusable component detection
|
|
76
|
+
New extractor `component-clusters`:
|
|
77
|
+
- For each DOM element matching button/card/input/badge/tag candidates, computes a structural hash (tag sequence + class pattern) + style vector (flattened computed-style array).
|
|
78
|
+
- Clusters by similarity (structural hash exact, style vector cosine > threshold).
|
|
79
|
+
- Replaces current "one example per component type" with `{ component, instanceCount, variants: [...] }`.
|
|
80
|
+
- Markdown output shows "Button — 24 instances, 2 variants (primary, ghost)" with CSS for each.
|
|
81
|
+
|
|
82
|
+
### 10. WordPress theme export
|
|
83
|
+
Covered under Feature 4; called out separately because it is a full emitter with file-tree skeleton, not only tokens.
|
|
84
|
+
|
|
85
|
+
## Architecture changes
|
|
86
|
+
|
|
87
|
+
### New modules
|
|
88
|
+
- `src/extractors/stack-fingerprint.js`
|
|
89
|
+
- `src/extractors/css-health.js`
|
|
90
|
+
- `src/extractors/semantic-regions.js`
|
|
91
|
+
- `src/extractors/component-clusters.js`
|
|
92
|
+
- `src/extractors/a11y-remediation.js` (or extend existing a11y)
|
|
93
|
+
- `src/formatters/dtcg-tokens.js` (replaces `design-tokens.js` with legacy fallback)
|
|
94
|
+
- `src/formatters/ios-swiftui.js`
|
|
95
|
+
- `src/formatters/android-compose.js`
|
|
96
|
+
- `src/formatters/flutter-dart.js`
|
|
97
|
+
- `src/formatters/wordpress-theme.js`
|
|
98
|
+
- `src/formatters/agent-rules.js`
|
|
99
|
+
- `src/mcp/server.js` + `src/mcp/resources.js` + `src/mcp/tools.js`
|
|
100
|
+
|
|
101
|
+
### New dependencies
|
|
102
|
+
- `@modelcontextprotocol/sdk` — for MCP server.
|
|
103
|
+
- No other additions.
|
|
104
|
+
|
|
105
|
+
### CLI surface
|
|
106
|
+
```
|
|
107
|
+
designlang <url> [...existing flags]
|
|
108
|
+
--platforms <csv> web,ios,android,flutter,wordpress,all (default: web)
|
|
109
|
+
--emit-agent-rules Emit Cursor/Claude Code/generic agent rules
|
|
110
|
+
--tokens-legacy Keep pre-v7 token JSON shape
|
|
111
|
+
|
|
112
|
+
designlang mcp [--output-dir <path>] # NEW: launch MCP server
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
All existing commands (`apply`, `clone`, `score`, `watch`, `diff`, `brands`, `sync`, `history`) unchanged.
|
|
116
|
+
|
|
117
|
+
### Backward compatibility
|
|
118
|
+
- Base extraction stays — same file names, same top-level keys.
|
|
119
|
+
- **Breaking:** token JSON shape changes to DTCG. Mitigated by `--tokens-legacy`, loud CHANGELOG, migration section in README.
|
|
120
|
+
- **Additive:** score JSON gains new fields; existing fields preserved.
|
|
121
|
+
- **Additive:** new files only appear with opt-in flags (`--platforms`, `--emit-agent-rules`).
|
|
122
|
+
|
|
123
|
+
## Testing
|
|
124
|
+
|
|
125
|
+
- Unit tests per extractor module using fixture HTML (existing pattern in `tests/`).
|
|
126
|
+
- Integration test: run full extraction on a local fixture site, snapshot each output file.
|
|
127
|
+
- DTCG output validated against the W3C DTCG JSON schema (vendored).
|
|
128
|
+
- Multi-platform emitters: golden-file tests (check generated Swift/Kotlin/Dart/theme.json against known-good outputs).
|
|
129
|
+
- MCP server: spin up server, run a handful of resource/tool requests over the MCP test harness, assert responses.
|
|
130
|
+
|
|
131
|
+
## Release plan
|
|
132
|
+
|
|
133
|
+
1. Implement features in dependency order (see writing-plans phase).
|
|
134
|
+
2. All tests pass.
|
|
135
|
+
3. Update README with new sections: MCP, agent rules, multi-platform, CSS health, WordPress.
|
|
136
|
+
4. Write CHANGELOG.md with breaking-change callout on DTCG + migration snippet.
|
|
137
|
+
5. Bump `package.json` version `6.0.0` → `7.0.0`.
|
|
138
|
+
6. `npm publish` + `git tag v7.0.0 && git push --tags`.
|
|
139
|
+
7. Website update — deferred to Wave 2.
|
|
140
|
+
|
|
141
|
+
## Out of scope (deferred to v7.1+)
|
|
142
|
+
|
|
143
|
+
- Bidirectional Figma Variables sync.
|
|
144
|
+
- Full JSX/Vue/Svelte component codegen (needs Mitosis-style IR or LLM).
|
|
145
|
+
- Versioned auto-published npm token package with changesets.
|
|
146
|
+
- Hosted shareable reports (needs backend).
|
|
147
|
+
- Hosted "Try it free" web extraction (Wave 2).
|
|
148
|
+
- CMS content-model extraction.
|
|
149
|
+
- Storybook + Chromatic integration.
|
|
150
|
+
- Live clone-to-editable canvas.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "designlang",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.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": {
|
|
@@ -10,16 +10,17 @@
|
|
|
10
10
|
"scripts": {
|
|
11
11
|
"postinstall": "npx playwright install chromium --with-deps 2>/dev/null || npx playwright install chromium",
|
|
12
12
|
"start": "node bin/design-extract.js",
|
|
13
|
-
"test": "node --test tests
|
|
13
|
+
"test": "node --test tests/*.test.js"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"
|
|
17
|
-
"commander": "^12.0.0",
|
|
16
|
+
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
18
17
|
"chalk": "^5.3.0",
|
|
19
|
-
"
|
|
18
|
+
"commander": "^12.0.0",
|
|
19
|
+
"ora": "^8.0.0",
|
|
20
|
+
"playwright": "^1.42.0"
|
|
20
21
|
},
|
|
21
22
|
"engines": {
|
|
22
|
-
"node": ">=
|
|
23
|
+
"node": ">=20"
|
|
23
24
|
},
|
|
24
25
|
"keywords": [
|
|
25
26
|
"design-system",
|
|
@@ -32,7 +33,12 @@
|
|
|
32
33
|
"colors",
|
|
33
34
|
"typography",
|
|
34
35
|
"claude-code",
|
|
35
|
-
"plugin"
|
|
36
|
+
"plugin",
|
|
37
|
+
"wordpress",
|
|
38
|
+
"vue",
|
|
39
|
+
"svelte",
|
|
40
|
+
"json",
|
|
41
|
+
"ci-cd"
|
|
36
42
|
],
|
|
37
43
|
"author": "masyv",
|
|
38
44
|
"license": "MIT"
|
package/src/config.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from 'fs';
|
|
2
|
+
import { join } from 'path';
|
|
3
|
+
|
|
4
|
+
const CONFIG_FILES = ['.designlangrc', 'designlang.config.json', '.designlangrc.json'];
|
|
5
|
+
|
|
6
|
+
export function loadConfig(dir = process.cwd()) {
|
|
7
|
+
for (const name of CONFIG_FILES) {
|
|
8
|
+
const path = join(dir, name);
|
|
9
|
+
if (existsSync(path)) {
|
|
10
|
+
try {
|
|
11
|
+
return JSON.parse(readFileSync(path, 'utf-8'));
|
|
12
|
+
} catch { return {}; }
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return {};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function mergeConfig(cliOpts, config) {
|
|
19
|
+
// CLI flags take precedence over config file
|
|
20
|
+
return {
|
|
21
|
+
ignore: cliOpts.ignore || config.ignore || [],
|
|
22
|
+
width: cliOpts.width || config.width || 1280,
|
|
23
|
+
height: cliOpts.height || config.height || 800,
|
|
24
|
+
wait: cliOpts.wait || config.wait || 0,
|
|
25
|
+
dark: cliOpts.dark || config.dark || false,
|
|
26
|
+
depth: cliOpts.depth || config.depth || 0,
|
|
27
|
+
screenshots: cliOpts.screenshots || config.screenshots || false,
|
|
28
|
+
framework: cliOpts.framework || config.framework,
|
|
29
|
+
responsive: cliOpts.responsive || config.responsive || false,
|
|
30
|
+
interactions: cliOpts.interactions || config.interactions || false,
|
|
31
|
+
full: cliOpts.full || config.full || false,
|
|
32
|
+
cookie: cliOpts.cookie || config.cookies,
|
|
33
|
+
header: cliOpts.header || config.headers,
|
|
34
|
+
out: cliOpts.out || config.out || './design-extract-output',
|
|
35
|
+
tokensLegacy: cliOpts.tokensLegacy || config.tokensLegacy || false,
|
|
36
|
+
platforms: parsePlatforms(cliOpts.platforms ?? config.platforms ?? 'web'),
|
|
37
|
+
emitAgentRules: cliOpts.emitAgentRules || config.emitAgentRules || false,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Normalize the --platforms value into an array. Accepts comma-separated strings
|
|
42
|
+
// or an existing array. Expands "all" to the full list. Always ensures "web"
|
|
43
|
+
// remains included (v7.0: --platforms is additive, web is not disabled).
|
|
44
|
+
export function parsePlatforms(value) {
|
|
45
|
+
const KNOWN = ['web', 'ios', 'android', 'flutter', 'wordpress'];
|
|
46
|
+
let list;
|
|
47
|
+
if (Array.isArray(value)) list = value.slice();
|
|
48
|
+
else if (typeof value === 'string') list = value.split(',').map((s) => s.trim()).filter(Boolean);
|
|
49
|
+
else list = ['web'];
|
|
50
|
+
|
|
51
|
+
const expanded = new Set();
|
|
52
|
+
for (const item of list) {
|
|
53
|
+
const v = item.toLowerCase();
|
|
54
|
+
if (v === 'all') KNOWN.forEach((k) => expanded.add(k));
|
|
55
|
+
else if (KNOWN.includes(v)) expanded.add(v);
|
|
56
|
+
}
|
|
57
|
+
expanded.add('web'); // web is always emitted in v7.0
|
|
58
|
+
return KNOWN.filter((k) => expanded.has(k));
|
|
59
|
+
}
|