@thorprovider/storefront 0.3.1 → 0.4.0-mvp.2

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 (263) hide show
  1. package/README.md +321 -152
  2. package/VENDOR.md +69 -0
  3. package/assets/openspec/config.yaml +38 -0
  4. package/assets/templates/AGENTS.md +76 -0
  5. package/assets/templates/app/app/[[...slug]]/page.tsx +54 -2
  6. package/assets/templates/app/app/[[...slug]]/renderer.tsx +13 -2
  7. package/assets/templates/app/app/globals.css +5 -8
  8. package/assets/templates/app/app/layout.tsx +17 -7
  9. package/assets/templates/app/app/robots.ts +19 -0
  10. package/assets/templates/app/app/sitemap.ts +71 -0
  11. package/assets/templates/app/lib/__STOREFRONT__/actions.ts +612 -0
  12. package/assets/templates/app/lib/__STOREFRONT__/cart-state.ts +66 -0
  13. package/assets/templates/app/lib/__STOREFRONT__/catalog.ts +50 -57
  14. package/assets/templates/app/lib/__STOREFRONT__/commerce.ts +679 -0
  15. package/assets/templates/app/lib/__STOREFRONT__/composition.ts +26 -0
  16. package/assets/templates/app/lib/__STOREFRONT__/handlers.core.ts +197 -0
  17. package/assets/templates/app/lib/__STOREFRONT__/handlers.ts +5 -36
  18. package/assets/templates/app/lib/__STOREFRONT__/icon-map.ts +27 -0
  19. package/assets/templates/app/lib/__STOREFRONT__/mappers.ts +13 -11
  20. package/assets/templates/app/lib/__STOREFRONT__/registry.tsx +264 -51
  21. package/assets/templates/app/lib/__STOREFRONT__/runtime.ts +6 -3
  22. package/assets/templates/app/lib/__STOREFRONT__/schema.ts +136 -0
  23. package/assets/templates/app/lib/__STOREFRONT__/section-observation.ts +182 -0
  24. package/assets/templates/app/lib/__STOREFRONT__/section-sources.ts +130 -0
  25. package/assets/templates/app/lib/__STOREFRONT__/session.core.ts +470 -0
  26. package/assets/templates/app/lib/__STOREFRONT__/session.ts +169 -0
  27. package/assets/templates/app/lib/__STOREFRONT__/shell/content.ts +120 -0
  28. package/assets/templates/app/lib/__STOREFRONT__/shell/props.ts +38 -0
  29. package/assets/templates/app/lib/__STOREFRONT__/spec/index.ts +129 -10
  30. package/assets/templates/app/lib/__STOREFRONT__/spec/page-root.ts +5 -1
  31. package/assets/templates/app/lib/__STOREFRONT__/spec/seo.ts +191 -0
  32. package/assets/templates/app/lib/__STOREFRONT__/state.core.ts +257 -0
  33. package/assets/templates/app/lib/__STOREFRONT__/state.ts +7 -31
  34. package/assets/templates/app/lib/__STOREFRONT__/store-context.ts +161 -0
  35. package/assets/templates/app/lib/__STOREFRONT__/views/sections/cta.client.tsx +25 -0
  36. package/assets/templates/app/lib/__STOREFRONT__/views/sections/cta.tsx +16 -0
  37. package/assets/templates/app/lib/__STOREFRONT__/views/sections/faq.client.tsx +24 -0
  38. package/assets/templates/app/lib/__STOREFRONT__/views/sections/faq.tsx +5 -18
  39. package/assets/templates/app/lib/__STOREFRONT__/views/sections/index.ts +18 -0
  40. package/assets/templates/app/lib/__STOREFRONT__/views/sections/logoCloud.tsx +26 -14
  41. package/assets/templates/app/lib/__STOREFRONT__/views/sections/pricing.tsx +36 -18
  42. package/assets/templates/app/lib/__STOREFRONT__/views/sections/products.client.tsx +100 -0
  43. package/assets/templates/app/lib/__STOREFRONT__/views/sections/products.tsx +19 -0
  44. package/assets/templates/app/lib/__STOREFRONT__/views/sections/schema.cta.ts +19 -0
  45. package/assets/templates/app/lib/__STOREFRONT__/views/sections/schema.faq.ts +18 -0
  46. package/assets/templates/app/lib/__STOREFRONT__/views/sections/schema.products.ts +39 -0
  47. package/assets/templates/app/lib/__STOREFRONT__/views/sections/statistics.tsx +35 -14
  48. package/assets/templates/app/lib/__STOREFRONT__/views/sections/testimonials.tsx +31 -13
  49. package/assets/templates/app/lib/__STOREFRONT__/views/types.ts +5 -3
  50. package/assets/templates/features/checkout/handlers.ts +159 -0
  51. package/assets/templates/features/checkout/state.ts +61 -0
  52. package/assets/templates/features/customer-auth/handlers.ts +59 -0
  53. package/assets/templates/features/customer-auth/state.ts +45 -0
  54. package/assets/templates/features/recommendations/state.ts +11 -0
  55. package/assets/templates/views/account/content.ts +35 -0
  56. package/assets/templates/views/account/index.tsx +114 -0
  57. package/assets/templates/views/account/registry.tsx +439 -0
  58. package/assets/templates/views/account/schema.ts +53 -0
  59. package/assets/templates/views/cart/content.ts +11 -0
  60. package/assets/templates/views/cart/data.ts +23 -0
  61. package/assets/templates/views/cart/index.tsx +53 -0
  62. package/assets/templates/views/cart/props.ts +12 -0
  63. package/assets/templates/views/cart/registry.tsx +81 -0
  64. package/assets/templates/views/cart/schema.ts +52 -0
  65. package/assets/templates/views/category/assembly/assembly.json +29 -0
  66. package/assets/templates/views/category/assembly/index.skeleton.tsx +251 -0
  67. package/assets/templates/views/category/assembly/registry.skeleton.tsx +34 -0
  68. package/assets/templates/views/category/assembly/slots/breadcrumb/Breadcrumb/binding.json +5 -0
  69. package/assets/templates/views/category/assembly/slots/breadcrumb/Breadcrumb/catalog.part +4 -0
  70. package/assets/templates/views/category/assembly/slots/breadcrumb/Breadcrumb/element.part +7 -0
  71. package/assets/templates/views/category/assembly/slots/breadcrumb/Breadcrumb/registry.part +18 -0
  72. package/assets/templates/views/category/assembly/slots/filter/CategoryFilter2/catalog.part +5 -0
  73. package/assets/templates/views/category/assembly/slots/filter/CategoryFilter2/element.part +34 -0
  74. package/assets/templates/views/category/assembly/slots/filter/CategoryFilter2/registry.part +71 -0
  75. package/assets/templates/views/category/content.ts +30 -0
  76. package/assets/templates/views/category/data.ts +12 -0
  77. package/assets/templates/views/category/index.tsx +299 -0
  78. package/assets/templates/views/category/props.ts +23 -0
  79. package/assets/templates/views/category/registry.tsx +122 -0
  80. package/assets/templates/views/category/schema.ts +91 -0
  81. package/assets/templates/views/checkout/content.ts +105 -0
  82. package/assets/templates/views/checkout/data.ts +23 -0
  83. package/assets/templates/views/checkout/index.tsx +111 -0
  84. package/assets/templates/views/checkout/props.ts +49 -0
  85. package/assets/templates/views/checkout/registry.tsx +217 -0
  86. package/assets/templates/views/checkout/schema.ts +229 -0
  87. package/assets/templates/views/home/assembly/assembly.json +33 -0
  88. package/assets/templates/views/home/assembly/index.skeleton.tsx +90 -0
  89. package/assets/templates/views/home/assembly/registry.skeleton.tsx +25 -0
  90. package/assets/templates/views/home/assembly/slots/benefits/Feature1/binding.json +5 -0
  91. package/assets/templates/views/home/assembly/slots/benefits/Feature1/catalog.part +4 -0
  92. package/assets/templates/views/home/assembly/slots/benefits/Feature1/element.part +4 -0
  93. package/assets/templates/views/home/assembly/slots/benefits/Feature1/registry.part +11 -0
  94. package/assets/templates/views/home/assembly/slots/benefits/Feature2/binding.json +5 -0
  95. package/assets/templates/views/home/assembly/slots/benefits/Feature2/catalog.part +4 -0
  96. package/assets/templates/views/home/assembly/slots/benefits/Feature2/element.part +4 -0
  97. package/assets/templates/views/home/assembly/slots/benefits/Feature2/registry.part +10 -0
  98. package/assets/templates/views/home/assembly/slots/categories/ProductCategory2/binding.json +5 -0
  99. package/assets/templates/views/home/assembly/slots/categories/ProductCategory2/catalog.part +4 -0
  100. package/assets/templates/views/home/assembly/slots/categories/ProductCategory2/element.part +5 -0
  101. package/assets/templates/views/home/assembly/slots/categories/ProductCategory2/registry.part +16 -0
  102. package/assets/templates/views/home/assembly/slots/hero/StorefrontHero1/binding.json +5 -0
  103. package/assets/templates/views/home/assembly/slots/hero/StorefrontHero1/catalog.part +4 -0
  104. package/assets/templates/views/home/assembly/slots/hero/StorefrontHero1/element.part +5 -0
  105. package/assets/templates/views/home/assembly/slots/hero/StorefrontHero1/registry.part +26 -0
  106. package/assets/templates/views/home/content.ts +70 -0
  107. package/assets/templates/views/home/data.ts +24 -0
  108. package/assets/templates/views/home/index.tsx +57 -85
  109. package/assets/templates/views/home/props.ts +22 -0
  110. package/assets/templates/views/home/registry.tsx +38 -22
  111. package/assets/templates/views/home/schema.ts +93 -0
  112. package/assets/templates/views/product/content.ts +25 -0
  113. package/assets/templates/views/product/data.ts +50 -0
  114. package/assets/templates/views/product/index.tsx +148 -0
  115. package/assets/templates/views/product/props.ts +27 -0
  116. package/assets/templates/views/product/registry.tsx +103 -0
  117. package/assets/templates/views/product/schema.ts +121 -0
  118. package/assets/templates/views/static/content.ts +99 -0
  119. package/assets/templates/views/static/index.tsx +60 -0
  120. package/assets/templates/views/static/registry.tsx +66 -0
  121. package/assets/templates/views/static/schema.ts +45 -0
  122. package/bin/storefront.js +2424 -148
  123. package/examples/merchandising/category-led.json +37 -0
  124. package/examples/merchandising/collection-led.json +37 -0
  125. package/package.json +15 -9
  126. package/recipes/archetypes.json +28 -14
  127. package/recipes/catalog.json +400 -0
  128. package/recipes/catalog.mjs +128 -0
  129. package/recipes/catalog.schema.json +64 -0
  130. package/recipes/feature.schema.json +89 -0
  131. package/recipes/features.json +162 -0
  132. package/recipes/manifest.schema.json +69 -0
  133. package/recipes/operations.schema.json +43 -0
  134. package/recipes/recipe.schema.json +11 -2
  135. package/recipes/recipes.json +76 -19
  136. package/recipes/sections.json +34 -5
  137. package/recipes/validate.mjs +838 -32
  138. package/scripts/candidate.mjs +236 -0
  139. package/scripts/composers.mjs +160 -0
  140. package/scripts/env-file.mjs +86 -0
  141. package/scripts/file-classes.mjs +121 -0
  142. package/scripts/logical-controls.mjs +61 -0
  143. package/scripts/manifest.mjs +298 -0
  144. package/scripts/migrate-english-routes.mjs +276 -0
  145. package/scripts/operation-registry.mjs +256 -0
  146. package/scripts/operations.mjs +720 -0
  147. package/scripts/ownership-conflict.mjs +356 -0
  148. package/scripts/pinning.mjs +573 -0
  149. package/scripts/plan-apply.mjs +987 -0
  150. package/scripts/preflight.mjs +51 -0
  151. package/scripts/reconcile.mjs +549 -0
  152. package/scripts/render-templates.mjs +338 -68
  153. package/scripts/schema-validate.mjs +132 -0
  154. package/scripts/section-compat.mjs +300 -0
  155. package/scripts/section-config.mjs +253 -0
  156. package/scripts/section-operations.mjs +508 -0
  157. package/scripts/starter.mjs +17 -0
  158. package/scripts/sync-assets.mjs +22 -15
  159. package/scripts/theme/color.mjs +185 -0
  160. package/scripts/theme/css-theme.mjs +233 -0
  161. package/scripts/theme/fonts.mjs +123 -0
  162. package/scripts/theme/import-export.mjs +125 -0
  163. package/scripts/theme/preset.mjs +93 -0
  164. package/scripts/theme/theme-plan.mjs +292 -0
  165. package/scripts/theme/tokens.mjs +137 -0
  166. package/scripts/view-assembly.mjs +337 -0
  167. package/scripts/view-selection.mjs +211 -0
  168. package/skills/sf-feature/SKILL.md +80 -0
  169. package/skills/sf-setup/SKILL.md +79 -0
  170. package/skills/sf-theme-gen/SKILL.md +100 -30
  171. package/skills/sf-theme-gen/references/shadcn-theming.md +87 -0
  172. package/skills/{shadcn-theming/references/templates → sf-theme-gen/references}/theme-setup.md +15 -19
  173. package/skills/{shadcn-theming → sf-theme-gen}/references/theming-guide.md +6 -11
  174. package/skills/sf-view-gen/SKILL.md +146 -93
  175. package/skills/sf-view-gen/assets/recipes/archetypes.json +28 -14
  176. package/skills/sf-view-gen/assets/recipes/catalog.json +400 -0
  177. package/skills/sf-view-gen/assets/recipes/catalog.schema.json +64 -0
  178. package/skills/sf-view-gen/assets/recipes/features.json +162 -0
  179. package/skills/sf-view-gen/assets/recipes/recipes.json +76 -19
  180. package/skills/sf-view-gen/assets/recipes/sections.json +34 -5
  181. package/skills/sf-view-gen/assets/templates/views/sections/cta.client.tsx +25 -0
  182. package/skills/sf-view-gen/assets/templates/views/sections/cta.tsx +16 -0
  183. package/skills/sf-view-gen/assets/templates/views/sections/faq.client.tsx +13 -9
  184. package/skills/sf-view-gen/assets/templates/views/sections/faq.tsx +2 -7
  185. package/skills/sf-view-gen/assets/templates/views/sections/logoCloud.client.tsx +12 -8
  186. package/skills/sf-view-gen/assets/templates/views/sections/logoCloud.tsx +2 -7
  187. package/skills/sf-view-gen/assets/templates/views/sections/pricing.client.tsx +14 -10
  188. package/skills/sf-view-gen/assets/templates/views/sections/pricing.tsx +2 -9
  189. package/skills/sf-view-gen/assets/templates/views/sections/products.client.tsx +100 -0
  190. package/skills/sf-view-gen/assets/templates/views/sections/products.tsx +19 -0
  191. package/skills/sf-view-gen/assets/templates/views/sections/schema.cta.ts +19 -0
  192. package/skills/sf-view-gen/assets/templates/views/sections/schema.faq.ts +18 -0
  193. package/skills/sf-view-gen/assets/templates/views/sections/schema.logoCloud.ts +19 -0
  194. package/skills/sf-view-gen/assets/templates/views/sections/schema.pricing.ts +26 -0
  195. package/skills/sf-view-gen/assets/templates/views/sections/schema.products.ts +39 -0
  196. package/skills/sf-view-gen/assets/templates/views/sections/schema.statistics.ts +25 -0
  197. package/skills/sf-view-gen/assets/templates/views/sections/schema.testimonials.ts +23 -0
  198. package/skills/sf-view-gen/assets/templates/views/sections/statistics.client.tsx +16 -8
  199. package/skills/sf-view-gen/assets/templates/views/sections/statistics.tsx +2 -7
  200. package/skills/sf-view-gen/assets/templates/views/sections/testimonials.client.tsx +13 -9
  201. package/skills/sf-view-gen/assets/templates/views/sections/testimonials.tsx +2 -5
  202. package/skills/{json-render-core/SKILL.md → sf-view-gen/references/json-render-core.md} +4 -27
  203. package/skills/{json-render-next/SKILL.md → sf-view-gen/references/json-render-next.md} +5 -8
  204. package/skills/{json-render-react/SKILL.md → sf-view-gen/references/json-render-react.md} +3 -5
  205. package/skills/{json-render-shadcn/SKILL.md → sf-view-gen/references/json-render-shadcn.md} +3 -5
  206. package/skills/sf-view-gen/references/views.md +58 -33
  207. package/skills/sf-view-gen/scripts/catalog.mjs +128 -0
  208. package/skills/sf-view-gen/scripts/schema-validate.mjs +132 -0
  209. package/skills/sf-view-gen/scripts/validate.mjs +838 -32
  210. package/skills/storefront-workflow/SKILL.md +179 -0
  211. package/skills/{storefront-best-practices/reference/design.md → storefront-workflow/references/design-consistency.md} +13 -29
  212. package/CHANGELOG.md +0 -61
  213. package/commands/sf-add-view.md +0 -26
  214. package/commands/sf-theme.md +0 -20
  215. package/commands/sf-view.md +0 -25
  216. package/skills/building-storefronts/SKILL.md +0 -178
  217. package/skills/building-storefronts/references/frontend-integration.md +0 -229
  218. package/skills/json-render-remotion/SKILL.md +0 -111
  219. package/skills/json-render-solid/SKILL.md +0 -204
  220. package/skills/nextjs-shadcn/SKILL.md +0 -367
  221. package/skills/nextjs-shadcn/references/architecture.md +0 -499
  222. package/skills/nextjs-shadcn/references/project-setup.md +0 -162
  223. package/skills/nextjs-shadcn/references/shadcn-platform.md +0 -261
  224. package/skills/nextjs-shadcn/references/sidebar.md +0 -274
  225. package/skills/nextjs-shadcn/references/styling.md +0 -555
  226. package/skills/sf-view-gen/assets/templates/views/category/index.tsx +0 -86
  227. package/skills/sf-view-gen/assets/templates/views/category/registry.tsx +0 -48
  228. package/skills/sf-view-gen/assets/templates/views/checkout/index.tsx +0 -192
  229. package/skills/sf-view-gen/assets/templates/views/checkout/registry.tsx +0 -45
  230. package/skills/sf-view-gen/assets/templates/views/product/index.tsx +0 -122
  231. package/skills/sf-view-gen/assets/templates/views/product/registry.tsx +0 -49
  232. package/skills/sf-view-gen/assets/templates/views/user-panel/index.tsx +0 -168
  233. package/skills/sf-view-gen/assets/templates/views/user-panel/registry.tsx +0 -49
  234. package/skills/shadcn-component-discovery/SKILL.md +0 -273
  235. package/skills/shadcn-component-discovery/references/registries.md +0 -226
  236. package/skills/shadcn-theming/SKILL.md +0 -104
  237. package/skills/storefront-best-practices/SKILL.md +0 -421
  238. package/skills/storefront-best-practices/reference/components/breadcrumbs.md +0 -123
  239. package/skills/storefront-best-practices/reference/components/cart-popup.md +0 -189
  240. package/skills/storefront-best-practices/reference/components/country-selector.md +0 -298
  241. package/skills/storefront-best-practices/reference/components/footer.md +0 -112
  242. package/skills/storefront-best-practices/reference/components/hero.md +0 -241
  243. package/skills/storefront-best-practices/reference/components/megamenu.md +0 -239
  244. package/skills/storefront-best-practices/reference/components/navbar.md +0 -397
  245. package/skills/storefront-best-practices/reference/components/popups.md +0 -221
  246. package/skills/storefront-best-practices/reference/components/product-card.md +0 -125
  247. package/skills/storefront-best-practices/reference/components/product-reviews.md +0 -217
  248. package/skills/storefront-best-practices/reference/components/product-slider.md +0 -174
  249. package/skills/storefront-best-practices/reference/components/search.md +0 -101
  250. package/skills/storefront-best-practices/reference/connecting-to-backend.md +0 -391
  251. package/skills/storefront-best-practices/reference/features/promotions.md +0 -307
  252. package/skills/storefront-best-practices/reference/features/wishlist.md +0 -230
  253. package/skills/storefront-best-practices/reference/layouts/account.md +0 -380
  254. package/skills/storefront-best-practices/reference/layouts/cart.md +0 -316
  255. package/skills/storefront-best-practices/reference/layouts/checkout.md +0 -486
  256. package/skills/storefront-best-practices/reference/layouts/home-page.md +0 -264
  257. package/skills/storefront-best-practices/reference/layouts/order-confirmation.md +0 -231
  258. package/skills/storefront-best-practices/reference/layouts/product-details.md +0 -527
  259. package/skills/storefront-best-practices/reference/layouts/product-listing.md +0 -520
  260. package/skills/storefront-best-practices/reference/layouts/static-pages.md +0 -356
  261. package/skills/storefront-best-practices/reference/medusa.md +0 -307
  262. /package/skills/{storefront-best-practices/reference → storefront-workflow/references}/mobile-responsiveness.md +0 -0
  263. /package/skills/{storefront-best-practices/reference → storefront-workflow/references}/seo.md +0 -0
