@open-mercato/cli 0.6.7 → 0.6.8-canary.320.1.bf889f49e4

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 (335) hide show
  1. package/.turbo/turbo-build.log +77 -4
  2. package/AGENTS.md +6 -1
  3. package/build.mjs +68 -11
  4. package/dist/agentic/claude-code/hooks/entity-migration-check.ts +32 -88
  5. package/dist/agentic/codex/enforcement-rules.md +2 -16
  6. package/dist/agentic/cursor/hooks/entity-migration-check.mjs +19 -50
  7. package/dist/agentic/cursor/rules/entity-guard.mdc +9 -21
  8. package/dist/agentic/cursor/rules/generated-guard.mdc +3 -5
  9. package/dist/agentic/cursor/rules/open-mercato.mdc +3 -29
  10. package/dist/agentic/guides/ai-workflows.md +76 -0
  11. package/dist/agentic/guides/architecture.md +107 -0
  12. package/dist/agentic/guides/backend-ui.md +86 -0
  13. package/dist/agentic/guides/contracts.md +92 -0
  14. package/dist/agentic/guides/extensions.md +121 -0
  15. package/dist/agentic/guides/framework-extension-points.md +36 -0
  16. package/dist/agentic/guides/integrations.md +81 -0
  17. package/dist/agentic/guides/module-facts.json +116757 -3951
  18. package/dist/agentic/guides/module-system.md +12 -127
  19. package/dist/agentic/guides/modules/ai_assistant.md +227 -28
  20. package/dist/agentic/guides/modules/api_docs.md +58 -2
  21. package/dist/agentic/guides/modules/api_keys.md +92 -7
  22. package/dist/agentic/guides/modules/attachments.md +119 -14
  23. package/dist/agentic/guides/modules/audit_logs.md +131 -10
  24. package/dist/agentic/guides/modules/auth.md +276 -33
  25. package/dist/agentic/guides/modules/business_rules.md +149 -14
  26. package/dist/agentic/guides/modules/catalog.md +482 -43
  27. package/dist/agentic/guides/modules/channel_gmail.md +82 -3
  28. package/dist/agentic/guides/modules/channel_imap.md +82 -3
  29. package/dist/agentic/guides/modules/checkout.md +305 -27
  30. package/dist/agentic/guides/modules/communication_channels.md +315 -33
  31. package/dist/agentic/guides/modules/configs.md +104 -8
  32. package/dist/agentic/guides/modules/content.md +57 -2
  33. package/dist/agentic/guides/modules/currencies.md +152 -17
  34. package/dist/agentic/guides/modules/customer_accounts.md +387 -45
  35. package/dist/agentic/guides/modules/customers.md +746 -85
  36. package/dist/agentic/guides/modules/dashboards.md +155 -10
  37. package/dist/agentic/guides/modules/data_sync.md +149 -16
  38. package/dist/agentic/guides/modules/design_system.md +102 -0
  39. package/dist/agentic/guides/modules/dictionaries.md +107 -12
  40. package/dist/agentic/guides/modules/directory.md +148 -15
  41. package/dist/agentic/guides/modules/entities.md +145 -13
  42. package/dist/agentic/guides/modules/events.md +59 -2
  43. package/dist/agentic/guides/modules/feature_toggles.md +119 -9
  44. package/dist/agentic/guides/modules/gateway_stripe.md +92 -4
  45. package/dist/agentic/guides/modules/generators.md +45 -2
  46. package/dist/agentic/guides/modules/inbox_ops.md +207 -27
  47. package/dist/agentic/guides/modules/integrations.md +149 -16
  48. package/dist/agentic/guides/modules/messages.md +223 -24
  49. package/dist/agentic/guides/modules/notifications.md +96 -8
  50. package/dist/agentic/guides/modules/onboarding.md +77 -6
  51. package/dist/agentic/guides/modules/payment_gateways.md +168 -21
  52. package/dist/agentic/guides/modules/perspectives.md +77 -7
  53. package/dist/agentic/guides/modules/planner.md +136 -18
  54. package/dist/agentic/guides/modules/portal.md +93 -2
  55. package/dist/agentic/guides/modules/progress.md +104 -14
  56. package/dist/agentic/guides/modules/query_index.md +154 -15
  57. package/dist/agentic/guides/modules/record_locks.md +206 -21
  58. package/dist/agentic/guides/modules/resources.md +197 -30
  59. package/dist/agentic/guides/modules/sales.md +687 -84
  60. package/dist/agentic/guides/modules/scheduler.md +133 -14
  61. package/dist/agentic/guides/modules/search.md +170 -6
  62. package/dist/agentic/guides/modules/security.md +294 -35
  63. package/dist/agentic/guides/modules/shipping_carriers.md +134 -18
  64. package/dist/agentic/guides/modules/sso.md +151 -26
  65. package/dist/agentic/guides/modules/staff.md +372 -57
  66. package/dist/agentic/guides/modules/storage_s3.md +95 -5
  67. package/dist/agentic/guides/modules/sync_akeneo.md +85 -3
  68. package/dist/agentic/guides/modules/sync_excel.md +75 -6
  69. package/dist/agentic/guides/modules/system_status_overlays.md +60 -2
  70. package/dist/agentic/guides/modules/translations.md +104 -10
  71. package/dist/agentic/guides/modules/webhooks.md +203 -24
  72. package/dist/agentic/guides/modules/wms.md +469 -47
  73. package/dist/agentic/guides/modules/workflows.md +302 -43
  74. package/dist/agentic/guides/reference-module-facts.json +6942 -0
  75. package/dist/agentic/guides/reference-modules/example.md +462 -0
  76. package/dist/agentic/guides/spec-delivery.md +56 -0
  77. package/dist/agentic/guides/testing-debugging.md +80 -0
  78. package/dist/agentic/guides/upstream/AGENTS.md +300 -0
  79. package/dist/agentic/guides/upstream/BACKWARD_COMPATIBILITY.md +334 -0
  80. package/dist/agentic/guides/upstream/manifest.json +8 -0
  81. package/dist/agentic/shared/AGENTS.md.template +120 -311
  82. package/dist/agentic/shared/ai/agentic.config.json +2 -0
  83. package/dist/agentic/shared/ai/harness/README.md +50 -0
  84. package/dist/agentic/shared/ai/harness/RELEASE.md +59 -0
  85. package/dist/agentic/shared/ai/harness/cases.json +20596 -0
  86. package/dist/agentic/shared/ai/harness/cases.schema.json +196 -0
  87. package/dist/agentic/shared/ai/harness/design-system-inventory.json +6326 -0
  88. package/dist/agentic/shared/ai/harness/fixtures/index.json +51 -0
  89. package/dist/agentic/shared/ai/harness/fixtures/seeds.json +166 -0
  90. package/dist/agentic/shared/ai/harness/generated-code-review-policy.md +21 -0
  91. package/dist/agentic/shared/ai/harness/generated-code-review-response.schema.json +96 -0
  92. package/dist/agentic/shared/ai/harness/generated-code-review-result.schema.json +172 -0
  93. package/dist/agentic/shared/ai/harness/knowledge-change.schema.json +228 -0
  94. package/dist/agentic/shared/ai/harness/release-matrix.json +163 -0
  95. package/dist/agentic/shared/ai/harness/release-result.schema.json +219 -0
  96. package/dist/agentic/shared/ai/harness/result.schema.json +136 -0
  97. package/dist/agentic/shared/ai/harness/routing-response.schema.json +22 -0
  98. package/dist/agentic/shared/ai/harness/source-link-inventory.json +1706 -0
  99. package/dist/agentic/shared/ai/harness/target-validation-result.schema.json +73 -0
  100. package/dist/agentic/shared/ai/harness/validators.json +82 -0
  101. package/dist/agentic/shared/ai/harness/writable-ast-oracles.mjs +2121 -0
  102. package/dist/agentic/shared/ai/harness/writable-behavior-oracles.mjs +1096 -0
  103. package/dist/agentic/shared/ai/harness/writable-spec-oracles.mjs +602 -0
  104. package/dist/agentic/shared/ai/lessons/_template.md +16 -0
  105. package/dist/agentic/shared/ai/lessons.md +26 -3
  106. package/dist/agentic/shared/ai/review-checklist.md +36 -0
  107. package/dist/agentic/shared/ai/skills/om-auto-implement-spec/SKILL.md +21 -0
  108. package/dist/agentic/shared/ai/skills/om-auto-review-pr/SKILL.md +4 -0
  109. package/dist/agentic/shared/ai/skills/om-auto-upgrade-0.6.6-to-0.6.7/SKILL.md +98 -0
  110. package/dist/agentic/shared/ai/skills/om-backend-ui-design/SKILL.md +21 -241
  111. package/dist/agentic/shared/ai/skills/om-backend-ui-design/references/crud-surfaces.md +31 -0
  112. package/dist/agentic/shared/ai/skills/om-backend-ui-design/references/frontend-and-design-system.md +53 -0
  113. package/dist/agentic/shared/ai/skills/om-backend-ui-design/references/page-and-navigation.md +15 -0
  114. package/dist/agentic/shared/ai/skills/om-backend-ui-design/references/quality-states.md +11 -0
  115. package/dist/agentic/shared/ai/skills/om-build-workflow/SKILL.md +30 -0
  116. package/dist/agentic/shared/ai/skills/om-build-workflow/references/activity-contracts.md +12 -0
  117. package/dist/agentic/shared/ai/skills/om-build-workflow/references/durability-and-progress.md +13 -0
  118. package/dist/agentic/shared/ai/skills/om-build-workflow/references/workflow-design.md +14 -0
  119. package/dist/agentic/shared/ai/skills/om-create-ai-agent/SKILL.md +28 -0
  120. package/dist/agentic/shared/ai/skills/om-create-ai-agent/references/attachments-and-overrides.md +12 -0
  121. package/dist/agentic/shared/ai/skills/om-create-ai-agent/references/module-agents-and-tools.md +22 -0
  122. package/dist/agentic/shared/ai/skills/om-create-ai-agent/references/orchestrator-agents.md +12 -0
  123. package/dist/agentic/shared/ai/skills/om-create-ai-agent/references/surface-selector.md +19 -0
  124. package/dist/agentic/shared/ai/skills/om-data-model-design/SKILL.md +17 -601
  125. package/dist/agentic/shared/ai/skills/om-data-model-design/references/integrity-and-concurrency.md +21 -0
  126. package/dist/agentic/shared/ai/skills/om-data-model-design/references/migration-workflow.md +15 -0
  127. package/dist/agentic/shared/ai/skills/om-data-model-design/references/schema-design.md +16 -0
  128. package/dist/agentic/shared/ai/skills/om-data-model-design/references/sensitive-data.md +10 -0
  129. package/dist/agentic/shared/ai/skills/om-eject-and-customize/SKILL.md +15 -310
  130. package/dist/agentic/shared/ai/skills/om-eject-and-customize/references/decision-and-procedure.md +19 -0
  131. package/dist/agentic/shared/ai/skills/om-evolve-harness/SKILL.md +31 -0
  132. package/dist/agentic/shared/ai/skills/om-evolve-harness/references/case-template.md +100 -0
  133. package/dist/agentic/shared/ai/skills/om-evolve-harness/references/case-workflow.md +16 -0
  134. package/dist/agentic/shared/ai/skills/om-evolve-harness/references/knowledge-change.md +133 -0
  135. package/dist/agentic/shared/ai/skills/om-evolve-harness/references/owner-selection.md +17 -0
  136. package/dist/agentic/shared/ai/skills/om-framework-context/SKILL.md +25 -0
  137. package/dist/agentic/shared/ai/skills/om-framework-context/references/resolver-procedure.md +11 -0
  138. package/dist/agentic/shared/ai/skills/om-framework-context/references/skew-and-escalation.md +13 -0
  139. package/dist/agentic/shared/ai/skills/om-help/SKILL.md +15 -97
  140. package/dist/agentic/shared/ai/skills/om-help/references/delivery-workflows.md +18 -0
  141. package/dist/agentic/shared/ai/skills/om-help/references/task-families.md +20 -0
  142. package/dist/agentic/shared/ai/skills/om-implement-spec/SKILL.md +33 -152
  143. package/dist/agentic/shared/ai/skills/om-implement-spec/references/phases-and-gates.md +33 -0
  144. package/dist/agentic/shared/ai/skills/om-implement-spec/references/planning-and-progress.md +40 -0
  145. package/dist/agentic/shared/ai/skills/om-implement-spec/references/report-templates.md +27 -0
  146. package/dist/agentic/shared/ai/skills/om-implement-spec/references/spec-resolution.md +24 -0
  147. package/dist/agentic/shared/ai/skills/om-integration-builder/SKILL.md +25 -708
  148. package/dist/agentic/shared/ai/skills/om-integration-builder/references/package-and-activation.md +16 -0
  149. package/dist/agentic/shared/ai/skills/om-integration-builder/references/provider-families.md +25 -0
  150. package/dist/agentic/shared/ai/skills/om-integration-builder/references/security-and-reliability.md +15 -0
  151. package/dist/agentic/shared/ai/skills/om-integration-builder/references/sync-and-files.md +12 -0
  152. package/dist/agentic/shared/ai/skills/om-judge-agent-session/SKILL.md +34 -0
  153. package/dist/agentic/shared/ai/skills/om-judge-agent-session/agents/openai.yaml +4 -0
  154. package/dist/agentic/shared/ai/skills/om-judge-agent-session/references/agentic-setup.md +11 -0
  155. package/dist/agentic/shared/ai/skills/om-judge-agent-session/references/input-normalization.md +31 -0
  156. package/dist/agentic/shared/ai/skills/om-judge-agent-session/references/judge-workflow.md +39 -0
  157. package/dist/agentic/shared/ai/skills/om-judge-agent-session/references/report-template.md +43 -0
  158. package/dist/agentic/shared/ai/skills/om-judge-agent-session/references/rules.md +11 -0
  159. package/dist/agentic/shared/ai/skills/om-module-scaffold/SKILL.md +20 -820
  160. package/dist/agentic/shared/ai/skills/om-module-scaffold/references/api-and-domain.md +32 -0
  161. package/dist/agentic/shared/ai/skills/om-module-scaffold/references/business-one-shot-blueprints.md +172 -0
  162. package/dist/agentic/shared/ai/skills/om-module-scaffold/references/data-and-migrations.md +14 -0
  163. package/dist/agentic/shared/ai/skills/om-module-scaffold/references/discovery-surface-catalog.md +83 -0
  164. package/dist/agentic/shared/ai/skills/om-module-scaffold/references/module-surfaces.md +40 -0
  165. package/dist/agentic/shared/ai/skills/om-module-scaffold/references/planning.md +11 -0
  166. package/dist/agentic/shared/ai/skills/om-module-scaffold/references/runtime-cache-and-queues.md +22 -0
  167. package/dist/agentic/shared/ai/skills/om-module-scaffold/references/verification.md +13 -0
  168. package/dist/agentic/shared/ai/skills/om-share-this-session/SKILL.md +41 -0
  169. package/dist/agentic/shared/ai/skills/om-share-this-session/references/agentic-setup.md +19 -0
  170. package/dist/agentic/shared/ai/skills/om-share-this-session/references/bundle-preparation.md +44 -0
  171. package/dist/agentic/shared/ai/skills/om-share-this-session/references/consent-and-review.md +39 -0
  172. package/dist/agentic/shared/ai/skills/om-share-this-session/references/publication.md +20 -0
  173. package/dist/agentic/shared/ai/skills/om-share-this-session/references/report-templates.md +57 -0
  174. package/dist/agentic/shared/ai/skills/om-share-this-session/references/rules.md +11 -0
  175. package/dist/agentic/shared/ai/skills/om-share-this-session/scripts/prepare-share-bundle.mjs +486 -0
  176. package/dist/agentic/shared/ai/skills/om-system-extension/SKILL.md +20 -843
  177. package/dist/agentic/shared/ai/skills/om-system-extension/references/extension-branches.md +42 -0
  178. package/dist/agentic/shared/ai/skills/om-system-extension/references/mechanism-selector.md +27 -0
  179. package/dist/agentic/shared/ai/skills/om-system-extension/references/read-write-roundtrip.md +13 -0
  180. package/dist/agentic/shared/ai/skills/om-system-extension/references/unified-overrides.md +43 -0
  181. package/dist/agentic/shared/ai/skills/om-system-extension/references/verification.md +11 -0
  182. package/dist/agentic/shared/ai/skills/om-trim-unused-modules/SKILL.md +15 -63
  183. package/dist/agentic/shared/ai/skills/om-trim-unused-modules/references/dependency-and-redirect.md +15 -0
  184. package/dist/agentic/shared/ai/skills/om-troubleshooter/SKILL.md +17 -467
  185. package/dist/agentic/shared/ai/skills/om-troubleshooter/references/diagnosis-map.md +29 -0
  186. package/dist/agentic/shared/ai/skills/om-troubleshooter/references/regression-oracles.md +14 -0
  187. package/dist/agentic/shared/ai/skills/tiers.json +143 -21
  188. package/dist/agentic/shared/ai/skills/tiers.schema.json +52 -40
  189. package/dist/agentic/shared/ai/specs/2026-08-06-reference-module-activation.md +248 -0
  190. package/dist/agentic/shared/ai/specs/README.md +4 -3
  191. package/dist/agentic/shared/ai/specs/SPEC-000-template.md +226 -10
  192. package/dist/agentic/shared/ai/trackers/github.md +108 -4
  193. package/dist/agentic/shared/scripts/agent-harness-tool-server.mjs +224 -0
  194. package/dist/agentic/shared/scripts/check-lessons.mjs +178 -0
  195. package/dist/agentic/shared/scripts/evaluate-agent-harness.mjs +3812 -0
  196. package/dist/agentic/shared/scripts/execution-sandbox.mjs +329 -0
  197. package/dist/agentic/shared/scripts/framework-context.mjs +888 -0
  198. package/dist/agentic/shared/scripts/install-skills.mjs +1029 -0
  199. package/dist/agentic/shared/scripts/install-skills.sh +4 -694
  200. package/dist/agentic/shared/scripts/prepare-agent-harness-fixture.mjs +222 -0
  201. package/dist/agentic/shared/scripts/run-agent-harness-release.mjs +1774 -0
  202. package/dist/agentic/shared/scripts/validate-knowledge-change.mjs +1172 -0
  203. package/dist/bin.js +32 -34
  204. package/dist/bin.js.map +2 -2
  205. package/dist/lib/__integration__/TC-INT-008.spec.js +88 -8
  206. package/dist/lib/__integration__/TC-INT-008.spec.js.map +2 -2
  207. package/dist/lib/agentic-init.js +13 -3
  208. package/dist/lib/agentic-init.js.map +2 -2
  209. package/dist/lib/agentic-setup.js +434 -186
  210. package/dist/lib/agentic-setup.js.map +2 -2
  211. package/dist/lib/cli-bootstrap-mode.js +32 -0
  212. package/dist/lib/cli-bootstrap-mode.js.map +7 -0
  213. package/dist/lib/dev-supervisor-manifest.js +105 -0
  214. package/dist/lib/dev-supervisor-manifest.js.map +7 -0
  215. package/dist/lib/generate-watch-events.js +15 -0
  216. package/dist/lib/generate-watch-events.js.map +2 -2
  217. package/dist/lib/generators/entity-ids.js +11 -24
  218. package/dist/lib/generators/entity-ids.js.map +2 -2
  219. package/dist/lib/generators/extensions/injection-widgets.js +20 -0
  220. package/dist/lib/generators/extensions/injection-widgets.js.map +2 -2
  221. package/dist/lib/generators/module-di.js +10 -23
  222. package/dist/lib/generators/module-di.js.map +2 -2
  223. package/dist/lib/generators/module-entities.js +10 -23
  224. package/dist/lib/generators/module-entities.js.map +2 -2
  225. package/dist/lib/generators/module-extension-facts.js +1882 -0
  226. package/dist/lib/generators/module-extension-facts.js.map +7 -0
  227. package/dist/lib/generators/module-fact-sources.js +70 -0
  228. package/dist/lib/generators/module-fact-sources.js.map +7 -0
  229. package/dist/lib/generators/module-facts-discovery.js +64 -7
  230. package/dist/lib/generators/module-facts-discovery.js.map +2 -2
  231. package/dist/lib/generators/module-facts.js +1913 -52
  232. package/dist/lib/generators/module-facts.js.map +3 -3
  233. package/dist/lib/generators/module-override-targets.js +712 -0
  234. package/dist/lib/generators/module-override-targets.js.map +7 -0
  235. package/dist/lib/generators/module-registry.js +405 -36
  236. package/dist/lib/generators/module-registry.js.map +2 -2
  237. package/dist/lib/generators/route-manifest-shards.js +170 -0
  238. package/dist/lib/generators/route-manifest-shards.js.map +7 -0
  239. package/dist/lib/in-process-generate-watcher.js +12 -3
  240. package/dist/lib/in-process-generate-watcher.js.map +2 -2
  241. package/dist/lib/load-env.js +24 -0
  242. package/dist/lib/load-env.js.map +7 -0
  243. package/dist/lib/queue-worker-supervisor.js.map +2 -2
  244. package/dist/lib/resolver.js +28 -3
  245. package/dist/lib/resolver.js.map +2 -2
  246. package/dist/lib/telemetry-init.js +358 -0
  247. package/dist/lib/telemetry-init.js.map +7 -0
  248. package/dist/lib/testing/integration.js +5 -2
  249. package/dist/lib/testing/integration.js.map +2 -2
  250. package/dist/lib/utils.js +15 -8
  251. package/dist/lib/utils.js.map +2 -2
  252. package/dist/mercato.js +35 -9
  253. package/dist/mercato.js.map +2 -2
  254. package/package.json +13 -11
  255. package/src/__tests__/mercato.test.ts +144 -0
  256. package/src/bin.ts +60 -42
  257. package/src/lib/__integration__/TC-INT-008.spec.ts +107 -9
  258. package/src/lib/__tests__/agentic-init.test.ts +41 -5
  259. package/src/lib/__tests__/agentic-setup.ownership.test.ts +386 -0
  260. package/src/lib/__tests__/cli-bootstrap-mode.test.ts +22 -0
  261. package/src/lib/__tests__/content-stable-writes.test.ts +74 -0
  262. package/src/lib/__tests__/dev-supervisor-manifest.test.ts +131 -0
  263. package/src/lib/__tests__/generate-watch-events.test.ts +76 -0
  264. package/src/lib/__tests__/in-process-generate-watcher.test.ts +52 -1
  265. package/src/lib/__tests__/injection-widget-id-validation.test.ts +184 -0
  266. package/src/lib/__tests__/load-env.test.ts +65 -0
  267. package/src/lib/__tests__/queue-worker-supervisor.test.ts +33 -0
  268. package/src/lib/__tests__/resolver.enterprise.test.ts +50 -0
  269. package/src/lib/__tests__/telemetry-init.test.ts +298 -0
  270. package/src/lib/agentic-init.ts +15 -3
  271. package/src/lib/agentic-setup.ts +573 -222
  272. package/src/lib/cli-bootstrap-mode.ts +31 -0
  273. package/src/lib/dev-supervisor-manifest.ts +142 -0
  274. package/src/lib/generate-watch-events.ts +14 -0
  275. package/src/lib/generators/__tests__/activation-adapter-coverage.test.ts +92 -0
  276. package/src/lib/generators/__tests__/entity-ids.test.ts +32 -0
  277. package/src/lib/generators/__tests__/helpers/override-target-diagnostic-fixtures.ts +150 -0
  278. package/src/lib/generators/__tests__/module-extension-activations.test.ts +762 -0
  279. package/src/lib/generators/__tests__/module-extension-facts.test.ts +603 -0
  280. package/src/lib/generators/__tests__/module-facts.bc-guard.test.ts +139 -2
  281. package/src/lib/generators/__tests__/module-facts.computed-di-token.test.ts +88 -0
  282. package/src/lib/generators/__tests__/module-facts.customers.fixture.test.ts +1 -0
  283. package/src/lib/generators/__tests__/module-facts.discovery.test.ts +54 -10
  284. package/src/lib/generators/__tests__/module-facts.example-fact-coverage.test.ts +414 -0
  285. package/src/lib/generators/__tests__/module-facts.extension-hosts.test.ts +108 -0
  286. package/src/lib/generators/__tests__/module-facts.local-reference.test.ts +393 -0
  287. package/src/lib/generators/__tests__/module-facts.owned-contracts.test.ts +561 -0
  288. package/src/lib/generators/__tests__/module-facts.search-entity-id.test.ts +151 -0
  289. package/src/lib/generators/__tests__/module-facts.source-links.test.ts +160 -0
  290. package/src/lib/generators/__tests__/module-override-targets.diagnostic-wiring.test.ts +92 -0
  291. package/src/lib/generators/__tests__/module-override-targets.roundtrip.test.ts +149 -0
  292. package/src/lib/generators/__tests__/module-override-targets.test.ts +328 -0
  293. package/src/lib/generators/__tests__/module-override-targets.unknown-mode.test.ts +117 -0
  294. package/src/lib/generators/__tests__/module-subset.test.ts +266 -0
  295. package/src/lib/generators/__tests__/output-snapshots.test.ts +3 -3
  296. package/src/lib/generators/__tests__/route-manifest-shards.test.ts +62 -0
  297. package/src/lib/generators/entity-ids.ts +10 -26
  298. package/src/lib/generators/extensions/injection-widgets.ts +51 -0
  299. package/src/lib/generators/module-di.ts +9 -25
  300. package/src/lib/generators/module-entities.ts +9 -25
  301. package/src/lib/generators/module-extension-facts.ts +2472 -0
  302. package/src/lib/generators/module-fact-sources.ts +108 -0
  303. package/src/lib/generators/module-facts-discovery.ts +104 -7
  304. package/src/lib/generators/module-facts.ts +2747 -138
  305. package/src/lib/generators/module-override-targets.ts +907 -0
  306. package/src/lib/generators/module-registry.ts +448 -35
  307. package/src/lib/generators/route-manifest-shards.ts +146 -0
  308. package/src/lib/in-process-generate-watcher.ts +13 -4
  309. package/src/lib/load-env.ts +30 -0
  310. package/src/lib/queue-worker-supervisor.ts +7 -2
  311. package/src/lib/resolver.ts +34 -3
  312. package/src/lib/telemetry-init.ts +461 -0
  313. package/src/lib/testing/__tests__/integration.test.ts +4 -0
  314. package/src/lib/testing/integration.ts +5 -2
  315. package/src/lib/utils.ts +24 -16
  316. package/src/mercato.ts +46 -9
  317. package/dist/agentic/guides/cache.md +0 -45
  318. package/dist/agentic/guides/core.md +0 -453
  319. package/dist/agentic/guides/events.md +0 -117
  320. package/dist/agentic/guides/queue.md +0 -53
  321. package/dist/agentic/guides/search.md +0 -115
  322. package/dist/agentic/guides/shared.md +0 -108
  323. package/dist/agentic/guides/ui.md +0 -347
  324. package/dist/agentic/shared/ai/skills/om-auto-continue-pr-loop/SKILL.md +0 -27
  325. package/dist/agentic/shared/ai/skills/om-auto-create-pr-loop/SKILL.md +0 -27
  326. package/dist/agentic/shared/ai/skills/om-backend-ui-design/references/ui-components.md +0 -260
  327. package/dist/agentic/shared/ai/skills/om-data-model-design/references/mikro-orm-cheatsheet.md +0 -146
  328. package/dist/agentic/shared/ai/skills/om-help/references/skills-catalog.md +0 -84
  329. package/dist/agentic/shared/ai/skills/om-help/references/workflow-sequences.md +0 -193
  330. package/dist/agentic/shared/ai/skills/om-integration-builder/STANDALONE.md +0 -34
  331. package/dist/agentic/shared/ai/skills/om-integration-builder/references/adapter-contracts.md +0 -762
  332. package/dist/agentic/shared/ai/skills/om-module-scaffold/references/naming-conventions.md +0 -50
  333. package/dist/agentic/shared/ai/skills/om-module-scaffold/references/navigation-patterns.md +0 -97
  334. package/dist/agentic/shared/ai/skills/om-system-extension/references/extension-contracts.md +0 -271
  335. package/dist/agentic/shared/ai/skills/om-troubleshooter/references/diagnostic-commands.md +0 -101
