@wix/agent-skills 1.33.1 → 1.35.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 (619) hide show
  1. package/README.md +3 -0
  2. package/package.json +1 -1
  3. package/skills/wix-export/SKILL.md +83 -0
  4. package/skills/wix-harmony-editor/.publish-manifest.json +8 -0
  5. package/skills/wix-harmony-editor/COPY-SITE.md +494 -0
  6. package/skills/wix-harmony-editor/SKILL.md +317 -0
  7. package/skills/wix-harmony-editor/scripts/copy/build-description.mjs +249 -0
  8. package/skills/wix-harmony-editor/scripts/copy/check-description.mjs +225 -0
  9. package/skills/wix-harmony-editor/scripts/copy/check-mirror.mjs +89 -0
  10. package/skills/wix-harmony-editor/scripts/copy/compare-preview.mjs +76 -0
  11. package/skills/wix-harmony-editor/scripts/copy/deploy-description.mjs +212 -0
  12. package/skills/wix-harmony-editor/scripts/copy/desc-hash.mjs +44 -0
  13. package/skills/wix-harmony-editor/scripts/copy/editor-run.mjs +45 -0
  14. package/skills/wix-harmony-editor/scripts/copy/export-page.mjs +53 -0
  15. package/skills/wix-harmony-editor/scripts/copy/find-interactions.mjs +76 -0
  16. package/skills/wix-harmony-editor/scripts/copy/hide-scrollbars.mjs +16 -0
  17. package/skills/wix-harmony-editor/scripts/copy/import-media.mjs +150 -0
  18. package/skills/wix-harmony-editor/scripts/copy/link-url.mjs +27 -0
  19. package/skills/wix-harmony-editor/scripts/copy/lint-api.mjs +56 -0
  20. package/skills/wix-harmony-editor/scripts/copy/measure-source.mjs +211 -0
  21. package/skills/wix-harmony-editor/scripts/copy/merge-mirrors.mjs +29 -0
  22. package/skills/wix-harmony-editor/scripts/copy/mirror-site.mjs +92 -0
  23. package/skills/wix-harmony-editor/scripts/copy/mobile-stage.mjs +56 -0
  24. package/skills/wix-harmony-editor/scripts/copy/preview-widths.mjs +73 -0
  25. package/skills/wix-harmony-editor/scripts/copy/render-plate.mjs +67 -0
  26. package/skills/wix-harmony-editor/scripts/copy/serve-mirror.mjs +102 -0
  27. package/skills/wix-harmony-editor/scripts/copy/snapshot-capabilities.mjs +40 -0
  28. package/skills/wix-harmony-editor/scripts/copy/split-sections.mjs +191 -0
  29. package/skills/wix-harmony-editor/scripts/copy/upload-media-manager.mjs +61 -0
  30. package/skills/wix-harmony-editor/scripts/launch.sh +359 -0
  31. package/skills/wix-headless/SKILL.md +7 -2
  32. package/skills/wix-headless/references/CAPABILITIES.md +6 -1
  33. package/skills/wix-headless/references/DISCOVERY.md +2 -1
  34. package/skills/wix-headless/references/SDK_HANDOFF.md +6 -1
  35. package/skills/wix-headless/references/SEED.md +3 -2
  36. package/skills/wix-headless/references/SETUP.md +1 -0
  37. package/skills/wix-headless/references/inline-recipes/experience-donations.md +102 -0
  38. package/skills/wix-headless/references/inline-recipes/how-to-code-donations.md +146 -0
  39. package/skills/wix-headless/references/inline-recipes/setup-donations.md +15 -0
  40. package/skills/wix-headless/references/managed/CREATE.md +1 -1
  41. package/skills/wix-headless-kit/SKILL.md +110 -21
  42. package/skills/wix-headless-kit/guides/api-run.md +15 -13
  43. package/skills/wix-headless-kit/guides/existing-site.md +31 -0
  44. package/skills/wix-headless-kit/guides/migration.md +49 -17
  45. package/skills/wix-headless-kit/install/agents-md.mjs +1 -1
  46. package/skills/wix-headless-kit/install/context.mjs +61 -6
  47. package/skills/wix-headless-kit/install/pins.json +1 -1
  48. package/skills/wix-headless-kit/install/setup.mjs +107 -12
  49. package/skills/wix-headless-replatform/.publish-manifest.json +8 -0
  50. package/skills/wix-headless-replatform/SKILL.md +116 -0
  51. package/skills/wix-headless-replatform/agents/openai.yaml +6 -0
  52. package/skills/wix-headless-replatform/references/control-and-visual-fidelity-contract.md +43 -0
  53. package/skills/wix-headless-replatform/references/extraction-schema.md +187 -0
  54. package/skills/wix-headless-replatform/references/interaction-runtime-contract.md +137 -0
  55. package/skills/wix-headless-replatform/references/layout-blueprint-contract.md +41 -0
  56. package/skills/wix-headless-replatform/references/output-contract.md +93 -0
  57. package/skills/wix-headless-replatform/references/post-build-gap-contract.md +125 -0
  58. package/skills/wix-headless-replatform/references/qa-checklist.md +83 -0
  59. package/skills/wix-headless-replatform/references/safety.md +19 -0
  60. package/skills/wix-headless-replatform/references/ui-normalization-contract.md +70 -0
  61. package/skills/wix-headless-replatform/references/workflow.md +157 -0
  62. package/skills/wix-headless-replatform/registry/README.md +20 -0
  63. package/skills/wix-headless-replatform/registry/approvals/button/shadcn-default-ac60ef5.json +28 -0
  64. package/skills/wix-headless-replatform/registry/items/button/shadcn-default-ac60ef5/button.tsx +54 -0
  65. package/skills/wix-headless-replatform/registry/items/button/shadcn-default-ac60ef5/capabilities.json +60 -0
  66. package/skills/wix-headless-replatform/registry/items/button/shadcn-default-ac60ef5/contract.md +48 -0
  67. package/skills/wix-headless-replatform/registry/licenses/shadcn-ui-ac60ef5-MIT.txt +21 -0
  68. package/skills/wix-headless-replatform/registry/registry.json +36 -0
  69. package/skills/wix-headless-replatform/resources/rp-facelift/SKILL.md +32 -0
  70. package/skills/wix-headless-replatform/resources/rp-project-context/SKILL.md +62 -0
  71. package/skills/wix-headless-replatform/resources/rp-qa-gap-loop/SKILL.md +64 -0
  72. package/skills/wix-headless-replatform/resources/rp-source-evidence/SKILL.md +42 -0
  73. package/skills/wix-headless-replatform/resources/rp-ui-implementation/SKILL.md +73 -0
  74. package/skills/wix-headless-replatform/schemas/build-plan.schema.json +10 -0
  75. package/skills/wix-headless-replatform/schemas/candidate.schema.json +19 -0
  76. package/skills/wix-headless-replatform/schemas/common.schema.json +33 -0
  77. package/skills/wix-headless-replatform/schemas/decision-patch.schema.json +10 -0
  78. package/skills/wix-headless-replatform/schemas/decision-request.schema.json +10 -0
  79. package/skills/wix-headless-replatform/schemas/extraction-gap.schema.json +28 -0
  80. package/skills/wix-headless-replatform/schemas/extraction-manifest.schema.json +34 -0
  81. package/skills/wix-headless-replatform/schemas/final-report.schema.json +10 -0
  82. package/skills/wix-headless-replatform/schemas/foundation.schema.json +11 -0
  83. package/skills/wix-headless-replatform/schemas/metadata.schema.json +11 -0
  84. package/skills/wix-headless-replatform/schemas/observation-packet.schema.json +17 -0
  85. package/skills/wix-headless-replatform/schemas/page-capture.schema.json +11 -0
  86. package/skills/wix-headless-replatform/schemas/page-resolution.schema.json +33 -0
  87. package/skills/wix-headless-replatform/schemas/shared-chrome.schema.json +11 -0
  88. package/skills/wix-headless-replatform/schemas/unit.schema.json +40 -0
  89. package/skills/wix-headless-replatform/scripts/assemble-extraction.mjs +844 -0
  90. package/skills/wix-headless-replatform/scripts/benchmark-extraction.mjs +163 -0
  91. package/skills/wix-headless-replatform/scripts/browser-extraction-preflight.mjs +42 -0
  92. package/skills/wix-headless-replatform/scripts/build-extracted-homepage.mjs +228 -0
  93. package/skills/wix-headless-replatform/scripts/clear-wix-starter.mjs +87 -0
  94. package/skills/wix-headless-replatform/scripts/create-wix-project.mjs +505 -0
  95. package/skills/wix-headless-replatform/scripts/discover-urls.mjs +142 -0
  96. package/skills/wix-headless-replatform/scripts/extract-assets.mjs +140 -0
  97. package/skills/wix-headless-replatform/scripts/extract-design-system.mjs +637 -0
  98. package/skills/wix-headless-replatform/scripts/extract-interactions.mjs +1903 -0
  99. package/skills/wix-headless-replatform/scripts/extract-page.mjs +2461 -0
  100. package/skills/wix-headless-replatform/scripts/extract-seo.mjs +25 -0
  101. package/skills/wix-headless-replatform/scripts/extract-tokens.mjs +63 -0
  102. package/skills/wix-headless-replatform/scripts/finalize-extraction-report.mjs +126 -0
  103. package/skills/wix-headless-replatform/scripts/finalize-gap-review.mjs +180 -0
  104. package/skills/wix-headless-replatform/scripts/finalize-gap-review.test.mjs +98 -0
  105. package/skills/wix-headless-replatform/scripts/finalize-migration-website.mjs +103 -0
  106. package/skills/wix-headless-replatform/scripts/generate-control-state-contract.mjs +176 -0
  107. package/skills/wix-headless-replatform/scripts/generate-design-md.mjs +261 -0
  108. package/skills/wix-headless-replatform/scripts/generate-extraction-validators.mjs +25 -0
  109. package/skills/wix-headless-replatform/scripts/generate-invoice-download-backend.mjs +342 -0
  110. package/skills/wix-headless-replatform/scripts/generate-layout-blueprint.mjs +140 -0
  111. package/skills/wix-headless-replatform/scripts/generate-repeater-cms.mjs +22 -0
  112. package/skills/wix-headless-replatform/scripts/generate-route-plan.mjs +143 -0
  113. package/skills/wix-headless-replatform/scripts/generate-scene-contract.mjs +288 -0
  114. package/skills/wix-headless-replatform/scripts/generate-ui-normalization.mjs +266 -0
  115. package/skills/wix-headless-replatform/scripts/generate-visual-assets.mjs +111 -0
  116. package/skills/wix-headless-replatform/scripts/lib/browser-tooling.mjs +570 -0
  117. package/skills/wix-headless-replatform/scripts/lib/common.mjs +329 -0
  118. package/skills/wix-headless-replatform/scripts/lib/component-capabilities.mjs +121 -0
  119. package/skills/wix-headless-replatform/scripts/lib/component-registry.mjs +282 -0
  120. package/skills/wix-headless-replatform/scripts/lib/content-boundary.mjs +61 -0
  121. package/skills/wix-headless-replatform/scripts/lib/extraction-contract.mjs +374 -0
  122. package/skills/wix-headless-replatform/scripts/lib/extraction-detectors.mjs +243 -0
  123. package/skills/wix-headless-replatform/scripts/lib/extraction-validators.generated.mjs +1139 -0
  124. package/skills/wix-headless-replatform/scripts/lib/font-contract.mjs +326 -0
  125. package/skills/wix-headless-replatform/scripts/lib/frontend-automation-state.mjs +184 -0
  126. package/skills/wix-headless-replatform/scripts/lib/gap-analysis.mjs +396 -0
  127. package/skills/wix-headless-replatform/scripts/lib/html-extract.mjs +168 -0
  128. package/skills/wix-headless-replatform/scripts/lib/interaction-bootstrap.mjs +10 -0
  129. package/skills/wix-headless-replatform/scripts/lib/interaction-runtime.mjs +194 -0
  130. package/skills/wix-headless-replatform/scripts/lib/interaction-timeline.mjs +348 -0
  131. package/skills/wix-headless-replatform/scripts/lib/layout-blueprint/classifiers.mjs +141 -0
  132. package/skills/wix-headless-replatform/scripts/lib/layout-blueprint/geometry.mjs +43 -0
  133. package/skills/wix-headless-replatform/scripts/lib/layout-blueprint/vocabulary.mjs +18 -0
  134. package/skills/wix-headless-replatform/scripts/lib/ui-normalization.css +64 -0
  135. package/skills/wix-headless-replatform/scripts/optimize-svg.mjs +31 -0
  136. package/skills/wix-headless-replatform/scripts/post-build-gap.mjs +358 -0
  137. package/skills/wix-headless-replatform/scripts/provision-repeater-cms.mjs +25 -0
  138. package/skills/wix-headless-replatform/scripts/record-gap-decision.mjs +39 -0
  139. package/skills/wix-headless-replatform/scripts/replay-extraction.mjs +107 -0
  140. package/skills/wix-headless-replatform/scripts/resolve-home-page.mjs +96 -0
  141. package/skills/wix-headless-replatform/scripts/site-clone.mjs +658 -0
  142. package/skills/wix-headless-replatform/scripts/validate-font-contract.mjs +29 -0
  143. package/skills/wix-headless-replatform/scripts/verify-interactions.mjs +669 -0
  144. package/skills/wix-headless-replatform/scripts/visual-qa.mjs +370 -0
  145. package/skills/wix-headless-templates/donations/INSTRUCTIONS.md +37 -24
  146. package/skills/wix-headless-templates/donations/app/components/donations/DonateForm.tsx +49 -23
  147. package/skills/wix-headless-templates/donations/app/components/donations/DonationReceipt.tsx +6 -5
  148. package/skills/wix-headless-templates/donations/app/components/donations/GoalProgress.tsx +5 -5
  149. package/skills/wix-headless-templates/donations/app/wix/donations/campaigns.ts +4 -4
  150. package/skills/wix-headless-templates/donations/app/wix/donations/donate.ts +7 -3
  151. package/skills/wix-headless-templates/donations/app/wix/donations/donation-store.ts +2 -2
  152. package/skills/wix-headless-templates/donations/app/wix/donations/donations-core.ts +12 -9
  153. package/skills/wix-headless-templates/donations/project/src/components/donations/DonateForm.tsx +49 -23
  154. package/skills/wix-headless-templates/donations/project/src/components/donations/DonationReceipt.tsx +6 -5
  155. package/skills/wix-headless-templates/donations/project/src/components/donations/GoalProgress.tsx +5 -5
  156. package/skills/wix-headless-templates/donations/project/src/wix/donations/campaigns.ts +4 -4
  157. package/skills/wix-headless-templates/donations/project/src/wix/donations/donate.ts +7 -3
  158. package/skills/wix-headless-templates/donations/project/src/wix/donations/donation-store.ts +2 -2
  159. package/skills/wix-headless-templates/donations/project/src/wix/donations/donations-core.ts +12 -9
  160. package/skills/wix-headless-templates/donations/rest/campaigns.ts +4 -4
  161. package/skills/wix-headless-templates/donations/rest/donate.ts +7 -3
  162. package/skills/wix-headless-templates/donations/seed/SEED.md +12 -7
  163. package/skills/wix-headless-templates/donations/tests/donation-contract.test.mjs +71 -0
  164. package/skills/wix-headless-templates/donations/tests/donation-form.test.cjs +137 -0
  165. package/skills/wix-headless-templates/restaurants/INSTRUCTIONS.md +28 -14
  166. package/skills/wix-headless-templates/restaurants/app/components/restaurants/OrderCartDrawer.tsx +87 -5
  167. package/skills/wix-headless-templates/restaurants/app/hooks/restaurants/useOrderCart.ts +9 -1
  168. package/skills/wix-headless-templates/restaurants/app/wix/restaurants/order-store.ts +33 -4
  169. package/skills/wix-headless-templates/restaurants/app/wix/restaurants/ordering-core.ts +100 -5
  170. package/skills/wix-headless-templates/restaurants/app/wix/restaurants/ordering.ts +101 -15
  171. package/skills/wix-headless-templates/restaurants/app/wix/restaurants/types.ts +35 -1
  172. package/skills/wix-headless-templates/restaurants/project/src/components/restaurants/OrderCartDrawer.tsx +87 -5
  173. package/skills/wix-headless-templates/restaurants/project/src/hooks/restaurants/useOrderCart.ts +9 -1
  174. package/skills/wix-headless-templates/restaurants/project/src/wix/restaurants/order-store.ts +33 -4
  175. package/skills/wix-headless-templates/restaurants/project/src/wix/restaurants/ordering-core.ts +100 -5
  176. package/skills/wix-headless-templates/restaurants/project/src/wix/restaurants/ordering.ts +101 -15
  177. package/skills/wix-headless-templates/restaurants/project/src/wix/restaurants/types.ts +35 -1
  178. package/skills/wix-headless-templates/restaurants/rest/ordering.ts +91 -14
  179. package/skills/wix-import/SKILL.md +90 -0
  180. package/skills/wix-manage/SKILL.md +14 -4
  181. package/skills/wix-manage/references/blog/how-to-create-blog-posts.md +2 -0
  182. package/skills/wix-manage/references/dashboard-navigation/dashboard-navigation.md +2 -1
  183. package/skills/wix-manage/references/dashboard-navigation/routes.json +249 -0
  184. package/skills/wix-manage/references/donations/create-and-update-donation-campaigns.md +139 -0
  185. package/skills/wix-manage/references/events/events-dashboard-navigation.md +81 -0
  186. package/skills/wix-manage/references/seo/manage-content-plan.md +207 -222
  187. package/skills/wix-manage/references/sites/manage-oauth-apps.md +1 -0
  188. package/skills/wix-manage/references/sites/upload-static-site.md +128 -8
  189. package/skills/wix-readme/SKILL.md +166 -0
  190. package/skills/wix-replatform/.publish-manifest.json +5 -5
  191. package/skills/wix-replatform/CLI.md +162 -0
  192. package/skills/wix-replatform/README.md +52 -0
  193. package/skills/wix-replatform/SKILL.md +229 -684
  194. package/skills/wix-replatform/console/account.css +1 -0
  195. package/skills/wix-replatform/console/app.css +1 -0
  196. package/skills/wix-replatform/console/app.js +117 -0
  197. package/skills/wix-replatform/console/index.html +4 -0
  198. package/skills/wix-replatform/console/json.css +11 -0
  199. package/skills/wix-replatform/lib/agent-adapters/index.js +71 -0
  200. package/skills/wix-replatform/lib/app-page-routing.js +75 -0
  201. package/skills/wix-replatform/lib/artifact-freshness.js +11 -1
  202. package/skills/wix-replatform/lib/blocked-data-requests.js +427 -0
  203. package/skills/wix-replatform/lib/census-reconciliation.js +426 -0
  204. package/skills/wix-replatform/lib/completion-report.js +1393 -13
  205. package/skills/wix-replatform/lib/config-env.js +85 -11
  206. package/skills/wix-replatform/lib/confirmed-pictures.js +212 -0
  207. package/skills/wix-replatform/lib/dependency-readiness.js +423 -0
  208. package/skills/wix-replatform/lib/dependency-recovery.js +21 -0
  209. package/skills/wix-replatform/lib/destination-choice.js +163 -0
  210. package/skills/wix-replatform/lib/destination-handoff.js +62 -0
  211. package/skills/wix-replatform/lib/destination-http.js +81 -0
  212. package/skills/wix-replatform/lib/destination-route.js +98 -0
  213. package/skills/wix-replatform/lib/destination.js +919 -0
  214. package/skills/wix-replatform/lib/discovered-census.js +231 -0
  215. package/skills/wix-replatform/lib/discovered-set-status.js +255 -0
  216. package/skills/wix-replatform/lib/document-url-guard.js +203 -0
  217. package/skills/wix-replatform/lib/entity-qa-attestation.js +339 -0
  218. package/skills/wix-replatform/lib/entity-verification.js +18 -0
  219. package/skills/wix-replatform/lib/execution-capability.js +120 -0
  220. package/skills/wix-replatform/lib/execution-log.js +170 -0
  221. package/skills/wix-replatform/lib/execution-manifest.js +20 -2
  222. package/skills/wix-replatform/lib/execution-state.js +22 -0
  223. package/skills/wix-replatform/lib/expectations-ledger.js +96 -0
  224. package/skills/wix-replatform/lib/generated-plugin-handoff.js +140 -0
  225. package/skills/wix-replatform/lib/import-readiness-contract.js +23 -0
  226. package/skills/wix-replatform/lib/import-recovery.js +800 -6
  227. package/skills/wix-replatform/lib/imported-redirect-targets.js +608 -0
  228. package/skills/wix-replatform/lib/internal-link-reconciliation.js +166 -0
  229. package/skills/wix-replatform/lib/link-audit.js +173 -0
  230. package/skills/wix-replatform/lib/link-census.js +194 -0
  231. package/skills/wix-replatform/lib/link-plan.js +148 -0
  232. package/skills/wix-replatform/lib/link-verification.js +274 -0
  233. package/skills/wix-replatform/lib/link-write-journal.js +42 -0
  234. package/skills/wix-replatform/lib/local-state.js +869 -30
  235. package/skills/wix-replatform/lib/member-completion.js +658 -0
  236. package/skills/wix-replatform/lib/member-crosswalk.js +69 -0
  237. package/skills/wix-replatform/lib/member-outcome-registry.js +265 -0
  238. package/skills/wix-replatform/lib/migration-completion.js +311 -0
  239. package/skills/wix-replatform/lib/operator-identity.js +47 -0
  240. package/skills/wix-replatform/lib/orchestration-decisions.js +248 -0
  241. package/skills/wix-replatform/lib/orchestration-preflight.js +401 -19
  242. package/skills/wix-replatform/lib/orchestration-router.js +608 -32
  243. package/skills/wix-replatform/lib/orchestration-state.js +188 -12
  244. package/skills/wix-replatform/lib/order-reference-readiness.js +30 -0
  245. package/skills/wix-replatform/lib/payments-outcome-registry.js +200 -0
  246. package/skills/wix-replatform/lib/plugin-cms-fallback.js +618 -0
  247. package/skills/wix-replatform/lib/preservation-approval-stamp.js +54 -0
  248. package/skills/wix-replatform/lib/product-media-deferral.js +96 -0
  249. package/skills/wix-replatform/lib/progress-log.js +19 -3
  250. package/skills/wix-replatform/lib/read-back-approval.js +184 -0
  251. package/skills/wix-replatform/lib/read-back-comparison.js +136 -0
  252. package/skills/wix-replatform/lib/read-back-contract.js +243 -0
  253. package/skills/wix-replatform/lib/read-back-extract.js +118 -0
  254. package/skills/wix-replatform/lib/read-back-gate.js +734 -0
  255. package/skills/wix-replatform/lib/read-back-reads.js +94 -0
  256. package/skills/wix-replatform/lib/read-back-state.js +107 -0
  257. package/skills/wix-replatform/lib/read-back-summary.js +81 -0
  258. package/skills/wix-replatform/lib/rerun-conflicts.js +334 -0
  259. package/skills/wix-replatform/lib/run-controller.js +401 -0
  260. package/skills/wix-replatform/lib/seo-outcome-registry.js +45 -0
  261. package/skills/wix-replatform/lib/setup-verification.js +148 -0
  262. package/skills/wix-replatform/lib/source-access.js +231 -0
  263. package/skills/wix-replatform/lib/source-coverage.js +1130 -0
  264. package/skills/wix-replatform/lib/source-secrets.js +277 -0
  265. package/skills/wix-replatform/lib/structured-link-patch.js +59 -0
  266. package/skills/wix-replatform/lib/task-state.js +110 -0
  267. package/skills/wix-replatform/lib/url-preservation-report.js +319 -0
  268. package/skills/wix-replatform/lib/url-preservation-state.js +349 -1
  269. package/skills/wix-replatform/lib/url-redirect-plan.js +728 -0
  270. package/skills/wix-replatform/lib/url-verification.js +315 -0
  271. package/skills/wix-replatform/lib/user-action-effects.js +42 -0
  272. package/skills/wix-replatform/lib/user-actions.js +264 -0
  273. package/skills/wix-replatform/lib/website-handoff.js +1220 -0
  274. package/skills/wix-replatform/lib/wix-client-callers.js +54 -0
  275. package/skills/wix-replatform/lib/wix-dashboard-url.js +35 -0
  276. package/skills/wix-replatform/lib/write-verification-state.js +92 -0
  277. package/skills/wix-replatform/lib/write-verification.js +274 -0
  278. package/skills/wix-replatform/resources/rp-destination/SKILL.md +137 -0
  279. package/skills/wix-replatform/resources/rp-discovery/SKILL.md +189 -16
  280. package/skills/wix-replatform/resources/rp-discovery/scripts/promote-source-coverage.js +47 -0
  281. package/skills/wix-replatform/resources/rp-execute-import/SKILL.md +869 -29
  282. package/skills/wix-replatform/resources/rp-execute-import/scripts/shipping-estimate-audit.js +70 -0
  283. package/skills/wix-replatform/resources/rp-execute-setup/SKILL.md +195 -29
  284. package/skills/wix-replatform/resources/rp-execute-setup/scripts/execute-setup.js +442 -0
  285. package/skills/wix-replatform/resources/rp-execution-policy/SKILL.md +112 -0
  286. package/skills/wix-replatform/resources/rp-execution-policy/lib/coupon-currency-plan-report.js +143 -0
  287. package/skills/wix-replatform/resources/rp-execution-policy/lib/payments-report.js +244 -0
  288. package/skills/wix-replatform/resources/rp-import-codegen/SKILL.md +2082 -38
  289. package/skills/wix-replatform/resources/rp-mapper/SKILL.md +528 -11
  290. package/skills/wix-replatform/resources/rp-mapper/lib/structure-bridge-planning.js +303 -0
  291. package/skills/wix-replatform/resources/rp-mapper/scripts/coverage-reconcile.js +88 -0
  292. package/skills/wix-replatform/resources/rp-mapper/wix-business-solutions-taxonomy.md +6 -5
  293. package/skills/wix-replatform/resources/rp-preflight/SKILL.md +40 -0
  294. package/skills/wix-replatform/resources/rp-project-intake/SKILL.md +55 -0
  295. package/skills/wix-replatform/resources/rp-quick-runtime/SKILL.md +60 -0
  296. package/skills/wix-replatform/resources/rp-quick-runtime/lib/import-progress.js +89 -0
  297. package/skills/wix-replatform/resources/rp-quick-runtime/lib/limit-recovery.js +36 -0
  298. package/skills/wix-replatform/resources/rp-quick-shopify/SKILL.md +123 -0
  299. package/skills/wix-replatform/resources/rp-quick-shopify/quick-mode.json +124 -0
  300. package/skills/wix-replatform/resources/rp-quick-shopify/scripts/quick-mode.js +522 -0
  301. package/skills/wix-replatform/resources/rp-quick-woocommerce/SKILL.md +56 -0
  302. package/skills/wix-replatform/resources/rp-quick-woocommerce/quick-mode.json +91 -0
  303. package/skills/wix-replatform/resources/rp-quick-woocommerce/scripts/quick-mode.js +255 -0
  304. package/skills/wix-replatform/resources/rp-setup-discovery/SKILL.md +80 -10
  305. package/skills/wix-replatform/resources/rp-setup-discovery/scripts/quick-setup-plan.js +44 -0
  306. package/skills/wix-replatform/resources/rp-source-csv/SKILL.md +3 -0
  307. package/skills/wix-replatform/resources/rp-source-csv/lib/csv-fileset.js +0 -0
  308. package/skills/wix-replatform/resources/rp-source-csv/scripts/csv-discovery.js +21 -1
  309. package/skills/wix-replatform/resources/rp-source-inputs/SKILL.md +66 -0
  310. package/skills/wix-replatform/resources/rp-source-sfcc/SKILL.md +153 -0
  311. package/skills/wix-replatform/resources/rp-source-shopify/SKILL.md +394 -0
  312. package/skills/wix-replatform/resources/rp-source-shopify/lib/discovery-reads.js +200 -0
  313. package/skills/wix-replatform/resources/rp-source-shopify/lib/import-findings.js +34 -0
  314. package/skills/wix-replatform/resources/rp-source-shopify/lib/shopify-bulk-sqlite-worker.js +44 -0
  315. package/skills/wix-replatform/resources/rp-source-shopify/lib/shopify-bulk.js +1470 -0
  316. package/skills/wix-replatform/resources/rp-source-shopify/lib/shopify-cli.js +446 -0
  317. package/skills/wix-replatform/resources/rp-source-shopify/lib/shopify-gift-cards.js +474 -0
  318. package/skills/wix-replatform/resources/rp-source-shopify/lib/shopify-protected-fields.js +879 -0
  319. package/skills/wix-replatform/resources/rp-source-shopify/lib/shopify-session.js +426 -0
  320. package/skills/wix-replatform/resources/rp-source-shopify/queries/articles.graphql +24 -0
  321. package/skills/wix-replatform/resources/rp-source-shopify/queries/blogs.graphql +18 -0
  322. package/skills/wix-replatform/resources/rp-source-shopify/queries/collections.graphql +40 -0
  323. package/skills/wix-replatform/resources/rp-source-shopify/queries/customers.graphql +76 -0
  324. package/skills/wix-replatform/resources/rp-source-shopify/queries/delivery-profiles.graphql +51 -0
  325. package/skills/wix-replatform/resources/rp-source-shopify/queries/discounts.graphql +35 -0
  326. package/skills/wix-replatform/resources/rp-source-shopify/queries/files.graphql +20 -0
  327. package/skills/wix-replatform/resources/rp-source-shopify/queries/gift-cards.graphql +18 -0
  328. package/skills/wix-replatform/resources/rp-source-shopify/queries/inventory.graphql +31 -0
  329. package/skills/wix-replatform/resources/rp-source-shopify/queries/locations.graphql +21 -0
  330. package/skills/wix-replatform/resources/rp-source-shopify/queries/menus.graphql +21 -0
  331. package/skills/wix-replatform/resources/rp-source-shopify/queries/metaobjects.graphql +30 -0
  332. package/skills/wix-replatform/resources/rp-source-shopify/queries/orders-core.graphql +150 -0
  333. package/skills/wix-replatform/resources/rp-source-shopify/queries/orders-fulfillments.graphql +36 -0
  334. package/skills/wix-replatform/resources/rp-source-shopify/queries/orders-refunds.graphql +48 -0
  335. package/skills/wix-replatform/resources/rp-source-shopify/queries/pages.graphql +20 -0
  336. package/skills/wix-replatform/resources/rp-source-shopify/queries/probe-customers-address.graphql +8 -0
  337. package/skills/wix-replatform/resources/rp-source-shopify/queries/probe-customers-email.graphql +6 -0
  338. package/skills/wix-replatform/resources/rp-source-shopify/queries/probe-customers-name.graphql +8 -0
  339. package/skills/wix-replatform/resources/rp-source-shopify/queries/probe-customers-phone.graphql +8 -0
  340. package/skills/wix-replatform/resources/rp-source-shopify/queries/probe-orders-address.graphql +12 -0
  341. package/skills/wix-replatform/resources/rp-source-shopify/queries/probe-orders-email.graphql +6 -0
  342. package/skills/wix-replatform/resources/rp-source-shopify/queries/probe-orders-name.graphql +13 -0
  343. package/skills/wix-replatform/resources/rp-source-shopify/queries/probe-orders-phone.graphql +13 -0
  344. package/skills/wix-replatform/resources/rp-source-shopify/queries/products.graphql +73 -0
  345. package/skills/wix-replatform/resources/rp-source-shopify/queries/url-redirects.graphql +13 -0
  346. package/skills/wix-replatform/resources/rp-source-shopify/scripts/shopify-discovery.js +693 -0
  347. package/skills/wix-replatform/resources/rp-source-shopify/scripts/shopify-extract.js +283 -0
  348. package/skills/wix-replatform/resources/rp-source-shopify/scripts/shopify-gift-card-remedy.js +191 -0
  349. package/skills/wix-replatform/resources/rp-source-shopify/scripts/shopify-session-check.js +115 -0
  350. package/skills/wix-replatform/resources/rp-source-shopify/source-schema.example.json +201 -0
  351. package/skills/wix-replatform/resources/rp-source-wordpress/PLUGIN-READ-PLANS.md +146 -0
  352. package/skills/wix-replatform/resources/rp-source-wordpress/SKILL.md +736 -22
  353. package/skills/wix-replatform/resources/rp-source-wordpress/lib/blocked-data-handlers.js +73 -0
  354. package/skills/wix-replatform/resources/rp-source-wordpress/lib/checkout-field-csv-parser.js +115 -0
  355. package/skills/wix-replatform/resources/rp-source-wordpress/lib/checkout-field-csv-parser.test-fixture.js +91 -0
  356. package/skills/wix-replatform/resources/rp-source-wordpress/lib/coupon-discovery.js +440 -0
  357. package/skills/wix-replatform/resources/rp-source-wordpress/lib/currency-gate.js +125 -0
  358. package/skills/wix-replatform/resources/rp-source-wordpress/lib/gateway-source-keys.js +252 -0
  359. package/skills/wix-replatform/resources/rp-source-wordpress/lib/gateway-source-keys.json +183 -0
  360. package/skills/wix-replatform/resources/rp-source-wordpress/lib/gateway-summary.mjs +333 -0
  361. package/skills/wix-replatform/resources/rp-source-wordpress/lib/invoice-discovery.js +426 -0
  362. package/skills/wix-replatform/resources/rp-source-wordpress/lib/plugin-disposition.js +400 -0
  363. package/skills/wix-replatform/resources/rp-source-wordpress/lib/plugin-entity-read-plan.js +633 -0
  364. package/skills/wix-replatform/resources/rp-source-wordpress/lib/plugin-knowledge.js +1127 -0
  365. package/skills/wix-replatform/resources/rp-source-wordpress/lib/refund-corroboration.js +194 -0
  366. package/skills/wix-replatform/resources/rp-source-wordpress/lib/refund-corroboration.json +100 -0
  367. package/skills/wix-replatform/resources/rp-source-wordpress/lib/sampled-ids-batch.js +157 -0
  368. package/skills/wix-replatform/resources/rp-source-wordpress/lib/secret-value-guard.js +234 -0
  369. package/skills/wix-replatform/resources/rp-source-wordpress/lib/store-currency.js +101 -0
  370. package/skills/wix-replatform/resources/rp-source-wordpress/lib/structure-bridge-reader.js +755 -0
  371. package/skills/wix-replatform/resources/rp-source-wordpress/lib/wix-wp-plugin-v2-client.js +1074 -0
  372. package/skills/wix-replatform/resources/rp-source-wordpress/lib/wix-wp-plugin-v2-client.test-fixture.js +149 -0
  373. package/skills/wix-replatform/resources/rp-source-wordpress/lib/woo-inventory.js +25 -0
  374. package/skills/wix-replatform/resources/rp-source-wordpress/lib/wp-http.js +204 -9
  375. package/skills/wix-replatform/resources/rp-source-wordpress/lib/wp-image-url.js +186 -0
  376. package/skills/wix-replatform/resources/rp-source-wordpress/lib/wp-plugin-detect.js +1422 -0
  377. package/skills/wix-replatform/resources/rp-source-wordpress/lib/wp-redirect-sources.js +343 -0
  378. package/skills/wix-replatform/resources/rp-source-wordpress/lib/wp-route-classifier.js +262 -26
  379. package/skills/wix-replatform/resources/rp-source-wordpress/lib/yoast-product-seo-evidence.js +272 -0
  380. package/skills/wix-replatform/resources/rp-source-wordpress/plugins/README.md +373 -0
  381. package/skills/wix-replatform/resources/rp-source-wordpress/plugins/advanced-custom-fields.json +101 -0
  382. package/skills/wix-replatform/resources/rp-source-wordpress/plugins/back-in-stock-notifier-for-woocommerce.json +81 -0
  383. package/skills/wix-replatform/resources/rp-source-wordpress/plugins/capabilities-pending-decision.json +128 -0
  384. package/skills/wix-replatform/resources/rp-source-wordpress/plugins/cms-fallback-eligible.json +18 -0
  385. package/skills/wix-replatform/resources/rp-source-wordpress/plugins/contact-form-7.json +104 -0
  386. package/skills/wix-replatform/resources/rp-source-wordpress/plugins/facebook-for-woocommerce.json +44 -0
  387. package/skills/wix-replatform/resources/rp-source-wordpress/plugins/fingerprint-aliases.json +49 -0
  388. package/skills/wix-replatform/resources/rp-source-wordpress/plugins/free-gifts-for-woocommerce.json +94 -0
  389. package/skills/wix-replatform/resources/rp-source-wordpress/plugins/index.json +863 -0
  390. package/skills/wix-replatform/resources/rp-source-wordpress/plugins/mailpoet.json +52 -0
  391. package/skills/wix-replatform/resources/rp-source-wordpress/plugins/membership-for-woocommerce.json +161 -0
  392. package/skills/wix-replatform/resources/rp-source-wordpress/plugins/mwb-bookings-for-woocommerce.json +180 -0
  393. package/skills/wix-replatform/resources/rp-source-wordpress/plugins/no-migration-needed.json +286 -0
  394. package/skills/wix-replatform/resources/rp-source-wordpress/plugins/pricing-deals-for-woocommerce.json +79 -0
  395. package/skills/wix-replatform/resources/rp-source-wordpress/plugins/product-extras-for-woocommerce.json +120 -0
  396. package/skills/wix-replatform/resources/rp-source-wordpress/plugins/pw-woocommerce-gift-cards.json +128 -0
  397. package/skills/wix-replatform/resources/rp-source-wordpress/plugins/requires-development.json +88 -0
  398. package/skills/wix-replatform/resources/rp-source-wordpress/plugins/seo-by-rank-math.json +80 -0
  399. package/skills/wix-replatform/resources/rp-source-wordpress/plugins/seriously-simple-podcasting.json +46 -0
  400. package/skills/wix-replatform/resources/rp-source-wordpress/plugins/strong-testimonials.json +55 -0
  401. package/skills/wix-replatform/resources/rp-source-wordpress/plugins/subscriptions-for-woocommerce.json +99 -0
  402. package/skills/wix-replatform/resources/rp-source-wordpress/plugins/tablepress.json +55 -0
  403. package/skills/wix-replatform/resources/rp-source-wordpress/plugins/the-events-calendar.json +160 -0
  404. package/skills/wix-replatform/resources/rp-source-wordpress/plugins/ti-woocommerce-wishlist.json +81 -0
  405. package/skills/wix-replatform/resources/rp-source-wordpress/plugins/woo-checkout-field-editor-pro.json +60 -0
  406. package/skills/wix-replatform/resources/rp-source-wordpress/plugins/woo-discount-rules.json +74 -0
  407. package/skills/wix-replatform/resources/rp-source-wordpress/plugins/woo-product-bundle.json +75 -0
  408. package/skills/wix-replatform/resources/rp-source-wordpress/plugins/woocommerce-gift-cards.json +60 -0
  409. package/skills/wix-replatform/resources/rp-source-wordpress/plugins/woocommerce-other-payment-gateway.json +44 -0
  410. package/skills/wix-replatform/resources/rp-source-wordpress/plugins/woocommerce-pdf-invoices-packing-slips.json +57 -0
  411. package/skills/wix-replatform/resources/rp-source-wordpress/plugins/woocommerce-product-addon.json +141 -0
  412. package/skills/wix-replatform/resources/rp-source-wordpress/plugins/woocommerce-progressive-discounts.json +54 -0
  413. package/skills/wix-replatform/resources/rp-source-wordpress/plugins/wordpress-seo.json +158 -0
  414. package/skills/wix-replatform/resources/rp-source-wordpress/plugins/wpc-composite-products.json +97 -0
  415. package/skills/wix-replatform/resources/rp-source-wordpress/plugins/wpforms-lite.json +86 -0
  416. package/skills/wix-replatform/resources/rp-source-wordpress/scripts/capture-store-settings.js +90 -0
  417. package/skills/wix-replatform/resources/rp-source-wordpress/scripts/plugin-knowledge-validate.js +51 -0
  418. package/skills/wix-replatform/resources/rp-source-wordpress/scripts/plugin-knowledge.js +103 -0
  419. package/skills/wix-replatform/resources/rp-source-wordpress/scripts/wp-discovery.js +1668 -33
  420. package/skills/wix-replatform/resources/rp-source-wordpress/scripts/wp-plugin-inventory.js +273 -0
  421. package/skills/wix-replatform/resources/rp-source-wordpress/secret-value-patterns.v1.json +11 -0
  422. package/skills/wix-replatform/resources/rp-source-wordpress/sub-parts.json +13 -0
  423. package/skills/wix-replatform/resources/rp-target-wix/SKILL.md +446 -32
  424. package/skills/wix-replatform/resources/rp-target-wix/app-page-routing-capabilities.json +36 -0
  425. package/skills/wix-replatform/resources/rp-target-wix/domains/README.md +38 -2
  426. package/skills/wix-replatform/resources/rp-target-wix/domains/SERVICE-PLUGINS.md +322 -0
  427. package/skills/wix-replatform/resources/rp-target-wix/domains/blog/docs-survey.json +70 -0
  428. package/skills/wix-replatform/resources/rp-target-wix/domains/blog/domain.json +19 -9
  429. package/skills/wix-replatform/resources/rp-target-wix/domains/blog/entities/category.json +42 -8
  430. package/skills/wix-replatform/resources/rp-target-wix/domains/blog/entities/comment.json +54 -8
  431. package/skills/wix-replatform/resources/rp-target-wix/domains/blog/entities/post.json +66 -10
  432. package/skills/wix-replatform/resources/rp-target-wix/domains/blog/entities/tag.json +38 -7
  433. package/skills/wix-replatform/resources/rp-target-wix/domains/bookings/docs-survey.json +332 -0
  434. package/skills/wix-replatform/resources/rp-target-wix/domains/bookings/domain.json +75 -0
  435. package/skills/wix-replatform/resources/rp-target-wix/domains/bookings/entities/booking.json +181 -0
  436. package/skills/wix-replatform/resources/rp-target-wix/domains/bookings/entities/service-add-on.json +130 -0
  437. package/skills/wix-replatform/resources/rp-target-wix/domains/bookings/entities/service.json +180 -0
  438. package/skills/wix-replatform/resources/rp-target-wix/domains/cms/docs-survey.json +161 -0
  439. package/skills/wix-replatform/resources/rp-target-wix/domains/cms/domain.json +15 -4
  440. package/skills/wix-replatform/resources/rp-target-wix/domains/cms/entities/collection.json +39 -7
  441. package/skills/wix-replatform/resources/rp-target-wix/domains/cms/entities/data-item.json +47 -8
  442. package/skills/wix-replatform/resources/rp-target-wix/domains/cms/entities/reference.json +7 -1
  443. package/skills/wix-replatform/resources/rp-target-wix/domains/crm/docs-survey.json +204 -0
  444. package/skills/wix-replatform/resources/rp-target-wix/domains/crm/domain.json +17 -4
  445. package/skills/wix-replatform/resources/rp-target-wix/domains/crm/entities/contact.json +159 -15
  446. package/skills/wix-replatform/resources/rp-target-wix/domains/crm/entities/email-subscription.json +80 -12
  447. package/skills/wix-replatform/resources/rp-target-wix/domains/crm/entities/label.json +48 -8
  448. package/skills/wix-replatform/resources/rp-target-wix/domains/ecom/docs-survey.json +306 -0
  449. package/skills/wix-replatform/resources/rp-target-wix/domains/ecom/domain.json +30 -7
  450. package/skills/wix-replatform/resources/rp-target-wix/domains/ecom/entities/delivery-profile.json +171 -0
  451. package/skills/wix-replatform/resources/rp-target-wix/domains/ecom/entities/discount-rule.json +182 -0
  452. package/skills/wix-replatform/resources/rp-target-wix/domains/ecom/entities/order-applied-discount.json +129 -0
  453. package/skills/wix-replatform/resources/rp-target-wix/domains/ecom/entities/order-invoice-document.json +192 -0
  454. package/skills/wix-replatform/resources/rp-target-wix/domains/ecom/entities/order-line-item-options.json +123 -0
  455. package/skills/wix-replatform/resources/rp-target-wix/domains/ecom/entities/order-line-item.json +60 -12
  456. package/skills/wix-replatform/resources/rp-target-wix/domains/ecom/entities/order-merchant-note.json +112 -0
  457. package/skills/wix-replatform/resources/rp-target-wix/domains/ecom/entities/order-payment.json +191 -0
  458. package/skills/wix-replatform/resources/rp-target-wix/domains/ecom/entities/order-refund.json +140 -13
  459. package/skills/wix-replatform/resources/rp-target-wix/domains/ecom/entities/order.json +383 -18
  460. package/skills/wix-replatform/resources/rp-target-wix/domains/ecom/entities/pickup-location.json +122 -0
  461. package/skills/wix-replatform/resources/rp-target-wix/domains/ecom/entities/shipping-option.json +98 -0
  462. package/skills/wix-replatform/resources/rp-target-wix/domains/ecom/entities/wishlist-item.json +86 -0
  463. package/skills/wix-replatform/resources/rp-target-wix/domains/events/docs-survey.json +128 -0
  464. package/skills/wix-replatform/resources/rp-target-wix/domains/events/domain.json +38 -0
  465. package/skills/wix-replatform/resources/rp-target-wix/domains/events/entities/category.json +73 -0
  466. package/skills/wix-replatform/resources/rp-target-wix/domains/events/entities/event.json +107 -0
  467. package/skills/wix-replatform/resources/rp-target-wix/domains/events/entities/registration-form.json +89 -0
  468. package/skills/wix-replatform/resources/rp-target-wix/domains/events/entities/rsvp.json +118 -0
  469. package/skills/wix-replatform/resources/rp-target-wix/domains/events/entities/ticket-definition.json +93 -0
  470. package/skills/wix-replatform/resources/rp-target-wix/domains/forms/docs-survey.json +86 -0
  471. package/skills/wix-replatform/resources/rp-target-wix/domains/forms/domain.json +56 -0
  472. package/skills/wix-replatform/resources/rp-target-wix/domains/forms/entities/form-submission.json +121 -0
  473. package/skills/wix-replatform/resources/rp-target-wix/domains/forms/entities/form.json +134 -0
  474. package/skills/wix-replatform/resources/rp-target-wix/domains/gift-cards/docs-survey.json +41 -0
  475. package/skills/wix-replatform/resources/rp-target-wix/domains/gift-cards/domain.json +50 -0
  476. package/skills/wix-replatform/resources/rp-target-wix/domains/gift-cards/entities/gift-card-product.json +87 -0
  477. package/skills/wix-replatform/resources/rp-target-wix/domains/gift-cards/entities/gift-card.json +130 -0
  478. package/skills/wix-replatform/resources/rp-target-wix/domains/index.json +914 -24
  479. package/skills/wix-replatform/resources/rp-target-wix/domains/media/docs-survey.json +41 -0
  480. package/skills/wix-replatform/resources/rp-target-wix/domains/media/domain.json +14 -4
  481. package/skills/wix-replatform/resources/rp-target-wix/domains/media/entities/media-file.json +45 -8
  482. package/skills/wix-replatform/resources/rp-target-wix/domains/media/entities/media-folder.json +41 -7
  483. package/skills/wix-replatform/resources/rp-target-wix/domains/members/docs-survey.json +119 -0
  484. package/skills/wix-replatform/resources/rp-target-wix/domains/members/domain.json +13 -3
  485. package/skills/wix-replatform/resources/rp-target-wix/domains/members/entities/badge.json +41 -7
  486. package/skills/wix-replatform/resources/rp-target-wix/domains/members/entities/custom-field.json +82 -0
  487. package/skills/wix-replatform/resources/rp-target-wix/domains/members/entities/member-about.json +77 -0
  488. package/skills/wix-replatform/resources/rp-target-wix/domains/members/entities/member.json +165 -13
  489. package/skills/wix-replatform/resources/rp-target-wix/domains/pricing-plans/docs-survey.json +41 -0
  490. package/skills/wix-replatform/resources/rp-target-wix/domains/pricing-plans/domain.json +46 -0
  491. package/skills/wix-replatform/resources/rp-target-wix/domains/pricing-plans/entities/plan-order.json +137 -0
  492. package/skills/wix-replatform/resources/rp-target-wix/domains/pricing-plans/entities/plan.json +133 -0
  493. package/skills/wix-replatform/resources/rp-target-wix/domains/sales-channels/docs-survey.json +7 -0
  494. package/skills/wix-replatform/resources/rp-target-wix/domains/sales-channels/domain.json +36 -0
  495. package/skills/wix-replatform/resources/rp-target-wix/domains/sales-channels/entities/amazon-shop-connect.json +71 -0
  496. package/skills/wix-replatform/resources/rp-target-wix/domains/sales-channels/entities/ebay-shop-connect.json +67 -0
  497. package/skills/wix-replatform/resources/rp-target-wix/domains/sales-channels/entities/google-youtube-connect.json +72 -0
  498. package/skills/wix-replatform/resources/rp-target-wix/domains/sales-channels/entities/meta-catalog-connect.json +74 -0
  499. package/skills/wix-replatform/resources/rp-target-wix/domains/sales-channels/entities/pinterest-catalog-connect.json +69 -0
  500. package/skills/wix-replatform/resources/rp-target-wix/domains/sales-channels/entities/tiktok-catalog-connect.json +61 -0
  501. package/skills/wix-replatform/resources/rp-target-wix/domains/schema.json +28 -1
  502. package/skills/wix-replatform/resources/rp-target-wix/domains/seo/docs-survey.json +109 -0
  503. package/skills/wix-replatform/resources/rp-target-wix/domains/seo/domain.json +73 -0
  504. package/skills/wix-replatform/resources/rp-target-wix/domains/seo/entities/item-seo-tags.json +148 -0
  505. package/skills/wix-replatform/resources/rp-target-wix/domains/seo/entities/seo-pattern.json +91 -0
  506. package/skills/wix-replatform/resources/rp-target-wix/domains/seo/entities/site-seo-tags.json +79 -0
  507. package/skills/wix-replatform/resources/rp-target-wix/domains/site/docs-survey.json +32 -0
  508. package/skills/wix-replatform/resources/rp-target-wix/domains/site/domain.json +49 -0
  509. package/skills/wix-replatform/resources/rp-target-wix/domains/site/entities/business-contact.json +103 -0
  510. package/skills/wix-replatform/resources/rp-target-wix/domains/stores/docs-survey.json +203 -0
  511. package/skills/wix-replatform/resources/rp-target-wix/domains/stores/domain.json +27 -10
  512. package/skills/wix-replatform/resources/rp-target-wix/domains/stores/entities/back-in-stock-request.json +119 -0
  513. package/skills/wix-replatform/resources/rp-target-wix/domains/stores/entities/brand.json +111 -0
  514. package/skills/wix-replatform/resources/rp-target-wix/domains/stores/entities/category.json +52 -8
  515. package/skills/wix-replatform/resources/rp-target-wix/domains/stores/entities/coupon.json +214 -10
  516. package/skills/wix-replatform/resources/rp-target-wix/domains/stores/entities/inventory-item.json +93 -13
  517. package/skills/wix-replatform/resources/rp-target-wix/domains/stores/entities/product-customization.json +111 -0
  518. package/skills/wix-replatform/resources/rp-target-wix/domains/stores/entities/product-tag.json +52 -10
  519. package/skills/wix-replatform/resources/rp-target-wix/domains/stores/entities/product.json +145 -14
  520. package/skills/wix-replatform/resources/rp-target-wix/domains/stores/entities/promotion.json +84 -0
  521. package/skills/wix-replatform/resources/rp-target-wix/domains/stores/entities/review.json +178 -0
  522. package/skills/wix-replatform/resources/rp-target-wix/domains/stores/entities/subscription-product.json +87 -0
  523. package/skills/wix-replatform/resources/rp-target-wix/domains/tax/docs-survey.json +106 -0
  524. package/skills/wix-replatform/resources/rp-target-wix/domains/tax/domain.json +64 -0
  525. package/skills/wix-replatform/resources/rp-target-wix/domains/tax/entities/manual-tax-mapping.json +119 -0
  526. package/skills/wix-replatform/resources/rp-target-wix/domains/tax/entities/tax-group.json +94 -0
  527. package/skills/wix-replatform/resources/rp-target-wix/domains/tax/entities/tax-region.json +113 -0
  528. package/skills/wix-replatform/resources/rp-target-wix/domains/tax/entities/tax-settings.json +65 -0
  529. package/skills/wix-replatform/resources/rp-target-wix/lib/blog-author-attribution.js +165 -0
  530. package/skills/wix-replatform/resources/rp-target-wix/lib/blog-post-build-client.js +60 -0
  531. package/skills/wix-replatform/resources/rp-target-wix/lib/blog-post-build-duplicates.js +201 -0
  532. package/skills/wix-replatform/resources/rp-target-wix/lib/blog-post-build-ledger.js +306 -0
  533. package/skills/wix-replatform/resources/rp-target-wix/lib/blog-post-build-report.js +229 -0
  534. package/skills/wix-replatform/resources/rp-target-wix/lib/blog-post-build-stage.js +55 -0
  535. package/skills/wix-replatform/resources/rp-target-wix/lib/blog-post-build.js +715 -0
  536. package/skills/wix-replatform/resources/rp-target-wix/lib/blog-post-media.js +567 -0
  537. package/skills/wix-replatform/resources/rp-target-wix/lib/bulk-results.js +73 -0
  538. package/skills/wix-replatform/resources/rp-target-wix/lib/contact-extended-fields.js +194 -0
  539. package/skills/wix-replatform/resources/rp-target-wix/lib/contact-import.js +133 -0
  540. package/skills/wix-replatform/resources/rp-target-wix/lib/contract-ledger.js +13 -4
  541. package/skills/wix-replatform/resources/rp-target-wix/lib/coupon-redemption-drift.js +491 -0
  542. package/skills/wix-replatform/resources/rp-target-wix/lib/customer-member.js +104 -0
  543. package/skills/wix-replatform/resources/rp-target-wix/lib/data-extension-schema.js +673 -0
  544. package/skills/wix-replatform/resources/rp-target-wix/lib/domain-knowledge.js +453 -2
  545. package/skills/wix-replatform/resources/rp-target-wix/lib/gift-card-balance-reconciliation.js +119 -0
  546. package/skills/wix-replatform/resources/rp-target-wix/lib/gift-card-build.js +566 -0
  547. package/skills/wix-replatform/resources/rp-target-wix/lib/gift-card-redemption-build.js +249 -0
  548. package/skills/wix-replatform/resources/rp-target-wix/lib/order-applied-discount-build.js +63 -0
  549. package/skills/wix-replatform/resources/rp-target-wix/lib/order-buyer.js +187 -0
  550. package/skills/wix-replatform/resources/rp-target-wix/lib/order-channel-build.js +64 -0
  551. package/skills/wix-replatform/resources/rp-target-wix/lib/order-history.js +1027 -0
  552. package/skills/wix-replatform/resources/rp-target-wix/lib/order-invoice-contract.js +90 -0
  553. package/skills/wix-replatform/resources/rp-target-wix/lib/order-payment-mapping.js +420 -0
  554. package/skills/wix-replatform/resources/rp-target-wix/lib/pricing-plan-definition.js +177 -0
  555. package/skills/wix-replatform/resources/rp-target-wix/lib/product-import.js +151 -0
  556. package/skills/wix-replatform/resources/rp-target-wix/lib/product-seo.js +723 -0
  557. package/skills/wix-replatform/resources/rp-target-wix/lib/seo-redirects.js +353 -0
  558. package/skills/wix-replatform/resources/rp-target-wix/lib/shipping-build.js +1437 -0
  559. package/skills/wix-replatform/resources/rp-target-wix/lib/shipping-option-stage.js +354 -0
  560. package/skills/wix-replatform/resources/rp-target-wix/lib/store-config-build.js +134 -0
  561. package/skills/wix-replatform/resources/rp-target-wix/lib/stores-category-attach.js +221 -0
  562. package/skills/wix-replatform/resources/rp-target-wix/lib/stores-inventory.js +248 -0
  563. package/skills/wix-replatform/resources/rp-target-wix/lib/stores-verification.js +86 -3
  564. package/skills/wix-replatform/resources/rp-target-wix/lib/tax-build.js +231 -0
  565. package/skills/wix-replatform/resources/rp-target-wix/lib/url-mapper-transport.js +28 -0
  566. package/skills/wix-replatform/resources/rp-target-wix/lib/value-utils.js +14 -0
  567. package/skills/wix-replatform/resources/rp-target-wix/lib/variant-correlation.js +34 -0
  568. package/skills/wix-replatform/resources/rp-target-wix/lib/wix-build.js +166 -15
  569. package/skills/wix-replatform/resources/rp-target-wix/lib/wix-target-spec.js +19 -2
  570. package/skills/wix-replatform/resources/rp-target-wix/lib/wix-writers.js +4079 -257
  571. package/skills/wix-replatform/resources/rp-target-wix/lib/write-verification.js +3 -0
  572. package/skills/wix-replatform/resources/rp-target-wix/scripts/docs-survey-sync.js +150 -0
  573. package/skills/wix-replatform/resources/rp-target-wix/scripts/domain-knowledge-validate.js +40 -2
  574. package/skills/wix-replatform/resources/rp-target-wix/scripts/verify-stores.js +6 -1
  575. package/skills/wix-replatform/resources/rp-telemetry/SKILL.md +148 -8
  576. package/skills/wix-replatform/resources/rp-telemetry/lib/bi-sink.js +83 -15
  577. package/skills/wix-replatform/resources/rp-telemetry/lib/telemetry-recorder.js +1119 -215
  578. package/skills/wix-replatform/resources/rp-telemetry/lib/transcript-digest.js +318 -0
  579. package/skills/wix-replatform/resources/rp-telemetry/scripts/meter-from-audit.js +2 -2
  580. package/skills/wix-replatform/resources/rp-telemetry/scripts/rp-telemetry.js +106 -4
  581. package/skills/wix-replatform/resources/rp-website-continuation/SKILL.md +94 -0
  582. package/skills/wix-replatform/scripts/census-reconciliation.js +25 -0
  583. package/skills/wix-replatform/scripts/cms-fallback.js +89 -0
  584. package/skills/wix-replatform/scripts/discovered-census.js +26 -0
  585. package/skills/wix-replatform/scripts/discovered-set-status.js +33 -0
  586. package/skills/wix-replatform/scripts/entity-qa-attestation.js +130 -0
  587. package/skills/wix-replatform/scripts/execution-health-check.js +415 -0
  588. package/skills/wix-replatform/scripts/execution-manifest-validate.js +1 -1
  589. package/skills/wix-replatform/scripts/execution-state-prepare.js +1 -1
  590. package/skills/wix-replatform/scripts/expectations-ledger.js +44 -0
  591. package/skills/wix-replatform/scripts/import-contract-verify.js +183 -0
  592. package/skills/wix-replatform/scripts/internal-link-audit.js +90 -0
  593. package/skills/wix-replatform/scripts/item-seo-tags-verify.js +205 -0
  594. package/skills/wix-replatform/scripts/migration-completion.js +76 -0
  595. package/skills/wix-replatform/scripts/orchestration-preflight.js +21 -2
  596. package/skills/wix-replatform/scripts/orchestration-route.js +32 -1
  597. package/skills/wix-replatform/scripts/orchestration-state.js +146 -10
  598. package/skills/wix-replatform/scripts/read-back-gate.js +175 -0
  599. package/skills/wix-replatform/scripts/replatform-console.js +146 -0
  600. package/skills/wix-replatform/scripts/replatform.js +436 -0
  601. package/skills/wix-replatform/scripts/source-secrets.js +77 -0
  602. package/skills/wix-replatform/scripts/url-redirects.js +286 -0
  603. package/skills/wix-replatform/scripts/user-action.js +58 -0
  604. package/skills/wix-replatform/scripts/website-handoff-generate.js +64 -0
  605. package/skills/wix-replatform/scripts/wix-dashboard-url.js +54 -0
  606. package/skills/wix-replatform/scripts/wix-destination.js +143 -0
  607. package/skills/wix-replatform/scripts/wix-headless-scaffold.js +762 -0
  608. package/skills/wix-vibe-headless/SKILL.md +7 -3
  609. package/skills/wix-vibe-headless/install/deploy.cjs +61 -34
  610. package/skills/wix-vibe-headless/platforms/base44.md +1 -0
  611. package/skills/wix-vibe-headless/references/donations/INSTRUCTIONS.md +88 -0
  612. package/skills/wix-vibe-headless/references/donations/app/rest/wix-donations.js +112 -0
  613. package/skills/wix-vibe-headless/references/donations/seed/SEED.md +11 -0
  614. package/skills/wix-vibe-headless/references/donations/tests/donations.test.mjs +258 -0
  615. package/skills/wix-vibe-headless/references/restaurants/INSTRUCTIONS.md +5 -2
  616. package/skills/wix-vibe-headless/references/restaurants/app/context/OrderCartContext.jsx +4 -1
  617. package/skills/wix-vibe-headless/references/restaurants/app/rest/wix-restaurants-ordering.js +67 -3
  618. package/skills/wix-vibe-headless/references/shared/app/rest/wix-client.js +4 -3
  619. package/skills/wix-replatform/resources/rp-target-wix/SPEC-product-reviews-and-blog-authorship.md +0 -330
