@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.
- package/README.md +321 -152
- package/VENDOR.md +69 -0
- package/assets/openspec/config.yaml +38 -0
- package/assets/templates/AGENTS.md +76 -0
- package/assets/templates/app/app/[[...slug]]/page.tsx +54 -2
- package/assets/templates/app/app/[[...slug]]/renderer.tsx +13 -2
- package/assets/templates/app/app/globals.css +5 -8
- package/assets/templates/app/app/layout.tsx +17 -7
- package/assets/templates/app/app/robots.ts +19 -0
- package/assets/templates/app/app/sitemap.ts +71 -0
- package/assets/templates/app/lib/__STOREFRONT__/actions.ts +612 -0
- package/assets/templates/app/lib/__STOREFRONT__/cart-state.ts +66 -0
- package/assets/templates/app/lib/__STOREFRONT__/catalog.ts +50 -57
- package/assets/templates/app/lib/__STOREFRONT__/commerce.ts +679 -0
- package/assets/templates/app/lib/__STOREFRONT__/composition.ts +26 -0
- package/assets/templates/app/lib/__STOREFRONT__/handlers.core.ts +197 -0
- package/assets/templates/app/lib/__STOREFRONT__/handlers.ts +5 -36
- package/assets/templates/app/lib/__STOREFRONT__/icon-map.ts +27 -0
- package/assets/templates/app/lib/__STOREFRONT__/mappers.ts +13 -11
- package/assets/templates/app/lib/__STOREFRONT__/registry.tsx +264 -51
- package/assets/templates/app/lib/__STOREFRONT__/runtime.ts +6 -3
- package/assets/templates/app/lib/__STOREFRONT__/schema.ts +136 -0
- package/assets/templates/app/lib/__STOREFRONT__/section-observation.ts +182 -0
- package/assets/templates/app/lib/__STOREFRONT__/section-sources.ts +130 -0
- package/assets/templates/app/lib/__STOREFRONT__/session.core.ts +470 -0
- package/assets/templates/app/lib/__STOREFRONT__/session.ts +169 -0
- package/assets/templates/app/lib/__STOREFRONT__/shell/content.ts +120 -0
- package/assets/templates/app/lib/__STOREFRONT__/shell/props.ts +38 -0
- package/assets/templates/app/lib/__STOREFRONT__/spec/index.ts +129 -10
- package/assets/templates/app/lib/__STOREFRONT__/spec/page-root.ts +5 -1
- package/assets/templates/app/lib/__STOREFRONT__/spec/seo.ts +191 -0
- package/assets/templates/app/lib/__STOREFRONT__/state.core.ts +257 -0
- package/assets/templates/app/lib/__STOREFRONT__/state.ts +7 -31
- package/assets/templates/app/lib/__STOREFRONT__/store-context.ts +161 -0
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/cta.client.tsx +25 -0
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/cta.tsx +16 -0
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/faq.client.tsx +24 -0
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/faq.tsx +5 -18
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/index.ts +18 -0
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/logoCloud.tsx +26 -14
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/pricing.tsx +36 -18
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/products.client.tsx +100 -0
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/products.tsx +19 -0
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/schema.cta.ts +19 -0
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/schema.faq.ts +18 -0
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/schema.products.ts +39 -0
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/statistics.tsx +35 -14
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/testimonials.tsx +31 -13
- package/assets/templates/app/lib/__STOREFRONT__/views/types.ts +5 -3
- package/assets/templates/features/checkout/handlers.ts +159 -0
- package/assets/templates/features/checkout/state.ts +61 -0
- package/assets/templates/features/customer-auth/handlers.ts +59 -0
- package/assets/templates/features/customer-auth/state.ts +45 -0
- package/assets/templates/features/recommendations/state.ts +11 -0
- package/assets/templates/views/account/content.ts +35 -0
- package/assets/templates/views/account/index.tsx +114 -0
- package/assets/templates/views/account/registry.tsx +439 -0
- package/assets/templates/views/account/schema.ts +53 -0
- package/assets/templates/views/cart/content.ts +11 -0
- package/assets/templates/views/cart/data.ts +23 -0
- package/assets/templates/views/cart/index.tsx +53 -0
- package/assets/templates/views/cart/props.ts +12 -0
- package/assets/templates/views/cart/registry.tsx +81 -0
- package/assets/templates/views/cart/schema.ts +52 -0
- package/assets/templates/views/category/assembly/assembly.json +29 -0
- package/assets/templates/views/category/assembly/index.skeleton.tsx +251 -0
- package/assets/templates/views/category/assembly/registry.skeleton.tsx +34 -0
- package/assets/templates/views/category/assembly/slots/breadcrumb/Breadcrumb/binding.json +5 -0
- package/assets/templates/views/category/assembly/slots/breadcrumb/Breadcrumb/catalog.part +4 -0
- package/assets/templates/views/category/assembly/slots/breadcrumb/Breadcrumb/element.part +7 -0
- package/assets/templates/views/category/assembly/slots/breadcrumb/Breadcrumb/registry.part +18 -0
- package/assets/templates/views/category/assembly/slots/filter/CategoryFilter2/catalog.part +5 -0
- package/assets/templates/views/category/assembly/slots/filter/CategoryFilter2/element.part +34 -0
- package/assets/templates/views/category/assembly/slots/filter/CategoryFilter2/registry.part +71 -0
- package/assets/templates/views/category/content.ts +30 -0
- package/assets/templates/views/category/data.ts +12 -0
- package/assets/templates/views/category/index.tsx +299 -0
- package/assets/templates/views/category/props.ts +23 -0
- package/assets/templates/views/category/registry.tsx +122 -0
- package/assets/templates/views/category/schema.ts +91 -0
- package/assets/templates/views/checkout/content.ts +105 -0
- package/assets/templates/views/checkout/data.ts +23 -0
- package/assets/templates/views/checkout/index.tsx +111 -0
- package/assets/templates/views/checkout/props.ts +49 -0
- package/assets/templates/views/checkout/registry.tsx +217 -0
- package/assets/templates/views/checkout/schema.ts +229 -0
- package/assets/templates/views/home/assembly/assembly.json +33 -0
- package/assets/templates/views/home/assembly/index.skeleton.tsx +90 -0
- package/assets/templates/views/home/assembly/registry.skeleton.tsx +25 -0
- package/assets/templates/views/home/assembly/slots/benefits/Feature1/binding.json +5 -0
- package/assets/templates/views/home/assembly/slots/benefits/Feature1/catalog.part +4 -0
- package/assets/templates/views/home/assembly/slots/benefits/Feature1/element.part +4 -0
- package/assets/templates/views/home/assembly/slots/benefits/Feature1/registry.part +11 -0
- package/assets/templates/views/home/assembly/slots/benefits/Feature2/binding.json +5 -0
- package/assets/templates/views/home/assembly/slots/benefits/Feature2/catalog.part +4 -0
- package/assets/templates/views/home/assembly/slots/benefits/Feature2/element.part +4 -0
- package/assets/templates/views/home/assembly/slots/benefits/Feature2/registry.part +10 -0
- package/assets/templates/views/home/assembly/slots/categories/ProductCategory2/binding.json +5 -0
- package/assets/templates/views/home/assembly/slots/categories/ProductCategory2/catalog.part +4 -0
- package/assets/templates/views/home/assembly/slots/categories/ProductCategory2/element.part +5 -0
- package/assets/templates/views/home/assembly/slots/categories/ProductCategory2/registry.part +16 -0
- package/assets/templates/views/home/assembly/slots/hero/StorefrontHero1/binding.json +5 -0
- package/assets/templates/views/home/assembly/slots/hero/StorefrontHero1/catalog.part +4 -0
- package/assets/templates/views/home/assembly/slots/hero/StorefrontHero1/element.part +5 -0
- package/assets/templates/views/home/assembly/slots/hero/StorefrontHero1/registry.part +26 -0
- package/assets/templates/views/home/content.ts +70 -0
- package/assets/templates/views/home/data.ts +24 -0
- package/assets/templates/views/home/index.tsx +57 -85
- package/assets/templates/views/home/props.ts +22 -0
- package/assets/templates/views/home/registry.tsx +38 -22
- package/assets/templates/views/home/schema.ts +93 -0
- package/assets/templates/views/product/content.ts +25 -0
- package/assets/templates/views/product/data.ts +50 -0
- package/assets/templates/views/product/index.tsx +148 -0
- package/assets/templates/views/product/props.ts +27 -0
- package/assets/templates/views/product/registry.tsx +103 -0
- package/assets/templates/views/product/schema.ts +121 -0
- package/assets/templates/views/static/content.ts +99 -0
- package/assets/templates/views/static/index.tsx +60 -0
- package/assets/templates/views/static/registry.tsx +66 -0
- package/assets/templates/views/static/schema.ts +45 -0
- package/bin/storefront.js +2424 -148
- package/examples/merchandising/category-led.json +37 -0
- package/examples/merchandising/collection-led.json +37 -0
- package/package.json +15 -9
- package/recipes/archetypes.json +28 -14
- package/recipes/catalog.json +400 -0
- package/recipes/catalog.mjs +128 -0
- package/recipes/catalog.schema.json +64 -0
- package/recipes/feature.schema.json +89 -0
- package/recipes/features.json +162 -0
- package/recipes/manifest.schema.json +69 -0
- package/recipes/operations.schema.json +43 -0
- package/recipes/recipe.schema.json +11 -2
- package/recipes/recipes.json +76 -19
- package/recipes/sections.json +34 -5
- package/recipes/validate.mjs +838 -32
- package/scripts/candidate.mjs +236 -0
- package/scripts/composers.mjs +160 -0
- package/scripts/env-file.mjs +86 -0
- package/scripts/file-classes.mjs +121 -0
- package/scripts/logical-controls.mjs +61 -0
- package/scripts/manifest.mjs +298 -0
- package/scripts/migrate-english-routes.mjs +276 -0
- package/scripts/operation-registry.mjs +256 -0
- package/scripts/operations.mjs +720 -0
- package/scripts/ownership-conflict.mjs +356 -0
- package/scripts/pinning.mjs +573 -0
- package/scripts/plan-apply.mjs +987 -0
- package/scripts/preflight.mjs +51 -0
- package/scripts/reconcile.mjs +549 -0
- package/scripts/render-templates.mjs +338 -68
- package/scripts/schema-validate.mjs +132 -0
- package/scripts/section-compat.mjs +300 -0
- package/scripts/section-config.mjs +253 -0
- package/scripts/section-operations.mjs +508 -0
- package/scripts/starter.mjs +17 -0
- package/scripts/sync-assets.mjs +22 -15
- package/scripts/theme/color.mjs +185 -0
- package/scripts/theme/css-theme.mjs +233 -0
- package/scripts/theme/fonts.mjs +123 -0
- package/scripts/theme/import-export.mjs +125 -0
- package/scripts/theme/preset.mjs +93 -0
- package/scripts/theme/theme-plan.mjs +292 -0
- package/scripts/theme/tokens.mjs +137 -0
- package/scripts/view-assembly.mjs +337 -0
- package/scripts/view-selection.mjs +211 -0
- package/skills/sf-feature/SKILL.md +80 -0
- package/skills/sf-setup/SKILL.md +79 -0
- package/skills/sf-theme-gen/SKILL.md +100 -30
- package/skills/sf-theme-gen/references/shadcn-theming.md +87 -0
- package/skills/{shadcn-theming/references/templates → sf-theme-gen/references}/theme-setup.md +15 -19
- package/skills/{shadcn-theming → sf-theme-gen}/references/theming-guide.md +6 -11
- package/skills/sf-view-gen/SKILL.md +146 -93
- package/skills/sf-view-gen/assets/recipes/archetypes.json +28 -14
- package/skills/sf-view-gen/assets/recipes/catalog.json +400 -0
- package/skills/sf-view-gen/assets/recipes/catalog.schema.json +64 -0
- package/skills/sf-view-gen/assets/recipes/features.json +162 -0
- package/skills/sf-view-gen/assets/recipes/recipes.json +76 -19
- package/skills/sf-view-gen/assets/recipes/sections.json +34 -5
- package/skills/sf-view-gen/assets/templates/views/sections/cta.client.tsx +25 -0
- package/skills/sf-view-gen/assets/templates/views/sections/cta.tsx +16 -0
- package/skills/sf-view-gen/assets/templates/views/sections/faq.client.tsx +13 -9
- package/skills/sf-view-gen/assets/templates/views/sections/faq.tsx +2 -7
- package/skills/sf-view-gen/assets/templates/views/sections/logoCloud.client.tsx +12 -8
- package/skills/sf-view-gen/assets/templates/views/sections/logoCloud.tsx +2 -7
- package/skills/sf-view-gen/assets/templates/views/sections/pricing.client.tsx +14 -10
- package/skills/sf-view-gen/assets/templates/views/sections/pricing.tsx +2 -9
- package/skills/sf-view-gen/assets/templates/views/sections/products.client.tsx +100 -0
- package/skills/sf-view-gen/assets/templates/views/sections/products.tsx +19 -0
- package/skills/sf-view-gen/assets/templates/views/sections/schema.cta.ts +19 -0
- package/skills/sf-view-gen/assets/templates/views/sections/schema.faq.ts +18 -0
- package/skills/sf-view-gen/assets/templates/views/sections/schema.logoCloud.ts +19 -0
- package/skills/sf-view-gen/assets/templates/views/sections/schema.pricing.ts +26 -0
- package/skills/sf-view-gen/assets/templates/views/sections/schema.products.ts +39 -0
- package/skills/sf-view-gen/assets/templates/views/sections/schema.statistics.ts +25 -0
- package/skills/sf-view-gen/assets/templates/views/sections/schema.testimonials.ts +23 -0
- package/skills/sf-view-gen/assets/templates/views/sections/statistics.client.tsx +16 -8
- package/skills/sf-view-gen/assets/templates/views/sections/statistics.tsx +2 -7
- package/skills/sf-view-gen/assets/templates/views/sections/testimonials.client.tsx +13 -9
- package/skills/sf-view-gen/assets/templates/views/sections/testimonials.tsx +2 -5
- package/skills/{json-render-core/SKILL.md → sf-view-gen/references/json-render-core.md} +4 -27
- package/skills/{json-render-next/SKILL.md → sf-view-gen/references/json-render-next.md} +5 -8
- package/skills/{json-render-react/SKILL.md → sf-view-gen/references/json-render-react.md} +3 -5
- package/skills/{json-render-shadcn/SKILL.md → sf-view-gen/references/json-render-shadcn.md} +3 -5
- package/skills/sf-view-gen/references/views.md +58 -33
- package/skills/sf-view-gen/scripts/catalog.mjs +128 -0
- package/skills/sf-view-gen/scripts/schema-validate.mjs +132 -0
- package/skills/sf-view-gen/scripts/validate.mjs +838 -32
- package/skills/storefront-workflow/SKILL.md +179 -0
- package/skills/{storefront-best-practices/reference/design.md → storefront-workflow/references/design-consistency.md} +13 -29
- package/CHANGELOG.md +0 -61
- package/commands/sf-add-view.md +0 -26
- package/commands/sf-theme.md +0 -20
- package/commands/sf-view.md +0 -25
- package/skills/building-storefronts/SKILL.md +0 -178
- package/skills/building-storefronts/references/frontend-integration.md +0 -229
- package/skills/json-render-remotion/SKILL.md +0 -111
- package/skills/json-render-solid/SKILL.md +0 -204
- package/skills/nextjs-shadcn/SKILL.md +0 -367
- package/skills/nextjs-shadcn/references/architecture.md +0 -499
- package/skills/nextjs-shadcn/references/project-setup.md +0 -162
- package/skills/nextjs-shadcn/references/shadcn-platform.md +0 -261
- package/skills/nextjs-shadcn/references/sidebar.md +0 -274
- package/skills/nextjs-shadcn/references/styling.md +0 -555
- package/skills/sf-view-gen/assets/templates/views/category/index.tsx +0 -86
- package/skills/sf-view-gen/assets/templates/views/category/registry.tsx +0 -48
- package/skills/sf-view-gen/assets/templates/views/checkout/index.tsx +0 -192
- package/skills/sf-view-gen/assets/templates/views/checkout/registry.tsx +0 -45
- package/skills/sf-view-gen/assets/templates/views/product/index.tsx +0 -122
- package/skills/sf-view-gen/assets/templates/views/product/registry.tsx +0 -49
- package/skills/sf-view-gen/assets/templates/views/user-panel/index.tsx +0 -168
- package/skills/sf-view-gen/assets/templates/views/user-panel/registry.tsx +0 -49
- package/skills/shadcn-component-discovery/SKILL.md +0 -273
- package/skills/shadcn-component-discovery/references/registries.md +0 -226
- package/skills/shadcn-theming/SKILL.md +0 -104
- package/skills/storefront-best-practices/SKILL.md +0 -421
- package/skills/storefront-best-practices/reference/components/breadcrumbs.md +0 -123
- package/skills/storefront-best-practices/reference/components/cart-popup.md +0 -189
- package/skills/storefront-best-practices/reference/components/country-selector.md +0 -298
- package/skills/storefront-best-practices/reference/components/footer.md +0 -112
- package/skills/storefront-best-practices/reference/components/hero.md +0 -241
- package/skills/storefront-best-practices/reference/components/megamenu.md +0 -239
- package/skills/storefront-best-practices/reference/components/navbar.md +0 -397
- package/skills/storefront-best-practices/reference/components/popups.md +0 -221
- package/skills/storefront-best-practices/reference/components/product-card.md +0 -125
- package/skills/storefront-best-practices/reference/components/product-reviews.md +0 -217
- package/skills/storefront-best-practices/reference/components/product-slider.md +0 -174
- package/skills/storefront-best-practices/reference/components/search.md +0 -101
- package/skills/storefront-best-practices/reference/connecting-to-backend.md +0 -391
- package/skills/storefront-best-practices/reference/features/promotions.md +0 -307
- package/skills/storefront-best-practices/reference/features/wishlist.md +0 -230
- package/skills/storefront-best-practices/reference/layouts/account.md +0 -380
- package/skills/storefront-best-practices/reference/layouts/cart.md +0 -316
- package/skills/storefront-best-practices/reference/layouts/checkout.md +0 -486
- package/skills/storefront-best-practices/reference/layouts/home-page.md +0 -264
- package/skills/storefront-best-practices/reference/layouts/order-confirmation.md +0 -231
- package/skills/storefront-best-practices/reference/layouts/product-details.md +0 -527
- package/skills/storefront-best-practices/reference/layouts/product-listing.md +0 -520
- package/skills/storefront-best-practices/reference/layouts/static-pages.md +0 -356
- package/skills/storefront-best-practices/reference/medusa.md +0 -307
- /package/skills/{storefront-best-practices/reference → storefront-workflow/references}/mobile-responsiveness.md +0 -0
- /package/skills/{storefront-best-practices/reference → storefront-workflow/references}/seo.md +0 -0
|
@@ -1,116 +1,169 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: sf-view-gen
|
|
3
|
-
description: Add a
|
|
3
|
+
description: Add or remove a Thor Commerce storefront view, compose and reorder a view's executable sections, or customize a view's user-owned files. Use when the user asks to add or remove a view (home, category, product, cart, account, static), add/remove/reorder a section (faq, cta, products), change a variant, or change a view's content, props, or data. Delegates every structural write to the `storefront` CLI.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# sf-view-gen
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
Choose a view's composition **by meaning**, delegate the structural write to the
|
|
9
|
+
`storefront` CLI, and edit only the user-owned files it leaves behind. The
|
|
10
|
+
manifest (`storefront.config.json`) is the structural authority; the CLI is the
|
|
11
|
+
only writer of derived files.
|
|
9
12
|
|
|
10
|
-
##
|
|
13
|
+
## Read the curated view set through the CLI (never from memory)
|
|
11
14
|
|
|
12
|
-
|
|
15
|
+
Run from the storefront project root. The CLI resolves the project from the
|
|
16
|
+
current directory; do not pass a directory.
|
|
13
17
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
- the values returned by the wizard (view name, description of what the view should contain or emphasize)
|
|
20
|
-
|
|
21
|
-
## Outputs (what this skill produces)
|
|
18
|
+
```bash
|
|
19
|
+
npx @thorprovider/storefront views --json # views, routes, intents/variants, installed
|
|
20
|
+
npx @thorprovider/storefront recipes --json # whole curated registry (views + features)
|
|
21
|
+
npx @thorprovider/storefront features --json # feature bundles and what they own
|
|
22
|
+
```
|
|
22
23
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
The `--json` output is the same registry the CLI validates against, so it cannot
|
|
25
|
+
advertise a selection the reconciler will not honour. There is **no fixed view
|
|
26
|
+
list in this skill**: `views --json` reports the authoritative curated set
|
|
27
|
+
(currently `home`, `product`, `cart`, `category`, `checkout`, `account`, and
|
|
28
|
+
`static`) annotated with `installed` and `supported`, so a view added to or
|
|
29
|
+
removed from the registry is reflected without editing this text.
|
|
30
|
+
|
|
31
|
+
`views --json` and `recipes --json` also report, per view, `registeredSlots` (the
|
|
32
|
+
non-removable core slots), `allowedSections` (the section types the view may
|
|
33
|
+
host), and `maxSections` (the editorial-instance bound), plus a top-level
|
|
34
|
+
`sectionTypes` list marking each type `executable` or `held` with a reason. Do not
|
|
35
|
+
read the JSON files directly; they are an implementation detail.
|
|
36
|
+
|
|
37
|
+
## Add a view
|
|
38
|
+
|
|
39
|
+
1. Read `views --json`. If the view is held (`supported: false`) or is
|
|
40
|
+
feature-owned, stop and explain the correct path (a direct `view add` of a
|
|
41
|
+
feature-owned view is rejected — route it through the owning feature's
|
|
42
|
+
`feature add`; see the `sf-feature` skill).
|
|
43
|
+
2. Choose an **intent by meaning** for each slot from the view's
|
|
44
|
+
`supportedIntents` (for example a "dense grid" description → the matching
|
|
45
|
+
intent). If the description is silent, use the default. Use
|
|
46
|
+
`--variant slot=Name` only when the user names an exact supported variant.
|
|
47
|
+
3. Delegate the write:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
npx @thorprovider/storefront view add <name> [--intent slot=intent] [--variant slot=Variant]
|
|
51
|
+
```
|
|
26
52
|
|
|
27
|
-
|
|
53
|
+
The CLI validates, updates the manifest, and reconciles the derived files. If
|
|
54
|
+
it exits non-zero, show its message and the supported options; do not hand-edit
|
|
55
|
+
derived files to work around it.
|
|
56
|
+
4. Report the created view and its route.
|
|
28
57
|
|
|
29
|
-
|
|
30
|
-
- `assets/recipes/sections.json` — optional sections → `elementType`, `variants`, `defaultVariant`, `propsHint`
|
|
31
|
-
- `assets/recipes/archetypes.json` — the **archetype (intent) layer**: per slot (`<view>.<slot>`) a set of named **intents**, each with a `variant` and a `when` usage hint, plus the slot `default` intent
|
|
32
|
-
- `assets/templates/views/<view>/` — the view modules it copies
|
|
33
|
-
- `assets/templates/views/sections/` — the optional-section fragments
|
|
34
|
-
- `scripts/validate.mjs` — the validator
|
|
35
|
-
- `references/views.md` — the view composition contract
|
|
36
|
-
- `../json-render-core/` — vendored catalog/schema/spec reference
|
|
37
|
-
- `../json-render-react/` — vendored registry/action reference
|
|
58
|
+
## Remove a view
|
|
38
59
|
|
|
39
|
-
Paths are relative to this `SKILL.md`. Run the validator from here:
|
|
40
60
|
```bash
|
|
41
|
-
|
|
42
|
-
node scripts/validate.mjs show <view>
|
|
43
|
-
node scripts/validate.mjs archetypes
|
|
44
|
-
node scripts/validate.mjs resolve <view> <slot> <intent>
|
|
45
|
-
node scripts/validate.mjs validate '<composition-json>'
|
|
61
|
+
npx @thorprovider/storefront view remove <name>
|
|
46
62
|
```
|
|
47
63
|
|
|
48
|
-
|
|
49
|
-
|
|
64
|
+
The CLI removes the derived wrapper and wiring. If it prints a preserved
|
|
65
|
+
user-owned file, relay that path to the user.
|
|
66
|
+
|
|
67
|
+
## Compose sections (the agent selects, the CLI writes)
|
|
68
|
+
|
|
69
|
+
A view's ordered composition mixes its **registered slots** (core presentation
|
|
70
|
+
slots, mandatory and non-removable) with **editorial section instances**. The
|
|
71
|
+
agent selects the options and runs the CLI; the user describes the change in
|
|
72
|
+
natural language and never types a command.
|
|
73
|
+
|
|
74
|
+
1. Read `views --json`. For the target view use `registeredSlots` (the core
|
|
75
|
+
slots), `allowedSections` (the host allowlist), and `maxSections`; read the
|
|
76
|
+
top-level `sectionTypes` list for which types are `executable`. Never treat the
|
|
77
|
+
`sections --json` installed-instance list as the set of available types.
|
|
78
|
+
2. Only `executable` types may be composed; a `held` type is refused with the
|
|
79
|
+
`reason` the registry reports — relay that reason, never invent one. A
|
|
80
|
+
`dataBound` `products` instance is configured separately by the developer in
|
|
81
|
+
`views/<view>/data.ts` → `sectionSources[id]` (a canonical query — not a sales
|
|
82
|
+
ranking); its variant only changes presentation, and until the selection is set
|
|
83
|
+
the instance renders a truthful "needs configuration" state that `doctor`
|
|
84
|
+
reports by file and instance id.
|
|
85
|
+
3. Compose through the CLI's section operations, carried in the operations
|
|
86
|
+
envelope `{ "formatVersion": 1, "operations": [ ... ] }`. Write the envelope
|
|
87
|
+
to a file, plan it, then apply the plan:
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
npx @thorprovider/storefront plan --operations operations.json --out plan.json
|
|
91
|
+
npx @thorprovider/storefront apply --plan plan.json
|
|
92
|
+
```
|
|
50
93
|
|
|
51
|
-
|
|
94
|
+
- `{ "op": "section.add", "view": "<view>", "type": "<type>" }` — optional `id`,
|
|
95
|
+
`variant`, and `at` (0-based insertion index, default append). Omit `id` to
|
|
96
|
+
auto-mint one; a `variant` must be declared by the section type.
|
|
97
|
+
- `{ "op": "section.remove", "view": "<view>", "id": "<id>" }` — removes an
|
|
98
|
+
editorial instance. A registered slot (`slot:<slot>`) cannot be removed.
|
|
99
|
+
- `{ "op": "section.reorder", "view": "<view>", "order": [ ... ] }` — `order`
|
|
100
|
+
must be a permutation of the view's current entry ids: every current id
|
|
101
|
+
exactly once, and every registered slot present.
|
|
102
|
+
|
|
103
|
+
4. `plan` is read-only and validates the whole intended state; `apply --plan` is
|
|
104
|
+
the only writer. On success the CLI updates the manifest and reconciles derived
|
|
105
|
+
files. If either exits non-zero, relay its diagnostic (it names the offending
|
|
106
|
+
field) and the supported options; do not hand-edit the manifest or derived
|
|
107
|
+
files to work around it.
|
|
108
|
+
5. A removed instance's content is preserved in the view's user-owned
|
|
109
|
+
`content.ts`; re-adding the same `id` rebinds it, while an auto-minted id never
|
|
110
|
+
rebinds preserved content.
|
|
111
|
+
|
|
112
|
+
## Variants
|
|
113
|
+
|
|
114
|
+
A slot's variant is a presentation choice carried by the manifest. Change it
|
|
115
|
+
through the CLI (`view add`/`remove` with `--variant`, or a `section.add` /
|
|
116
|
+
`section.reorder` operation for editorial sections); never hand-edit a derived
|
|
117
|
+
`index.tsx` or registry to swap an import identifier. Variant changes go through
|
|
118
|
+
the CLI plan/apply path so the manifest and the derived files stay in sync.
|
|
119
|
+
|
|
120
|
+
## Customize a view
|
|
121
|
+
|
|
122
|
+
Only **user-owned** files may be edited by hand. They are consumed by thin
|
|
123
|
+
derived wrappers, so `sync` regenerates the wrappers around your edits.
|
|
124
|
+
|
|
125
|
+
User-owned (edit these): `lib/<name>/views/<view>/content.ts`, `props.ts`,
|
|
126
|
+
`data.ts`, `schema.ts`, and `lib/<name>/mappers.ts`.
|
|
127
|
+
|
|
128
|
+
Derived (never edit; the CLI regenerates them): `index.tsx`, `registry.tsx`,
|
|
129
|
+
`lib/<name>/views/index.ts`, `lib/<name>/views/registry.ts`, `catalog.ts`,
|
|
130
|
+
`runtime.ts`, `spec/index.ts`, `state.ts`, `handlers.ts`.
|
|
131
|
+
|
|
132
|
+
1. Read the current user-owned files for the view.
|
|
133
|
+
2. Apply the requested change there. Preserve exported names, element ids, and
|
|
134
|
+
the event/prop contracts the derived wrapper imports.
|
|
135
|
+
3. Regenerate the wrappers: `npx @thorprovider/storefront sync`.
|
|
136
|
+
4. If the change needs a different block variant or a new view, use the CLI
|
|
137
|
+
(`view add`/`remove` or the section operations); never edit a derived file to
|
|
138
|
+
swap a variant.
|
|
139
|
+
|
|
140
|
+
## References
|
|
141
|
+
|
|
142
|
+
Relative to this `SKILL.md`:
|
|
143
|
+
|
|
144
|
+
- `references/views.md` — view module shape, registering, and data contracts.
|
|
145
|
+
- `references/json-render-core.md` — catalog zod props and spec shape.
|
|
146
|
+
- `references/json-render-react.md` — registry mapping, providers, and actions.
|
|
147
|
+
- `references/json-render-next.md` — the Next rendering shape.
|
|
148
|
+
- `references/json-render-shadcn.md` — standard component definitions.
|
|
52
149
|
|
|
53
|
-
##
|
|
150
|
+
## Stack constraints
|
|
54
151
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
152
|
+
- UI components only from `@thorprovider/blocks`.
|
|
153
|
+
- Data only through `@thorprovider/adapters` + `@thorprovider/runtime/commerce`.
|
|
154
|
+
- Never `@thorprovider/medusa-extended`.
|
|
155
|
+
- No custom blocks without explicit user authorization.
|
|
156
|
+
- A missing capability is a gap to report, not a reason to install another UI
|
|
157
|
+
framework or hand-edit a derived file.
|
|
59
158
|
|
|
60
|
-
|
|
61
|
-
- `../json-render-react/` — registry mapping and action wiring (`defineRegistry`, `Renderer`, `useStateStore`)
|
|
159
|
+
## Workflow model
|
|
62
160
|
|
|
63
|
-
|
|
161
|
+
Read `../storefront-workflow/SKILL.md` for the four phases and the CLI/agent
|
|
162
|
+
authority.
|
|
64
163
|
|
|
65
|
-
|
|
66
|
-
node scripts/validate.mjs resolve home hero showcase # -> StorefrontHero2
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
## Stack constraints
|
|
70
|
-
- UI: only `@thorprovider/blocks`
|
|
71
|
-
- Data: only `@thorprovider/adapters` + `@thorprovider/runtime/commerce`
|
|
72
|
-
- Never `@thorprovider/medusa-extended`
|
|
73
|
-
- No custom blocks without explicit user authorization
|
|
74
|
-
- **Two-file view split (RSC):** `index.tsx` is a pure Server Component module (name, elements, zod catalog, route, loader) and imports `registry` from the sibling `registry.tsx` as data. `registry.tsx` is the **`'use client'`** module and is the only place that imports values from `@json-render/react` or `@thorprovider/blocks`. Never add those imports to `index.tsx` — `@json-render/react` calls `createContext` at module scope, which breaks the RSC server graph.
|
|
75
|
-
- Every element `type` used in a spec MUST be registered in the view's zod catalog (`index.tsx`) AND its client registry (`registry.tsx`); the shared `catalog.ts` / `registry.tsx` compose both through the barrel and are never hand-edited
|
|
76
|
-
|
|
77
|
-
## Add-view workflow
|
|
78
|
-
|
|
79
|
-
1. Parse `$ARGUMENTS` → view name (+ optional description). Validate name. Confirm `lib/<name>/` exists (else run `npx @thorprovider/storefront create` to scaffold it).
|
|
80
|
-
2. `node scripts/validate.mjs show <view>` — read slots, allowed variants + sections. `node scripts/validate.mjs archetypes` — read slots with their named intents.
|
|
81
|
-
3. Choose an intent per slot by meaning from the description (defaults if silent), resolve each with `node scripts/validate.mjs resolve <view> <slot> <intent>`, choose optional sections the same way, then validate the full composition with `node scripts/validate.mjs validate '<json>'` **before writing anything**. On failure → stop, show the allowed options.
|
|
82
|
-
4. Copy the view template: `assets/templates/views/<view>/` → `lib/<name>/views/<view>/`. Each template is the two-file split: `index.tsx` (server spec) + `registry.tsx` ('use client' component mappings).
|
|
83
|
-
5. Register it in the barrel `lib/<name>/views/index.ts` — ONE import and ONE array entry:
|
|
84
|
-
```ts
|
|
85
|
-
import { <view> } from './<view>'
|
|
86
|
-
export const views: ViewModule[] = [home, <view>]
|
|
87
|
-
```
|
|
88
|
-
6. Substitute variants: each slot's block is imported under a stable alias (e.g. `ProductOverview1 as ProductOverviewBlock`), shipping the recipe default. Replace **only the imported identifier** with the resolved variant — never the alias, never the props:
|
|
89
|
-
```ts
|
|
90
|
-
import { ProductOverview5 as ProductOverviewBlock } from '@thorprovider/blocks'
|
|
91
|
-
```
|
|
92
|
-
7. Include any chosen optional section — fragments live at `assets/templates/views/sections/` as a two-file split:
|
|
93
|
-
- `<section>.tsx` (server): exports the section object with `elementType`, the zod `catalog` entry, and `registryModule: './<section>.client'`.
|
|
94
|
-
- `<section>.client.tsx` ('use client'): exports `registry: ViewRegistry` with the component mapping.
|
|
95
|
-
Import the section object from `<section>` into `index.tsx` and merge its elements/catalog into the view; put the component mapping from `<section>.client` into the view's `registry.tsx` (re-exporting the fragment's registry).
|
|
96
|
-
8. Verify: `yarn typecheck`. Do NOT hand-edit `catalog.ts`, `registry.tsx`, `runtime.ts`, or `spec/index.ts` — they compose whatever the barrel exports.
|
|
97
|
-
|
|
98
|
-
## Modify workflow (`/sf-view`)
|
|
99
|
-
|
|
100
|
-
1. Parse view name + change. Validate name.
|
|
101
|
-
2. Read `lib/<name>/views/<view>/index.tsx` (server spec) and `registry.tsx` (client mappings) fully.
|
|
102
|
-
3. Apply ONLY the change. Preserve ids, `type`, untouched `props`, `$state`, `on` wiring, route/loader, and the barrel entry.
|
|
103
|
-
4. If new blocks are needed, choose intents from `archetypes.json`, resolve to allowed variants, and validate before writing.
|
|
104
|
-
5. Re-run `yarn typecheck`.
|
|
105
|
-
|
|
106
|
-
## Generation headers
|
|
107
|
-
Every generated/edited file gets:
|
|
108
|
-
```
|
|
109
|
-
// Generated by @thorprovider/storefront (sf-view-gen) from recipes/<view>
|
|
110
|
-
```
|
|
164
|
+
## Completion criteria
|
|
111
165
|
|
|
112
|
-
|
|
113
|
-
-
|
|
114
|
-
|
|
115
|
-
-
|
|
116
|
-
- Type errors → fix before finishing; never leave broken specs.
|
|
166
|
+
- The manifest reflects the requested composition and `sync` reports no drift.
|
|
167
|
+
- Only user-owned files were hand-edited; every derived file was written by the
|
|
168
|
+
CLI.
|
|
169
|
+
- The CLI command's exit status was checked and reported.
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"description": "Archetype (intent) layer. Maps a slot to named intents so selection is by meaning, not by variant ordinal. Each intent resolves to a variant that MUST be allowed by the recipe for that slot.",
|
|
5
5
|
"slots": {
|
|
6
6
|
"home.hero": {
|
|
7
|
-
"default": "
|
|
7
|
+
"default": "compact",
|
|
8
8
|
"intents": {
|
|
9
9
|
"compact": {
|
|
10
10
|
"variant": "StorefrontHero1",
|
|
@@ -88,6 +88,15 @@
|
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
},
|
|
91
|
+
"cart.view": {
|
|
92
|
+
"default": "review",
|
|
93
|
+
"intents": {
|
|
94
|
+
"review": {
|
|
95
|
+
"variant": "ShoppingCart4",
|
|
96
|
+
"when": "A standalone cart review page: line editing plus backend-authoritative totals before checkout."
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
},
|
|
91
100
|
"category.filter": {
|
|
92
101
|
"default": "sidebar",
|
|
93
102
|
"intents": {
|
|
@@ -122,25 +131,30 @@
|
|
|
122
131
|
}
|
|
123
132
|
}
|
|
124
133
|
},
|
|
125
|
-
"
|
|
126
|
-
"default": "
|
|
134
|
+
"account.login": {
|
|
135
|
+
"default": "signIn",
|
|
127
136
|
"intents": {
|
|
128
|
-
"
|
|
129
|
-
"variant": "
|
|
130
|
-
"when": "A
|
|
137
|
+
"signIn": {
|
|
138
|
+
"variant": "LoginPage1",
|
|
139
|
+
"when": "A full sign-in page with email and password and a link to create an account."
|
|
131
140
|
}
|
|
132
141
|
}
|
|
133
142
|
},
|
|
134
|
-
"
|
|
135
|
-
"default": "
|
|
143
|
+
"account.register": {
|
|
144
|
+
"default": "signUp",
|
|
136
145
|
"intents": {
|
|
137
|
-
"
|
|
138
|
-
"variant": "
|
|
139
|
-
"when": "A
|
|
140
|
-
}
|
|
141
|
-
|
|
146
|
+
"signUp": {
|
|
147
|
+
"variant": "SignUpPage1",
|
|
148
|
+
"when": "A full registration page with name, email, and password and a link to sign in."
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
"account.orders": {
|
|
153
|
+
"default": "viewOrders",
|
|
154
|
+
"intents": {
|
|
155
|
+
"viewOrders": {
|
|
142
156
|
"variant": "OrderHistory2",
|
|
143
|
-
"when": "
|
|
157
|
+
"when": "A signed-in shopper's order history with per-order totals and detail on demand."
|
|
144
158
|
}
|
|
145
159
|
}
|
|
146
160
|
}
|