@wix/agent-skills 1.20.0 → 1.20.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (152) hide show
  1. package/package.json +1 -1
  2. package/skills/wix-headless-fast/SKILL.md +200 -34
  3. package/skills/wix-headless-fast/entry/skill.md +10 -2
  4. package/skills/wix-headless-fast/install/attach.mjs +253 -0
  5. package/skills/wix-headless-fast/install/deploy.mjs +109 -9
  6. package/skills/wix-headless-fast/install/fast-path.mjs +29 -34
  7. package/skills/wix-headless-fast/references/blog/INSTRUCTIONS.md +224 -60
  8. package/skills/wix-headless-fast/references/blog/app/components/blog/BlogFeedView.tsx +2 -3
  9. package/skills/wix-headless-fast/references/blog/app/components/blog/PostView.tsx +2 -3
  10. package/skills/wix-headless-fast/references/blog/app/hooks/blog/useBlogFeed.ts +24 -116
  11. package/skills/wix-headless-fast/references/blog/app/hooks/blog/usePost.ts +16 -64
  12. package/skills/wix-headless-fast/references/blog/app/wix/blog/blog-feed-store.ts +137 -0
  13. package/skills/wix-headless-fast/references/blog/app/wix/blog/post-store.ts +78 -0
  14. package/skills/wix-headless-fast/references/blog/app/wix/blog/posts-core.ts +117 -0
  15. package/skills/wix-headless-fast/references/blog/app/wix/blog/posts.ts +13 -60
  16. package/skills/wix-headless-fast/references/blog/app/wix/blog/taxonomy-core.ts +47 -0
  17. package/skills/wix-headless-fast/references/blog/app/wix/blog/taxonomy.ts +10 -28
  18. package/skills/wix-headless-fast/references/blog/app-astro/pages/blog/[...slug].astro +2 -4
  19. package/skills/wix-headless-fast/references/blog/rest/posts.ts +42 -0
  20. package/skills/wix-headless-fast/references/blog/rest/taxonomy.ts +62 -0
  21. package/skills/wix-headless-fast/references/blog/seed/SEED.md +9 -0
  22. package/skills/wix-headless-fast/references/bookings/INSTRUCTIONS.md +179 -33
  23. package/skills/wix-headless-fast/references/bookings/app/components/bookings/ServiceBookingView.tsx +2 -1
  24. package/skills/wix-headless-fast/references/bookings/app/hooks/bookings/useBookingFlow.ts +26 -132
  25. package/skills/wix-headless-fast/references/bookings/app/hooks/bookings/useServices.ts +18 -49
  26. package/skills/wix-headless-fast/references/bookings/app/wix/bookings/booking-core.ts +218 -0
  27. package/skills/wix-headless-fast/references/bookings/app/wix/bookings/booking-flow-store.ts +169 -0
  28. package/skills/wix-headless-fast/references/bookings/app/wix/bookings/booking.ts +57 -142
  29. package/skills/wix-headless-fast/references/bookings/app/wix/bookings/services-core.ts +92 -0
  30. package/skills/wix-headless-fast/references/bookings/app/wix/bookings/services-store.ts +90 -0
  31. package/skills/wix-headless-fast/references/bookings/app/wix/bookings/services.ts +22 -61
  32. package/skills/wix-headless-fast/references/bookings/app/wix/bookings/types.ts +3 -1
  33. package/skills/wix-headless-fast/references/bookings/rest/booking.ts +113 -0
  34. package/skills/wix-headless-fast/references/bookings/rest/services.ts +55 -0
  35. package/skills/wix-headless-fast/references/bookings/seed/SEED.md +10 -0
  36. package/skills/wix-headless-fast/references/cms/INSTRUCTIONS.md +236 -62
  37. package/skills/wix-headless-fast/references/cms/app/hooks/cms/useCollection.ts +19 -52
  38. package/skills/wix-headless-fast/references/cms/app/hooks/cms/useItem.ts +16 -36
  39. package/skills/wix-headless-fast/references/cms/app/wix/cms/collection-store.ts +158 -0
  40. package/skills/wix-headless-fast/references/cms/app/wix/cms/item-store.ts +93 -0
  41. package/skills/wix-headless-fast/references/cms/app/wix/cms/items-core.ts +177 -0
  42. package/skills/wix-headless-fast/references/cms/app/wix/cms/items.ts +13 -41
  43. package/skills/wix-headless-fast/references/cms/rest/items.ts +125 -0
  44. package/skills/wix-headless-fast/references/cms/seed/SEED.md +9 -0
  45. package/skills/wix-headless-fast/references/events/INSTRUCTIONS.md +239 -83
  46. package/skills/wix-headless-fast/references/events/app/components/events/EventConfirmationView.tsx +1 -1
  47. package/skills/wix-headless-fast/references/events/app/components/events/EventRegistrationView.tsx +7 -5
  48. package/skills/wix-headless-fast/references/events/app/components/events/EventsView.tsx +2 -2
  49. package/skills/wix-headless-fast/references/events/app/hooks/events/useEventRegistration.ts +28 -110
  50. package/skills/wix-headless-fast/references/events/app/hooks/events/useEvents.ts +19 -54
  51. package/skills/wix-headless-fast/references/events/app/wix/events/events-core.ts +130 -0
  52. package/skills/wix-headless-fast/references/events/app/wix/events/events-store.ts +97 -0
  53. package/skills/wix-headless-fast/references/events/app/wix/events/events.ts +13 -94
  54. package/skills/wix-headless-fast/references/events/app/wix/events/registration-core.ts +113 -0
  55. package/skills/wix-headless-fast/references/events/app/wix/events/registration-store.ts +156 -0
  56. package/skills/wix-headless-fast/references/events/app/wix/events/registration.ts +38 -69
  57. package/skills/wix-headless-fast/references/events/rest/events.ts +57 -0
  58. package/skills/wix-headless-fast/references/events/rest/registration.ts +83 -0
  59. package/skills/wix-headless-fast/references/events/seed/SEED.md +9 -0
  60. package/skills/wix-headless-fast/references/forms/INSTRUCTIONS.md +214 -26
  61. package/skills/wix-headless-fast/references/forms/app/hooks/forms/useWixForm.ts +35 -267
  62. package/skills/wix-headless-fast/references/forms/app/wix/forms/form-store.ts +332 -0
  63. package/skills/wix-headless-fast/references/forms/app/wix/forms/forms-core.ts +238 -0
  64. package/skills/wix-headless-fast/references/forms/app/wix/forms/forms.ts +28 -243
  65. package/skills/wix-headless-fast/references/forms/app/wix/forms/submissions-core.ts +216 -0
  66. package/skills/wix-headless-fast/references/forms/app/wix/forms/submissions.ts +32 -204
  67. package/skills/wix-headless-fast/references/forms/rest/forms.ts +34 -0
  68. package/skills/wix-headless-fast/references/forms/rest/submissions.ts +56 -0
  69. package/skills/wix-headless-fast/references/forms/seed/SEED.md +8 -0
  70. package/skills/wix-headless-fast/references/forms/seed/seed-forms.mjs +15 -8
  71. package/skills/wix-headless-fast/references/members/INSTRUCTIONS.md +314 -63
  72. package/skills/wix-headless-fast/references/members/app/components/members/LoginForm.tsx +1 -1
  73. package/skills/wix-headless-fast/references/members/app/wix/members/auth-core.ts +105 -0
  74. package/skills/wix-headless-fast/references/members/app/wix/members/auth.ts +36 -65
  75. package/skills/wix-headless-fast/references/members/app/wix/members/client.ts +1 -1
  76. package/skills/wix-headless-fast/references/members/app/wix/members/members-core.ts +43 -0
  77. package/skills/wix-headless-fast/references/members/app/wix/members/members.ts +11 -32
  78. package/skills/wix-headless-fast/references/members/rest/auth.ts +215 -0
  79. package/skills/wix-headless-fast/references/members/rest/members.ts +26 -0
  80. package/skills/wix-headless-fast/references/portfolio/INSTRUCTIONS.md +238 -59
  81. package/skills/wix-headless-fast/references/portfolio/app/components/portfolio/CollectionProjectsView.tsx +2 -2
  82. package/skills/wix-headless-fast/references/portfolio/app/components/portfolio/CollectionsView.tsx +2 -2
  83. package/skills/wix-headless-fast/references/portfolio/app/components/portfolio/GalleryMedia.tsx +35 -0
  84. package/skills/wix-headless-fast/references/portfolio/app/components/portfolio/ProjectDetailView.tsx +8 -38
  85. package/skills/wix-headless-fast/references/portfolio/app/hooks/portfolio/useCollectionProjects.ts +23 -50
  86. package/skills/wix-headless-fast/references/portfolio/app/hooks/portfolio/useCollections.ts +16 -34
  87. package/skills/wix-headless-fast/references/portfolio/app/hooks/portfolio/useProjectDetail.ts +22 -49
  88. package/skills/wix-headless-fast/references/portfolio/app/wix/portfolio/collection-projects-store.ts +82 -0
  89. package/skills/wix-headless-fast/references/portfolio/app/wix/portfolio/collections-store.ts +58 -0
  90. package/skills/wix-headless-fast/references/portfolio/app/wix/portfolio/portfolio-core.ts +177 -0
  91. package/skills/wix-headless-fast/references/portfolio/app/wix/portfolio/portfolio.ts +31 -118
  92. package/skills/wix-headless-fast/references/portfolio/app/wix/portfolio/project-detail-store.ts +81 -0
  93. package/skills/wix-headless-fast/references/portfolio/rest/portfolio.ts +75 -0
  94. package/skills/wix-headless-fast/references/portfolio/seed/SEED.md +8 -0
  95. package/skills/wix-headless-fast/references/pricing-plans/INSTRUCTIONS.md +212 -51
  96. package/skills/wix-headless-fast/references/pricing-plans/app/components/pricing-plans/PlanDetailView.tsx +9 -20
  97. package/skills/wix-headless-fast/references/pricing-plans/app/components/pricing-plans/PlansView.tsx +7 -32
  98. package/skills/wix-headless-fast/references/pricing-plans/app/components/pricing-plans/SubscribeButton.tsx +41 -0
  99. package/skills/wix-headless-fast/references/pricing-plans/app/hooks/pricing-plans/usePlanPurchase.ts +12 -33
  100. package/skills/wix-headless-fast/references/pricing-plans/app/hooks/pricing-plans/usePlans.ts +17 -34
  101. package/skills/wix-headless-fast/references/pricing-plans/app/wix/pricing-plans/plan-purchase-store.ts +54 -0
  102. package/skills/wix-headless-fast/references/pricing-plans/app/wix/pricing-plans/plans-core.ts +106 -0
  103. package/skills/wix-headless-fast/references/pricing-plans/app/wix/pricing-plans/plans-store.ts +64 -0
  104. package/skills/wix-headless-fast/references/pricing-plans/app/wix/pricing-plans/plans.ts +7 -55
  105. package/skills/wix-headless-fast/references/pricing-plans/app/wix/pricing-plans/purchase-core.ts +43 -0
  106. package/skills/wix-headless-fast/references/pricing-plans/app/wix/pricing-plans/purchase.ts +11 -34
  107. package/skills/wix-headless-fast/references/pricing-plans/rest/plans.ts +31 -0
  108. package/skills/wix-headless-fast/references/pricing-plans/rest/purchase.ts +20 -0
  109. package/skills/wix-headless-fast/references/pricing-plans/seed/SEED.md +8 -0
  110. package/skills/wix-headless-fast/references/restaurants/INSTRUCTIONS.md +240 -47
  111. package/skills/wix-headless-fast/references/restaurants/app/components/restaurants/MenuView.tsx +2 -2
  112. package/skills/wix-headless-fast/references/restaurants/app/components/restaurants/OrderCartDrawer.tsx +2 -2
  113. package/skills/wix-headless-fast/references/restaurants/app/hooks/restaurants/useMenus.ts +14 -35
  114. package/skills/wix-headless-fast/references/restaurants/app/hooks/restaurants/useReservation.ts +28 -171
  115. package/skills/wix-headless-fast/references/restaurants/app/wix/restaurants/menu-core.ts +155 -0
  116. package/skills/wix-headless-fast/references/restaurants/app/wix/restaurants/menu-store.ts +89 -0
  117. package/skills/wix-headless-fast/references/restaurants/app/wix/restaurants/menu.ts +23 -117
  118. package/skills/wix-headless-fast/references/restaurants/app/wix/restaurants/ordering-core.ts +124 -0
  119. package/skills/wix-headless-fast/references/restaurants/app/wix/restaurants/ordering.ts +45 -114
  120. package/skills/wix-headless-fast/references/restaurants/app/wix/restaurants/reservation-store.ts +193 -0
  121. package/skills/wix-headless-fast/references/restaurants/app/wix/restaurants/reservations-core.ts +94 -0
  122. package/skills/wix-headless-fast/references/restaurants/app/wix/restaurants/reservations.ts +15 -87
  123. package/skills/wix-headless-fast/references/restaurants/rest/menu.ts +60 -0
  124. package/skills/wix-headless-fast/references/restaurants/rest/ordering.ts +169 -0
  125. package/skills/wix-headless-fast/references/restaurants/rest/reservations.ts +68 -0
  126. package/skills/wix-headless-fast/references/restaurants/seed/SEED.md +8 -0
  127. package/skills/wix-headless-fast/references/shared/SUPPLIED-CONTENT.md +23 -0
  128. package/skills/wix-headless-fast/references/shared/app/wix/media.ts +45 -4
  129. package/skills/wix-headless-fast/references/shared/app/wix/sdk.ts +13 -0
  130. package/skills/wix-headless-fast/references/shared/rest/client.ts +155 -0
  131. package/skills/wix-headless-fast/references/shared/rest/config.ts +3 -0
  132. package/skills/wix-headless-fast/references/shared/rest/media.ts +65 -0
  133. package/skills/wix-headless-fast/references/storefront/INSTRUCTIONS.md +182 -63
  134. package/skills/wix-headless-fast/references/storefront/app/components/storefront/OptionPicker.tsx +95 -0
  135. package/skills/wix-headless-fast/references/storefront/app/components/storefront/QuickAdd.tsx +29 -58
  136. package/skills/wix-headless-fast/references/storefront/app/hooks/storefront/useProductDetail.ts +29 -163
  137. package/skills/wix-headless-fast/references/storefront/app/hooks/storefront/useShop.ts +26 -300
  138. package/skills/wix-headless-fast/references/storefront/app/wix/storefront/cart-core.ts +121 -0
  139. package/skills/wix-headless-fast/references/storefront/app/wix/storefront/cart.ts +49 -162
  140. package/skills/wix-headless-fast/references/storefront/app/wix/storefront/catalog-core.ts +309 -0
  141. package/skills/wix-headless-fast/references/storefront/app/wix/storefront/catalog.ts +47 -370
  142. package/skills/wix-headless-fast/references/storefront/app/wix/storefront/product-detail-store.ts +147 -0
  143. package/skills/wix-headless-fast/references/storefront/app/wix/storefront/shop-store.ts +289 -0
  144. package/skills/wix-headless-fast/references/storefront/rest/cart.ts +132 -0
  145. package/skills/wix-headless-fast/references/storefront/rest/catalog.ts +123 -0
  146. package/skills/wix-headless-fast/references/storefront/seed/SEED.md +25 -9
  147. package/skills/wix-headless-fast/references/storefront/seed/seed-store.mjs +6 -35
  148. package/skills/wix-manage/references/ecommerce/ecom-shipping.md +1 -1
  149. package/skills/wix-vibe-headless/references/storefront/INSTRUCTIONS.md +0 -40
  150. package/skills/wix-vibe-headless/references/storefront/seed/SEED.md +3 -0
  151. package/skills/wix-vibe-headless/references/storefront/seed/seed-store.cjs +6 -0
  152. package/skills/wix-headless-fast/install/pin-agents-md.mjs +0 -57