@@ -2,7 +2,10 @@
2
2
 
3
3
  const fs = require('node:fs/promises');
4
4
  const path = require('node:path');
5
+ const { randomUUID } = require('node:crypto');
5
6
  const { createProgressLogger, parseProgressArgs } = require('../../../lib/progress-log.js');
7
+ const { readEnvFile } = require('../../../lib/config-env.js');
8
+ const { buildWordPressCoverageRows, buildCoverageFile, ADAPTER_RAW_DIRS } = require('../../../lib/source-coverage.js');
6
9
 
7
10
  // Transport, auth, throttling, and pagination-header parsing live in the shared
8
11
  // adapter lib so the bulk-extract reader generated by rp-import-codegen inherits
@@ -17,7 +20,65 @@ const {
17
20
  fetchJson,
18
21
  parseTotalHeader,
19
22
  } = require('../lib/wp-http.js');
20
- const { classifyRoutes, summarizeSkippedByCategory } = require('../lib/wp-route-classifier.js');
23
+ const {
24
+ classifyRoutes,
25
+ summarizeSkippedByCategory,
26
+ buildRegisteredRestBases,
27
+ defaultPluginRules,
28
+ defaultQueryFor,
29
+ defaultQueryReasonFor,
30
+ } = require('../lib/wp-route-classifier.js');
31
+ // Plugin awareness: detection runs before classification so profile routes are
32
+ // in scope; embedded detection and Tier-B derivation run after sampling because they need
33
+ // real record payloads and the accepted route set.
34
+ const { gatherInventory, inventoryPayload } = require('./wp-plugin-inventory.js');
35
+ // discover-structure/query-structure: the only source for entities whose
36
+ // blocked[].fulfillment.kind is structure-bridge-plugin -- data with no REST route at all.
37
+ const {
38
+ discoverStructure, queryStructure, guardedValueColumns, violatesTierRule,
39
+ discoverEavKeys, buildEavReadPlan,
40
+ } = require('../lib/wix-wp-plugin-v2-client.js');
41
+ const {
42
+ pluginsRoot,
43
+ loadProfiles,
44
+ loadNoMigrationNeeded,
45
+ loadRequiresDevelopment,
46
+ loadPendingDecisions,
47
+ loadFingerprintAliases,
48
+ loadCmsFallbackEligible,
49
+ CHILD_ROUTE_PLACEHOLDER,
50
+ buildResponseEnvelopes,
51
+ buildRequestOverrides,
52
+ buildResponseFragmentGroups,
53
+ buildRecordKeyFields,
54
+ } = require('../lib/plugin-knowledge.js');
55
+ const {
56
+ buildDispositionRows,
57
+ summarizeDispositions,
58
+ } = require('../lib/plugin-disposition.js');
59
+ const {
60
+ cmsFallbackDecisionKeys,
61
+ cmsFallbackDecisionShape,
62
+ capabilityOfKey: cmsFallbackCapabilityOfKey,
63
+ cmsFallbackResolutionInputs,
64
+ cmsFallbackInputsDigest,
65
+ detectedPluginsOf,
66
+ } = require('../../../lib/plugin-cms-fallback.js');
67
+ const {
68
+ detectPlugins,
69
+ describeProfiledEntity,
70
+ collectRecordProperties,
71
+ collectUnprofiledRoutes,
72
+ collectCandidateNamespaces,
73
+ deriveGenericEntities,
74
+ classifyCoverage,
75
+ coverageSummary,
76
+ } = require('../lib/wp-plugin-detect.js');
77
+ const {
78
+ collectAllIds,
79
+ queryInBatches,
80
+ DEFAULT_BATCH_SIZE,
81
+ } = require('../lib/sampled-ids-batch.js');
21
82
 
