@zohofinance/commerce 1.0.0 → 1.1.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 (127) hide show
  1. package/README.md +59 -0
  2. package/package.json +2 -2
  3. package/ts-dist/mocks/init-theme/.claude/CLAUDE.md +6 -0
  4. package/ts-dist/mocks/init-theme/.claude/skills/.archive/zcommerce-section-from-design.20260528/SKILL.md +242 -0
  5. package/ts-dist/mocks/init-theme/.claude/skills/.archive/zcommerce-section-from-design.20260528/inputs/figma.md +81 -0
  6. package/ts-dist/mocks/init-theme/.claude/skills/.archive/zcommerce-section-from-design.20260528/inputs/screenshot.md +54 -0
  7. package/ts-dist/mocks/init-theme/.claude/skills/.archive/zcommerce-section-from-design.20260528/inputs/url.md +88 -0
  8. package/ts-dist/mocks/init-theme/.claude/skills/.archive/zcommerce-section-from-design.20260528/spec-table.md +102 -0
  9. package/ts-dist/mocks/init-theme/.claude/skills/.archive/zcommerce-section-from-design.20260528/verification/accessibility.md +110 -0
  10. package/ts-dist/mocks/init-theme/.claude/skills/.archive/zcommerce-section-from-design.20260528/verification/performance.md +127 -0
  11. package/ts-dist/mocks/init-theme/.claude/skills/.archive/zcommerce-section-from-design.20260528/verification/tokens.md +87 -0
  12. package/ts-dist/mocks/init-theme/.claude/skills/.archive/zcommerce-section-from-design.20260528/verification/visual-diff.md +123 -0
  13. package/ts-dist/mocks/init-theme/.claude/skills/.archive/zcommerce-theme-builder.20260528/SKILL.md +605 -0
  14. package/ts-dist/mocks/init-theme/.claude/skills/.archive/zcommerce-theme-builder.20260528/design-tokens.md +105 -0
  15. package/ts-dist/mocks/init-theme/.claude/skills/.archive/zcommerce-theme-builder.20260528/page-json-contract.md +58 -0
  16. package/ts-dist/mocks/init-theme/.claude/skills/.archive/zcommerce-theme-builder.20260528/qa-accessibility.md +35 -0
  17. package/ts-dist/mocks/init-theme/.claude/skills/.archive/zcommerce-theme-builder.20260528/reference-lookup.md +94 -0
  18. package/ts-dist/mocks/init-theme/.claude/skills/.archive/zcommerce-theme-builder.20260528/section-anatomy.md +109 -0
  19. package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/SKILL.md +313 -0
  20. package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/agent-hierarchy.md +142 -0
  21. package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/ask-developer.md +113 -0
  22. package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/bootstrap.md +260 -0
  23. package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/build-metrics.md +89 -0
  24. package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/code-quality.md +186 -0
  25. package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/common-pages-agent.md +97 -0
  26. package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/dev-server-and-urls.md +136 -0
  27. package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/exemplars.md +79 -0
  28. package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/figma-discovery.md +138 -0
  29. package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/figma-extraction.md +132 -0
  30. package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/image-sources.md +84 -0
  31. package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/inputs/guidelines-frame.md +178 -0
  32. package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/page-builder.md +322 -0
  33. package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/page-orchestrator.md +199 -0
  34. package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/parallel-fanout.md +152 -0
  35. package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/scripts/a11y.mjs +129 -0
  36. package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/scripts/lint-section.mjs +502 -0
  37. package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/scripts/perf.mjs +134 -0
  38. package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/scripts/pixel-diff.mjs +206 -0
  39. package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/scripts/record-build-metrics.mjs +118 -0
  40. package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/section-builder.md +131 -0
  41. package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/subagent-escalation.md +75 -0
  42. package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/transcription-rules.md +98 -0
  43. package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/verification.md +227 -0
  44. package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/visual-verify-loop.md +117 -0
  45. package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/zcommerce-docs/_index.md +4 -0
  46. package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/zcommerce-docs/assets.md +105 -0
  47. package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/zcommerce-docs/best-practices.md +212 -0
  48. package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/zcommerce-docs/custom-scripts.md +294 -0
  49. package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/zcommerce-docs/i18n.md +155 -0
  50. package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/zcommerce-docs/introduction.md +91 -0
  51. package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/zcommerce-docs/layouts.md +158 -0
  52. package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/zcommerce-docs/pages.md +156 -0
  53. package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/zcommerce-docs/reference/_index.md +4 -0
  54. package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/zcommerce-docs/reference/filters.md +419 -0
  55. package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/zcommerce-docs/reference/global-objects.md +415 -0
  56. package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/zcommerce-docs/reference/schema-types.md +926 -0
  57. package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/zcommerce-docs/reference/tags.md +259 -0
  58. package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/zcommerce-docs/sections.md +203 -0
  59. package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/zcommerce-docs/setup-guide.md +424 -0
  60. package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/zcommerce-docs/snippets.md +70 -0
  61. package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/zcommerce-docs/theme-structure.md +252 -0
  62. package/ts-dist/mocks/init-theme/.cursor/PLAYBOOK.md +144 -0
  63. package/ts-dist/mocks/init-theme/.cursor/README.md +6 -0
  64. package/ts-dist/mocks/init-theme/.cursor/agents/figma-desktop-mobile-parallel.md +48 -0
  65. package/ts-dist/mocks/init-theme/.cursor/agents/visual-compare.md +221 -0
  66. package/ts-dist/mocks/init-theme/.cursor/commands/add-field.md +83 -0
  67. package/ts-dist/mocks/init-theme/.cursor/commands/add-theme-setting.md +200 -0
  68. package/ts-dist/mocks/init-theme/.cursor/commands/assemble-page.md +72 -0
  69. package/ts-dist/mocks/init-theme/.cursor/commands/audit-page.md +57 -0
  70. package/ts-dist/mocks/init-theme/.cursor/commands/build-page-sections.md +110 -0
  71. package/ts-dist/mocks/init-theme/.cursor/commands/build-section.md +418 -0
  72. package/ts-dist/mocks/init-theme/.cursor/commands/build-theme.md +307 -0
  73. package/ts-dist/mocks/init-theme/.cursor/commands/compare-section.md +358 -0
  74. package/ts-dist/mocks/init-theme/.cursor/commands/create-theme.md +77 -0
  75. package/ts-dist/mocks/init-theme/.cursor/commands/extract-tokens.md +43 -0
  76. package/ts-dist/mocks/init-theme/.cursor/commands/fix-section.md +92 -0
  77. package/ts-dist/mocks/init-theme/.cursor/commands/impact.md +50 -0
  78. package/ts-dist/mocks/init-theme/.cursor/commands/qa-a11y.md +66 -0
  79. package/ts-dist/mocks/init-theme/.cursor/commands/qa-i18n.md +110 -0
  80. package/ts-dist/mocks/init-theme/.cursor/commands/qa-layout.md +127 -0
  81. package/ts-dist/mocks/init-theme/.cursor/commands/qa-performance.md +72 -0
  82. package/ts-dist/mocks/init-theme/.cursor/commands/qa-section.md +84 -0
  83. package/ts-dist/mocks/init-theme/.cursor/commands/qa-sections.md +48 -0
  84. package/ts-dist/mocks/init-theme/.cursor/commands/qa-theme.md +85 -0
  85. package/ts-dist/mocks/init-theme/.cursor/commands/redesign-section.md +177 -0
  86. package/ts-dist/mocks/init-theme/.cursor/commands/refactor-section.md +185 -0
  87. package/ts-dist/mocks/init-theme/.cursor/commands/sync-theme-settings.md +132 -0
  88. package/ts-dist/mocks/init-theme/.cursor/commands/validate-page.md +60 -0
  89. package/ts-dist/mocks/init-theme/.cursor/commands/validate-section-group.md +88 -0
  90. package/ts-dist/mocks/init-theme/.cursor/commands/validate-theme-settings.md +119 -0
  91. package/ts-dist/mocks/init-theme/.cursor/examples/design-instructions-template.md +151 -0
  92. package/ts-dist/mocks/init-theme/.cursor/mcp.json +18 -0
  93. package/ts-dist/mocks/init-theme/.cursor/rules/README.md +160 -0
  94. package/ts-dist/mocks/init-theme/.cursor/rules/accessibility.mdc +24 -0
  95. package/ts-dist/mocks/init-theme/.cursor/rules/add-field.mdc +222 -0
  96. package/ts-dist/mocks/init-theme/.cursor/rules/add-theme-setting.mdc +39 -0
  97. package/ts-dist/mocks/init-theme/.cursor/rules/assemble-page.mdc +130 -0
  98. package/ts-dist/mocks/init-theme/.cursor/rules/audit-page.mdc +92 -0
  99. package/ts-dist/mocks/init-theme/.cursor/rules/build-section.mdc +178 -0
  100. package/ts-dist/mocks/init-theme/.cursor/rules/build-theme.mdc +47 -0
  101. package/ts-dist/mocks/init-theme/.cursor/rules/compare-section.mdc +94 -0
  102. package/ts-dist/mocks/init-theme/.cursor/rules/create-theme.mdc +78 -0
  103. package/ts-dist/mocks/init-theme/.cursor/rules/css.mdc +137 -0
  104. package/ts-dist/mocks/init-theme/.cursor/rules/design-spec-extraction.mdc +255 -0
  105. package/ts-dist/mocks/init-theme/.cursor/rules/extract-tokens.mdc +43 -0
  106. package/ts-dist/mocks/init-theme/.cursor/rules/figma-mcp-resolution.mdc +40 -0
  107. package/ts-dist/mocks/init-theme/.cursor/rules/fix-section.mdc +154 -0
  108. package/ts-dist/mocks/init-theme/.cursor/rules/general.mdc +30 -0
  109. package/ts-dist/mocks/init-theme/.cursor/rules/i18n.mdc +85 -0
  110. package/ts-dist/mocks/init-theme/.cursor/rules/javascript.mdc +85 -0
  111. package/ts-dist/mocks/init-theme/.cursor/rules/liquid-no-hardcoded-strings.mdc +42 -0
  112. package/ts-dist/mocks/init-theme/.cursor/rules/liquid.mdc +171 -0
  113. package/ts-dist/mocks/init-theme/.cursor/rules/mobile-desktop-setting-meta.mdc +34 -0
  114. package/ts-dist/mocks/init-theme/.cursor/rules/naming-convention.mdc +64 -0
  115. package/ts-dist/mocks/init-theme/.cursor/rules/pages.mdc +120 -0
  116. package/ts-dist/mocks/init-theme/.cursor/rules/performance.mdc +51 -0
  117. package/ts-dist/mocks/init-theme/.cursor/rules/qa-section.mdc +134 -0
  118. package/ts-dist/mocks/init-theme/.cursor/rules/redesign-section.mdc +147 -0
  119. package/ts-dist/mocks/init-theme/.cursor/rules/schema-sync.mdc +110 -0
  120. package/ts-dist/mocks/init-theme/.cursor/rules/schema.mdc +360 -0
  121. package/ts-dist/mocks/init-theme/.cursor/rules/share-urls.mdc +68 -0
  122. package/ts-dist/mocks/init-theme/.cursor/skills/browser-verify.md +128 -0
  123. package/ts-dist/mocks/init-theme/.cursor/skills/design-tokens.md +105 -0
  124. package/ts-dist/mocks/init-theme/.cursor/skills/page-json-contract.md +87 -0
  125. package/ts-dist/mocks/init-theme/.cursor/skills/qa-accessibility.md +35 -0
  126. package/ts-dist/mocks/init-theme/.cursor/skills/reference-lookup.md +88 -0
  127. package/ts-dist/mocks/init-theme/.cursor/skills/section-anatomy.md +173 -0