@@ -8,6 +8,21 @@
8
8
  // --stack react — copies only the core (app/) into src/, and writes the public OAuth
9
9
  // client id into src/wix/config.ts (pass --client-id, or it's read from
10
10
  // wix.config.json's appId when present).
11
+ // --stack lib — a bundled JS project that isn't React (Vue, Svelte, Solid, plain Vite): copies
12
+ // ONLY the data layer — shared app/wix/ (sdk, media, money, config) and each
13
+ // vertical's app/wix/<vertical>/ (data layer, cart store, types, *-core rules) —
14
+ // none of which imports React; writes the client id like react. No hooks, no
15
+ // components, no global.css, no Tailwind deps. The agent writes its framework's
16
+ // stores and components against the same DTO contracts.
17
+ // --stack static — a site with NO bundler (plain HTML/CSS/JS): composes the REST layer flat into
18
+ // <out>/js/wix/ — shared/rest/ (client, media, config) + each vertical's rest/ + the
19
+ // vertical's transport-agnostic core files (types, *-core) from its app/ — writes
20
+ // the client id, and strips it to browser-ready ESM with tsc (comments kept, the
21
+ // .ts sources kept beside the .js). No package.json is touched. Storefront only
22
+ // until other verticals ship a rest/. `--out <dir>` (default: the project root)
23
+ // is the folder the site is served from — the one wix.config.json's
24
+ // site.outputDirectory points at — so the modules land where the pages import
25
+ // them and nothing else in the project gets uploaded.
11
26
  //
