design-playbook 0.7.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 (47) hide show
  1. package/LICENSE +28 -0
  2. package/NOTICE +37 -0
  3. package/README.md +143 -0
  4. package/commands/design-io.md +8 -0
  5. package/commands/ui-review.md +8 -0
  6. package/commands/ux-spec.md +8 -0
  7. package/mcp/__init__.py +0 -0
  8. package/mcp/_transport.py +242 -0
  9. package/mcp/evidence/README.md +40 -0
  10. package/mcp/evidence/__init__.py +0 -0
  11. package/mcp/evidence/server.py +450 -0
  12. package/mcp/evidence/test_server_stdio.py +645 -0
  13. package/mcp/preview/__init__.py +0 -0
  14. package/mcp/preview/browser.py +661 -0
  15. package/mcp/preview/confirm.py +255 -0
  16. package/mcp/preview/control.py +1293 -0
  17. package/mcp/preview/i18n.py +162 -0
  18. package/mcp/preview/server.py +126 -0
  19. package/mcp/preview/test_browser_control.py +663 -0
  20. package/mcp/preview/test_server_stdio.py +630 -0
  21. package/mcp/preview/test_transaction.py +436 -0
  22. package/mcp/preview/transaction.py +536 -0
  23. package/mcp/preview/util.py +19 -0
  24. package/mcp/test_transport.py +39 -0
  25. package/package.json +42 -0
  26. package/skills/craft-guard/SKILL.md +59 -0
  27. package/skills/craft-guard/references/craft.md +29 -0
  28. package/skills/craft-guard/references/detectors.md +124 -0
  29. package/skills/design-baseline/SKILL.md +134 -0
  30. package/skills/design-baseline/agents/openai.yaml +4 -0
  31. package/skills/design-baseline/references/design-template.md +73 -0
  32. package/skills/design-baseline/references/extraction-guidance.md +39 -0
  33. package/skills/design-baseline/scripts/design_baseline.py +780 -0
  34. package/skills/design-playbook/SKILL.md +219 -0
  35. package/skills/native-craft/SKILL.md +59 -0
  36. package/skills/native-craft/references/native-feel.md +79 -0
  37. package/skills/reference-intake/SKILL.md +86 -0
  38. package/skills/reference-intake/references/contract-template.md +82 -0
  39. package/skills/ui-evaluator/SKILL.md +110 -0
  40. package/skills/ui-evaluator/references/rubric.md +45 -0
  41. package/skills/ui-picker/SKILL.md +63 -0
  42. package/skills/ui-picker/references/components.md +31 -0
  43. package/skills/ui-picker/references/design.md +21 -0
  44. package/skills/ui-picker/references/domain.md +26 -0
  45. package/skills/ui-picker/references/template.md +24 -0
  46. package/skills/ux-spec/SKILL.md +51 -0
  47. package/skills/ux-spec/references/spec-template.md +43 -0