@@ -0,0 +1,79 @@
1
+ ---
2
+ name: sf-setup
3
+ description: Connect or re-point a Thor Commerce storefront to a Medusa backend — set the backend URL, publishable API key, sales channel id, and region, or preserve the current environment when no key is supplied. Use when the user asks to connect or reconnect the backend, change the region or API key, switch the data source, or "set up" the store's data. Delegates to the `storefront setup` CLI command.
4
+ ---
5
+
6
+ # sf-setup
7
+
8
+ Connect a storefront to a real Medusa backend, or re-point an already-connected
9
+ store. `setup` takes the sales channel id as an explicit input (there is no store API
10
+ that reads the channels bound to a publishable key), derives the region's currency,
11
+ then writes them to `.env.local`. The CLI writes the file; agents never hand-edit it.
12
+
13
+ ## Run it
14
+
15
+ Run from the storefront project root:
16
+
17
+ ```bash
18
+ npx @thorprovider/storefront setup \
19
+ --backend-url http://localhost:9000 \
20
+ --publishable-key <pk_...> \
21
+ --sales-channel-id <sc_...> \
22
+ --region-id <reg_...>
23
+ ```
24
+
25
+ On a terminal with no flags it runs an interactive wizard (backend URL →
26
+ publishable key → sales channel id → region). Pass the flags to run
27
+ non-interactively (CI, scripts).
28
+
29
+ ## Flags
30
+
31
+ | Flag | Meaning |
32
+ | --- | --- |
33
+ | `--backend-url` | Medusa backend base URL. Defaults to `http://localhost:9000`. |
34
+ | `--publishable-key` | Publishable API key (`pk_...`). Required to connect. |
35
+ | `--sales-channel-id` | Sales channel id (`sc_...`) from the Medusa admin (Settings → Sales Channels). Required without a terminal. |
36
+ | `--region-id` | Region id to bind. Required without a terminal; the wizard offers the available regions. |
37
+
38
+ ## No key — the existing environment is preserved
39
+
40
+ With no publishable key, `setup` makes no network calls, **changes no files**, and
41
+ exits 0, so it is safe to run in CI/bootstrap without a key. It does not switch
42
+ the store to `mock`: the existing data source is left exactly as it was (`mock`
43
+ stays `mock`, `medusa` stays `medusa`). A freshly created store is already in
44
+ `mock` mode, so running with no key simply leaves it there.
45
+
46
+ ## What it writes
47
+
48
+ Only the keys `setup` manages are upserted in `.env.local`; everything else (the
49
+ session secret, the site URL, store identity, and any user additions) is
50
+ preserved:
51
+
52
+ - `THOR_DATA_SOURCE=medusa`
53
+ - `MEDUSA_BASE_URL`
54
+ - `MEDUSA_PUBLISHABLE_KEY`
55
+ - `MEDUSA_REGION_ID`
56
+ - `MEDUSA_SALES_CHANNEL_ID` (from the `--sales-channel-id` input)
57
+ - `MEDUSA_CURRENCY_CODE` (derived from `GET /store/regions`)
58
+
59
+ Restart the dev server to pick up the change.
60
+
61
+ ## Failure behavior
62
+
63
+ If the backend is unreachable, the key is rejected, the sales channel id is
64
+ missing, or the region is missing or has no currency, `setup` prints the reason,
65
+ **changes no files**, preserves the existing environment (`mock` stays `mock`,
66
+ `medusa` stays `medusa`), and exits non-zero. The store is placed in `medusa` mode
67
+ only after the backend URL, publishable key, sales channel id, and region are all
68
+ resolved and the region's currency resolves successfully. Relay the message to the
69
+ user and fix the input; do not hand-edit `.env.local`.
70
+
71
+ ## Workflow model
72
+
73
+ Read `../storefront-workflow/SKILL.md` for the four phases and the CLI/agent
74
+ authority.
75
+
76
+ ## Completion criteria
77
+
78
+ - `.env.local` contains the managed keys for the chosen backend and region.
79
+ - The dev server starts and loads data from the connected backend.
@@ -1,61 +1,131 @@
1
1
  ---