@@ -0,0 +1,307 @@
1
+ ---
2
+ description: Autopilot — scaffold, extract tokens, audit pages, build all sections with design verification, assemble pages, and QA an entire theme from a Figma file
3
+ alwaysApply: false
4
+ ---
5
+
6
+ # /build-theme
7
+
8
+ Full autopilot using **Level 0 → A → B** agent hierarchy (`agent-hierarchy.md`). Level 0 discovers pages; Level A identifies sections and spawns Level B per section; Level B builds from **section Figma node only** with lint + visual verify; Level A assembles page JSON and runs whole-page visual compare.
9
+
10
+ ## Usage
11
+ ```
12
+ /build-theme <theme_name> <figma_file_key> [<root_node_id>]
13
+ ```
14
+
15
+ Provide the Figma file URL or key. The root node is optional — if omitted, the whole canvas is scanned.
16
+
17
+ ---
18
+
19
+ ## Phase 0 — Discover Figma Structure
20
+
21
+ ### 0a. Fetch the root canvas
22
+ Call `get_design_context` on the root node (or canvas) with `clientLanguages: "html,css,liquid"` and `clientFrameworks: "tailwind"`.
23
+
24
+ The response will be a sparse metadata tree. Extract the **top-level sections** — these follow a standard naming convention:
25
+
26
+ | Expected section | Contains |
27
+ |--------------------|-----------------------------------------------------------------|
28
+ | **Guidelines** | Typography (fonts, headings H1–H6, body), Colours, Components |
29
+ | **Website View** | One child frame per page — desktop (≈ 1496px wide) |
30
+ | **Mobile View** | One child frame per page — mobile (≈ 390px wide) |
31
+ | **Theme Settings** | Customizer UI mockups (informational only) |
32
+
33
+ If any of these are missing, log a warning but continue with whatever is available.
34
+
35
+ ### 0b. Build the page map
36
+ From **Website View**, list every direct child frame. Each is a page. Match by name to their **Mobile View** counterpart.
37
+
38
+ Produce a page map:
39
+
40
+ ```
41
+ PAGE MAP
42
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
43
+ Page Name | Desktop Node | Mobile Node | Page JSON
44
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
45
+ Home Page | 2613:146 | 2375:4029 | index.json
46
+ Product Detail Page | 2321:4829 | 2560:1012 | product.json
47
+ Blog Page | 2344:5667 | 2568:1434 | blog.json
48
+ Collection Page | 2375:2752 | 2568:2220 | collection.json
49
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
50
+ ```
51
+
52
+ Map page names to standard page JSON filenames (`index.json`, `product.json`, `blog.json`, `collection.json`, etc.).
53
+
54
+ ---
55
+
56
+ ## Phase 1 — Scaffold Theme
57
+
58
+ Run the `/create-theme` logic:
59
+
60
+ 1. Validate the target theme folder does not already exist (or confirm overwrite).
61
+ 2. Use this theme's current files as the template — do not look outside this directory for other themes.
62
+ 3. Create the full folder structure (assets, i18n, layouts, sections, snippets, pages, settings, etc.).
63
+ 4. Copy snippets, layouts, settings, and config files from this theme's existing files.
64
+ 5. Update `package.json` and `project.json` name fields.
65
+
66
+ If the theme folder already exists, ask the user whether to continue with the existing folder or abort.
67
+
68
+ ---
69
+
70
+ ## Phase 2 — Extract Global Styles from Guidelines
71
+
72
+ ### 2a. Fetch the Guidelines section
73
+ Call `get_design_context` on the **Guidelines** section node. This frame contains:
74
+
75
+ - **Typography** — Heading font family, Body font family, H1–H6 sizes/line-heights, Body text specs.
76
+ - **Colour** — Primary, Secondary, Neutral, Error, Success, Warning, Link, Background 1, Background 2, Border.
77
+ - **Component specs** — Tooltip, Breadcrumb, Badge, Buttons (padding, font, border-radius).
78
+
79
+ ### 2b. Extract tokens — EXACT VALUES ONLY
80
+ From the Guidelines frame, extract all design token values as exact px/hex numbers.
81
+ Cross-reference with `figma-variables.json` if it exists.
82
+ Follow the Design Spec Extraction Protocol in `.cursor/rules/design-spec-extraction.mdc`.
83
+
84
+ Build a **token summary** with exact values:
85
+
86
+ ```
87
+ GLOBAL TOKENS EXTRACTED
88
+ ━━━━━━━━━━━━━━━━━━━━━━━
89
+ TYPOGRAPHY
90
+ Heading font: [font name] [weight]
91
+ Body font: [font name] [weight]
92
+ H1: [size]px / [line-height]px → text-[size] / leading-[lh]
93
+ H2: [size]px / [line-height]px → text-[size] / leading-[lh]
94
+ H3: [size]px / [line-height]px → text-[size] / leading-[lh]
95
+ H4: [size]px / [line-height]px → text-[size] / leading-[lh]
96
+ H5: [size]px / [line-height]px → text-[size] / leading-[lh]
97
+ H6: [size]px / [line-height]px → text-[size] / leading-[lh]
98
+ Body: [size]px / [line-height]px → text-[size] / leading-[lh]
99
+ Small: [size]px / [line-height]px → text-[size] / leading-[lh]
100
+
101
+ COLOURS
102
+ Primary: [hex] → var(--color-primary)
103
+ On-Primary: [hex] → var(--color-on-primary)
104
+ Secondary: [hex]
105
+ Neutral: [hex]
106
+ Error: [hex]
107
+ Success: [hex]
108
+ Warning: [hex]
109
+ Link: [hex]
110
+ Heading: [hex] → var(--color-heading)
111
+ Body text: [hex]
112
+ Background 1: [hex] → var(--color-background)
113
+ Background 2: [hex]
114
+ Border: [hex] → var(--color-border)
115
+
116
+ COMPONENTS
117
+ Button padding: [top]px [right]px [bottom]px [left]px → py-[n] px-[n]
118
+ Button radius: [value]px → rounded-[class]
119
+ Button font: [size]px [weight] → text-[class] font-[class]
120
+ Badge padding: [value]px → p-[n]
121
+ Badge radius: [value]px → rounded-[class]
122
+ ```
123
+
124
+ ### 2c. Populate theme settings
125
+ Using the extracted tokens, update:
126
+
127
+ - `settings/schema.json` — ensure all colour, typography, and component settings have correct defaults matching the Figma guidelines.
128
+ - `settings/theme.json` — fill the Default preset with the extracted token values.
129
+ - `i18n/en.schema.json` — ensure all translation keys for settings exist.
130
+
131
+ Verify by running `/validate-theme-settings` logic internally (do not output a separate report — just fix any mismatches).
132
+
133
+ ### 2d. Save Global Token Reference
134
+ Save the token summary to `.design-tokens-summary.md` for reference during section builds. This file ensures every section build has access to the global typography and colour decisions.
135
+
136
+ ---
137
+
138
+ ## Phase 3 — Developer approval (Level 0)
139
+
140
+ Present the page map from Phase 0. Ask:
141
+
142
+ ```
143
+ Does this page map look correct?
144
+ - Reply YES to start Stage 1 (Level A agents)
145
+ - Reply EDIT to adjust page names or node IDs
146
+ ```
147
+
148
+ **Wait for approval.** Level 0 does not build sections.
149
+
150
+ ---
151
+
152
+ ## Phase 4 — Stage 1: Level A → Level B (see `parallel-fanout.md`)
153
+
154
+ **Architecture:** `.claude/skills/theme-from-figma/agent-hierarchy.md`
155
+
156
+ ### 4a. Index Level A (serial)
157
+ Spawn one **Level A** for `index`. It:
158
+ 1. Calls `get_design_context` on the **page frame** (desktop + mobile)
159
+ 2. Writes `sections.plan.md` with Figma node ID per section
160
+ 3. Spawns **Level B** per section in parallel (header, footer, hero, …)
161
+ 4. Waits for all Level B PASS
162
+ 5. Assembles `pages/index.json`
163
+ 6. Whole-page visual verify vs Figma home frame
164
+ 7. Writes `header-footer-ready` marker
165
+
166
+ ### 4b. Four parallel Level A agents
167
+ After marker, spawn Level A for `listing`, `product`, `blog_list`, `blog_detail`.
168
+
169
+ Each Level A follows `page-orchestrator.md`. Each Level B follows `section-builder.md`.
170
+
171
+ ### Level B per-section gates (mandatory)
172
+ 1. `get_design_context` on **section node ID only** — NOT parent page (`figma-extraction.md`)
173
+ 2. `figma-spec.json` with every visual value (`transcription-rules.md`)
174
+ 3. `lint-section.mjs` PASS
175
+ 4. Chrome DevTools visual vs Figma **section crop** — `visual-diff.md` 0 CRITICAL
176
+
177
+ ### Anti-hallucination (fixes border-radius, colors, card heights)
178
+ - No `rounded-*` unless spec `border_radius > 0`
179
+ - Colors from spec → token map only
180
+ - Product grids: fixed media box `w`×`h` + `object-fit`
181
+ - Heading blocks / title fields → `text` only; body/description → `richtext`
182
+
183
+ ### Progress tracking
184
+ Each Level B writes to scratchpad:
185
+
186
+ ```
187
+ pages/<page>/sections/<section>/
188
+ figma-spec.json
189
+ visual-diff.md
190
+ report.md
191
+ ```
192
+
193
+ Each Level A writes:
194
+
195
+ ```
196
+ pages/<page>/
197
+ sections.plan.md
198
+ report.md
199
+ ```
200
+
201
+ ---
202
+
203
+ ## Phase 5 — Stage 2: Consolidation
204
+
205
+ 1. Run `verify-theme.mjs <theme_name>`
206
+ 2. Run `record-build-metrics.mjs`
207
+ 3. Cross-page token consistency check
208
+ 4. Collect all Level A/B `report.md` + `visual-diff.md` files
209
+
210
+ Page JSON assembly happens inside each Level A — not in a separate phase.
211
+
212
+ ---
213
+
214
+ ## Phase 6 — QA summary
215
+
216
+ Aggregate from Level B reports:
217
+ - Sections with 0 CRITICAL visual diff
218
+ - Sections NEEDS_REVIEW
219
+ - Lint failures
220
+ - Unmapped colors (`unmapped-colors.md`)
221
+
222
+ Auto-fix only cross-cutting i18n gaps. Section visual issues → re-spawn Level B for that section.
223
+
224
+ ---
225
+
226
+ ## Phase 7 — Design accuracy summary
227
+
228
+ ```
229
+ DESIGN ACCURACY SUMMARY
230
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
231
+ Sections built: <n>
232
+ Level B PASS (0 CRITICAL): <n>
233
+ Level B NEEDS_REVIEW: <n>
234
+ Whole-page Level A PASS: <n>/<total pages>
235
+
236
+ COMMON FAILURE PATTERNS (should be 0 with transcription-rules.md):
237
+ rounded-* without Figma radius: <n>
238
+ unmapped colors: <n>
239
+ product grids without fixed media box: <n>
240
+ ```
241
+
242
+ ---
243
+
244
+ ## Output — Final Report
245
+
246
+ ```
247
+ BUILD THEME — <theme_name>
248
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
249
+
250
+ SOURCE: Figma file <figma_file_key>
251
+
252
+ GLOBAL TOKENS
253
+ Heading font: [name] | Body font: [name]
254
+ Primary: [hex] | Secondary: [hex] | Neutral: [hex]
255
+ ...
256
+
257
+ PAGES BUILT
258
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━
259
+ Page | Sections | Status
260
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━
261
+ Home (index.json) | 8 | ✅ complete
262
+ Product (product) | 5 | ✅ complete
263
+ Blog (blog) | 4 | ✅ complete
264
+ Collection | 3 | ✅ complete
265
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━
266
+
267
+ SECTIONS BUILT
268
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
269
+ # | Section | Status | Spec Match | Reference
270
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
271
+ 1 | header | SKIPPED | — | shared snippet
272
+ 2 | hero-banner | BUILT | 100% | sections/hero-banner.liquid
273
+ 3 | product-carousel | BUILT | 97% | sections/product-carousel.liquid
274
+ 4 | ... | ... | ... | ...
275
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
276
+ Built: <n> | Skipped: <n> | Failed: <n>
277
+
278
+ DESIGN ACCURACY: <overall_percentage>% spec match
279
+
280
+ QA SUMMARY
281
+ Sections: <n> clean | <n> with warnings
282
+ Settings: ✅ / ⚠️
283
+ Layouts: ✅ / ⚠️
284
+ Pages: ✅ / ⚠️
285
+ i18n: ✅ / ⚠️
286
+
287
+ ⚠️ ITEMS REQUIRING DEVELOPER ATTENTION:
288
+ 1. [severity] [file]: [description]
289
+ 2. ...
290
+
291
+ NEXT STEPS:
292
+ 1. Review unresolved items above
293
+ 2. /compare-section <theme_name> <section> — only if unresolved items exist
294
+ 3. /qa-theme <theme_name> — full QA after any manual fixes
295
+ 4. npx @zohofinance/commerce theme dev --storeUrl=<your store url> — preview in browser (live store data; omit `--storeUrl` for mock only)
296
+ ```
297
+
298
+ ---
299
+
300
+ ## Notes
301
+
302
+ - This command now includes integrated design verification. The self-compare step in each section build eliminates most issues that previously required separate compare→fix iterations.
303
+ - Figma MCP has context limits per frame. If a page frame is too large, this command automatically splits it into individual section frames and fetches them separately.
304
+ - The only required pause point is Phase 3 (audit plan approval). All other phases run continuously.
305
+ - If `figma-variables.json` is missing, the command still runs but logs warnings for every unresolved token. Add the file later and re-run `/sync-theme-settings`.
306
+ - Section groups, page JSON, and i18n are all generated — the developer does not need to create any JSON files manually.
307
+ - The `.design-tokens-summary.md` file is an internal reference — it can be deleted after the theme is complete.
@@ -0,0 +1,358 @@
1
+ ---
2
+
3
+ description: Compare a built section against its Figma design and report all mismatches by severity
4
+ alwaysApply: false
5
+ ---
6
+
7
+
8
+ # /compare-section
9
+
10
+ Compare a built section file against its Figma design source.
11
+ Produces a structured mismatch report grouped by severity.
12
+ Does NOT fix anything — approval required before any changes.
13
+ Always run /qa-section first, then /compare-section, then /fix-section.
14
+
15
+ This command uses the same Design Spec Extraction Protocol as /build-section,
16
+ ensuring consistency between what was built and what is verified.
17
+
18
+ ## Usage
19
+ ```
20
+ /compare-section <theme_name> <section_name> [figma_node_id]
21
+ /compare-section <theme_name> <section_name> --visual [--page <page_name>] [--store-url <url>]
22
+ ```
23
+
24
+ `figma_node_id` is optional. If not provided, Claude will look it up automatically.
25
+
26
+ ### Flags
27
+
28
+ | Flag | Description |
29
+ |------|-------------|
30
+ | `--visual` | Enables visual browser comparison mode. Launches/connects to the dev server, captures browser screenshots of the rendered section, fetches Figma screenshots, and produces a side-by-side visual diff report. |
31
+ | `--page <name>` | Page where the section appears (default: `index`). Used with `--visual` to navigate to the correct page. |
32
+ | `--store-url <url>` | Dev server store URL (default: `<your store url>`). |
33
+
34
+ ### Modes
35
+
36
+ **Default mode (code compare):** Extracts values from code and Figma MCP data, compares numerically. Fast and precise for CSS/Tailwind property matching.
37
+
38
+ **Visual mode (`--visual`):** Launches the `visual-compare` subagent (see `.cursor/agents/visual-compare.md`). This mode:
39
+ 1. Ensures the dev server is running (`npx @zohofinance/commerce theme dev --storeUrl=<your store url>` — from `--store-url` / `dev-config.json`; without `--storeUrl`, preview uses mock data only)
40
+ 2. Uses Claude in Chrome to navigate to the page and screenshot the rendered section (desktop + mobile)
41
+ 3. Fetches the Figma screenshot via Figma MCP (`get_screenshot`)
42
+ 4. Visually compares both screenshots and reports differences
43
+ 5. Also checks the browser console for JS/Liquid errors
44
+
45
+ **Combined mode (recommended for final QA):** Run both:
46
+ ```
47
+ /compare-section <theme_name> <section_name> → code-level compare
48
+ /compare-section <theme_name> <section_name> --visual → visual compare
49
+ ```
50
+ Code compare catches precise CSS mismatches; visual compare catches rendering bugs, cascade issues, and browser-specific behavior that code compare cannot detect.
51
+
52
+ ---
53
+
54
+ ## Pre-flight — Files to Read Automatically
55
+
56
+ Before comparing, read ALL of these without being asked:
57
+
58
+ 1. `sections/<section_name>.liquid` — the section file
59
+ 2. Every snippet referenced via `{% render 'snippet-name' %}` inside the section
60
+ - Read `snippets/<snippet-name>.liquid` for each
61
+ - Repeat recursively — if a snippet renders another snippet, read that too
62
+ 3. `figma-variables.json` — token values for this theme
63
+ 4. `.cursor/rules/css.mdc` — Figma → Tailwind conversion table
64
+ 5. `.cursor/rules/design-spec-extraction.mdc` — extraction protocol
65
+
66
+ Never ask the developer to paste file contents — read them directly.
67
+
68
+ ---
69
+
70
+ ## Figma Frame — via Cursor Figma MCP
71
+
72
+ Cursor reads the Figma frame from whatever is currently selected in the Figma app
73
+ via the Figma Dev Mode MCP plugin. The developer selects the frame in Figma first,
74
+ then runs this command in Cursor.
75
+
76
+ **Do NOT say "no Figma data available" without first checking MCP context.**
77
+
78
+ The MCP frame data is already in your context if the developer had a frame selected.
79
+ Look for it — it will contain layout, typography, color, and spacing values for the frame.
80
+
81
+ If no Figma MCP context is present in the conversation:
82
+ ```
83
+ ⚠️ No Figma frame data found.
84
+ Please:
85
+ 1. Open your Figma file in the browser
86
+ 2. Click on the <section_name> frame
87
+ 3. Re-run this command in Cursor
88
+ ```
89
+
90
+ Never silently skip the comparison and say "no issues found".
91
+
92
+ ---
93
+
94
+
95
+ ## Stage 1 — Extract Code Values
96
+
97
+ From the section file and its snippets, extract current values for EVERY element:
98
+
99
+ **Typography** (per text element)
100
+ - Tailwind text class (font-size)
101
+ - Font weight class
102
+ - Line height classes if present
103
+ - Letter spacing classes if present
104
+ - Text colour (CSS variable used)
105
+ - Text alignment
106
+
107
+ **Spacing** (per container)
108
+ - Section padding top/bottom (from {% style %} block or range default)
109
+ - Padding inside containers (all four sides)
110
+ - Gap between elements (flex/grid gap classes)
111
+ - Margin between text blocks
112
+
113
+ **Layout** (per container)
114
+ - Grid column count at each breakpoint
115
+ - Flex direction and alignment
116
+ - Element order
117
+ - Max-width container class
118
+
119
+ **Visual** (per element)
120
+ - Border radius classes on each element
121
+ - Border classes (width, colour)
122
+ - Shadow classes
123
+ - Background colour (CSS variable or Tailwind bg class)
124
+
125
+ **Images** (per image)
126
+ - Aspect ratio classes
127
+ - Object-fit classes
128
+ - Width/height constraints
129
+ - Border radius
130
+
131
+ **Buttons / CTAs** (per button)
132
+ - Padding classes (vertical and horizontal)
133
+ - Border radius
134
+ - Font size and weight
135
+ - Background and text colour
136
+ - Border if any
137
+
138
+ **Produce a structured list** matching the Design Spec Table format (element → property → value).
139
+
140
+ ---
141
+
142
+
143
+ ## Stage 2 — Extract Figma Values Using Design Spec Extraction Protocol
144
+
145
+ Follow `.cursor/rules/design-spec-extraction.mdc` EXACTLY:
146
+
147
+ ### 2a. Resolve ALL var() values first
148
+ For every `var(--name, fallback)` in the MCP data:
149
+ - Look up in `figma-variables.json` by path
150
+ - Use `$value` if present, fallback otherwise
151
+ - Never use variable names for comparison
152
+
153
+ ### 2b. Extract per-element design spec
154
+ Extract EXACT resolved values for every visible element — same format as Stage 1.
155
+ Produce the Design Spec Table with columns: Element | Property | Figma Value | Tailwind/CSS.
156
+
157
+ ### 2c. Extract responsive differences
158
+ If mobile frame available, note what differs from desktop.
159
+
160
+ Do NOT compare a variable name like `--font-size-9xl` against a Tailwind class —
161
+ that comparison is meaningless. Only compare resolved px/hex values against code values.
162
+
163
+ ---
164
+
165
+
166
+ ## Stage 3 — Compare and Classify
167
+
168
+ For EVERY property in the Design Spec Table, compare Figma value vs code value.
169
+
170
+ Classify each mismatch:
171
+
172
+ **🔴 CRITICAL**
173
+ Clearly visible to any user. Blocks sign-off.
174
+ - Wrong font size (more than one Tailwind step off)
175
+ - Wrong font weight (bold vs regular)
176
+ - Wrong colour (wrong CSS variable or hardcoded value)
177
+ - Wrong column count
178
+ - Wrong element missing entirely
179
+ - Wrong element order
180
+ - Missing responsive override (desktop layout on mobile)
181
+
182
+ **🟡 MINOR**
183
+ Noticeable on close inspection. Should fix before launch.
184
+ - Spacing off by one Tailwind step (e.g. gap-4 vs gap-6)
185
+ - Border radius one step off (rounded-lg vs rounded-xl)
186
+ - Line height mismatch
187
+ - Letter spacing mismatch
188
+ - Shadow missing or too strong
189
+ - Image aspect ratio off
190
+ - Padding defaults don't match Figma section padding
191
+
192
+ **⚪ SUGGESTION**
193
+ Subtle. Developer judgement call — may be intentional.
194
+ - Spacing off by less than 4px
195
+ - Font weight one step off (medium vs semibold)
196
+ - Colour slightly different due to opacity
197
+ - Responsive behaviour differs from Figma mobile frame
198
+ - Hover state not implemented
199
+
200
+ Do NOT report items that match correctly — only report mismatches.
201
+ If a value was not specified in Figma, do not flag it.
202
+
203
+ ---
204
+
205
+
206
+ ## Stage 4 — Check Responsive
207
+
208
+ If a Figma mobile frame is provided, compare:
209
+ - Column count on mobile vs desktop
210
+ - Font size changes at mobile breakpoint
211
+ - Stacking order of elements
212
+ - Hidden/shown elements per breakpoint
213
+ - Touch target sizes on buttons (minimum 44px)
214
+ - Gap/padding changes at mobile breakpoint
215
+
216
+ ---
217
+
218
+
219
+ ## Output Format
220
+
221
+ ```
222
+ DESIGN COMPARISON — <section_name>.liquid
223
+ vs Figma: <frame name if known>
224
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
225
+
226
+ DESIGN SPEC TABLE (what Figma specifies):
227
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
228
+ # | Element | Property | Figma Value | Expected Tailwind/CSS
229
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
230
+ [full spec table here]
231
+
232
+ MISMATCHES:
233
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
234
+
235
+ 🔴 CRITICAL — <count> issues
236
+ ─────────────────────────────────────────
237
+ 1. <Property>
238
+ Figma: <expected value>
239
+ Code: <actual value> — <file>:<line>
240
+ Fix: <exact change to make>
241
+
242
+ 2. <Property>
243
+ Figma: <expected value>
244
+ Code: <actual value> — <file>:<line>
245
+ Fix: <exact change to make>
246
+
247
+ 🟡 MINOR — <count> issues
248
+ ─────────────────────────────────────────
249
+ 3. <Property>
250
+ Figma: <expected value>
251
+ Code: <actual value> — <file>:<line>
252
+ Fix: <exact change to make>
253
+
254
+ ⚪ SUGGESTIONS — <count> items
255
+ ─────────────────────────────────────────
256
+ 4. <Property>
257
+ Figma: <expected value>
258
+ Code: <actual value>
259
+ Note: May be intentional — confirm with designer
260
+
261
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
262
+ SUMMARY
263
+ Files checked: <section_name>.liquid + <list of snippets>
264
+ Critical: <n> · Minor: <n> · Suggestions: <n>
265
+ Design accuracy: <percentage>% (matched / total spec rows)
266
+
267
+ Which issues should I fix?
268
+ Reply with: ALL / CRITICAL ONLY / numbers (e.g. 1,2,4) / NONE
269
+ ```
270
+
271
+ - If the user said **"Implement this design from Figma"** or **"Apply all"**, treat as **ALL** and apply all reported fixes, then run `/qa-section <theme_name> <section_name>` to verify.
272
+ - Wait for developer approval before making any changes unless the user explicitly asked to apply all.
273
+
274
+ ---
275
+
276
+
277
+ ## Stage 5 — Apply Approved Fixes
278
+
279
+ Once developer specifies which issues to fix:
280
+
281
+ - Apply ONLY the approved fixes
282
+ - For each fix, reference the issue number in a comment:
283
+ `{{-- compare-fix #1: text-4xl → text-5xl to match Figma spec --}}`
284
+ - Do not touch anything not in the approved list
285
+ - Do not refactor, reorganise, or improve other areas
286
+
287
+ After applying:
288
+
289
+ ```
290
+ ✅ FIXES APPLIED
291
+
292
+ Fixed: #<n>, #<n>, #<n>
293
+ Skipped: #<n>, #<n> (not approved)
294
+
295
+ Files changed:
296
+ - sections/<section_name>.liquid
297
+ - snippets/<snippet>.liquid (if applicable)
298
+
299
+ Design accuracy after fix: <percentage>%
300
+
301
+ NEXT: Run /qa-section <theme_name> <section_name> to verify no regressions
302
+ ```
303
+
304
+ ---
305
+
306
+
307
+ ## Visual Mode (`--visual`)
308
+
309
+ When the `--visual` flag is provided, delegate to the **visual-compare** subagent:
310
+
311
+ 1. **Read the agent spec:** `.cursor/agents/visual-compare.md`
312
+ 2. **Pass inputs:**
313
+ - `theme_name`, `section_name` from the command arguments
314
+ - `page_name` from `--page` flag (default: `index`)
315
+ - `store_url` from `--store-url` flag (default: `<your store url>`)
316
+ - Figma frame data (from MCP context or provided URLs)
317
+ 3. **The subagent will:**
318
+ - Check/start the dev server
319
+ - Navigate Claude in Chrome to the rendered page
320
+ - Screenshot the section at desktop (1440px) and mobile (375px) viewports
321
+ - Fetch Figma screenshots via `get_screenshot`
322
+ - Compare visually and produce a categorized diff report
323
+ - Check the browser console for errors
324
+ 4. **Output** follows the visual-compare agent's report format (visual diff with CRITICAL/MINOR/SUGGESTION/MOBILE-SPECIFIC categories)
325
+
326
+ ### Prerequisites for Visual Mode
327
+
328
+ - **Claude in Chrome** must be available (for browser navigation and screenshots)
329
+ - **Figma MCP** must be connected (for `get_screenshot` and `get_design_context`)
330
+ - **Dev server** must be running OR the subagent will attempt to start it
331
+ - The section must already be built and saved to the theme's `sections/` folder
332
+ - The page JSON must reference this section (so it renders on the page)
333
+
334
+ ### When to use Visual Mode
335
+
336
+ - After initial `/compare-section` (code compare) passes but you want visual confirmation
337
+ - When debugging a section that "looks wrong" but code values seem correct
338
+ - For final QA before shipping — visual compare catches CSS cascade issues, z-index problems, overflow clipping, and browser rendering quirks that code compare cannot detect
339
+ - When the Figma design has subtle visual details (gradients, shadows, overlapping elements) that are hard to verify from code alone
340
+
341
+ ---
342
+
343
+
344
+ ## Figma MCP fallback
345
+
346
+ If Figma MCP context is not available, ask: "Figma MCP data not found. You can paste a structured design spec (e.g. spacing, typography, colours, CTA dimensions) and I'll compare against the section code." Then run the same comparison logic using the pasted spec.
347
+
348
+ ---
349
+
350
+
351
+ ## Notes
352
+
353
+ - If Figma input is a screenshot, flag all extracted values with ~ to indicate they are estimates
354
+ - If a value cannot be determined from Figma input, skip that check — do not guess
355
+ - If the same mismatch appears in a shared snippet used by multiple sections, note it once and flag that fixing it affects all sections that use that snippet
356
+ - Never change schema fields or Liquid logic — this command is HTML/CSS only
357
+ - If a mismatch looks intentional (e.g. a responsive adaptation), flag as suggestion with note rather than critical
358
+ - The Design Spec Table in the output gives the developer a complete reference of what Figma specifies, making it easier to review and approve fixes