@wix/agent-skills 1.5.0 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (156) hide show
  1. package/README.md +2 -2
  2. package/package.json +1 -1
  3. package/skills/wix-app/SKILL.md +49 -42
  4. package/skills/wix-app/references/BACKEND_EVENT.md +10 -65
  5. package/skills/wix-app/references/CUSTOM_ELEMENT_WIDGET.md +101 -406
  6. package/skills/wix-app/references/DASHBOARD_MENU_PLUGIN.md +14 -111
  7. package/skills/wix-app/references/DASHBOARD_MODAL.md +56 -205
  8. package/skills/wix-app/references/DASHBOARD_PAGE.md +19 -98
  9. package/skills/wix-app/references/DASHBOARD_PLUGIN.md +6 -108
  10. package/skills/wix-app/references/DATA_COLLECTION.md +113 -198
  11. package/skills/wix-app/references/EDITOR_REACT_COMPONENT.md +15 -1
  12. package/skills/wix-app/references/EMBEDDED_SCRIPT.md +41 -268
  13. package/skills/wix-app/references/EXTENSION_REGISTRATION.md +27 -76
  14. package/skills/wix-app/references/SERVICE_PLUGIN.md +35 -188
  15. package/skills/wix-app/references/SITE_PLUGIN.md +8 -92
  16. package/skills/wix-app/references/backend-event/COMMON-EVENTS.md +0 -44
  17. package/skills/wix-app/references/custom-element-widget/SETTINGS_PANEL.md +19 -330
  18. package/skills/wix-app/references/dashboard-menu-plugin/bookings-slots.md +0 -12
  19. package/skills/wix-app/references/dashboard-menu-plugin/ecommerce-slots.md +7 -0
  20. package/skills/wix-app/references/dashboard-menu-plugin/restaurants-slots.md +0 -12
  21. package/skills/wix-app/references/dashboard-plugin/SLOTS.md +3 -15
  22. package/skills/wix-app/references/data-collection/WIX_DATA.md +1 -1
  23. package/skills/wix-app/references/editor-react-component/COMPONENT-API.md +1 -1
  24. package/skills/wix-app/references/service-plugin/ADDITIONAL-FEES.md +2 -18
  25. package/skills/wix-app/references/service-plugin/BOOKINGS-STAFF-SORTING.md +2 -42
  26. package/skills/wix-app/references/service-plugin/DISCOUNT-TRIGGERS.md +1 -11
  27. package/skills/wix-app/references/service-plugin/GIFT-CARDS.md +1 -11
  28. package/skills/wix-app/references/service-plugin/PAYMENT-SETTINGS.md +2 -40
  29. package/skills/wix-app/references/service-plugin/SHIPPING-RATES.md +2 -19
  30. package/skills/wix-app/references/service-plugin/VALIDATIONS.md +2 -18
  31. package/skills/wix-app/references/site-plugin/SLOTS.md +17 -68
  32. package/skills/wix-headless/SKILL.md +112 -368
  33. package/skills/wix-headless/references/BUILD.md +307 -0
  34. package/skills/wix-headless/references/DESIGN_SYSTEM.md +115 -0
  35. package/skills/wix-headless/references/DISCOVERY.md +237 -112
  36. package/skills/wix-headless/references/PLAN.md +82 -0
  37. package/skills/wix-headless/references/SEED.md +205 -0
  38. package/skills/wix-headless/references/SETUP.md +250 -94
  39. package/skills/wix-headless/references/astro/COMPOSE.md +142 -0
  40. package/skills/wix-headless/references/{blog → astro/blog}/BLOG_PAGES.md +1 -1
  41. package/skills/wix-headless/references/{blog → astro/blog}/BLOG_SETUP.md +2 -2
  42. package/skills/wix-headless/references/astro/cms/CMS_FOUNDATIONS.md +214 -0
  43. package/skills/wix-headless/references/{cms → astro/cms}/FAQ_KNOWLEDGE_BASE.md +6 -4
  44. package/skills/wix-headless/references/{cms → astro/cms}/PORTFOLIO.md +5 -5
  45. package/skills/wix-headless/references/{cms → astro/cms}/RESOURCE_LIBRARY.md +5 -5
  46. package/skills/wix-headless/references/{cms → astro/cms}/TEAM_DIRECTORY.md +5 -5
  47. package/skills/wix-headless/references/astro/designer/INSTRUCTIONS.md +331 -0
  48. package/skills/wix-headless/references/{ecom → astro/ecom}/CART_PAGES.md +1 -1
  49. package/skills/wix-headless/references/{ecom → astro/ecom}/CART_WIRING.md +1 -1
  50. package/skills/wix-headless/references/{ecom → astro/ecom}/COMPONENTS_CSS.md +3 -3
  51. package/skills/wix-headless/references/{forms → astro/forms}/CONTACT_FORM.md +13 -13
  52. package/skills/wix-headless/references/{gift-cards → astro/gift-cards}/COMPONENTS.md +1 -1
  53. package/skills/wix-headless/references/{gift-cards → astro/gift-cards}/PAGES.md +1 -1
  54. package/skills/wix-headless/references/{stores → astro/stores}/BACK_IN_STOCK.md +1 -1
  55. package/skills/wix-headless/references/{stores → astro/stores}/CATEGORY_PAGES.md +12 -13
  56. package/skills/wix-headless/references/{stores → astro/stores}/COMPONENTS_CSS.md +4 -4
  57. package/skills/wix-headless/references/{stores → astro/stores}/HOME_AND_NAV.md +11 -9
  58. package/skills/wix-headless/references/{stores → astro/stores}/PRODUCT_PAGES.md +5 -3
  59. package/skills/wix-headless/references/{stores → astro/stores}/SHARED_WIRING.md +3 -3
  60. package/skills/wix-headless/references/astro/templates/Footer.astro +27 -0
  61. package/skills/wix-headless/references/astro/templates/Layout.astro +132 -0
  62. package/skills/wix-headless/references/astro/templates/Navigation.astro +38 -0
  63. package/skills/wix-headless/references/astro/templates/astro.config.mjs +41 -0
  64. package/skills/wix-headless/references/astro/templates/ecom/components-ecom.css +302 -0
  65. package/skills/wix-headless/references/astro/templates/global.css +286 -0
  66. package/skills/wix-headless/references/astro/templates/index.astro +56 -0
  67. package/skills/wix-headless/{templates → references/astro/templates}/stores/back-in-stock.ts +1 -1
  68. package/skills/wix-headless/{templates → references/astro/templates}/stores/components-stores.css +138 -33
  69. package/skills/wix-headless/references/blog/BLOG_CONTENT.md +10 -11
  70. package/skills/wix-headless/references/blog/INSTRUCTIONS.md +5 -5
  71. package/skills/wix-headless/references/cms/CMS_FOUNDATIONS.md +31 -230
  72. package/skills/wix-headless/references/cms/INSTRUCTIONS.md +13 -8
  73. package/skills/wix-headless/references/custom/INSTRUCTIONS.md +38 -0
  74. package/skills/wix-headless/references/ecom/INSTRUCTIONS.md +10 -10
  75. package/skills/wix-headless/references/forms/INSTRUCTIONS.md +5 -5
  76. package/skills/wix-headless/references/gift-cards/INSTRUCTIONS.md +11 -11
  77. package/skills/wix-headless/references/images/INSTRUCTIONS.md +47 -50
  78. package/skills/wix-headless/references/seed-recipes.md +49 -0
  79. package/skills/wix-headless/references/shared/AUTHENTICATION.md +110 -0
  80. package/skills/wix-headless/references/shared/BUILD_NOISE.md +2 -2
  81. package/skills/wix-headless/references/shared/DOCS_SEARCH.md +41 -0
  82. package/skills/wix-headless/references/shared/IMAGE_GENERATION.md +17 -17
  83. package/skills/wix-headless/references/shared/IMPLEMENTER.md +20 -29
  84. package/skills/wix-headless/references/shared/PRODUCTION_SHARP_EDGES.md +1 -1
  85. package/skills/wix-headless/references/shared/RETURN_CONTRACT.md +25 -16
  86. package/skills/wix-headless/references/shared/STYLING.md +47 -10
  87. package/skills/wix-headless/references/stores/INSTRUCTIONS.md +25 -25
  88. package/skills/wix-headless/references/stores/PRODUCT_CATALOG_DATA.md +17 -17
  89. package/skills/wix-headless/references/verticals/_schema.json +31 -117
  90. package/skills/wix-headless/references/verticals/_schema.md +60 -150
  91. package/skills/wix-headless/references/verticals/blog.md +5 -99
  92. package/skills/wix-headless/references/verticals/cms.md +9 -100
  93. package/skills/wix-headless/references/verticals/ecom.md +5 -76
  94. package/skills/wix-headless/references/verticals/forms.md +5 -85
  95. package/skills/wix-headless/references/verticals/gift-cards.md +6 -103
  96. package/skills/wix-headless/references/verticals/stores.md +10 -144
  97. package/skills/wix-headless/scripts/check-manifest.mjs +5 -5
  98. package/skills/wix-headless/scripts/emit-design-tokens.mjs +29 -23
  99. package/skills/wix-headless/scripts/init-site-json.mjs +59 -21
  100. package/skills/wix-headless/scripts/patch-decorative-slots.mjs +67 -43
  101. package/skills/wix-headless/scripts/plan-entity-image-waves.mjs +3 -3
  102. package/skills/wix-headless/scripts/preview.sh +3 -3
  103. package/skills/wix-headless/scripts/release.sh +4 -4
  104. package/skills/wix-headless/scripts/scaffold.sh +75 -20
  105. package/skills/wix-headless/scripts/seed-utilities.sh +50 -12
  106. package/skills/wix-manage/SKILL.md +4 -8
  107. package/skills/wix-manage/references/blog/how-to-create-blog-posts.md +70 -1
  108. package/skills/wix-manage/references/cms/cms-data-items-crud.md +4 -0
  109. package/skills/wix-manage/references/cms/cms-references-and-relationships.md +2 -0
  110. package/skills/wix-manage/references/cms/cms-schema-management.md +4 -0
  111. package/skills/wix-manage/references/ecommerce/api-shipping.md +443 -0
  112. package/skills/wix-manage/references/ecommerce/flow-add-free-shipping.md +5 -6
  113. package/skills/wix-manage/references/ecommerce/flow-fix-coverage-gaps.md +4 -5
  114. package/skills/wix-manage/references/ecommerce/flow-optimize-shipping-rates.md +4 -5
  115. package/skills/wix-manage/references/ecommerce/goal-increase-aov.md +1 -1
  116. package/skills/wix-manage/references/ecommerce/goal-reduce-cart-abandonment.md +1 -2
  117. package/skills/wix-manage/references/ecommerce/guardrail-shipping-health.md +2 -2
  118. package/skills/wix-manage/references/ecommerce/recipe-apply-shipping-recommendations.md +4 -5
  119. package/skills/wix-manage/references/ecommerce/recommend-ecommerce-strategy.md +7 -7
  120. package/skills/wix-manage/references/ecommerce/setup-discount-rules.md +209 -72
  121. package/skills/wix-manage/references/ecommerce/setup-store-pickup-location.md +9 -10
  122. package/skills/wix-manage/references/ecommerce/skill-graph.md +4 -4
  123. package/skills/wix-manage/references/forms/create-form.md +2 -0
  124. package/skills/wix-manage/references/stores/bulk-create-products-with-options.md +2 -0
  125. package/skills/wix-manage/references/stores/create-product-from-image.md +91 -38
  126. package/skills/wix-manage/references/stores/setup-online-store-catalog-v3.md +14 -7
  127. package/skills/wix-app/references/data-collection/extension-template.ts +0 -107
  128. package/skills/wix-headless/references/ORCHESTRATION.md +0 -269
  129. package/skills/wix-headless/references/commands/install-app.md +0 -42
  130. package/skills/wix-headless/references/commands/mcp-bootstrap.md +0 -28
  131. package/skills/wix-headless/references/designer/INSTRUCTIONS.md +0 -828
  132. package/skills/wix-headless/references/shared/MCP_PREFIX.md +0 -105
  133. package/skills/wix-headless/scripts/copy-utility-templates.mjs +0 -153
  134. package/skills/wix-headless/templates/ecom/components-ecom.css +0 -215
  135. package/skills/wix-manage/references/events/list-events.md +0 -203
  136. /package/skills/wix-headless/{templates → references/astro/templates}/ecom/CartBadge.tsx +0 -0
  137. /package/skills/wix-headless/{templates → references/astro/templates}/ecom/CartView.tsx +0 -0
  138. /package/skills/wix-headless/{templates → references/astro/templates}/ecom/cart.astro +0 -0
  139. /package/skills/wix-headless/{templates → references/astro/templates}/ecom/discounts.ts +0 -0
  140. /package/skills/wix-headless/{templates → references/astro/templates}/ecom/thank-you.astro +0 -0
  141. /package/skills/wix-headless/{templates → references/astro/templates}/gift-cards/GiftCardPurchase.tsx +0 -0
  142. /package/skills/wix-headless/{templates → references/astro/templates}/gift-cards/_home-teaser-snippet.astro +0 -0
  143. /package/skills/wix-headless/{templates → references/astro/templates}/gift-cards/_nav-snippet.astro +0 -0
  144. /package/skills/wix-headless/{templates → references/astro/templates}/gift-cards/components-gift-cards.css +0 -0
  145. /package/skills/wix-headless/{templates → references/astro/templates}/gift-cards/gift-cards.astro +0 -0
  146. /package/skills/wix-headless/{templates → references/astro/templates}/gift-cards/gift-cards.ts +0 -0
  147. /package/skills/wix-headless/{templates → references/astro/templates}/stores/AddToCartButton.tsx +0 -0
  148. /package/skills/wix-headless/{templates → references/astro/templates}/stores/BackInStockForm.tsx +0 -0
  149. /package/skills/wix-headless/{templates → references/astro/templates}/stores/CategoryRail.astro +0 -0
  150. /package/skills/wix-headless/{templates → references/astro/templates}/stores/ProductCard.astro +0 -0
  151. /package/skills/wix-headless/{templates → references/astro/templates}/stores/ProductPurchase.tsx +0 -0
  152. /package/skills/wix-headless/{templates → references/astro/templates}/stores/SeoTags.astro +0 -0
  153. /package/skills/wix-headless/{templates → references/astro/templates}/stores/categories.ts +0 -0
  154. /package/skills/wix-headless/{templates → references/astro/templates}/stores/category/[slug].astro +0 -0
  155. /package/skills/wix-headless/{templates → references/astro/templates}/stores/products/[slug].astro +0 -0
  156. /package/skills/wix-headless/{templates → references/astro/templates}/stores/products/index.astro +0 -0