2
2
  name: sf-theme-gen
3
- description: Customize a Thor Commerce storefront's OKLCH color tokens (light/dark), typography, and identity/SEO metadata
3
+ description: Customize a Thor Commerce storefront's theme — OKLCH colors, radius, fonts, shadcn presets and imported themes, plus typography and global identity/SEO metadata. Use when the user asks to change the storefront's colors, brand, theme, typography, site name, or SEO metadata.
4
4
  ---
5
5
 
6
6
  # sf-theme-gen
7
7
 
8
- Customize a storefront's theme and identity. This skill ships with everything it needs: it uses the vendored theming skill alongside it. When a choice is not resolved by those files, ask the user.
8
+ Customize a storefront's theme and identity. Prefer the deterministic
9
+ `storefront theme` controls; fall back to hand-editing the two external files only
10
+ within their bounded surface. When a required choice is not determined by the
11
+ references, ask the user.
9
12
 
10
- ## Source of truth
13
+ ## Inputs
11
14
 
12
- The workflow uses only the assets in this skill directory and the vendored `../shadcn-theming/` skill next to it. When a required choice is not determined there, ask the user.
15
+ - The manifest `storefront.config.json` — the theme authority for the **mode**.
16
+ - The two external files `app/globals.css` and `app/layout.tsx` — the current
17
+ visual tokens, fonts, and identity.
18
+ - The user's chosen customization area and value.
13
19
 
