@open-mercato/cli 0.6.7-develop.6863.1.61001cf9a8 → 0.6.7

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 (278) hide show
  1. package/.turbo/turbo-build.log +4 -4
  2. package/build.mjs +7 -24
  3. package/dist/agentic/claude-code/hooks/entity-migration-check.ts +88 -32
  4. package/dist/agentic/codex/enforcement-rules.md +16 -2
  5. package/dist/agentic/cursor/hooks/entity-migration-check.mjs +50 -19
  6. package/dist/agentic/cursor/rules/entity-guard.mdc +21 -9
  7. package/dist/agentic/cursor/rules/generated-guard.mdc +5 -3
  8. package/dist/agentic/cursor/rules/open-mercato.mdc +29 -3
  9. package/dist/agentic/guides/cache.md +45 -0
  10. package/dist/agentic/guides/core.md +453 -0
  11. package/dist/agentic/guides/events.md +117 -0
  12. package/dist/agentic/guides/module-facts.json +3833 -115419
  13. package/dist/agentic/guides/module-system.md +127 -12
  14. package/dist/agentic/guides/modules/ai_assistant.md +28 -227
  15. package/dist/agentic/guides/modules/api_docs.md +2 -58
  16. package/dist/agentic/guides/modules/api_keys.md +7 -92
  17. package/dist/agentic/guides/modules/attachments.md +14 -119
  18. package/dist/agentic/guides/modules/audit_logs.md +10 -131
  19. package/dist/agentic/guides/modules/auth.md +33 -276
  20. package/dist/agentic/guides/modules/business_rules.md +14 -149
  21. package/dist/agentic/guides/modules/catalog.md +43 -475
  22. package/dist/agentic/guides/modules/channel_gmail.md +3 -82
  23. package/dist/agentic/guides/modules/channel_imap.md +3 -82
  24. package/dist/agentic/guides/modules/checkout.md +27 -299
  25. package/dist/agentic/guides/modules/communication_channels.md +33 -315
  26. package/dist/agentic/guides/modules/configs.md +8 -104
  27. package/dist/agentic/guides/modules/content.md +2 -57
  28. package/dist/agentic/guides/modules/currencies.md +17 -152
  29. package/dist/agentic/guides/modules/customer_accounts.md +45 -387
  30. package/dist/agentic/guides/modules/customers.md +85 -746
  31. package/dist/agentic/guides/modules/dashboards.md +10 -155
  32. package/dist/agentic/guides/modules/data_sync.md +16 -149
  33. package/dist/agentic/guides/modules/dictionaries.md +12 -107
  34. package/dist/agentic/guides/modules/directory.md +15 -148
  35. package/dist/agentic/guides/modules/entities.md +13 -145
  36. package/dist/agentic/guides/modules/events.md +2 -59
  37. package/dist/agentic/guides/modules/feature_toggles.md +9 -119
  38. package/dist/agentic/guides/modules/gateway_stripe.md +4 -92
  39. package/dist/agentic/guides/modules/generators.md +2 -45
  40. package/dist/agentic/guides/modules/inbox_ops.md +27 -207
  41. package/dist/agentic/guides/modules/integrations.md +16 -146
  42. package/dist/agentic/guides/modules/messages.md +24 -223
  43. package/dist/agentic/guides/modules/notifications.md +8 -96
  44. package/dist/agentic/guides/modules/onboarding.md +6 -77
  45. package/dist/agentic/guides/modules/payment_gateways.md +21 -164
  46. package/dist/agentic/guides/modules/perspectives.md +7 -77
  47. package/dist/agentic/guides/modules/planner.md +18 -136
  48. package/dist/agentic/guides/modules/portal.md +2 -93
  49. package/dist/agentic/guides/modules/progress.md +14 -104
  50. package/dist/agentic/guides/modules/query_index.md +15 -154
  51. package/dist/agentic/guides/modules/record_locks.md +21 -206
  52. package/dist/agentic/guides/modules/resources.md +30 -197
  53. package/dist/agentic/guides/modules/sales.md +84 -678
  54. package/dist/agentic/guides/modules/scheduler.md +14 -133
  55. package/dist/agentic/guides/modules/search.md +6 -170
  56. package/dist/agentic/guides/modules/security.md +35 -294
  57. package/dist/agentic/guides/modules/shipping_carriers.md +18 -134
  58. package/dist/agentic/guides/modules/sso.md +26 -151
  59. package/dist/agentic/guides/modules/staff.md +57 -369
  60. package/dist/agentic/guides/modules/storage_s3.md +5 -95
  61. package/dist/agentic/guides/modules/sync_akeneo.md +3 -85
  62. package/dist/agentic/guides/modules/sync_excel.md +6 -75
  63. package/dist/agentic/guides/modules/system_status_overlays.md +2 -60
  64. package/dist/agentic/guides/modules/translations.md +10 -104
  65. package/dist/agentic/guides/modules/webhooks.md +24 -203
  66. package/dist/agentic/guides/modules/wms.md +46 -441
  67. package/dist/agentic/guides/modules/workflows.md +43 -302
  68. package/dist/agentic/guides/queue.md +53 -0
  69. package/dist/agentic/guides/search.md +115 -0
  70. package/dist/agentic/guides/shared.md +108 -0
  71. package/dist/agentic/guides/ui.md +347 -0
  72. package/dist/agentic/shared/AGENTS.md.template +311 -124
  73. package/dist/agentic/shared/ai/agentic.config.json +0 -2
  74. package/dist/agentic/shared/ai/lessons.md +3 -26
  75. package/dist/agentic/shared/ai/skills/om-auto-continue-pr-loop/SKILL.md +27 -0
  76. package/dist/agentic/shared/ai/skills/om-auto-create-pr-loop/SKILL.md +27 -0
  77. package/dist/agentic/shared/ai/skills/om-auto-review-pr/SKILL.md +0 -4
  78. package/dist/agentic/shared/ai/skills/om-backend-ui-design/SKILL.md +241 -20
  79. package/dist/agentic/shared/ai/skills/om-backend-ui-design/references/ui-components.md +260 -0
  80. package/dist/agentic/shared/ai/skills/om-data-model-design/SKILL.md +601 -16
  81. package/dist/agentic/shared/ai/skills/om-data-model-design/references/mikro-orm-cheatsheet.md +146 -0
  82. package/dist/agentic/shared/ai/skills/om-eject-and-customize/SKILL.md +310 -14
  83. package/dist/agentic/shared/ai/skills/om-help/SKILL.md +97 -15
  84. package/dist/agentic/shared/ai/skills/om-help/references/skills-catalog.md +84 -0
  85. package/dist/agentic/shared/ai/skills/om-help/references/workflow-sequences.md +193 -0
  86. package/dist/agentic/shared/ai/skills/om-implement-spec/SKILL.md +152 -33
  87. package/dist/agentic/shared/ai/skills/om-integration-builder/SKILL.md +708 -24
  88. package/dist/agentic/shared/ai/skills/om-integration-builder/STANDALONE.md +34 -0
  89. package/dist/agentic/shared/ai/skills/om-integration-builder/references/adapter-contracts.md +762 -0
  90. package/dist/agentic/shared/ai/skills/om-module-scaffold/SKILL.md +820 -20
  91. package/dist/agentic/shared/ai/skills/om-module-scaffold/references/naming-conventions.md +50 -0
  92. package/dist/agentic/shared/ai/skills/om-module-scaffold/references/navigation-patterns.md +97 -0
  93. package/dist/agentic/shared/ai/skills/om-system-extension/SKILL.md +843 -19
  94. package/dist/agentic/shared/ai/skills/om-system-extension/references/extension-contracts.md +271 -0
  95. package/dist/agentic/shared/ai/skills/om-trim-unused-modules/SKILL.md +63 -15
  96. package/dist/agentic/shared/ai/skills/om-troubleshooter/SKILL.md +467 -16
  97. package/dist/agentic/shared/ai/skills/om-troubleshooter/references/diagnostic-commands.md +101 -0
  98. package/dist/agentic/shared/ai/skills/tiers.json +21 -143
  99. package/dist/agentic/shared/ai/skills/tiers.schema.json +40 -52
  100. package/dist/agentic/shared/ai/specs/README.md +3 -4
  101. package/dist/agentic/shared/ai/specs/SPEC-000-template.md +10 -226
  102. package/dist/agentic/shared/ai/trackers/github.md +4 -108
  103. package/dist/agentic/shared/scripts/install-skills.sh +694 -4
  104. package/dist/bin.js +1 -13
  105. package/dist/bin.js.map +2 -2
  106. package/dist/lib/__integration__/TC-INT-008.spec.js +8 -88
  107. package/dist/lib/__integration__/TC-INT-008.spec.js.map +2 -2
  108. package/dist/lib/agentic-init.js +3 -13
  109. package/dist/lib/agentic-init.js.map +2 -2
  110. package/dist/lib/agentic-setup.js +186 -418
  111. package/dist/lib/agentic-setup.js.map +2 -2
  112. package/dist/lib/generators/extensions/injection-widgets.js +0 -20
  113. package/dist/lib/generators/extensions/injection-widgets.js.map +2 -2
  114. package/dist/lib/generators/module-facts-discovery.js +7 -41
  115. package/dist/lib/generators/module-facts-discovery.js.map +2 -2
  116. package/dist/lib/generators/module-facts.js +45 -1387
  117. package/dist/lib/generators/module-facts.js.map +3 -3
  118. package/dist/lib/generators/module-registry.js +5 -11
  119. package/dist/lib/generators/module-registry.js.map +2 -2
  120. package/dist/lib/resolver.js +0 -2
  121. package/dist/lib/resolver.js.map +2 -2
  122. package/dist/lib/testing/integration.js +0 -5
  123. package/dist/lib/testing/integration.js.map +2 -2
  124. package/dist/mercato.js +1 -23
  125. package/dist/mercato.js.map +2 -2
  126. package/package.json +11 -13
  127. package/src/bin.ts +1 -33
  128. package/src/lib/__integration__/TC-INT-008.spec.ts +9 -107
  129. package/src/lib/__tests__/agentic-init.test.ts +5 -41
  130. package/src/lib/agentic-init.ts +3 -15
  131. package/src/lib/agentic-setup.ts +224 -530
  132. package/src/lib/generators/__tests__/module-facts.bc-guard.test.ts +2 -88
  133. package/src/lib/generators/__tests__/module-facts.customers.fixture.test.ts +0 -1
  134. package/src/lib/generators/__tests__/module-facts.discovery.test.ts +10 -54
  135. package/src/lib/generators/__tests__/module-subset.test.ts +0 -18
  136. package/src/lib/generators/extensions/injection-widgets.ts +0 -51
  137. package/src/lib/generators/module-facts-discovery.ts +7 -58
  138. package/src/lib/generators/module-facts.ts +46 -1851
  139. package/src/lib/generators/module-registry.ts +6 -16
  140. package/src/lib/resolver.ts +0 -3
  141. package/src/lib/testing/__tests__/integration.test.ts +0 -4
  142. package/src/lib/testing/integration.ts +0 -5
  143. package/src/mercato.ts +1 -26
  144. package/dist/agentic/guides/ai-workflows.md +0 -76
  145. package/dist/agentic/guides/architecture.md +0 -107
  146. package/dist/agentic/guides/backend-ui.md +0 -80
  147. package/dist/agentic/guides/contracts.md +0 -92
  148. package/dist/agentic/guides/extensions.md +0 -121
  149. package/dist/agentic/guides/framework-extension-points.md +0 -36
  150. package/dist/agentic/guides/integrations.md +0 -81
  151. package/dist/agentic/guides/modules/design_system.md +0 -102
  152. package/dist/agentic/guides/spec-delivery.md +0 -22
  153. package/dist/agentic/guides/testing-debugging.md +0 -80
  154. package/dist/agentic/guides/upstream/AGENTS.md +0 -298
  155. package/dist/agentic/guides/upstream/BACKWARD_COMPATIBILITY.md +0 -316
  156. package/dist/agentic/guides/upstream/manifest.json +0 -8
  157. package/dist/agentic/shared/ai/harness/README.md +0 -50
  158. package/dist/agentic/shared/ai/harness/RELEASE.md +0 -57
  159. package/dist/agentic/shared/ai/harness/cases.json +0 -13680
  160. package/dist/agentic/shared/ai/harness/cases.schema.json +0 -133
  161. package/dist/agentic/shared/ai/harness/fixtures/index.json +0 -49
  162. package/dist/agentic/shared/ai/harness/fixtures/seeds.json +0 -162
  163. package/dist/agentic/shared/ai/harness/generated-code-review-policy.md +0 -21
  164. package/dist/agentic/shared/ai/harness/generated-code-review-response.schema.json +0 -96
  165. package/dist/agentic/shared/ai/harness/generated-code-review-result.schema.json +0 -172
  166. package/dist/agentic/shared/ai/harness/release-matrix.json +0 -158
  167. package/dist/agentic/shared/ai/harness/release-result.schema.json +0 -219
  168. package/dist/agentic/shared/ai/harness/result.schema.json +0 -76
  169. package/dist/agentic/shared/ai/harness/routing-response.schema.json +0 -12
  170. package/dist/agentic/shared/ai/harness/target-validation-result.schema.json +0 -73
  171. package/dist/agentic/shared/ai/harness/validators.json +0 -78
  172. package/dist/agentic/shared/ai/harness/writable-ast-oracles.mjs +0 -2121
  173. package/dist/agentic/shared/ai/harness/writable-behavior-oracles.mjs +0 -1096
  174. package/dist/agentic/shared/ai/lessons/_template.md +0 -16
  175. package/dist/agentic/shared/ai/review-checklist.md +0 -36
  176. package/dist/agentic/shared/ai/skills/om-auto-implement-spec/SKILL.md +0 -21
  177. package/dist/agentic/shared/ai/skills/om-auto-upgrade-0.6.6-to-0.6.7/SKILL.md +0 -98
  178. package/dist/agentic/shared/ai/skills/om-backend-ui-design/references/crud-surfaces.md +0 -16
  179. package/dist/agentic/shared/ai/skills/om-backend-ui-design/references/frontend-and-design-system.md +0 -53
  180. package/dist/agentic/shared/ai/skills/om-backend-ui-design/references/page-and-navigation.md +0 -13
  181. package/dist/agentic/shared/ai/skills/om-backend-ui-design/references/quality-states.md +0 -11
  182. package/dist/agentic/shared/ai/skills/om-build-workflow/SKILL.md +0 -30
  183. package/dist/agentic/shared/ai/skills/om-build-workflow/references/activity-contracts.md +0 -12
  184. package/dist/agentic/shared/ai/skills/om-build-workflow/references/durability-and-progress.md +0 -13
  185. package/dist/agentic/shared/ai/skills/om-build-workflow/references/workflow-design.md +0 -14
  186. package/dist/agentic/shared/ai/skills/om-create-ai-agent/SKILL.md +0 -28
  187. package/dist/agentic/shared/ai/skills/om-create-ai-agent/references/attachments-and-overrides.md +0 -12
  188. package/dist/agentic/shared/ai/skills/om-create-ai-agent/references/module-agents-and-tools.md +0 -22
  189. package/dist/agentic/shared/ai/skills/om-create-ai-agent/references/orchestrator-agents.md +0 -12
  190. package/dist/agentic/shared/ai/skills/om-create-ai-agent/references/surface-selector.md +0 -19
  191. package/dist/agentic/shared/ai/skills/om-data-model-design/references/integrity-and-concurrency.md +0 -19
  192. package/dist/agentic/shared/ai/skills/om-data-model-design/references/migration-workflow.md +0 -13
  193. package/dist/agentic/shared/ai/skills/om-data-model-design/references/schema-design.md +0 -14
  194. package/dist/agentic/shared/ai/skills/om-data-model-design/references/sensitive-data.md +0 -10
  195. package/dist/agentic/shared/ai/skills/om-eject-and-customize/references/decision-and-procedure.md +0 -17
  196. package/dist/agentic/shared/ai/skills/om-evolve-harness/SKILL.md +0 -29
  197. package/dist/agentic/shared/ai/skills/om-evolve-harness/references/case-template.md +0 -100
  198. package/dist/agentic/shared/ai/skills/om-evolve-harness/references/case-workflow.md +0 -16
  199. package/dist/agentic/shared/ai/skills/om-evolve-harness/references/owner-selection.md +0 -17
  200. package/dist/agentic/shared/ai/skills/om-framework-context/SKILL.md +0 -25
  201. package/dist/agentic/shared/ai/skills/om-framework-context/references/resolver-procedure.md +0 -11
  202. package/dist/agentic/shared/ai/skills/om-framework-context/references/skew-and-escalation.md +0 -13
  203. package/dist/agentic/shared/ai/skills/om-help/references/delivery-workflows.md +0 -18
  204. package/dist/agentic/shared/ai/skills/om-help/references/task-families.md +0 -20
  205. package/dist/agentic/shared/ai/skills/om-implement-spec/references/phases-and-gates.md +0 -33
  206. package/dist/agentic/shared/ai/skills/om-implement-spec/references/planning-and-progress.md +0 -40
  207. package/dist/agentic/shared/ai/skills/om-implement-spec/references/report-templates.md +0 -27
  208. package/dist/agentic/shared/ai/skills/om-implement-spec/references/spec-resolution.md +0 -24
  209. package/dist/agentic/shared/ai/skills/om-integration-builder/references/package-and-activation.md +0 -16
  210. package/dist/agentic/shared/ai/skills/om-integration-builder/references/provider-families.md +0 -14
  211. package/dist/agentic/shared/ai/skills/om-integration-builder/references/security-and-reliability.md +0 -15
  212. package/dist/agentic/shared/ai/skills/om-integration-builder/references/sync-and-files.md +0 -12
  213. package/dist/agentic/shared/ai/skills/om-judge-agent-session/SKILL.md +0 -34
  214. package/dist/agentic/shared/ai/skills/om-judge-agent-session/agents/openai.yaml +0 -4
  215. package/dist/agentic/shared/ai/skills/om-judge-agent-session/references/agentic-setup.md +0 -11
  216. package/dist/agentic/shared/ai/skills/om-judge-agent-session/references/input-normalization.md +0 -31
  217. package/dist/agentic/shared/ai/skills/om-judge-agent-session/references/judge-workflow.md +0 -39
  218. package/dist/agentic/shared/ai/skills/om-judge-agent-session/references/report-template.md +0 -43
  219. package/dist/agentic/shared/ai/skills/om-judge-agent-session/references/rules.md +0 -11
  220. package/dist/agentic/shared/ai/skills/om-module-scaffold/references/api-and-domain.md +0 -19
  221. package/dist/agentic/shared/ai/skills/om-module-scaffold/references/business-one-shot-blueprints.md +0 -172
  222. package/dist/agentic/shared/ai/skills/om-module-scaffold/references/data-and-migrations.md +0 -12
  223. package/dist/agentic/shared/ai/skills/om-module-scaffold/references/discovery-surface-catalog.md +0 -83
  224. package/dist/agentic/shared/ai/skills/om-module-scaffold/references/module-surfaces.md +0 -21
  225. package/dist/agentic/shared/ai/skills/om-module-scaffold/references/planning.md +0 -11
  226. package/dist/agentic/shared/ai/skills/om-module-scaffold/references/runtime-cache-and-queues.md +0 -22
  227. package/dist/agentic/shared/ai/skills/om-module-scaffold/references/verification.md +0 -13
  228. package/dist/agentic/shared/ai/skills/om-share-this-session/SKILL.md +0 -41
  229. package/dist/agentic/shared/ai/skills/om-share-this-session/references/agentic-setup.md +0 -19
  230. package/dist/agentic/shared/ai/skills/om-share-this-session/references/bundle-preparation.md +0 -44
  231. package/dist/agentic/shared/ai/skills/om-share-this-session/references/consent-and-review.md +0 -39
  232. package/dist/agentic/shared/ai/skills/om-share-this-session/references/publication.md +0 -20
  233. package/dist/agentic/shared/ai/skills/om-share-this-session/references/report-templates.md +0 -57
  234. package/dist/agentic/shared/ai/skills/om-share-this-session/references/rules.md +0 -11
  235. package/dist/agentic/shared/ai/skills/om-share-this-session/scripts/prepare-share-bundle.mjs +0 -486
  236. package/dist/agentic/shared/ai/skills/om-system-extension/references/extension-branches.md +0 -18
  237. package/dist/agentic/shared/ai/skills/om-system-extension/references/mechanism-selector.md +0 -27
  238. package/dist/agentic/shared/ai/skills/om-system-extension/references/read-write-roundtrip.md +0 -13
  239. package/dist/agentic/shared/ai/skills/om-system-extension/references/unified-overrides.md +0 -41
  240. package/dist/agentic/shared/ai/skills/om-system-extension/references/verification.md +0 -11
  241. package/dist/agentic/shared/ai/skills/om-trim-unused-modules/references/dependency-and-redirect.md +0 -15
  242. package/dist/agentic/shared/ai/skills/om-troubleshooter/references/diagnosis-map.md +0 -16
  243. package/dist/agentic/shared/ai/skills/om-troubleshooter/references/regression-oracles.md +0 -14
  244. package/dist/agentic/shared/scripts/agent-harness-tool-server.mjs +0 -187
  245. package/dist/agentic/shared/scripts/check-lessons.mjs +0 -178
  246. package/dist/agentic/shared/scripts/evaluate-agent-harness.mjs +0 -2958
  247. package/dist/agentic/shared/scripts/execution-sandbox.mjs +0 -329
  248. package/dist/agentic/shared/scripts/framework-context.mjs +0 -888
  249. package/dist/agentic/shared/scripts/install-skills.mjs +0 -1029
  250. package/dist/agentic/shared/scripts/prepare-agent-harness-fixture.mjs +0 -222
  251. package/dist/agentic/shared/scripts/run-agent-harness-release.mjs +0 -1774
  252. package/dist/lib/generators/module-extension-facts.js +0 -1840
  253. package/dist/lib/generators/module-extension-facts.js.map +0 -7
  254. package/dist/lib/generators/module-fact-sources.js +0 -70
  255. package/dist/lib/generators/module-fact-sources.js.map +0 -7
  256. package/dist/lib/generators/module-override-targets.js +0 -688
  257. package/dist/lib/generators/module-override-targets.js.map +0 -7
  258. package/dist/lib/load-env.js +0 -24
  259. package/dist/lib/load-env.js.map +0 -7
  260. package/dist/lib/telemetry-init.js +0 -358
  261. package/dist/lib/telemetry-init.js.map +0 -7
  262. package/src/lib/__tests__/agentic-setup.ownership.test.ts +0 -386
  263. package/src/lib/__tests__/injection-widget-id-validation.test.ts +0 -184
  264. package/src/lib/__tests__/load-env.test.ts +0 -65
  265. package/src/lib/__tests__/telemetry-init.test.ts +0 -298
  266. package/src/lib/generators/__tests__/activation-adapter-coverage.test.ts +0 -92
  267. package/src/lib/generators/__tests__/module-extension-activations.test.ts +0 -762
  268. package/src/lib/generators/__tests__/module-extension-facts.test.ts +0 -404
  269. package/src/lib/generators/__tests__/module-facts.extension-hosts.test.ts +0 -108
  270. package/src/lib/generators/__tests__/module-facts.owned-contracts.test.ts +0 -561
  271. package/src/lib/generators/__tests__/module-facts.source-links.test.ts +0 -119
  272. package/src/lib/generators/__tests__/module-override-targets.roundtrip.test.ts +0 -149
  273. package/src/lib/generators/__tests__/module-override-targets.test.ts +0 -304
  274. package/src/lib/generators/module-extension-facts.ts +0 -2365
  275. package/src/lib/generators/module-fact-sources.ts +0 -108
  276. package/src/lib/generators/module-override-targets.ts +0 -863
  277. package/src/lib/load-env.ts +0 -30
  278. package/src/lib/telemetry-init.ts +0 -461
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/lib/generators/module-override-targets.ts"],
4
- "sourcesContent": ["import crypto from 'node:crypto'\nimport type { ModuleOverrideDomain } from '@open-mercato/shared/modules/overrides'\nimport type { ModuleExtensionContributionFact } from '@open-mercato/shared/modules/widgets/extension-points'\nimport type {\n ModuleFactRef,\n ModuleFactSourceKind,\n ModuleFactSourceRef,\n ModuleFactsJsonEntry,\n ModuleOwnedContractFact,\n} from './module-facts'\nimport { buildFactSourceLookup, type FactSourceLookup } from './module-fact-sources'\nimport { getFrameworkOverrideModes } from './module-extension-facts'\n\n/**\n * Exact module-specific unified override targets.\n *\n * Spec: `.ai/specs/2026-08-02-module-facts-exact-override-targets.md`.\n *\n * Projects every concrete key a downstream app can set under\n * `modules.<moduleId>.overrides.<domain>` from the normalized owned facts\n * (spec 1 provenance) and the extension-surface contributions (spec 2). Each\n * target carries the structured runtime `path`, the applicable framework mode,\n * a module-owned `factRef`, and a portable `source`. The framework catalog\n * (`framework-extension-points`) stays the authority for domains/modes; this\n * layer only emits the module's concrete keys. Framework-only settings such as\n * `nav.groupOrder` are never module targets.\n */\n\nexport type ModuleOverrideMode = 'disable-replace' | 'replace' | 'additive'\n\nexport type ModuleOverrideTargetNote =\n | 'safe-metadata-only'\n | 'page-middleware-not-mutation-guard'\n\nexport type ModuleOverrideTarget = {\n id: string\n domain: ModuleOverrideDomain\n key?: string\n path: string[]\n modes: ModuleOverrideMode[]\n factRef: ModuleFactRef\n source: ModuleFactSourceRef\n notes?: ModuleOverrideTargetNote[]\n}\n\nexport type ModuleOverrideTargetDiagnosticCode =\n | 'missing-owned-fact'\n | 'missing-source'\n | 'unsupported-dynamic-key'\n | 'unknown-framework-domain'\n\nexport type ModuleOverrideTargetDiagnostic = {\n code: ModuleOverrideTargetDiagnosticCode\n moduleId: string\n domain: ModuleOverrideDomain\n candidatePath?: string[]\n source?: ModuleFactSourceRef\n}\n\n/**\n * Public, spec-shaped adapter view. `collect` mirrors the spec's illustrative\n * signature (targets only); `diagnose` is the additive per-module diagnostic\n * companion. Every adapter is bound to exactly one top-level override domain,\n * or classified `frameworkOnly` (framework-catalog settings that never become\n * module targets, e.g. `nav`).\n */\nexport type OverrideTargetAdapter = {\n domain: ModuleOverrideDomain\n collect(moduleFacts: ModuleFactsJsonEntry): ModuleOverrideTarget[]\n diagnose(moduleFacts: ModuleFactsJsonEntry): ModuleOverrideTargetDiagnostic[]\n frameworkOnly?: boolean\n}\n\ntype AdapterResult = {\n targets: ModuleOverrideTarget[]\n diagnostics: ModuleOverrideTargetDiagnostic[]\n}\n\ntype InternalAdapter = {\n domain: ModuleOverrideDomain\n frameworkOnly?: boolean\n run(moduleFacts: ModuleFactsJsonEntry, resolveFactSource: FactSourceLookup): AdapterResult\n}\n\nconst OVERRIDE_MODES = getFrameworkOverrideModes()\n\n/**\n * Supported modes come from the framework catalog only. A host the catalog does not\n * describe is never guessed: the caller emits an `unknown-framework-domain`\n * diagnostic and no target, so a downstream app is not told a key is overridable in\n * a mode the runtime may not support.\n */\nfunction modesFor(dottedHost: string): ModuleOverrideMode[] | null {\n const mode = OVERRIDE_MODES[dottedHost]\n return mode ? [mode] : null\n}\n\n/**\n * The module id equals the last segment of the portable `sourceRoot`\n * (`node_modules/<pkg>/src/modules/<moduleId>`), which the provenance builder\n * derives from the module id itself, so this round-trips losslessly.\n */\nfunction moduleIdOf(facts: ModuleFactsJsonEntry): string {\n const segments = facts.sourceRoot.split('/').filter(Boolean)\n return segments[segments.length - 1] ?? ''\n}\n\n/**\n * Deterministic id derived from the JSON-serialized `[moduleId, domain, path]`\n * tuple so segment boundaries cannot collide. `path` remains the lossless\n * authority; this is a compact stable handle for consumers that key by id.\n */\nexport function computeOverrideTargetId(moduleId: string, domain: ModuleOverrideDomain, path: string[]): string {\n return crypto.createHash('sha1').update(JSON.stringify([moduleId, domain, path])).digest('hex').slice(0, 16)\n}\n\nfunction compareSourceRefs(left: ModuleFactSourceRef, right: ModuleFactSourceRef): number {\n return (\n left.sourcePath.localeCompare(right.sourcePath) ||\n (left.line ?? 0) - (right.line ?? 0) ||\n (left.exportName ?? '').localeCompare(right.exportName ?? '')\n )\n}\n\nfunction comparePaths(left: string[], right: string[]): number {\n const length = Math.max(left.length, right.length)\n for (let index = 0; index < length; index += 1) {\n const leftSegment = left[index]\n const rightSegment = right[index]\n if (leftSegment === undefined) return -1\n if (rightSegment === undefined) return 1\n const compared = leftSegment.localeCompare(rightSegment)\n if (compared !== 0) return compared\n }\n return 0\n}\n\ntype MakeTargetInput = {\n moduleId: string\n domain: ModuleOverrideDomain\n path: string[]\n dottedHost: string\n factRef: ModuleFactRef\n source: ModuleFactSourceRef\n key?: string\n notes?: ModuleOverrideTargetNote[]\n}\n\nfunction makeTarget(input: MakeTargetInput): ModuleOverrideTarget | null {\n const modes = modesFor(input.dottedHost)\n if (!modes) return null\n const target: ModuleOverrideTarget = {\n id: computeOverrideTargetId(input.moduleId, input.domain, input.path),\n domain: input.domain,\n ...(input.key !== undefined ? { key: input.key } : {}),\n path: input.path,\n modes,\n factRef: input.factRef,\n source: input.source,\n ...(input.notes && input.notes.length > 0 ? { notes: input.notes } : {}),\n }\n return target\n}\n\n/**\n * Emits the target, or an `unknown-framework-domain` diagnostic when the framework\n * catalog does not describe the target's dotted host.\n */\nfunction pushTarget(\n targets: ModuleOverrideTarget[],\n diagnostics: ModuleOverrideTargetDiagnostic[],\n input: MakeTargetInput,\n): void {\n const target = makeTarget(input)\n if (target) {\n targets.push(target)\n return\n }\n diagnostics.push({\n code: 'unknown-framework-domain',\n moduleId: input.moduleId,\n domain: input.domain,\n candidatePath: input.path,\n source: input.source,\n })\n}\n\n/** Portable contribution source ref \u2192 override target source ref. */\nfunction contributionSource(contribution: ModuleExtensionContributionFact): ModuleFactSourceRef {\n return {\n sourcePath: contribution.source.path,\n ...(contribution.source.symbol ? { exportName: contribution.source.symbol } : {}),\n }\n}\n\n/** Owned-contract source ref, dropping the (constant) exportName for compactness. */\nfunction ownedSource(fact: ModuleOwnedContractFact): ModuleFactSourceRef {\n return {\n sourcePath: fact.source.sourcePath,\n ...(fact.source.line ? { line: fact.source.line } : {}),\n }\n}\n\nfunction contributionsOfKind<K extends ModuleExtensionContributionFact['kind']>(\n facts: ModuleFactsJsonEntry,\n kind: K,\n): Array<Extract<ModuleExtensionContributionFact, { kind: K }>> {\n const contributions = facts.extensionSurfaces?.contributions ?? []\n return contributions.filter((contribution): contribution is Extract<ModuleExtensionContributionFact, { kind: K }> =>\n contribution.kind === kind,\n )\n}\n\nfunction indexedFactSourcePath(\n resolveFactSource: FactSourceLookup,\n kind: ModuleFactSourceKind,\n id: string,\n): string | null {\n return resolveFactSource(kind, id)?.sourcePath ?? null\n}\n\n// ---------------------------------------------------------------------------\n// Local canonical override-key normalizers.\n//\n// These MIRROR the private `normalizeApiRouteOverrideKey` /\n// `normalizePageRouteOverrideKey` in\n// `packages/shared/src/modules/overrides.ts` (not exported by that module).\n// Round-trip tests feed the emitted keys back through the exported runtime\n// appliers (`applyApiOverridesToManifests` / `applyPageOverridesToManifests`)\n// to prove equivalence. See the implementation report: exporting the shared\n// normalizers would let this file import rather than mirror them.\n// ---------------------------------------------------------------------------\n\nconst VALID_HTTP_METHODS = new Set(['GET', 'POST', 'PUT', 'PATCH', 'DELETE'])\n\n/**\n * Canonical `'METHOD /api/path'` public override key for a route method. Route\n * fact paths are stored without the `/api` prefix (e.g. `/customers/x`), so the\n * public key downstream apps write is `METHOD /api<path>`.\n */\nfunction apiRouteOverrideKey(method: string, routePath: string): string | null {\n const upper = method.trim().toUpperCase()\n if (!VALID_HTTP_METHODS.has(upper)) return null\n const withLead = routePath.startsWith('/') ? routePath : `/${routePath}`\n const publicPath = withLead.startsWith('/api/') || withLead === '/api' ? withLead : `/api${withLead}`\n const normalized = publicPath.replace(/\\/+$/, '') || '/'\n return `${upper} ${normalized}`\n}\n\nfunction pageRouteOverrideKey(routePath: string): string | null {\n const trimmed = routePath.trim()\n if (!trimmed) return null\n if (trimmed.startsWith('backend:') || trimmed.startsWith('frontend:')) return trimmed\n const withLead = trimmed.startsWith('/') ? trimmed : `/${trimmed}`\n const stripped = withLead.replace(/\\/+$/, '') || '/'\n if (stripped === '/frontend') return 'frontend:/'\n if (stripped.startsWith('/frontend/')) return `frontend:/${stripped.slice('/frontend/'.length)}`\n if (stripped === '/backend' || stripped.startsWith('/backend/')) return `backend:${stripped}`\n return `frontend:${stripped}`\n}\n\n// ---------------------------------------------------------------------------\n// Adapters (one per top-level override domain).\n// ---------------------------------------------------------------------------\n\nconst aiAdapter: InternalAdapter = {\n domain: 'ai',\n run(facts) {\n const moduleId = moduleIdOf(facts)\n const targets: ModuleOverrideTarget[] = []\n const diagnostics: ModuleOverrideTargetDiagnostic[] = []\n\n for (const agent of facts.aiAgents) {\n if (!agent.sourcePath) {\n diagnostics.push({ code: 'missing-source', moduleId, domain: 'ai', candidatePath: ['ai', 'agents', agent.id] })\n continue\n }\n const path = ['ai', 'agents', agent.id]\n pushTarget(targets, diagnostics, {\n moduleId, domain: 'ai', path, key: agent.id, dottedHost: 'ai.agents',\n factRef: { factSection: 'aiAgents', factKey: agent.id },\n source: { sourcePath: agent.sourcePath },\n })\n }\n for (const tool of facts.aiTools) {\n if (!tool.sourcePath) {\n diagnostics.push({ code: 'missing-source', moduleId, domain: 'ai', candidatePath: ['ai', 'tools', tool.name] })\n continue\n }\n const path = ['ai', 'tools', tool.name]\n pushTarget(targets, diagnostics, {\n moduleId, domain: 'ai', path, key: tool.name, dottedHost: 'ai.tools',\n factRef: { factSection: 'aiTools', factKey: tool.name },\n source: { sourcePath: tool.sourcePath },\n })\n }\n // AI file contracts split by mode: keyed `aiAgentOverrides` / `aiToolOverrides`\n // entries are exact `ai.agents.<id>` / `ai.tools.<id>` targets, while additive\n // `aiAgentExtensions` patches belong to the keyless `ai.extensions` array.\n const aiFileContracts = facts.ownedContracts?.['ai-extension'] ?? []\n const additiveExtensions: ModuleOwnedContractFact[] = []\n for (const fact of aiFileContracts) {\n const metadata = fact.metadata ?? {}\n if (metadata.mode !== 'override') {\n additiveExtensions.push(fact)\n continue\n }\n const overrideKey = typeof metadata.overrideKey === 'string' ? metadata.overrideKey : null\n const target = metadata.target === 'agent' ? 'agents' : metadata.target === 'tool' ? 'tools' : null\n if (!overrideKey || !target) {\n diagnostics.push({\n code: 'unsupported-dynamic-key',\n moduleId,\n domain: 'ai',\n candidatePath: ['ai', target ?? 'extensions'],\n source: ownedSource(fact),\n })\n continue\n }\n const path = ['ai', target, overrideKey]\n pushTarget(targets, diagnostics, {\n moduleId, domain: 'ai', path, key: overrideKey, dottedHost: `ai.${target}`,\n factRef: { factSection: 'ownedContracts.ai-extension', factKey: fact.id },\n source: ownedSource(fact),\n })\n }\n if (additiveExtensions.length > 0) {\n const anchor = [...additiveExtensions].sort((left, right) => left.id.localeCompare(right.id))[0]\n pushTarget(targets, diagnostics, {\n moduleId, domain: 'ai', path: ['ai', 'extensions'], dottedHost: 'ai.extensions',\n factRef: { factSection: 'ownedContracts.ai-extension', factKey: anchor.id },\n source: ownedSource(anchor),\n })\n }\n return { targets, diagnostics }\n },\n}\n\nconst routesAdapter: InternalAdapter = {\n domain: 'routes',\n run(facts) {\n const moduleId = moduleIdOf(facts)\n const targets: ModuleOverrideTarget[] = []\n const diagnostics: ModuleOverrideTargetDiagnostic[] = []\n\n for (const route of facts.apiRoutes) {\n for (const method of route.methods) {\n const key = apiRouteOverrideKey(method, route.path)\n if (!key) {\n diagnostics.push({ code: 'unsupported-dynamic-key', moduleId, domain: 'routes', candidatePath: ['routes', 'api', `${method} ${route.path}`] })\n continue\n }\n if (!route.sourcePath) {\n diagnostics.push({ code: 'missing-source', moduleId, domain: 'routes', candidatePath: ['routes', 'api', key] })\n continue\n }\n const path = ['routes', 'api', key]\n pushTarget(targets, diagnostics, {\n moduleId, domain: 'routes', path, key, dottedHost: 'routes.api',\n factRef: { factSection: 'apiRoutes', factKey: route.path },\n source: { sourcePath: route.sourcePath },\n })\n }\n }\n\n const emitPage = (page: { path: string; sourcePath: string }, section: 'backendPages' | 'frontendPages'): void => {\n const key = pageRouteOverrideKey(page.path)\n if (!key) {\n diagnostics.push({ code: 'unsupported-dynamic-key', moduleId, domain: 'routes', candidatePath: ['routes', 'pages', page.path] })\n return\n }\n if (!page.sourcePath) {\n diagnostics.push({ code: 'missing-source', moduleId, domain: 'routes', candidatePath: ['routes', 'pages', key] })\n return\n }\n const path = ['routes', 'pages', key]\n pushTarget(targets, diagnostics, {\n moduleId, domain: 'routes', path, key, dottedHost: 'routes.pages',\n factRef: { factSection: section, factKey: page.path },\n source: { sourcePath: page.sourcePath },\n })\n }\n for (const page of facts.backendPages) emitPage(page, 'backendPages')\n for (const page of facts.frontendPages) emitPage(page, 'frontendPages')\n\n return { targets, diagnostics }\n },\n}\n\nconst eventsAdapter: InternalAdapter = {\n domain: 'events',\n run(facts) {\n const moduleId = moduleIdOf(facts)\n const targets: ModuleOverrideTarget[] = []\n const diagnostics: ModuleOverrideTargetDiagnostic[] = []\n for (const contribution of contributionsOfKind(facts, 'subscriber')) {\n const subscriberId = contribution.details.subscriberId || contribution.id\n const path = ['events', 'subscribers', subscriberId]\n if (!contribution.source.path) {\n diagnostics.push({ code: 'missing-source', moduleId, domain: 'events', candidatePath: path })\n continue\n }\n pushTarget(targets, diagnostics, {\n moduleId, domain: 'events', path, key: subscriberId, dottedHost: 'events.subscribers',\n factRef: { factSection: 'extensionSurfaces.contributions', factKey: contribution.id },\n source: contributionSource(contribution),\n })\n }\n return { targets, diagnostics }\n },\n}\n\nconst workersAdapter: InternalAdapter = {\n domain: 'workers',\n run(facts) {\n const moduleId = moduleIdOf(facts)\n const targets: ModuleOverrideTarget[] = []\n const diagnostics: ModuleOverrideTargetDiagnostic[] = []\n for (const fact of facts.ownedContracts?.worker ?? []) {\n const path = ['workers', fact.id]\n if (!fact.source.sourcePath) {\n diagnostics.push({ code: 'missing-source', moduleId, domain: 'workers', candidatePath: path })\n continue\n }\n pushTarget(targets, diagnostics, {\n moduleId, domain: 'workers', path, key: fact.id, dottedHost: 'workers',\n factRef: { factSection: 'ownedContracts.worker', factKey: fact.id },\n source: ownedSource(fact),\n })\n }\n return { targets, diagnostics }\n },\n}\n\nconst widgetsAdapter: InternalAdapter = {\n domain: 'widgets',\n run(facts) {\n const moduleId = moduleIdOf(facts)\n const targets: ModuleOverrideTarget[] = []\n const diagnostics: ModuleOverrideTargetDiagnostic[] = []\n\n const emitInjection = (registryKey: string, contribution: ModuleExtensionContributionFact): void => {\n const path = ['widgets', 'injection', registryKey]\n pushTarget(targets, diagnostics, {\n moduleId, domain: 'widgets', path, key: registryKey, dottedHost: 'widgets.injection',\n factRef: { factSection: 'extensionSurfaces.contributions', factKey: contribution.id },\n source: contributionSource(contribution),\n })\n }\n\n for (const contribution of contributionsOfKind(facts, 'widget')) {\n const registryKey = contribution.details.registryKey\n if (!registryKey) {\n diagnostics.push({ code: 'unsupported-dynamic-key', moduleId, domain: 'widgets', candidatePath: ['widgets', 'injection', contribution.id] })\n continue\n }\n if (contribution.details.payload === 'dashboard') {\n const path = ['widgets', 'dashboard', registryKey]\n pushTarget(targets, diagnostics, {\n moduleId, domain: 'widgets', path, key: registryKey, dottedHost: 'widgets.dashboard',\n factRef: { factSection: 'extensionSurfaces.contributions', factKey: contribution.id },\n source: contributionSource(contribution),\n })\n } else {\n emitInjection(registryKey, contribution)\n }\n }\n\n // data-table / crud-form contributions are injection-widget entries whose\n // registry key is the id segment before the `@<spot>` suffix.\n for (const contribution of [\n ...contributionsOfKind(facts, 'data-table'),\n ...contributionsOfKind(facts, 'crud-form'),\n ]) {\n const registryKey = contribution.id.split('@')[0]\n if (!registryKey || registryKey === contribution.id) {\n diagnostics.push({ code: 'unsupported-dynamic-key', moduleId, domain: 'widgets', candidatePath: ['widgets', 'injection', contribution.id] })\n continue\n }\n emitInjection(registryKey, contribution)\n }\n\n for (const contribution of contributionsOfKind(facts, 'component-override')) {\n const componentId = contribution.details.handle\n const path = ['widgets', 'components', componentId]\n pushTarget(targets, diagnostics, {\n moduleId, domain: 'widgets', path, key: componentId, dottedHost: 'widgets.components',\n factRef: { factSection: 'extensionSurfaces.contributions', factKey: contribution.id },\n source: contributionSource(contribution),\n })\n }\n\n return { targets, diagnostics }\n },\n}\n\nconst notificationsAdapter: InternalAdapter = {\n domain: 'notifications',\n run(facts, resolveFactSource) {\n const moduleId = moduleIdOf(facts)\n const targets: ModuleOverrideTarget[] = []\n const diagnostics: ModuleOverrideTargetDiagnostic[] = []\n\n const registrySources = new Map<string, ModuleFactSourceRef>()\n for (const contribution of contributionsOfKind(facts, 'specialized-registry')) {\n if (contribution.details.registry !== 'notification') continue\n registrySources.set(contribution.details.registryId, contributionSource(contribution))\n }\n for (const type of facts.notifications) {\n const path = ['notifications', 'types', type]\n const indexedPath = indexedFactSourcePath(resolveFactSource, 'notification', type)\n const source = registrySources.get(type) ?? (indexedPath ? { sourcePath: indexedPath } : null)\n if (!source) {\n diagnostics.push({ code: 'missing-source', moduleId, domain: 'notifications', candidatePath: path })\n continue\n }\n pushTarget(targets, diagnostics, {\n moduleId, domain: 'notifications', path, key: type, dottedHost: 'notifications.types',\n factRef: { factSection: 'notifications', factKey: type },\n source,\n })\n }\n\n // Reactive handlers (`notifications.handlers.ts`) are keyed by their declared\n // handler id; a handler that declares none cannot be addressed by runtime.\n for (const contribution of contributionsOfKind(facts, 'browser-reaction')) {\n if (!contribution.details.transports.includes('notification-effect')) continue\n const overrideKey = contribution.details.overrideKey\n if (!overrideKey) {\n diagnostics.push({\n code: 'unsupported-dynamic-key',\n moduleId,\n domain: 'notifications',\n candidatePath: ['notifications', 'handlers'],\n source: contributionSource(contribution),\n })\n continue\n }\n pushTarget(targets, diagnostics, {\n moduleId,\n domain: 'notifications',\n path: ['notifications', 'handlers', overrideKey],\n key: overrideKey,\n dottedHost: 'notifications.handlers',\n factRef: { factSection: 'extensionSurfaces.contributions', factKey: contribution.id },\n source: contributionSource(contribution),\n })\n }\n return { targets, diagnostics }\n },\n}\n\nfunction contributionIdAdapter(\n domain: ModuleOverrideDomain,\n kind: ModuleExtensionContributionFact['kind'],\n dottedHost: string,\n): InternalAdapter {\n return {\n domain,\n run(facts) {\n const moduleId = moduleIdOf(facts)\n const targets: ModuleOverrideTarget[] = []\n const diagnostics: ModuleOverrideTargetDiagnostic[] = []\n for (const contribution of contributionsOfKind(facts, kind)) {\n const path = [domain, contribution.id]\n if (!contribution.source.path) {\n diagnostics.push({ code: 'missing-source', moduleId, domain, candidatePath: path })\n continue\n }\n pushTarget(targets, diagnostics, {\n moduleId, domain, path, key: contribution.id, dottedHost,\n factRef: { factSection: 'extensionSurfaces.contributions', factKey: contribution.id },\n source: contributionSource(contribution),\n })\n }\n return { targets, diagnostics }\n },\n }\n}\n\nconst interceptorsAdapter = contributionIdAdapter('interceptors', 'api-interceptor', 'interceptors')\nconst commandInterceptorsAdapter = contributionIdAdapter('commandInterceptors', 'command-interceptor', 'commandInterceptors')\nconst enrichersAdapter = contributionIdAdapter('enrichers', 'response-enricher', 'enrichers')\n\n/**\n * `guards` targets ONLY backend/frontend page route middleware\n * (`ownedContracts['page-middleware']`). `data/guards.ts` mutation guards\n * (contribution kind `mutation-guard`) are a different runtime contract and\n * MUST NEVER surface here \u2014 every target carries the closed\n * `page-middleware-not-mutation-guard` note.\n */\nconst guardsAdapter: InternalAdapter = {\n domain: 'guards',\n run(facts) {\n const moduleId = moduleIdOf(facts)\n const targets: ModuleOverrideTarget[] = []\n const diagnostics: ModuleOverrideTargetDiagnostic[] = []\n for (const fact of facts.ownedContracts?.['page-middleware'] ?? []) {\n const path = ['guards', fact.id]\n if (!fact.source.sourcePath) {\n diagnostics.push({ code: 'missing-source', moduleId, domain: 'guards', candidatePath: path })\n continue\n }\n pushTarget(targets, diagnostics, {\n moduleId, domain: 'guards', path, key: fact.id, dottedHost: 'guards',\n factRef: { factSection: 'ownedContracts.page-middleware', factKey: fact.id },\n source: ownedSource(fact),\n notes: ['page-middleware-not-mutation-guard'],\n })\n }\n return { targets, diagnostics }\n },\n}\n\nconst cliAdapter: InternalAdapter = {\n domain: 'cli',\n run(facts) {\n const moduleId = moduleIdOf(facts)\n const targets: ModuleOverrideTarget[] = []\n const diagnostics: ModuleOverrideTargetDiagnostic[] = []\n for (const command of facts.cliCommands) {\n const path = ['cli', command.command]\n if (!command.sourcePath) {\n diagnostics.push({ code: 'missing-source', moduleId, domain: 'cli', candidatePath: path })\n continue\n }\n pushTarget(targets, diagnostics, {\n moduleId, domain: 'cli', path, key: command.command, dottedHost: 'cli',\n factRef: { factSection: 'cliCommands', factKey: command.command },\n source: { sourcePath: command.sourcePath },\n })\n }\n return { targets, diagnostics }\n },\n}\n\n// `SetupOverridesShape` keys the runtime override resolver accepts. Only these\n// supported hook/profile properties become `setup` targets.\nconst SUPPORTED_SETUP_HOOKS = new Set(['seedDefaults', 'seedExamples', 'onTenantCreated'])\n\nconst setupAdapter: InternalAdapter = {\n domain: 'setup',\n run(facts) {\n const moduleId = moduleIdOf(facts)\n const targets: ModuleOverrideTarget[] = []\n const diagnostics: ModuleOverrideTargetDiagnostic[] = []\n const setupFacts = facts.ownedContracts?.setup ?? []\n for (const fact of setupFacts) {\n if (!fact.source.sourcePath) {\n diagnostics.push({ code: 'missing-source', moduleId, domain: 'setup', candidatePath: ['setup'] })\n continue\n }\n const source = ownedSource(fact)\n const properties: string[] = []\n const hooks = fact.metadata?.hooks\n if (Array.isArray(hooks)) {\n for (const hook of hooks) {\n if (typeof hook === 'string' && SUPPORTED_SETUP_HOOKS.has(hook)) properties.push(hook)\n }\n }\n const roles = fact.metadata?.roles\n if (Array.isArray(roles) && roles.length > 0) properties.push('defaultRoleFeatures')\n const customerRoles = fact.metadata?.customerRoles\n if (Array.isArray(customerRoles) && customerRoles.length > 0) properties.push('defaultCustomerRoleFeatures')\n for (const property of properties) {\n const path = ['setup', property]\n pushTarget(targets, diagnostics, {\n moduleId, domain: 'setup', path, dottedHost: 'setup',\n factRef: { factSection: 'ownedContracts.setup', factKey: fact.id },\n source,\n })\n }\n }\n return { targets, diagnostics }\n },\n}\n\nconst aclAdapter: InternalAdapter = {\n domain: 'acl',\n run(facts, resolveFactSource) {\n const moduleId = moduleIdOf(facts)\n const targets: ModuleOverrideTarget[] = []\n const diagnostics: ModuleOverrideTargetDiagnostic[] = []\n for (const feature of facts.aclFeatures) {\n const path = ['acl', 'features', feature]\n const sourcePath = indexedFactSourcePath(resolveFactSource, 'acl-feature', feature)\n if (!sourcePath) {\n diagnostics.push({ code: 'missing-source', moduleId, domain: 'acl', candidatePath: path })\n continue\n }\n pushTarget(targets, diagnostics, {\n moduleId, domain: 'acl', path, key: feature, dottedHost: 'acl.features',\n factRef: { factSection: 'aclFeatures', factKey: feature },\n source: { sourcePath },\n })\n }\n return { targets, diagnostics }\n },\n}\n\n/**\n * `di` targets expose the exact registration token and correlate to the rich DI\n * owned fact (which carries the registration kind). They NEVER include the\n * `asValue` payload, constructed service, or factory/class body \u2014 the target\n * schema has no such field and carries the `safe-metadata-only` note.\n */\nconst diAdapter: InternalAdapter = {\n domain: 'di',\n run(facts) {\n const moduleId = moduleIdOf(facts)\n const targets: ModuleOverrideTarget[] = []\n const diagnostics: ModuleOverrideTargetDiagnostic[] = []\n for (const fact of facts.ownedContracts?.['di-registration'] ?? []) {\n const path = ['di', fact.id]\n if (!fact.source.sourcePath) {\n diagnostics.push({ code: 'missing-source', moduleId, domain: 'di', candidatePath: path })\n continue\n }\n pushTarget(targets, diagnostics, {\n moduleId, domain: 'di', path, key: fact.id, dottedHost: 'di',\n factRef: { factSection: 'ownedContracts.di-registration', factKey: fact.id },\n source: ownedSource(fact),\n notes: ['safe-metadata-only'],\n })\n }\n return { targets, diagnostics }\n },\n}\n\nconst encryptionAdapter: InternalAdapter = {\n domain: 'encryption',\n run(facts) {\n const moduleId = moduleIdOf(facts)\n const targets: ModuleOverrideTarget[] = []\n const diagnostics: ModuleOverrideTargetDiagnostic[] = []\n for (const fact of facts.ownedContracts?.encryption ?? []) {\n const path = ['encryption', 'maps', fact.id]\n if (!fact.source.sourcePath) {\n diagnostics.push({ code: 'missing-source', moduleId, domain: 'encryption', candidatePath: path })\n continue\n }\n pushTarget(targets, diagnostics, {\n moduleId, domain: 'encryption', path, key: fact.id, dottedHost: 'encryption.maps',\n factRef: { factSection: 'ownedContracts.encryption', factKey: fact.id },\n source: ownedSource(fact),\n })\n }\n return { targets, diagnostics }\n },\n}\n\n/** `nav.groupOrder` is a framework-only setting; never a module target. */\nconst navAdapter: InternalAdapter = {\n domain: 'nav',\n frameworkOnly: true,\n run() {\n return { targets: [], diagnostics: [] }\n },\n}\n\nconst INTERNAL_ADAPTERS: InternalAdapter[] = [\n aiAdapter,\n routesAdapter,\n eventsAdapter,\n workersAdapter,\n widgetsAdapter,\n notificationsAdapter,\n interceptorsAdapter,\n commandInterceptorsAdapter,\n enrichersAdapter,\n guardsAdapter,\n cliAdapter,\n setupAdapter,\n aclAdapter,\n diAdapter,\n encryptionAdapter,\n navAdapter,\n]\n\n/**\n * Runtime enumeration of every unified override domain. Typed as a\n * `Record<ModuleOverrideDomain, true>` so adding a member to the runtime\n * `ModuleOverrideDomain` union fails the build here until it is listed \u2014 and\n * the coverage test then fails until an adapter (or `frameworkOnly`\n * classification) is registered.\n */\nconst OVERRIDE_DOMAIN_PRESENCE: Record<ModuleOverrideDomain, true> = {\n ai: true,\n routes: true,\n events: true,\n workers: true,\n widgets: true,\n notifications: true,\n interceptors: true,\n commandInterceptors: true,\n enrichers: true,\n guards: true,\n cli: true,\n setup: true,\n acl: true,\n di: true,\n encryption: true,\n nav: true,\n}\n\nexport const ALL_OVERRIDE_DOMAINS = Object.keys(OVERRIDE_DOMAIN_PRESENCE) as ModuleOverrideDomain[]\n\nexport const MODULE_OVERRIDE_TARGET_ADAPTERS: OverrideTargetAdapter[] = INTERNAL_ADAPTERS.map((adapter) => ({\n domain: adapter.domain,\n ...(adapter.frameworkOnly ? { frameworkOnly: true } : {}),\n collect: (moduleFacts) => adapter.run(moduleFacts, buildFactSourceLookup(moduleFacts)).targets,\n diagnose: (moduleFacts) => adapter.run(moduleFacts, buildFactSourceLookup(moduleFacts)).diagnostics,\n}))\n\nexport type ModuleOverrideTargetsResult = {\n overrideTargets: ModuleOverrideTarget[]\n overrideTargetDiagnostics: ModuleOverrideTargetDiagnostic[]\n}\n\n/**\n * Project every exact override target (and per-module diagnostic) for one\n * module's facts. Output sorts by domain, then path segments, then source;\n * diagnostics sort by moduleId, domain, code, then path/source. Targets are\n * deduped by `(domain, path)` keeping the source-first entry.\n */\nexport function collectModuleOverrideTargets(\n facts: ModuleFactsJsonEntry,\n resolveFactSource: FactSourceLookup = buildFactSourceLookup(facts),\n): ModuleOverrideTargetsResult {\n const collected: ModuleOverrideTarget[] = []\n const diagnostics: ModuleOverrideTargetDiagnostic[] = []\n for (const adapter of INTERNAL_ADAPTERS) {\n if (adapter.frameworkOnly) continue\n const result = adapter.run(facts, resolveFactSource)\n collected.push(...result.targets)\n diagnostics.push(...result.diagnostics)\n }\n\n const byPath = new Map<string, ModuleOverrideTarget>()\n for (const target of collected) {\n const pathKey = `${target.domain} ${JSON.stringify(target.path)}`\n const existing = byPath.get(pathKey)\n if (!existing || compareSourceRefs(target.source, existing.source) < 0) byPath.set(pathKey, target)\n }\n\n const overrideTargets = [...byPath.values()].sort(\n (left, right) =>\n left.domain.localeCompare(right.domain) ||\n comparePaths(left.path, right.path) ||\n compareSourceRefs(left.source, right.source),\n )\n\n const overrideTargetDiagnostics = diagnostics.sort(\n (left, right) =>\n left.moduleId.localeCompare(right.moduleId) ||\n left.domain.localeCompare(right.domain) ||\n left.code.localeCompare(right.code) ||\n comparePaths(left.candidatePath ?? [], right.candidatePath ?? []) ||\n compareSourceRefs(left.source ?? { sourcePath: '' }, right.source ?? { sourcePath: '' }),\n )\n\n return { overrideTargets, overrideTargetDiagnostics }\n}\n"],
5
- "mappings": "AAAA,OAAO,YAAY;AAUnB,SAAS,6BAAoD;AAC7D,SAAS,iCAAiC;AAyE1C,MAAM,iBAAiB,0BAA0B;AAQjD,SAAS,SAAS,YAAiD;AACjE,QAAM,OAAO,eAAe,UAAU;AACtC,SAAO,OAAO,CAAC,IAAI,IAAI;AACzB;AAOA,SAAS,WAAW,OAAqC;AACvD,QAAM,WAAW,MAAM,WAAW,MAAM,GAAG,EAAE,OAAO,OAAO;AAC3D,SAAO,SAAS,SAAS,SAAS,CAAC,KAAK;AAC1C;AAOO,SAAS,wBAAwB,UAAkB,QAA8B,MAAwB;AAC9G,SAAO,OAAO,WAAW,MAAM,EAAE,OAAO,KAAK,UAAU,CAAC,UAAU,QAAQ,IAAI,CAAC,CAAC,EAAE,OAAO,KAAK,EAAE,MAAM,GAAG,EAAE;AAC7G;AAEA,SAAS,kBAAkB,MAA2B,OAAo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,cAAc,MAAM,QAAQ,KAC1C,KAAK,OAAO,cAAc,MAAM,MAAM,KACtC,KAAK,KAAK,cAAc,MAAM,IAAI,KAClC,aAAa,KAAK,iBAAiB,CAAC,GAAG,MAAM,iBAAiB,CAAC,CAAC,KAChE,kBAAkB,KAAK,UAAU,EAAE,YAAY,GAAG,GAAG,MAAM,UAAU,EAAE,YAAY,GAAG,CAAC;AAAA,EAC3F;AAEA,SAAO,EAAE,iBAAiB,0BAA0B;AACtD;",
6
- "names": []
7
- }
@@ -1,24 +0,0 @@
1
- import fs from "node:fs";
2
- import path from "node:path";
3
- async function loadAppEnv(options = {}) {
4
- try {
5
- const { createResolver } = await import("./resolver.js");
6
- const appDir = createResolver(options.cwd).getAppDir();
7
- const envPath = path.join(appDir, ".env");
8
- if (fs.existsSync(envPath)) {
9
- const dotenv = await import("dotenv");
10
- dotenv.config({ path: envPath, quiet: true });
11
- return;
12
- }
13
- } catch {
14
- }
15
- try {
16
- const dotenv = await import("dotenv");
17
- dotenv.config({ quiet: true });
18
- } catch {
19
- }
20
- }
21
- export {
22
- loadAppEnv
23
- };
24
- //# sourceMappingURL=load-env.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/lib/load-env.ts"],
4
- "sourcesContent": ["import fs from 'node:fs'\nimport path from 'node:path'\n\n/**\n * Bootstrap-free `.env` loader for the CLI binary. `bin.ts` must load the app's\n * `.env` BEFORE `initTelemetry()` so `TELEMETRY_*` set only in `.env` resolves a\n * real backend for worker/scheduler processes \u2014 `run()`'s `ensureEnvLoaded()`\n * happens after telemetry init, which is too late. Deliberately read-only (no\n * `.env.example` copy \u2014 that UX stays in `ensureEnvLoaded`) and pulls in only the\n * resolver + dotenv, so nothing here loads `pg` and the OTEL instrumentation\n * load-order guarantee is preserved.\n */\nexport async function loadAppEnv(options: { cwd?: string } = {}): Promise<void> {\n try {\n const { createResolver } = await import('./resolver.js')\n const appDir = createResolver(options.cwd).getAppDir()\n const envPath = path.join(appDir, '.env')\n if (fs.existsSync(envPath)) {\n const dotenv = await import('dotenv')\n dotenv.config({ path: envPath, quiet: true })\n return\n }\n } catch {\n // Resolver can fail outside an app dir \u2014 fall through to plain cwd loading.\n }\n try {\n const dotenv = await import('dotenv')\n dotenv.config({ quiet: true })\n } catch {}\n}\n"],
5
- "mappings": "AAAA,OAAO,QAAQ;AACf,OAAO,UAAU;AAWjB,eAAsB,WAAW,UAA4B,CAAC,GAAkB;AAC9E,MAAI;AACF,UAAM,EAAE,eAAe,IAAI,MAAM,OAAO,eAAe;AACvD,UAAM,SAAS,eAAe,QAAQ,GAAG,EAAE,UAAU;AACrD,UAAM,UAAU,KAAK,KAAK,QAAQ,MAAM;AACxC,QAAI,GAAG,WAAW,OAAO,GAAG;AAC1B,YAAM,SAAS,MAAM,OAAO,QAAQ;AACpC,aAAO,OAAO,EAAE,MAAM,SAAS,OAAO,KAAK,CAAC;AAC5C;AAAA,IACF;AAAA,EACF,QAAQ;AAAA,EAER;AACA,MAAI;AACF,UAAM,SAAS,MAAM,OAAO,QAAQ;AACpC,WAAO,OAAO,EAAE,OAAO,KAAK,CAAC;AAAA,EAC/B,QAAQ;AAAA,EAAC;AACX;",
6
- "names": []
7
- }
@@ -1,358 +0,0 @@
1
- import { existsSync, readFileSync, writeFileSync, mkdirSync } from "node:fs";
2
- import { dirname, join, resolve } from "node:path";
3
- const BULLMQ_OTEL_VERSION = "^1.3.1";
4
- const ENV_BLOCK = `
5
- # --- Telemetry & Observability (vendor-neutral OTLP: traces, logs, metrics, errors) ---
6
- # Off by default: leave TELEMETRY_BACKEND unset (or =noop) for a hard no-op
7
- # (the OpenTelemetry SDK is never loaded). Set to 'console' for local span/metric
8
- # output, or an OTLP backend to export: 'signoz' | 'newrelic' | 'otlp' (generic).
9
- # All three OTLP names use the same exporter \u2014 they differ only by the endpoint +
10
- # headers below. Any OTLP backend is a one-line swap; no code change.
11
- # TELEMETRY_BACKEND=otlp
12
- # Logs use the shared logger facade and its OM_LOG_LEVEL / OM_LOG_PRETTY /
13
- # OM_LOG_DESTINATION controls. Telemetry adds remote export; it does not create
14
- # a second local output path.
15
- # TELEMETRY_SAMPLING_RATIO=1.0 # 0.0\u20131.0 (default 1.0 dev / 0.1 prod)
16
- # TELEMETRY_TRUST_INBOUND_TRACE=false # default false: root-per-request (ignore an
17
- # # inbound traceparent from a proxy/LB). Set true
18
- # # only behind a trusted upstream whose trace continues.
19
- # # This also enables richer bullmq-otel spans;
20
- # # otherwise async queues use metadata._trace.
21
- #
22
- # OTLP endpoint + auth \u2014 pick ONE vendor (use your region's host):
23
- # SigNoz Cloud:
24
- # OTEL_EXPORTER_OTLP_ENDPOINT=https://ingest.<region>.signoz.cloud:443
25
- # OTEL_EXPORTER_OTLP_HEADERS=signoz-ingestion-key=<your-ingestion-key>
26
- # New Relic (OTLP-native; EU host shown, US is https://otlp.nr-data.net):
27
- # OTEL_EXPORTER_OTLP_ENDPOINT=https://otlp.eu01.nr-data.net
28
- # OTEL_EXPORTER_OTLP_HEADERS=api-key=<your-ingest-license-key>
29
- #
30
- # Resource identity: keep one stable service name across environments and
31
- # separate envs via the deployment.environment resource attribute.
32
- # OTEL_SERVICE_NAME=open-mercato
33
- # OTEL_RESOURCE_ATTRIBUTES=deployment.environment=local
34
- `;
35
- const INSTRUMENTATION_TS = `import { isTelemetryBackendEnabled } from '@open-mercato/shared/lib/telemetry/runtime'
36
-
37
- export async function register(): Promise<void> {
38
- // Initialize telemetry (no-op unless TELEMETRY_BACKEND is set). OTEL's NodeSDK
39
- // is Node-only and incompatible with the edge runtime, so the telemetry
40
- // bootstrap \u2014 which can pull in the SDK \u2014 is imported only on the Node.js
41
- // runtime. The helper owns init + graceful degrade + shutdown flush.
42
- if (
43
- process.env.NEXT_RUNTIME === 'nodejs'
44
- && isTelemetryBackendEnabled()
45
- ) {
46
- const { registerTelemetryForNextjs } = await import('@open-mercato/telemetry/nextjs')
47
- await registerTelemetryForNextjs()
48
- }
49
- }
50
- `;
51
- const DISPATCHER_SNIPPET = ` // add near the other imports:
52
- import { getTelemetryRuntime } from '@open-mercato/shared/lib/telemetry/runtime'
53
-
54
- // in the dispatcher's success path, just before returning the response:
55
- getTelemetryRuntime()?.recordHttpDuration(method, match.route.path, finalResponse.status, startedAt)
56
-
57
- // in the dispatcher's catch (error) block, before re-throwing:
58
- getTelemetryRuntime()?.reportError(error, {
59
- attributes: { 'http.request.method': method, 'http.route': match.route.path, 'http.response.status_code': 500 },
60
- })
61
- getTelemetryRuntime()?.recordHttpDuration(method, match.route.path, 500, startedAt)`;
62
- function parseArgs(args) {
63
- return {
64
- dryRun: args.includes("--dry-run") || args.includes("-n")
65
- };
66
- }
67
- function resolveOpenMercatoVersion(pkg) {
68
- for (const field of ["dependencies", "devDependencies"]) {
69
- const deps = pkg[field];
70
- if (deps && typeof deps === "object") {
71
- for (const [name, version] of Object.entries(deps)) {
72
- if (name.startsWith("@open-mercato/") && typeof version === "string") return version;
73
- }
74
- }
75
- }
76
- return "*";
77
- }
78
- function patchPackageJson(appDir, options) {
79
- const file = "package.json";
80
- const path = join(appDir, file);
81
- const raw = readFileSync(path, "utf8");
82
- const pkg = JSON.parse(raw);
83
- const version = resolveOpenMercatoVersion(pkg);
84
- const hasTelemetry = Boolean(pkg.dependencies?.["@open-mercato/telemetry"]);
85
- const hasBullmqOtel = Boolean(pkg.optionalDependencies?.["bullmq-otel"]);
86
- if (hasTelemetry && hasBullmqOtel) {
87
- return { file, status: "skipped", detail: "@open-mercato/telemetry already installed" };
88
- }
89
- const deps = { ...pkg.dependencies ?? {} };
90
- if (!hasTelemetry) deps["@open-mercato/telemetry"] = version;
91
- const optDeps = { ...pkg.optionalDependencies ?? {} };
92
- if (!hasBullmqOtel) optDeps["bullmq-otel"] = BULLMQ_OTEL_VERSION;
93
- const next = {
94
- ...pkg,
95
- dependencies: sortRecord(deps),
96
- optionalDependencies: sortRecord(optDeps)
97
- };
98
- if (!options.dryRun) writeFileSync(path, `${JSON.stringify(next, null, 2)}
99
- `);
100
- return {
101
- file,
102
- status: "patched",
103
- detail: `+@open-mercato/telemetry@${version}${hasBullmqOtel ? "" : ` +bullmq-otel@${BULLMQ_OTEL_VERSION} (optional)`} \u2014 run \`yarn install\``
104
- };
105
- }
106
- function sortRecord(record) {
107
- return Object.fromEntries(Object.entries(record).sort(([a], [b]) => a.localeCompare(b)));
108
- }
109
- function patchEnvFile(appDir, relativePath, options) {
110
- const path = join(appDir, relativePath);
111
- if (!existsSync(path)) return null;
112
- const content = readFileSync(path, "utf8");
113
- if (content.includes("TELEMETRY_BACKEND")) {
114
- return { file: relativePath, status: "skipped", detail: "TELEMETRY_* block already present" };
115
- }
116
- const next = `${content.replace(/\s*$/, "")}
117
- ${ENV_BLOCK}`;
118
- if (!options.dryRun) writeFileSync(path, next);
119
- return { file: relativePath, status: "patched", detail: "appended commented TELEMETRY_* / OTEL_* block" };
120
- }
121
- function patchInstrumentation(appDir, options) {
122
- const file = "src/instrumentation.ts";
123
- const path = join(appDir, file);
124
- if (!existsSync(path)) {
125
- if (!options.dryRun) {
126
- mkdirSync(dirname(path), { recursive: true });
127
- writeFileSync(path, INSTRUMENTATION_TS);
128
- }
129
- return { file, status: "created", detail: "Node-runtime-guarded registerTelemetryForNextjs() bootstrap" };
130
- }
131
- const content = readFileSync(path, "utf8");
132
- if (content.includes("registerTelemetryForNextjs")) {
133
- if (content.includes("isTelemetryBackendEnabled")) {
134
- return { file, status: "skipped", detail: "telemetry already wired" };
135
- }
136
- const migrated = `import { isTelemetryBackendEnabled } from '@open-mercato/shared/lib/telemetry/runtime'
137
- ` + content.replace(
138
- `if (process.env.NEXT_RUNTIME === 'nodejs') {`,
139
- `if (process.env.NEXT_RUNTIME === 'nodejs' && isTelemetryBackendEnabled()) {`
140
- );
141
- if (!options.dryRun) writeFileSync(path, migrated);
142
- return { file, status: "patched", detail: "added the explicit backend import guard" };
143
- }
144
- const anchor = content.match(/export\s+async\s+function\s+register\s*\([^)]*\)\s*:\s*Promise<void>\s*\{/);
145
- if (!anchor || anchor.index === void 0) {
146
- return {
147
- file,
148
- status: "manual",
149
- detail: "register() not found \u2014 add the telemetry bootstrap manually",
150
- manualSnippet: INSTRUMENTATION_TS
151
- };
152
- }
153
- const insertAt = anchor.index + anchor[0].length;
154
- const block = `
155
- // Initialize telemetry (no-op unless TELEMETRY_BACKEND is set); Node-only.
156
- if (process.env.NEXT_RUNTIME === 'nodejs' && isTelemetryBackendEnabled()) {
157
- const { registerTelemetryForNextjs } = await import('@open-mercato/telemetry/nextjs')
158
- await registerTelemetryForNextjs()
159
- }`;
160
- const importLine = `import { isTelemetryBackendEnabled } from '@open-mercato/shared/lib/telemetry/runtime'
161
- `;
162
- const withImport = content.includes("isTelemetryBackendEnabled") ? content : importLine + content;
163
- const shiftedInsertAt = insertAt + (withImport.length - content.length);
164
- const next = withImport.slice(0, shiftedInsertAt) + block + withImport.slice(shiftedInsertAt);
165
- if (!options.dryRun) writeFileSync(path, next);
166
- return { file, status: "patched", detail: "inserted registerTelemetryForNextjs() into register()" };
167
- }
168
- async function patchNextConfig(appDir, options) {
169
- const file = "next.config.ts";
170
- const path = join(appDir, file);
171
- if (!existsSync(path)) {
172
- return { file, status: "manual", detail: "next.config.ts not found", manualSnippet: nextConfigSnippet() };
173
- }
174
- const { Project, SyntaxKind } = await import("ts-morph");
175
- const project = new Project({ skipAddingFilesFromTsConfig: true, skipFileDependencyResolution: true });
176
- const sf = project.addSourceFileAtPath(path);
177
- const telemetryConfigImport = sf.getImportDeclarations().find((decl) => [
178
- "@open-mercato/telemetry/nextjs",
179
- "@open-mercato/telemetry/nextjs-config"
180
- ].includes(decl.getModuleSpecifierValue()));
181
- const hasImport = Boolean(telemetryConfigImport);
182
- const hasCanonicalImport = telemetryConfigImport?.getModuleSpecifierValue() === "@open-mercato/telemetry/nextjs-config";
183
- const arrayProp = sf.getDescendantsOfKind(SyntaxKind.PropertyAssignment).find((prop) => prop.getName() === "serverExternalPackages");
184
- const arrayInit = arrayProp?.getInitializerIfKind(SyntaxKind.ArrayLiteralExpression);
185
- if (!arrayInit) {
186
- return {
187
- file,
188
- status: "manual",
189
- detail: "serverExternalPackages array not found",
190
- manualSnippet: nextConfigSnippet()
191
- };
192
- }
193
- const hasSpread = arrayInit.getElements().some((el) => el.getText().includes("telemetryServerExternalPackages"));
194
- if (hasCanonicalImport && hasSpread) {
195
- return { file, status: "skipped", detail: "telemetryServerExternalPackages already wired" };
196
- }
197
- let text = readFileSync(path, "utf8");
198
- if (!hasSpread) {
199
- const start = arrayInit.getStart();
200
- const end = arrayInit.getEnd();
201
- text = text.slice(0, start) + insertSpread(text.slice(start, end)) + text.slice(end);
202
- }
203
- text = text.replace(
204
- "from '@open-mercato/telemetry/nextjs'",
205
- "from '@open-mercato/telemetry/nextjs-config'"
206
- );
207
- if (!hasImport) {
208
- const importRegex = /^import[^\n]*$/gm;
209
- let lastImport = null;
210
- let match;
211
- while ((match = importRegex.exec(text)) !== null) lastImport = match;
212
- const insertAt = lastImport ? lastImport.index + lastImport[0].length : 0;
213
- text = text.slice(0, insertAt) + `
214
- import { telemetryServerExternalPackages } from '@open-mercato/telemetry/nextjs-config'` + text.slice(insertAt);
215
- }
216
- if (!options.dryRun) writeFileSync(path, text);
217
- return { file, status: "patched", detail: "spread telemetryServerExternalPackages into serverExternalPackages" };
218
- }
219
- function insertSpread(arrayText) {
220
- const inner = arrayText.slice(1, -1);
221
- if (inner.includes("\n")) {
222
- const elementIndent = inner.match(/\n([ \t]+)\S/)?.[1] ?? " ";
223
- const closeIndent = arrayText.match(/\n([ \t]*)\]$/)?.[1] ?? "";
224
- const trimmed = inner.replace(/\s*$/, "");
225
- const separator = trimmed === "" || trimmed.endsWith(",") ? "" : ",";
226
- return `[${trimmed}${separator}
227
- ${elementIndent}...telemetryServerExternalPackages,
228
- ${closeIndent}]`;
229
- }
230
- const flat = inner.trim();
231
- return flat === "" ? "[...telemetryServerExternalPackages]" : `[${flat}, ...telemetryServerExternalPackages]`;
232
- }
233
- function nextConfigSnippet() {
234
- return `import { telemetryServerExternalPackages } from '@open-mercato/telemetry/nextjs-config'
235
- // serverExternalPackages: [ ...existing, ...telemetryServerExternalPackages ]`;
236
- }
237
- function patchDispatcher(appDir, options) {
238
- const file = "src/app/api/[...slug]/route.ts";
239
- const path = join(appDir, file);
240
- if (!existsSync(path)) {
241
- return { file, status: "manual", detail: "dispatcher not found", manualSnippet: DISPATCHER_SNIPPET };
242
- }
243
- let content = readFileSync(path, "utf8");
244
- if (content.includes("from '@open-mercato/shared/lib/telemetry/runtime'") && content.includes("getTelemetryRuntime()?.recordHttpDuration")) {
245
- return { file, status: "skipped", detail: "telemetry already wired" };
246
- }
247
- if (content.includes("import { reportError } from '@open-mercato/telemetry'") && content.includes("import { recordHttpDuration } from '@open-mercato/telemetry/nextjs'")) {
248
- content = content.replace(
249
- "import { reportError } from '@open-mercato/telemetry'\nimport { recordHttpDuration } from '@open-mercato/telemetry/nextjs'",
250
- "import { getTelemetryRuntime } from '@open-mercato/shared/lib/telemetry/runtime'"
251
- ).replace(/\brecordHttpDuration\(/g, "getTelemetryRuntime()?.recordHttpDuration(").replace(/\breportError\(/g, "getTelemetryRuntime()?.reportError(");
252
- if (!options.dryRun) writeFileSync(path, content);
253
- return { file, status: "patched", detail: "migrated dispatcher to the default-off runtime bridge" };
254
- }
255
- const importAnchor = "import { isCrudHttpError } from '@open-mercato/shared/lib/crud/errors'";
256
- const returnMatch = content.match(/^([ \t]*)return finalResponse\s*$/m);
257
- const catchRegex = /^([ \t]*)\}\s*catch\s*\(error\)\s*\{[ \t]*$/gm;
258
- const catchMatch = findCatchAfter(content, catchRegex, returnMatch?.index ?? -1);
259
- if (!content.includes(importAnchor) || !returnMatch || returnMatch.index === void 0 || !catchMatch) {
260
- return {
261
- file,
262
- status: "manual",
263
- detail: "dispatcher shape not recognized \u2014 apply the snippet by hand",
264
- manualSnippet: DISPATCHER_SNIPPET
265
- };
266
- }
267
- content = content.replace(
268
- importAnchor,
269
- `${importAnchor}
270
- import { getTelemetryRuntime } from '@open-mercato/shared/lib/telemetry/runtime'`
271
- );
272
- const ret = content.match(/^([ \t]*)return finalResponse\s*$/m);
273
- if (!ret || ret.index === void 0) {
274
- return { file, status: "manual", detail: "success-path anchor lost", manualSnippet: DISPATCHER_SNIPPET };
275
- }
276
- const retIndent = ret[1];
277
- content = content.slice(0, ret.index) + `${retIndent}getTelemetryRuntime()?.recordHttpDuration(method, match.route.path, finalResponse.status, startedAt)
278
- ` + content.slice(ret.index);
279
- const catch2 = findCatchAfter(content, /^([ \t]*)\}\s*catch\s*\(error\)\s*\{[ \t]*$/gm, content.indexOf("return finalResponse"));
280
- if (!catch2) {
281
- return { file, status: "manual", detail: "catch anchor lost", manualSnippet: DISPATCHER_SNIPPET };
282
- }
283
- const bodyIndent = `${catch2.indent} `;
284
- const insertAt = catch2.index + catch2.length;
285
- const block = `
286
- ${bodyIndent}getTelemetryRuntime()?.reportError(error, {
287
- ${bodyIndent} attributes: { 'http.request.method': method, 'http.route': match.route.path, 'http.response.status_code': 500 },
288
- ${bodyIndent}})
289
- ${bodyIndent}getTelemetryRuntime()?.recordHttpDuration(method, match.route.path, 500, startedAt)`;
290
- content = content.slice(0, insertAt) + block + content.slice(insertAt);
291
- if (!options.dryRun) writeFileSync(path, content);
292
- return { file, status: "patched", detail: "wired reportError (5xx) + http.server.request.duration metric" };
293
- }
294
- function findCatchAfter(content, regex, afterIndex) {
295
- regex.lastIndex = 0;
296
- let match;
297
- while ((match = regex.exec(content)) !== null) {
298
- if (match.index > afterIndex) {
299
- return { index: match.index, length: match[0].length, indent: match[1] };
300
- }
301
- }
302
- return null;
303
- }
304
- async function runTelemetryInit(args) {
305
- const appDir = resolve(".");
306
- const options = parseArgs(args);
307
- if (!existsSync(join(appDir, "src", "modules.ts"))) {
308
- console.error("\u274C Not an Open Mercato app directory (src/modules.ts not found)");
309
- return 1;
310
- }
311
- if (!existsSync(join(appDir, "package.json"))) {
312
- console.error("\u274C package.json not found");
313
- return 1;
314
- }
315
- console.log("");
316
- console.log(options.dryRun ? "\u{1F52D} Telemetry init (dry run \u2014 no files written)\n" : "\u{1F52D} Wiring @open-mercato/telemetry into this app\n");
317
- const results = [];
318
- results.push(patchPackageJson(appDir, options));
319
- const envExample = patchEnvFile(appDir, ".env.example", options);
320
- if (envExample) results.push(envExample);
321
- const env = patchEnvFile(appDir, ".env", options);
322
- if (env) results.push(env);
323
- results.push(patchInstrumentation(appDir, options));
324
- results.push(await patchNextConfig(appDir, options));
325
- results.push(patchDispatcher(appDir, options));
326
- const icon = { created: "\u270D\uFE0F ", patched: "\u2705", skipped: "\u23ED\uFE0F ", manual: "\u26A0\uFE0F " };
327
- for (const result of results) {
328
- console.log(`${icon[result.status]} ${result.file} \u2014 ${result.detail}`);
329
- }
330
- const manual = results.filter((result) => result.status === "manual");
331
- for (const result of manual) {
332
- if (!result.manualSnippet) continue;
333
- console.log("");
334
- console.log(`\u2500\u2500 manual step for ${result.file} \u2500\u2500`);
335
- console.log(result.manualSnippet);
336
- }
337
- console.log("");
338
- const changed = results.some((result) => result.status === "patched" || result.status === "created");
339
- if (options.dryRun) {
340
- console.log("Dry run complete \u2014 re-run without --dry-run to apply.");
341
- } else if (changed) {
342
- console.log("Next steps:");
343
- console.log(" 1. yarn install (resolve @open-mercato/telemetry + the OTEL SDK)");
344
- console.log(" 2. set TELEMETRY_BACKEND + OTEL_EXPORTER_OTLP_* in .env");
345
- console.log(" 3. yarn typecheck && yarn build (verify the wiring)");
346
- } else {
347
- console.log("Nothing to do \u2014 telemetry is already wired.");
348
- }
349
- if (manual.length > 0) {
350
- console.log("");
351
- console.log(`\u26A0\uFE0F ${manual.length} file(s) need a manual edit (shown above) \u2014 the rest were applied automatically.`);
352
- }
353
- return 0;
354
- }
355
- export {
356
- runTelemetryInit
357
- };
358
- //# sourceMappingURL=telemetry-init.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/lib/telemetry-init.ts"],
4
- "sourcesContent": ["import { existsSync, readFileSync, writeFileSync, mkdirSync } from 'node:fs'\nimport { dirname, join, resolve } from 'node:path'\n\n/**\n * `mercato telemetry init` \u2014 wire `@open-mercato/telemetry` into an app that was\n * scaffolded before telemetry existed. Deterministic, idempotent, and safe to\n * re-run: each step detects whether it is already applied and skips.\n *\n * The web-tier wiring lives in app-owned source files (a dependency bump cannot\n * touch them), so this patches them in place using the same idioms the rest of\n * the CLI uses: JSON edits, detect-before-append for `.env`, a ts-morph edit for\n * `next.config.ts`, and anchored insertion for `instrumentation.ts` + the API\n * dispatcher. When a file's shape is not recognized (a customized dispatcher, an\n * unusual next.config), the step degrades to printing the exact snippet and\n * flags it as a manual step rather than editing code it does not understand.\n *\n * Worker/scheduler telemetry is not handled here \u2014 it ships transitively via\n * `@open-mercato/cli`'s telemetry dependency once the app updates its packages.\n */\n\nconst BULLMQ_OTEL_VERSION = '^1.3.1'\n\ntype StepStatus = 'created' | 'patched' | 'skipped' | 'manual'\n\ntype StepResult = {\n file: string\n status: StepStatus\n detail: string\n /** Snippet to show when the step needs manual work. */\n manualSnippet?: string\n}\n\ntype TelemetryInitOptions = {\n dryRun: boolean\n}\n\nconst ENV_BLOCK = `\n# --- Telemetry & Observability (vendor-neutral OTLP: traces, logs, metrics, errors) ---\n# Off by default: leave TELEMETRY_BACKEND unset (or =noop) for a hard no-op\n# (the OpenTelemetry SDK is never loaded). Set to 'console' for local span/metric\n# output, or an OTLP backend to export: 'signoz' | 'newrelic' | 'otlp' (generic).\n# All three OTLP names use the same exporter \u2014 they differ only by the endpoint +\n# headers below. Any OTLP backend is a one-line swap; no code change.\n# TELEMETRY_BACKEND=otlp\n# Logs use the shared logger facade and its OM_LOG_LEVEL / OM_LOG_PRETTY /\n# OM_LOG_DESTINATION controls. Telemetry adds remote export; it does not create\n# a second local output path.\n# TELEMETRY_SAMPLING_RATIO=1.0 # 0.0\u20131.0 (default 1.0 dev / 0.1 prod)\n# TELEMETRY_TRUST_INBOUND_TRACE=false # default false: root-per-request (ignore an\n# # inbound traceparent from a proxy/LB). Set true\n# # only behind a trusted upstream whose trace continues.\n# # This also enables richer bullmq-otel spans;\n# # otherwise async queues use metadata._trace.\n#\n# OTLP endpoint + auth \u2014 pick ONE vendor (use your region's host):\n# SigNoz Cloud:\n# OTEL_EXPORTER_OTLP_ENDPOINT=https://ingest.<region>.signoz.cloud:443\n# OTEL_EXPORTER_OTLP_HEADERS=signoz-ingestion-key=<your-ingestion-key>\n# New Relic (OTLP-native; EU host shown, US is https://otlp.nr-data.net):\n# OTEL_EXPORTER_OTLP_ENDPOINT=https://otlp.eu01.nr-data.net\n# OTEL_EXPORTER_OTLP_HEADERS=api-key=<your-ingest-license-key>\n#\n# Resource identity: keep one stable service name across environments and\n# separate envs via the deployment.environment resource attribute.\n# OTEL_SERVICE_NAME=open-mercato\n# OTEL_RESOURCE_ATTRIBUTES=deployment.environment=local\n`\n\nconst INSTRUMENTATION_TS = `import { isTelemetryBackendEnabled } from '@open-mercato/shared/lib/telemetry/runtime'\n\nexport async function register(): Promise<void> {\n // Initialize telemetry (no-op unless TELEMETRY_BACKEND is set). OTEL's NodeSDK\n // is Node-only and incompatible with the edge runtime, so the telemetry\n // bootstrap \u2014 which can pull in the SDK \u2014 is imported only on the Node.js\n // runtime. The helper owns init + graceful degrade + shutdown flush.\n if (\n process.env.NEXT_RUNTIME === 'nodejs'\n && isTelemetryBackendEnabled()\n ) {\n const { registerTelemetryForNextjs } = await import('@open-mercato/telemetry/nextjs')\n await registerTelemetryForNextjs()\n }\n}\n`\n\nconst DISPATCHER_SNIPPET = ` // add near the other imports:\n import { getTelemetryRuntime } from '@open-mercato/shared/lib/telemetry/runtime'\n\n // in the dispatcher's success path, just before returning the response:\n getTelemetryRuntime()?.recordHttpDuration(method, match.route.path, finalResponse.status, startedAt)\n\n // in the dispatcher's catch (error) block, before re-throwing:\n getTelemetryRuntime()?.reportError(error, {\n attributes: { 'http.request.method': method, 'http.route': match.route.path, 'http.response.status_code': 500 },\n })\n getTelemetryRuntime()?.recordHttpDuration(method, match.route.path, 500, startedAt)`\n\nfunction parseArgs(args: string[]): TelemetryInitOptions {\n return {\n dryRun: args.includes('--dry-run') || args.includes('-n'),\n }\n}\n\n/** Read the version an app already pins its `@open-mercato/*` deps to (lockstep). */\nfunction resolveOpenMercatoVersion(pkg: Record<string, unknown>): string {\n for (const field of ['dependencies', 'devDependencies'] as const) {\n const deps = pkg[field]\n if (deps && typeof deps === 'object') {\n for (const [name, version] of Object.entries(deps as Record<string, string>)) {\n if (name.startsWith('@open-mercato/') && typeof version === 'string') return version\n }\n }\n }\n return '*'\n}\n\nfunction patchPackageJson(appDir: string, options: TelemetryInitOptions): StepResult {\n const file = 'package.json'\n const path = join(appDir, file)\n const raw = readFileSync(path, 'utf8')\n const pkg = JSON.parse(raw) as {\n dependencies?: Record<string, string>\n optionalDependencies?: Record<string, string>\n }\n const version = resolveOpenMercatoVersion(pkg)\n const hasTelemetry = Boolean(pkg.dependencies?.['@open-mercato/telemetry'])\n const hasBullmqOtel = Boolean(pkg.optionalDependencies?.['bullmq-otel'])\n if (hasTelemetry && hasBullmqOtel) {\n return { file, status: 'skipped', detail: '@open-mercato/telemetry already installed' }\n }\n\n const deps = { ...(pkg.dependencies ?? {}) }\n if (!hasTelemetry) deps['@open-mercato/telemetry'] = version\n const optDeps = { ...(pkg.optionalDependencies ?? {}) }\n if (!hasBullmqOtel) optDeps['bullmq-otel'] = BULLMQ_OTEL_VERSION\n\n const next = {\n ...pkg,\n dependencies: sortRecord(deps),\n optionalDependencies: sortRecord(optDeps),\n }\n if (!options.dryRun) writeFileSync(path, `${JSON.stringify(next, null, 2)}\\n`)\n return {\n file,\n status: 'patched',\n detail: `+@open-mercato/telemetry@${version}${hasBullmqOtel ? '' : ` +bullmq-otel@${BULLMQ_OTEL_VERSION} (optional)`} \u2014 run \\`yarn install\\``,\n }\n}\n\nfunction sortRecord(record: Record<string, string>): Record<string, string> {\n return Object.fromEntries(Object.entries(record).sort(([a], [b]) => a.localeCompare(b)))\n}\n\nfunction patchEnvFile(appDir: string, relativePath: string, options: TelemetryInitOptions): StepResult | null {\n const path = join(appDir, relativePath)\n if (!existsSync(path)) return null\n const content = readFileSync(path, 'utf8')\n if (content.includes('TELEMETRY_BACKEND')) {\n return { file: relativePath, status: 'skipped', detail: 'TELEMETRY_* block already present' }\n }\n const next = `${content.replace(/\\s*$/, '')}\\n${ENV_BLOCK}`\n if (!options.dryRun) writeFileSync(path, next)\n return { file: relativePath, status: 'patched', detail: 'appended commented TELEMETRY_* / OTEL_* block' }\n}\n\nfunction patchInstrumentation(appDir: string, options: TelemetryInitOptions): StepResult {\n const file = 'src/instrumentation.ts'\n const path = join(appDir, file)\n if (!existsSync(path)) {\n if (!options.dryRun) {\n mkdirSync(dirname(path), { recursive: true })\n writeFileSync(path, INSTRUMENTATION_TS)\n }\n return { file, status: 'created', detail: 'Node-runtime-guarded registerTelemetryForNextjs() bootstrap' }\n }\n const content = readFileSync(path, 'utf8')\n if (content.includes('registerTelemetryForNextjs')) {\n if (content.includes('isTelemetryBackendEnabled')) {\n return { file, status: 'skipped', detail: 'telemetry already wired' }\n }\n const migrated =\n `import { isTelemetryBackendEnabled } from '@open-mercato/shared/lib/telemetry/runtime'\\n` +\n content.replace(\n `if (process.env.NEXT_RUNTIME === 'nodejs') {`,\n `if (process.env.NEXT_RUNTIME === 'nodejs' && isTelemetryBackendEnabled()) {`,\n )\n if (!options.dryRun) writeFileSync(path, migrated)\n return { file, status: 'patched', detail: 'added the explicit backend import guard' }\n }\n const anchor = content.match(/export\\s+async\\s+function\\s+register\\s*\\([^)]*\\)\\s*:\\s*Promise<void>\\s*\\{/)\n if (!anchor || anchor.index === undefined) {\n return {\n file,\n status: 'manual',\n detail: 'register() not found \u2014 add the telemetry bootstrap manually',\n manualSnippet: INSTRUMENTATION_TS,\n }\n }\n const insertAt = anchor.index + anchor[0].length\n const block =\n `\\n // Initialize telemetry (no-op unless TELEMETRY_BACKEND is set); Node-only.` +\n `\\n if (process.env.NEXT_RUNTIME === 'nodejs' && isTelemetryBackendEnabled()) {` +\n `\\n const { registerTelemetryForNextjs } = await import('@open-mercato/telemetry/nextjs')` +\n `\\n await registerTelemetryForNextjs()` +\n `\\n }`\n const importLine = `import { isTelemetryBackendEnabled } from '@open-mercato/shared/lib/telemetry/runtime'\\n`\n const withImport = content.includes('isTelemetryBackendEnabled')\n ? content\n : importLine + content\n const shiftedInsertAt = insertAt + (withImport.length - content.length)\n const next = withImport.slice(0, shiftedInsertAt) + block + withImport.slice(shiftedInsertAt)\n if (!options.dryRun) writeFileSync(path, next)\n return { file, status: 'patched', detail: 'inserted registerTelemetryForNextjs() into register()' }\n}\n\nasync function patchNextConfig(appDir: string, options: TelemetryInitOptions): Promise<StepResult> {\n const file = 'next.config.ts'\n const path = join(appDir, file)\n if (!existsSync(path)) {\n return { file, status: 'manual', detail: 'next.config.ts not found', manualSnippet: nextConfigSnippet() }\n }\n // Use ts-morph to *detect* the real `serverExternalPackages` array literal\n // (robust against a match inside a comment/string), then do the *insertion*\n // via a formatting-preserving text splice so the user's config stays tidy.\n const { Project, SyntaxKind } = await import('ts-morph')\n const project = new Project({ skipAddingFilesFromTsConfig: true, skipFileDependencyResolution: true })\n const sf = project.addSourceFileAtPath(path)\n\n const telemetryConfigImport = sf\n .getImportDeclarations()\n .find((decl) => [\n '@open-mercato/telemetry/nextjs',\n '@open-mercato/telemetry/nextjs-config',\n ].includes(decl.getModuleSpecifierValue()))\n const hasImport = Boolean(telemetryConfigImport)\n const hasCanonicalImport =\n telemetryConfigImport?.getModuleSpecifierValue() === '@open-mercato/telemetry/nextjs-config'\n\n const arrayProp = sf\n .getDescendantsOfKind(SyntaxKind.PropertyAssignment)\n .find((prop) => prop.getName() === 'serverExternalPackages')\n const arrayInit = arrayProp?.getInitializerIfKind(SyntaxKind.ArrayLiteralExpression)\n if (!arrayInit) {\n return {\n file,\n status: 'manual',\n detail: 'serverExternalPackages array not found',\n manualSnippet: nextConfigSnippet(),\n }\n }\n const hasSpread = arrayInit.getElements().some((el) => el.getText().includes('telemetryServerExternalPackages'))\n if (hasCanonicalImport && hasSpread) {\n return { file, status: 'skipped', detail: 'telemetryServerExternalPackages already wired' }\n }\n\n let text = readFileSync(path, 'utf8')\n // Splice the array first, using the AST node's byte offsets (formatting-agnostic:\n // handles both single-line and multi-line arrays). Do this before modifying\n // imports, because either an inserted import or the legacy import migration\n // shifts the array offsets captured from the original source.\n if (!hasSpread) {\n const start = arrayInit.getStart()\n const end = arrayInit.getEnd()\n text = text.slice(0, start) + insertSpread(text.slice(start, end)) + text.slice(end)\n }\n text = text.replace(\n \"from '@open-mercato/telemetry/nextjs'\",\n \"from '@open-mercato/telemetry/nextjs-config'\",\n )\n if (!hasImport) {\n const importRegex = /^import[^\\n]*$/gm\n let lastImport: RegExpExecArray | null = null\n let match: RegExpExecArray | null\n while ((match = importRegex.exec(text)) !== null) lastImport = match\n const insertAt = lastImport ? lastImport.index + lastImport[0].length : 0\n text =\n text.slice(0, insertAt) +\n `\\nimport { telemetryServerExternalPackages } from '@open-mercato/telemetry/nextjs-config'` +\n text.slice(insertAt)\n }\n if (!options.dryRun) writeFileSync(path, text)\n return { file, status: 'patched', detail: 'spread telemetryServerExternalPackages into serverExternalPackages' }\n}\n\n/** Add `...telemetryServerExternalPackages` as the last element of an array literal, preserving its style. */\nfunction insertSpread(arrayText: string): string {\n const inner = arrayText.slice(1, -1)\n if (inner.includes('\\n')) {\n const elementIndent = inner.match(/\\n([ \\t]+)\\S/)?.[1] ?? ' '\n const closeIndent = arrayText.match(/\\n([ \\t]*)\\]$/)?.[1] ?? ''\n const trimmed = inner.replace(/\\s*$/, '')\n const separator = trimmed === '' || trimmed.endsWith(',') ? '' : ','\n return `[${trimmed}${separator}\\n${elementIndent}...telemetryServerExternalPackages,\\n${closeIndent}]`\n }\n const flat = inner.trim()\n return flat === '' ? '[...telemetryServerExternalPackages]' : `[${flat}, ...telemetryServerExternalPackages]`\n}\n\nfunction nextConfigSnippet(): string {\n return (\n `import { telemetryServerExternalPackages } from '@open-mercato/telemetry/nextjs-config'\\n` +\n `// serverExternalPackages: [ ...existing, ...telemetryServerExternalPackages ]`\n )\n}\n\n/**\n * Auto-patch the catch-all API dispatcher \u2014 but only when it still matches the\n * known scaffold shape (all anchors present, telemetry not yet wired). On any\n * mismatch, print the snippet and mark it manual rather than editing an\n * unrecognized (customized) handler.\n */\nfunction patchDispatcher(appDir: string, options: TelemetryInitOptions): StepResult {\n const file = 'src/app/api/[...slug]/route.ts'\n const path = join(appDir, file)\n if (!existsSync(path)) {\n return { file, status: 'manual', detail: 'dispatcher not found', manualSnippet: DISPATCHER_SNIPPET }\n }\n let content = readFileSync(path, 'utf8')\n if (\n content.includes(\"from '@open-mercato/shared/lib/telemetry/runtime'\")\n && content.includes('getTelemetryRuntime()?.recordHttpDuration')\n ) {\n return { file, status: 'skipped', detail: 'telemetry already wired' }\n }\n if (\n content.includes(\"import { reportError } from '@open-mercato/telemetry'\")\n && content.includes(\"import { recordHttpDuration } from '@open-mercato/telemetry/nextjs'\")\n ) {\n content = content\n .replace(\n \"import { reportError } from '@open-mercato/telemetry'\\nimport { recordHttpDuration } from '@open-mercato/telemetry/nextjs'\",\n \"import { getTelemetryRuntime } from '@open-mercato/shared/lib/telemetry/runtime'\",\n )\n .replace(/\\brecordHttpDuration\\(/g, 'getTelemetryRuntime()?.recordHttpDuration(')\n .replace(/\\breportError\\(/g, 'getTelemetryRuntime()?.reportError(')\n if (!options.dryRun) writeFileSync(path, content)\n return { file, status: 'patched', detail: 'migrated dispatcher to the default-off runtime bridge' }\n }\n\n const importAnchor = \"import { isCrudHttpError } from '@open-mercato/shared/lib/crud/errors'\"\n const returnMatch = content.match(/^([ \\t]*)return finalResponse\\s*$/m)\n // The handleRequest catch is the first `} catch (error) {` after the success return.\n const catchRegex = /^([ \\t]*)\\}\\s*catch\\s*\\(error\\)\\s*\\{[ \\t]*$/gm\n const catchMatch = findCatchAfter(content, catchRegex, returnMatch?.index ?? -1)\n\n if (!content.includes(importAnchor) || !returnMatch || returnMatch.index === undefined || !catchMatch) {\n return {\n file,\n status: 'manual',\n detail: 'dispatcher shape not recognized \u2014 apply the snippet by hand',\n manualSnippet: DISPATCHER_SNIPPET,\n }\n }\n\n // 1) imports\n content = content.replace(\n importAnchor,\n `${importAnchor}\\nimport { getTelemetryRuntime } from '@open-mercato/shared/lib/telemetry/runtime'`,\n )\n\n // 2) success-path metric (re-match after the import edit shifted offsets)\n const ret = content.match(/^([ \\t]*)return finalResponse\\s*$/m)\n if (!ret || ret.index === undefined) {\n return { file, status: 'manual', detail: 'success-path anchor lost', manualSnippet: DISPATCHER_SNIPPET }\n }\n const retIndent = ret[1]\n content =\n content.slice(0, ret.index) +\n `${retIndent}getTelemetryRuntime()?.recordHttpDuration(method, match.route.path, finalResponse.status, startedAt)\\n` +\n content.slice(ret.index)\n\n // 3) catch-block error funnel + 500 metric\n const catch2 = findCatchAfter(content, /^([ \\t]*)\\}\\s*catch\\s*\\(error\\)\\s*\\{[ \\t]*$/gm, content.indexOf('return finalResponse'))\n if (!catch2) {\n return { file, status: 'manual', detail: 'catch anchor lost', manualSnippet: DISPATCHER_SNIPPET }\n }\n const bodyIndent = `${catch2.indent} `\n const insertAt = catch2.index + catch2.length\n const block =\n `\\n${bodyIndent}getTelemetryRuntime()?.reportError(error, {` +\n `\\n${bodyIndent} attributes: { 'http.request.method': method, 'http.route': match.route.path, 'http.response.status_code': 500 },` +\n `\\n${bodyIndent}})` +\n `\\n${bodyIndent}getTelemetryRuntime()?.recordHttpDuration(method, match.route.path, 500, startedAt)`\n content = content.slice(0, insertAt) + block + content.slice(insertAt)\n\n if (!options.dryRun) writeFileSync(path, content)\n return { file, status: 'patched', detail: 'wired reportError (5xx) + http.server.request.duration metric' }\n}\n\nfunction findCatchAfter(\n content: string,\n regex: RegExp,\n afterIndex: number,\n): { index: number; length: number; indent: string } | null {\n regex.lastIndex = 0\n let match: RegExpExecArray | null\n while ((match = regex.exec(content)) !== null) {\n if (match.index > afterIndex) {\n return { index: match.index, length: match[0].length, indent: match[1] }\n }\n }\n return null\n}\n\nexport async function runTelemetryInit(args: string[]): Promise<number> {\n const appDir = resolve('.')\n const options = parseArgs(args)\n\n if (!existsSync(join(appDir, 'src', 'modules.ts'))) {\n console.error('\u274C Not an Open Mercato app directory (src/modules.ts not found)')\n return 1\n }\n if (!existsSync(join(appDir, 'package.json'))) {\n console.error('\u274C package.json not found')\n return 1\n }\n\n console.log('')\n console.log(options.dryRun ? '\uD83D\uDD2D Telemetry init (dry run \u2014 no files written)\\n' : '\uD83D\uDD2D Wiring @open-mercato/telemetry into this app\\n')\n\n const results: StepResult[] = []\n results.push(patchPackageJson(appDir, options))\n const envExample = patchEnvFile(appDir, '.env.example', options)\n if (envExample) results.push(envExample)\n const env = patchEnvFile(appDir, '.env', options)\n if (env) results.push(env)\n results.push(patchInstrumentation(appDir, options))\n results.push(await patchNextConfig(appDir, options))\n results.push(patchDispatcher(appDir, options))\n\n const icon: Record<StepStatus, string> = { created: '\u270D\uFE0F ', patched: '\u2705', skipped: '\u23ED\uFE0F ', manual: '\u26A0\uFE0F ' }\n for (const result of results) {\n console.log(`${icon[result.status]} ${result.file} \u2014 ${result.detail}`)\n }\n\n const manual = results.filter((result) => result.status === 'manual')\n for (const result of manual) {\n if (!result.manualSnippet) continue\n console.log('')\n console.log(`\u2500\u2500 manual step for ${result.file} \u2500\u2500`)\n console.log(result.manualSnippet)\n }\n\n console.log('')\n const changed = results.some((result) => result.status === 'patched' || result.status === 'created')\n if (options.dryRun) {\n console.log('Dry run complete \u2014 re-run without --dry-run to apply.')\n } else if (changed) {\n console.log('Next steps:')\n console.log(' 1. yarn install (resolve @open-mercato/telemetry + the OTEL SDK)')\n console.log(' 2. set TELEMETRY_BACKEND + OTEL_EXPORTER_OTLP_* in .env')\n console.log(' 3. yarn typecheck && yarn build (verify the wiring)')\n } else {\n console.log('Nothing to do \u2014 telemetry is already wired.')\n }\n if (manual.length > 0) {\n console.log('')\n console.log(`\u26A0\uF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