@@ -0,0 +1,712 @@
1
+ import crypto from "node:crypto";
2
+ import { buildFactSourceLookup } from "./module-fact-sources.js";
3
+ import { getFrameworkOverrideHostOperations } from "./module-extension-facts.js";
4
+ const MODULE_OVERRIDE_MODES = ["disable-replace", "replace", "additive"];
5
+ const MODULE_OVERRIDE_TARGET_NOTES = [
6
+ "safe-metadata-only",
7
+ "page-middleware-not-mutation-guard"
8
+ ];
9
+ function isModuleOverrideMode(value) {
10
+ return MODULE_OVERRIDE_MODES.includes(value);
11
+ }
12
+ const MODULE_OVERRIDE_TARGET_DIAGNOSTIC_CODES = [
13
+ "missing-owned-fact",
14
+ "missing-source",
15
+ "unsupported-dynamic-key",
16
+ "unknown-framework-domain",
17
+ "unknown-framework-mode"
18
+ ];
19
+ const OVERRIDE_HOST_OPERATIONS = getFrameworkOverrideHostOperations();
20
+ function resolveFrameworkOverrideModes(operation) {
21
+ if (operation === void 0) return { outcome: "unknown-framework-domain" };
22
+ if (!isModuleOverrideMode(operation)) return { outcome: "unknown-framework-mode", operation };
23
+ return { outcome: "resolved", modes: [operation] };
24
+ }
25
+ function modesFor(dottedHost) {
26
+ return resolveFrameworkOverrideModes(OVERRIDE_HOST_OPERATIONS[dottedHost]);
27
+ }
28
+ function moduleIdOf(facts) {
29
+ const segments = facts.sourceRoot.split("/").filter(Boolean);
30
+ return segments[segments.length - 1] ?? "";
31
+ }
32
+ function computeOverrideTargetId(moduleId, domain, path) {
33
+ return crypto.createHash("sha1").update(JSON.stringify([moduleId, domain, path])).digest("hex").slice(0, 16);
34
+ }
35
+ function compareSourceRefs(left, right) {
36
+ return left.sourcePath.localeCompare(right.sourcePath) || (left.line ?? 0) - (right.line ?? 0) || (left.exportName ?? "").localeCompare(right.exportName ?? "");
37
+ }
38
+ function comparePaths(left, right) {
39
+ const length = Math.max(left.length, right.length);
40
+ for (let index = 0; index < length; index += 1) {
41
+ const leftSegment = left[index];
42
+ const rightSegment = right[index];
43
+ if (leftSegment === void 0) return -1;
44
+ if (rightSegment === void 0) return 1;
45
+ const compared = leftSegment.localeCompare(rightSegment);
46
+ if (compared !== 0) return compared;
47
+ }
48
+ return 0;
49
+ }
50
+ function makeTarget(input) {
51
+ const resolution = modesFor(input.dottedHost);
52
+ if (resolution.outcome !== "resolved") return resolution;
53
+ const { modes } = resolution;
54
+ const target = {
55
+ id: computeOverrideTargetId(input.moduleId, input.domain, input.path),
56
+ domain: input.domain,
57
+ ...input.key !== void 0 ? { key: input.key } : {},
58
+ path: input.path,
59
+ modes,
60
+ factRef: input.factRef,
61
+ source: input.source,
62
+ ...input.notes && input.notes.length > 0 ? { notes: input.notes } : {}
63
+ };
64
+ return target;
65
+ }
66
+ function pushTarget(targets, diagnostics, input) {
67
+ const result = makeTarget(input);
68
+ if (!("outcome" in result)) {
69
+ targets.push(result);
70
+ return;
71
+ }
72
+ diagnostics.push({
73
+ code: result.outcome,
74
+ moduleId: input.moduleId,
75
+ domain: input.domain,
76
+ candidatePath: input.path,
77
+ source: input.source
78
+ });
79
+ }
80
+ function contributionSource(contribution) {
81
+ return {
82
+ sourcePath: contribution.source.path,
83
+ ...contribution.source.symbol ? { exportName: contribution.source.symbol } : {}
84
+ };
85
+ }
86
+ function ownedSource(fact) {
87
+ return {
88
+ sourcePath: fact.source.sourcePath,
89
+ ...fact.source.line ? { line: fact.source.line } : {}
90
+ };
91
+ }
92
+ function contributionsOfKind(facts, kind) {
93
+ const contributions = facts.extensionSurfaces?.contributions ?? [];
94
+ return contributions.filter(
95
+ (contribution) => contribution.kind === kind
96
+ );
97
+ }
98
+ function indexedFactSourcePath(resolveFactSource, kind, id) {
99
+ return resolveFactSource(kind, id)?.sourcePath ?? null;
100
+ }
101
+ const VALID_HTTP_METHODS = /* @__PURE__ */ new Set(["GET", "POST", "PUT", "PATCH", "DELETE"]);
102
+ function apiRouteOverrideKey(method, routePath) {
103
+ const upper = method.trim().toUpperCase();
104
+ if (!VALID_HTTP_METHODS.has(upper)) return null;
105
+ const withLead = routePath.startsWith("/") ? routePath : `/${routePath}`;
106
+ const publicPath = withLead.startsWith("/api/") || withLead === "/api" ? withLead : `/api${withLead}`;
107
+ const normalized = publicPath.replace(/\/+$/, "") || "/";
108
+ return `${upper} ${normalized}`;
109
+ }
110
+ function pageRouteOverrideKey(routePath) {
111
+ const trimmed = routePath.trim();
112
+ if (!trimmed) return null;
113
+ if (trimmed.startsWith("backend:") || trimmed.startsWith("frontend:")) return trimmed;
114
+ const withLead = trimmed.startsWith("/") ? trimmed : `/${trimmed}`;
115
+ const stripped = withLead.replace(/\/+$/, "") || "/";
116
+ if (stripped === "/frontend") return "frontend:/";
117
+ if (stripped.startsWith("/frontend/")) return `frontend:/${stripped.slice("/frontend/".length)}`;
118
+ if (stripped === "/backend" || stripped.startsWith("/backend/")) return `backend:${stripped}`;
119
+ return `frontend:${stripped}`;
120
+ }
121
+ const aiAdapter = {
122
+ domain: "ai",
123
+ run(facts) {
124
+ const moduleId = moduleIdOf(facts);
125
+ const targets = [];
126
+ const diagnostics = [];
127
+ for (const agent of facts.aiAgents) {
128
+ if (!agent.sourcePath) {
129
+ diagnostics.push({ code: "missing-source", moduleId, domain: "ai", candidatePath: ["ai", "agents", agent.id] });
130
+ continue;
131
+ }
132
+ const path = ["ai", "agents", agent.id];
133
+ pushTarget(targets, diagnostics, {
134
+ moduleId,
135
+ domain: "ai",
136
+ path,
137
+ key: agent.id,
138
+ dottedHost: "ai.agents",
139
+ factRef: { factSection: "aiAgents", factKey: agent.id },
140
+ source: { sourcePath: agent.sourcePath }
141
+ });
142
+ }
143
+ for (const tool of facts.aiTools) {
144
+ if (!tool.sourcePath) {
145
+ diagnostics.push({ code: "missing-source", moduleId, domain: "ai", candidatePath: ["ai", "tools", tool.name] });
146
+ continue;
147
+ }
148
+ const path = ["ai", "tools", tool.name];
149
+ pushTarget(targets, diagnostics, {
150
+ moduleId,
151
+ domain: "ai",
152
+ path,
153
+ key: tool.name,
154
+ dottedHost: "ai.tools",
155
+ factRef: { factSection: "aiTools", factKey: tool.name },
156
+ source: { sourcePath: tool.sourcePath }
157
+ });
158
+ }
159
+ const aiFileContracts = facts.ownedContracts?.["ai-extension"] ?? [];
160
+ const additiveExtensions = [];
161
+ for (const fact of aiFileContracts) {
162
+ const metadata = fact.metadata ?? {};
163
+ if (metadata.mode !== "override") {
164
+ additiveExtensions.push(fact);
165
+ continue;
166
+ }
167
+ const overrideKey = typeof metadata.overrideKey === "string" ? metadata.overrideKey : null;
168
+ const target = metadata.target === "agent" ? "agents" : metadata.target === "tool" ? "tools" : null;
169
+ if (!overrideKey || !target) {
170
+ diagnostics.push({
171
+ code: "unsupported-dynamic-key",
172
+ moduleId,
173
+ domain: "ai",
174
+ candidatePath: ["ai", target ?? "extensions"],
175
+ source: ownedSource(fact)
176
+ });
177
+ continue;
178
+ }
179
+ const path = ["ai", target, overrideKey];
180
+ pushTarget(targets, diagnostics, {
181
+ moduleId,
182
+ domain: "ai",
183
+ path,
184
+ key: overrideKey,
185
+ dottedHost: `ai.${target}`,
186
+ factRef: { factSection: "ownedContracts.ai-extension", factKey: fact.id },
187
+ source: ownedSource(fact)
188
+ });
189
+ }
190
+ if (additiveExtensions.length > 0) {
191
+ const anchor = [...additiveExtensions].sort((left, right) => left.id.localeCompare(right.id))[0];
192
+ pushTarget(targets, diagnostics, {
193
+ moduleId,
194
+ domain: "ai",
195
+ path: ["ai", "extensions"],
196
+ dottedHost: "ai.extensions",
197
+ factRef: { factSection: "ownedContracts.ai-extension", factKey: anchor.id },
198
+ source: ownedSource(anchor)
199
+ });
200
+ }
201
+ return { targets, diagnostics };
202
+ }
203
+ };
204
+ const routesAdapter = {
205
+ domain: "routes",
206
+ run(facts) {
207
+ const moduleId = moduleIdOf(facts);
208
+ const targets = [];
209
+ const diagnostics = [];
210
+ for (const route of facts.apiRoutes) {
211
+ for (const method of route.methods) {
212
+ const key = apiRouteOverrideKey(method, route.path);
213
+ if (!key) {
214
+ diagnostics.push({ code: "unsupported-dynamic-key", moduleId, domain: "routes", candidatePath: ["routes", "api", `${method} ${route.path}`] });
215
+ continue;
216
+ }
217
+ if (!route.sourcePath) {
218
+ diagnostics.push({ code: "missing-source", moduleId, domain: "routes", candidatePath: ["routes", "api", key] });
219
+ continue;
220
+ }
221
+ const path = ["routes", "api", key];
222
+ pushTarget(targets, diagnostics, {
223
+ moduleId,
224
+ domain: "routes",
225
+ path,
226
+ key,
227
+ dottedHost: "routes.api",
228
+ factRef: { factSection: "apiRoutes", factKey: route.path },
229
+ source: { sourcePath: route.sourcePath }
230
+ });
231
+ }
232
+ }
233
+ const emitPage = (page, section) => {
234
+ const key = pageRouteOverrideKey(page.path);
235
+ if (!key) {
236
+ diagnostics.push({ code: "unsupported-dynamic-key", moduleId, domain: "routes", candidatePath: ["routes", "pages", page.path] });
237
+ return;
238
+ }
239
+ if (!page.sourcePath) {
240
+ diagnostics.push({ code: "missing-source", moduleId, domain: "routes", candidatePath: ["routes", "pages", key] });
241
+ return;
242
+ }
243
+ const path = ["routes", "pages", key];
244
+ pushTarget(targets, diagnostics, {
245
+ moduleId,
246
+ domain: "routes",
247
+ path,
248
+ key,
249
+ dottedHost: "routes.pages",
250
+ factRef: { factSection: section, factKey: page.path },
251
+ source: { sourcePath: page.sourcePath }
252
+ });
253
+ };
254
+ for (const page of facts.backendPages) emitPage(page, "backendPages");
255
+ for (const page of facts.frontendPages) emitPage(page, "frontendPages");
256
+ return { targets, diagnostics };
257
+ }
258
+ };
259
+ const eventsAdapter = {
260
+ domain: "events",
261
+ run(facts) {
262
+ const moduleId = moduleIdOf(facts);
263
+ const targets = [];
264
+ const diagnostics = [];
265
+ for (const contribution of contributionsOfKind(facts, "subscriber")) {
266
+ const subscriberId = contribution.details.subscriberId || contribution.id;
267
+ const path = ["events", "subscribers", subscriberId];
268
+ if (!contribution.source.path) {
269
+ diagnostics.push({ code: "missing-source", moduleId, domain: "events", candidatePath: path });
270
+ continue;
271
+ }
272
+ pushTarget(targets, diagnostics, {
273
+ moduleId,
274
+ domain: "events",
275
+ path,
276
+ key: subscriberId,
277
+ dottedHost: "events.subscribers",
278
+ factRef: { factSection: "extensionSurfaces.contributions", factKey: contribution.id },
279
+ source: contributionSource(contribution)
280
+ });
281
+ }
282
+ return { targets, diagnostics };
283
+ }
284
+ };
285
+ const workersAdapter = {
286
+ domain: "workers",
287
+ run(facts) {
288
+ const moduleId = moduleIdOf(facts);
289
+ const targets = [];
290
+ const diagnostics = [];
291
+ for (const fact of facts.ownedContracts?.worker ?? []) {
292
+ const path = ["workers", fact.id];
293
+ if (!fact.source.sourcePath) {
294
+ diagnostics.push({ code: "missing-source", moduleId, domain: "workers", candidatePath: path });
295
+ continue;
296
+ }
297
+ pushTarget(targets, diagnostics, {
298
+ moduleId,
299
+ domain: "workers",
300
+ path,
301
+ key: fact.id,
302
+ dottedHost: "workers",
303
+ factRef: { factSection: "ownedContracts.worker", factKey: fact.id },
304
+ source: ownedSource(fact)
305
+ });
306
+ }
307
+ return { targets, diagnostics };
308
+ }
309
+ };
310
+ const widgetsAdapter = {
311
+ domain: "widgets",
312
+ run(facts) {
313
+ const moduleId = moduleIdOf(facts);
314
+ const targets = [];
315
+ const diagnostics = [];
316
+ const emitInjection = (registryKey, contribution) => {
317
+ const path = ["widgets", "injection", registryKey];
318
+ pushTarget(targets, diagnostics, {
319
+ moduleId,
320
+ domain: "widgets",
321
+ path,
322
+ key: registryKey,
323
+ dottedHost: "widgets.injection",
324
+ factRef: { factSection: "extensionSurfaces.contributions", factKey: contribution.id },
325
+ source: contributionSource(contribution)
326
+ });
327
+ };
328
+ for (const contribution of contributionsOfKind(facts, "widget")) {
329
+ const registryKey = contribution.details.registryKey;
330
+ if (!registryKey) {
331
+ diagnostics.push({ code: "unsupported-dynamic-key", moduleId, domain: "widgets", candidatePath: ["widgets", "injection", contribution.id] });
332
+ continue;
333
+ }
334
+ if (contribution.details.payload === "dashboard") {
335
+ const path = ["widgets", "dashboard", registryKey];
336
+ pushTarget(targets, diagnostics, {
337
+ moduleId,
338
+ domain: "widgets",
339
+ path,
340
+ key: registryKey,
341
+ dottedHost: "widgets.dashboard",
342
+ factRef: { factSection: "extensionSurfaces.contributions", factKey: contribution.id },
343
+ source: contributionSource(contribution)
344
+ });
345
+ } else {
346
+ emitInjection(registryKey, contribution);
347
+ }
348
+ }
349
+ for (const contribution of [
350
+ ...contributionsOfKind(facts, "data-table"),
351
+ ...contributionsOfKind(facts, "crud-form")
352
+ ]) {
353
+ const registryKey = contribution.id.split("@")[0];
354
+ if (!registryKey || registryKey === contribution.id) {
355
+ diagnostics.push({ code: "unsupported-dynamic-key", moduleId, domain: "widgets", candidatePath: ["widgets", "injection", contribution.id] });
356
+ continue;
357
+ }
358
+ emitInjection(registryKey, contribution);
359
+ }
360
+ for (const contribution of contributionsOfKind(facts, "component-override")) {
361
+ const componentId = contribution.details.handle;
362
+ const path = ["widgets", "components", componentId];
363
+ pushTarget(targets, diagnostics, {
364
+ moduleId,
365
+ domain: "widgets",
366
+ path,
367
+ key: componentId,
368
+ dottedHost: "widgets.components",
369
+ factRef: { factSection: "extensionSurfaces.contributions", factKey: contribution.id },
370
+ source: contributionSource(contribution)
371
+ });
372
+ }
373
+ return { targets, diagnostics };
374
+ }
375
+ };
376
+ const notificationsAdapter = {
377
+ domain: "notifications",
378
+ run(facts, resolveFactSource) {
379
+ const moduleId = moduleIdOf(facts);
380
+ const targets = [];
381
+ const diagnostics = [];
382
+ const registrySources = /* @__PURE__ */ new Map();
383
+ for (const contribution of contributionsOfKind(facts, "specialized-registry")) {
384
+ if (contribution.details.registry !== "notification") continue;
385
+ registrySources.set(contribution.details.registryId, contributionSource(contribution));
386
+ }
387
+ for (const type of facts.notifications) {
388
+ const path = ["notifications", "types", type];
389
+ const indexedPath = indexedFactSourcePath(resolveFactSource, "notification", type);
390
+ const source = registrySources.get(type) ?? (indexedPath ? { sourcePath: indexedPath } : null);
391
+ if (!source) {
392
+ diagnostics.push({ code: "missing-source", moduleId, domain: "notifications", candidatePath: path });
393
+ continue;
394
+ }
395
+ pushTarget(targets, diagnostics, {
396
+ moduleId,
397
+ domain: "notifications",
398
+ path,
399
+ key: type,
400
+ dottedHost: "notifications.types",
401
+ factRef: { factSection: "notifications", factKey: type },
402
+ source
403
+ });
404
+ }
405
+ for (const contribution of contributionsOfKind(facts, "browser-reaction")) {
406
+ if (!contribution.details.transports.includes("notification-effect")) continue;
407
+ const overrideKey = contribution.details.overrideKey;
408
+ if (!overrideKey) {
409
+ diagnostics.push({
410
+ code: "unsupported-dynamic-key",
411
+ moduleId,
412
+ domain: "notifications",
413
+ candidatePath: ["notifications", "handlers"],
414
+ source: contributionSource(contribution)
415
+ });
416
+ continue;
417
+ }
418
+ pushTarget(targets, diagnostics, {
419
+ moduleId,
420
+ domain: "notifications",
421
+ path: ["notifications", "handlers", overrideKey],
422
+ key: overrideKey,
423
+ dottedHost: "notifications.handlers",
424
+ factRef: { factSection: "extensionSurfaces.contributions", factKey: contribution.id },
425
+ source: contributionSource(contribution)
426
+ });
427
+ }
428
+ return { targets, diagnostics };
429
+ }
430
+ };
431
+ function contributionIdAdapter(domain, kind, dottedHost) {
432
+ return {
433
+ domain,
434
+ run(facts) {
435
+ const moduleId = moduleIdOf(facts);
436
+ const targets = [];
437
+ const diagnostics = [];
438
+ for (const contribution of contributionsOfKind(facts, kind)) {
439
+ const path = [domain, contribution.id];
440
+ if (!contribution.source.path) {
441
+ diagnostics.push({ code: "missing-source", moduleId, domain, candidatePath: path });
442
+ continue;
443
+ }
444
+ pushTarget(targets, diagnostics, {
445
+ moduleId,
446
+ domain,
447
+ path,
448
+ key: contribution.id,
449
+ dottedHost,
450
+ factRef: { factSection: "extensionSurfaces.contributions", factKey: contribution.id },
451
+ source: contributionSource(contribution)
452
+ });
453
+ }
454
+ return { targets, diagnostics };
455
+ }
456
+ };
457
+ }
458
+ const interceptorsAdapter = contributionIdAdapter("interceptors", "api-interceptor", "interceptors");
459
+ const commandInterceptorsAdapter = contributionIdAdapter("commandInterceptors", "command-interceptor", "commandInterceptors");
460
+ const enrichersAdapter = contributionIdAdapter("enrichers", "response-enricher", "enrichers");
461
+ const guardsAdapter = {
462
+ domain: "guards",
463
+ run(facts) {
464
+ const moduleId = moduleIdOf(facts);
465
+ const targets = [];
466
+ const diagnostics = [];
467
+ for (const fact of facts.ownedContracts?.["page-middleware"] ?? []) {
468
+ const path = ["guards", fact.id];
469
+ if (!fact.source.sourcePath) {
470
+ diagnostics.push({ code: "missing-source", moduleId, domain: "guards", candidatePath: path });
471
+ continue;
472
+ }
473
+ pushTarget(targets, diagnostics, {
474
+ moduleId,
475
+ domain: "guards",
476
+ path,
477
+ key: fact.id,
478
+ dottedHost: "guards",
479
+ factRef: { factSection: "ownedContracts.page-middleware", factKey: fact.id },
480
+ source: ownedSource(fact),
481
+ notes: ["page-middleware-not-mutation-guard"]
482
+ });
483
+ }
484
+ return { targets, diagnostics };
485
+ }
486
+ };
487
+ const cliAdapter = {
488
+ domain: "cli",
489
+ run(facts) {
490
+ const moduleId = moduleIdOf(facts);
491
+ const targets = [];
492
+ const diagnostics = [];
493
+ for (const command of facts.cliCommands) {
494
+ const path = ["cli", command.command];
495
+ if (!command.sourcePath) {
496
+ diagnostics.push({ code: "missing-source", moduleId, domain: "cli", candidatePath: path });
497
+ continue;
498
+ }
499
+ pushTarget(targets, diagnostics, {
500
+ moduleId,
501
+ domain: "cli",
502
+ path,
503
+ key: command.command,
504
+ dottedHost: "cli",
505
+ factRef: { factSection: "cliCommands", factKey: command.command },
506
+ source: { sourcePath: command.sourcePath }
507
+ });
508
+ }
509
+ return { targets, diagnostics };
510
+ }
511
+ };
512
+ const SUPPORTED_SETUP_HOOKS = /* @__PURE__ */ new Set(["seedDefaults", "seedExamples", "onTenantCreated"]);
513
+ const setupAdapter = {
514
+ domain: "setup",
515
+ run(facts) {
516
+ const moduleId = moduleIdOf(facts);
517
+ const targets = [];
518
+ const diagnostics = [];
519
+ const setupFacts = facts.ownedContracts?.setup ?? [];
520
+ for (const fact of setupFacts) {
521
+ if (!fact.source.sourcePath) {
522
+ diagnostics.push({ code: "missing-source", moduleId, domain: "setup", candidatePath: ["setup"] });
523
+ continue;
524
+ }
525
+ const source = ownedSource(fact);
526
+ const properties = [];
527
+ const hooks = fact.metadata?.hooks;
528
+ if (Array.isArray(hooks)) {
529
+ for (const hook of hooks) {
530
+ if (typeof hook === "string" && SUPPORTED_SETUP_HOOKS.has(hook)) properties.push(hook);
531
+ }
532
+ }
533
+ const roles = fact.metadata?.roles;
534
+ if (Array.isArray(roles) && roles.length > 0) properties.push("defaultRoleFeatures");
535
+ const customerRoles = fact.metadata?.customerRoles;
536
+ if (Array.isArray(customerRoles) && customerRoles.length > 0) properties.push("defaultCustomerRoleFeatures");
537
+ for (const property of properties) {
538
+ const path = ["setup", property];
539
+ pushTarget(targets, diagnostics, {
540
+ moduleId,
541
+ domain: "setup",
542
+ path,
543
+ dottedHost: "setup",
544
+ factRef: { factSection: "ownedContracts.setup", factKey: fact.id },
545
+ source
546
+ });
547
+ }
548
+ }
549
+ return { targets, diagnostics };
550
+ }
551
+ };
552
+ const aclAdapter = {
553
+ domain: "acl",
554
+ run(facts, resolveFactSource) {
555
+ const moduleId = moduleIdOf(facts);
556
+ const targets = [];
557
+ const diagnostics = [];
558
+ for (const feature of facts.aclFeatures) {
559
+ const path = ["acl", "features", feature];
560
+ const sourcePath = indexedFactSourcePath(resolveFactSource, "acl-feature", feature);
561
+ if (!sourcePath) {
562
+ diagnostics.push({ code: "missing-source", moduleId, domain: "acl", candidatePath: path });
563
+ continue;
564
+ }
565
+ pushTarget(targets, diagnostics, {
566
+ moduleId,
567
+ domain: "acl",
568
+ path,
569
+ key: feature,
570
+ dottedHost: "acl.features",
571
+ factRef: { factSection: "aclFeatures", factKey: feature },
572
+ source: { sourcePath }
573
+ });
574
+ }
575
+ return { targets, diagnostics };
576
+ }
577
+ };
578
+ const diAdapter = {
579
+ domain: "di",
580
+ run(facts) {
581
+ const moduleId = moduleIdOf(facts);
582
+ const targets = [];
583
+ const diagnostics = [];
584
+ for (const fact of facts.ownedContracts?.["di-registration"] ?? []) {
585
+ const path = ["di", fact.id];
586
+ if (!fact.source.sourcePath) {
587
+ diagnostics.push({ code: "missing-source", moduleId, domain: "di", candidatePath: path });
588
+ continue;
589
+ }
590
+ pushTarget(targets, diagnostics, {
591
+ moduleId,
592
+ domain: "di",
593
+ path,
594
+ key: fact.id,
595
+ dottedHost: "di",
596
+ factRef: { factSection: "ownedContracts.di-registration", factKey: fact.id },
597
+ source: ownedSource(fact),
598
+ notes: ["safe-metadata-only"]
599
+ });
600
+ }
601
+ return { targets, diagnostics };
602
+ }
603
+ };
604
+ const encryptionAdapter = {
605
+ domain: "encryption",
606
+ run(facts) {
607
+ const moduleId = moduleIdOf(facts);
608
+ const targets = [];
609
+ const diagnostics = [];
610
+ for (const fact of facts.ownedContracts?.encryption ?? []) {
611
+ const path = ["encryption", "maps", fact.id];
612
+ if (!fact.source.sourcePath) {
613
+ diagnostics.push({ code: "missing-source", moduleId, domain: "encryption", candidatePath: path });
614
+ continue;
615
+ }
616
+ pushTarget(targets, diagnostics, {
617
+ moduleId,
618
+ domain: "encryption",
619
+ path,
620
+ key: fact.id,
621
+ dottedHost: "encryption.maps",
622
+ factRef: { factSection: "ownedContracts.encryption", factKey: fact.id },
623
+ source: ownedSource(fact)
624
+ });
625
+ }
626
+ return { targets, diagnostics };
627
+ }
628
+ };
629
+ const navAdapter = {
630
+ domain: "nav",
631
+ frameworkOnly: true,
632
+ run() {
633
+ return { targets: [], diagnostics: [] };
634
+ }
635
+ };
636
+ const INTERNAL_ADAPTERS = [
637
+ aiAdapter,
638
+ routesAdapter,
639
+ eventsAdapter,
640
+ workersAdapter,
641
+ widgetsAdapter,
642
+ notificationsAdapter,
643
+ interceptorsAdapter,
644
+ commandInterceptorsAdapter,
645
+ enrichersAdapter,
646
+ guardsAdapter,
647
+ cliAdapter,
648
+ setupAdapter,
649
+ aclAdapter,
650
+ diAdapter,
651
+ encryptionAdapter,
652
+ navAdapter
653
+ ];
654
+ const OVERRIDE_DOMAIN_PRESENCE = {
655
+ ai: true,
656
+ routes: true,
657
+ events: true,
658
+ workers: true,
659
+ widgets: true,
660
+ notifications: true,
661
+ interceptors: true,
662
+ commandInterceptors: true,
663
+ enrichers: true,
664
+ guards: true,
665
+ cli: true,
666
+ setup: true,
667
+ acl: true,
668
+ di: true,
669
+ encryption: true,
670
+ nav: true
671
+ };
672
+ const ALL_OVERRIDE_DOMAINS = Object.keys(OVERRIDE_DOMAIN_PRESENCE);
673
+ const MODULE_OVERRIDE_TARGET_ADAPTERS = INTERNAL_ADAPTERS.map((adapter) => ({
674
+ domain: adapter.domain,
675
+ ...adapter.frameworkOnly ? { frameworkOnly: true } : {},
676
+ collect: (moduleFacts) => adapter.run(moduleFacts, buildFactSourceLookup(moduleFacts)).targets,
677
+ diagnose: (moduleFacts) => adapter.run(moduleFacts, buildFactSourceLookup(moduleFacts)).diagnostics
678
+ }));
679
+ function collectModuleOverrideTargets(facts, resolveFactSource = buildFactSourceLookup(facts)) {
680
+ const collected = [];
681
+ const diagnostics = [];
682
+ for (const adapter of INTERNAL_ADAPTERS) {
683
+ if (adapter.frameworkOnly) continue;
684
+ const result = adapter.run(facts, resolveFactSource);
685
+ collected.push(...result.targets);
686
+ diagnostics.push(...result.diagnostics);
687
+ }
688
+ const byPath = /* @__PURE__ */ new Map();
689
+ for (const target of collected) {
690
+ const pathKey = `${target.domain} ${JSON.stringify(target.path)}`;
691
+ const existing = byPath.get(pathKey);
692
+ if (!existing || compareSourceRefs(target.source, existing.source) < 0) byPath.set(pathKey, target);
693
+ }
694
+ const overrideTargets = [...byPath.values()].sort(
695
+ (left, right) => left.domain.localeCompare(right.domain) || comparePaths(left.path, right.path) || compareSourceRefs(left.source, right.source)
696
+ );
697
+ const overrideTargetDiagnostics = diagnostics.sort(
698
+ (left, right) => left.moduleId.localeCompare(right.moduleId) || left.domain.localeCompare(right.domain) || left.code.localeCompare(right.code) || comparePaths(left.candidatePath ?? [], right.candidatePath ?? []) || compareSourceRefs(left.source ?? { sourcePath: "" }, right.source ?? { sourcePath: "" })
699
+ );
700
+ return { overrideTargets, overrideTargetDiagnostics };
701
+ }
702
+ export {
703
+ ALL_OVERRIDE_DOMAINS,
704
+ MODULE_OVERRIDE_MODES,
705
+ MODULE_OVERRIDE_TARGET_ADAPTERS,
706
+ MODULE_OVERRIDE_TARGET_DIAGNOSTIC_CODES,
707
+ MODULE_OVERRIDE_TARGET_NOTES,
708
+ collectModuleOverrideTargets,
709
+ computeOverrideTargetId,
710
+ resolveFrameworkOverrideModes
711
+ };
712
+ //# sourceMappingURL=module-override-targets.js.map