14
- ## Inputs (the only target-project facts this skill reads)
20
+ ## Outputs
15
21
 
16
- - the existence of the target project's `package.json`
17
- - the existence of `lib/<name>/`
18
- - the existence of the project's `.opencode/`
19
- - the values returned by the wizard (which area to customize, and its value)
22
+ - Edited `app/globals.css` (tokens, `@theme` bridge, font variables) and/or
23
+ `app/layout.tsx` (font loading, metadata/identity) — produced by
24
+ `storefront theme` when a control exists, or by hand within the bounds below.
25
+ - A summary listing every file edited and every command run.
20
26
 
21
- ## Outputs (what this skill produces)
27
+ ## Scope (bounded external surface)
22
28
 
23
- - generated files: `app/globals.css` and `app/layout.tsx`
24
- - declared setup commands: the dev server and typecheck commands it reports
25
- - a summary listing every file edited and every command run
29
+ | Area | File | Allowed change |
30
+ |---|---|---|
31
+ | Design tokens (OKLCH, light/dark) | `app/globals.css` | token values + foreground pairs, `@theme` bridge, font variable |
32
+ | Typography | `app/layout.tsx` + `globals.css` | load the font with `next/font`, point `--font-sans` at it |
33
+ | Identity / metadata / Open Graph | `app/layout.tsx` | the `metadata` object |
26
34
 