@@ -1,6 +1,71 @@
1
1
  # Discovery
2
2
 
3
- Infer as much as possible from the user's opening message; ask only what's genuinely unknown. Target: **~1:30 of discovery** including user think-time.
3
+ Capture brand + vibe + imagery + the per-vertical intent inferred from the user's prompt, present a slim plan, get approval, write `.wix/site.json`.
4
+
5
+ Infer as much as possible from the user's opening message; ask only what's genuinely unknown. Target: **~1:30 of discovery** including user think-time, **≤ 80 s** excluding it.
6
+
7
+ This phase owns the *domain* of discovery only. Run FLOW — when background work is dispatched, what waits on what, batching, and the transition into Setup/Seed — is owned by `references/PLAN.md` (pre-approval) and `references/BUILD.md` (post-approval).
8
+
9
+ ## Wave 0 — Mode detection (BEFORE any user-facing question)
10
+
11
+ Frontend mode is the single axis the frontend track branches on. Detect it from the working directory **first** — before the CLI-auth pre-flight, before Q1 — so the rest of Discovery knows which path to take. The detection is a file-existence check; cost is ~1 ms. The axis is binary: **astro (supported) vs custom (anything else, not available yet).**
12
+
13
+ ```
14
+ Inspect CWD:
15
+
16
+ 1. CWD is empty (or doesn't exist) → SCAFFOLD MODE (astro).
17
+ 2. CWD contains `wix.config.json` AND Astro structure (`src/`, `astro.config.mjs`)
18
+ → resume a prior wix-headless run. See SKILL.md § "When NOT to use this skill"
19
+ ("continue or start fresh?" — out of pivot scope).
20
+ 3. CWD contains `wix.config.json` AND a non-Astro frontend (e.g. `index.html` at
21
+ root, `*.jsx`/`*.tsx`/`*.vue` files) → CUSTOM (non-astro), not available yet.
22
+ 4. CWD contains source files (`index.html`, `*.jsx`, `*.tsx`, `*.vue`,
23
+ `package.json` from a non-Wix template, etc.) AND no `wix.config.json`
24
+ → CUSTOM (non-astro), not available yet.
25
+ ```
26
+
27
+ Capture the resolved value in session scratch as `frontend`:
28
+
29
+ | Scenario | `frontend` value | Wave 0 next |
30
+ |---|---|---|
31
+ | Scaffold mode (empty CWD) | `astro` | Continue to Pre-flight below |
32
+ | Prompt names a non-astro frontend (Vite, React SPA, etc.) | `custom` | Route to the custom stub — see § "Custom (non-astro) — not available yet" below |
33
+ | Existing project detected (cases 3 & 4 above) | `custom` | Route to the custom stub — see § "Custom (non-astro) — not available yet" below |
34
+
35
+ > **No `AskUserQuestion` for mode detection.** Mode is detected, never asked. If the working directory is ambiguous, default to `custom` and let the not-available message redirect the user (they can re-run with an empty directory for the astro path).
36
+
37
+ `frontend` flows into three places:
38
+ - `scaffold.sh --frontend <value>` — the scaffolder's input (only `astro` is built; custom does not scaffold — see § "Custom (non-astro) — not available yet").
39
+ - `init-site-json.mjs --frontend <value>` — "After Approval" § 2 (records it in the slim site.json snapshot; only reached on the astro path).
40
+ - Orchestrator session scratch — every downstream branch reads the scratch value, not the file: the frontend-track project-prep script (`seed-utilities.sh --template astro`) and the SEED Layout-import bridge. (Business-track steps — app install, seeders — never read it.)
41
+
42
+ ## Custom (non-astro) — not available yet (when `frontend === "custom"`)
43
+
44
+ Custom frontends are **not available yet** — astro is the only supported frontend. Do **not** run the interview, scaffold, Designer, Setup, or Seed. Open `<SKILL_ROOT>/references/custom/INSTRUCTIONS.md`, surface its not-available message to the user, and **stop**:
45
+
46
+ > *Custom (non-astro) frontends are not available yet — astro is the supported frontend. Re-run with the astro frontend (start from an empty directory), or check back later.*
47
+
48
+ No `.wix/site.json` is written and no `BUILD.md` flow runs. The intended future shape for the custom track (init scaffold + shared business track + per-pack SDK wiring) is recorded in `references/custom/INSTRUCTIONS.md` § "Intended future shape"; the retired Integrate (Path B) flow in `SETUP.md` is its historical reference. See `PLAN.md` § "Custom (non-astro) frontends — not available yet" for the routing.
49
+
50
+ ---
51
+
52
+ ## Pre-flight — Verify CLI auth (BEFORE any user-facing question)
53
+
54
+ The first Wix touch is the post-approval scaffold (`scaffold.sh` → `npm create @wix/new@latest headless`), which creates a business + project against the user's Wix account and so requires an active CLI session. Without one it fails — and because the scaffold now runs **after** approval (`BUILD.md` run-step 0), a logged-out user wouldn't find out until they'd done the whole interview *and* approved, only to have the build fail immediately. Run the auth check foreground here so a logged-out user sees the login prompt before any `AskUserQuestion`.
55
+
56
+ ```bash
57
+ npx @wix/cli@latest whoami >/dev/null 2>&1
58
+ ```
59
+
60
+ - Exit 0 → continue to Step 0.
61
+ - Exit non-zero → **run `npx @wix/cli@latest login` yourself; do NOT punt to the user.** Steps:
62
+ 1. `Bash` tool with command `npx @wix/cli@latest login`, `run_in_background: true`. No shell `&`, no `mktemp` redirect, no chaining.
63
+ 2. Read the harness output-file path from the tool reply's `<bash-stdout>` (or use `TaskOutput`).
64
+ 3. Parse line 1 for `{"event":"awaiting_user","userCode":"…","verificationUri":"…"}` (ignore any `TimeoutNaNWarning` on later lines).
65
+ 4. Surface in one plain-prose message — *not* `AskUserQuestion`: *"Open `<verificationUri>` in your browser and enter the code `<userCode>` — I'll continue once you've completed the login."*
66
+ 5. Wait for the harness `task-notification` with `<status>completed</status>`; confirm with `whoami`, then proceed to Step 0.
67
+
68
+ Full recovery reference: [`shared/AUTHENTICATION.md`](shared/AUTHENTICATION.md#wix-login-from-a-non-interactive-agent).
4
69
 
5
70
  ## Step 0 — Infer Vertical(s) and Business Context
6
71
 
@@ -35,57 +100,40 @@ If the user picks *"Type my own"*, follow up conversationally: *"Sure — what s
35
100
 
36
101
  If the user already named the brand in the opening message, skip this step.
37
102
 
38
- ### Background actions on Q1 answer
103
+ ### After Q1 — read the loaded pack files; scaffold inputs
39
104
 
40
- Immediately after the brand name is confirmed (before Q2), emit **one concurrent batch** containing both the scaffold dispatch AND prefetch reads of the shared contract docs. These reads cost nothing during Q2 + plan review wait time but save ~1 min of post-approval latency that prior runs spent reading these docs serially.
105
+ Once the brand is confirmed, read the loaded pack contents (to compose the plan) and prepare the scaffold inputs (slug + frontend value) for later. **The scaffold is NOT dispatched during Discovery** — it is dispatched post-approval (`BUILD.md` run-step 0), so the funnel can present the plan without waiting on anything. This section defines only the slug derivation + the `scaffold.sh` command shape.
41
106
 
42
- 1. **Scaffold dispatch.** Derive the project slug from the brand, validate it, then run `bash <SKILL_ROOT>/scripts/scaffold.sh <slug> "<Brand>"` as a background shell. The script handles the npm-create invocation + slug pre-flight (regex `^[a-z0-9]{3,20}$`); the orchestrator handles slug derivation from the human-readable brand.
107
+ **(a) Read every pack in the resolved set.** The full resolved set lives in SKILL.md § "When this skill triggers" (third column). For example, a `stores` run reads four files: `stores.md`, `cms.md`, `ecom.md`, `gift-cards.md`. Read the whole resolved set at once — do **not** read the top-level pack alone, then discover its `requires:` and issue a second batch.
43
108
 
44
- **Slug derivation (apply to brand before invoking the script):**
45
- 1. Lowercase
46
- 2. Strip every char that isn't `[a-z0-9]` (drop hyphens, spaces, punctuation, accents — the Wix CLI rejects them)
47
- 3. Truncate to 20 chars
48
- 4. If the result is shorter than 3 chars, ask the user explicitly for a slug (`AskUserQuestion`)
109
+ - `Read <SKILL_ROOT>/references/verticals/<pack>.md` for each pack in the resolved set (resolve `<SKILL_ROOT>` per SKILL.md § "Path resolution"). Read individual `.md` files; `Read` on the directory returns `EISDIR`.
49
110
 
50
- Examples: `"Acme-Co" → "acmeco"`; `"Sole Society" → "solesociety"`; `"E&E Co." → "eeco"`; `"AB" → ask the user`.
111
+ These reads pre-load the `routes:`, `apps:`, `requires:`, and `disabled` fields needed to compose the Pages table at Step 3.
51
112
 
52
- The Wix CLI requires `[a-z0-9]{3,20}` — hyphens, underscores, uppercase, and other punctuation are rejected.
113
+ **(b) The scaffold inputs.** The scaffolder is invoked as:
53
114
 
54
- **Pre-flight validation (orchestrator-side, before invoking the script).** Both must pass; if either fails, regenerate the slug or re-prompt the user — do NOT rely solely on the script's pre-flight (it'll exit non-zero, but that costs a round-trip):
55
- - `slug` matches `^[a-z0-9]{3,20}$`
56
- - `brand` is non-empty after trimming whitespace
115
+ ```bash
116
+ bash <SKILL_ROOT>/scripts/scaffold.sh <slug> "<brand>" --frontend <frontend> 2> <tempfile>
117
+ ```
57
118
 