12
27
  // TWO mechanisms, driven by the same vertical arguments:
13
28
  // 1. Recursive file copy with force:false — only files that AREN'T there yet are written, so
@@ -158,17 +173,18 @@ const flag = (name) => {
158
173
  const stack = flag("stack") ?? "astro";
159
174
  const clientIdFlag = flag("client-id");
160
175
  const planPath = flag("plan");
176
+ const outDir = flag("out");
161
177
  const flagArgs = new Set(
162
- ["--stack", "--client-id", "--plan", stack, clientIdFlag, planPath].filter(Boolean),
178
+ ["--stack", "--client-id", "--plan", "--out", stack, clientIdFlag, planPath, outDir].filter(Boolean),
163
179
  );
164
180
  const requested = [...new Set(argv.filter((a) => !flagArgs.has(a)))];
165
181
 
166
182
  const result = { stack, verticals: [], skillRoot: SKILL_ROOT };
167
183
 
168
- if (!["astro", "react"].includes(stack)) {
184
+ if (!["astro", "react", "lib", "static"].includes(stack)) {
169
185
  console.log(
170
186
  JSON.stringify({
171
- error: `unknown --stack "${stack}" — expected astro|react`,
187
+ error: `unknown --stack "${stack}" — expected astro|react|lib|static`,
172
188
  }),
173
189
  );
174
190
  process.exit(1);
@@ -193,6 +209,87 @@ if (!Array.isArray(uploadPolicies)) {
193
209
  console.log(JSON.stringify({ error: "plan.capabilities.mediaUpload.policies must be an array" }));
194
210
  process.exit(1);
195
211
  }
212
+ // ---- static stack: the REST layer, composed flat and stripped ------------------------------------
213
+ if (stack === "static") {
214
+ const { spawnSync } = await import("node:child_process");
215
+ const { rmSync } = await import("node:fs");
216
+ const OUT = outDir ? resolve(PROJECT, outDir) : PROJECT;
217
+ const JS = join(OUT, "js", "wix");
218
+ result.out = outDir ?? ".";
219
+ let clientId = clientIdFlag;
220
+ if (!clientId && existsSync(join(PROJECT, "wix.config.json"))) {
221
+ clientId = JSON.parse(readFileSync(join(PROJECT, "wix.config.json"), "utf8")).appId ?? null;
222
+ }
223
+ if (!clientId) {
224
+ console.log(JSON.stringify({ error: "static stack needs the public OAuth client id — run `npm create @wix/new@latest init` here first, or pass --client-id" }));
225
+ process.exit(1);
226
+ }
227
+ const missing = requested.filter((v) => !existsSync(join(REF, v, "rest")));
228
+ if (missing.length) {
229
+ console.log(JSON.stringify({ error: `no rest/ layer yet for ${missing.map((v) => `"${v}"`).join(", ")} — the static stack ships: ${VERTICALS.filter((v) => existsSync(join(REF, v, "rest"))).join(", ")}` }));
230
+ process.exit(1);
231
+ }
232
+ // Only files that aren't there yet — a re-run restores, never clobbers (same as the copy below).
233
+ cpSync(join(REF, "shared", "rest"), JS, COPY);
234
+ for (const vertical of requested) {
235
+ cpSync(join(REF, vertical, "rest"), JS, COPY);
236
+ // The vertical's transport-agnostic core: types, every *-core.ts, and every *-store.ts under its
237
+ // app/wix/<vertical>/ — the stores are the hooks' logic without React, over the same function
238
+ // names the REST twin exports, so they run against it unchanged.
239
+ const appWix = join(REF, vertical, "app", "wix", vertical);
240
+ for (const f of readdirSync(appWix)) {
241
+ // Every vertical has a types.ts; flat in one folder they would collide, so each lands as
242
+ // <vertical>-types.ts and the vertical's own files are pointed at it below.
243
+ if (f === "types.ts") cpSync(join(appWix, f), join(JS, `${vertical}-types.ts`), COPY);
244
+ else if (f.endsWith("-core.ts") || f.endsWith("-store.ts")) cpSync(join(appWix, f), join(JS, f), COPY);
245
+ }
246
+ const own = new Set([...readdirSync(join(REF, vertical, "rest")), ...readdirSync(appWix)].filter((f) => f.endsWith(".ts") && f !== "types.ts"));
247
+ for (const f of own) {
248
+ const fp = join(JS, f);
249
+ if (!existsSync(fp)) continue;
250
+ const src = readFileSync(fp, "utf8");
251
+ const fixed = src.replace(/from\s+"\.\/types(?:\.js)?"/g, `from "./${vertical}-types.js"`);
252
+ if (fixed !== src) writeFileSync(fp, fixed);
253
+ }
254
+ result.verticals.push(vertical);
255
+ }
256
+ // Browser ESM resolves nothing: every relative import needs its .js. The rest/ files are written
257
+ // that way; the files borrowed from app/wix/ are bundler-style and get the suffix here.
258
+ for (const f of readdirSync(JS).filter((f) => f.endsWith(".ts"))) {
259
+ const src = readFileSync(join(JS, f), "utf8");
260
+ const fixed = src.replace(/(from\s+"\.\/[^"]+?)(?<!\.js)"/g, '$1.js"');
261
+ if (fixed !== src) writeFileSync(join(JS, f), fixed);
262
+ }
263
+ const cfg = join(JS, "config.ts");
264
+ const current = readFileSync(cfg, "utf8");
265
+ if (/WIX_CLIENT_ID: string = ""/.test(current)) {
266
+ writeFileSync(cfg, current.replace(/WIX_CLIENT_ID: string = ""/, `WIX_CLIENT_ID: string = "${clientId}"`));
267
+ result.clientId = "written";
268
+ } else {
269
+ result.clientId = "already_set";
270
+ }
271
+ // Strip to ESM with tsc — comments are the spec for whoever reads js/wix/, so they stay.
272
+ const sources = readdirSync(JS).filter((f) => f.endsWith(".ts")).map((f) => join(JS, f));
273
+ const tsc = spawnSync(
274
+ "npx",
275
+ ["-y", "-p", "typescript@5", "tsc", ...sources, "--outDir", JS, "--module", "esnext", "--target", "es2022",
276
+ "--moduleResolution", "bundler", "--lib", "es2022,dom", "--strict", "--skipLibCheck", "--removeComments", "false"],
277
+ { encoding: "utf8", timeout: 180_000 },
278
+ );
279
+ if (tsc.status !== 0) {
280
+ console.log(JSON.stringify({ ...result, error: `tsc strip failed: ${(tsc.stdout || tsc.stderr || "").slice(-800)}` }));
281
+ process.exit(1);
282
+ }
283
+ rmSync(join(JS, "tsconfig.json"), { force: true });
284
+ result.js = `${outDir ? outDir.replace(/\/$/, "") + "/" : ""}js/wix/*.js`;
285
+ // The note lists what actually landed, so it holds for every vertical (and several at once).
286
+ const stores = readdirSync(JS).filter((f) => f.endsWith("-store.js")).map((f) => `./js/wix/${f}`);
287
+ const dataFiles = readdirSync(JS).filter((f) => f.endsWith(".js") && !f.endsWith("-store.js") && !f.endsWith("-core.js") && !f.endsWith("-types.js") && !["client.js", "config.js", "media.js"].includes(f)).map((f) => `./js/wix/${f}`);
288
+ result.note = `import the data layer (${dataFiles.join(", ")})${stores.length ? ` and the stores (${stores.join(", ")})` : ""} relative to ${outDir ?? "the project root"} in a <script type="module">; the .ts beside them are the same files with types, for reading; point wix.config.json site.outputDirectory at "./${outDir ?? "."}"`;
289
+ console.log(JSON.stringify(result));
290
+ process.exit(0);
291
+ }
292
+
196
293
  if (uploadPolicies.length && stack !== "astro") {
197
294
  console.log(JSON.stringify({ error: "mediaUpload currently requires --stack astro because it ships a validated server endpoint" }));
198
295
  process.exit(1);
@@ -212,8 +309,9 @@ for (const policy of uploadPolicies) {
212
309
  }
213
310
 
214
311
  // ---- copy ---------------------------------------------------------------------------------------
215
- // Shared core — always.
216
- cpSync(join(REF, "shared", "app"), SRC, COPY);
312
+ // Shared core — always. The lib stack takes only the framework-free wix/ part (no styles).
313
+ if (stack === "lib") cpSync(join(REF, "shared", "app", "wix"), join(SRC, "wix"), COPY);
314
+ else cpSync(join(REF, "shared", "app"), SRC, COPY);
217
315
 
218
316
  if (uploadPolicies.length) {
219
317
  cpSync(join(REF, "shared", "capabilities", "media-upload", "app"), SRC, COPY);
@@ -221,10 +319,12 @@ if (uploadPolicies.length) {
221
319
  }
222
320
 
223
321
  const unknown = requested.filter((v) => !VERTICALS.includes(v));
224
- const wantedDeps = { ...SHARED_DEPS };
322
+ // lib: only @wix/sdk from the shared deps — the Tailwind pair serves the components, which don't ship there.
323
+ const wantedDeps = stack === "lib" ? { "@wix/sdk": SHARED_DEPS["@wix/sdk"] } : { ...SHARED_DEPS };
225
324
  if (uploadPolicies.length) Object.assign(wantedDeps, CAPABILITY_DEPS["media-upload"]);
226
325
  for (const vertical of requested.filter((v) => VERTICALS.includes(v))) {
227
- cpSync(join(REF, vertical, "app"), SRC, COPY);
326
+ if (stack === "lib") cpSync(join(REF, vertical, "app", "wix"), join(SRC, "wix"), COPY);
327
+ else cpSync(join(REF, vertical, "app"), SRC, COPY);
228
328
  if (stack === "astro" && existsSync(join(REF, vertical, "app-astro"))) {
229
329
  cpSync(join(REF, vertical, "app-astro"), SRC, COPY);
230
330
  }
@@ -386,7 +486,7 @@ if (!clientId && existsSync(join(PROJECT, "wix.config.json"))) {
386
486
  JSON.parse(readFileSync(join(PROJECT, "wix.config.json"), "utf8")).appId ??
387
487
  null;
388
488
  }
389
- if (stack === "react") {
489
+ if (stack === "react" || stack === "lib") {
390
490
  if (clientId) {
391
491
  const current = readFileSync(CONFIG_TS, "utf8");
392
492
  // A non-null id already set wins; only fill the shipped null placeholder.
@@ -404,7 +504,7 @@ if (stack === "react") {
404
504
  }
405
505
  } else {
406
506
  result.clientId =
407
- "missing — pass --client-id (react stack needs the public OAuth client id)";
507
+ `missing — pass --client-id (the ${stack} stack needs the public OAuth client id)`;
408
508
  }
409
509
  }
410
510
  if (requested.includes("members")) {
@@ -4,16 +4,18 @@
4
4
  // or for connect/iterate runs (which must NOT scaffold and don't use this script).
5
5
  //
6
6
  // node <SKILL_ROOT>/install/fast-path.mjs --business-name "<Brand>" --plan plan.json \
7
- // --vertical <storefront|bookings|…> [--stack astro] [--folder-name <npm-safe-name>] [--flatten]
7
+ // --vertical <storefront|bookings|…> [--stack astro] [--subfolder [--folder-name <npm-safe-name>]]
8
8
  //
9
- // --flatten (opt-in): leave the project directly in the current directory instead of a subfolder,
10
- // moving it before the background install starts. Default off — the normal output is a subfolder.
9
+ // The project is created in the CURRENT DIRECTORY — the folder the entry had the agent work from,
10
+ // which already holds the installed skills (`.agents/skills/`), so the project is self-contained
11
+ // and a later session opened in it finds them. `--subfolder` (opt-in) leaves it in a new folder
12
+ // named after the business instead, for a current folder that must stay as it is.
11
13
  //
12
14
  // It emits ONE JSON event per line and exits in ~35s with BOTH long steps — the dependency
13
15
  // install AND the seed — running detached in the background (logs + completion markers
14
16
  // reported in the final event), so the caller can build the brand layer while they finish.
15
17
  // Steps: scaffold (Wix CLI; requires a logged-in session) → deploy shipped code + deps +
16
- // lockfile → pin AGENTS.md → start `npm ci || npm install` detached → start the seed detached.
18
+ // lockfile → start `npm ci || npm install` detached → start the seed detached.
17
19
  import { spawn, spawnSync } from "node:child_process";
18
20
  import { existsSync, openSync, readFileSync, readdirSync, renameSync, rmSync } from "node:fs";
19
21
  import { dirname, join, resolve } from "node:path";
@@ -37,8 +39,8 @@ const businessName = flag("business-name");
37
39
  const planPath = flag("plan");
38
40
  const vertical = flag("vertical");
39
41
  const stack = flag("stack") ?? "astro";
40
- // Opt-in: leave the project in the current directory (flat) instead of a subfolder.
41
- const flatten = argv.includes("--flatten");
42
+ // Opt-in: keep the project in a subfolder instead of the current directory.
43
+ const subfolder = argv.includes("--subfolder");
42
44
  // --vertical is REQUIRED: a defaulted vertical deploys the wrong code and runs the wrong
43
45
  // seed against the plan — fail loudly with the discovered choices instead.
44
46
  const knownVerticals = readdirSync(join(SKILL_ROOT, "references"), { withFileTypes: true })
@@ -56,9 +58,9 @@ const plan = JSON.parse(readFileSync(planPath, "utf8"));
56
58
  const folderName =
57
59
  flag("folder-name") ??
58
60
  businessName.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 40);
59
- // `let`: after deploy we flatten the scaffold up into the repo root and repoint
60
- // projectDir there, so the detached install/seed and every reported path use the
61
- // final location.
61
+ // `let`: the Wix CLI can only scaffold into a subfolder; by default we then move the scaffold up
62
+ // into the current directory and repoint projectDir there, so the detached install/seed and every
63
+ // reported path use the final location.
62
64
  let projectDir = resolve(process.cwd(), folderName);
63
65
 
64
66
  // ---- 1 · scaffold -------------------------------------------------------------------------------
@@ -108,33 +110,28 @@ try { deployResult = JSON.parse(deploy.stdout); } catch { /* keep going with raw
108
110
  if (deployResult.error) fail("deploy", deployResult.error);
109
111
  emit("deployed", deployResult);
110
112
 
111
- // ---- 2b · record what this project is, for later sessions ---------------------------------------
112
- const pin = spawnSync(
113
- "node",
114
- [join(SKILL_ROOT, "install", "pin-agents-md.mjs"), "--vertical", vertical, "--stack", stack],
115
- { cwd: projectDir, encoding: "utf8", timeout: 10_000 },
116
- );
117
- try { emit("agents_md", JSON.parse(pin.stdout)); } catch { /* never block the build on the note */ }
118
-
119
- // ---- 2c · optional --flatten: move the scaffold into the current directory ----------------------
120
- // OFF by default — the normal output is a self-contained subfolder, unchanged. Opt in when the
121
- // caller wants the project directly in the current directory (e.g. bootstrapping into an existing
122
- // repo that must stay one flat tree). Done HERE, before the detached install below, on purpose:
123
- // no node_modules exists yet, so the move is instant and cannot collide with a running install —
124
- // the failure mode when a project is flattened by hand after the background install has started.
125
- // A pure move: the scaffold was created with --skip-git (above), so there is no nested repo to
126
- // reconcile — git is whatever the destination already is.
113
+ // ---- 2c · place the project in the current directory --------------------------------------------
114
+ // The default. The Wix CLI scaffolds into a subfolder, so the scaffold is moved up into the current
115
+ // directory — the folder that already holds the installed skills — and the subfolder removed. Done
116
+ // HERE, before the detached install below, on purpose: no node_modules exists yet, so the move is
117
+ // instant and cannot collide with a running install. A pure move: the scaffold was created with
118
+ // --skip-git, so there is no nested repo to reconcile — git is whatever the folder already is.
119
+ // Refuses rather than overwrite: an entry that already exists in the current directory stops the
120
+ // move before anything is touched. `--subfolder` skips this step.
127
121
  const targetDir = process.cwd();
128
- if (flatten && projectDir !== targetDir) {
122
+ if (!subfolder && projectDir !== targetDir) {
123
+ const entries = readdirSync(projectDir);
124
+ const clashes = entries.filter((e) => existsSync(join(targetDir, e)));
125
+ if (clashes.length) {
126
+ fail("place", `the current directory already has: ${clashes.join(", ")} — run with --subfolder to keep the project in ${folderName}/, or start in an empty folder`);
127
+ }
129
128
  try {
130
- for (const entry of readdirSync(projectDir)) {
131
- renameSync(join(projectDir, entry), join(targetDir, entry));
132
- }
129
+ for (const entry of entries) renameSync(join(projectDir, entry), join(targetDir, entry));
133
130
  rmSync(projectDir, { recursive: true, force: true });
134
131
  projectDir = targetDir;
135
- emit("flattened", { into: targetDir });
132
+ emit("project_placed", { into: targetDir });
136
133
  } catch (e) {
137
- fail("flatten", e?.stack || e);
134
+ fail("place", e?.stack || e);
138
135
  }
139
136
  }
140
137
 
@@ -165,9 +162,7 @@ const seedDoneMarker = join(projectDir, ".seed-exit");
165
162
  const planAbs = resolve(planPath);
166
163
  const seedChild = spawn(
167
164
  "sh",
168
- // --fresh-site: this script created the site moments ago, so the only products in it are the
169
- // Stores install's samples — the seed clears them first (a seed run by hand never deletes).
170
- ["-c", `node "${seedFile}" "${planAbs}" --fresh-site > seed-result.json 2> seed.log; echo $? > .seed-exit`],
165
+ ["-c", `node "${seedFile}" "${planAbs}" > seed-result.json 2> seed.log; echo $? > .seed-exit`],
171
166
  { cwd: projectDir, detached: true, stdio: "ignore" },
172
167
  );
173
168
  seedChild.unref();