27
- ## Scope
35
+ Everything else in these files is **CLI-managed and must be preserved**: the
36
+ stylesheet import, the provider import and its marker, the theme-mode marker, and
37
+ the block token contract. The CLI appends idempotently; never remove or duplicate
38
+ a marker, and never edit the mode wiring by hand.
28
39
 
29
- | Area | File |
30
- |---|---|
31
- | Design tokens (shadcn) | `app/globals.css` |
32
- | Typography + metadata | `app/layout.tsx` |
40
+ ## CLI controls (preferred path)
33
41
 
34
- ## Vendored skill
35
- Follow `../shadcn-theming/SKILL.md` for OKLCH pair rules and contrast. Paths are relative to this `SKILL.md`.
42
+ Visual values live in `app/globals.css`; the mode lives in the manifest. All
43
+ controls are one command and are validated before any write:
44
+
45
+ ```
46
+ storefront theme --inspect [--json] # read-only: current tokens, names, formats
47
+ storefront theme --mode light|dark|system # site color mode (manifest + wiring)
48
+ storefront theme --brand orange # named brand -> full primary family
49
+ storefront theme --primary '#f97316' # one color (named | #hex | oklch(...))
50
+ storefront theme --accent 'oklch(0.6 0.15 200)'
51
+ storefront theme --radius 0.75rem # base radius (drives the radius scale)
52
+ storefront theme --font-sans google:Inter # loads the font, points --font-sans at it
53
+ storefront theme --set light.primary=#f97316 # scope = light | dark | shared; repeatable
54
+ storefront theme --preset <name|code|url> [--only theme|font|theme,font]
55
+ storefront theme --import ./theme.css|./theme.json|<registry-url>
56
+ storefront theme --export ./brand.theme.json # portable snapshot; never overwrites
57
+ storefront theme ... --dry-run # describe the change, write nothing
58
+ storefront theme ... --json # machine-readable result envelope
59
+ ```
60
+
61
+ `--brand`/`--primary` set the primary family (primary, foreground, hover, soft,
62
+ ring, nav) in both modes. Explicit `--set` values win over shortcuts; later
63
+ arguments win over earlier ones. A `--preset` applies **theme and fonts only** —
64
+ it never reinstalls or restyles components.
65
+
66
+ ## Free theme workflow (generator → CLI)
67
+
68
+ 1. Design the palette in a free editor and export its CSS: the official builder
69
+ at `ui.shadcn.com/create` (preset code/URL) or a CSS export from tweakcn /
70
+ Shadcn Studio. These are authoring tools; the CLI is the writer.
71
+ 2. Apply it: `storefront theme --preset <code>` for a preset, or
72
+ `storefront theme --import ./exported.css` for a CSS export (only theme tokens
73
+ and font variables are merged; unrelated CSS is ignored).
74
+ 3. Fine-tune: `--brand`, `--primary`, `--accent`, `--radius`, `--set`, `--font-*`.
75
+ 4. `storefront theme --export ./brand.theme.json` to keep a portable snapshot;
76
+ replay it elsewhere with `--import ./brand.theme.json`.
36
77
 