58
- **The scaffold call (background shell, with timing capture):**
119
+ `<frontend>` is `astro` — the only supported (and only scaffolded) frontend. The scaffold step is reached only on the astro path; a custom frontend never gets here, because Wave 0 routes it to the stub before Q1 (§ "Custom (non-astro) — not available yet"). If the opening prompt explicitly names a non-astro frontend (Vite / React SPA / etc.), Wave 0 already set `frontend = "custom"` and short-circuited — this step does not run.
59
120
 
60
- ```bash
61
- STARTED_AT=$(date -u +%Y-%m-%dT%H:%M:%SZ)
62
- bash "<SKILL_ROOT>/scripts/scaffold.sh" "<slug>" "<brand>"
63
- ENDED_AT=$(date -u +%Y-%m-%dT%H:%M:%SZ)
64
- ```
121
+ **Slug derivation:** lowercase the brand, then **STRIP every character not matching `[a-z0-9]` — do NOT replace them with hyphens or underscores**. Truncate to 20 chars. The `scaffold.sh` pre-flight enforces `^[a-z0-9]{3,20}$` and rejects anything else with exit 2; a rejected slug forces a re-run of the ~30 s scaffold (the indie-bookshop-class regression).
65
122
 
66
123
  - Substitute `<brand>` with the user's confirmed brand (preserve original case; quotes are passed by the shell). Substitute `<slug>` with the validated slug.
