@wix/agent-skills 1.15.1 → 1.16.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 (332) hide show
  1. package/README.md +3 -7
  2. package/package.json +1 -1
  3. package/skills/wix-app/SKILL.md +4 -1
  4. package/skills/wix-app/references/APP_TOOLS.md +134 -0
  5. package/skills/wix-app/references/CUSTOM_ELEMENT_WIDGET.md +1 -1
  6. package/skills/wix-app/references/DASHBOARD_PAGE.md +0 -10
  7. package/skills/wix-app/references/DATA_COLLECTION.md +1 -1
  8. package/skills/wix-app/references/EDITOR_REACT_COMPONENT.md +42 -8
  9. package/skills/wix-app/references/SERVICE_PLUGIN.md +12 -10
  10. package/skills/wix-app/references/app-tools/TOOLS.md +75 -0
  11. package/skills/wix-app/references/dashboard-page/DASHBOARD_API.md +2 -2
  12. package/skills/wix-app/references/editor-react-component/A11Y-REVIEW-REFERENCE.md +172 -0
  13. package/skills/wix-app/references/editor-react-component/A11Y-REVIEW.md +143 -0
  14. package/skills/wix-app/references/editor-react-component/ANIMATED-COMPONENTS.md +23 -2
  15. package/skills/wix-app/references/editor-react-component/BRANDED-COMPONENTS.md +29 -0
  16. package/skills/wix-app/references/editor-react-component/COMPONENT-API.md +1 -1
  17. package/skills/wix-app/references/editor-react-component/COMPONENT-CONFIGURATION.md +60 -0
  18. package/skills/wix-app/references/editor-react-component/CSS-GUIDELINES.md +27 -2
  19. package/skills/wix-app/references/editor-react-component/DESIGN-STATES.md +5 -3
  20. package/skills/wix-app/references/editor-react-component/DIRECTIONALITY.md +24 -7
  21. package/skills/wix-app/references/editor-react-component/PARTS.md +15 -2
  22. package/skills/wix-app/references/editor-react-component/REACT-GUIDELINES.md +2 -3
  23. package/skills/wix-app/references/editor-react-component/SITE-CONTEXT-HOOKS.md +187 -0
  24. package/skills/wix-app/references/service-plugin/BOOKINGS-STAFF-SORTING.md +13 -9
  25. package/skills/wix-app/references/service-plugin/DISCOUNT-TRIGGERS.md +4 -0
  26. package/skills/wix-app/references/service-plugin/GIFT-CARDS.md +4 -0
  27. package/skills/wix-app/references/service-plugin/PAYMENT-SETTINGS.md +3 -1
  28. package/skills/wix-app/references/service-plugin/SHIPPING-RATES.md +4 -0
  29. package/skills/wix-app/references/service-plugin/TOOLS_PROVIDER.md +54 -0
  30. package/skills/wix-app/references/stores/QUERY.md +32 -0
  31. package/skills/wix-app/scripts/scan-a11y-code.cjs +777 -0
  32. package/skills/wix-app/scripts/scan-a11y-eslint.cjs +201 -0
  33. package/skills/wix-docs/SKILL.md +35 -3
  34. package/skills/wix-headless/SKILL.md +3 -1
  35. package/skills/wix-headless/references/CAPABILITIES.md +16 -3
  36. package/skills/wix-headless/references/CONTENT.md +36 -0
  37. package/skills/wix-headless/references/DESIGN.md +54 -0
  38. package/skills/wix-headless/references/DISCOVERY.md +24 -0
  39. package/skills/wix-headless/references/IMAGE_GENERATION.md +10 -0
  40. package/skills/wix-headless/references/SDK_HANDOFF.md +1 -1
  41. package/skills/wix-headless/references/SEED.md +1 -1
  42. package/skills/wix-headless/references/inline-recipes/how-to-code-a-store.md +3 -2
  43. package/skills/wix-headless/references/inline-recipes/how-to-code-forms.md +560 -102
  44. package/skills/wix-headless/references/inline-recipes/setup-forms.md +210 -143
  45. package/skills/wix-headless/references/inline-recipes/setup-online-store.md +32 -23
  46. package/skills/wix-headless/references/managed/CONNECT.md +1 -1
  47. package/skills/wix-headless/references/managed/CREATE.md +14 -0
  48. package/skills/wix-headless/references/managed/DEPLOYMENT.md +25 -0
  49. package/skills/wix-manage/SKILL.md +130 -7
  50. package/skills/wix-manage/references/accessibility/scan-site-accessibility.md +98 -0
  51. package/skills/wix-manage/references/analytics/analytics-dashboard-navigation.md +40 -0
  52. package/skills/wix-manage/references/app-installation/app-installation-dashboard-navigation.md +28 -0
  53. package/skills/wix-manage/references/blog/blog-dashboard-navigation.md +56 -0
  54. package/skills/wix-manage/references/blog/how-to-create-blog-posts.md +31 -6
  55. package/skills/wix-manage/references/bookings/booking-service-policy-setup.md +3 -1
  56. package/skills/wix-manage/references/bookings/bookings-dashboard-navigation.md +63 -0
  57. package/skills/wix-manage/references/bookings/diagnose-availability-issues.md +10 -1
  58. package/skills/wix-manage/references/cms/cms-dashboard-navigation.md +44 -0
  59. package/skills/wix-manage/references/cms/cms-data-items-crud.md +31 -3
  60. package/skills/wix-manage/references/cms/cms-publishing-flow.md +287 -0
  61. package/skills/wix-manage/references/cms/cms-schema-management.md +27 -1
  62. package/skills/wix-manage/references/contacts/contacts-dashboard-navigation.md +46 -0
  63. package/skills/wix-manage/references/contacts/create-a-contact.md +82 -0
  64. package/skills/wix-manage/references/contacts/update-a-contact.md +119 -0
  65. package/skills/wix-manage/references/dashboard-navigation/dashboard-navigation.md +82 -0
  66. package/skills/wix-manage/references/dashboard-navigation/routes.json +1733 -0
  67. package/skills/wix-manage/references/domains/domains-dashboard-navigation.md +32 -0
  68. package/skills/wix-manage/references/ecommerce/ecom-pricing.md +4 -4
  69. package/skills/wix-manage/references/ecommerce/ecom-shipping.md +1 -1
  70. package/skills/wix-manage/references/ecommerce/gift-cards/ecom-gift-cards-goal-sell-gift-cards.md +338 -0
  71. package/skills/wix-manage/references/ecommerce/pricing-promotions/ecom-pricing-create-discount-rule.md +42 -78
  72. package/skills/wix-manage/references/ecommerce/pricing-promotions/ecom-pricing-flow-bundle-and-save.md +1 -1
  73. package/skills/wix-manage/references/ecommerce/pricing-promotions/ecom-pricing-flow-stock-mover.md +1 -1
  74. package/skills/wix-manage/references/ecommerce/pricing-promotions/ecom-pricing-flow-upsell-boost.md +1 -1
  75. package/skills/wix-manage/references/ecommerce/recommend-ecommerce-strategy.md +90 -92
  76. package/skills/wix-manage/references/events/create-wix-event.md +176 -0
  77. package/skills/wix-manage/references/events/manage-wix-events.md +174 -0
  78. package/skills/wix-manage/references/forms/forms-dashboard-navigation.md +44 -0
  79. package/skills/wix-manage/references/get-paid/get-paid-dashboard-navigation.md +52 -0
  80. package/skills/wix-manage/references/google-ads/billing-and-payment.md +80 -0
  81. package/skills/wix-manage/references/google-ads/create-performance-max-campaign.md +212 -0
  82. package/skills/wix-manage/references/google-ads/get-campaign-suggestions.md +110 -0
  83. package/skills/wix-manage/references/google-ads/google-ads-dashboard-navigation.md +25 -0
  84. package/skills/wix-manage/references/google-ads/install-and-create-account.md +155 -0
  85. package/skills/wix-manage/references/google-ads/manage-campaign-lifecycle.md +63 -0
  86. package/skills/wix-manage/references/google-ads/query-campaign-analytics.md +155 -0
  87. package/skills/wix-manage/references/marketing/marketing-dashboard-navigation.md +52 -0
  88. package/skills/wix-manage/references/pricing-plans/create-and-update-pricing-plans.md +99 -1
  89. package/skills/wix-manage/references/pricing-plans/pricing-plans-dashboard-navigation.md +45 -0
  90. package/skills/wix-manage/references/restaurants/restaurants-dashboard-navigation.md +68 -0
  91. package/skills/wix-manage/references/restaurants/wix-restaurants-setup.md +94 -125
  92. package/skills/wix-manage/references/site-properties/change-payment-currency-site-properties.md +48 -9
  93. package/skills/wix-manage/references/site-properties/site-properties-dashboard-navigation.md +31 -0
  94. package/skills/wix-manage/references/sites/create-headless-site.md +52 -0
  95. package/skills/wix-manage/references/sites/create-site-from-template.md +2 -25
  96. package/skills/wix-manage/references/sites/site-import.md +217 -192
  97. package/skills/wix-manage/references/sites/sites-dashboard-navigation.md +29 -0
  98. package/skills/wix-manage/references/stores/add-store-pages-to-site.md +17 -1
  99. package/skills/wix-manage/references/stores/find-products-query-and-search-catalog-v3.md +26 -8
  100. package/skills/wix-manage/references/stores/stores-dashboard-navigation.md +65 -0
  101. package/skills/wix-manage/references/stores/update-product-with-options.md +39 -7
  102. package/skills/wix-replatform/.publish-manifest.json +8 -0
  103. package/skills/wix-replatform/SKILL.md +693 -0
  104. package/skills/wix-replatform/lib/artifact-freshness.js +215 -0
  105. package/skills/wix-replatform/lib/completion-report.js +200 -0
  106. package/skills/wix-replatform/lib/config-env.js +59 -0
  107. package/skills/wix-replatform/lib/execution-manifest.js +185 -0
  108. package/skills/wix-replatform/lib/execution-state.js +173 -0
  109. package/skills/wix-replatform/lib/import-recovery.js +313 -0
  110. package/skills/wix-replatform/lib/local-state.js +642 -0
  111. package/skills/wix-replatform/lib/orchestration-preflight.js +143 -0
  112. package/skills/wix-replatform/lib/orchestration-router.js +122 -0
  113. package/skills/wix-replatform/lib/orchestration-state.js +455 -0
  114. package/skills/wix-replatform/lib/progress-log.js +224 -0
  115. package/skills/wix-replatform/lib/progress-log.sh +140 -0
  116. package/skills/wix-replatform/lib/url-preservation-state.js +391 -0
  117. package/skills/wix-replatform/resources/rp-discovery/SKILL.md +184 -0
  118. package/skills/wix-replatform/resources/rp-execute-import/SKILL.md +529 -0
  119. package/skills/wix-replatform/resources/rp-execute-setup/SKILL.md +316 -0
  120. package/skills/wix-replatform/resources/rp-execute-setup/scripts/mint-token.sh +64 -0
  121. package/skills/wix-replatform/resources/rp-import-codegen/SKILL.md +1114 -0
  122. package/skills/wix-replatform/resources/rp-mapper/SKILL.md +430 -0
  123. package/skills/wix-replatform/resources/rp-mapper/lib/mapping-resolve.js +217 -0
  124. package/skills/wix-replatform/resources/rp-mapper/scripts/resolve-mapping.js +148 -0
  125. package/skills/wix-replatform/resources/rp-mapper/wix-business-solutions-taxonomy.md +378 -0
  126. package/skills/wix-replatform/resources/rp-setup-discovery/SKILL.md +183 -0
  127. package/skills/wix-replatform/resources/rp-source-csv/SKILL.md +478 -0
  128. package/skills/wix-replatform/resources/rp-source-csv/lib/canonical-record.js +136 -0
  129. package/skills/wix-replatform/resources/rp-source-csv/lib/csv-fileset.js +0 -0
  130. package/skills/wix-replatform/resources/rp-source-csv/lib/csv-fingerprint.js +310 -0
  131. package/skills/wix-replatform/resources/rp-source-csv/lib/csv-layout.js +1081 -0
  132. package/skills/wix-replatform/resources/rp-source-csv/lib/csv-parse.js +618 -0
  133. package/skills/wix-replatform/resources/rp-source-csv/scripts/csv-discovery.js +949 -0
  134. package/skills/wix-replatform/resources/rp-source-csv/source-schema.example.json +196 -0
  135. package/skills/wix-replatform/resources/rp-source-csv/vendors/bigcommerce.json +66 -0
  136. package/skills/wix-replatform/resources/rp-source-csv/vendors/magento.json +60 -0
  137. package/skills/wix-replatform/resources/rp-source-csv/vendors/shopify.json +95 -0
  138. package/skills/wix-replatform/resources/rp-source-csv/vendors/woocommerce.json +82 -0
  139. package/skills/wix-replatform/resources/rp-source-wordpress/SKILL.md +256 -0
  140. package/skills/wix-replatform/resources/rp-source-wordpress/lib/wp-http.js +249 -0
  141. package/skills/wix-replatform/resources/rp-source-wordpress/lib/wp-route-classifier.js +444 -0
  142. package/skills/wix-replatform/resources/rp-source-wordpress/scripts/wp-discovery.js +774 -0
  143. package/skills/wix-replatform/resources/rp-source-wordpress/source-schema.example.json +71 -0
  144. package/skills/wix-replatform/resources/rp-target-wix/SKILL.md +632 -0
  145. package/skills/wix-replatform/resources/rp-target-wix/SPEC-product-reviews-and-blog-authorship.md +330 -0
  146. package/skills/wix-replatform/resources/rp-target-wix/domains/README.md +21 -0
  147. package/skills/wix-replatform/resources/rp-target-wix/domains/blog/domain.json +19 -0
  148. package/skills/wix-replatform/resources/rp-target-wix/domains/blog/entities/category.json +37 -0
  149. package/skills/wix-replatform/resources/rp-target-wix/domains/blog/entities/comment.json +37 -0
  150. package/skills/wix-replatform/resources/rp-target-wix/domains/blog/entities/post.json +39 -0
  151. package/skills/wix-replatform/resources/rp-target-wix/domains/blog/entities/tag.json +35 -0
  152. package/skills/wix-replatform/resources/rp-target-wix/domains/cms/domain.json +14 -0
  153. package/skills/wix-replatform/resources/rp-target-wix/domains/cms/entities/collection.json +35 -0
  154. package/skills/wix-replatform/resources/rp-target-wix/domains/cms/entities/data-item.json +36 -0
  155. package/skills/wix-replatform/resources/rp-target-wix/domains/cms/entities/reference.json +35 -0
  156. package/skills/wix-replatform/resources/rp-target-wix/domains/crm/domain.json +14 -0
  157. package/skills/wix-replatform/resources/rp-target-wix/domains/crm/entities/contact.json +131 -0
  158. package/skills/wix-replatform/resources/rp-target-wix/domains/crm/entities/email-subscription.json +37 -0
  159. package/skills/wix-replatform/resources/rp-target-wix/domains/crm/entities/label.json +37 -0
  160. package/skills/wix-replatform/resources/rp-target-wix/domains/ecom/domain.json +21 -0
  161. package/skills/wix-replatform/resources/rp-target-wix/domains/ecom/entities/order-line-item.json +37 -0
  162. package/skills/wix-replatform/resources/rp-target-wix/domains/ecom/entities/order-refund.json +37 -0
  163. package/skills/wix-replatform/resources/rp-target-wix/domains/ecom/entities/order.json +97 -0
  164. package/skills/wix-replatform/resources/rp-target-wix/domains/index.json +528 -0
  165. package/skills/wix-replatform/resources/rp-target-wix/domains/media/domain.json +14 -0
  166. package/skills/wix-replatform/resources/rp-target-wix/domains/media/entities/media-file.json +38 -0
  167. package/skills/wix-replatform/resources/rp-target-wix/domains/media/entities/media-folder.json +37 -0
  168. package/skills/wix-replatform/resources/rp-target-wix/domains/members/domain.json +13 -0
  169. package/skills/wix-replatform/resources/rp-target-wix/domains/members/entities/badge.json +37 -0
  170. package/skills/wix-replatform/resources/rp-target-wix/domains/members/entities/member.json +53 -0
  171. package/skills/wix-replatform/resources/rp-target-wix/domains/schema.json +84 -0
  172. package/skills/wix-replatform/resources/rp-target-wix/domains/stores/domain.json +25 -0
  173. package/skills/wix-replatform/resources/rp-target-wix/domains/stores/entities/category.json +37 -0
  174. package/skills/wix-replatform/resources/rp-target-wix/domains/stores/entities/coupon.json +37 -0
  175. package/skills/wix-replatform/resources/rp-target-wix/domains/stores/entities/inventory-item.json +38 -0
  176. package/skills/wix-replatform/resources/rp-target-wix/domains/stores/entities/product-tag.json +37 -0
  177. package/skills/wix-replatform/resources/rp-target-wix/domains/stores/entities/product.json +90 -0
  178. package/skills/wix-replatform/resources/rp-target-wix/lib/audit-summary.js +64 -0
  179. package/skills/wix-replatform/resources/rp-target-wix/lib/contract-ledger.js +141 -0
  180. package/skills/wix-replatform/resources/rp-target-wix/lib/domain-knowledge.js +384 -0
  181. package/skills/wix-replatform/resources/rp-target-wix/lib/ndjson.js +260 -0
  182. package/skills/wix-replatform/resources/rp-target-wix/lib/stores-verification.js +238 -0
  183. package/skills/wix-replatform/resources/rp-target-wix/lib/wix-build.js +237 -0
  184. package/skills/wix-replatform/resources/rp-target-wix/lib/wix-target-spec.js +238 -0
  185. package/skills/wix-replatform/resources/rp-target-wix/lib/wix-writers.js +2219 -0
  186. package/skills/wix-replatform/resources/rp-target-wix/scripts/domain-knowledge-validate.js +31 -0
  187. package/skills/wix-replatform/resources/rp-target-wix/scripts/domain-knowledge.js +100 -0
  188. package/skills/wix-replatform/resources/rp-target-wix/scripts/verify-stores.js +107 -0
  189. package/skills/wix-replatform/resources/rp-telemetry/SKILL.md +344 -0
  190. package/skills/wix-replatform/resources/rp-telemetry/lib/bi-sink.js +250 -0
  191. package/skills/wix-replatform/resources/rp-telemetry/lib/telemetry-recorder.js +1927 -0
  192. package/skills/wix-replatform/resources/rp-telemetry/scripts/meter-from-audit.js +83 -0
  193. package/skills/wix-replatform/resources/rp-telemetry/scripts/rp-telemetry.js +141 -0
  194. package/skills/wix-replatform/scripts/artifact-freshness.js +76 -0
  195. package/skills/wix-replatform/scripts/execution-manifest-validate.js +43 -0
  196. package/skills/wix-replatform/scripts/execution-state-prepare.js +128 -0
  197. package/skills/wix-replatform/scripts/orchestration-preflight.js +48 -0
  198. package/skills/wix-replatform/scripts/orchestration-route.js +46 -0
  199. package/skills/wix-replatform/scripts/orchestration-state.js +245 -0
  200. package/skills/wix-vibe-headless/SKILL.md +49 -25
  201. package/skills/wix-vibe-headless/install/deploy.cjs +156 -0
  202. package/skills/wix-vibe-headless/install/pin-agents-md.cjs +34 -0
  203. package/skills/wix-vibe-headless/platforms/README.md +8 -4
  204. package/skills/wix-vibe-headless/platforms/base44.md +111 -101
  205. package/skills/wix-vibe-headless/platforms/generic.md +99 -64
  206. package/skills/wix-vibe-headless/references/blog/INSTRUCTIONS.md +226 -119
  207. package/skills/wix-vibe-headless/references/blog/app/components/PostCard.jsx +43 -0
  208. package/skills/wix-vibe-headless/references/blog/app/components/PostChips.jsx +25 -0
  209. package/skills/wix-vibe-headless/references/blog/app/components/PostGrid.jsx +15 -0
  210. package/skills/wix-vibe-headless/references/blog/app/context/TaxonomyContext.jsx +35 -0
  211. package/skills/wix-vibe-headless/references/blog/app/hooks/usePostDetail.js +38 -0
  212. package/skills/wix-vibe-headless/references/blog/app/pages/Blog.jsx +40 -0
  213. package/skills/wix-vibe-headless/references/blog/app/pages/CategoryPage.jsx +54 -0
  214. package/skills/wix-vibe-headless/references/blog/app/pages/PostDetail.jsx +65 -0
  215. package/skills/wix-vibe-headless/references/blog/app/pages/TagPage.jsx +50 -0
  216. package/skills/wix-vibe-headless/references/blog/seed/SEED.md +103 -0
  217. package/skills/wix-vibe-headless/references/blog/seed/seed-blog.js +270 -0
  218. package/skills/wix-vibe-headless/references/bookings/INSTRUCTIONS.md +256 -149
  219. package/skills/wix-vibe-headless/references/bookings/app/components/BookingForm.jsx +65 -0
  220. package/skills/wix-vibe-headless/references/bookings/app/components/ServiceCard.jsx +47 -0
  221. package/skills/wix-vibe-headless/references/bookings/app/components/ServiceGrid.jsx +13 -0
  222. package/skills/wix-vibe-headless/references/bookings/app/components/SlotPicker.jsx +126 -0
  223. package/skills/wix-vibe-headless/references/bookings/app/hooks/useServiceDetail.js +108 -0
  224. package/skills/wix-vibe-headless/references/bookings/app/hooks/useServices.js +58 -0
  225. package/skills/wix-vibe-headless/references/bookings/app/lib/serviceFacts.js +95 -0
  226. package/skills/wix-vibe-headless/references/bookings/app/pages/ServiceDetail.jsx +94 -0
  227. package/skills/wix-vibe-headless/references/bookings/app/pages/Services.jsx +89 -0
  228. package/skills/wix-vibe-headless/references/bookings/{wix-bookings-checkout.js → app/rest/wix-bookings-checkout.js} +1 -1
  229. package/skills/wix-vibe-headless/references/bookings/{wix-bookings-services.js → app/rest/wix-bookings-services.js} +87 -11
  230. package/skills/wix-vibe-headless/references/bookings/seed/SEED.md +117 -0
  231. package/skills/wix-vibe-headless/references/bookings/seed/seed-bookings.js +333 -0
  232. package/skills/wix-vibe-headless/references/cms/INSTRUCTIONS.md +168 -147
  233. package/skills/wix-vibe-headless/references/cms/app/collection.config.js +31 -0
  234. package/skills/wix-vibe-headless/references/cms/app/lib/wixImage.js +18 -0
  235. package/skills/wix-vibe-headless/references/cms/{wix-cms.js → app/rest/wix-cms.js} +47 -2
  236. package/skills/wix-vibe-headless/references/cms/seed/SEED.md +145 -0
  237. package/skills/wix-vibe-headless/references/events/INSTRUCTIONS.md +223 -131
  238. package/skills/wix-vibe-headless/references/events/app/components/CategoryFilter.jsx +23 -0
  239. package/skills/wix-vibe-headless/references/events/app/components/EventCard.jsx +43 -0
  240. package/skills/wix-vibe-headless/references/events/app/components/EventGrid.jsx +13 -0
  241. package/skills/wix-vibe-headless/references/events/app/components/EventRegistration.jsx +29 -0
  242. package/skills/wix-vibe-headless/references/events/app/components/RsvpForm.jsx +57 -0
  243. package/skills/wix-vibe-headless/references/events/app/components/TicketPicker.jsx +78 -0
  244. package/skills/wix-vibe-headless/references/events/app/hooks/useEventDetail.js +27 -0
  245. package/skills/wix-vibe-headless/references/events/app/hooks/useEventsList.js +54 -0
  246. package/skills/wix-vibe-headless/references/events/app/hooks/useRsvpForm.js +40 -0
  247. package/skills/wix-vibe-headless/references/events/app/hooks/useTicketing.js +81 -0
  248. package/skills/wix-vibe-headless/references/events/app/pages/EventDetail.jsx +48 -0
  249. package/skills/wix-vibe-headless/references/events/app/pages/Events.jsx +36 -0
  250. package/skills/wix-vibe-headless/references/events/{wix-events-browse.js → app/rest/wix-events-browse.js} +1 -1
  251. package/skills/wix-vibe-headless/references/events/seed/SEED.md +107 -0
  252. package/skills/wix-vibe-headless/references/events/seed/seed-events.js +251 -0
  253. package/skills/wix-vibe-headless/references/members/INSTRUCTIONS.md +272 -188
  254. package/skills/wix-vibe-headless/references/members/app/components/LoginForm.jsx +101 -0
  255. package/skills/wix-vibe-headless/references/members/app/components/MemberMenu.jsx +33 -0
  256. package/skills/wix-vibe-headless/references/members/app/components/RequireAuth.jsx +21 -0
  257. package/skills/wix-vibe-headless/references/members/app/components/SocialButtons.jsx +29 -0
  258. package/skills/wix-vibe-headless/references/members/app/context/MemberContext.jsx +54 -0
  259. package/skills/wix-vibe-headless/references/members/app/hooks/useLoginForm.js +77 -0
  260. package/skills/wix-vibe-headless/references/members/app/pages/Account.jsx +36 -0
  261. package/skills/wix-vibe-headless/references/members/app/pages/Callback.jsx +32 -0
  262. package/skills/wix-vibe-headless/references/members/app/pages/Login.jsx +35 -0
  263. package/skills/wix-vibe-headless/references/members/{wix-members-auth.js → app/rest/wix-members-auth.js} +6 -3
  264. package/skills/wix-vibe-headless/references/members/install/Register.jsx +22 -0
  265. package/skills/wix-vibe-headless/references/members/seed/SEED.md +22 -0
  266. package/skills/wix-vibe-headless/references/portfolio/INSTRUCTIONS.md +229 -104
  267. package/skills/wix-vibe-headless/references/portfolio/app/components/CollectionCard.jsx +31 -0
  268. package/skills/wix-vibe-headless/references/portfolio/app/components/CollectionGrid.jsx +15 -0
  269. package/skills/wix-vibe-headless/references/portfolio/app/components/ProjectCard.jsx +39 -0
  270. package/skills/wix-vibe-headless/references/portfolio/app/components/ProjectGrid.jsx +15 -0
  271. package/skills/wix-vibe-headless/references/portfolio/app/components/ProjectMedia.jsx +29 -0
  272. package/skills/wix-vibe-headless/references/portfolio/app/hooks/useCollectionProjects.js +35 -0
  273. package/skills/wix-vibe-headless/references/portfolio/app/hooks/usePortfolioGallery.js +27 -0
  274. package/skills/wix-vibe-headless/references/portfolio/app/hooks/useProjectDetail.js +25 -0
  275. package/skills/wix-vibe-headless/references/portfolio/app/pages/CollectionPage.jsx +39 -0
  276. package/skills/wix-vibe-headless/references/portfolio/app/pages/Portfolio.jsx +27 -0
  277. package/skills/wix-vibe-headless/references/portfolio/app/pages/ProjectDetail.jsx +60 -0
  278. package/skills/wix-vibe-headless/references/portfolio/seed/SEED.md +94 -0
  279. package/skills/wix-vibe-headless/references/portfolio/seed/seed-portfolio.js +236 -0
  280. package/skills/wix-vibe-headless/references/pricing-plans/INSTRUCTIONS.md +236 -117
  281. package/skills/wix-vibe-headless/references/pricing-plans/app/components/OrderCard.jsx +35 -0
  282. package/skills/wix-vibe-headless/references/pricing-plans/app/components/PlanCard.jsx +48 -0
  283. package/skills/wix-vibe-headless/references/pricing-plans/app/components/PlanGrid.jsx +16 -0
  284. package/skills/wix-vibe-headless/references/pricing-plans/app/components/PlanPrice.jsx +35 -0
  285. package/skills/wix-vibe-headless/references/pricing-plans/app/hooks/useMyPlans.js +25 -0
  286. package/skills/wix-vibe-headless/references/pricing-plans/app/hooks/usePlanDetail.js +28 -0
  287. package/skills/wix-vibe-headless/references/pricing-plans/app/hooks/usePlans.js +30 -0
  288. package/skills/wix-vibe-headless/references/pricing-plans/app/pages/MyPlans.jsx +30 -0
  289. package/skills/wix-vibe-headless/references/pricing-plans/app/pages/PlanDetail.jsx +53 -0
  290. package/skills/wix-vibe-headless/references/pricing-plans/app/pages/Plans.jsx +28 -0
  291. package/skills/wix-vibe-headless/references/pricing-plans/seed/SEED.md +86 -0
  292. package/skills/wix-vibe-headless/references/pricing-plans/seed/seed-pricing-plans.js +251 -0
  293. package/skills/wix-vibe-headless/references/restaurants/INSTRUCTIONS.md +244 -124
  294. package/skills/wix-vibe-headless/references/restaurants/app/components/ItemDialog.jsx +81 -0
  295. package/skills/wix-vibe-headless/references/restaurants/app/components/MenuItemCard.jsx +71 -0
  296. package/skills/wix-vibe-headless/references/restaurants/app/components/MenuList.jsx +43 -0
  297. package/skills/wix-vibe-headless/references/restaurants/app/components/OrderCartButton.jsx +21 -0
  298. package/skills/wix-vibe-headless/references/restaurants/app/components/OrderCartDrawer.jsx +60 -0
  299. package/skills/wix-vibe-headless/references/restaurants/app/context/OrderCartContext.jsx +63 -0
  300. package/skills/wix-vibe-headless/references/restaurants/app/hooks/useItemOrder.js +32 -0
  301. package/skills/wix-vibe-headless/references/restaurants/app/hooks/useReservation.js +73 -0
  302. package/skills/wix-vibe-headless/references/restaurants/app/pages/Menu.jsx +28 -0
  303. package/skills/wix-vibe-headless/references/restaurants/app/pages/Reservations.jsx +102 -0
  304. package/skills/wix-vibe-headless/references/restaurants/seed/SEED.md +180 -0
  305. package/skills/wix-vibe-headless/references/restaurants/seed/seed-restaurants.js +452 -0
  306. package/skills/wix-vibe-headless/references/shared/app/components/WixManageBanner.jsx +56 -0
  307. package/skills/wix-vibe-headless/references/shared/{wix-client.js → app/rest/wix-client.js} +6 -8
  308. package/skills/wix-vibe-headless/references/shared/app/rest/wix-config.js +8 -0
  309. package/skills/wix-vibe-headless/references/storefront/INSTRUCTIONS.md +259 -157
  310. package/skills/wix-vibe-headless/references/storefront/app/components/CartButton.jsx +20 -0
  311. package/skills/wix-vibe-headless/references/storefront/app/components/CartDrawer.jsx +150 -0
  312. package/skills/wix-vibe-headless/references/storefront/app/components/ProductCard.jsx +167 -0
  313. package/skills/wix-vibe-headless/references/storefront/app/components/ProductGallery.jsx +51 -0
  314. package/skills/wix-vibe-headless/references/storefront/app/components/ProductGrid.jsx +54 -0
  315. package/skills/wix-vibe-headless/references/storefront/app/components/VariantPicker.jsx +119 -0
  316. package/skills/wix-vibe-headless/references/storefront/app/context/CartContext.jsx +71 -0
  317. package/skills/wix-vibe-headless/references/storefront/app/hooks/useProductDetail.js +109 -0
  318. package/skills/wix-vibe-headless/references/storefront/app/hooks/useShop.js +98 -0
  319. package/skills/wix-vibe-headless/references/storefront/app/lib/storeImage.js +27 -0
  320. package/skills/wix-vibe-headless/references/storefront/app/pages/ProductDetail.jsx +139 -0
  321. package/skills/wix-vibe-headless/references/storefront/app/pages/Shop.jsx +75 -0
  322. package/skills/wix-vibe-headless/references/storefront/{wix-store-cart.js → app/rest/wix-store-cart.js} +1 -1
  323. package/skills/wix-vibe-headless/references/storefront/{wix-store-catalog.js → app/rest/wix-store-catalog.js} +20 -1
  324. package/skills/wix-vibe-headless/references/storefront/seed/SEED.md +111 -0
  325. package/skills/wix-vibe-headless/references/storefront/seed/seed-store.js +338 -0
  326. /package/skills/wix-vibe-headless/references/blog/{wix-blog.js → app/rest/wix-blog.js} +0 -0
  327. /package/skills/wix-vibe-headless/references/events/{wix-events-registration.js → app/rest/wix-events-registration.js} +0 -0
  328. /package/skills/wix-vibe-headless/references/portfolio/{wix-portfolio.js → app/rest/wix-portfolio.js} +0 -0
  329. /package/skills/wix-vibe-headless/references/pricing-plans/{wix-pricing-plans.js → app/rest/wix-pricing-plans.js} +0 -0
  330. /package/skills/wix-vibe-headless/references/restaurants/{wix-restaurants-menu.js → app/rest/wix-restaurants-menu.js} +0 -0
  331. /package/skills/wix-vibe-headless/references/restaurants/{wix-restaurants-ordering.js → app/rest/wix-restaurants-ordering.js} +0 -0
  332. /package/skills/wix-vibe-headless/references/restaurants/{wix-restaurants-reservations.js → app/rest/wix-restaurants-reservations.js} +0 -0
