@noemuch/bridge-ds 2.3.0 → 2.5.1
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/.claude-plugin/plugin.json +31 -0
- package/.cursor-plugin/plugin.json +26 -0
- package/.mcp.json +12 -0
- package/CHANGELOG.md +93 -0
- package/CLAUDE.md +84 -0
- package/README.md +25 -10
- package/lib/cli.js +107 -134
- package/lib/mcp-setup.js +32 -28
- package/lib/scaffold.js +6 -3
- package/package.json +10 -3
- package/skills/design-workflow/SKILL.md +70 -17
- package/skills/design-workflow/references/actions/design.md +63 -12
- package/skills/design-workflow/references/actions/done.md +21 -3
- package/skills/design-workflow/references/actions/learn.md +147 -0
- package/skills/design-workflow/references/actions/quick.md +80 -0
- package/skills/design-workflow/references/actions/review.md +14 -3
- package/skills/design-workflow/references/actions/spec.md +24 -0
- package/skills/design-workflow/references/actions/sync.md +176 -0
- package/skills/design-workflow/references/figma-api-rules.md +112 -0
- package/skills/design-workflow/references/knowledge-base/README.md +18 -1
- package/skills/design-workflow/references/knowledge-base/schemas/assets.md +6 -0
- package/skills/design-workflow/references/knowledge-base/schemas/components.md +6 -0
- package/skills/design-workflow/references/knowledge-base/schemas/learnings.md +250 -0
- package/skills/design-workflow/references/knowledge-base/schemas/text-styles.md +6 -0
- package/skills/design-workflow/references/knowledge-base/schemas/validation.md +6 -0
- package/skills/design-workflow/references/knowledge-base/schemas/variables.md +6 -0
- package/skills/design-workflow/references/onboarding.md +51 -9
- package/skills/design-workflow/references/quality-gates.md +51 -2
- package/skills/design-workflow/references/templates/screen-template.md +12 -0
- package/skills/design-workflow/references/templates/spec-template.md +12 -0
- package/skills/design-workflow/references/transport-adapter.md +210 -0
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# Quick Mode — Express Design Generation
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
Generate a Figma design directly from a brief description, skipping the formal spec phase. Uses existing knowledge base, registries, and learnings. For when you need speed over ceremony.
|
|
5
|
+
|
|
6
|
+
## Prerequisites
|
|
7
|
+
- Knowledge base exists (registries populated) — if not, suggest: "Run `/design-workflow setup` first"
|
|
8
|
+
- MCP transport available (see transport-adapter.md)
|
|
9
|
+
|
|
10
|
+
## Procedure
|
|
11
|
+
|
|
12
|
+
### Step 1 — Load context
|
|
13
|
+
1. Load all registries (components.json, variables.json, text-styles.json)
|
|
14
|
+
2. Load all guides (token usage, component overview, design patterns)
|
|
15
|
+
3. Load learnings.json (apply all with scope=global + contextual matching description)
|
|
16
|
+
4. Load ui-references guide if available
|
|
17
|
+
|
|
18
|
+
### Step 2 — Gather intent (2 questions max)
|
|
19
|
+
Ask the user exactly two things:
|
|
20
|
+
1. **What to design**: brief description (e.g., "a settings page with profile section and notification preferences")
|
|
21
|
+
2. **Where**: Figma file URL or file key + page name
|
|
22
|
+
|
|
23
|
+
Do NOT ask for detailed content, states, responsive rules, or acceptance criteria. Infer reasonable defaults from the knowledge base and design patterns.
|
|
24
|
+
|
|
25
|
+
### Step 3 — Pattern matching (best-effort)
|
|
26
|
+
- Identify the screen type from the description
|
|
27
|
+
- Load matching design patterns from guides/design-patterns.md
|
|
28
|
+
- If ui-references/screenshots exist, identify the closest reference
|
|
29
|
+
- This step is NON-BLOCKING — if no pattern matches, proceed with reasonable layout defaults
|
|
30
|
+
- Note: in full mode, pattern matching is a blocking gate. In quick mode, it is best-effort.
|
|
31
|
+
|
|
32
|
+
### Step 4 — Generate mini-spec (inline, not persisted)
|
|
33
|
+
Write a condensed spec covering only:
|
|
34
|
+
- **Layout**: zones, grid, overall structure (1-2 sentences)
|
|
35
|
+
- **Sections**: list of sections with DS components to use (table format)
|
|
36
|
+
- **Tokens**: key tokens for the layout (background, spacing rhythm)
|
|
37
|
+
- **Known Preferences**: applicable learnings from learnings.json
|
|
38
|
+
|
|
39
|
+
Format as a concise markdown block. Do NOT write to specs/active/. This lives only in the conversation.
|
|
40
|
+
|
|
41
|
+
Show the mini-spec to the user and ask: "Generate this design?" (single yes/no confirmation)
|
|
42
|
+
|
|
43
|
+
### Step 5 — Generate design
|
|
44
|
+
Follow the same generation procedure as design.md steps 3-6:
|
|
45
|
+
1. Read figma-api-rules.md (MANDATORY — same rules apply in quick mode)
|
|
46
|
+
2. Determine canvas dimensions based on screen type
|
|
47
|
+
3. **Pre-script audit** (MANDATORY — list every element, cross-reference against registries. Validate all keys per Rule 26.)
|
|
48
|
+
4. Generate atomically in 4-6 scripts, ~30-80 lines each
|
|
49
|
+
5. Take screenshot after each atomic step for verification — **but NOT before Script 1** (Rule 24: empty pages/frames cannot be screenshotted)
|
|
50
|
+
6. For form inputs with values, use `state=filled` variant (Rule 25)
|
|
51
|
+
7. Fix any issues before proceeding to next step
|
|
52
|
+
|
|
53
|
+
IMPORTANT: These gates are NOT relaxed in quick mode:
|
|
54
|
+
- Pre-script element audit (Rule 18) — BLOCKING
|
|
55
|
+
- Registry key validation (Rule 26) — BLOCKING
|
|
56
|
+
- Zero hardcoded hex colors — BLOCKING
|
|
57
|
+
- Atomic generation with screenshots — MANDATORY
|
|
58
|
+
- DS component reuse (never recreate) — BLOCKING
|
|
59
|
+
|
|
60
|
+
### Step 6 — Present result
|
|
61
|
+
Take a final screenshot of the complete design. Present to the user with:
|
|
62
|
+
- Link to the Figma node
|
|
63
|
+
- Summary of what was created (sections, components used, tokens applied)
|
|
64
|
+
- Any learnings that were applied
|
|
65
|
+
- Suggestion: "Run `/design-workflow review` for a formal quality check, or `/design-workflow learn` if you make corrections"
|
|
66
|
+
|
|
67
|
+
## What is NOT done in quick mode
|
|
68
|
+
- No formal spec file written to specs/active/
|
|
69
|
+
- No formal review phase (but user can run review separately)
|
|
70
|
+
- No automatic snapshot for learn (but user can run learn separately)
|
|
71
|
+
- No pattern matching gate (best-effort only)
|
|
72
|
+
- No acceptance criteria validation
|
|
73
|
+
|
|
74
|
+
## Quality guarantee
|
|
75
|
+
Even in quick mode, every design:
|
|
76
|
+
- Uses 100% DS components (never raw recreations)
|
|
77
|
+
- Uses 100% bound tokens (never hardcoded hex)
|
|
78
|
+
- Is generated atomically with visual verification
|
|
79
|
+
- Follows all 22+ figma-api-rules
|
|
80
|
+
- Applies relevant learnings from previous corrections
|
|
@@ -19,10 +19,10 @@
|
|
|
19
19
|
- Load knowledge base registries for validation:
|
|
20
20
|
- `references/knowledge-base/registries/components.json` → verify component instances match registry
|
|
21
21
|
- `references/knowledge-base/registries/variables.json` → verify variable bindings use correct names
|
|
22
|
-
- Inspect Figma design via MCP:
|
|
22
|
+
- Inspect Figma design via MCP (tool names depend on transport — see `references/transport-adapter.md`):
|
|
23
23
|
```
|
|
24
|
-
figma_take_screenshot({ node_id
|
|
25
|
-
figma_get_variables({ file_key
|
|
24
|
+
Screenshot: console → figma_take_screenshot({ node_id, file_key }) / official → get_screenshot({ nodeId, fileKey })
|
|
25
|
+
Variables: console → figma_get_variables({ file_key }) / official → get_variable_defs({ fileKey })
|
|
26
26
|
```
|
|
27
27
|
|
|
28
28
|
### 2. Review checklist
|
|
@@ -106,6 +106,17 @@ Cross-reference every visual element in the design against `registries/component
|
|
|
106
106
|
- [ ] Could the props surface be smaller?
|
|
107
107
|
- [ ] Is the component reusable beyond its primary use case?
|
|
108
108
|
|
|
109
|
+
#### G. Learning Opportunity
|
|
110
|
+
|
|
111
|
+
If the review identifies issues that the user may want to correct manually in Figma (spacing adjustments, token swaps, component replacements):
|
|
112
|
+
|
|
113
|
+
```
|
|
114
|
+
💡 After making corrections in Figma, run: `learn`
|
|
115
|
+
Bridge will detect your changes and remember them for future designs.
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
This hint is informational only — it does not block the review.
|
|
119
|
+
|
|
109
120
|
### 3. Report
|
|
110
121
|
|
|
111
122
|
```markdown
|
|
@@ -46,6 +46,30 @@ Without one, I'll build from scratch (slower, may need iterations).
|
|
|
46
46
|
- Check existing specs: `specs/active/`, `specs/backlog/`
|
|
47
47
|
- Check existing DS components in `references/knowledge-base/registries/components.json`
|
|
48
48
|
|
|
49
|
+
### 2.5. Load Learnings
|
|
50
|
+
|
|
51
|
+
Load `references/knowledge-base/learnings.json` (skip if file doesn't exist).
|
|
52
|
+
|
|
53
|
+
Filter learnings by `screenType` matching the new spec's type (from step 1 context):
|
|
54
|
+
- Include all **global** learnings (`scope: "global"`)
|
|
55
|
+
- Include **contextual** learnings where `context.screenType` matches
|
|
56
|
+
|
|
57
|
+
If matching learnings exist, include a **"Known Preferences"** section in the spec:
|
|
58
|
+
|
|
59
|
+
```markdown
|
|
60
|
+
## Known Preferences (from learnings)
|
|
61
|
+
|
|
62
|
+
The following preferences have been learned from previous design corrections:
|
|
63
|
+
|
|
64
|
+
| Rule | Property | Preferred Token | Scope | Signals |
|
|
65
|
+
|------|----------|----------------|-------|---------|
|
|
66
|
+
| {rule} | {property} | {to.token} | {scope} | {signals} |
|
|
67
|
+
|
|
68
|
+
These preferences MUST be applied during design generation unless the spec explicitly overrides them.
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
This section goes after "Design tokens" and before "Responsive rules" (screens) or before "Acceptance criteria" (components).
|
|
72
|
+
|
|
49
73
|
### 3. Write the spec
|
|
50
74
|
|
|
51
75
|
Write to `specs/active/{name}-spec.md`.
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
# Action: sync
|
|
2
|
+
|
|
3
|
+
> Incrementally sync the DS knowledge base with the current state of the Figma DS library.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Prerequisites
|
|
8
|
+
|
|
9
|
+
- Knowledge base exists (`references/knowledge-base/registries/` has JSON files) — abort if missing: "No knowledge base found. Run: `setup` first."
|
|
10
|
+
- Figma MCP transport available (console: `figma_get_status`, official: `whoami` — see `references/transport-adapter.md` Section F)
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## Procedure
|
|
15
|
+
|
|
16
|
+
### 1. Read current registries
|
|
17
|
+
|
|
18
|
+
Load all existing registries:
|
|
19
|
+
- `registries/components.json`
|
|
20
|
+
- `registries/variables.json`
|
|
21
|
+
- `registries/text-styles.json`
|
|
22
|
+
- `registries/icons.json` (if exists)
|
|
23
|
+
- `registries/logos.json` (if exists)
|
|
24
|
+
- `registries/illustrations.json` (if exists)
|
|
25
|
+
|
|
26
|
+
Note the `meta.fileKey` from any registry to identify the DS source file.
|
|
27
|
+
|
|
28
|
+
### 2. Re-extract from Figma
|
|
29
|
+
|
|
30
|
+
Use the same MCP tools as `setup` (tool names depend on transport — see `references/transport-adapter.md`):
|
|
31
|
+
|
|
32
|
+
**Console transport:**
|
|
33
|
+
- `figma_get_design_system_kit({ file_key })` → full DS snapshot
|
|
34
|
+
- `figma_get_variables({ file_key })` → current variables
|
|
35
|
+
- `figma_get_styles({ file_key })` → current text/color/effect styles
|
|
36
|
+
- If keys missing, supplement with `figma_execute` extraction scripts (from `schemas/`)
|
|
37
|
+
|
|
38
|
+
**Official transport** (composite strategy — see transport-adapter.md Section D):
|
|
39
|
+
- `get_variable_defs({ fileKey })` → variables
|
|
40
|
+
- `search_design_system({ query: "*", includeComponents: true })` → components
|
|
41
|
+
- `search_design_system({ query: "*", includeStyles: true })` → styles
|
|
42
|
+
- Supplement with `use_figma` extraction scripts from schemas as needed
|
|
43
|
+
|
|
44
|
+
### 3. Diff registries
|
|
45
|
+
|
|
46
|
+
Compare old vs new for each registry:
|
|
47
|
+
|
|
48
|
+
**Components (`components.json`):**
|
|
49
|
+
- **Added:** components in new extraction not in current registry
|
|
50
|
+
- **Removed:** components in current registry not in new extraction (match by `key`)
|
|
51
|
+
- **Modified:** same `key` but different `properties`, `name`, or `variants` count
|
|
52
|
+
|
|
53
|
+
**Variables (`variables.json`):**
|
|
54
|
+
- **Added:** new variable keys
|
|
55
|
+
- **Removed:** variable keys no longer present
|
|
56
|
+
- **Modified:** same `key` but different `name`, `valuesByMode`, or collection assignment
|
|
57
|
+
|
|
58
|
+
**Text styles (`text-styles.json`):**
|
|
59
|
+
- **Added:** new style keys
|
|
60
|
+
- **Removed:** style keys no longer present
|
|
61
|
+
- **Modified:** same `key` but different `name` or font properties
|
|
62
|
+
|
|
63
|
+
**Assets (icons/logos/illustrations):**
|
|
64
|
+
- Same add/remove/modify logic by `key`
|
|
65
|
+
|
|
66
|
+
### 4. Impact analysis
|
|
67
|
+
|
|
68
|
+
For removed or modified items, check references across the knowledge base:
|
|
69
|
+
|
|
70
|
+
**Guides impact:**
|
|
71
|
+
- Search `guides/components/*.md` for references to removed/renamed components
|
|
72
|
+
- Search `guides/tokens/*.md` for references to removed/renamed variables
|
|
73
|
+
- Search `guides/patterns/*.md` for affected patterns
|
|
74
|
+
|
|
75
|
+
**Learnings impact:**
|
|
76
|
+
- Check `learnings.json` for learnings referencing removed tokens
|
|
77
|
+
- Flag affected learnings (don't delete — mark for user review)
|
|
78
|
+
|
|
79
|
+
**Active specs impact:**
|
|
80
|
+
- Check `specs/active/*.md` for references to removed/modified components or tokens
|
|
81
|
+
|
|
82
|
+
### 5. Report to user
|
|
83
|
+
|
|
84
|
+
Present the diff report BEFORE applying changes:
|
|
85
|
+
|
|
86
|
+
```markdown
|
|
87
|
+
## DS Sync Report
|
|
88
|
+
|
|
89
|
+
### Summary
|
|
90
|
+
- Components: +{added} ~{modified} -{removed}
|
|
91
|
+
- Variables: +{added} ~{modified} -{removed}
|
|
92
|
+
- Text styles: +{added} ~{modified} -{removed}
|
|
93
|
+
- Assets: +{added} ~{modified} -{removed}
|
|
94
|
+
|
|
95
|
+
### Added
|
|
96
|
+
{list of new items per registry}
|
|
97
|
+
|
|
98
|
+
### Modified
|
|
99
|
+
{list of changed items with old → new values}
|
|
100
|
+
|
|
101
|
+
### Removed (⚠️ Breaking Changes)
|
|
102
|
+
{list of removed items}
|
|
103
|
+
|
|
104
|
+
#### Impact of removals:
|
|
105
|
+
- Guides affected: {list of guide files referencing removed items}
|
|
106
|
+
- Learnings affected: {list of learning IDs referencing removed tokens}
|
|
107
|
+
- Active specs affected: {list of spec files referencing removed items}
|
|
108
|
+
|
|
109
|
+
### Recommended actions:
|
|
110
|
+
1. {action per breaking change}
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
**BLOCKING:** If there are removals (breaking changes), ask the user to confirm before proceeding:
|
|
114
|
+
```
|
|
115
|
+
{n} items were removed from the DS. This affects {n} guides and {n} learnings.
|
|
116
|
+
Proceed with sync? (Removed items will be deleted from registries, affected guides will be patched.)
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### 6. Apply updates
|
|
120
|
+
|
|
121
|
+
After user confirmation:
|
|
122
|
+
|
|
123
|
+
**Update registries:**
|
|
124
|
+
- Add new entries
|
|
125
|
+
- Update modified entries (preserve `key`, update other fields)
|
|
126
|
+
- Remove deleted entries
|
|
127
|
+
|
|
128
|
+
**Patch guides:**
|
|
129
|
+
- For removed components: remove or comment out references in affected guide files
|
|
130
|
+
- For renamed components: find-and-replace old name with new name
|
|
131
|
+
- For modified properties: update property descriptions in component guides
|
|
132
|
+
|
|
133
|
+
**Update learnings:**
|
|
134
|
+
- For learnings referencing removed tokens: add a flag entry noting the token was removed
|
|
135
|
+
- Do NOT delete learnings — they may still be conceptually valid even if the token name changed
|
|
136
|
+
|
|
137
|
+
**Re-validate registries:**
|
|
138
|
+
- Run sample import test (3-5 keys per registry) via `figma_execute` to confirm new/modified keys work
|
|
139
|
+
- Follow `schemas/validation.md` procedure
|
|
140
|
+
|
|
141
|
+
### 7. Regenerate affected guides (optional)
|
|
142
|
+
|
|
143
|
+
If significant changes detected (>10 items changed or any category restructured), suggest:
|
|
144
|
+
```
|
|
145
|
+
Significant DS changes detected. Regenerate affected guides?
|
|
146
|
+
- Token guides: {list if token changes}
|
|
147
|
+
- Component guides: {list if component changes}
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
Only regenerate if user confirms. Use the same guide generation logic as `setup`.
|
|
151
|
+
|
|
152
|
+
---
|
|
153
|
+
|
|
154
|
+
## Output
|
|
155
|
+
|
|
156
|
+
```
|
|
157
|
+
DS Sync complete.
|
|
158
|
+
|
|
159
|
+
Updated:
|
|
160
|
+
- components.json: +{n} ~{n} -{n}
|
|
161
|
+
- variables.json: +{n} ~{n} -{n}
|
|
162
|
+
- text-styles.json: +{n} ~{n} -{n}
|
|
163
|
+
- {assets}: +{n} ~{n} -{n}
|
|
164
|
+
|
|
165
|
+
Guides patched: {n} files
|
|
166
|
+
Learnings preserved: {n} ({n} flagged for review)
|
|
167
|
+
Validation: {PASS/FAIL}
|
|
168
|
+
|
|
169
|
+
Next: Review updated registries, then continue with `spec` or `design`.
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
---
|
|
173
|
+
|
|
174
|
+
## Transition
|
|
175
|
+
|
|
176
|
+
After sync → suggest: "DS synced. Run: `status` to see current state."
|
|
@@ -499,6 +499,71 @@ Input (default) → components.json key: def456 → import ✓
|
|
|
499
499
|
|
|
500
500
|
---
|
|
501
501
|
|
|
502
|
+
## Rule 23: Transport-aware scripting
|
|
503
|
+
|
|
504
|
+
Script format depends on the active MCP transport. See `references/transport-adapter.md` for full details.
|
|
505
|
+
|
|
506
|
+
| Aspect | Console (`figma_execute`) | Official (`use_figma`) |
|
|
507
|
+
|--------|--------------------------|------------------------|
|
|
508
|
+
| Wrapper | IIFE: `return (async function() { ... })();` | Top-level `await`, no IIFE |
|
|
509
|
+
| Parameters | `{ code }` | `{ fileKey, description, code }` |
|
|
510
|
+
| `figma.notify()` | Allowed | **Forbidden** |
|
|
511
|
+
| `getPluginData()` | Allowed | **Forbidden** (use `getSharedPluginData()`) |
|
|
512
|
+
| Response size | Unlimited | **20KB limit** — chunk large extractions |
|
|
513
|
+
|
|
514
|
+
**Before writing any script, check which transport is active and use the correct format.**
|
|
515
|
+
|
|
516
|
+
---
|
|
517
|
+
|
|
518
|
+
## Rule 24: Never screenshot a page or empty node
|
|
519
|
+
|
|
520
|
+
`figma_take_screenshot` / `get_screenshot` will fail on:
|
|
521
|
+
- Page nodes (type PAGE) — they are not renderable
|
|
522
|
+
- Empty frames (0 children) — nothing to render
|
|
523
|
+
|
|
524
|
+
**Always create at least one visible frame before taking the first screenshot.** In quick mode and design mode, skip the initial screenshot attempt and wait until after Script 1 has created the root frame.
|
|
525
|
+
|
|
526
|
+
---
|
|
527
|
+
|
|
528
|
+
## Rule 25: Input/Select components — swap to `filled` state for values
|
|
529
|
+
|
|
530
|
+
When placing TextInput, SelectInput, or similar form components with actual values (not empty placeholders), **always swap to the `state=filled` variant** before setting text properties. The default variant is often `state=placeholder`, which hides the value text layer.
|
|
531
|
+
|
|
532
|
+
Pattern:
|
|
533
|
+
```js
|
|
534
|
+
// 1. Import the component set
|
|
535
|
+
var inputSet = await figma.importComponentSetByKeyAsync(TEXTINPUT_KEY);
|
|
536
|
+
|
|
537
|
+
// 2. Find the filled variant (not placeholder)
|
|
538
|
+
var filled = inputSet.findChild(function(n) {
|
|
539
|
+
return n.name.includes("state=filled") || n.name.includes("state=filling");
|
|
540
|
+
});
|
|
541
|
+
|
|
542
|
+
// 3. Create instance from the filled variant
|
|
543
|
+
var instance = filled.createInstance();
|
|
544
|
+
|
|
545
|
+
// 4. Now set text properties — they will be visible
|
|
546
|
+
instance.setProperties({ "label#HASH": "First Name", "placeholder#HASH": "John" });
|
|
547
|
+
```
|
|
548
|
+
|
|
549
|
+
If the DS has no `filled` variant, check for `default` or `rest` — but never leave `state=placeholder` when displaying real values.
|
|
550
|
+
|
|
551
|
+
---
|
|
552
|
+
|
|
553
|
+
## Rule 26: Validate registry keys before writing scripts
|
|
554
|
+
|
|
555
|
+
Variable and component keys are 40-char hex strings — typos crash scripts at runtime with unhelpful errors like `could not find variable with key "..."`.
|
|
556
|
+
|
|
557
|
+
**Before writing any figma_execute / use_figma script:**
|
|
558
|
+
1. List every key you plan to use in the script
|
|
559
|
+
2. Cross-reference each key against the exact values in `registries/variables.json`, `registries/components.json`, or `registries/text-styles.json`
|
|
560
|
+
3. Copy-paste keys directly from the registry — never type them manually
|
|
561
|
+
4. If a key is not found in registries, search with `Grep` before assuming the name
|
|
562
|
+
|
|
563
|
+
This is part of the pre-script audit (Rule 18). Every key in the script must have a verified source in the registries.
|
|
564
|
+
|
|
565
|
+
---
|
|
566
|
+
|
|
502
567
|
## Standard Script Boilerplate
|
|
503
568
|
|
|
504
569
|
```js
|
|
@@ -550,3 +615,50 @@ return (async function() {
|
|
|
550
615
|
return { success: true };
|
|
551
616
|
})();
|
|
552
617
|
```
|
|
618
|
+
|
|
619
|
+
### Official transport version (use_figma)
|
|
620
|
+
|
|
621
|
+
Same helpers, no IIFE wrapper. Called with `use_figma({ fileKey: "...", description: "...", code: "..." })`.
|
|
622
|
+
|
|
623
|
+
```js
|
|
624
|
+
// ─── FONTS ───
|
|
625
|
+
await figma.loadFontAsync({ family: "Inter", style: "Regular" });
|
|
626
|
+
await figma.loadFontAsync({ family: "Inter", style: "Medium" });
|
|
627
|
+
await figma.loadFontAsync({ family: "Inter", style: "Semi Bold" });
|
|
628
|
+
await figma.loadFontAsync({ family: "Inter", style: "Bold" });
|
|
629
|
+
|
|
630
|
+
// ─── VARIABLES (from registries/variables.json) ───
|
|
631
|
+
// var spLarge = await figma.variables.importVariableByKeyAsync("YOUR_KEY");
|
|
632
|
+
|
|
633
|
+
// ─── HELPERS ───
|
|
634
|
+
function mf(colorVar) {
|
|
635
|
+
var p = figma.util.solidPaint("#000000");
|
|
636
|
+
p = figma.variables.setBoundVariableForPaint(p, "color", colorVar);
|
|
637
|
+
return [p];
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
function appendFill(parent, child, fillH, fillV) {
|
|
641
|
+
parent.appendChild(child);
|
|
642
|
+
if (fillH) child.layoutSizingHorizontal = "FILL";
|
|
643
|
+
if (fillV) child.layoutSizingVertical = "FILL";
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
function bindPadding(frame, top, right, bottom, left) {
|
|
647
|
+
if (top) frame.setBoundVariable("paddingTop", top);
|
|
648
|
+
if (right) frame.setBoundVariable("paddingRight", right);
|
|
649
|
+
if (bottom) frame.setBoundVariable("paddingBottom", bottom);
|
|
650
|
+
if (left) frame.setBoundVariable("paddingLeft", left);
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
function bindRadius(frame, radiusVar) {
|
|
654
|
+
frame.setBoundVariable("topLeftRadius", radiusVar);
|
|
655
|
+
frame.setBoundVariable("topRightRadius", radiusVar);
|
|
656
|
+
frame.setBoundVariable("bottomLeftRadius", radiusVar);
|
|
657
|
+
frame.setBoundVariable("bottomRightRadius", radiusVar);
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
// ─── BUILD ───
|
|
661
|
+
// ... your design code here ...
|
|
662
|
+
|
|
663
|
+
return { success: true };
|
|
664
|
+
```
|
|
@@ -43,6 +43,8 @@ knowledge-base/
|
|
|
43
43
|
ui-references/ ← Product screenshots for pattern extraction
|
|
44
44
|
screenshots/ ← PNG/JPG files of your product's key screens
|
|
45
45
|
ui-references-guide.md ← Which screenshot for which pattern type
|
|
46
|
+
|
|
47
|
+
learnings.json ← Persistent learning store (generated by `learn`)
|
|
46
48
|
```
|
|
47
49
|
|
|
48
50
|
## How to populate
|
|
@@ -56,6 +58,21 @@ Run `/design-workflow setup` in Claude Code. Claude will:
|
|
|
56
58
|
5. **Ask for screenshots** of your product's key screens
|
|
57
59
|
6. **Generate** layout pattern documentation from the screenshots
|
|
58
60
|
|
|
61
|
+
## Learnings
|
|
62
|
+
|
|
63
|
+
`learnings.json` stores user corrections detected by the `learn` action. See `schemas/learnings.md` for the full schema.
|
|
64
|
+
|
|
65
|
+
- **Learnings** = DS-compliant changes (user swapped one token for another) → applied in future generations
|
|
66
|
+
- **Flags** = non-DS-compliant changes (hardcoded hex, raw values) → surfaced for user review
|
|
67
|
+
- Learnings start as `contextual` (screen/component-specific) and promote to `global` after 3+ signals across 2+ screen types
|
|
68
|
+
|
|
59
69
|
## How to update
|
|
60
70
|
|
|
61
|
-
When your DS evolves (new components, changed tokens), run `/design-workflow
|
|
71
|
+
When your DS evolves (new components, changed tokens), run `/design-workflow sync` for an incremental update. Claude will:
|
|
72
|
+
|
|
73
|
+
1. Re-extract the DS from Figma
|
|
74
|
+
2. Diff against existing registries
|
|
75
|
+
3. Show a report: added, modified, removed items
|
|
76
|
+
4. Apply updates after confirmation (with breaking change analysis)
|
|
77
|
+
|
|
78
|
+
For a full re-extraction, run `/design-workflow setup` again.
|
|
@@ -142,3 +142,9 @@ var logoInstance = defaultVariant.createInstance();
|
|
|
142
142
|
- Illustrations often have theme variants (dark/light/brand)
|
|
143
143
|
- May be component sets (`type: "COMPONENT_SET"`)
|
|
144
144
|
- Naming convention: `{category}/{name}` (e.g., `asset/crypto`, `utility/empty-state`)
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
## Transport Note
|
|
149
|
+
|
|
150
|
+
For official transport: remove the IIFE wrapper from extraction scripts, add `fileKey` and `description` to the `use_figma` call. See `references/transport-adapter.md` for details.
|
|
@@ -122,3 +122,9 @@ Group components by semantic category:
|
|
|
122
122
|
- `indicators` — Avatars, Status, Progress
|
|
123
123
|
|
|
124
124
|
Use whatever categories match the DS's own organization.
|
|
125
|
+
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
## Transport Note
|
|
129
|
+
|
|
130
|
+
For official transport: remove the IIFE wrapper from extraction scripts, add `fileKey` and `description` to the `use_figma` call. See `references/transport-adapter.md` for details.
|