67
- - The script pins `--site-template-id` to the pure-headless blank template (`212b41cb-0da6-4401-9c72-7c579e6477a2`). Vibe-compatible templates trigger an interactive prompt that blocks non-TTY runs — the template ID is intentionally hardcoded inside the script.
124
+ - The script passes bare `--site-template` so non-interactive scaffolding stays on the blank starter. Keep the new-site flow there unless the skill is explicitly redesigned around another scaffold. (Without it, `@wix/create-new` ≥0.0.72 prompts for a template and aborts in the agent's non-TTY shell.)
68
125
  - Append timing to `.wix/run.json.phases[]` as `{ phase: "scaffold", seconds: <duration>, started: $STARTED_AT, ended: $ENDED_AT }`.
69
126
 
70
- **Strict-then-recover:**
71
- 1. Script exit 2 (slug or brand validation failed) → orchestrator-side bug; the orchestrator should have caught this in pre-flight. Fix the slug derivation and retry.
72
- 2. Auth error from npm/Wix CLI → surface `"Run \`npx @wix/cli login\` and retry."` and stop.
73
- 3. `invalid template` error → the template ID inside `scaffold.sh` is stale. Look up the current ID via `<prefix>SearchWixCLIDocumentation` query `create headless template`, edit the script's `TEMPLATE_ID` constant, retry once, log to `.wix/run.json.commandDrift[]` so the script can be tightened.
74
- 4. Other errors → surface stderr to the user.
75
-
76
- Launch with background.
77
-
78
- 2. **Prefetch shared contracts** — siblings in the same concurrent batch (resolve `<SKILL_ROOT>` per SKILL.md § "Path resolution"):
79
- - `Read <SKILL_ROOT>/references/shared/RETURN_CONTRACT.md`
80
- - `Read <SKILL_ROOT>/references/shared/IMAGE_GENERATION.md`
81
- - `Read <SKILL_ROOT>/references/shared/MCP_PREFIX.md`
127
+ Correct (strip-and-concatenate):
128
+ - `"Bloom & Root"` → `"bloomroot"` (not `"bloom-and-root"`, not `"bloom-root"`)
129
+ - `"Page & Ember"` → `"pageember"` (not `"page-ember"`, not `"page-and-ember"`)
130
+ - `"ACME, Co."` → `"acmeco"`
131
+ - `"42 Below"` → `"42below"`
132
+ - `"Single-Origin Roasters"` → `"singleoriginroasters"` (cap at 20 → `"singleoriginroaster"` if truncation needed)
82
133
 
83
- 3. **Prefetch loaded pack files** — siblings in the same message:
84
- - `Read <SKILL_ROOT>/references/verticals/<pack>.md` for each loaded pack
134
+ **Wrong** (kebab-case / snake-case): any slug containing `-`, `_`, or any other separator. The transformation is **strip**, not **replace** — there are no separators in a valid slug.
85
135
 
86
- Then continue to Q2. The scaffold runs during Q2 + plan review (~30–60s, usually finishes before approval); the reads resolve near-instantly and pre-load the docs the orchestrator needs at Step 3 and Step 7, eliminating mid-flow read churn.
87
-
88
- **Do NOT also prefetch these docs after plan approval.** Reading them between plan approval and Step 3 adds ~1 min of user-visible wait with zero overlap to useful work.
136
+ Then continue to Q2.
89
137
 
90
138
  ---
91
139
 
@@ -103,6 +151,90 @@ Example options for a jewelry store:
103
151
 
104
152
  If the user picks "Something else", follow up with `AskUserQuestion` using a text input.
105
153
 
154
+ ---
155
+
156
+ ## Step 2.5 — Imagery preference
157
+
158
+ Before crafting the aesthetic direction and presenting the plan, capture the user's imagery preference. Hold this `imagery` flag in orchestrator session scratch — it gates whether downstream phases generate AI imagery (Wix AI credits) or rely on CSS-only themed blocks. The flag is **not** persisted to `.wix/site.json`; the orchestrator inlines it into the prompts of any subagent that needs to branch on it (Image Phase 1 dispatch, Image Phase 2 gate).
159
+
160
+ **Skip rule.** If the user's opening prompt explicitly mentioned imagery — phrases like *"with photos"*, *"with images"*, *"AI imagery"*, *"product photos"*, *"with pictures"* — skip the Q3 `AskUserQuestion` call and default `imagery` to `"ai-generated"`. Re-asking would feel redundant ("you already said you wanted images"). The credit estimate (§ 2.5.1) and balance fetch (§ 2.5.2) still run so the captured intent has the right numbers for the plan's Imagery line — only the `AskUserQuestion` itself is skipped.
161
+
162
+ ### 2.5.1 — Compute the credit estimate
163
+
164
+ In session scratch, compute `<estimatedCredits>` from the loaded packs and the per-vertical intent inferences (see "After Approval" § 1 for the inference rules — `productCount` defaults to 3, `postCount` defaults to 6).
165
+
166
+ ```
167
+ estimatedCredits =
168
+ 1 // hero / home decorative
169
+ + 2 // additional section decoratives
170
+ + (cms loaded ? 2 : 0) // /about + /faq hero images
171
+ + (stores loaded ? stores.productCount : 0) // default 3 when unknown
172
+ + (blog loaded ? blog.postCount : 0) // default 6 when unknown
173
+ + (forms loaded ? 0 : 0) // forms never trigger imagery
174
+ + (gift-cards loaded ? 0 : 0) // disabled pack — skip
175
+ ```
176
+
177
+ Packs with `disabled: true` contribute 0 regardless. The integer total is what we show. **Reuse** the `productCount=3` and `postCount=6` defaults from "After Approval" § 1 — do not invent new numbers.
178
+
179
+ Worked examples:
180
+ - Skincare (stores + cms, productCount=3, no blog): `1 + 2 + 2 + 3 + 0 + 0 + 0 = 8`.
181
+ - Coffee shop (stores + cms + blog, productCount=3, postCount=6): `1 + 2 + 2 + 3 + 6 + 0 + 0 = 14`.
182
+
183
+ ### 2.5.2 — Fetch the AI-credit balance
184
+
185
+ `npx @wix/cli@latest token` **without** `--site` mints an **account-scoped** token. With that token, the balance endpoint at `POST https://manage.wix.com/credit-transactions/v1/credit-transactions/get-account-balance` returns the current periodic credit balance + cap.
186
+
187
+ ```bash
188
+ ACCOUNT_TOKEN=$(npx @wix/cli@latest token) # NO --site — mints account-scoped
189
+ curl -sS -X POST \
190
+ -H "Authorization: Bearer $ACCOUNT_TOKEN" \
191
+ -H "Content-Type: application/json" \
192
+ -d '{}' \
193
+ "https://manage.wix.com/credit-transactions/v1/credit-transactions/get-account-balance"
194
+ ```
195
+
196
+ Successful response (HTTP 200):
197
+ ```json
198
+ {
199
+ "periodicCredits": { "balance": 250, "cap": 250 },
200
+ "creditBalanceBreakdown": [
201
+ { "subscriptionId": "…",
202
+ "usageRules": [{ "period": "MONTH", "balance": 250, "cap": 250, "resetDate": "…" }] }
203
+ ]
204
+ }
205
+ ```
206
+
207
+ Hold `balance = response.periodicCredits.balance` and `cap = response.periodicCredits.cap` in scratch.
208
+
209
+ **Recovery / fallback (in order):**
210
+
211
+ 1. **`wix token` (no `--site`) fails** — surface the error from the CLI; that is a `wix login` problem, not a balance-lookup problem. Set `balance = null` only after the CLI failure surfaces.
212
+ 2. **POST returns 401/403** — the **account-scoped** token (no `--site`) was rejected. Re-mint the account-scoped token once and retry. (The site-scoped "never re-mint" rule in `SEED.md` / `SETUP.md` does not apply here — these are distinct token caches.) If still 401/403, set `balance = null` and proceed.
213
+ 3. **POST returns 4xx other than 401/403** — log the response in scratch (do not crash) and set `balance = null`. The endpoint is POST-only; a GET returns 400.
214
+ 4. **Network error / timeout** — set `balance = null`. The credit estimate (§ 2.5.1) is unaffected; only the Q3 description's *"Current balance: …"* tail goes silent.
215
+
216
+ > **Don't share the token across calls.** The account-scoped token is for account-level reads only (balance, account metadata). Every other site-operating call in this skill uses `npx @wix/cli@latest token --site "$SITE_ID"` — site-scoped — per `references/shared/AUTHENTICATION.md`. Site-scoped tokens are rejected by the account endpoint and vice-versa.
217
+
218
+ ### 2.5.3 — Ask Q3
219
+
220
+ Ask **Q3** via `AskUserQuestion` with two single-select options. Interpolate `<estimatedCredits>` (from § 2.5.1) and the balance (from § 2.5.2) into the AI-generated `description:` before issuing the call.
221
+
222
+ > *"How should we handle imagery?"*
223
+
224
+ Options:
225
+ - **Themed blocks (Recommended)** — `description:` *"Polished CSS-only design. ~6 min build. Uses 0 Wix AI credits."*
226
+ - **AI-generated imagery** — `description:` *"Bespoke images per product and section. ~10 min build. Uses ~<estimatedCredits> Wix AI credits (1 image = 1 credit). Current balance: <balance> / <cap>."*
227
+
228
+ If `balance === null`, drop the trailing *"Current balance: …"* sentence entirely (do not print *"Current balance: unknown"* — silence is the contract). The AI-generated option then reads: *"Bespoke images per product and section. ~10 min build. Uses ~<estimatedCredits> Wix AI credits (1 image = 1 credit)."*
229
+
230
+ → **Verify Q3:** Themed blocks description ends `Uses 0 Wix AI credits.`. AI-generated description contains the substring `Uses ~<estimatedCredits> Wix AI credits (1 image = 1 credit).` (with `<estimatedCredits>` replaced by the integer). When balance is known, description also ends with `Current balance: <balance> / <cap>.`. When balance is unknown, description ends with `(1 image = 1 credit).` and no balance text follows.
231
+
232
+ Capture the answer as `imagery: "themed-blocks" | "ai-generated"` in session scratch. The downstream dispatch gates that consume it are owned by `BUILD.md § "Imagery gates"`.
233
+
234
+ The captured `imagery` value lives in orchestrator session scratch (alongside the inferred per-vertical intent — see "After Approval" § 1). It is **not** written to `.wix/site.json`; subagents that need to branch on it receive it inlined in their prompts.
235
+
236
+ ---
237
+
106
238
  ### Craft the aesthetic direction (in session scratch)
107
239
 
108
240
  Based on vertical + brand personality + audience, craft a **2–3 sentence aesthetic direction** like a designer would. Decide — don't ask more questions.
@@ -114,19 +246,32 @@ Example:
114
246
 
115
247
  ---
116
248
 
249
+ ## The Designer's inputs
250
+
251
+ The Designer owns **the design itself** — it returns a framework-agnostic JSON spec (tokens + brand-voice strings) and **writes no files**. It is framework-blind and application-blind by construction, so its inputs are *judgment* inputs only, and they are all produced here in Discovery and held in scratch:
252
+
253
+ - **Brand**: `{ name, description }` from Q1 (description = the user's opening business context, distilled to one line).
254
+ - **Aesthetic direction, color palette, typography, mood, page color strategy**: from the craft step above.
255
+
256
+ The application inputs (loaded packs, packs-with-components, disabled packs, navigation links) are **not** passed to the Designer — they go to the **Composer**. Hold them in scratch too, but for the Composer prompt in SEED. (Nav-links example for stores+cms+ecom+gift-cards: `[{"href":"/about","label":"About"},{"href":"/faq","label":"FAQ"}]` — `/about` + `/faq` when `cms` is loaded; never `/products` (stores splices it), `/gift-cards` (disabled), or any route whose pack contributes a nav marker.)
257
+
258
+ The orchestrator dispatches the Designer with these inputs **post-approval** (`BUILD.md` run-step 0) — not during Discovery; the Designer's prompt template lives in `DESIGN_SYSTEM.md`. Discovery only produces and holds the inputs in scratch.
259
+
260
+ ---
261
+
117
262
  ## Step 3 — Present the Plan
118
263
 
119
- Present the plan as formatted markdown. After presenting, use `AskUserQuestion` for approval.
264
+ **Send the rendered plan as its own assistant message FIRST** — the full formatted markdown (Sections A/B/C + Imagery line) that the user reads. **Only then, as a separate step, use `AskUserQuestion` for approval.** Never bundle the plan into the approval question, never replace it with a one-line "here's the plan", and never skip straight to "Ready to build?" — the user must see the rendered plan before the question. (This is the only thing between Q&A and approval; there is nothing else to do here — see `PLAN.md` § "Wave 0".)
120
265
 
121
- > **Do NOT show implementation details.** Users do not want to read about scaffolding, `npm install`, `env pull`, MCP calls, phase agents, designer handoffs, sidecars, or build/preview steps. They care about their site. The TaskList conveys progress; the plan conveys outcome. Never open with SDK packages or CMS collection fields.
266
+ > **Do NOT show implementation details.** Users do not want to read about scaffolding, `npm install`, `env pull`, API calls, phase agents, designer handoffs, sidecars, or build/preview steps. They care about their site. The TaskList conveys progress; the plan conveys outcome. Never open with SDK packages or CMS collection fields.
122
267
 
123
- The plan is composed from the loaded vertical packs. Each pack contributes: apps, packages, pages, CMS collections, features blurbs. The skill assembles; the packs supply.
268
+ The plan is composed from the loaded vertical packs. Each pack contributes: pages and features blurbs. The skill assembles; the packs supply. **Apps, packages, and CMS collection names are implementation details** — not surfaced in the plan; the loaded verticals determine apps to install and the seeder names CMS collections at run time.
124
269
 
125
270
  ### Plan structure (in order)
126
271
 
127
- The plan has TWO halves: a short **decision card** (Sections A + B — what the user actually weighs in on) and a longer **technical scope** block (Sections C + D + E — what comes "for free" from the loaded packs). The user reads A and B carefully; C–E are reference material they skim or skip.
272
+ The plan has TWO halves: a short **decision card** (Sections A + B — what the user actually weighs in on) and a tighter **technical scope** block (Section C + Imagery line — what comes "for free" from the loaded packs). The user reads A and B carefully; C is reference material they skim or skip.
128
273
 
129
- > **Sections C, D, E are markdown tables.** Each section below leads with the exact header skeleton — copy it verbatim. Do NOT type column headers from memory: that's the root cause of every plan-format regression.
274
+ > **Section C is a markdown table.** It leads with the exact header skeleton — copy it verbatim. Do NOT type column headers from memory: that's the root cause of every plan-format regression.
130
275
 
131
276
  **Section A: Design Direction** — Lead with this. Open with the aesthetic paragraph crafted in Step 2, then a compact detail block:
132
277
  - Aesthetic tone (e.g., "organic editorial")
@@ -192,57 +337,15 @@ Source cell:
192
337
 
193
338
  ---
194
339
 
195
- **Section D: CMS Collections.** Emit exactly this header, then one row per `cmsCollections:` entry from each loaded pack:
340
+ **Imagery line.** A single line below Section C, not a table:
196
341
 
197
342
  ```
198
- | Collection | Key Fields |
199
- |------------|------------|
343
+ **Imagery:** Themed blocks
200
344
  ```
201
345
 
202
- > **STOP if you typed `Fields` instead of `Key Fields`.** Re-read the skeleton above.
346
+ …or `**Imagery:** AI-generated (~<estimatedCredits> Wix AI credits)` when Q3 captured `ai-generated`, with `<estimatedCredits>` replaced by the integer computed in Step 2.5 § 2.5.1. Copy the imagery value from the captured preference; the credit count is the same number shown to the user at Q3. **Do not** repeat the current balance here — it was already shown at Q3, and re-printing it in Section C clutters the reference table the user skims.
203
347
 
204
- Iterate `cmsCollections:` from each loaded pack and emit one row per collection (collections from the `cms` pack always appear; other packs may declare their own).
205
-
206
- → **Verify D:** Header is exactly `| Collection | Key Fields |`.
207
-
208
- ---
209
-
210
- **Section E: Apps & SDK Packages.** Last. Reference table for developer-minded users. Emit exactly this header, then **one row per loaded pack** (NOT one row per package):
211
-
212
- ```
213
- | App | SDK Packages |
214
- |-----|--------------|
215
- ```
216
-
217
- > **STOP if you wrote one row per package.** `| Item | Type |` with `@wix/stores | SDK`, `@wix/ecom | SDK`, … is the wrong shape. Two columns, comma-joined packages in cell two, **one row per App**, not per SDK. Re-read the skeleton above.
218
-
219
- **Compose Section E from loaded pack frontmatter:**
220
-
221
- ```
222
- A pack contributes a Section E row iff:
223
- - Its `apps:` array is non-empty (top-level user-facing app), OR
224
- - Its `include: true` (the cms pack — built-in, no app to install).
225
-
226
- The "App" cell:
227
- - For packs with non-empty `apps:`: apps[0].name (e.g. "Wix Stores").
228
- - For the cms pack: the literal "CMS (builtin)".
229
-
230
- The "SDK Packages" cell:
231
- - This pack's `packages:` ∪ packages from every pack in its transitive
232
- `requires:` chain — deduped, in declared order.
233
- - So when stores is loaded (and pulls in ecom + gift-cards via requires),
234
- the "Wix Stores" row's SDK Packages cell is the union of stores +
235
- ecom + gift-cards packages — typically: @wix/stores, @wix/ecom,
236
- @wix/redirects, @wix/site, @wix/essentials.
237
-
238
- Packs with `apps: []` AND `include: false` (ecom, gift-cards) do
239
- NOT get their own row. Their packages roll up under whichever loaded
240
- top-level pack pulled them in. There is no "@wix/gift-cards" SDK on
241
- npm; the gift-cards pack is runtime-detected via REST and contributes
242
- zero npm packages of its own.
243
- ```
244
-
245
- → **Verify E:** Header is exactly `| App | SDK Packages |`. One row per loaded pack with non-empty `apps:` OR `include: true`. SDK Packages cell is comma-joined within a single cell, NOT split across rows. No "Wix Gift Cards" row when gift-cards loads transitively (no `@wix/gift-cards` SDK exists).
348
+ → **Verify Imagery:** Exactly one line. If themed: value is `Themed blocks`. If AI-generated: value matches `^AI-generated \(~\d+ Wix AI credits\)$`. No second line, no table, no other commentary.
246
349
 
247
350
  ### Example (skincare ecommerce brand)
248
351
 
@@ -286,19 +389,7 @@ tactile and approachable.
286
389
  | Thank You | /thank-you | Wix Stores |
287
390
  | Checkout | Hosted by Wix | Wix Stores |
288
391
 
289
- ## CMS Collections
290
-
291
- | Collection | Key Fields |
292
- |----------------|-----------------------------|
293
- | About Content | heading, body, image |
294
- | FAQ | question, answer, sortOrder |
295
-
296
- ## Apps & SDK Packages
297
-
298
- | App | SDK Packages |
299
- |---------------|--------------------------------------------------------------------|
300
- | Wix Stores | @wix/stores, @wix/ecom, @wix/redirects, @wix/site, @wix/essentials |
301
- | CMS (builtin) | @wix/data, @wix/essentials |
392
+ **Imagery:** Themed blocks
302
393
 
303
394
  Should I proceed?
304
395
  ```
@@ -307,7 +398,7 @@ The Cart, Thank You, and Checkout rows show `Source: Wix Stores` — not "Wix eC
307
398
 
308
399
  ### Final scan (MANDATORY)
309
400
 
310
- Before sending the plan, confirm each inline → Verify above (B, C, D, E) passed. If any failed, regenerate that section and re-scan before emitting. Plans that violate multiple inline checks at once cost a full plan replay (~25 min of user time) when caught post-hoc. The inline → Verify lines exist to catch them before sending.
401
+ Before sending the plan, confirm each inline → Verify above (B, C, Imagery) passed. If any failed, regenerate that section and re-scan before emitting. Plans that violate multiple inline checks at once cost a full plan replay (~25 min of user time) when caught post-hoc. The inline → Verify lines exist to catch them before sending.
311
402
 
312
403
  ### Approval
313
404
 
@@ -317,16 +408,50 @@ If the user wants to adjust, handle it conversationally (swap brand, change vibe
317
408
 
318
409
  ---
319
410
 
320
- ## After Approval
411
+ ## After Approval — capture intent in scratch and write `.wix/site.json`
321
412
 
322
- Save the project context to memory (type: `project`) so future sessions can resume:
323
- - Brand name, vertical(s) inferred
324
- - Apps, packages, pages from the loaded packs
325
- - Project name + absolute project directory
326
- - Current phase: `scaffolding`
413
+ On the user's "Yes, build it" approval, hold the captured intent in orchestrator session scratch and write a slim `.wix/site.json` metadata snapshot. The transition into Setup — and what Setup synchronizes on — is FLOW, owned by `PLAN.md` (which hands off to `BUILD.md` on approval).
327
414
 
328
- > **Do NOT narrate the internal sub-steps.** After approval, proceed silently through setup, launch phases, etc. The user tracks progress via TaskList — that's enough. No *"Now I'll install Wix Stores via MCP"*, no *"Launching Phase 1 agents"*, no MCP / sidecar / agent-name / `.wix/` leakage.
415
+ ### 1 · Compose the intent block in session scratch
416
+
417
+ In session scratch, build a single JSON object carrying the captured imagery flag plus per-vertical hints inferred from the user's prompt. Only include blocks for verticals that were loaded. This stays in orchestrator memory for the rest of the run — it is **not** written to disk. Seeders receive the relevant `intent.<pack>` slice inlined in their prompts (see `SEED.md` Step 2).
418
+
419
+ ```json
420
+ {
421
+ "imagery": "themed-blocks",
422
+ "stores": { "productCount": 3, "categoriesNamed": ["..."] },
423
+ "cms": { "collections": [{ "purpose": "about", "itemCount": 1 }] },
424
+ "blog": { "postCount": 6, "topics": ["..."] },
425
+ "forms": { "forms": [{ "purpose": "contact", "fields": ["..."] }] },
426
+ "gift-cards": { "enabled": true }
427
+ }
428
+ ```
429
+
430
+ Inference guidelines for each block:
431
+ - **`imagery`** — exactly the value captured at Step 2.5. If the user picked `"ai-generated"`, still pass `"ai-generated"` here; the AI-imagery fallback messaging happens in the user-facing summary, not in the captured intent.
432
+ - **`stores.productCount`** — number of products the user implied (e.g. *"a few candles"* → 3, *"a full catalog"* → 8). When unclear, default to 3.
433
+ - **`stores.categoriesNamed`** — strings the user explicitly named (*"a section for soaps and one for candles"* → `["Soaps", "Candles"]`). Empty array if none named.
434
+ - **`cms.collections`** — one entry per CMS-driven page: at minimum `{purpose: "about"}` and `{purpose: "faq"}` for any cms-loaded run. `itemCount` only when the user implied a number (*"a 5-question FAQ"* → `itemCount: 5`).
435
+ - **`blog.postCount`** — count the user implied; default to 6 when unclear. **`topics`** are explicit-only.
436
+ - **`forms.forms`** — one per form the user described; `purpose` is one of `contact`, `signup`, `lead`, etc.; `fields` are explicit only.
437
+ - **`gift-cards.enabled`** — `true` when the user explicitly asked for gift cards; `false` (or omit the block) otherwise.
438
+
439
+ When in doubt, omit a field rather than fabricate. The downstream phases that consume this block aren't built yet — overconfident inference can't be verified until then.
440
+
441
+ ### 2 · Write the slim `.wix/site.json` snapshot
442
+
443
+ ```bash
444
+ mkdir -p .wix
445
+ node "<SKILL_ROOT>/scripts/init-site-json.mjs" \
446
+ "$(pwd)" "<brand name>" "<one-line aesthetic from Q2>" "<verticals-csv>" \
447
+ --frontend "<frontend>"
448
+ ```
329
449
 
330
- Brief transition messages are fine when major milestones complete (e.g., *"Products seeded, designing pages now"* or the final preview URL), but never surface tool-layer mechanics.
450
+ - `<frontend>` is the value captured in Wave 0 — `astro` on the supported path (the only path that reaches this step; custom frontends are routed to the stub before approval and never write `.wix/site.json`). Always pass it explicitly so the recorded JSON is unambiguous.
451
+ - `<verticals-csv>` is the comma-joined list of all loaded packs (top-level + transitive via `requires:`). For a stores+cms run this is `"stores,ecom,cms,gift-cards"`.
452
+ - `<one-line aesthetic from Q2>` is the short aesthetic tone phrase, not the full 2–3 sentence direction.
453
+ - The script writes a slim `.wix/site.json` containing only `{brand, frontend, verticals}` (plus `siteId` / `appId` once Setup patches them in). It refuses to overwrite an existing file. If a stale site.json is present from a prior run, surface that to the user before retrying — do NOT silently `rm` it.
454
+ - The intent block from § 1 is **not** passed to the script — it lives in orchestrator scratch and feeds seeder prompts directly.
455
+ - **Trust the script's response.** A `{"status": "ok", "path": "..."}` return is the contract — do **not** follow up with a defensive `ls` + `Read` against `.wix/site.json` to confirm. Re-reading costs ~3s and adds nothing.
331
456
 
332
- Proceed to **Setup** (see `SETUP.md`).
457
+ Once `init-site-json.mjs` returns `{"status": "ok"}`, Discovery's domain work is complete. The transition into Setup and the rest of the run is owned by `PLAN.md` (which hands off to `BUILD.md` on approval).
@@ -0,0 +1,82 @@
1
+ # Plan — the pre-approval funnel
2
+
3
+ This file owns the run **from the first Discovery question to the user's approval of the plan** — mode routing, the questions, the background dispatches that hide latency, and the plan/approval gate. Its job is to get the user to the commitment moment **fast**, so keep it lean.
4
+
5
+ **On approval, open `BUILD.md`** — the post-approval conductor that owns execution (Setup → design-system bridge → Seed → Components → Pages → Build → Release). Everything past the approval gate lives there, so it is not read until the user has committed.
6
+
7
+ **The contract with the other files.** The domain/step files answer *what each step does* (the questions Discovery asks, the recipes, the prompt templates). This file + `BUILD.md` answer *when, in what order, in parallel with what, gated on what*. The step files do not name the sequence or chain to each other; the conductor (this file → `BUILD.md`) names when to apply each one. Neither prescribes a tool API — map each step to whatever subagent / parallel-execution primitive your runtime offers.
8
+
9
+ ## Concurrency vocabulary
10
+
11
+ The terms below appear throughout this skill. They describe the *shape* of work; the runtime decides how to implement them:
12
+
13
+ - **Subagent** — an isolated worker with its own context. The orchestrator sends it a prompt (an `Instruction file` path + inputs); the subagent reads the instruction file, performs the scope, and returns a structured result.
14
+ - **Concurrent batch** — N subagents (or N tool calls) launched together so they execute in parallel rather than serially.
15
+ - **Background subagent** — a subagent the orchestrator does not block on; it runs while the orchestrator continues with downstream work and reports its result asynchronously.
16
+ - **Foreground subagent** — a subagent the orchestrator blocks on before continuing.
17
+ - **Wait (gate)** — the orchestrator pauses until specified background work (subagents or background `Bash` jobs like the scaffold) finishes. **Waiting means awaiting the harness's background-task completion notification — never a `sleep`/poll loop against an output file.** A poll loop burns the whole wait as blocked orchestrator time and delays everything gated behind it (e.g. sleep-polling the scaffold lands the Composer late). The completion notification is the only signal you need; the same rule covers the `wix login` wait (`shared/AUTHENTICATION.md`) and the no-sidecar-poll rule for image phases (`images/INSTRUCTIONS.md`).
18
+ - **Result** — the structured JSON block each subagent returns at the end of its run, per `references/shared/RETURN_CONTRACT.md`.
19
+
20
+ ## Two tracks (business vs frontend)
21
+
22
+ The run is two semi-independent tracks that the orchestrator interleaves for wall-time:
23
+
24
+ - **Business track** (frontend-blind) — create/connect the site, **install Wix apps**, **seed backend data**. Inputs: `siteId`, `verticals`, `intent`, `brand`. It never reads `frontend`/template — a product (or collection, post, form) is the same regardless of what renders it. Its domain content lives in `SETUP.md` (app installs) + `SEED.md` (seeders).
25
+ - **Frontend track** (frontend-aware) — scaffold/prep the local project, Designer + design tokens, Composer, components, pages, SDK wiring, build. Every `frontend`/template branch lives here. Its domain content lives in `scaffold.sh` + `seed-utilities.sh` + `DESIGN_SYSTEM.md` / `astro/COMPOSE.md` + the per-vertical references (frontend guides under `references/astro/`).
26
+
27
+ The only cross-track data flow is **one-way, business → frontend**: seeders produce entity IDs which the orchestrator inlines into the frontend track's Page-subagent prompts. There is no frontend → business dependency.
28
+
29
+ ## Frontend-mode routing
30
+
31
+ `frontend` (captured by `DISCOVERY.md` § "Wave 0 — Mode detection") is the axis the frontend track branches on. The orchestrator holds it in scratch and uses it in two ways: it branches inline in the PLAN/BUILD orchestration on the scratch value, and it passes `--frontend <value>` to `scaffold.sh` and `init-site-json.mjs` (and `--template astro` to `seed-utilities.sh`). The axis is binary — **astro (supported) vs custom (anything else, not available yet)**:
32
+
33
+ | `frontend` | Mode | Flow |
34
+ |---|---|---|
35
+ | `astro` | Scaffold (supported) | Wave 0 below → on approval → `BUILD.md`. The full playbook lives under `<SKILL_ROOT>/references/astro/`. |
36
+ | anything else (custom) | Not available yet | Open `<SKILL_ROOT>/references/custom/INSTRUCTIONS.md`, surface its not-available message, and **stop** — no scaffold, no Designer/Composer, no Setup/Seed authoring, no `BUILD.md` build flow, no half-built site. |
37
+
38
+ > **Astro is the one Wix-preferred frontend the skill builds end-to-end.** Every non-astro value (a user-provided project, a Vite/React SPA, anything else) is a **custom** frontend; the custom authoring track is deferred. Route it to the stub and tell the user astro is the supported path. The intended future shape for custom is recorded in `references/custom/INSTRUCTIONS.md`.
39
+
40
+ This is the **track-selection routing layer**: `SETUP.md`'s steps assume the routing already happened; the conductor owns the branch.
41
+
42
+ ## Wave 0 — Discovery → plan → approval (Path A)
43
+
44
+ **The funnel dispatches nothing.** Its only job is to talk to the user, present the plan, and get approval. (The scaffold and Designer used to be dispatched here to hide their wall behind Q&A think-time — but the Designer is now ~10–15 s and the scaffold ~23 s, so the hiding isn't worth it, and those dispatches were what distracted the agent from actually showing the plan. **Both now dispatch in `BUILD.md`, post-approval.**) So the funnel is exactly three things:
45
+
46
+ 1. **Mode detection + pre-flight, then the interview** — apply `DISCOVERY.md` (mode detection, CLI auth, Q0 vertical inference, Q1 brand, Q2 vibe, Q2.5 imagery). **Read only what the next question needs** — do not pre-read `BUILD.md`; read the vertical packs for plan composition (not before the vibe question).
47
+ 2. **Compose and PRESENT the plan — as a standalone assistant message.** The moment Q&A ends and the aesthetic-direction craft is done, **render the full plan** (Design Direction from the Q2 craft + the Pages/Features tables, per `DISCOVERY.md` § plan) as a normal message the user reads. **The user MUST SEE the rendered plan before being asked to approve.** Do **not** fold the plan into the approval question, do **not** replace it with a one-line "here's the plan" + dispatch, and do **not** do any other work (no scaffold, no Designer, no scaffold-output reads) between the craft and the plan — there is nothing to dispatch here, so present the plan immediately.
48
+ 3. **Approval gate** — *only after* the plan message has been sent, ask the approval question (`AskUserQuestion`).
49
+
50
+ **On approval** — `init-site-json.mjs --frontend <value>` writes the slim `.wix/site.json`, then **open `BUILD.md`** and continue from its run-step 0 (which dispatches the scaffold + Designer, then runs Setup).
51
+
52
+ ## Custom (non-astro) frontends — not available yet
53
+
54
+ When `frontend` is anything other than `astro`, the run routes to the **custom stub** and stops the frontend track. Open `<SKILL_ROOT>/references/custom/INSTRUCTIONS.md`, surface its not-available message, and do **not** attempt authoring — no scaffold, no Designer/Composer, no Setup/Seed, no `BUILD.md`, no half-built site. The user is told astro is the supported frontend.
55
+
56
+ > **Retired: the Integrate (Path B) flow.** The skill used to run a live "Integrate" sequence for `user-provided` frontends — `DISCOVERY.md` § "Integrate-mode short flow" → `SETUP.md` § "Existing project flow" E1–E6 (E1 init → E2 analyze → E3 install apps → E4 SDK wiring → E5 release). That flow is **no longer dispatched**: non-astro frontends now hit the stub instead. The E1–E6 mechanics (especially the E4 SDK-wiring recipe) are kept in `SETUP.md` as a **historical reference** for the eventual custom authoring track (`references/custom/INSTRUCTIONS.md` § "Intended future shape"), not as a Beta deliverable.
57
+
58
+ ## User-facing output (keep the machinery invisible)
59
+
60
+ This rule governs the **whole run**, both files. The user should see **milestones in plain language, never the orchestration machinery.** Between the Discovery approval and the final summary the run is largely silent — the orchestrator is dispatching, waiting, and gating, none of which is the user's concern.
61
+
62
+ **Never put internal orchestration vocabulary in a user-facing message.** That includes: background-handle names (`*_handle`), dispatch markers ("→ dispatch:", "dispatching X", "launching Wave 3"), subagent START/END, "seed gate" / "all handles complete", wave/step numbers ("Wave 3", "Step 4.5"), in-flight **subagent/handle status tables** (especially any "Handle" column), and internal paths (`wix-manage-root`, the scaffold subdir). These describe *how the conductor works*, not *what the user is getting*.
63
+
64
+ **The only user-facing messages in a Path A run are:**
65
+ 1. **Discovery** — the questions, the plan, and the approval gate (`DISCOVERY.md`'s domain).
66
+ 2. **One brief seed-progress sentence** (`SEED.md` Step 5) — plain prose naming what was seeded, no tables.
67
+ 3. **The final summary** (`BUILD.md` § "Final Message").
68
+
69
+ Everything else is silent. If a long phase (Components, Pages) would otherwise look stalled, at most **one short plain-language line** ("Building your product and category pages…") — never a status table, handle list, or wave number. The in-flight subagent tables that runs have emitted ("Phase 3 Components running: | Subagent | Handle |…", "🎉 Seed gate open! All handles complete") are the anti-pattern this rule removes.
70
+
71
+ ## Batching discipline
72
+
73
+ This rule governs **every** concurrent batch in the run — the Wave-0 pack reads (here), and the BUILD-entry scaffold + Designer dispatch, the Setup app-installs, and the Wave-3 seed batch (all in `BUILD.md`). The step files describe *what* is in each batch; the rule that they go out as one batch lives here.
74
+
75
+ Historical runs lost 1–2 minutes per phase to serialized dispatch — N operations emitted one-per-turn instead of in a single concurrent batch. Even when each ran fast, the inter-dispatch gaps (12–39s in measured runs) accumulated to >25% overhead per phase.
76
+
77
+ Two mitigations; use both:
78
+
79
+ 1. **Fire the whole batch as one assistant message** — N `Agent`/`Bash` tool_uses as siblings. **No narration between dispatches** ("Now installing apps:", "Dispatching seeders:"). Any text adjacent to a dispatch closes the batch and forces the rest into separate turns, adding seconds per dispatch. This holds even for a 2-item batch (a measured 2-seeder run lost 12 s to one interstitial sentence).
80
+ 2. **Use background-on-dispatch for anything that doesn't block downstream work.** Even if the runtime serializes the launch turns, background dispatch lets the work overlap in execution. Measured compression on a sequential-launch / background-execute model: ~2× wall-time vs. serial.
81
+
82
+ If your runtime forces serialization across turns, make every subagent that can run in the background a background subagent — the Designer, Composer, seeders, and image phases all dispatch background so the foreground never blocks on them.