Plan O2 / spec §10 / §21.3.2.
apps/daemon/src/plugins/atoms/design-extract.ts ships the
daemon-side implementation behind the SKILL.md fragment landed in
§3.M4 / §3.N. Given a project cwd that already has
`code/index.json` (from code-import) and the imported repo path,
the runner walks every scannable file (css/scss/ts/tsx/js/jsx/
html/json) and extracts:
colors — hex (#abc / #aabbcc / #aabbccdd), rgba(), hsla(),
CSS custom properties (--*-color / --*-bg / etc),
Tailwind config quoted hex palette entries.
typography — font-family declarations.
spacing — px / rem / em values on padding/margin/gap/inset/
top/left/right/bottom.
radius — border-radius declarations.
shadow — box-shadow declarations.
Each token is deduped by canonical value and carries:
- sources[]: '${path}:${line}' entries (audit trail token-map
references).
- usage[]: bare basenames so a designer can spot 'this colour
is referenced from Header.tsx + Footer.tsx + button.css'.
- name?: populated for CSS custom properties; absent for
inline literals.
The pass is heuristic by design: false negatives are preferable to
false positives because token-map asks the human to confirm each
match. Files larger than 256 KiB are skipped (default; configurable)
to keep the regex pass bounded on bundled output.
Output: `<cwd>/code/tokens.json` — the exact shape the SKILL.md
fragment promises.
Daemon tests: 1556 → 1564 (+8 cases on plugins-design-extract:
hex/rgba/CSS-variable colour extraction, font-family capture,
spacing extraction across px+rem, border-radius + box-shadow,
Tailwind config quoted hex palette, persisted JSON layout, missing
code/index.json error path, empty-bag round trip).
Co-authored-by: Tom Huang <1043269994@qq.com>