37
78
  ## Color rules
79
+
38
80
  - Colors are CSS variables, never raw Tailwind color utilities.
39
81
  - OKLCH only; define complete background/foreground pairs.
40
- - Lightness rule: bg `L < 0.55` → fg `L >= 0.93`; bg `L >= 0.55` → fg `L <= 0.20`.
41
- - Named accents can use `accentColorToOklch(name)` from `@thorprovider/runtime/render-core/theme`.
82
+ - The CLI pairs a changed color with its foreground using **measured contrast**
83
+ (WCAG relative luminance), not a lightness threshold; auto-selected foregrounds
84
+ meet >= 4.5:1. A contrast below 4.5:1 is reported as a warning but never
85
+ silently changes an explicit pair — use `--set light.primary-foreground=#fff`
86
+ to force a specific pairing.
87
+ - Accepts `<name>` (see `storefront theme --inspect`), `#hex`, `oklch(...)`.
42
88
 
43
89
  ## Workflow
44
90
 
45
- 1. Use the `question` tool to ask what to customize: colors, typography, identity, SEO, Open Graph.
46
- 2. **Colors**: follow `../shadcn-theming/SKILL.md`; update BOTH `:root` (light) and `.dark` blocks in `app/globals.css`, keeping the `@theme inline` mapping intact.
47
- 3. **Pairs**: every changed color gets its foreground pair in both modes; verify the lightness rule.
48
- 4. **Typography**: load the font with `next/font` in `app/layout.tsx`; point `--font-sans` in `globals.css` at the new variable; keep body >= 1rem / line-height 1.5.
49
- 5. **Identity**: update the `metadata` object in `app/layout.tsx` (title, description) and add Open Graph + Twitter Card fields. Research the current Next.js Metadata API before writing.
50
- 6. **Verify**: run the dev server; confirm both color modes, font, and head metadata. `yarn typecheck` passes.
91
+ 1. Ask what to customize: colors/brand, radius, typography, identity, SEO, Open Graph.
92
+ 2. **Mode** is deterministic: `storefront theme --mode light|dark|system`; never
93
+ edit the mode wiring by hand. There is no visitor-facing toggle by design.
94
+ 3. **Colors**: prefer `storefront theme --brand/--primary/--accent` or `--set`.
95
+ For a full palette, import a generator export (see above). Hand-edit only a
96
+ value the CLI cannot express, updating BOTH `:root` and `.dark`.
97
+ 4. **Pairs**: a color change gets its foreground pair; the CLI does this and
98
+ warns on low contrast.
99
+ 5. **Typography**: `storefront theme --font-sans google:Inter` loads the font with
100
+ `next/font` and points `--font-sans` at it. Use `system:<stack>` for a CSS
101
+ stack. Existing local fonts are preserved unless explicitly replaced. A font
102
+ name alone is not proof it loads — verify rendering.
103
+ 6. **Identity**: update the `metadata` object in `app/layout.tsx` (title,
104
+ description) and add Open Graph + Twitter Card fields. Confirm the current
105
+ Next.js Metadata API before writing.
106
+ 7. **Verify**: `storefront theme --dry-run` first, then apply; run the dev server
107
+ and confirm both color modes, the font, and the head metadata. `yarn build` is
108
+ the final acceptance. A `sync` must leave the CLI-managed markers intact and
109
+ the theme unchanged.
110
+
111
+ ## Limits
112
+
113
+ - A preset changes theme tokens and font wiring only; it cannot redesign
114
+ package-owned `@thorprovider/blocks` beyond their tokens.
115
+ - `--export` is read-only over the project and refuses to overwrite a file.
116
+ - Invalid input (unknown color/token/length/font, unsupported import) fails with
117
+ a diagnostic and writes nothing.
51
118
 