@@ -0,0 +1,455 @@
1
+ 'use strict';
2
+
3
+ const fs = require('node:fs/promises');
4
+ const path = require('node:path');
5
+ const crypto = require('node:crypto');
6
+
7
+ const SCHEMA_VERSION = 1;
8
+
9
+ const RUN_STATUS = new Set(['running', 'completed', 'partial', 'blocked', 'failed']);
10
+ const ACTIVE_PHASE = new Set(['orchestration', 'discovery', 'mapping', 'setup', 'codegen', 'execution']);
11
+ const ORCHESTRATION_STATES = new Set([
12
+ 'initialized',
13
+ 'awaiting_source',
14
+ 'awaiting_import_scope',
15
+ 'awaiting_credentials',
16
+ 'awaiting_files',
17
+ 'awaiting_destination_strategy',
18
+ 'preflight_running',
19
+ 'preflight_blocked',
20
+ 'discovery_running',
21
+ 'discovery_complete',
22
+ 'mapping_running',
23
+ 'awaiting_mapping_approval',
24
+ 'mapping_approved',
25
+ 'setup_discovery_running',
26
+ 'setup_complete',
27
+ 'codegen_running',
28
+ 'awaiting_execution_approval',
29
+ 'execution_approved',
30
+ 'executing_setup',
31
+ 'executing_import',
32
+ 'completed',
33
+ 'partial',
34
+ 'blocked',
35
+ 'failed',
36
+ ]);
37
+ const PHASE_STATUS = new Set(['not_started', 'running', 'complete', 'partial', 'blocked', 'failed']);
38
+ const EXECUTION_ITEM_STATUS = new Set(['not_started', 'running', 'complete', 'partial', 'blocked', 'failed', 'skipped']);
39
+ const APPROVAL_STATUS = new Set(['pending', 'approved', 'rejected', 'provisional']);
40
+ const APPROVAL_ACTOR = new Set(['user', 'system', null]);
41
+ const DECISION_SOURCE = new Set(['user', 'deterministic_inference', 'prior_artifact']);
42
+
43
+ function nowIso(date = new Date()) {
44
+ return date.toISOString();
45
+ }
46
+
47
+ function randomId(prefix) {
48
+ return `${prefix}_${crypto.randomUUID()}`;
49
+ }
50
+
51
+ function orchestrationDir(projectDir) {
52
+ return path.join(projectDir, 'orchestration');
53
+ }
54
+
55
+ function phaseStatusTemplate(timestamp) {
56
+ return {
57
+ status: 'not_started',
58
+ lastCompletedStep: null,
59
+ artifactRefs: [],
60
+ updatedAt: timestamp,
61
+ };
62
+ }
63
+
64
+ function executionStatusTemplate(timestamp) {
65
+ return {
66
+ ...phaseStatusTemplate(timestamp),
67
+ setupStatus: 'not_started',
68
+ importStatus: 'not_started',
69
+ lastCheckpointId: null,
70
+ };
71
+ }
72
+
73
+ function createRun(projectId, timestamp = nowIso()) {
74
+ return {
75
+ schemaVersion: SCHEMA_VERSION,
76
+ projectId,
77
+ status: 'running',
78
+ currentState: 'initialized',
79
+ activePhase: 'orchestration',
80
+ startedAt: timestamp,
81
+ updatedAt: timestamp,
82
+ sourcePlatform: null,
83
+ sourceMode: null,
84
+ resumeFrom: null,
85
+ needsUserInput: false,
86
+ needsLlm: false,
87
+ lastEventId: null,
88
+ };
89
+ }
90
+
91
+ function createCheckpoints(timestamp = nowIso()) {
92
+ return {
93
+ schemaVersion: SCHEMA_VERSION,
94
+ discovery: phaseStatusTemplate(timestamp),
95
+ mapping: phaseStatusTemplate(timestamp),
96
+ setup: phaseStatusTemplate(timestamp),
97
+ codegen: phaseStatusTemplate(timestamp),
98
+ execution: executionStatusTemplate(timestamp),
99
+ };
100
+ }
101
+
102
+ function createApprovals() {
103
+ return {
104
+ schemaVersion: SCHEMA_VERSION,
105
+ mapping: {
106
+ status: 'pending',
107
+ decidedAt: null,
108
+ artifactRefs: [],
109
+ notes: null,
110
+ decidedBy: null,
111
+ },
112
+ execution: {
113
+ status: 'pending',
114
+ decidedAt: null,
115
+ artifactRefs: [],
116
+ notes: null,
117
+ decidedBy: null,
118
+ },
119
+ };
120
+ }
121
+
122
+ function createDecisions() {
123
+ return {
124
+ schemaVersion: SCHEMA_VERSION,
125
+ };
126
+ }
127
+
128
+ function createPreflight(timestamp = nowIso()) {
129
+ return {
130
+ schemaVersion: SCHEMA_VERSION,
131
+ status: 'not_started',
132
+ updatedAt: timestamp,
133
+ checks: [],
134
+ };
135
+ }
136
+
137
+ async function mkdirp(dirPath) {
138
+ await fs.mkdir(dirPath, { recursive: true });
139
+ }
140
+
141
+ async function writeJsonAtomic(filePath, data) {
142
+ const dirPath = path.dirname(filePath);
143
+ await mkdirp(dirPath);
144
+ const tempPath = `${filePath}.${process.pid}.${Date.now()}.tmp`;
145
+ await fs.writeFile(tempPath, `${JSON.stringify(data, null, 2)}\n`, 'utf8');
146
+ await fs.rename(tempPath, filePath);
147
+ }
148
+
149
+ async function readJson(filePath) {
150
+ const raw = await fs.readFile(filePath, 'utf8');
151
+ return JSON.parse(raw);
152
+ }
153
+
154
+ async function maybeReadJson(filePath) {
155
+ try {
156
+ return await readJson(filePath);
157
+ } catch (error) {
158
+ if (error && error.code === 'ENOENT') {
159
+ return null;
160
+ }
161
+ throw error;
162
+ }
163
+ }
164
+
165
+ function reasonRef(code, message, artifactRefs = []) {
166
+ return { code, message, artifactRefs };
167
+ }
168
+
169
+ function pushError(errors, code, message) {
170
+ errors.push(reasonRef(code, message));
171
+ }
172
+
173
+ function requireSetMember(errors, code, value, allowed, label) {
174
+ if (!allowed.has(value)) {
175
+ pushError(errors, code, `${label} must be one of: ${Array.from(allowed).join(', ')} (got: ${value})`);
176
+ }
177
+ }
178
+
179
+ function isAwaitingState(state) {
180
+ return typeof state === 'string' && state.startsWith('awaiting_');
181
+ }
182
+
183
+ function validateRun(run, errors) {
184
+ if (!run || typeof run !== 'object') {
185
+ pushError(errors, 'run_missing', 'run.json is missing or not an object');
186
+ return;
187
+ }
188
+ if (run.schemaVersion !== SCHEMA_VERSION) {
189
+ pushError(errors, 'run_schema_version', `run.json schemaVersion must be ${SCHEMA_VERSION}`);
190
+ }
191
+ if (!run.projectId || typeof run.projectId !== 'string') {
192
+ pushError(errors, 'run_project_id', 'run.json projectId must be a non-empty string');
193
+ }
194
+ requireSetMember(errors, 'run_status', run.status, RUN_STATUS, 'run.json status');
195
+ requireSetMember(errors, 'run_current_state', run.currentState, ORCHESTRATION_STATES, 'run.json currentState');
196
+ requireSetMember(errors, 'run_active_phase', run.activePhase, ACTIVE_PHASE, 'run.json activePhase');
197
+ if (run.resumeFrom !== null && typeof run.resumeFrom !== 'object') {
198
+ pushError(errors, 'run_resume_from', 'run.json resumeFrom must be null or a reasonRef object');
199
+ }
200
+ if ((isAwaitingState(run.currentState) || run.currentState === 'blocked') && run.needsUserInput !== true) {
201
+ pushError(errors, 'run_needs_user_input', 'needsUserInput must be true for awaiting_* and blocked states');
202
+ }
203
+ }
204
+
205
+ function validateCheckpoints(checkpoints, errors) {
206
+ if (!checkpoints || typeof checkpoints !== 'object') {
207
+ pushError(errors, 'checkpoints_missing', 'checkpoints.json is missing or not an object');
208
+ return;
209
+ }
210
+ if (checkpoints.schemaVersion !== SCHEMA_VERSION) {
211
+ pushError(errors, 'checkpoints_schema_version', `checkpoints.json schemaVersion must be ${SCHEMA_VERSION}`);
212
+ }
213
+ for (const phase of ['discovery', 'mapping', 'setup', 'codegen']) {
214
+ const item = checkpoints[phase];
215
+ if (!item || typeof item !== 'object') {
216
+ pushError(errors, `checkpoint_${phase}_missing`, `${phase} checkpoint is missing`);
217
+ continue;
218
+ }
219
+ requireSetMember(errors, `checkpoint_${phase}_status`, item.status, PHASE_STATUS, `${phase} checkpoint status`);
220
+ if (!Array.isArray(item.artifactRefs)) {
221
+ pushError(errors, `checkpoint_${phase}_artifact_refs`, `${phase} checkpoint artifactRefs must be an array`);
222
+ }
223
+ }
224
+ const execution = checkpoints.execution;
225
+ if (!execution || typeof execution !== 'object') {
226
+ pushError(errors, 'checkpoint_execution_missing', 'execution checkpoint is missing');
227
+ return;
228
+ }
229
+ requireSetMember(errors, 'checkpoint_execution_status', execution.status, PHASE_STATUS, 'execution checkpoint status');
230
+ requireSetMember(errors, 'checkpoint_execution_setup_status', execution.setupStatus, EXECUTION_ITEM_STATUS, 'execution.setupStatus');
231
+ requireSetMember(errors, 'checkpoint_execution_import_status', execution.importStatus, EXECUTION_ITEM_STATUS, 'execution.importStatus');
232
+ }
233
+
234
+ function validateApprovals(approvals, errors) {
235
+ if (!approvals || typeof approvals !== 'object') {
236
+ pushError(errors, 'approvals_missing', 'approvals.json is missing or not an object');
237
+ return;
238
+ }
239
+ if (approvals.schemaVersion !== SCHEMA_VERSION) {
240
+ pushError(errors, 'approvals_schema_version', `approvals.json schemaVersion must be ${SCHEMA_VERSION}`);
241
+ }
242
+ for (const approvalType of ['mapping', 'execution']) {
243
+ const item = approvals[approvalType];
244
+ if (!item || typeof item !== 'object') {
245
+ pushError(errors, `approval_${approvalType}_missing`, `${approvalType} approval is missing`);
246
+ continue;
247
+ }
248
+ requireSetMember(errors, `approval_${approvalType}_status`, item.status, APPROVAL_STATUS, `${approvalType} approval status`);
249
+ requireSetMember(errors, `approval_${approvalType}_decided_by`, item.decidedBy, APPROVAL_ACTOR, `${approvalType} approval decidedBy`);
250
+ if (!Array.isArray(item.artifactRefs)) {
251
+ pushError(errors, `approval_${approvalType}_artifact_refs`, `${approvalType} approval artifactRefs must be an array`);
252
+ }
253
+ if (approvalType === 'execution' && item.status === 'provisional') {
254
+ pushError(errors, 'approval_execution_provisional', 'execution approval must not be provisional');
255
+ }
256
+ }
257
+ }
258
+
259
+ function validateDecisions(decisions, errors) {
260
+ if (!decisions || typeof decisions !== 'object') {
261
+ pushError(errors, 'decisions_missing', 'decisions.json is missing or not an object');
262
+ return;
263
+ }
264
+ if (decisions.schemaVersion !== SCHEMA_VERSION) {
265
+ pushError(errors, 'decisions_schema_version', `decisions.json schemaVersion must be ${SCHEMA_VERSION}`);
266
+ }
267
+ for (const [key, value] of Object.entries(decisions)) {
268
+ if (key === 'schemaVersion') {
269
+ continue;
270
+ }
271
+ if (!value || typeof value !== 'object') {
272
+ pushError(errors, 'decision_entry_invalid', `decision ${key} must be an object`);
273
+ continue;
274
+ }
275
+ requireSetMember(errors, `decision_${key}_source`, value.source, DECISION_SOURCE, `decision ${key} source`);
276
+ }
277
+ }
278
+
279
+ function validateCrossArtifactInvariants(artifacts, errors) {
280
+ const { run, checkpoints, approvals } = artifacts;
281
+ if (!run || !checkpoints || !approvals) {
282
+ return;
283
+ }
284
+ if (run.currentState === 'preflight_running' || run.currentState === 'preflight_blocked' || run.currentState === 'awaiting_destination_strategy') {
285
+ if (run.activePhase !== 'orchestration') {
286
+ pushError(errors, 'state_phase_preflight', `${run.currentState} requires activePhase=orchestration`);
287
+ }
288
+ }
289
+ if (run.currentState === 'mapping_running' && checkpoints.mapping.status === 'not_started') {
290
+ pushError(errors, 'state_mapping_checkpoint', 'mapping_running requires mapping checkpoint status to be started');
291
+ }
292
+ if (run.currentState === 'awaiting_mapping_approval' && approvals.mapping.status !== 'pending') {
293
+ pushError(errors, 'state_mapping_approval_pending', 'awaiting_mapping_approval requires approvals.mapping.status=pending');
294
+ }
295
+ if (run.currentState === 'mapping_approved' && !['approved', 'provisional'].includes(approvals.mapping.status)) {
296
+ pushError(errors, 'state_mapping_approved', 'mapping_approved requires approvals.mapping.status=approved|provisional');
297
+ }
298
+ if (run.currentState === 'awaiting_execution_approval' && approvals.execution.status !== 'pending') {
299
+ pushError(errors, 'state_execution_approval_pending', 'awaiting_execution_approval requires approvals.execution.status=pending');
300
+ }
301
+ if (['execution_approved', 'executing_setup', 'executing_import', 'completed'].includes(run.currentState) &&
302
+ approvals.execution.status !== 'approved') {
303
+ pushError(errors, 'state_execution_approved', `${run.currentState} requires approvals.execution.status=approved`);
304
+ }
305
+ }
306
+
307
+ function validateArtifacts(artifacts) {
308
+ const errors = [];
309
+ validateRun(artifacts.run, errors);
310
+ validateCheckpoints(artifacts.checkpoints, errors);
311
+ validateApprovals(artifacts.approvals, errors);
312
+ validateDecisions(artifacts.decisions, errors);
313
+ validateCrossArtifactInvariants(artifacts, errors);
314
+ return {
315
+ ok: errors.length === 0,
316
+ errors,
317
+ };
318
+ }
319
+
320
+ async function appendEvent(projectDir, event) {
321
+ const dirPath = orchestrationDir(projectDir);
322
+ await mkdirp(dirPath);
323
+ const filePath = path.join(dirPath, 'events.jsonl');
324
+ const line = `${JSON.stringify({ schemaVersion: SCHEMA_VERSION, ...event })}\n`;
325
+ await fs.appendFile(filePath, line, 'utf8');
326
+ }
327
+
328
+ async function initArtifacts(projectDir, { projectId = path.basename(projectDir), timestamp = nowIso() } = {}) {
329
+ const dirPath = orchestrationDir(projectDir);
330
+ await mkdirp(dirPath);
331
+ const run = createRun(projectId, timestamp);
332
+ const checkpoints = createCheckpoints(timestamp);
333
+ const decisions = createDecisions();
334
+ const approvals = createApprovals();
335
+ const preflight = createPreflight(timestamp);
336
+ await writeJsonAtomic(path.join(dirPath, 'run.json'), run);
337
+ await writeJsonAtomic(path.join(dirPath, 'checkpoints.json'), checkpoints);
338
+ await writeJsonAtomic(path.join(dirPath, 'decisions.json'), decisions);
339
+ await writeJsonAtomic(path.join(dirPath, 'approvals.json'), approvals);
340
+ await writeJsonAtomic(path.join(dirPath, 'preflight.json'), preflight);
341
+ const eventId = randomId('evt');
342
+ await appendEvent(projectDir, {
343
+ id: eventId,
344
+ timestamp,
345
+ phase: 'orchestration',
346
+ state: 'initialized',
347
+ type: 'orchestration.initialized',
348
+ payload: { projectId },
349
+ });
350
+ run.lastEventId = eventId;
351
+ await writeJsonAtomic(path.join(dirPath, 'run.json'), run);
352
+ return loadArtifacts(projectDir);
353
+ }
354
+
355
+ async function loadArtifacts(projectDir) {
356
+ const dirPath = orchestrationDir(projectDir);
357
+ return {
358
+ run: await maybeReadJson(path.join(dirPath, 'run.json')),
359
+ checkpoints: await maybeReadJson(path.join(dirPath, 'checkpoints.json')),
360
+ decisions: await maybeReadJson(path.join(dirPath, 'decisions.json')),
361
+ approvals: await maybeReadJson(path.join(dirPath, 'approvals.json')),
362
+ preflight: await maybeReadJson(path.join(dirPath, 'preflight.json')),
363
+ };
364
+ }
365
+
366
+ function updateDecisionObject(decisions, key, value, { source = 'user', rationale = null, timestamp = nowIso() } = {}) {
367
+ if (!DECISION_SOURCE.has(source)) {
368
+ throw new Error(`invalid decision source: ${source}`);
369
+ }
370
+ decisions[key] = {
371
+ value,
372
+ decidedAt: timestamp,
373
+ source,
374
+ rationale,
375
+ };
376
+ return decisions;
377
+ }
378
+
379
+ function updateApprovalObject(approvals, approvalType, status, { artifactRefs = [], notes = null, decidedBy = 'user', timestamp = nowIso() } = {}) {
380
+ if (!approvals[approvalType]) {
381
+ throw new Error(`unknown approval type: ${approvalType}`);
382
+ }
383
+ if (!APPROVAL_STATUS.has(status)) {
384
+ throw new Error(`invalid approval status: ${status}`);
385
+ }
386
+ if (approvalType === 'execution' && status === 'provisional') {
387
+ throw new Error('execution approval cannot be provisional');
388
+ }
389
+ approvals[approvalType] = {
390
+ status,
391
+ decidedAt: status === 'pending' ? null : timestamp,
392
+ artifactRefs,
393
+ notes,
394
+ decidedBy: status === 'pending' ? null : decidedBy,
395
+ };
396
+ return approvals;
397
+ }
398
+
399
+ function updateCheckpointObject(checkpoints, phase, patch, timestamp = nowIso()) {
400
+ if (!checkpoints[phase]) {
401
+ throw new Error(`unknown checkpoint phase: ${phase}`);
402
+ }
403
+ checkpoints[phase] = {
404
+ ...checkpoints[phase],
405
+ ...patch,
406
+ updatedAt: timestamp,
407
+ };
408
+ return checkpoints;
409
+ }
410
+
411
+ function transitionRun(run, { state, activePhase, status = run.status, needsUserInput = run.needsUserInput, needsLlm = run.needsLlm, resumeFrom = run.resumeFrom, timestamp = nowIso() }) {
412
+ if (!ORCHESTRATION_STATES.has(state)) {
413
+ throw new Error(`invalid state: ${state}`);
414
+ }
415
+ if (!ACTIVE_PHASE.has(activePhase)) {
416
+ throw new Error(`invalid active phase: ${activePhase}`);
417
+ }
418
+ if (!RUN_STATUS.has(status)) {
419
+ throw new Error(`invalid run status: ${status}`);
420
+ }
421
+ return {
422
+ ...run,
423
+ currentState: state,
424
+ activePhase,
425
+ status,
426
+ needsUserInput,
427
+ needsLlm,
428
+ resumeFrom,
429
+ updatedAt: timestamp,
430
+ };
431
+ }
432
+
433
+ module.exports = {
434
+ SCHEMA_VERSION,
435
+ orchestrationDir,
436
+ nowIso,
437
+ randomId,
438
+ reasonRef,
439
+ createRun,
440
+ createCheckpoints,
441
+ createApprovals,
442
+ createDecisions,
443
+ createPreflight,
444
+ writeJsonAtomic,
445
+ readJson,
446
+ maybeReadJson,
447
+ loadArtifacts,
448
+ initArtifacts,
449
+ validateArtifacts,
450
+ appendEvent,
451
+ updateDecisionObject,
452
+ updateApprovalObject,
453
+ updateCheckpointObject,
454
+ transitionRun,
455
+ };
@@ -0,0 +1,224 @@
1
+ 'use strict';
2
+
3
+ const fs = require('node:fs');
4
+ const path = require('node:path');
5
+ const crypto = require('node:crypto');
6
+
7
+ const RUNNING_EVENTS = new Set(['start', 'progress', 'heartbeat', 'warning']);
8
+
9
+ function slugify(value) {
10
+ return String(value || 'script')
11
+ .toLowerCase()
12
+ .replace(/[^a-z0-9]+/g, '-')
13
+ .replace(/^-+|-+$/g, '') || 'script';
14
+ }
15
+
16
+ function defaultRunId(script) {
17
+ return `${slugify(script)}-${Date.now()}-${crypto.randomBytes(2).toString('hex')}`;
18
+ }
19
+
20
+ function parseProgressArgs(argv, env = process.env) {
21
+ const args = [];
22
+ const progress = {
23
+ progressLog: env.PROGRESS_LOG || null,
24
+ runId: env.RUN_ID || null,
25
+ parentRunId: env.PARENT_RUN_ID || null,
26
+ };
27
+
28
+ for (let i = 0; i < argv.length; i += 1) {
29
+ const arg = argv[i];
30
+ if (arg === '--progress-log') {
31
+ progress.progressLog = argv[i + 1];
32
+ i += 1;
33
+ } else if (arg === '--run-id') {
34
+ progress.runId = argv[i + 1];
35
+ i += 1;
36
+ } else if (arg === '--parent-run-id') {
37
+ progress.parentRunId = argv[i + 1];
38
+ i += 1;
39
+ } else {
40
+ args.push(arg);
41
+ }
42
+ }
43
+
44
+ return { args, progress };
45
+ }
46
+
47
+ function statusForEvent(event) {
48
+ if (event === 'complete') {
49
+ return 'completed';
50
+ }
51
+ if (event === 'error') {
52
+ return 'failed';
53
+ }
54
+ if (RUNNING_EVENTS.has(event)) {
55
+ return 'running';
56
+ }
57
+ throw new Error(`unknown progress event: ${event}`);
58
+ }
59
+
60
+ function createProgressLogger(options = {}) {
61
+ const progressLog = options.progressLog || null;
62
+ const script = options.script || 'script';
63
+ const runId = options.runId || defaultRunId(script);
64
+ const parentRunId = options.parentRunId || null;
65
+ const heartbeatIntervalMs = options.heartbeatIntervalMs || 30000;
66
+
67
+ let seq = 0;
68
+ let started = false;
69
+ let terminal = false;
70
+ let lastProgressAt = 0;
71
+ let heartbeatTimer = null;
72
+ let heartbeatContext = null;
73
+
74
+ function enabled() {
75
+ return Boolean(progressLog);
76
+ }
77
+
78
+ function append(event, message, fields = {}) {
79
+ if (!enabled()) {
80
+ return null;
81
+ }
82
+ fs.mkdirSync(path.dirname(progressLog), { recursive: true });
83
+ seq += 1;
84
+ const record = {
85
+ ts: new Date().toISOString(),
86
+ runId,
87
+ ...(parentRunId ? { parentRunId } : {}),
88
+ script,
89
+ event,
90
+ status: statusForEvent(event),
91
+ seq,
92
+ ...fields,
93
+ message: String(message || event),
94
+ };
95
+ fs.appendFileSync(progressLog, `${JSON.stringify(record)}\n`, { encoding: 'utf8', flag: 'a' });
96
+ if (event !== 'heartbeat') {
97
+ lastProgressAt = Date.now();
98
+ }
99
+ if (event === 'start') {
100
+ started = true;
101
+ }
102
+ if (event === 'complete' || event === 'error') {
103
+ terminal = true;
104
+ stopHeartbeat();
105
+ }
106
+ return record;
107
+ }
108
+
109
+ function start(message, fields = {}) {
110
+ return append('start', message, fields);
111
+ }
112
+
113
+ function progress(message, fields = {}) {
114
+ return append('progress', message, fields);
115
+ }
116
+
117
+ function heartbeat(message, fields = {}) {
118
+ return append('heartbeat', message, fields);
119
+ }
120
+
121
+ function warn(message, fields = {}) {
122
+ return append('warning', message, fields);
123
+ }
124
+
125
+ function error(message, fields = {}) {
126
+ return append('error', message, fields);
127
+ }
128
+
129
+ function complete(message, fields = {}) {
130
+ return append('complete', message, fields);
131
+ }
132
+
133
+ function startHeartbeat(fields = {}) {
134
+ if (!enabled() || heartbeatTimer) {
135
+ return;
136
+ }
137
+ heartbeatContext = fields;
138
+ heartbeatTimer = setInterval(() => {
139
+ if (terminal) {
140
+ stopHeartbeat();
141
+ return;
142
+ }
143
+ const elapsed = Date.now() - lastProgressAt;
144
+ if (elapsed >= heartbeatIntervalMs) {
145
+ heartbeat(fields.message || 'Still running', fields);
146
+ }
147
+ }, Math.max(1000, Math.min(heartbeatIntervalMs, 5000)));
148
+ heartbeatTimer.unref?.();
149
+ }
150
+
151
+ function stopHeartbeat() {
152
+ if (heartbeatTimer) {
153
+ clearInterval(heartbeatTimer);
154
+ heartbeatTimer = null;
155
+ heartbeatContext = null;
156
+ }
157
+ }
158
+
159
+ async function withHeartbeat(fields, fn) {
160
+ startHeartbeat(fields);
161
+ try {
162
+ return await fn();
163
+ } finally {
164
+ stopHeartbeat();
165
+ }
166
+ }
167
+
168
+ function childEnv(extra = {}) {
169
+ return {
170
+ ...extra,
171
+ ...(progressLog ? { PROGRESS_LOG: progressLog, PARENT_RUN_ID: runId } : {}),
172
+ };
173
+ }
174
+
175
+ function installTerminalHandlers() {
176
+ if (!enabled()) {
177
+ return;
178
+ }
179
+ process.on('exit', (code) => {
180
+ if (started && !terminal && code !== 0) {
181
+ append('error', `Process exited before writing a terminal progress record`, {
182
+ exitCode: code,
183
+ ...(heartbeatContext || {}),
184
+ });
185
+ }
186
+ });
187
+ process.on('uncaughtException', (err) => {
188
+ if (started && !terminal) {
189
+ error(err && err.message ? err.message : 'Uncaught exception', { errorName: err && err.name });
190
+ }
191
+ throw err;
192
+ });
193
+ process.on('unhandledRejection', (reason) => {
194
+ if (started && !terminal) {
195
+ error(reason && reason.message ? reason.message : 'Unhandled rejection', { errorName: reason && reason.name });
196
+ }
197
+ });
198
+ }
199
+
200
+ installTerminalHandlers();
201
+
202
+ return {
203
+ progressLog,
204
+ script,
205
+ runId,
206
+ parentRunId,
207
+ enabled,
208
+ start,
209
+ progress,
210
+ heartbeat,
211
+ warn,
212
+ error,
213
+ complete,
214
+ startHeartbeat,
215
+ stopHeartbeat,
216
+ withHeartbeat,
217
+ childEnv,
218
+ };
219
+ }
220
+
221
+ module.exports = {
222
+ createProgressLogger,
223
+ parseProgressArgs,
224
+ };