@@ -0,0 +1,59 @@
1
+ ---
2
+ name: craft-guard
3
+ description: UI craft and feedback quality. Use when polishing product UI (motion, loading/error feedback) or when a page reads as AI slop.
4
+ ---
5
+
6
+ # craft-guard
7
+
8
+ **Craft** declaration for cross-product quality: hierarchy, wait feedback, purposeful motion, CJK-safe type. Does not own business risk (`domain`) or token inventory (`design`).
9
+
10
+ When a verified design-baseline binding exists (`status: ready`), use that path as the project-specific visual baseline. Report clear divergence (density, type, spacing, shape, motion, or primitive treatment) to `ui-evaluator` with source set to the bound path; do not replace valid project choices with this skill's generic taste defaults.
11
+
12
+ ## Apply (checklist)
13
+
14
+ Treat as exhaustive for the surface under edit.
15
+
16
+ ### Hierarchy and type
17
+
18
+ - One clear primary; secondary recedes via density/space, not rainbow chrome.
19
+ - CJK UI uses the project Chinese stack (`var(--font-cn)` or equivalent).
20
+ - Brand solid + brand-gradient **≤ 3** emphasis hits per viewport; neutrals carry the rest.
21
+
22
+ **Done when:** a cold reader can name the primary action/region in one glance.
23
+
24
+ ### Loading tiers
25
+
26
+ ```text
27
+ <300ms no indicator
28
+ 300ms–2s skeleton (layout stable)
29
+ >2s loader + what is happening
30
+ >10s timeout + retry (or cancel)
31
+ ```
32
+
33
+ **Done when:** every async path in scope maps to a tier with a next action on failure/timeout.
34
+
35
+ ### Motion
36
+
37
+ - UI motion ≤ 300ms; animate `transform` / `opacity` only.
38
+ - Each animation names the state change it explains.
39
+ - Honor `prefers-reduced-motion`. Keyboard-triggered actions stay free of decorative motion.
40
+
41
+ **Done when:** every motion in scope states the state change it explains.
42
+
43
+ ### AI slop → target look
44
+
45
+ For implemented UI, run all eight checks in [`references/detectors.md`](references/detectors.md) against rendered UI plus relevant source. Write exactly one `clear|hit|blocked` row per detector to `.scratch/<run>/craft-guard.md`. Detector output is advisory: record evidence, exception check, and positive fix; leave declaration source, severity, and verdict to `ui-evaluator`. Missing proof is `blocked`, not a silent clear.
46
+
47
+ | Push toward | Instead of default sludge |
48
+ | --- | --- |
49
+ | Accent on key noun + primary CTA | Purple–blue gradient wallpaper |
50
+ | Glass only on rare floating layers | Blur on every card |
51
+ | Project CJK stack | Inter/Roboto as Chinese body |
52
+ | Weighted modules | Equal white card grid |
53
+ | State-explaining motion | Bounce/elastic decoration |
54
+
55
+ [`references/craft.md`](references/craft.md) — **required when the surface has L4 interactive zones** (per-zone hover/motion affordance, with its own Done when); also holds edge craft (failure/permission feedback, 圆角/阴影, charts).
56
+
57
+ ## Completion
58
+
59
+ **Done when:** hierarchy, every in-scope wait/fail path, every animation, and — when the surface has L4 interactive zones — every zone's affordance (per `references/craft.md`) pass their checks; implemented UI also has all eight detector rows with no unexplained missing proof. Residual hits and blocked proof are handed to `ui-evaluator`; detector rows do not assign source, severity, or verdict.
@@ -0,0 +1,29 @@
1
+ # craft 细则
2
+
3
+ ## 状态反馈
4
+
5
+ 等待分层归 `SKILL.md` loading tiers;此处只管失败与降级:
6
+
7
+ - 失败:原因 + 可恢复动作(重试/忽略/查看日志)
8
+ - 权限不足:禁用 + 需要的权限说明
9
+
10
+ ## 工艺
11
+
12
+ - 嵌套圆角与间距分层,忌全站同一圆角同一阴影
13
+ - 阴影档位少而稳;层级靠 surface 不靠彩虹边
14
+ - 中英混排:中文行高与标点优先
15
+
16
+ ## 交互 affordance(L4 交互区,grill v0.3 Q3.4)
17
+
18
+ 每个 L4 声明的交互区(行、卡片、按钮组、可点单元)须有有意的 motion/hover affordance,且在 craft review 里说明用途:
19
+
20
+ - 默认 hover/active 有过渡(opacity / transform / background 之一,~120ms),用途写在 craft 报告(如「行可点 → 提示可进入详情」「行只读 → 不加 hover」)。
21
+ - 静态 throwaway 也得体现 affordance 目标:要么给出 hover,要么显式声明「此区只读,无 hover」——不允许「交互区既无 hover 又无声明」的静默 PASS。
22
+ - 数据表/list 的 ledger 行尤其易漏:扫描密集时 hover 是可扫描性 affordance,不是装饰。
23
+
24
+ **Done when:** 每个 L4 交互区都有 motion/hover purpose(给出或显式声明只读);无静默漏 hover 的交互区。
25
+
26
+ ## 图表
27
+
28
+ - 分类色稳定可复述;风险色回 `domain`
29
+ - 容器与坐标可读,不为「炫」牺牲扫描
@@ -0,0 +1,124 @@
1
+ # Craft detector protocol
2
+
3
+ Run all eight detectors for implemented UI. Inspect rendered UI at declared target viewports and relevant source. Generic detector taste never overrides a verified project baseline; safety, usability, and explicit declarations still do.
4
+
5
+ Record exactly one row per detector in `.scratch/<run>/craft-guard.md`:
6
+
7
+ ```text
8
+ | ID | Status | Rendered evidence | Source evidence | Exception check | Positive fix |
9
+ | CRAFT-01 | clear|hit|blocked | observable or missing proof | source location or missing proof | applied exception or none | required for hit; `-` otherwise |
10
+ ```
11
+
12
+ Allowed status is `clear`, `hit`, or `blocked`. `blocked` names missing proof. Detector rows are advisory: do not assign declaration source, severity, or verdict. `ui-evaluator` owns those decisions.
13
+
14
+ ## CRAFT-01 — Primary hierarchy
15
+
16
+ **Purpose:** Detect absent or competing primary actions and regions.
17
+
18
+ **Rendered signals:** More than one element claims primary emphasis, or no action/region leads the scan.
19
+
20
+ **Source signals:** Multiple primary variants, equivalent emphasis tokens, or page structure without a main landmark.
21
+
22
+ **Legitimate exceptions:** Deliberate equal-choice comparison supported by spec or verified baseline.
23
+
24
+ **Owner hint:** `craft` for emphasis; `template` when shell composition causes conflict.
25
+
26
+ **Positive fix:** Preserve one scene-appropriate primary and make secondary actions recede through placement, density, or neutral treatment.
27
+
28
+ ## CRAFT-02 — Repeated card wall
29
+
30
+ **Purpose:** Detect undifferentiated card grids replacing useful information structure.
31
+
32
+ **Rendered signals:** Most content appears as equal floating cards with no scanning hierarchy or task grouping.
33
+
34
+ **Source signals:** Repeated card wrappers applied to unrelated regions or list/table records without a card-specific interaction.
35
+
36
+ **Legitimate exceptions:** Browsable collections where each item is a genuinely independent object and the verified baseline uses cards.
37
+
38
+ **Owner hint:** `template` for scene structure; `craft` for visual weighting.
39
+
40
+ **Positive fix:** Use list, table, band, or unframed grouping that matches comparison and action needs; reserve cards for independent items.
41
+
42
+ ## CRAFT-03 — Nested or floating containers
43
+
44
+ **Purpose:** Detect cards inside cards and page sections styled as decorative floating panels.
45
+
46
+ **Rendered signals:** Multiple nested borders, radii, shadows, or detached section surfaces obscure ownership.
47
+
48
+ **Source signals:** Card components nested for spacing, or full-width sections wrapped in decorative card primitives.
49
+
50
+ **Legitimate exceptions:** A real framed tool, modal, or repeated item nested within an unframed page region.
51
+
52
+ **Owner hint:** `template` for section composition; `components` for wrong primitive identity.
53
+
54
+ **Positive fix:** Flatten page regions, use spacing and dividers for grouping, and retain a frame only where interaction semantics require one.
55
+
56
+ ## CRAFT-04 — One-note palette
57
+
58
+ **Purpose:** Detect hue dominance that erases semantic contrast and hierarchy.
59
+
60
+ **Rendered signals:** Backgrounds, surfaces, accents, and states rely on variations of one hue family.
61
+
62
+ **Source signals:** One color ramp fills unrelated semantic roles or repeated gradients replace neutral surfaces.
63
+
64
+ **Legitimate exceptions:** Verified monochrome brand systems with sufficient state, contrast, and hierarchy differentiation.
65
+
66
+ **Owner hint:** `design` for token roles; `craft` for emphasis distribution.
67
+
68
+ **Positive fix:** Keep brand color selective, restore neutral surfaces, and use semantic colors only for named roles.
69
+
70
+ ## CRAFT-05 — Shape and pill overuse
71
+
72
+ **Purpose:** Detect excessive rounded containers and text pills where familiar controls fit.
73
+
74
+ **Rendered signals:** Most labels, actions, and containers share pill geometry or oversized rounding.
75
+
76
+ **Source signals:** Large border-radius tokens applied globally, or text-in-rounded-rectangle controls replacing icons, toggles, tabs, or badges.
77
+
78
+ **Legitimate exceptions:** Verified brand geometry or semantic chips/tags whose shape communicates grouping or status.
79
+
80
+ **Owner hint:** `components` for control identity; `design` for radius tokens; `craft` for repetition.
81
+
82
+ **Positive fix:** Use control-specific primitives and restrained radii; reserve pills for semantics that need compact grouping.
83
+
84
+ ## CRAFT-06 — Type-scale mismatch
85
+
86
+ **Purpose:** Detect typography whose scale conflicts with container and workflow density.
87
+
88
+ **Rendered signals:** Hero-sized copy dominates compact panels, or hierarchy depends on oversized text instead of structure.
89
+
90
+ **Source signals:** Display tokens used in cards, toolbars, dashboards, or narrow controls without a true hero context.
91
+
92
+ **Legitimate exceptions:** Literal landing-page hero or verified expressive product surface with stable responsive fit.
93
+
94
+ **Owner hint:** `design` for type roles; `craft` for contextual hierarchy.
95
+
96
+ **Positive fix:** Match type role to container and task density, using structure and weight before display scale.
97
+
98
+ ## CRAFT-07 — Text-as-control and icon misuse
99
+
100
+ **Purpose:** Detect verbose rounded text controls where familiar symbols or dedicated controls communicate better.
101
+
102
+ **Rendered signals:** Repeated Undo, Close, Save, formatting, color, or binary actions consume space as text buttons.
103
+
104
+ **Source signals:** Text buttons replace available icon buttons, swatches, segmented controls, toggles, or checkboxes.
105
+
106
+ **Legitimate exceptions:** Unfamiliar, high-risk, or ambiguous actions that require explicit text; accessibility names remain required for icons.
107
+
108
+ **Owner hint:** `components` for primitive choice; `craft` for density and recognition.
109
+
110
+ **Positive fix:** Use familiar icon/control primitives with accessible names and tooltips where recognition needs support.
111
+
112
+ ## CRAFT-08 — Decorative or purposeless motion
113
+
114
+ **Purpose:** Detect motion that explains no state change or destabilizes interaction.
115
+
116
+ **Rendered signals:** Bounce, elastic, looping, or entrance motion draws attention without communicating state.
117
+
118
+ **Source signals:** Animation targets layout properties, lacks reduced-motion handling, or has no named state transition.
119
+
120
+ **Legitimate exceptions:** Expressive game or immersive scene motion declared by product intent and kept clear of task controls.
121
+
122
+ **Owner hint:** `craft` for motion purpose; `design` for motion tokens.
123
+
124
+ **Positive fix:** Remove decorative motion or replace it with short transform/opacity feedback tied to a named state change.
@@ -0,0 +1,134 @@
1
+ ---
2
+ name: design-baseline
3
+ description: Discover, validate, or draft a project-owned DESIGN.md before adding or revising UI in an existing frontend. Use during design-playbook initialization when a repository already has pages, components, themes, tokens, or styles; when new UI looks inconsistent with existing surfaces; when DESIGN.md may be missing, incomplete, conflicting, or stale; or when the user asks to generate a design system from existing frontend source. Produces a provenance-backed draft and requires confirmation before creating or replacing the durable baseline.
4
+ ---
5
+
6
+ # design-baseline
7
+
8
+ Establish one project-owned visual authority before UI decisions or Fill. Treat existing code and rendered pages as evidence, not as permission to silently rewrite `DESIGN.md`.
9
+
10
+ ## Authority boundary
11
+
12
+ | This skill owns | Does not own |
13
+ | --- | --- |
14
+ | Discovering and structurally validating project `DESIGN.md` | Functional success criteria (`spec` L1–L6) |
15
+ | Extracting a draft from first-party frontend source | Third-party reference Keep/Change/Do not copy (`reference-intake`) |
16
+ | Source hashes, observed/inferred labels, confidence, unresolved gaps | Component/template selection (`ui-picker`) |
17
+ | Confirmation before a durable baseline write | Pass/Fail verdict (`ui-evaluator`) |
18
+
19
+ Canonical authority is `<project-root>/DESIGN.md`. Accept `.stitch/DESIGN.md` as a compatibility candidate only. If both exist with different content, stop for an explicit user choice; never merge them silently.
20
+
21
+ ## Deep module (SSOT for deterministic work)
22
+
23
+ All path resolution, scanning, drafting, hashing, durable write, and re-verification live in one module:
24
+
25
+ [`scripts/design_baseline.py`](scripts/design_baseline.py)
26
+
27
+ Public interface:
28
+
29
+ ```python
30
+ prepare(project_root, run_root) -> state
31
+ confirm(project_root, run_root, decision, reason=None) -> state
32
+ verify(project_root, run_root) -> state
33
+ ```
34
+
35
+ CLI:
36
+
37
+ ```text
38
+ python scripts/design_baseline.py prepare <project_root> <run_root>
39
+ python scripts/design_baseline.py confirm <project_root> <run_root> --decision accept|waive [--reason ...]
40
+ python scripts/design_baseline.py verify <project_root> <run_root>
41
+ ```
42
+
43
+ State is a cache, not authority. Every public call resolves paths against the supplied project root. `verify` re-hashes the bound baseline and its first-party sources before returning a downstream binding. Fill and other consumers may only use a binding that just passed `verify`.
44
+
45
+ | `status` | Meaning |
46
+ | --- | --- |
47
+ | `ready` | Bound baseline (`decision.kind` = `existing` or `accepted`) |
48
+ | `needs_confirmation` | Provenance-backed draft awaits accept/waive |
49
+ | `waived` | Explicit user waiver with non-empty reason |
50
+ | `ambiguous` | Conflicting candidates; human choice required |
51
+
52
+ ## Workflow
53
+
54
+ ### 1. Classify the project
55
+
56
+ Apply the existing-product gate when the requested build or fix adds/revises UI and the repository already contains meaningful first-party UI: pages/routes, shared components, theme or token files, global styles, or shipped screenshots/stories.
57
+
58
+ Skip for answer-only, review-only, diagnosis-only, or planning-only work that will not change UI. Skip the entry gate for a true greenfield repository with no existing visual surface. Narrate either skip in one line.
59
+
60
+ **Done when:** the run records `existing-product` or `greenfield`, with the file signals used for that classification.
61
+
62
+ ### 2. Prepare (`prepare`)
63
+
64
+ Run `prepare(project_root, run_root)`. Deterministic code:
65
+
66
+ - discovers `DESIGN.md` / `.stitch/DESIGN.md` (rejects escaping symlinks);
67
+ - validates a complete existing baseline in place;
68
+ - or scans first-party theme/token/style/component/page sources, writes `evidence.json` + `DESIGN.draft.md`, and returns `needs_confirmation`;
69
+ - writes `.scratch/<run>/design-baseline/state.json` (`schema: design-baseline/v1`).
70
+
71
+ Agent work after prepare:
72
+
73
+ - if `status` is `ready` → cite path + sha256 and continue;
74
+ - if `ambiguous` → stop for the smallest user decision; never invent a third authority;
75
+ - if `needs_confirmation` → review the draft; optionally enrich only material claims with `[inferred confidence=…]` **in the draft file**, then re-run prepare if structure/sources changed (do not hand-edit hashes).
76
+
77
+ Never write or overwrite project `DESIGN.md` in this step.
78
+
79
+ **Done when:** `state.json` exists with one of the four statuses above; drafts carry source paths + SHA-256 and observed/inferred labels.
80
+
81
+ ### 3. Confirm or waive (`confirm`)
82
+
83
+ Show a compact summary: atmosphere, core tokens, typography, layout, primitives, conflicting evidence, inferred claims. Ask before the durable write.
84
+
85
+ - **Accept:** `confirm(..., decision="accept")` atomically writes canonical `<project-root>/DESIGN.md` from the bound draft and returns a `ready` state.
86
+ - **Waive:** `confirm(..., decision="waive", reason=<user reason>)` does not write `DESIGN.md`. Existing-product Fill may continue only after this explicit waiver.
87
+ - **Revise:** edit only the draft (or fix sources), then `prepare` again.
88
+
89
+ Never infer acceptance from silence. Never replace a valid baseline merely because extraction found different implementation details; report the drift for a decision.
90
+
91
+ **Done when:** `state.json` is `ready` (existing or accepted) or `waived` with a non-empty reason.
92
+
93
+ ### 4. Verify before Fill (`verify`)
94
+
95
+ Immediately before Fill (and any time a consumer needs a binding), call `verify(project_root, run_root)`.
96
+
97
+ - Re-checks path containment, baseline hash, source freshness, and provenance alignment.
98
+ - Rejects forged `state.json`, stale sources, candidate conflicts, and symlink escape.
99
+ - On success, returns the binding: baseline path + sha256 (or an explicit waiver).
100
+
101
+ Downstream may only consume this verified result — not a hand-edited confirm file and not a draft.
102
+
103
+ **Done when:** `verify` returns without error; the decision report can cite `design-baseline: <path> sha256:<digest>` or `waived:<reason>`.
104
+
105
+ ### 5. Bind downstream consumers
106
+
107
+ | Consumer | Required behavior |
108
+ | --- | --- |
109
+ | `ui-picker` | Cite the verified baseline in the decision report; preserve visual roles, density, layout, and component conventions unless a declared change is approved |
110
+ | Fill | Use project tokens and primitives; log missing roles instead of inventing raw values; gate on successful `verify` |
111
+ | `craft-guard` | Treat obvious baseline drift as a craft failure, not merely personal taste |
112
+ | `ui-evaluator` | Point observable drift back to `DESIGN.md`; the baseline is supporting declaration evidence, never L6 runtime proof by itself |
113
+
114
+ Third-party or sample `DESIGN.md` files remain `reference-intake` inputs. They never become project authority automatically.
115
+
116
+ ## Artifacts
117
+
118
+ ```text
119
+ <project-root>/DESIGN.md # durable authority after accept
120
+ .scratch/<run>/design-baseline/state.json # gate cache (schema design-baseline/v1)
121
+ .scratch/<run>/design-baseline/evidence.json # extraction evidence (when drafted)
122
+ .scratch/<run>/design-baseline/DESIGN.draft.md # proposal; never authority by itself
123
+ ```
124
+
125
+ The deep module `prepare`/`confirm`/`verify` is the sole gate surface. An adopted existing `DESIGN.md` only needs to carry verifiable source provenance (path + SHA-256 under `## Source Evidence & Confidence`) to be bound; the other section names in [`references/design-template.md`](references/design-template.md) are draft guidance, not a structural contract imposed on hand-written baselines.
126
+
127
+ ## Scope fence
128
+
129
+ | In | Out → |
130
+ | --- | --- |
131
+ | First-party visual baseline and provenance | Functional behavior → `ux-spec` |
132
+ | Existing-source extraction | External inspiration → `reference-intake` |
133
+ | Confirmation before durable write | Scene/template/component decision → `ui-picker` |
134
+ | Baseline drift source for point-back | Runtime evidence judgment → `ui-evaluator` |
@@ -0,0 +1,4 @@
1
+ interface:
2
+ display_name: "Design Baseline"
3
+ short_description: "Discover, validate, or draft project DESIGN.md"
4
+ default_prompt: "Use $design-baseline to inspect this project's existing UI and establish a confirmed DESIGN.md baseline before adding a new page."
@@ -0,0 +1,73 @@
1
+ ---
2
+ name: "<project-name>"
3
+ colors:
4
+ background: "<#hex-or-token>"
5
+ surface: "<#hex-or-token>"
6
+ text: "<#hex-or-token>"
7
+ primary: "<#hex-or-token>"
8
+ ---
9
+
10
+ # Design System: <project-name>
11
+
12
+ ## Visual Theme & Atmosphere
13
+
14
+ - [observed] <dominant visual character and evidence>
15
+ - [inferred] <design intent, with confidence>
16
+
17
+ ## Color Palette & Roles
18
+
19
+ ### Foundation
20
+
21
+ - `<token or value>` — <background/surface role>
22
+
23
+ ### Interactive and Functional
24
+
25
+ - `<token or value>` — <primary/success/warning/error role>
26
+
27
+ ### Text Hierarchy
28
+
29
+ - `<token or value>` — <primary/secondary/muted role>
30
+
31
+ ## Typography Rules
32
+
33
+ - Font families: <families and fallbacks>
34
+ - Hierarchy: <display/heading/body/label sizes, weights, and line heights>
35
+ - Usage: <where each role appears>
36
+
37
+ ## Component Stylings
38
+
39
+ - Buttons: <shape, variants, states, spacing>
40
+ - Containers/cards: <radius, border, elevation, padding>
41
+ - Navigation: <layout and active states>
42
+ - Inputs: <shape, focus, validation, touch target>
43
+ - Domain primitives: <project-specific components>
44
+
45
+ ## Layout Principles
46
+
47
+ - Container/grid: <width, columns, alignment>
48
+ - Spacing: <base unit and density>
49
+ - Responsive behavior: <breakpoints and collapse rules>
50
+
51
+ ## Motion & Interaction
52
+
53
+ - Timing/easing: <tokens or observed values>
54
+ - State transitions: <hover/focus/pressed/loading>
55
+ - Reduced motion: <behavior>
56
+
57
+ ## Accessibility
58
+
59
+ - Contrast and color semantics: <rules>
60
+ - Focus and keyboard: <rules>
61
+ - Touch targets and text scaling: <rules>
62
+
63
+ ## Source Evidence & Confidence
64
+
65
+ - path: `src/path/to/high-signal-file`
66
+ sha256: `<64-lowercase-hex-digest>`
67
+ captures: <tokens/theme/layout/components>
68
+ confidence: <high|medium|low>
69
+
70
+ ## Known Gaps & Exceptions
71
+
72
+ - <contradiction, unverified inference, legacy override, or missing state>
73
+
@@ -0,0 +1,39 @@
1
+ # Existing UI extraction guidance
2
+
3
+ Use source precedence to separate intended design rules from accidental one-offs.
4
+
5
+ ## 1. Discover the frontend shape
6
+
7
+ Identify framework and styling signals from manifests and configuration. Map pages/routes, shared components, global styles, themes/tokens, fonts, assets, and stories/screenshots. Ignore generated output, dependencies, caches, and vendored UI.
8
+
9
+ Classify the project as existing-product only when meaningful first-party UI exists. A dependency on React/Vue/Svelte alone is not enough.
10
+
11
+ ## 2. Read sources in precedence order
12
+
13
+ 1. Explicit tokens and theme files.
14
+ 2. Global CSS variables, Tailwind/theme configuration, font declarations.
15
+ 3. Shared primitives: buttons, inputs, cards, navigation, dialogs.
16
+ 4. Two to five representative pages covering dominant and edge-case layouts.
17
+ 5. Rendered evidence when the app can be inspected safely.
18
+
19
+ Higher-precedence sources express intent. Lower-precedence sources prove what shipped. Record conflicts; do not hide them by averaging values.
20
+
21
+ ## 3. Extract by functional role
22
+
23
+ - Colors: background, surface, text hierarchy, interaction, semantic state.
24
+ - Typography: family, scale, weight, line height, letter spacing, usage.
25
+ - Layout: container width, grid, density, spacing unit, responsive collapse.
26
+ - Components: shape, variants, states, focus, elevation, domain primitives.
27
+ - Motion: duration, easing, state change, reduced-motion handling.
28
+ - Accessibility: contrast intent, focus visibility, keyboard, touch targets.
29
+
30
+ Consolidate near-duplicate values only when their role is demonstrably the same. Keep unexplained divergence under Known Gaps & Exceptions.
31
+
32
+ ## 4. Preserve provenance
33
+
34
+ For every high-signal source included in the baseline, record its project-relative path and SHA-256. Label design claims `[observed]` when directly supported and `[inferred]` when synthesized. Give inferred claims a confidence level and expose unresolved contradictions.
35
+
36
+ ## 5. Draft, then confirm
37
+
38
+ Generate only `.scratch/<run>/design-baseline/DESIGN.draft.md`. Compare it with representative existing pages. Present the meaningful design rules and conflicts to the user. A draft becomes `<project-root>/DESIGN.md` only after explicit confirmation.
39
+