52
119
  ## Error handling
120
+
53
121
  - Invalid color input → re-prompt (accept `<name>`, `#hex`, `oklch(...)`).
54
- - No `lib/<name>/` → run `npx @thorprovider/storefront create`, stop.
55
- - Unknown token key → check `themeTokenKeys` in `@thorprovider/runtime/contracts` first.
122
+ - Unknown token key → run `storefront theme --inspect` (lists supported tokens).
123
+ - Mode change → always via `storefront theme --mode ...`; never edit by hand.
56
124
 
57
125
  ## Generation headers
126
+
58
127
  ```
59
128
  // Themed by @thorprovider/storefront (sf-theme-gen)
60
129
  ```
130
+
61
131
  Never remove existing tokens; only override values.
@@ -0,0 +1,87 @@
1
+ # shadcn theming reference
2
+
3
+ Reference material for the `sf-theme-gen` skill. It documents shadcn/ui design
4
+ tokens, OKLCH color rules, dark/light mode CSS variables, and the Tailwind v4
5
+ `@theme` bridge for the two external files `app/globals.css` and
6
+ `app/layout.tsx`.
7
+
8
+ ## Overview
9
+
10
+ | Feature | Description |
11
+ |---------|-------------|
12
+ | **CSS Variables** | `--background`, `--foreground`, `--primary`, etc. |
13
+ | **OKLCH Colors** | Wide-gamut P3 color space, perceptually uniform |
14
+ | **Dark Mode** | `.dark` class or `prefers-color-scheme` |
15
+ | **Tailwind v4** | `@theme` directive integration |
16
+
17
+ ## Critical rules
18
+
19
+ 1. **ALWAYS use OKLCH** color space for all tokens.
20
+ 2. **ALWAYS define dark mode** overrides for every token.
21
+ 3. **NEVER hard-code** hex or rgb in components.
22
+ 4. **USE the `@theme`** directive for Tailwind v4 integration.
23
+ 5. **MAP semantic tokens** to primitive OKLCH values.
24
+
25
+ ## Lightness rule (contrast)
26
+
27
+ Apply it to every custom pair (`--secondary`, `--accent`, `--destructive`, `--muted`):
28
+
29
+ - Background `L < 0.55` → foreground `L >= 0.93`.
30
+ - Background `L >= 0.55` → foreground `L <= 0.20`.
31
+
32
+ ## Token hierarchy
33
+
34
+ ```
35
+ Component: --card, --card-foreground, --button-*
36
+ ↑
37
+ Semantic: --primary, --secondary, --accent, --muted
38
+ ↑
39
+ Primitive: oklch(55% 0.20 260), oklch(98% 0.01 260)
40
+ ```
41
+
42
+ ## File scope
43
+
44
+ Only these two external files are touched, and only for tokens, fonts, and
45
+ identity. The CLI-managed imports and markers inside them must survive.
46
+
47
+ ```
48
+ app/globals.css # :root + .dark token definitions, @theme bridge
49
+ app/layout.tsx # font wiring (next/font) + metadata/identity
50
+ ```
51
+
52
+ The theme mode (`light` / `dark` / `system`) is a CLI operation
53
+ (`storefront theme --mode ...`); do not hand-edit the `ThemeProvider` wiring in
54
+ `app/layout.tsx`.
55
+
56
+ ## Validation checklist
57
+
58
+ ```
59
+ [ ] CSS variables defined in :root
60
+ [ ] Dark mode overrides in .dark
61
+ [ ] OKLCH color space used
62
+ [ ] Chart variables (--chart-1 to --chart-5) if used
63
+ [ ] Sidebar variables if applicable
64
+ [ ] No hard-coded hex in components
65
+ [ ] @theme bridge maps each semantic token
66
+ ```
67
+
68
+ ## Best practices
69
+
70
+ ### DO
71
+ - Use OKLCH for all colors.
72
+ - Define semantic tokens mapped to primitives.
73
+ - Provide dark mode overrides for all tokens.
74
+ - Use `@theme` for Tailwind v4 integration.
75
+
76
+ ### DON'T
77
+ - Hard-code hex or rgb values.
78
+ - Skip dark mode definitions.
79
+ - Mix color spaces (hex + oklch).
80
+ - Define tokens only in a Tailwind config.
81
+
82
+ ## Reference guide
83
+
84
+ | Topic | Reference | When to consult |
85
+ |-------|-----------|-----------------|
86
+ | Theming guide | [theming-guide.md](theming-guide.md) | CSS variables and OKLCH setup |
87
+ | Complete theme template | [theme-setup.md](theme-setup.md) | Light + dark token definitions and `@theme` bridge |
@@ -1,11 +1,8 @@
1
- ---
2
- name: theme-setup
3
- description: Complete shadcn/ui theme with CSS variables, dark mode, and Tailwind v4 integration
4
- keywords: theme, setup, css, oklch, dark-mode, tailwind
5
- ---
6
-
7
1
  # Theme Setup