22
83
  const DEFAULT_SAMPLE_LIMIT = 3;
23
84
  let progress;
@@ -29,6 +90,18 @@ function printUsage() {
29
90
  Required:
30
91
  --base-url <url> WordPress site base URL, e.g. https://example.com
31
92
  --out-dir <dir> Directory to write discovery markdown files into
93
+ --decisions <path> orchestration/decisions.json to read batched-ask answers from
94
+ (default: <out-dir>/../../orchestration/decisions.json)
95
+ --env-file <path> Load defaults from a project-local env file
96
+
97
+ Reclassify without refetching (no source network calls):
98
+ node wp-discovery.js --reclassify-coverage --out-dir <dir> [--decisions <path>]
99
+ [--canonical-coverage <path>]
100
+ Rebuilds <out-dir>/plugin-coverage.json from the stored plugin-inventory.json, the prior
101
+ coverage's entityStats/review evidence, and the current profiles, registers, target
102
+ knowledge and decisions. Also rewrites --canonical-coverage (default:
103
+ <out-dir>/../../discovery/plugin-coverage.json when that directory exists). Exits 3 with
104
+ outcome needs-full-discovery, writing nothing, when the stored evidence is incomplete.
32
105
 
33
106
  Authentication options:
34
107
  --username <name> WordPress username for Application Password auth
@@ -44,6 +117,8 @@ Optional:
44
117
  --max-retries <n> Retries on 429/503 (honors Retry-After). Default: 3
45
118
  --commerce-mode <mode> WooCommerce read mode: public | authenticated.
46
119
  Defaults to public without auth, otherwise authenticated.
120
+ --no-plugin-inventory Skip plugin detection, Tier-B derivation, and coverage.
121
+ --no-html-fingerprint Skip the homepage fetch used for asset-path fingerprints.
47
122
  --include-namespace <ns> Only inspect a namespace. Can be repeated.
48
123
  --include-route <path> Force-sample a route. Can be repeated.
49
124
  --include-excluded-category <category>
@@ -81,6 +156,8 @@ function parseArgs(argv) {
81
156
  rateLimitRpm: DEFAULT_RATE_LIMIT_RPM,
82
157
  maxRetries: DEFAULT_MAX_RETRIES,
83
158
  commerceMode: null,
159
+ pluginInventory: true,
160
+ htmlFingerprint: true,
84
161
  };
85
162
 
86
163
  for (let i = 0; i < argv.length; i += 1) {
@@ -100,6 +177,14 @@ function parseArgs(argv) {
100
177
  args.outDir = next;
101
178
  i += 1;
102
179
  break;
180
+ case '--decisions':
181
+ args.decisions = next;
182
+ i += 1;
183
+ break;
184
+ case '--env-file':
185
+ args.envFile = next;
186
+ i += 1;
187
+ break;
103
188
  case '--username':
104
189
  args.username = next;
105
190
  i += 1;
@@ -160,6 +245,28 @@ function parseArgs(argv) {
160
245
  args.overrideReason = next;
161
246
  i += 1;
162
247
  break;
248
+ case '--no-plugin-inventory':
249
+ args.pluginInventory = false;
250
+ break;
251
+ case '--no-html-fingerprint':
252
+ args.htmlFingerprint = false;
253
+ break;
254
+ case '--reclassify-coverage':
255
+ args.reclassifyCoverage = true;
256
+ break;
257
+ case '--canonical-coverage':
258
+ args.canonicalCoverage = next;
259
+ i += 1;
260
+ break;
261
+ // Fixture-tree overrides for tests; both default to the installed skill.
262
+ case '--plugins-root':
263
+ args.pluginsRoot = next;
264
+ i += 1;
265
+ break;
266
+ case '--target-knowledge-root':
267
+ args.targetKnowledgeRoot = next;
268
+ i += 1;
269
+ break;
163
270
  default:
164
271
  if (arg.startsWith('--')) {
165
272
  throw new Error(`Unknown argument: ${arg}`);
@@ -185,6 +292,9 @@ function parseArgs(argv) {
185
292
  if (!args.applicationPassword) {
186
293
  args.applicationPassword = process.env.WP_APPLICATION_PASSWORD;
187
294
  }
295
+ if (!args.migrationKey) {
296
+ args.migrationKey = process.env.WMH2_MIGRATION_KEY;
297
+ }
188
298
  if (args.authHeaders.length === 0 && process.env.WP_AUTH_HEADER) {
189
299
  args.authHeaders.push(process.env.WP_AUTH_HEADER);
190
300
  }
@@ -210,6 +320,37 @@ function parseArgs(argv) {
210
320
  return args;
211
321
  }
212
322
 
323
+ async function hydrateArgsFromEnvFile(args) {
324
+ if (!args.envFile) {
325
+ return args;
326
+ }
327
+
328
+ const envValues = await readEnvFile(path.resolve(args.envFile));
329
+ if (!args.baseUrl && envValues.WP_BASE_URL) {
330
+ args.baseUrl = envValues.WP_BASE_URL;
331
+ }
332
+ if (!args.username && envValues.WP_USERNAME) {
333
+ args.username = envValues.WP_USERNAME;
334
+ }
335
+ if (!args.applicationPassword && envValues.WP_APPLICATION_PASSWORD) {
336
+ args.applicationPassword = envValues.WP_APPLICATION_PASSWORD;
337
+ }
338
+ if (!args.migrationKey && envValues.WMH2_MIGRATION_KEY) {
339
+ args.migrationKey = envValues.WMH2_MIGRATION_KEY;
340
+ }
341
+ if (!args.apiKey && envValues.WP_API_KEY) {
342
+ args.apiKey = envValues.WP_API_KEY;
343
+ }
344
+ if (!args.apiKeyHeader && envValues.WP_API_KEY_HEADER) {
345
+ args.apiKeyHeader = envValues.WP_API_KEY_HEADER;
346
+ }
347
+ if (args.authHeaders.length === 0 && envValues.WP_AUTH_HEADER) {
348
+ args.authHeaders.push(envValues.WP_AUTH_HEADER);
349
+ }
350
+
351
+ return args;
352
+ }
353
+
213
354
  function endpointMethods(endpoint) {
214
355
  const raw = endpoint?.methods;
215
356
  if (Array.isArray(raw)) {
@@ -280,6 +421,28 @@ function summarizeAuthMode(args) {
280
421
  return 'none';
281
422
  }
282
423
 
424
+ function summarizeBridgeAuthMode(args, namespaces) {
425
+ const hasWooCommerce = namespaces.some((namespace) => namespace.startsWith('wc/'));
426
+ const hasRestCredential = Boolean(
427
+ (args.username && args.applicationPassword) || args.apiKey || args.authHeaders.length > 0,
428
+ );
429
+ if (args.migrationKey) return 'migration-key';
430
+ if (hasWooCommerce && hasRestCredential) return 'wordpress-rest-credential';
431
+ if (hasRestCredential) return 'unavailable-without-woocommerce-capability';
432
+ return 'none';
433
+ }
434
+
435
+ function chooseBridgeAuth({ migrationKey, timeoutMs }) {
436
+ const useMigrationKey = Boolean(migrationKey);
437
+ return {
438
+ auth: useMigrationKey
439
+ ? { type: 'migration-key', migrationKey, migrationId: randomUUID(), timeoutMs }
440
+ : undefined,
441
+ structureMethod: useMigrationKey ? 'POST' : 'GET',
442
+ queryRoute: useMigrationKey ? '/wix-wp-plugin/v2/query' : '/wix-wp-plugin/v2/query/admin-key',
443
+ };
444
+ }
445
+
283
446
  function summarizeOverrides(args) {
284
447
  return {
285
448
  includeRoutes: args.includeRoutes,
@@ -291,7 +454,7 @@ function summarizeOverrides(args) {
291
454
  };
292
455
  }
293
456
 
294
- function deriveEntityCandidates(indexJson, includeNamespaces) {
457
+ function deriveEntityCandidates(indexJson, includeNamespaces, requestOverrides = new Map()) {
295
458
  const routes = indexJson?.routes || {};
296
459
  const candidates = [];
297
460
 
@@ -311,7 +474,13 @@ function deriveEntityCandidates(indexJson, includeNamespaces) {
311
474
  }
312
475
 
313
476
  const endpoints = Array.isArray(routeDefinition?.endpoints) ? routeDefinition.endpoints : [];
314
- const getEndpoint = endpoints.find((endpoint) => endpointMethods(endpoint).includes('GET'));
477
+ // A profile may declare that this entity's real read path is not GET (see
478
+ // plugin-knowledge.js buildRequestOverrides) — the declared method then stands in for
479
+ // the GET-collection requirement below, generically for any plugin/entity.
480
+ const requestOverride = requestOverrides.get(routePath) || null;
481
+ const getEndpoint = requestOverride
482
+ ? endpoints.find((endpoint) => endpointMethods(endpoint).includes(requestOverride.method))
483
+ : endpoints.find((endpoint) => endpointMethods(endpoint).includes('GET'));
315
484
  if (!getEndpoint) {
316
485
  continue;
317
486
  }
@@ -320,7 +489,11 @@ function deriveEntityCandidates(indexJson, includeNamespaces) {
320
489
  const supportsPagination = Boolean(getEndpoint?.args?.page || getEndpoint?.args?.per_page);
321
490
  const hasSchema = Boolean(getEndpoint?.schema || routeDefinition?.schema);
322
491
 
323
- if (!hasSchema && !supportsPagination && segments.length < 3) {
492
+ // The generic shape heuristic (schema or pagination or 3+ path segments) exists to
493
+ // filter out config/dashboard noise when nothing else vouches for a route. A profile
494
+ // explicitly declaring a request override already is that vouching — same principle as
495
+ // profile-declared routes outranking the classifier's shape rules.
496
+ if (!requestOverride && !hasSchema && !supportsPagination && segments.length < 3) {
324
497
  continue;
325
498
  }
326
499
 
@@ -337,6 +510,7 @@ function deriveEntityCandidates(indexJson, includeNamespaces) {
337
510
  getEndpoint,
338
511
  routeDefinition,
339
512
  supportsPagination,
513
+ requestOverride,
340
514
  fileName: `${slugify(namespace)}--${pathSlug}.md`,
341
515
  });
342
516
  }
@@ -352,6 +526,102 @@ function deriveEntityCandidates(indexJson, includeNamespaces) {
352
526
  return [...unique.values()].sort((a, b) => a.routePath.localeCompare(b.routePath));
353
527
  }
354
528
 
529
+ // Finds every route named by a "$SAMPLED_IDS:<route>" placeholder anywhere
530
+ // inside a requestOverride body, however deeply nested. A body may reference more than one
531
+ // route (e.g. two independent id lists); collecting all of them, not just the first match, is
532
+ // what lets the pagination+batch mechanism below (lib/sampled-ids-batch.js) discover every
533
+ // route it must paginate to exhaustion rather than resolving one placeholder to []. Generic
534
+ // body-walk, no field names baked in.
535
+ function findSampledIdsDependencies(value, found = new Set()) {
536
+ if (Array.isArray(value)) {
537
+ for (const item of value) {
538
+ findSampledIdsDependencies(item, found);
539
+ }
540
+ } else if (value && typeof value === 'object') {
541
+ for (const nested of Object.values(value)) {
542
+ findSampledIdsDependencies(nested, found);
543
+ }
544
+ } else if (typeof value === 'string') {
545
+ const match = value.match(/^\$SAMPLED_IDS:(.+)$/);
546
+ if (match) found.add(match[1]);
547
+ }
548
+ return found;
549
+ }
550
+
551
+ // Resolves a dot-path ("data.items", "data.meta.count") against a response body for a
552
+ // responseEnvelope-declaring entity. Returns undefined on any missing/non-object segment
553
+ // rather than throwing, so an envelope path that stops matching (a plugin update, a stale
554
+ // profile) degrades to the safe fallback in inspectEntity instead of crashing the run.
555
+ function getAtPath(value, dotPath) {
556
+ return String(dotPath).split('.').reduce(
557
+ (acc, key) => (acc && typeof acc === 'object' ? acc[key] : undefined),
558
+ value,
559
+ );
560
+ }
561
+
562
+ // Deep-resolves a profile-declared requestBody template against a batch's ids. `idsByRoute` is
563
+ // a plain `{ route: string[] }` map — for the $SAMPLED_IDS mechanism this is
564
+ // always the CURRENT BATCH's ids for the route being paginated, resolved fresh per batch, never
565
+ // a fixed full list baked into one oversized request. Generic across any entity/route pair —
566
+ // the placeholder names the OTHER route's ids it wants, nothing plugin-specific lives here.
567
+ function resolveRequestBody(template, idsByRoute) {
568
+ if (Array.isArray(template)) {
569
+ return template.map((value) => resolveRequestBody(value, idsByRoute));
570
+ }
571
+ if (template && typeof template === 'object') {
572
+ const resolved = {};
573
+ for (const [key, value] of Object.entries(template)) {
574
+ resolved[key] = resolveRequestBody(value, idsByRoute);
575
+ }
576
+ return resolved;
577
+ }
578
+ if (typeof template === 'string') {
579
+ const match = template.match(/^\$SAMPLED_IDS:(.+)$/);
580
+ if (match) {
581
+ return (idsByRoute && idsByRoute[match[1]]) || [];
582
+ }
583
+ }
584
+ return template;
585
+ }
586
+
587
+ // Envelope resolution + fragment-group reassembly, shared by the single-fetch path below and
588
+ // by every batch of the paginate+batch path (lib/sampled-ids-batch.js) — one profile's response
589
+ // shape must normalize the same way regardless of which path fetched it. Pushes discovery
590
+ // notes only when `notes` is provided (batched callers pass it for the first batch only, since
591
+ // the shape characteristic belongs to the endpoint, not to any one batch). Returns `{ ok,
592
+ // records }`: `ok: false` means the payload did not resolve to an array after envelope
593
+ // resolution (when declared) and fragment reassembly (when declared) — a genuine shape
594
+ // mismatch, not "zero records" — and callers on the batched path must treat that as a failure
595
+ // to defer on, never silently as an empty batch (an enveloped response whose itemsPath
596
+ // mismatches would otherwise look like an authoritative, exact zero).
597
+ function normalizeResponseRecords(payload, { envelope, fragmentGroupSize, notes } = {}) {
598
+ let effectivePayload = payload;
599
+ if (envelope) {
600
+ const items = getAtPath(payload, envelope.itemsPath);
601
+ if (Array.isArray(items)) {
602
+ effectivePayload = items;
603
+ } else if (notes) {
604
+ notes.push(`responseEnvelope.itemsPath="${envelope.itemsPath}" did not resolve to an array on this response; falling back to the raw payload shape. The profile may be stale or the plugin version differs.`);
605
+ }
606
+ }
607
+ if (fragmentGroupSize && Array.isArray(effectivePayload)) {
608
+ const completeGroups = Math.floor(effectivePayload.length / fragmentGroupSize);
609
+ const reassembled = [];
610
+ for (let i = 0; i < completeGroups; i += 1) {
611
+ reassembled.push(Object.assign({}, ...effectivePayload.slice(i * fragmentGroupSize, (i + 1) * fragmentGroupSize)));
612
+ }
613
+ if (notes && effectivePayload.length % fragmentGroupSize !== 0) {
614
+ notes.push(`Response length ${effectivePayload.length} is not a multiple of the declared responseFragmentGroupSize=${fragmentGroupSize}; the trailing ${effectivePayload.length % fragmentGroupSize} fragment(s) were dropped rather than emitted as a broken record.`);
615
+ }
616
+ if (notes) {
617
+ notes.push(`Response records were flattened into groups of ${fragmentGroupSize} single-key fragments (per profile responseFragmentGroupSize) and reassembled into one object per record.`);
618
+ }
619
+ effectivePayload = reassembled;
620
+ }
621
+ const ok = Array.isArray(effectivePayload);
622
+ return { ok, records: ok ? effectivePayload : [] };
623
+ }
624
+
355
625
  async function inspectEntity(baseUrl, headers, candidate, options) {
356
626
  const details = {
357
627
  entityName: candidate.entityName,
@@ -408,46 +678,137 @@ async function inspectEntity(baseUrl, headers, candidate, options) {
408
678
  });
409
679
  }
410
680
 
411
- const query = candidate.supportsPagination ? { per_page: options.sampleLimit } : {};
412
- const sampleResponse = await fetchJson(baseUrl, candidate.routePath, {
413
- headers,
414
- method: 'GET',
415
- query,
416
- timeoutMs: options.timeoutMs,
417
- progress: options.progress,
418
- progressContext: {
419
- step: 'inspect-endpoint',
420
- entity: candidate.routePath,
421
- },
422
- });
681
+ // A profile may declare that this entity's real read path is a non-GET request with a
682
+ // JSON body — generic across any plugin/entity, not special-cased here.
683
+ const requestOverride = options.requestOverride || null;
684
+ const dependencyRoutes = requestOverride ? [...findSampledIdsDependencies(requestOverride.body)] : [];
685
+
686
+ if (requestOverride && dependencyRoutes.length > 0) {
687
+ // The $SAMPLED_IDS mechanism always means "paginate the dependency route to exhaustion,
688
+ // then batch-query this route" — the dependency's record count is unknown, so
689
+ // there is no bounded "small sample" variant that is safe to assume complete. This is the
690
+ // ENTIRE meaning of a $SAMPLED_IDS placeholder now, in both discovery and any generated
691
+ // reader (see rp-import-codegen's sourceMeta contract).
692
+ return inspectDependentEntity(baseUrl, headers, candidate, options, details, requestOverride, dependencyRoutes);
693
+ }
694
+
695
+ let sampleResponse;
696
+ if (requestOverride) {
697
+ // A fixed-body override with no $SAMPLED_IDS placeholder — single request, unbounded by
698
+ // definition since nothing here scales with another route's record count.
699
+ const resolvedBody = resolveRequestBody(requestOverride.body, {});
700
+ details.discoveryNotes.push(
701
+ `Sampled via profile-declared ${requestOverride.method} request with a JSON body, not a plain GET collection.`,
702
+ );
703
+ sampleResponse = await fetchJson(baseUrl, candidate.routePath, {
704
+ // `headers` is a real Headers instance (wp-http.js buildHeaders) — spreading it
705
+ // would silently drop every entry including Authorization, since Headers is not a
706
+ // plain object. Clone it properly instead.
707
+ headers: (() => {
708
+ const withBody = new Headers(headers);
709
+ withBody.set('content-type', 'application/json');
710
+ return withBody;
711
+ })(),
712
+ method: requestOverride.method,
713
+ body: JSON.stringify(resolvedBody),
714
+ timeoutMs: options.timeoutMs,
715
+ progress: options.progress,
716
+ progressContext: {
717
+ step: 'inspect-endpoint',
718
+ entity: candidate.routePath,
719
+ },
720
+ });
721
+ } else {
722
+ // Per-route default query (see ROUTE_DEFAULT_QUERY_RULES): some collection routes apply
723
+ // a default filter when the caller sends none, so sampling with `per_page` alone reads a
724
+ // subset and the plan under-counts. Paging is layered on top; a route with no rule is
725
+ // unchanged.
726
+ const defaultQuery = options.defaultQuery || {};
727
+ const query = {
728
+ ...defaultQuery,
729
+ ...(candidate.supportsPagination ? { per_page: options.sampleLimit } : {}),
730
+ };
731
+ if (Object.keys(defaultQuery).length > 0) {
732
+ const pairs = Object.entries(defaultQuery).map(([key, value]) => `${key}=${value}`).join('&');
733
+ const reason = options.defaultQueryReason ? ` — ${options.defaultQueryReason}` : '';
734
+ details.discoveryNotes.push(`Sampled with route default query ${pairs} so the full collection is counted${reason}. Generated readers must send the same parameters.`);
735
+ }
736
+
737
+ sampleResponse = await fetchJson(baseUrl, candidate.routePath, {
738
+ headers,
739
+ method: 'GET',
740
+ query,
741
+ timeoutMs: options.timeoutMs,
742
+ progress: options.progress,
743
+ progressContext: {
744
+ step: 'inspect-endpoint',
745
+ entity: candidate.routePath,
746
+ },
747
+ });
748
+ }
423
749
 
424
750
  if (sampleResponse.ok) {
425
751
  const payload = sampleResponse.json;
426
752
  const totalFromHeader = parseTotalHeader(sampleResponse.headers);
427
- if (Array.isArray(payload)) {
428
- details.responseShape = 'array';
429
- details.sampleRecords = payload.slice(0, options.sampleLimit);
430
- details.sampleRecordCount = payload.length;
431
- details.recordCount = totalFromHeader !== null ? totalFromHeader : payload.length;
753
+
754
+ // responseEnvelope support: some plugin REST APIs (MailPoet's
755
+ // /mailpoet/v1/* namespace, verified live 2026-08-11) wrap their records in a body path
756
+ // instead of returning a flat array, and carry no X-WP-Total/X-WP-TotalPages headers —
757
+ // the total lives inside the body too. Unwrap to the declared path and otherwise treat it
758
+ // exactly like a flat array; a path that no longer resolves (stale profile, plugin
759
+ // version drift) falls back to the raw payload rather than failing the run.
760
+ const envelope = options.responseEnvelope || null;
761
+ let effectivePayload = payload;
762
+ let envelopeCount = null;
763
+ if (envelope) {
764
+ const items = getAtPath(payload, envelope.itemsPath);
765
+ if (Array.isArray(items)) {
766
+ effectivePayload = items;
767
+ envelopeCount = envelope.countPath ? getAtPath(payload, envelope.countPath) : null;
768
+ } else {
769
+ details.discoveryNotes.push(`responseEnvelope.itemsPath="${envelope.itemsPath}" did not resolve to an array on this response; falling back to the raw payload shape. The profile may be stale or the plugin version differs.`);
770
+ }
771
+ }
772
+
773
+ // responseFragmentGroupSize support: some plugin REST APIs (Back In Stock Notifier's
774
+ // list_subscriber, verified live 2026-08-19) emit each logical record as N separate
775
+ // single-key array entries in sequence instead of one merged object. Reassemble every N
776
+ // entries into one record via Object.assign before anything downstream counts or samples
777
+ // — a reader built from a stale sample would otherwise see 4x the real record count and a
778
+ // schema missing whichever key happened to be sampled out of order. A trailing partial
779
+ // group (malformed response, plugin bug) is dropped and noted rather than emitted broken.
780
+ const fragmentGroupSize = options.responseFragmentGroupSize || null;
781
+ if (fragmentGroupSize && Array.isArray(effectivePayload)) {
782
+ effectivePayload = normalizeResponseRecords(effectivePayload, { fragmentGroupSize, notes: details.discoveryNotes }).records;
783
+ }
784
+
785
+ if (Array.isArray(effectivePayload)) {
786
+ details.responseShape = envelope && effectivePayload !== payload ? 'enveloped-array' : 'array';
787
+ details.sampleRecords = effectivePayload.slice(0, options.sampleLimit);
788
+ details.sampleRecordCount = effectivePayload.length;
789
+ const hasEnvelopeCount = typeof envelopeCount === 'number';
790
+ details.recordCount = hasEnvelopeCount ? envelopeCount : (totalFromHeader !== null ? totalFromHeader : effectivePayload.length);
432
791
  details.inUse = details.recordCount > 0;
433
- if (totalFromHeader === null) {
792
+ if (details.responseShape === 'enveloped-array' && !hasEnvelopeCount) {
793
+ details.discoveryNotes.push(`responseEnvelope has no working countPath (itemsPath="${envelope.itemsPath}"); recordCount reflects only the sampled page and may undercount the true total.`);
794
+ } else if (details.responseShape === 'array' && totalFromHeader === null) {
434
795
  details.discoveryNotes.push('No X-WP-Total header returned; recordCount reflects only the sampled page and may undercount the true total.');
435
796
  }
436
797
  if (candidate.routePath.startsWith('/wc/store/v1/') && !Object.keys(sampleResponse.headers || {}).some((key) => key.toLowerCase() === 'x-wp-totalpages')) {
437
798
  details.discoveryNotes.push('WooCommerce Store API route does not advertise X-WP-TotalPages; generated readers must stop on a short page when bulk-extracting this entity.');
438
799
  }
439
- if (payload.length === 0) {
800
+ if (effectivePayload.length === 0) {
440
801
  details.discoveryNotes.push('Endpoint returned an empty array. The entity is advertised but appears unused (no records).');
441
802
  }
442
- } else if (payload && typeof payload === 'object') {
803
+ } else if (effectivePayload && typeof effectivePayload === 'object') {
443
804
  details.responseShape = 'object';
444
- details.sampleRecords = [payload];
805
+ details.sampleRecords = [effectivePayload];
445
806
  details.sampleRecordCount = 1;
446
807
  details.recordCount = totalFromHeader !== null ? totalFromHeader : 1;
447
808
  details.inUse = details.recordCount > 0;
448
809
  } else {
449
- details.responseShape = typeof payload;
450
- details.discoveryNotes.push(`Endpoint returned a non-object payload of type ${typeof payload}.`);
810
+ details.responseShape = typeof effectivePayload;
811
+ details.discoveryNotes.push(`Endpoint returned a non-object payload of type ${typeof effectivePayload}.`);
451
812
  }
452
813
 
453
814
  const firstRecord = details.sampleRecords[0];
@@ -456,7 +817,7 @@ async function inspectEntity(baseUrl, headers, candidate, options) {
456
817
  }
457
818
  } else {
458
819
  details.requestErrors.push({
459
- request: 'GET',
820
+ request: requestOverride ? requestOverride.method : 'GET',
460
821
  routePath: candidate.routePath,
461
822
  status: sampleResponse.status,
462
823
  statusText: sampleResponse.statusText,
@@ -468,6 +829,106 @@ async function inspectEntity(baseUrl, headers, candidate, options) {
468
829
  return details;
469
830
  }
470
831
 
832
+ // Paginates every $SAMPLED_IDS dependency route to exhaustion, then batch-queries `candidate`'s
833
+ // route — split out of inspectEntity because it is a fundamentally different shape
834
+ // (two routes, many requests, an explicit fail/defer path) from a single-fetch inspection.
835
+ // Assumes a single batching axis: when a body references more than one dependency route, only
836
+ // the first drives batching (noted below) — no known profile needs two independent id lists
837
+ // batched together, and this stays honest about that boundary rather than guessing a policy.
838
+ async function inspectDependentEntity(baseUrl, headers, candidate, options, details, requestOverride, dependencyRoutes) {
839
+ const batchRoute = dependencyRoutes[0];
840
+ if (dependencyRoutes.length > 1) {
841
+ details.discoveryNotes.push(
842
+ `requestBody references multiple $SAMPLED_IDS routes (${dependencyRoutes.join(', ')}); only the first, ${batchRoute}, drives pagination/batching — a profile needing more than one independent id list is not yet supported generically.`,
843
+ );
844
+ }
845
+
846
+ const paged = await collectAllIds({
847
+ baseUrl,
848
+ headers,
849
+ route: batchRoute,
850
+ timeoutMs: options.timeoutMs,
851
+ progress: options.progress,
852
+ });
853
+ if (!paged.ok) {
854
+ // Fail/defer explicitly: recordCount/inUse stay at their initial `null`, which
855
+ // is this codebase's existing "unknown, not zero" signal, backed by a requestErrors entry
856
+ // explaining exactly which page of which route failed — never a false empty or a silent
857
+ // undercount from whatever ids were collected before the failure.
858
+ details.requestErrors.push({
859
+ request: 'GET',
860
+ routePath: paged.failure.route,
861
+ status: paged.failure.status,
862
+ statusText: paged.failure.statusText,
863
+ url: null,
864
+ body: `Failed while paginating the $SAMPLED_IDS dependency route ${paged.failure.route} at page ${paged.failure.page}. ${candidate.routePath}'s record count and schema are unknown and must be treated as deferred, not reported as empty.`,
865
+ });
866
+ return details;
867
+ }
868
+
869
+ details.discoveryNotes.push(
870
+ `Sampled via profile-declared ${requestOverride.method} request with a JSON body, against the FULL paginated id list of ${batchRoute} (${paged.ids.length} ids across ${Math.ceil(paged.ids.length / DEFAULT_BATCH_SIZE)} batches of up to ${DEFAULT_BATCH_SIZE}) rather than a fixed small sample.`,
871
+ );
872
+
873
+ let shapeNotesEmitted = false;
874
+ const batched = await queryInBatches({
875
+ baseUrl,
876
+ headers,
877
+ route: candidate.routePath,
878
+ method: requestOverride.method,
879
+ ids: paged.ids,
880
+ recordKeyField: options.recordKeyField || 'id',
881
+ buildBody: (batchIds) => resolveRequestBody(requestOverride.body, { [batchRoute]: batchIds.map(String) }),
882
+ // Pass the RAW batch JSON through — response.json may be an enveloped object, not an
883
+ // array, and normalizeResponseRecords (not this callback) is what unwraps it. Returning
884
+ // its {ok, records} result unchanged is what lets queryInBatches distinguish "this batch's
885
+ // response didn't match the declared shape" from "this batch legitimately matched zero
886
+ // subscribers" and defer on the former instead of counting it as an exact zero.
887
+ normalizeBatch: (rawJson) => {
888
+ const normalized = normalizeResponseRecords(rawJson, {
889
+ envelope: options.responseEnvelope,
890
+ fragmentGroupSize: options.responseFragmentGroupSize,
891
+ notes: shapeNotesEmitted ? null : details.discoveryNotes,
892
+ });
893
+ shapeNotesEmitted = true;
894
+ return normalized;
895
+ },
896
+ timeoutMs: options.timeoutMs,
897
+ progress: options.progress,
898
+ });
899
+ if (!batched.ok) {
900
+ const shapeFailure = batched.failure.reason === 'invalid-shape';
901
+ details.requestErrors.push({
902
+ request: requestOverride.method,
903
+ routePath: batched.failure.route,
904
+ status: batched.failure.status,
905
+ statusText: batched.failure.statusText,
906
+ url: null,
907
+ body: shapeFailure
908
+ ? `Batch ${batched.failure.batchIndex + 1} (${batched.failure.batchSize} ids) returned a ${batched.failure.status} response that did not match the declared response shape (responseEnvelope/responseFragmentGroupSize). Batches already merged before this failure are discarded — ${candidate.routePath}'s record count and schema are unknown and must be treated as deferred, not reported as an exact zero.`
909
+ : `Failed on batch ${batched.failure.batchIndex + 1} (${batched.failure.batchSize} ids). Batches already merged before this failure are discarded — ${candidate.routePath}'s record count and schema are unknown and must be treated as deferred, not reported as a partial undercount.`,
910
+ });
911
+ return details;
912
+ }
913
+
914
+ details.responseShape = 'array';
915
+ details.sampleRecords = batched.records.slice(0, options.sampleLimit);
916
+ details.sampleRecordCount = batched.records.length;
917
+ // Exact, not an estimate: every dependency id was queried and every batch's records were
918
+ // deduplicated, unlike the sampled-page count elsewhere in this function.
919
+ details.recordCount = batched.records.length;
920
+ details.inUse = details.recordCount > 0;
921
+ details.discoveryNotes.push('recordCount reflects the full deduplicated merge across every batch of the complete dependency id list, not a sampled page — this total is exact.');
922
+ if (batched.records.length === 0) {
923
+ details.discoveryNotes.push('No records matched any batch across the full paginated dependency id list. The entity is advertised but appears unused (no records).');
924
+ }
925
+ const firstRecord = details.sampleRecords[0];
926
+ if (firstRecord && typeof firstRecord === 'object') {
927
+ details.relationships = summarizeRelationships(firstRecord);
928
+ }
929
+ return details;
930
+ }
931
+
471
932
  function markdownJsonBlock(value) {
472
933
  if (value === null || value === undefined) {
473
934
  return '\n\n`Unavailable`';
@@ -518,6 +979,53 @@ function renderEntityFile(details) {
518
979
  `## Sample Records${markdownJsonBlock(details.sampleRecords)}\n`;
519
980
  }
520
981
 
982
+ function renderPluginSection(context) {
983
+ if (!context.plugins) {
984
+ return `## Plugin Coverage\n\nPlugin inventory was not run for this capture.\n\n`;
985
+ }
986
+
987
+ const { detection, coverage, summary, unprofiled } = context.plugins;
988
+ const rows = coverage
989
+ .map((row) => {
990
+ const via = row.status === 'migration-planned' ? `${row.via} · ${row.confidence}` : '-';
991
+ const blocked = (row.blocked || []).length > 0
992
+ ? row.blocked.map((blocker) => `${blocker.kind}${blocker.declined ? ' (declined)' : ''}`).join(', ')
993
+ : '-';
994
+ return `| ${row.capability} | \`${row.status}\` | ${via} | ${row.recognized ? 'yes' : 'no'} | ${row.plugins.join(', ') || '-'} | \`${row.channel || 'none'}\` | ${blocked} | ${row.action ? row.action : '-'} |`;
995
+ })
996
+ .join('\n');
997
+
998
+ const authNote = detection.pluginListAvailable
999
+ ? ''
1000
+ : `**\`GET /wp/v2/plugins\` was unavailable**, so installed-but-unprofiled plugins could not be enumerated. ` +
1001
+ `Detection used REST namespaces, declared routes, registered types/taxonomies, and public asset paths only. ` +
1002
+ `Re-run with an administrator credential for a complete plugin list.\n\n`;
1003
+
1004
+ const installedRows = detection.installedButUnprofiled
1005
+ .map((entry) => `- \`${entry.plugin}\`${entry.name ? ` (${entry.name})` : ''}${entry.active ? '' : ' — inactive'}`)
1006
+ .join('\n') || '- None';
1007
+
1008
+ const unprofiledRows = unprofiled
1009
+ .map((entry) => `- \`${entry.namespace}\`: ${entry.routes.length} route(s) accepted by shape`)
1010
+ .join('\n') || '- None';
1011
+
1012
+ return `## Plugin Coverage\n\n` +
1013
+ authNote +
1014
+ `- Recognized plugins detected: ${detection.detected.length}\n` +
1015
+ `- Derived entities (no profile): ${context.plugins.genericEntities.length}\n` +
1016
+ `- Unprofiled namespaces: ${unprofiled.length}\n` +
1017
+ `- Installed but unrecognized: ${detection.installedButUnprofiled.length}\n` +
1018
+ `- Publicly fingerprinted (named, not enumerated): ${(detection.fingerprinted || []).length}\n` +
1019
+ `- Capabilities by status: ${Object.entries(summary.byStatus).map(([status, count]) => `\`${status}\`: ${count}`).join(', ') || 'none'}\n\n` +
1020
+ `| Capability | Status | Via | Recognized | Plugins | Channel | Blocked | Action needed |\n` +
1021
+ `| --- | --- | --- | --- | --- | --- | --- | --- |\n` +
1022
+ `${rows || '| None | - | - | - | - | - | - | - |'}\n\n` +
1023
+ `### Installed but unprofiled\n\n${installedRows}\n\n` +
1024
+ `### Unprofiled namespaces accepted by shape\n\n${unprofiledRows}\n\n` +
1025
+ `Full coverage evidence: [plugin-coverage.json](./plugin-coverage.json) · ` +
1026
+ `detection evidence: [plugin-inventory.json](./plugin-inventory.json)\n\n`;
1027
+ }
1028
+
521
1029
  function renderIndexFile(context) {
522
1030
  const entityRows = context.entities.map((entity) => {
523
1031
  const status = entity.requestErrors.length > 0 ? 'partial' : 'ok';
@@ -551,6 +1059,8 @@ function renderIndexFile(context) {
551
1059
  `Auth-gated entities: ${authGatedEntities.map((entity) => `\`${entity.entityName}\``).join(', ')}\n\n`
552
1060
  : '';
553
1061
 
1062
+ const pluginSection = renderPluginSection(context);
1063
+
554
1064
  return `# WordPress Discovery\n\n` +
555
1065
  `- Generated at: \`${context.generatedAt}\`\n` +
556
1066
  `- Base URL: \`${context.baseUrl}\`\n` +
@@ -568,6 +1078,7 @@ function renderIndexFile(context) {
568
1078
  `### Skipped Routes by Category\n\n${skippedByCategoryLines}\n\n` +
569
1079
  `### Overrides\n\n${overrideLines}\n\n` +
570
1080
  `Skipped route evidence: [skipped-routes.json](./skipped-routes.json)\n\n` +
1081
+ pluginSection +
571
1082
  `## Discovery Summary\n\n` +
572
1083
  `| Entity | Namespace | Route | Records | In use | Samples | Status | File |\n` +
573
1084
  `| --- | --- | --- | ---: | --- | ---: | --- | --- |\n` +
@@ -603,12 +1114,855 @@ function skippedRoutesPayload(context) {
603
1114
  };
604
1115
  }
605
1116
 
1117
+ // orchestration/decisions.json sits two levels above the discovery out-dir in the standard
1118
+ // layout (migrations/<project>/data/wp-discovery); --decisions overrides. Missing or
1119
+ // unparseable files mean "no answers yet", never an error — the ask may not have run.
1120
+ function loadDecisions(args) {
1121
+ const filePath = args.decisions
1122
+ || (args.outDir ? path.resolve(args.outDir, '..', '..', 'orchestration', 'decisions.json') : null);
1123
+ if (!filePath) return {};
1124
+ try {
1125
+ return JSON.parse(require('node:fs').readFileSync(filePath, 'utf8'));
1126
+ } catch {
1127
+ return {};
1128
+ }
1129
+ }
1130
+
1131
+ // The batched ask (J1 step 9) records one decision per blocker under the key
1132
+ // `pluginBlocker:<capability>:<kind>`; a value of `declined` (or `skipped`) marks it declined.
1133
+ function applyBlockerDecisions(rows, decisions) {
1134
+ for (const row of rows) {
1135
+ for (const blocker of row.blocked || []) {
1136
+ const entry = decisions[`pluginBlocker:${row.capability}:${blocker.kind}`];
1137
+ if (entry && ['declined', 'skipped'].includes(entry.value)) blocker.declined = true;
1138
+ }
1139
+ }
1140
+ }
1141
+
1142
+ function loadTargetKnowledge(domainsDir = null) {
1143
+ try {
1144
+ const {
1145
+ knowledgeRoot,
1146
+ knowledgeSummary,
1147
+ } = require('../../rp-target-wix/lib/domain-knowledge.js');
1148
+ return knowledgeSummary(domainsDir || knowledgeRoot(path.resolve(__dirname, '..', '..', 'rp-target-wix')));
1149
+ } catch (error) {
1150
+ // A partial install must not break discovery; coverage then reports CMS/native-gap
1151
+ // conservatively instead of resolving target refs.
1152
+ return { knownRefs: new Set(), capabilityRefs: new Map(), verificationByRef: new Map(), loadError: error.message };
1153
+ }
1154
+ }
1155
+
1156
+ // The record-count note a route's sample left (e.g. no X-WP-Total header), if any.
1157
+ function countNoteOf(sampled) {
1158
+ return (sampled.discoveryNotes || []).find((note) => /recordCount|undercount|record count/i.test(note)) || null;
1159
+ }
1160
+
1161
+ // Durable record counts and sample evidence, one key per route of every detected plugin's
1162
+ // profile entities (null when the route was not sampled). This is what lets coverage be
1163
+ // reclassified later without a source fetch and without silently dropping counts.
1164
+ function buildEntityStats(detection, sampledByRoute) {
1165
+ const stats = {};
1166
+ for (const plugin of detection?.detected || []) {
1167
+ for (const entity of plugin.entities || []) {
1168
+ if (!entity.route) continue;
1169
+ const sampled = sampledByRoute.get(entity.route);
1170
+ stats[entity.route] = sampled ? {
1171
+ recordCount: sampled.recordCount ?? null,
1172
+ inUse: sampled.inUse ?? null,
1173
+ sampleRecordCount: sampled.sampleRecordCount ?? (sampled.sampleRecords || []).length,
1174
+ countNote: countNoteOf(sampled),
1175
+ } : null;
1176
+ }
1177
+ }
1178
+ return Object.fromEntries(Object.entries(stats).sort(([a], [b]) => a.localeCompare(b)));
1179
+ }
1180
+
1181
+ function entityStatsMap(entityStats) {
1182
+ return new Map(Object.entries(entityStats || {}).filter(([, value]) => value && typeof value === 'object'));
1183
+ }
1184
+
1185
+ // Malformed `pluginCmsFallback:*` keys with no row to carry them (capability not detected, or
1186
+ // not eligible): listed once at the top level so the mapping review can show them.
1187
+ function cmsFallbackDecisionIssues(rows, decisions) {
1188
+ const carried = new Set(rows.filter((row) => row.recognized && row.cmsFallback).map((row) => row.capability));
1189
+ const issues = [];
1190
+ for (const key of cmsFallbackDecisionKeys(decisions)) {
1191
+ const shape = cmsFallbackDecisionShape(key, decisions[key]);
1192
+ if (shape.ok || carried.has(cmsFallbackCapabilityOfKey(key))) continue;
1193
+ issues.push({ key, problem: shape.problem });
1194
+ }
1195
+ return issues;
1196
+ }
1197
+
1198
+ function cmsFallbackDigestFor({ inventory, profiles, targetKnowledge, knowledgeDir, hints, decisions }) {
1199
+ return cmsFallbackInputsDigest(cmsFallbackResolutionInputs({
1200
+ detectedPlugins: detectedPluginsOf(inventory),
1201
+ profiles,
1202
+ targetKnowledge,
1203
+ registers: {
1204
+ cmsFallbackEligible: loadCmsFallbackEligible(knowledgeDir).capabilities || [],
1205
+ requiresDevelopment: loadRequiresDevelopment(knowledgeDir).capabilities || [],
1206
+ noMigrationNeeded: hints,
1207
+ },
1208
+ decisions,
1209
+ }));
1210
+ }
1211
+
1212
+ // Plugin detection, Tier-B derivation, and coverage classification, run after sampling so
1213
+ // record payloads are available for core-embedded plugins that add no REST route.
1214
+ function buildPluginCoverage({ args, inventory, classifications, entities, allCandidates = [] }) {
1215
+ const knowledgeDir = args.pluginsRoot ? path.resolve(args.pluginsRoot) : pluginsRoot(path.resolve(__dirname, '..'));
1216
+ const profiles = loadProfiles(knowledgeDir);
1217
+ const sampledRecordProperties = collectRecordProperties(entities);
1218
+
1219
+ const detection = detectPlugins({
1220
+ profiles,
1221
+ restIndex: inventory.restIndex,
1222
+ pluginList: inventory.detection.pluginListAvailable ? inventory.pluginList : null,
1223
+ types: inventory.types,
1224
+ taxonomies: inventory.taxonomies,
1225
+ htmlSources: inventory.htmlSources || [],
1226
+ sampledRecordProperties,
1227
+ fingerprintAliases: loadFingerprintAliases(knowledgeDir),
1228
+ });
1229
+
1230
+ const sampledByRoute = new Map(entities.map((entity) => [entity.routePath, entity]));
1231
+ const unprofiled = [
1232
+ ...collectUnprofiledRoutes({ classifications, detection }),
1233
+ ...collectCandidateNamespaces({ classifications, candidates: allCandidates, detection }),
1234
+ ];
1235
+ const genericEntities = deriveGenericEntities({
1236
+ types: inventory.types,
1237
+ taxonomies: inventory.taxonomies,
1238
+ classifications,
1239
+ detection,
1240
+ sampledByRoute,
1241
+ });
1242
+
1243
+ const targetKnowledge = loadTargetKnowledge(args.targetKnowledgeRoot ? path.resolve(args.targetKnowledgeRoot) : null);
1244
+ const hints = loadNoMigrationNeeded(knowledgeDir);
1245
+ const decisions = loadDecisions(args);
1246
+ const rows = classifyCoverage({
1247
+ detection,
1248
+ genericEntities,
1249
+ unprofiledRoutes: unprofiled,
1250
+ targetKnowledge,
1251
+ entityStatsByRoute: sampledByRoute,
1252
+ // Only human-signed verdicts may produce a requires-development status.
1253
+ requiresDevelopmentEntries: loadRequiresDevelopment(knowledgeDir).capabilities || [],
1254
+ // Working notes for profiled capabilities we have not placed yet.
1255
+ pendingNotes: loadPendingDecisions(knowledgeDir).capabilities || [],
1256
+ // Nothing-to-move verdicts, both tiers: the slug list resolves unprofiled plugins into
1257
+ // rows (basis: list), and the signed capabilities[] register resolves profiled
1258
+ // capabilities a human decided need no migration (basis: decision).
1259
+ noMigrationNeeded: hints,
1260
+ // CMS fallback: the signed eligibility register plus this run's merchant answers
1261
+ // (`pluginCmsFallback:<capability>`). Neither alone plans a CMS write.
1262
+ cmsFallbackEntries: loadCmsFallbackEligible(knowledgeDir).capabilities || [],
1263
+ cmsFallbackDecisions: decisions,
1264
+ });
1265
+
1266
+ // Read back the batched-ask answers so a declined blocker renders as declined, never as
1267
+ // unanswered. A declined blocker stays on the row — skipping is an answer, not silence.
1268
+ applyBlockerDecisions(rows, decisions);
1269
+
1270
+ // One row per installed plugin, for customer review and for debugging this run later.
1271
+ const dispositionRows = buildDispositionRows({
1272
+ detection,
1273
+ coverage: rows,
1274
+ profiles,
1275
+ hints,
1276
+ });
1277
+
1278
+ return {
1279
+ detection,
1280
+ genericEntities,
1281
+ unprofiled,
1282
+ sampledRecordProperties,
1283
+ coverage: rows,
1284
+ summary: coverageSummary(rows),
1285
+ disposition: dispositionRows,
1286
+ dispositionSummary: summarizeDispositions(dispositionRows),
1287
+ targetKnowledgeError: targetKnowledge.loadError || null,
1288
+ entityStats: buildEntityStats(detection, sampledByRoute),
1289
+ cmsFallbackDecisionIssues: cmsFallbackDecisionIssues(rows, decisions),
1290
+ cmsFallbackDigest: cmsFallbackDigestFor({ inventory: detection, profiles, targetKnowledge, knowledgeDir, hints, decisions }),
1291
+ };
1292
+ }
1293
+
1294
+ /**
1295
+ * Rebuild plugin coverage with no source network calls, after a CMS-fallback answer or a change
1296
+ * to what could resolve an in-scope capability. Inputs are durable artifacts only: the stored
1297
+ * detection (plugin-inventory.json), the prior coverage's entityStats and review evidence (copied
1298
+ * forward unchanged), and the CURRENT profiles, registers, target knowledge and decisions.
1299
+ * Returns { outcome: 'needs-full-discovery', reason } instead of a payload whenever the stored
1300
+ * evidence cannot carry every count; it never writes a row with counts silently dropped.
1301
+ */
1302
+ function reclassifyPluginCoverage({ prior, inventory, decisions = {}, pluginsRoot: pluginsDir = null, targetKnowledgeRoot = null, generatedAt = new Date().toISOString() }) {
1303
+ if (!prior || !prior.entityStats || typeof prior.entityStats !== 'object' || Array.isArray(prior.entityStats)) {
1304
+ return { outcome: 'needs-full-discovery', reason: 'prior plugin-coverage.json has no entityStats' };
1305
+ }
1306
+ if (!inventory || !Array.isArray(inventory.detected)) {
1307
+ return { outcome: 'needs-full-discovery', reason: 'plugin-inventory.json is missing or has no detected[]' };
1308
+ }
1309
+ const knowledgeDir = pluginsDir || pluginsRoot(path.resolve(__dirname, '..'));
1310
+ const profiles = loadProfiles(knowledgeDir);
1311
+ const profileBySlug = new Map(profiles.map((profile) => [profile.plugin, profile]));
1312
+ const targetKnowledge = loadTargetKnowledge(targetKnowledgeRoot);
1313
+ const hints = loadNoMigrationNeeded(knowledgeDir);
1314
+ const cmsFallbackEntries = loadCmsFallbackEligible(knowledgeDir).capabilities || [];
1315
+ const requiresDevelopmentEntries = loadRequiresDevelopment(knowledgeDir).capabilities || [];
1316
+
1317
+ const sampledRoutes = new Set(Object.keys(prior.entityStats).filter((route) => prior.entityStats[route]));
1318
+ const detected = inventory.detected.map((stored) => {
1319
+ const profile = profileBySlug.get(stored.plugin);
1320
+ // A detected plugin whose profile left the repo keeps its capabilities but declares no
1321
+ // entities, so nothing can resolve for it and no CMS plan survives.
1322
+ if (!profile) return { ...stored, entities: [] };
1323
+ return {
1324
+ ...stored,
1325
+ displayName: profile.displayName || stored.displayName,
1326
+ capabilities: [...(profile.capabilities || [])],
1327
+ profileVersion: profile.profileVersion || stored.profileVersion,
1328
+ entities: (profile.entities || []).map((entity) => {
1329
+ const described = describeProfiledEntity(entity, {
1330
+ routes: sampledRoutes,
1331
+ rawRoutes: {},
1332
+ properties: new Set(),
1333
+ apiBelowMinVersion: stored.apiBelowMinVersion === true,
1334
+ });
1335
+ const previous = (stored.entities || []).find((candidate) => candidate.entity === entity.entity
1336
+ && candidate.channel === entity.channel && (candidate.route || null) === (entity.route || null));
1337
+ return previous ? { ...described, channelStatus: previous.channelStatus } : described;
1338
+ }),
1339
+ };
1340
+ });
1341
+
1342
+ const inputs = cmsFallbackResolutionInputs({
1343
+ detectedPlugins: detectedPluginsOf(inventory),
1344
+ profiles,
1345
+ targetKnowledge,
1346
+ registers: { cmsFallbackEligible: cmsFallbackEntries, requiresDevelopment: requiresDevelopmentEntries, noMigrationNeeded: hints },
1347
+ decisions,
1348
+ });
1349
+ for (const capability of Object.keys(inputs.capabilities)) {
1350
+ for (const plugin of detected.filter((candidate) => (candidate.capabilities || []).includes(capability))) {
1351
+ for (const entity of plugin.entities) {
1352
+ if (entity.route && !Object.prototype.hasOwnProperty.call(prior.entityStats, entity.route)) {
1353
+ return { outcome: 'needs-full-discovery', reason: `route ${entity.route} of ${plugin.plugin} (${capability}) has no stored entityStats` };
1354
+ }
1355
+ }
1356
+ }
1357
+ }
1358
+
1359
+ const detection = {
1360
+ pluginListAvailable: inventory.pluginListAvailable === true,
1361
+ detected,
1362
+ installedButUnprofiled: inventory.installedButUnprofiled || [],
1363
+ fingerprinted: inventory.fingerprinted || [],
1364
+ };
1365
+ const rows = classifyCoverage({
1366
+ detection,
1367
+ genericEntities: prior.genericEntities || [],
1368
+ unprofiledRoutes: prior.unprofiledRoutes || [],
1369
+ targetKnowledge,
1370
+ entityStatsByRoute: entityStatsMap(prior.entityStats),
1371
+ requiresDevelopmentEntries,
1372
+ pendingNotes: loadPendingDecisions(knowledgeDir).capabilities || [],
1373
+ noMigrationNeeded: hints,
1374
+ cmsFallbackEntries,
1375
+ cmsFallbackDecisions: decisions,
1376
+ });
1377
+ applyBlockerDecisions(rows, decisions);
1378
+ const disposition = buildDispositionRows({ detection, coverage: rows, profiles, hints });
1379
+
1380
+ return {
1381
+ outcome: 'reclassified',
1382
+ payload: {
1383
+ ...prior,
1384
+ generatedAt,
1385
+ summary: coverageSummary(rows),
1386
+ perPluginSummary: summarizeDispositions(disposition),
1387
+ capabilities: rows,
1388
+ perPlugin: disposition,
1389
+ cmsFallbackDecisionIssues: cmsFallbackDecisionIssues(rows, decisions),
1390
+ inputs: { ...(prior.inputs || {}), cmsFallbackDigest: cmsFallbackInputsDigest(inputs), reclassifiedFrom: prior.generatedAt || null },
1391
+ },
1392
+ };
1393
+ }
1394
+
1395
+ async function runReclassifyCoverage(args) {
1396
+ if (!args.outDir) throw new Error('--reclassify-coverage requires --out-dir (the raw discovery directory)');
1397
+ const outDir = path.resolve(args.outDir);
1398
+ const readOrNull = async (filePath) => {
1399
+ try {
1400
+ return JSON.parse(await fs.readFile(filePath, 'utf8'));
1401
+ } catch {
1402
+ return null;
1403
+ }
1404
+ };
1405
+ const result = reclassifyPluginCoverage({
1406
+ prior: await readOrNull(path.join(outDir, 'plugin-coverage.json')),
1407
+ inventory: await readOrNull(path.join(outDir, 'plugin-inventory.json')),
1408
+ decisions: loadDecisions({ ...args, outDir }),
1409
+ pluginsRoot: args.pluginsRoot ? path.resolve(args.pluginsRoot) : null,
1410
+ targetKnowledgeRoot: args.targetKnowledgeRoot ? path.resolve(args.targetKnowledgeRoot) : null,
1411
+ });
1412
+ if (result.outcome !== 'reclassified') return result;
1413
+ const text = `${JSON.stringify(result.payload, null, 2)}\n`;
1414
+ const targets = [path.join(outDir, 'plugin-coverage.json')];
1415
+ const canonical = args.canonicalCoverage
1416
+ ? path.resolve(args.canonicalCoverage)
1417
+ : path.resolve(outDir, '..', '..', 'discovery', 'plugin-coverage.json');
1418
+ let canonicalDirExists = Boolean(args.canonicalCoverage);
1419
+ if (!canonicalDirExists) {
1420
+ try {
1421
+ canonicalDirExists = (await fs.stat(path.dirname(canonical))).isDirectory();
1422
+ } catch {
1423
+ canonicalDirExists = false;
1424
+ }
1425
+ }
1426
+ if (canonicalDirExists) targets.push(canonical);
1427
+ for (const target of targets) {
1428
+ await fs.mkdir(path.dirname(target), { recursive: true });
1429
+ const tempPath = `${target}.${process.pid}.tmp`;
1430
+ await fs.writeFile(tempPath, text, 'utf8');
1431
+ await fs.rename(tempPath, target);
1432
+ }
1433
+ return { outcome: 'reclassified', written: targets, cmsFallbackDigest: result.payload.inputs.cmsFallbackDigest };
1434
+ }
1435
+
1436
+ // plugin-rest-child support: a parent-scoped sub-resource (e.g.
1437
+ // /wc/v3/orders/{parentId}/notes) cannot be listed on its own, so it is checked by
1438
+ // substituting real ids from the already-sampled parent collection. Pure and exported so the
1439
+ // id-picking and route-building logic is fixture-testable with no live site.
1440
+
1441
+ // Candidate parent ids for a plugin-rest-child entity, drawn from its parent collection's
1442
+ // already-sampled records and capped at a small representative count — this is a check, not
1443
+ // an attempt at full coverage.
1444
+ function pickChildSampleParentIds(parentEntity, limit) {
1445
+ const records = parentEntity?.sampleRecords || [];
1446
+ return records
1447
+ .map((record) => (record && typeof record === 'object' ? record.id : undefined))
1448
+ .filter((id) => id !== undefined && id !== null)
1449
+ .slice(0, limit);
1450
+ }
1451
+
1452
+ function buildChildRoutePath(template, parentId) {
1453
+ return template.replace(CHILD_ROUTE_PLACEHOLDER, encodeURIComponent(String(parentId)));
1454
+ }
1455
+
1456
+ function describeChildSample(sample) {
1457
+ const label = `${sample.plugin} · ${sample.entity}`;
1458
+ if (sample.parentsChecked === 0) {
1459
+ return `${label}: no sampled ${sample.parentRoute} records were available to check ${sample.route} against.`;
1460
+ }
1461
+ return `${label}: checked ${sample.parentsChecked} sampled ${sample.parentRoute} record(s)' `
1462
+ + `${sample.route} — ${sample.parentsWithRecords} of ${sample.parentsChecked} returned matching records `
1463
+ + `(${sample.sampleRecords.length} sample record(s) total). Representative check only, not a full count.`;
1464
+ }
1465
+
1466
+ // Live per-parent sampling for every detected plugin-rest-child entity. Runs after the main
1467
+ // sampling loop so `sampledByRoute` already holds real parent records to draw ids from.
1468
+ async function sampleChildEntities({ baseUrl, headers, timeoutMs, sampleLimit, progress, detection, sampledByRoute }) {
1469
+ const results = [];
1470
+ const parentSampleLimit = Math.min(3, sampleLimit);
1471
+
1472
+ for (const detected of detection?.detected || []) {
1473
+ for (const entity of detected.entities) {
1474
+ if (entity.channel !== 'plugin-rest-child' || entity.channelStatus !== 'available') continue;
1475
+
1476
+ const parentEntity = sampledByRoute.get(entity.parentRoute);
1477
+ const parentIds = pickChildSampleParentIds(parentEntity, parentSampleLimit);
1478
+ if (parentIds.length === 0) {
1479
+ results.push({
1480
+ plugin: detected.plugin,
1481
+ entity: entity.entity,
1482
+ parentRoute: entity.parentRoute,
1483
+ route: entity.route,
1484
+ parentsChecked: 0,
1485
+ parentsWithRecords: 0,
1486
+ sampleRecords: [],
1487
+ });
1488
+ continue;
1489
+ }
1490
+
1491
+ const sampleRecords = [];
1492
+ let parentsWithRecords = 0;
1493
+ for (const parentId of parentIds) {
1494
+ const childRoute = buildChildRoutePath(entity.route, parentId);
1495
+ // eslint-disable-next-line no-await-in-loop -- each parent's sub-resource must be
1496
+ // fetched under the shared rate limiter, one request at a time, like inspectEntity.
1497
+ const response = await fetchJson(baseUrl, childRoute, {
1498
+ headers,
1499
+ method: 'GET',
1500
+ timeoutMs,
1501
+ progress,
1502
+ progressContext: { step: 'sample-child-entity', entity: entity.entity },
1503
+ });
1504
+ if (response.ok && Array.isArray(response.json) && response.json.length > 0) {
1505
+ parentsWithRecords += 1;
1506
+ sampleRecords.push(...response.json.slice(0, Math.max(0, sampleLimit - sampleRecords.length)));
1507
+ }
1508
+ }
1509
+
1510
+ results.push({
1511
+ plugin: detected.plugin,
1512
+ entity: entity.entity,
1513
+ parentRoute: entity.parentRoute,
1514
+ route: entity.route,
1515
+ parentsChecked: parentIds.length,
1516
+ parentsWithRecords,
1517
+ sampleRecords,
1518
+ });
1519
+ }
1520
+ }
1521
+
1522
+ return results;
1523
+ }
1524
+
1525
+ // Pure -- no I/O -- so it can be unit-tested directly without mocking httpClient or the
1526
+ // profile loader. Decides what query a structure-bridge-plugin entity's sample should
1527
+ // run, or why none can be run at all. `table` is spread in LAST when a fulfillment declares its
1528
+ // own sampleStructureRequest so a stray `table` key inside that declaration (which
1529
+ // plugin-knowledge.js's validator already rejects at authoring time) can never silently
1530
+ // redirect the query at a different table than this entity's fulfillment names -- this is
1531
+ // the second, independent line of defense for that same invariant.
1532
+ function resolveSampleStructureRequest(fulfillment, table, schema) {
1533
+ if (fulfillment.sampleStructureRequest) {
1534
+ return { sampleRequest: { ...fulfillment.sampleStructureRequest, table }, skippedReason: null };
1535
+ }
1536
+ if (schema.columns.length === 0) {
1537
+ return {
1538
+ sampleRequest: null,
1539
+ skippedReason: 'discover-structure returned zero columns for this table -- cannot build a default sample. Unexpected for a real table; the fulfillment metadata or the live schema needs review.',
1540
+ };
1541
+ }
1542
+ if (schema.columns.length > 50) {
1543
+ return {
1544
+ sampleRequest: null,
1545
+ skippedReason: `this table has ${schema.columns.length} columns, more than wix-wp-plugin-v2's own 50-column select limit -- a default "every column" sample would silently drop ${schema.columns.length - 50} of them. This entity's fulfillment must declare an explicit sampleStructureRequest choosing which columns matter; there is no safe default for a table this wide.`,
1546
+ };
1547
+ }
1548
+ // On a key/value table the guarded value column(s) are unreachable until the
1549
+ // request pins the matching key column, so a default "select every column" sample is a
1550
+ // request the plugin REFUSES with a 400 -- and a 400 here reads as "this table is broken"
1551
+ // rather than "this sample was built wrong". Drop the guarded columns and sample the key
1552
+ // names instead, which is the discovery tier and exactly what a mapper needs first: the
1553
+ // real key list for whatever plugin this site runs.
1554
+ const guarded = guardedValueColumns(schema.eavPair);
1555
+ const sampleable = schema.columns.filter((column) => !guarded.includes(column.name));
1556
+ if (sampleable.length === 0) {
1557
+ return {
1558
+ sampleRequest: null,
1559
+ skippedReason: 'every column on this table is a guarded key/value column -- nothing can be sampled without naming specific keys first.',
1560
+ };
1561
+ }
1562
+ if (guarded.length > 0) {
1563
+ return {
1564
+ sampleRequest: {
1565
+ table,
1566
+ select: sampleable.map((column) => ({ column: column.name })),
1567
+ orderBy: [{ column: schema.eavPair.keyColumn, direction: 'asc' }],
1568
+ },
1569
+ skippedReason: null,
1570
+ eavNote: `key/value table: ${guarded.join(', ')} omitted from this sample because wix-wp-plugin-v2 will not return a value until the request pins its key column (${schema.eavPair.keyColumn}). Read those with a scoped request naming the keys this sample reveals.`,
1571
+ };
1572
+ }
1573
+ const primaryColumn = schema.columns.find((column) => column.key === 'primary') || schema.columns[0];
1574
+ return {
1575
+ sampleRequest: {
1576
+ table,
1577
+ select: schema.columns.map((column) => ({ column: column.name })),
1578
+ orderBy: [{ column: primaryColumn.name, direction: 'asc' }],
1579
+ },
1580
+ skippedReason: null,
1581
+ };
1582
+ }
1583
+
1584
+ // Every entity whose blocked[].fulfillment.kind is structure-bridge-plugin has
1585
+ // no REST route at all -- the ONLY way to capture it is wix-wp-plugin-v2's own routes. Runs
1586
+ // after plugin detection/coverage so it can skip a plugin that isn't actually active, and
1587
+ // after the REST sampling passes so it never competes with them for the shared rate limit
1588
+ // slot ordering. Never throws: a per-entity failure (plugin not installed, table renamed,
1589
+ // wix-wp-plugin-v2 not installed at all) is recorded as a request error on that entity's own
1590
+ // file, exactly like an auth-gated REST route already is -- it must not abort discovery.
1591
+ /**
1592
+ * Accumulates the per-read counts the client derives and files them with
1593
+ * rp-telemetry once, at the end of the bridge pass.
1594
+ *
1595
+ * Wired HERE, in the real caller, rather than left as a hook nobody calls: `onSourceRead` with
1596
+ * no production caller is telemetry that exists in the code and not in the data, which is
1597
+ * indistinguishable from a run that read nothing. Failure to record is swallowed on purpose --
1598
+ * telemetry must never be able to abort a discovery run, and this whole function is already
1599
+ * built on "a per-entity failure is recorded, not thrown".
1600
+ */
1601
+ function makeSourceReadCollector(outDir) {
1602
+ const totals = { discovery_queries: 0, scoped_queries: 0, tier_refusals: 0, redacted_values: 0 };
1603
+ const discoveryTables = new Set();
1604
+ const scopedTables = new Set();
1605
+ return {
1606
+ onSourceRead(counts) {
1607
+ for (const key of Object.keys(totals)) totals[key] += counts[key] || 0;
1608
+ for (const table of counts.discovery_tables || []) discoveryTables.add(table);
1609
+ for (const table of counts.scoped_tables || []) scopedTables.add(table);
1610
+ },
1611
+ countTierRefusal() {
1612
+ totals.tier_refusals += 1;
1613
+ },
1614
+ flush(progress) {
1615
+ const payload = { ...totals };
1616
+ if (discoveryTables.size > 0) payload.discovery_tables = [...discoveryTables].sort();
1617
+ if (scopedTables.size > 0) payload.scoped_tables = [...scopedTables].sort();
1618
+ if (Object.values(totals).every((n) => n === 0)) return;
1619
+ try {
1620
+ // outDir is <project>/discovery/wordpress; the project root is two levels up, the same
1621
+ // derivation the decisions.json lookup above already uses.
1622
+ const projectDir = path.resolve(outDir, '..', '..');
1623
+ // eslint-disable-next-line global-require
1624
+ require('../../rp-telemetry/lib/telemetry-recorder.js').sourceRead(projectDir, payload);
1625
+ } catch (error) {
1626
+ progress?.progress(`source-read telemetry not recorded: ${error.message}`, {
1627
+ phase: 'discovery',
1628
+ step: 'structure-bridge-plugin',
1629
+ });
1630
+ }
1631
+ },
1632
+ };
1633
+ }
1634
+
1635
+ async function sampleStructureBridgeEntities({ baseUrl, headers, migrationKey, namespaces, sampleLimit, timeoutMs, progress, detection, outDir }) {
1636
+ if (!namespaces.includes('wix-wp-plugin/v2')) {
1637
+ progress?.progress('wix-wp-plugin-v2 not detected on this site; skipping structure-bridge-plugin entities', {
1638
+ phase: 'discovery',
1639
+ step: 'structure-bridge-plugin',
1640
+ });
1641
+ return [];
1642
+ }
1643
+
1644
+ // Prefer the signed route whenever a migration key is configured, avoiding capability
1645
+ // drift on the manage_woocommerce-gated route. Without a key, the ordinary route is usable
1646
+ // only when WooCommerce is present (the source skill enforces that credential selection).
1647
+ const bridge = chooseBridgeAuth({ migrationKey, timeoutMs });
1648
+ const bridgeAuth = bridge.auth;
1649
+ const bridgeStructureMethod = bridge.structureMethod;
1650
+ const bridgeQueryRoute = bridge.queryRoute;
1651
+
1652
+ const httpClient = {
1653
+ async get(url, { params } = {}) {
1654
+ const response = await fetchJson(baseUrl, '/wix-wp-plugin/v2/structure', {
1655
+ headers, method: 'GET', query: params, timeoutMs, progress,
1656
+ progressContext: { step: 'structure-bridge-discover', entity: params?.table },
1657
+ });
1658
+ if (!response.ok) {
1659
+ const error = new Error(`HTTP ${response.status} ${response.statusText}`);
1660
+ error.status = response.status;
1661
+ throw error;
1662
+ }
1663
+ return { data: response.json };
1664
+ },
1665
+ async post(url, { body } = {}) {
1666
+ const response = await fetchJson(baseUrl, '/wix-wp-plugin/v2/query/admin-key', {
1667
+ headers, method: 'POST', body, timeoutMs, progress,
1668
+ progressContext: { step: 'structure-bridge-query' },
1669
+ });
1670
+ if (!response.ok) {
1671
+ const error = new Error(`HTTP ${response.status} ${response.statusText}`);
1672
+ error.status = response.status;
1673
+ throw error;
1674
+ }
1675
+ return { data: response.json };
1676
+ },
1677
+ };
1678
+
1679
+ const detectedSlugs = new Set((detection?.detected || []).map((entry) => entry.plugin));
1680
+ const profiles = loadProfiles(pluginsRoot(path.resolve(__dirname, '..')));
1681
+ const results = [];
1682
+
1683
+ const sourceReads = makeSourceReadCollector(outDir);
1684
+
1685
+ for (const profile of profiles) {
1686
+ if (!detectedSlugs.has(profile.plugin)) continue;
1687
+ for (const entity of profile.entities || []) {
1688
+ const blockedEntries = [
1689
+ ...(entity.blocked || []),
1690
+ ...((entity.pitfalls || []).flatMap((pitfall) => pitfall.blocked || [])),
1691
+ ];
1692
+ for (const blockedEntry of blockedEntries) {
1693
+ const fulfillment = blockedEntry.fulfillment;
1694
+ if (!fulfillment || fulfillment.kind !== 'structure-bridge-plugin' || fulfillment.handlerId !== 'wix-wp-plugin-v2') continue;
1695
+
1696
+ const { table } = fulfillment;
1697
+ const fileName = `${slugify('wix-wp-plugin/v2')}--${slugify(table)}.md`;
1698
+ const notes = [
1699
+ `Captured via wix-wp-plugin-v2's discover-structure (schema) and query-structure (sample rows), not the WordPress REST API -- this entity has no REST route at all (channel: ${entity.channel}).`,
1700
+ `Source plugin: ${profile.plugin}.`,
1701
+ ];
1702
+ const requestErrors = [];
1703
+ let schema = null;
1704
+ let sampleRecords = [];
1705
+ let recordCount = null;
1706
+
1707
+ progress?.progress(`Inspecting structure-bridge-plugin table ${table}`, {
1708
+ phase: 'discovery',
1709
+ step: 'structure-bridge-plugin',
1710
+ entity: table,
1711
+ });
1712
+
1713
+ try {
1714
+ schema = await discoverStructure({ httpClient, siteBaseUrl: baseUrl, auth: bridgeAuth, table });
1715
+ } catch (error) {
1716
+ requestErrors.push({ request: bridgeStructureMethod, routePath: `/wix-wp-plugin/v2/structure?table=${table}`, status: error.status || 0, statusText: error.message });
1717
+ notes.push(`discover-structure failed: ${error.message}. wix-wp-plugin-v2 may not be fully installed/authorized on this site, or ${table} may not exist -- this entity's fulfillment metadata may need review.`);
1718
+ results.push({
1719
+ entityName: entity.entity, namespace: 'wix-wp-plugin/v2', routePath: `/structure?table=${table}`,
1720
+ classification: null, methods: ['GET'], responseShape: 'object', recordCount: null, inUse: null,
1721
+ sampleRecords: [], discoveryNotes: notes, relationships: [], requestErrors, schema: null, collectionArgs: [], fileName,
1722
+ });
1723
+ continue;
1724
+ }
1725
+
1726
+ // The authoritative `table` is spread LAST so it always wins even if a declared
1727
+ // sampleStructureRequest carried its own `table` key -- plugin-knowledge.js's
1728
+ // validator already rejects that key at authoring time, but this ordering is the
1729
+ // second, independent line of defense: a profile can never make this code query a
1730
+ // different table than the one this entity's filename/notes say it describes.
1731
+ const { sampleRequest, skippedReason: sampleSkippedReason, eavNote } = resolveSampleStructureRequest(fulfillment, table, schema);
1732
+ // Surfaced to the mapper, not swallowed: "this table's values need a second, scoped
1733
+ // read" is exactly the kind of thing that turns into a silent data gap if the sample
1734
+ // merely looks a bit thin.
1735
+ if (eavNote) notes.push(eavNote);
1736
+ if (fulfillment.sampleStructureRequest) {
1737
+ notes.push('This sample uses the fulfillment\'s own declared query, not a raw "select every column" dump -- see this entity\'s blocked[].resolution for why a raw sample is not safe here.');
1738
+ }
1739
+
1740
+ let queried = false;
1741
+ if (sampleSkippedReason) {
1742
+ notes.push(sampleSkippedReason);
1743
+ } else {
1744
+ try {
1745
+ const response = await queryStructure({
1746
+ httpClient, siteBaseUrl: baseUrl, auth: bridgeAuth, structureRequest: sampleRequest, limit: sampleLimit,
1747
+ onSourceRead: sourceReads.onSourceRead,
1748
+ });
1749
+ sampleRecords = response.rows;
1750
+ recordCount = response.pagingMetadata.total;
1751
+ queried = true;
1752
+ // A redaction is a finding about the SOURCE SITE -- it means a credential is
1753
+ // stored somewhere nobody expected -- so it belongs in the discovery record
1754
+ // rather than being noticed later as a value that looks oddly literal.
1755
+ if (response.redactionMetadata.redactedValueCount > 0) {
1756
+ notes.push(`${response.redactionMetadata.redactedValueCount} value(s) in ${response.redactionMetadata.redactedColumns.join(', ')} matched a credential shape and were returned as [REDACTED:secret-shaped]. This is a source-site finding, not a sampling error: something on this site keeps a secret in this column.`);
1757
+ }
1758
+ if (response.eavAccess) {
1759
+ notes.push(`Key/value table, served in the ${response.eavAccess.tier} tier: key column ${response.eavAccess.keyColumn}, guarded value column(s) ${guardedValueColumns(response.eavAccess).join(', ')}.`);
1760
+ }
1761
+ } catch (error) {
1762
+ requestErrors.push({ request: 'POST', routePath: bridgeQueryRoute, status: error.status || 0, statusText: error.message });
1763
+ notes.push(`query-structure failed: ${error.message}. Schema above is still real; no sample rows could be captured this run.`);
1764
+ // Count a tier refusal only when the REQUEST actually violates the tier rule.
1765
+ // A 400 here can equally mean a nonexistent column (an outdated profile naming a
1766
+ // column the site dropped), a malformed request, or a bad cursor -- the plugin
1767
+ // uses one error for all of them on purpose, so that a refusal never discloses
1768
+ // which column holds values. Deciding from the request instead keeps
1769
+ // `tier_refusals` meaning "something tried to reach values it had not named".
1770
+ if (error.status === 400 && violatesTierRule(sampleRequest, schema.eavPair)) {
1771
+ sourceReads.countTierRefusal();
1772
+ }
1773
+ }
1774
+ }
1775
+
1776
+ // Persisted as a machine-readable sidecar (not just described in this file's own
1777
+ // "Collection Args" prose) so rp-import-codegen can consume the EXACT request
1778
+ // verbatim instead of re-deriving its own default at codegen time, which could
1779
+ // drift from this one if the table's live schema changes in between (this is a normal reader,
1780
+ // not a blocked-dependency snapshot). This filename is
1781
+ // computed unconditionally (even when nothing gets written this run) so writeOutputs
1782
+ // can clean up a STALE sidecar from a prior run when this run could not produce a
1783
+ // fresh one -- publishing only happens when the query actually succeeded (`queried`),
1784
+ // never merely because a request was built; a failed or skipped run must not leave a
1785
+ // sidecar codegen would then trust as current.
1786
+ const structureRequestArtifactFileName = `${slugify('wix-wp-plugin/v2')}--${slugify(table)}.structure-request.json`;
1787
+ const structureRequestArtifact = queried
1788
+ ? { fileName: structureRequestArtifactFileName, content: sampleRequest }
1789
+ : null;
1790
+
1791
+ // A key/value table needs a SECOND artifact, because the request above deliberately
1792
+ // omits the guarded value columns -- a reader running it verbatim extracts key names
1793
+ // and no values, which is the opposite of what this capability is for. The read plan
1794
+ // is the executable second step: every distinct key, batched at the plugin's 50-key
1795
+ // cap, each batch a complete runnable request.
1796
+ const eavReadPlanFileName = `${slugify('wix-wp-plugin/v2')}--${slugify(table)}.eav-read-plan.json`;
1797
+ let eavReadPlan = null;
1798
+ // Deliberately NOT gated on `queried`. The ordinary sample is skipped for a table wider
1799
+ // than the 50-column select cap (and fails for other reasons too), but key discovery
1800
+ // selects exactly ONE column, so nothing that stopped the sample applies to it. Tying
1801
+ // the two together meant a wide key/value table -- which a busy `postmeta` absolutely
1802
+ // can be -- silently lost its only path to values.
1803
+ if (schema.eavPair) {
1804
+ try {
1805
+ const pairs = [
1806
+ { keyColumn: schema.eavPair.keyColumn, valueColumn: schema.eavPair.valueColumn },
1807
+ ...(schema.eavPair.additionalPairs || []),
1808
+ ];
1809
+ // One key sweep PER PAIR: each value column answers only to its own key column, so
1810
+ // one pair's key list cannot unlock another pair's values.
1811
+ const keysByPair = {};
1812
+ const countsByPair = {};
1813
+ let anyTruncated = false;
1814
+ let totalPages = 0;
1815
+ for (const pair of pairs) {
1816
+ // eslint-disable-next-line no-await-in-loop
1817
+ const discovered = await discoverEavKeys({
1818
+ httpClient, siteBaseUrl: baseUrl, auth: bridgeAuth, table, keyColumn: pair.keyColumn,
1819
+ onSourceRead: sourceReads.onSourceRead,
1820
+ });
1821
+ keysByPair[pair.keyColumn] = discovered.keys;
1822
+ countsByPair[pair.keyColumn] = discovered.keyCounts;
1823
+ anyTruncated = anyTruncated || discovered.truncated;
1824
+ totalPages += discovered.pages;
1825
+ }
1826
+ const content = buildEavReadPlan({
1827
+ table, eavPair: schema.eavPair, schemaColumns: schema.columns, keysByPair, countsByPair, truncated: anyTruncated,
1828
+ });
1829
+ eavReadPlan = { fileName: eavReadPlanFileName, content };
1830
+ notes.push(
1831
+ `Key/value table: ${content.distinctKeyCount} distinct key(s) across ${pairs.length} pair(s), discovered over ${totalPages} page(s). `
1832
+ + `Values are extracted by ${content.expectedBatches} scoped batch(es)`
1833
+ + (content.expectedScopedRequests === null ? '' : ` (~${content.expectedScopedRequests} paginated request(s))`)
1834
+ + ` carrying ${content.identityColumns.join(', ') || 'no'} identity column(s) -- `
1835
+ + `see ${eavReadPlanFileName}, which rp-import-codegen runs verbatim.`
1836
+ + (anyTruncated ? ' *** KEY LIST TRUNCATED: this extraction cannot be treated as whole-table. ***' : '')
1837
+ + (content.droppedIdentityColumns.length === 0 ? ''
1838
+ : ` *** WIDER THAN THE 50-COLUMN SELECT CAP: ${content.droppedIdentityColumns.length} column(s) are absent from every extracted row (${content.droppedIdentityColumns.join(', ')}). `
1839
+ + 'Every row will be INCOMPLETE per record until the mapping narrows this table and the plan is regenerated with an explicit column choice. ***')
1840
+ + (content.orderByIsUnique ? '' : ` *** No primary or NOT-NULL unique column: batches order by ${content.orderColumn}, which can tie, so paging is best-effort. ***`),
1841
+ );
1842
+ } catch (error) {
1843
+ // Never fatal: the schema above is still real, and a discovery run must not abort
1844
+ // because one table's key sweep failed.
1845
+ notes.push(`Key discovery for the scoped-value read failed: ${error.message}. Values for this table cannot be extracted until this succeeds.`);
1846
+ requestErrors.push({ request: 'POST', routePath: bridgeQueryRoute, status: error.status || 0, statusText: error.message });
1847
+ }
1848
+ }
1849
+
1850
+ results.push({
1851
+ entityName: entity.entity,
1852
+ sourceEntityRef: `plugin.${profile.plugin}.${entity.entity}`,
1853
+ sourceMeta: { plugin: profile.plugin, candidateTargetRefs: entity.candidateTargetRefs || [] },
1854
+ namespace: 'wix-wp-plugin/v2',
1855
+ routePath: `${bridgeAuth ? '/query' : '/query/admin-key'} (table=${table})`,
1856
+ classification: null,
1857
+ methods: ['POST'],
1858
+ responseShape: 'object',
1859
+ recordCount,
1860
+ inUse: sampleRecords.length > 0,
1861
+ sampleRecords,
1862
+ discoveryNotes: notes,
1863
+ relationships: [],
1864
+ requestErrors,
1865
+ schema,
1866
+ // Not literally REST "collection args" (no such concept here) -- reusing this
1867
+ // section to display the actual structureRequest this sample used (or an empty
1868
+ // array when none was attempted), so a human reader can see (e.g.) that
1869
+ // gift-card-activity's sample is an aggregate query, not a raw dump, without
1870
+ // having to go read the plugin profile's JSON. The machine-readable copy
1871
+ // consumers should actually parse is structureRequestArtifact below.
1872
+ collectionArgs: sampleRequest ? [sampleRequest] : [],
1873
+ fileName,
1874
+ structureRequestArtifact,
1875
+ structureRequestArtifactFileName,
1876
+ eavReadPlan,
1877
+ eavReadPlanFileName,
1878
+ });
1879
+ }
1880
+ }
1881
+ }
1882
+
1883
+ // One telemetry write for the whole bridge pass, after every entity, so a resumed or
1884
+ // partially-failed run still files what it actually read.
1885
+ sourceReads.flush(progress);
1886
+
1887
+ return results;
1888
+ }
1889
+
1890
+ // Everything this run advertised or attempted but did not capture as an entity
1891
+ // (401/403, failed capture, a data route skipped by rule, an unsupported route surface). Always
1892
+ // written, `rows: []` when there is nothing to report; rp-discovery refuses to promote without it.
1893
+ function sourceCoveragePayload(context) {
1894
+ return buildCoverageFile({
1895
+ platform: 'wordpress',
1896
+ adapter: 'wordpress',
1897
+ generatedAt: context.generatedAt,
1898
+ rows: buildWordPressCoverageRows({
1899
+ entities: context.entities,
1900
+ classifications: context.classifications,
1901
+ rawDir: ADAPTER_RAW_DIRS.wordpress,
1902
+ }),
1903
+ });
1904
+ }
1905
+
1906
+ function pluginCoveragePayload(context) {
1907
+ const plugins = context.plugins;
1908
+ return {
1909
+ generatedAt: context.generatedAt,
1910
+ baseUrl: context.baseUrl,
1911
+ authenticated: context.authMode !== 'none',
1912
+ bridgeAuthMode: context.bridgeAuthMode,
1913
+ pluginListAvailable: plugins.detection.pluginListAvailable,
1914
+ notes: [
1915
+ ...(context.pluginNotes || []),
1916
+ ...(plugins.targetKnowledgeError
1917
+ ? [`Wix target knowledge could not be loaded (${plugins.targetKnowledgeError}); target refs were not resolved.`]
1918
+ : []),
1919
+ ...(plugins.childSamples || []).map(describeChildSample),
1920
+ ],
1921
+ childSamples: plugins.childSamples || [],
1922
+ summary: plugins.summary,
1923
+ perPluginSummary: plugins.dispositionSummary,
1924
+ // The status invariant: N installed plugins produce N per-plugin rows, recognized or not.
1925
+ // Recorded here so the check is inspectable in the artifact, not just in tests.
1926
+ statusInvariant: {
1927
+ detectedRecognized: plugins.detection.detected.length,
1928
+ installedButUnrecognized: plugins.detection.installedButUnprofiled.length,
1929
+ genericEntities: plugins.genericEntities.length,
1930
+ unprofiledNamespaces: plugins.unprofiled.length,
1931
+ pluginListAvailable: plugins.detection.pluginListAvailable,
1932
+ },
1933
+ capabilities: plugins.coverage,
1934
+ // One artifact, two views: the capability rows above are the contract;
1935
+ // this per-plugin projection answers the question a merchant actually asks.
1936
+ perPlugin: plugins.disposition,
1937
+ genericEntities: plugins.genericEntities,
1938
+ unprofiledRoutes: plugins.unprofiled,
1939
+ // Durable per-route counts and sample evidence, so --reclassify-coverage never refetches.
1940
+ entityStats: plugins.entityStats || {},
1941
+ // Malformed pluginCmsFallback:* answers with no capability row to carry them.
1942
+ cmsFallbackDecisionIssues: plugins.cmsFallbackDecisionIssues || [],
1943
+ // The CMS-fallback resolution-input digest. rp-mapper copies it into mapping-plan.json and
1944
+ // rp-setup-discovery into setup-plan.json; the router refuses any artifact that disagrees.
1945
+ inputs: { cmsFallbackDigest: plugins.cmsFallbackDigest || null },
1946
+ };
1947
+ }
1948
+
606
1949
  async function ensureDir(dirPath) {
607
1950
  await fs.mkdir(dirPath, { recursive: true });
608
1951
  }
609
1952
 
610
1953
  async function writeOutputs(outDir, context, progress) {
611
1954
  await ensureDir(outDir);
1955
+ const planProjectDir = context.projectDir ? path.resolve(context.projectDir)
1956
+ : (path.basename(path.resolve(outDir)) === 'wp-discovery' && path.basename(path.dirname(path.resolve(outDir))) === 'data' ? path.resolve(outDir, '../..') : null);
1957
+ if (planProjectDir) {
1958
+ const { sha } = require('../lib/plugin-entity-read-plan.js');
1959
+ for (const entity of context.entities) {
1960
+ if (entity.sourceEntityRef && entity.namespace === 'wix-wp-plugin/v2') {
1961
+ entity.fileName = `wix-wp-plugin-v2--${sha(entity.sourceEntityRef)}.md`;
1962
+ entity.rawFile = entity.fileName;
1963
+ }
1964
+ }
1965
+ }
612
1966
  await fs.writeFile(path.join(outDir, 'README.md'), renderIndexFile(context), 'utf8');
613
1967
  progress?.progress('Wrote WordPress discovery index', { phase: 'discovery', step: 'write-artifact', artifact: path.join(outDir, 'README.md') });
614
1968
  await fs.writeFile(
@@ -621,33 +1975,161 @@ async function writeOutputs(outDir, context, progress) {
621
1975
  step: 'write-artifact',
622
1976
  artifact: path.join(outDir, 'skipped-routes.json'),
623
1977
  });
1978
+ await fs.writeFile(
1979
+ path.join(outDir, 'source-coverage.json'),
1980
+ `${JSON.stringify(sourceCoveragePayload(context), null, 2)}\n`,
1981
+ 'utf8',
1982
+ );
1983
+ progress?.progress('Wrote WordPress source coverage', {
1984
+ phase: 'discovery',
1985
+ step: 'write-artifact',
1986
+ artifact: path.join(outDir, 'source-coverage.json'),
1987
+ });
1988
+
1989
+ if (context.plugins) {
1990
+ await fs.writeFile(
1991
+ path.join(outDir, 'plugin-inventory.json'),
1992
+ `${JSON.stringify(inventoryPayload({
1993
+ generatedAt: context.generatedAt,
1994
+ baseUrl: context.baseUrl,
1995
+ authenticated: context.authMode !== 'none',
1996
+ detection: context.plugins.detection,
1997
+ notes: context.pluginNotes || [],
1998
+ unprofiled: context.plugins.unprofiled,
1999
+ profileCount: context.pluginProfileCount,
2000
+ }), null, 2)}\n`,
2001
+ 'utf8',
2002
+ );
2003
+ progress?.progress('Wrote WordPress plugin inventory', {
2004
+ phase: 'discovery',
2005
+ step: 'write-artifact',
2006
+ artifact: path.join(outDir, 'plugin-inventory.json'),
2007
+ });
2008
+ await fs.writeFile(
2009
+ path.join(outDir, 'plugin-coverage.json'),
2010
+ `${JSON.stringify(pluginCoveragePayload(context), null, 2)}\n`,
2011
+ 'utf8',
2012
+ );
2013
+ progress?.progress('Wrote WordPress plugin coverage', {
2014
+ phase: 'discovery',
2015
+ step: 'write-artifact',
2016
+ artifact: path.join(outDir, 'plugin-coverage.json'),
2017
+ });
2018
+ // Deliberately no plugin-disposition.md: the per-plugin view lives inside
2019
+ // plugin-coverage.json (one coverage artifact, no second document).
2020
+ }
624
2021
 
625
2022
  for (const entity of context.entities) {
626
- await fs.writeFile(path.join(outDir, entity.fileName), renderEntityFile(entity), 'utf8');
2023
+ if (entity.sourceEntityRef && entity.namespace === 'wix-wp-plugin/v2'
2024
+ && planProjectDir) {
2025
+ const plans = require('../lib/plugin-entity-read-plan.js');
2026
+ const projectDir = planProjectDir;
2027
+ try {
2028
+ const artifact = entity.eavReadPlan || entity.structureRequestArtifact;
2029
+ if (!artifact || !entity.schema) throw Object.assign(new Error('discovery could not produce a supported read recipe; inspect its storage evidence'), { code: 'plan-unavailable' });
2030
+ const base = `data/wp-discovery/entity-read-plans/${plans.sha(entity.sourceEntityRef)}`;
2031
+ const evidence = plans.writeJson(projectDir, `${base}/schema.json`, entity.schema);
2032
+ const request = plans.writeJson(projectDir, `${base}/${entity.eavReadPlan ? 'eav-read-plan' : 'structure-request'}.json`, artifact.content);
2033
+ plans.writePluginEntityReadPlan({ projectDir, siteBaseUrl: context.baseUrl, sourceEntity: entity,
2034
+ plan: { schemaVersion: 1, sourceEntityRef: entity.sourceEntityRef, sourceIdentity: plans.sourceIdentity(context.baseUrl), evidenceRefs: [evidence],
2035
+ components: [{ id: 'root', table: entity.schema.table, variant: entity.eavReadPlan ? 'eav' : 'single-request', schema: entity.schema,
2036
+ readArtifacts: { [entity.eavReadPlan ? 'eavReadPlan' : 'structureRequest']: request }, scope: { where: artifact.content.where || [] } }],
2037
+ assembly: { kind: 'identity', identityColumn: artifact.content.groupBy?.[0] || entity.schema.columns.find((column) => column.key === 'primary' || (column.key === 'unique' && column.nullable === false))?.name || '' },
2038
+ cost: { expectedRequests: artifact.content.expectedScopedRequests ?? null } } });
2039
+ } catch (error) {
2040
+ plans.invalidatePluginEntityReadPlan({ projectDir, sourceEntityRef: entity.sourceEntityRef });
2041
+ entity.sourceMeta = { ...entity.sourceMeta, extractionPlan: null };
2042
+ plans.recordPluginExtractionDeferral({ projectDir, sourceEntityRef: entity.sourceEntityRef, code: error.code || 'plan-invalid', reason: error.message, producer: 'rp-source-wordpress/scripts/wp-discovery.js' });
2043
+ entity.discoveryNotes.push(`Entity plan deferred: ${error.message}`);
2044
+ }
2045
+ }
2046
+ const metadata = entity.sourceEntityRef ? `\n## Source binding\n\n${JSON.stringify({ sourceEntityRef: entity.sourceEntityRef, bridgeDesignated: true, sourceMeta: entity.sourceMeta }, null, 2)}\n` : '';
2047
+ await fs.writeFile(path.join(outDir, entity.fileName), renderEntityFile(entity) + metadata, 'utf8');
627
2048
  progress?.progress(`Wrote WordPress discovery artifact for ${entity.entityName}`, {
628
2049
  phase: 'discovery',
629
2050
  step: 'write-artifact',
630
2051
  entity: entity.routePath,
631
2052
  artifact: path.join(outDir, entity.fileName),
632
2053
  });
2054
+ // structure-bridge-plugin entities additionally persist the exact
2055
+ // structureRequest their sample used, as machine-readable JSON alongside the
2056
+ // human-readable markdown -- see sampleStructureBridgeEntities()'s own comment on why.
2057
+ if (entity.structureRequestArtifact) {
2058
+ const artifactPath = path.join(outDir, entity.structureRequestArtifact.fileName);
2059
+ await fs.writeFile(artifactPath, `${JSON.stringify(entity.structureRequestArtifact.content, null, 2)}\n`, 'utf8');
2060
+ progress?.progress(`Wrote structure-request artifact for ${entity.entityName}`, {
2061
+ phase: 'discovery',
2062
+ step: 'write-artifact',
2063
+ entity: entity.routePath,
2064
+ artifact: artifactPath,
2065
+ });
2066
+ } else if (entity.structureRequestArtifactFileName) {
2067
+ // This run could not produce a fresh sidecar (query skipped or failed) -- delete any
2068
+ // sidecar a PRIOR run left behind for this exact table, so rp-import-codegen can never
2069
+ // consume a stale one and mistake it for this run's (non-existent) authoritative query.
2070
+ const stalePath = path.join(outDir, entity.structureRequestArtifactFileName);
2071
+ try {
2072
+ await fs.unlink(stalePath);
2073
+ progress?.progress(`Removed stale structure-request artifact for ${entity.entityName}`, {
2074
+ phase: 'discovery',
2075
+ step: 'write-artifact',
2076
+ entity: entity.routePath,
2077
+ artifact: stalePath,
2078
+ });
2079
+ } catch (error) {
2080
+ if (error.code !== 'ENOENT') throw error;
2081
+ }
2082
+ }
2083
+
2084
+ // Same publish-or-clean rule for the scoped-value read plan: a stale plan is worse than a
2085
+ // missing one, because codegen would run it and produce a confidently wrong extraction
2086
+ // against a key list the site no longer has.
2087
+ if (entity.eavReadPlan) {
2088
+ const planPath = path.join(outDir, entity.eavReadPlan.fileName);
2089
+ await fs.writeFile(planPath, `${JSON.stringify(entity.eavReadPlan.content, null, 2)}\n`, 'utf8');
2090
+ progress?.progress(`Wrote EAV read plan for ${entity.entityName}`, {
2091
+ phase: 'discovery',
2092
+ step: 'write-artifact',
2093
+ entity: entity.routePath,
2094
+ artifact: planPath,
2095
+ });
2096
+ } else if (entity.eavReadPlanFileName) {
2097
+ try {
2098
+ await fs.unlink(path.join(outDir, entity.eavReadPlanFileName));
2099
+ } catch (error) {
2100
+ if (error.code !== 'ENOENT') throw error;
2101
+ }
2102
+ }
633
2103
  }
634
2104
  }
635
2105
 
636
2106
  async function main() {
637
2107
  const parsed = parseProgressArgs(process.argv.slice(2));
638
2108
  progress = createProgressLogger({
639
- script: 'skills/replatform/resources/rp-source-wordpress/scripts/wp-discovery.js',
2109
+ script: 'skills/wix-replatform/resources/rp-source-wordpress/scripts/wp-discovery.js',
640
2110
  ...parsed.progress,
641
2111
  });
642
2112
  progress.start('WordPress discovery started', { phase: 'discovery' });
643
2113
 
644
- const args = parseArgs(parsed.args);
2114
+ const args = await hydrateArgsFromEnvFile(parseArgs(parsed.args));
645
2115
  if (args.help) {
646
2116
  printUsage();
647
2117
  progress.complete('WordPress discovery help shown', { phase: 'discovery', step: 'help' });
648
2118
  return;
649
2119
  }
650
2120
 
2121
+ if (args.reclassifyCoverage) {
2122
+ const result = await runReclassifyCoverage(args);
2123
+ console.log(JSON.stringify({ ok: result.outcome === 'reclassified', ...result }, null, 2));
2124
+ if (result.outcome !== 'reclassified') {
2125
+ progress.warn('Plugin coverage reclassification needs a full discovery run', { phase: 'discovery', step: 'reclassify-coverage' });
2126
+ process.exitCode = 3;
2127
+ return;
2128
+ }
2129
+ progress.complete('Plugin coverage reclassified without refetching', { phase: 'discovery', step: 'reclassify-coverage' });
2130
+ return;
2131
+ }
2132
+
651
2133
  if (!args.baseUrl || !args.outDir) {
652
2134
  printUsage();
653
2135
  progress.error('Missing required WordPress discovery arguments', { phase: 'discovery' });
@@ -677,14 +2159,63 @@ async function main() {
677
2159
  count: namespaces.length,
678
2160
  unit: 'namespaces',
679
2161
  });
680
- const candidates = deriveEntityCandidates(indexJson, args.includeNamespaces);
2162
+ // Plugin inventory pre-pass: runs before classification so profile-declared routes are
2163
+ // already in scope when routes are classified.
2164
+ let inventory = null;
2165
+ if (args.pluginInventory) {
2166
+ try {
2167
+ const gathered = await gatherInventory({
2168
+ baseUrl: args.baseUrl,
2169
+ headers,
2170
+ timeoutMs: args.timeoutMs,
2171
+ htmlFingerprint: args.htmlFingerprint,
2172
+ restIndex: indexJson,
2173
+ logger: progress,
2174
+ });
2175
+ inventory = gathered;
2176
+ progress.progress('WordPress plugin inventory completed', {
2177
+ phase: 'discovery',
2178
+ step: 'plugin-inventory',
2179
+ count: gathered.detection.detected.length,
2180
+ unit: 'plugins',
2181
+ details: {
2182
+ pluginListAvailable: gathered.detection.pluginListAvailable,
2183
+ installedButUnprofiled: gathered.detection.installedButUnprofiled.length,
2184
+ },
2185
+ });
2186
+ } catch (error) {
2187
+ // Never fail discovery over the plugin pre-pass; record and continue.
2188
+ progress.progress(`WordPress plugin inventory skipped: ${error.message}`, {
2189
+ phase: 'discovery',
2190
+ step: 'plugin-inventory',
2191
+ });
2192
+ }
2193
+ }
2194
+
2195
+ const requestOverrides = buildRequestOverrides(pluginsRoot(path.resolve(__dirname, '..')));
2196
+ const candidates = deriveEntityCandidates(indexJson, args.includeNamespaces, requestOverrides);
681
2197
  progress.progress('WordPress endpoint candidates derived', {
682
2198
  phase: 'discovery',
683
2199
  step: 'derive-endpoints',
684
2200
  count: candidates.length,
685
2201
  unit: 'endpoints',
686
2202
  });
687
- const classifications = classifyRoutes(candidates, summarizeOverrides(args));
2203
+ // Registered post types/taxonomies are positive evidence for classification, so the
2204
+ // inventory pre-pass must run before this point (it fetches /wp/v2/types+taxonomies).
2205
+ const classifications = classifyRoutes(candidates, {
2206
+ ...summarizeOverrides(args),
2207
+ registeredRestBases: inventory ? buildRegisteredRestBases({ types: inventory.types, taxonomies: inventory.taxonomies }) : null,
2208
+ });
2209
+ // classifyRoutes() loads the checked-in plugin profiles lazily via defaultPluginRules();
2210
+ // a failed load degrades to zero plugin rules with no exception, so it must be surfaced
2211
+ // here or every plugin-owned route silently falls through to generic/unsupported handling.
2212
+ const pluginRulesError = defaultPluginRules().loadError || null;
2213
+ if (pluginRulesError) {
2214
+ progress.progress(`WordPress plugin route rules could not be loaded (${pluginRulesError}); plugin-owned routes will not be recognized this run.`, {
2215
+ phase: 'discovery',
2216
+ step: 'classify-endpoints',
2217
+ });
2218
+ }
688
2219
  const candidatesByRoute = new Map(candidates.map((candidate) => [candidate.routePath, candidate]));
689
2220
  const candidatesToInspect = classifications
690
2221
  .filter((classification) => ['sample', 'metadata'].includes(classification.effectiveAction))
@@ -707,6 +2238,9 @@ async function main() {
707
2238
  },
708
2239
  });
709
2240
  const entities = [];
2241
+ const responseEnvelopes = buildResponseEnvelopes(pluginsRoot(path.resolve(__dirname, '..')));
2242
+ const responseFragmentGroups = buildResponseFragmentGroups(pluginsRoot(path.resolve(__dirname, '..')));
2243
+ const recordKeyFields = buildRecordKeyFields(pluginsRoot(path.resolve(__dirname, '..')));
710
2244
 
711
2245
  for (let i = 0; i < candidatesToInspect.length; i += 1) {
712
2246
  const candidate = candidatesToInspect[i];
@@ -723,15 +2257,84 @@ async function main() {
723
2257
  sampleLimit: args.sampleLimit,
724
2258
  timeoutMs: args.timeoutMs,
725
2259
  progress,
2260
+ responseEnvelope: responseEnvelopes.get(candidate.routePath) || null,
2261
+ responseFragmentGroupSize: responseFragmentGroups.get(candidate.routePath) || null,
2262
+ recordKeyField: recordKeyFields.get(candidate.routePath) || null,
2263
+ requestOverride: candidate.requestOverride,
2264
+ defaultQuery: defaultQueryFor(candidate.routePath),
2265
+ defaultQueryReason: defaultQueryReasonFor(candidate.routePath),
726
2266
  });
727
2267
  entities.push(details);
728
2268
  }
729
2269
 
2270
+ // Second detection pass + Tier-B derivation + coverage. This is where plugins that add
2271
+ // no REST route (Product Bundles, ACF, Yoast) become visible, because it looks at the
2272
+ // record payload keys the sampling loop just collected.
2273
+ let plugins = null;
2274
+ if (inventory) {
2275
+ plugins = buildPluginCoverage({ args, inventory, classifications, entities, allCandidates: candidates });
2276
+ progress.progress('WordPress plugin coverage classified', {
2277
+ phase: 'discovery',
2278
+ step: 'plugin-coverage',
2279
+ count: plugins.coverage.length,
2280
+ unit: 'capabilities',
2281
+ details: plugins.summary.byStatus,
2282
+ });
2283
+
2284
+ // Third pass: plugin-rest-child entities — a parent-scoped sub-resource
2285
+ // (e.g. /wc/v3/orders/{parentId}/notes) cannot be listed on its own, so it is checked by
2286
+ // substituting real ids from the parent collection this run already sampled.
2287
+ const childSamples = await sampleChildEntities({
2288
+ baseUrl: args.baseUrl,
2289
+ headers,
2290
+ timeoutMs: args.timeoutMs,
2291
+ sampleLimit: args.sampleLimit,
2292
+ progress,
2293
+ detection: plugins.detection,
2294
+ sampledByRoute: new Map(entities.map((entity) => [entity.routePath, entity])),
2295
+ });
2296
+ if (childSamples.length > 0) {
2297
+ progress.progress('WordPress per-parent sub-resource sampling completed', {
2298
+ phase: 'discovery',
2299
+ step: 'sample-child-entity',
2300
+ count: childSamples.length,
2301
+ unit: 'entities',
2302
+ });
2303
+ }
2304
+ plugins = { ...plugins, childSamples };
2305
+
2306
+ // Fourth pass: structure-bridge-plugin entities -- data with no REST route
2307
+ // at all, captured through wix-wp-plugin-v2 instead. Pushed into the same `entities`
2308
+ // array so it flows through the existing per-entity markdown writer unchanged; run
2309
+ // after detection/coverage so it can skip a plugin that isn't actually active.
2310
+ const structureBridgeEntities = await sampleStructureBridgeEntities({
2311
+ baseUrl: args.baseUrl,
2312
+ headers,
2313
+ migrationKey: args.migrationKey,
2314
+ namespaces,
2315
+ sampleLimit: args.sampleLimit,
2316
+ timeoutMs: args.timeoutMs,
2317
+ progress,
2318
+ detection: plugins.detection,
2319
+ outDir: args.outDir,
2320
+ });
2321
+ if (structureBridgeEntities.length > 0) {
2322
+ progress.progress('wix-wp-plugin-v2 structure-bridge-plugin capture completed', {
2323
+ phase: 'discovery',
2324
+ step: 'structure-bridge-plugin',
2325
+ count: structureBridgeEntities.length,
2326
+ unit: 'entities',
2327
+ });
2328
+ }
2329
+ entities.push(...structureBridgeEntities);
2330
+ }
2331
+
730
2332
  const context = {
731
2333
  generatedAt: new Date().toISOString(),
732
2334
  baseUrl: normalizeBaseUrl(args.baseUrl),
733
2335
  restRoot: `${normalizeBaseUrl(args.baseUrl)}/wp-json`,
734
2336
  authMode: summarizeAuthMode(args),
2337
+ bridgeAuthMode: summarizeBridgeAuthMode(args, namespaces),
735
2338
  authProviders: Object.keys(indexJson?.authentication || {}),
736
2339
  namespaces,
737
2340
  totalAdvertisedRoutes: Object.keys(indexJson?.routes || {}).length,
@@ -743,6 +2346,14 @@ async function main() {
743
2346
  classifications,
744
2347
  routeIndexSample: Object.keys(indexJson?.routes || {}).slice(0, 50),
745
2348
  entities,
2349
+ plugins,
2350
+ pluginNotes: [
2351
+ ...(inventory ? inventory.notes : ['Plugin inventory was disabled with --no-plugin-inventory.']),
2352
+ ...(pluginRulesError
2353
+ ? [`WordPress plugin route rules could not be loaded (${pluginRulesError}); plugin-owned routes were not recognized this run.`]
2354
+ : []),
2355
+ ],
2356
+ pluginProfileCount: inventory ? inventory.profileCount : 0,
746
2357
  };
747
2358
 
748
2359
  await writeOutputs(args.outDir, context, progress);
@@ -770,5 +2381,29 @@ module.exports = {
770
2381
  parseArgs,
771
2382
  deriveEntityCandidates,
772
2383
  renderIndexFile,
2384
+ renderPluginSection,
773
2385
  skippedRoutesPayload,
2386
+ sourceCoveragePayload,
2387
+ buildPluginCoverage,
2388
+ pluginCoveragePayload,
2389
+ buildEntityStats,
2390
+ reclassifyPluginCoverage,
2391
+ runReclassifyCoverage,
2392
+ loadDecisions,
2393
+ loadTargetKnowledge,
2394
+ pickChildSampleParentIds,
2395
+ buildChildRoutePath,
2396
+ describeChildSample,
2397
+ sampleChildEntities,
2398
+ sampleStructureBridgeEntities,
2399
+ resolveSampleStructureRequest,
2400
+ writeOutputs,
2401
+ getAtPath,
2402
+ inspectEntity,
2403
+ resolveRequestBody,
2404
+ normalizeResponseRecords,
2405
+ findSampledIdsDependencies,
2406
+ summarizeAuthMode,
2407
+ summarizeBridgeAuthMode,
2408
+ chooseBridgeAuth,
774
2409
  };