8
2
 
3
+ Reference material for the `sf-theme-gen` skill: the complete light + dark theme
4
+ with CSS variables, dark mode, and Tailwind v4 integration.
5
+
9
6
  ## Complete Light + Dark Theme
10
7
 
11
8
  ```css
@@ -92,18 +89,17 @@ keywords: theme, setup, css, oklch, dark-mode, tailwind
92
89
  }
93
90
  ```
94
91
 
95
- ## Theme Switching (React)
92
+ ## Theme switching
96
93
 
97
- ```tsx
98
- // components/theme-provider.tsx
99
- "use client"
100
- import { ThemeProvider as NextThemesProvider } from "next-themes"
94
+ The light/dark/system mode is a CLI operation, not a hand edit. Run
95
+ `npx @thorprovider/storefront theme --mode light|dark|system`: it rewrites the
96
+ `ThemeProvider` wiring in `app/layout.tsx` idempotently. Do **not** add your own
97
+ provider or toggle; the mode is a site setting and the CLI-managed import and
98
+ marker must survive. This template covers the `:root` / `.dark` token blocks and
99
+ the `@theme` bridge only.
101
100
 
102
- export function ThemeProvider({ children }: { children: React.ReactNode }) {
103
- return (
104
- <NextThemesProvider attribute="class" defaultTheme="system" enableSystem>
105
- {children}
106
- </NextThemesProvider>
107
- )
108
- }
109
- ```
101
+ ## Marker preservation
102
+
103
+ `app/globals.css` and `app/layout.tsx` are `external` files: keep the CLI-managed
104
+ provider/mode/style imports and block-token markers intact. Change only token
105
+ values, font wiring, and global identity/metadata.
@@ -1,14 +1,9 @@
1
- ---
2
- name: theming-guide
3
- description: CSS variables, OKLCH colors, chart/sidebar tokens, and Tailwind integration
4
- when-to-use: When configuring theme tokens or color system
5
- keywords: theme, oklch, css-variables, dark-mode, tailwind, tokens, colors
6
- priority: high
7
- related: ../SKILL.md
8
- ---
9
-
10
1
  # Theming Guide
11
2
 
3
+ Reference material for the `sf-theme-gen` skill: CSS variables, OKLCH colors,
4
+ chart/sidebar tokens, and the Tailwind v4 integration used by the external
5
+ `app/globals.css`.
6
+
12
7
  ## Overview
13
8
 
14
9
  shadcn/ui uses CSS custom properties with OKLCH color space for wide-gamut P3 support and perceptual uniformity. Tokens follow a 3-level hierarchy: primitive -> semantic -> component.
@@ -71,7 +66,7 @@ Use `.dark` class on `<html>` or CSS media query:
71
66
  <html className={theme === "dark" ? "dark" : ""}>
72
67
  ```
73
68
 
74
- For full setup with next-themes, see [theme-setup.md](templates/theme-setup.md).
69
+ For the full token template, see [theme-setup.md](theme-setup.md).
75
70
 
76
71
  ---
77
72
 
@@ -87,4 +82,4 @@ For full setup with next-themes, see [theme-setup.md](templates/theme-setup.md).
87
82
 
88
83
  ## Related Templates
89
84
 
90
- - [theme-setup.md](templates/theme-setup.md) - Complete theme configuration
85
+ - [theme-setup.md](theme-setup.md) - Complete theme configuration