@open-mercato/cli 0.6.7 → 0.6.8-develop.6875.1.871a4afc94

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 +24 -7
  3. package/dist/agentic/claude-code/hooks/entity-migration-check.ts +32 -88
  4. package/dist/agentic/codex/enforcement-rules.md +2 -16
  5. package/dist/agentic/cursor/hooks/entity-migration-check.mjs +19 -50
  6. package/dist/agentic/cursor/rules/entity-guard.mdc +9 -21
  7. package/dist/agentic/cursor/rules/generated-guard.mdc +3 -5
  8. package/dist/agentic/cursor/rules/open-mercato.mdc +3 -29
  9. package/dist/agentic/guides/ai-workflows.md +76 -0
  10. package/dist/agentic/guides/architecture.md +107 -0
  11. package/dist/agentic/guides/backend-ui.md +80 -0
  12. package/dist/agentic/guides/contracts.md +92 -0
  13. package/dist/agentic/guides/extensions.md +121 -0
  14. package/dist/agentic/guides/framework-extension-points.md +36 -0
  15. package/dist/agentic/guides/integrations.md +81 -0
  16. package/dist/agentic/guides/module-facts.json +115537 -3951
  17. package/dist/agentic/guides/module-system.md +12 -127
  18. package/dist/agentic/guides/modules/ai_assistant.md +227 -28
  19. package/dist/agentic/guides/modules/api_docs.md +58 -2
  20. package/dist/agentic/guides/modules/api_keys.md +92 -7
  21. package/dist/agentic/guides/modules/attachments.md +119 -14
  22. package/dist/agentic/guides/modules/audit_logs.md +131 -10
  23. package/dist/agentic/guides/modules/auth.md +276 -33
  24. package/dist/agentic/guides/modules/business_rules.md +149 -14
  25. package/dist/agentic/guides/modules/catalog.md +475 -43
  26. package/dist/agentic/guides/modules/channel_gmail.md +82 -3
  27. package/dist/agentic/guides/modules/channel_imap.md +82 -3
  28. package/dist/agentic/guides/modules/checkout.md +299 -27
  29. package/dist/agentic/guides/modules/communication_channels.md +315 -33
  30. package/dist/agentic/guides/modules/configs.md +104 -8
  31. package/dist/agentic/guides/modules/content.md +57 -2
  32. package/dist/agentic/guides/modules/currencies.md +152 -17
  33. package/dist/agentic/guides/modules/customer_accounts.md +387 -45
  34. package/dist/agentic/guides/modules/customers.md +746 -85
  35. package/dist/agentic/guides/modules/dashboards.md +155 -10
  36. package/dist/agentic/guides/modules/data_sync.md +149 -16
  37. package/dist/agentic/guides/modules/design_system.md +102 -0
  38. package/dist/agentic/guides/modules/dictionaries.md +107 -12
  39. package/dist/agentic/guides/modules/directory.md +148 -15
  40. package/dist/agentic/guides/modules/entities.md +145 -13
  41. package/dist/agentic/guides/modules/events.md +59 -2
  42. package/dist/agentic/guides/modules/feature_toggles.md +119 -9
  43. package/dist/agentic/guides/modules/gateway_stripe.md +92 -4
  44. package/dist/agentic/guides/modules/generators.md +45 -2
  45. package/dist/agentic/guides/modules/inbox_ops.md +207 -27
  46. package/dist/agentic/guides/modules/integrations.md +146 -16
  47. package/dist/agentic/guides/modules/messages.md +223 -24
  48. package/dist/agentic/guides/modules/notifications.md +96 -8
  49. package/dist/agentic/guides/modules/onboarding.md +77 -6
  50. package/dist/agentic/guides/modules/payment_gateways.md +164 -21
  51. package/dist/agentic/guides/modules/perspectives.md +77 -7
  52. package/dist/agentic/guides/modules/planner.md +136 -18
  53. package/dist/agentic/guides/modules/portal.md +93 -2
  54. package/dist/agentic/guides/modules/progress.md +104 -14
  55. package/dist/agentic/guides/modules/query_index.md +154 -15
  56. package/dist/agentic/guides/modules/record_locks.md +206 -21
  57. package/dist/agentic/guides/modules/resources.md +197 -30
  58. package/dist/agentic/guides/modules/sales.md +678 -84
  59. package/dist/agentic/guides/modules/scheduler.md +133 -14
  60. package/dist/agentic/guides/modules/search.md +170 -6
  61. package/dist/agentic/guides/modules/security.md +294 -35
  62. package/dist/agentic/guides/modules/shipping_carriers.md +134 -18
  63. package/dist/agentic/guides/modules/sso.md +151 -26
  64. package/dist/agentic/guides/modules/staff.md +369 -57
  65. package/dist/agentic/guides/modules/storage_s3.md +95 -5
  66. package/dist/agentic/guides/modules/sync_akeneo.md +85 -3
  67. package/dist/agentic/guides/modules/sync_excel.md +75 -6
  68. package/dist/agentic/guides/modules/system_status_overlays.md +60 -2
  69. package/dist/agentic/guides/modules/translations.md +104 -10
  70. package/dist/agentic/guides/modules/webhooks.md +203 -24
  71. package/dist/agentic/guides/modules/wms.md +441 -46
  72. package/dist/agentic/guides/modules/workflows.md +302 -43
  73. package/dist/agentic/guides/spec-delivery.md +22 -0
  74. package/dist/agentic/guides/testing-debugging.md +80 -0
  75. package/dist/agentic/guides/upstream/AGENTS.md +299 -0
  76. package/dist/agentic/guides/upstream/BACKWARD_COMPATIBILITY.md +316 -0
  77. package/dist/agentic/guides/upstream/manifest.json +8 -0
  78. package/dist/agentic/shared/AGENTS.md.template +124 -311
  79. package/dist/agentic/shared/ai/agentic.config.json +2 -0
  80. package/dist/agentic/shared/ai/harness/README.md +50 -0
  81. package/dist/agentic/shared/ai/harness/RELEASE.md +57 -0
  82. package/dist/agentic/shared/ai/harness/cases.json +13680 -0
  83. package/dist/agentic/shared/ai/harness/cases.schema.json +133 -0
  84. package/dist/agentic/shared/ai/harness/fixtures/index.json +49 -0
  85. package/dist/agentic/shared/ai/harness/fixtures/seeds.json +162 -0
  86. package/dist/agentic/shared/ai/harness/generated-code-review-policy.md +21 -0
  87. package/dist/agentic/shared/ai/harness/generated-code-review-response.schema.json +96 -0
  88. package/dist/agentic/shared/ai/harness/generated-code-review-result.schema.json +172 -0
  89. package/dist/agentic/shared/ai/harness/release-matrix.json +158 -0
  90. package/dist/agentic/shared/ai/harness/release-result.schema.json +219 -0
  91. package/dist/agentic/shared/ai/harness/result.schema.json +76 -0
  92. package/dist/agentic/shared/ai/harness/routing-response.schema.json +12 -0
  93. package/dist/agentic/shared/ai/harness/target-validation-result.schema.json +73 -0
  94. package/dist/agentic/shared/ai/harness/validators.json +78 -0
  95. package/dist/agentic/shared/ai/harness/writable-ast-oracles.mjs +2121 -0
  96. package/dist/agentic/shared/ai/harness/writable-behavior-oracles.mjs +1096 -0
  97. package/dist/agentic/shared/ai/lessons/_template.md +16 -0
  98. package/dist/agentic/shared/ai/lessons.md +26 -3
  99. package/dist/agentic/shared/ai/review-checklist.md +36 -0
  100. package/dist/agentic/shared/ai/skills/om-auto-implement-spec/SKILL.md +21 -0
  101. package/dist/agentic/shared/ai/skills/om-auto-review-pr/SKILL.md +4 -0
  102. package/dist/agentic/shared/ai/skills/om-auto-upgrade-0.6.6-to-0.6.7/SKILL.md +98 -0
  103. package/dist/agentic/shared/ai/skills/om-backend-ui-design/SKILL.md +20 -241
  104. package/dist/agentic/shared/ai/skills/om-backend-ui-design/references/crud-surfaces.md +16 -0
  105. package/dist/agentic/shared/ai/skills/om-backend-ui-design/references/frontend-and-design-system.md +53 -0
  106. package/dist/agentic/shared/ai/skills/om-backend-ui-design/references/page-and-navigation.md +13 -0
  107. package/dist/agentic/shared/ai/skills/om-backend-ui-design/references/quality-states.md +11 -0
  108. package/dist/agentic/shared/ai/skills/om-build-workflow/SKILL.md +30 -0
  109. package/dist/agentic/shared/ai/skills/om-build-workflow/references/activity-contracts.md +12 -0
  110. package/dist/agentic/shared/ai/skills/om-build-workflow/references/durability-and-progress.md +13 -0
  111. package/dist/agentic/shared/ai/skills/om-build-workflow/references/workflow-design.md +14 -0
  112. package/dist/agentic/shared/ai/skills/om-create-ai-agent/SKILL.md +28 -0
  113. package/dist/agentic/shared/ai/skills/om-create-ai-agent/references/attachments-and-overrides.md +12 -0
  114. package/dist/agentic/shared/ai/skills/om-create-ai-agent/references/module-agents-and-tools.md +22 -0
  115. package/dist/agentic/shared/ai/skills/om-create-ai-agent/references/orchestrator-agents.md +12 -0
  116. package/dist/agentic/shared/ai/skills/om-create-ai-agent/references/surface-selector.md +19 -0
  117. package/dist/agentic/shared/ai/skills/om-data-model-design/SKILL.md +16 -601
  118. package/dist/agentic/shared/ai/skills/om-data-model-design/references/integrity-and-concurrency.md +19 -0
  119. package/dist/agentic/shared/ai/skills/om-data-model-design/references/migration-workflow.md +13 -0
  120. package/dist/agentic/shared/ai/skills/om-data-model-design/references/schema-design.md +14 -0
  121. package/dist/agentic/shared/ai/skills/om-data-model-design/references/sensitive-data.md +10 -0
  122. package/dist/agentic/shared/ai/skills/om-eject-and-customize/SKILL.md +14 -310
  123. package/dist/agentic/shared/ai/skills/om-eject-and-customize/references/decision-and-procedure.md +17 -0
  124. package/dist/agentic/shared/ai/skills/om-evolve-harness/SKILL.md +29 -0
  125. package/dist/agentic/shared/ai/skills/om-evolve-harness/references/case-template.md +100 -0
  126. package/dist/agentic/shared/ai/skills/om-evolve-harness/references/case-workflow.md +16 -0
  127. package/dist/agentic/shared/ai/skills/om-evolve-harness/references/owner-selection.md +17 -0
  128. package/dist/agentic/shared/ai/skills/om-framework-context/SKILL.md +25 -0
  129. package/dist/agentic/shared/ai/skills/om-framework-context/references/resolver-procedure.md +11 -0
  130. package/dist/agentic/shared/ai/skills/om-framework-context/references/skew-and-escalation.md +13 -0
  131. package/dist/agentic/shared/ai/skills/om-help/SKILL.md +15 -97
  132. package/dist/agentic/shared/ai/skills/om-help/references/delivery-workflows.md +18 -0
  133. package/dist/agentic/shared/ai/skills/om-help/references/task-families.md +20 -0
  134. package/dist/agentic/shared/ai/skills/om-implement-spec/SKILL.md +33 -152
  135. package/dist/agentic/shared/ai/skills/om-implement-spec/references/phases-and-gates.md +33 -0
  136. package/dist/agentic/shared/ai/skills/om-implement-spec/references/planning-and-progress.md +40 -0
  137. package/dist/agentic/shared/ai/skills/om-implement-spec/references/report-templates.md +27 -0
  138. package/dist/agentic/shared/ai/skills/om-implement-spec/references/spec-resolution.md +24 -0
  139. package/dist/agentic/shared/ai/skills/om-integration-builder/SKILL.md +24 -708
  140. package/dist/agentic/shared/ai/skills/om-integration-builder/references/package-and-activation.md +16 -0
  141. package/dist/agentic/shared/ai/skills/om-integration-builder/references/provider-families.md +14 -0
  142. package/dist/agentic/shared/ai/skills/om-integration-builder/references/security-and-reliability.md +15 -0
  143. package/dist/agentic/shared/ai/skills/om-integration-builder/references/sync-and-files.md +12 -0
  144. package/dist/agentic/shared/ai/skills/om-judge-agent-session/SKILL.md +34 -0
  145. package/dist/agentic/shared/ai/skills/om-judge-agent-session/agents/openai.yaml +4 -0
  146. package/dist/agentic/shared/ai/skills/om-judge-agent-session/references/agentic-setup.md +11 -0
  147. package/dist/agentic/shared/ai/skills/om-judge-agent-session/references/input-normalization.md +31 -0
  148. package/dist/agentic/shared/ai/skills/om-judge-agent-session/references/judge-workflow.md +39 -0
  149. package/dist/agentic/shared/ai/skills/om-judge-agent-session/references/report-template.md +43 -0
  150. package/dist/agentic/shared/ai/skills/om-judge-agent-session/references/rules.md +11 -0
  151. package/dist/agentic/shared/ai/skills/om-module-scaffold/SKILL.md +20 -820
  152. package/dist/agentic/shared/ai/skills/om-module-scaffold/references/api-and-domain.md +19 -0
  153. package/dist/agentic/shared/ai/skills/om-module-scaffold/references/business-one-shot-blueprints.md +172 -0
  154. package/dist/agentic/shared/ai/skills/om-module-scaffold/references/data-and-migrations.md +12 -0
  155. package/dist/agentic/shared/ai/skills/om-module-scaffold/references/discovery-surface-catalog.md +83 -0
  156. package/dist/agentic/shared/ai/skills/om-module-scaffold/references/module-surfaces.md +21 -0
  157. package/dist/agentic/shared/ai/skills/om-module-scaffold/references/planning.md +11 -0
  158. package/dist/agentic/shared/ai/skills/om-module-scaffold/references/runtime-cache-and-queues.md +22 -0
  159. package/dist/agentic/shared/ai/skills/om-module-scaffold/references/verification.md +13 -0
  160. package/dist/agentic/shared/ai/skills/om-share-this-session/SKILL.md +41 -0
  161. package/dist/agentic/shared/ai/skills/om-share-this-session/references/agentic-setup.md +19 -0
  162. package/dist/agentic/shared/ai/skills/om-share-this-session/references/bundle-preparation.md +44 -0
  163. package/dist/agentic/shared/ai/skills/om-share-this-session/references/consent-and-review.md +39 -0
  164. package/dist/agentic/shared/ai/skills/om-share-this-session/references/publication.md +20 -0
  165. package/dist/agentic/shared/ai/skills/om-share-this-session/references/report-templates.md +57 -0
  166. package/dist/agentic/shared/ai/skills/om-share-this-session/references/rules.md +11 -0
  167. package/dist/agentic/shared/ai/skills/om-share-this-session/scripts/prepare-share-bundle.mjs +486 -0
  168. package/dist/agentic/shared/ai/skills/om-system-extension/SKILL.md +19 -843
  169. package/dist/agentic/shared/ai/skills/om-system-extension/references/extension-branches.md +18 -0
  170. package/dist/agentic/shared/ai/skills/om-system-extension/references/mechanism-selector.md +27 -0
  171. package/dist/agentic/shared/ai/skills/om-system-extension/references/read-write-roundtrip.md +13 -0
  172. package/dist/agentic/shared/ai/skills/om-system-extension/references/unified-overrides.md +41 -0
  173. package/dist/agentic/shared/ai/skills/om-system-extension/references/verification.md +11 -0
  174. package/dist/agentic/shared/ai/skills/om-trim-unused-modules/SKILL.md +15 -63
  175. package/dist/agentic/shared/ai/skills/om-trim-unused-modules/references/dependency-and-redirect.md +15 -0
  176. package/dist/agentic/shared/ai/skills/om-troubleshooter/SKILL.md +16 -467
  177. package/dist/agentic/shared/ai/skills/om-troubleshooter/references/diagnosis-map.md +16 -0
  178. package/dist/agentic/shared/ai/skills/om-troubleshooter/references/regression-oracles.md +14 -0
  179. package/dist/agentic/shared/ai/skills/tiers.json +143 -21
  180. package/dist/agentic/shared/ai/skills/tiers.schema.json +52 -40
  181. package/dist/agentic/shared/ai/specs/README.md +4 -3
  182. package/dist/agentic/shared/ai/specs/SPEC-000-template.md +226 -10
  183. package/dist/agentic/shared/ai/trackers/github.md +108 -4
  184. package/dist/agentic/shared/scripts/agent-harness-tool-server.mjs +187 -0
  185. package/dist/agentic/shared/scripts/check-lessons.mjs +178 -0
  186. package/dist/agentic/shared/scripts/evaluate-agent-harness.mjs +2958 -0
  187. package/dist/agentic/shared/scripts/execution-sandbox.mjs +329 -0
  188. package/dist/agentic/shared/scripts/framework-context.mjs +888 -0
  189. package/dist/agentic/shared/scripts/install-skills.mjs +1029 -0
  190. package/dist/agentic/shared/scripts/install-skills.sh +4 -694
  191. package/dist/agentic/shared/scripts/prepare-agent-harness-fixture.mjs +222 -0
  192. package/dist/agentic/shared/scripts/run-agent-harness-release.mjs +1774 -0
  193. package/dist/bin.js +13 -1
  194. package/dist/bin.js.map +2 -2
  195. package/dist/lib/__integration__/TC-INT-008.spec.js +88 -8
  196. package/dist/lib/__integration__/TC-INT-008.spec.js.map +2 -2
  197. package/dist/lib/agentic-init.js +13 -3
  198. package/dist/lib/agentic-init.js.map +2 -2
  199. package/dist/lib/agentic-setup.js +434 -186
  200. package/dist/lib/agentic-setup.js.map +2 -2
  201. package/dist/lib/generators/extensions/injection-widgets.js +20 -0
  202. package/dist/lib/generators/extensions/injection-widgets.js.map +2 -2
  203. package/dist/lib/generators/module-extension-facts.js +1840 -0
  204. package/dist/lib/generators/module-extension-facts.js.map +7 -0
  205. package/dist/lib/generators/module-fact-sources.js +70 -0
  206. package/dist/lib/generators/module-fact-sources.js.map +7 -0
  207. package/dist/lib/generators/module-facts-discovery.js +41 -7
  208. package/dist/lib/generators/module-facts-discovery.js.map +2 -2
  209. package/dist/lib/generators/module-facts.js +1387 -45
  210. package/dist/lib/generators/module-facts.js.map +3 -3
  211. package/dist/lib/generators/module-override-targets.js +688 -0
  212. package/dist/lib/generators/module-override-targets.js.map +7 -0
  213. package/dist/lib/generators/module-registry.js +11 -5
  214. package/dist/lib/generators/module-registry.js.map +2 -2
  215. package/dist/lib/load-env.js +24 -0
  216. package/dist/lib/load-env.js.map +7 -0
  217. package/dist/lib/resolver.js +2 -0
  218. package/dist/lib/resolver.js.map +2 -2
  219. package/dist/lib/telemetry-init.js +358 -0
  220. package/dist/lib/telemetry-init.js.map +7 -0
  221. package/dist/lib/testing/integration.js +5 -0
  222. package/dist/lib/testing/integration.js.map +2 -2
  223. package/dist/mercato.js +23 -1
  224. package/dist/mercato.js.map +2 -2
  225. package/package.json +13 -11
  226. package/src/bin.ts +33 -1
  227. package/src/lib/__integration__/TC-INT-008.spec.ts +107 -9
  228. package/src/lib/__tests__/agentic-init.test.ts +41 -5
  229. package/src/lib/__tests__/agentic-setup.ownership.test.ts +386 -0
  230. package/src/lib/__tests__/injection-widget-id-validation.test.ts +184 -0
  231. package/src/lib/__tests__/load-env.test.ts +65 -0
  232. package/src/lib/__tests__/telemetry-init.test.ts +298 -0
  233. package/src/lib/agentic-init.ts +15 -3
  234. package/src/lib/agentic-setup.ts +573 -222
  235. package/src/lib/generators/__tests__/activation-adapter-coverage.test.ts +92 -0
  236. package/src/lib/generators/__tests__/module-extension-activations.test.ts +762 -0
  237. package/src/lib/generators/__tests__/module-extension-facts.test.ts +404 -0
  238. package/src/lib/generators/__tests__/module-facts.bc-guard.test.ts +88 -2
  239. package/src/lib/generators/__tests__/module-facts.customers.fixture.test.ts +1 -0
  240. package/src/lib/generators/__tests__/module-facts.discovery.test.ts +54 -10
  241. package/src/lib/generators/__tests__/module-facts.extension-hosts.test.ts +108 -0
  242. package/src/lib/generators/__tests__/module-facts.owned-contracts.test.ts +561 -0
  243. package/src/lib/generators/__tests__/module-facts.source-links.test.ts +119 -0
  244. package/src/lib/generators/__tests__/module-override-targets.roundtrip.test.ts +149 -0
  245. package/src/lib/generators/__tests__/module-override-targets.test.ts +304 -0
  246. package/src/lib/generators/__tests__/module-subset.test.ts +18 -0
  247. package/src/lib/generators/extensions/injection-widgets.ts +51 -0
  248. package/src/lib/generators/module-extension-facts.ts +2365 -0
  249. package/src/lib/generators/module-fact-sources.ts +108 -0
  250. package/src/lib/generators/module-facts-discovery.ts +58 -7
  251. package/src/lib/generators/module-facts.ts +1851 -46
  252. package/src/lib/generators/module-override-targets.ts +863 -0
  253. package/src/lib/generators/module-registry.ts +16 -6
  254. package/src/lib/load-env.ts +30 -0
  255. package/src/lib/resolver.ts +3 -0
  256. package/src/lib/telemetry-init.ts +461 -0
  257. package/src/lib/testing/__tests__/integration.test.ts +4 -0
  258. package/src/lib/testing/integration.ts +5 -0
  259. package/src/mercato.ts +26 -1
  260. package/dist/agentic/guides/cache.md +0 -45
  261. package/dist/agentic/guides/core.md +0 -453
  262. package/dist/agentic/guides/events.md +0 -117
  263. package/dist/agentic/guides/queue.md +0 -53
  264. package/dist/agentic/guides/search.md +0 -115
  265. package/dist/agentic/guides/shared.md +0 -108
  266. package/dist/agentic/guides/ui.md +0 -347
  267. package/dist/agentic/shared/ai/skills/om-auto-continue-pr-loop/SKILL.md +0 -27
  268. package/dist/agentic/shared/ai/skills/om-auto-create-pr-loop/SKILL.md +0 -27
  269. package/dist/agentic/shared/ai/skills/om-backend-ui-design/references/ui-components.md +0 -260
  270. package/dist/agentic/shared/ai/skills/om-data-model-design/references/mikro-orm-cheatsheet.md +0 -146
  271. package/dist/agentic/shared/ai/skills/om-help/references/skills-catalog.md +0 -84
  272. package/dist/agentic/shared/ai/skills/om-help/references/workflow-sequences.md +0 -193
  273. package/dist/agentic/shared/ai/skills/om-integration-builder/STANDALONE.md +0 -34
  274. package/dist/agentic/shared/ai/skills/om-integration-builder/references/adapter-contracts.md +0 -762
  275. package/dist/agentic/shared/ai/skills/om-module-scaffold/references/naming-conventions.md +0 -50
  276. package/dist/agentic/shared/ai/skills/om-module-scaffold/references/navigation-patterns.md +0 -97
  277. package/dist/agentic/shared/ai/skills/om-system-extension/references/extension-contracts.md +0 -271
  278. package/dist/agentic/shared/ai/skills/om-troubleshooter/references/diagnostic-commands.md +0 -101
package/dist/bin.js CHANGED
@@ -1,5 +1,8 @@
1
1
  #!/usr/bin/env node
2
- import { run } from "./mercato.js";
2
+ import {
3
+ getTelemetryRuntime,
4
+ isTelemetryBackendEnabled
5
+ } from "@open-mercato/shared/lib/telemetry/runtime";
3
6
  const BOOTSTRAP_FREE_COMMANDS = [
4
7
  "generate",
5
8
  "module",
@@ -7,6 +10,7 @@ const BOOTSTRAP_FREE_COMMANDS = [
7
10
  "db",
8
11
  "init",
9
12
  "agentic:init",
13
+ "telemetry",
10
14
  "eject",
11
15
  "test",
12
16
  "test:integration",
@@ -62,6 +66,12 @@ async function main() {
62
66
  assertNode24Runtime();
63
67
  const requiresBootstrap = needsBootstrap(process.argv);
64
68
  if (requiresBootstrap) {
69
+ const { loadAppEnv } = await import("./lib/load-env.js");
70
+ await loadAppEnv();
71
+ if (isTelemetryBackendEnabled()) {
72
+ const { initTelemetry } = await import("@open-mercato/telemetry");
73
+ await initTelemetry();
74
+ }
65
75
  const bootstrapSucceeded = await tryBootstrap();
66
76
  if (!bootstrapSucceeded) {
67
77
  console.error("\u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557");
@@ -76,7 +86,9 @@ async function main() {
76
86
  process.exit(1);
77
87
  }
78
88
  }
89
+ const { run } = await import("./mercato.js");
79
90
  const code = await run(process.argv);
91
+ await getTelemetryRuntime()?.shutdown();
80
92
  process.exit(code ?? 0);
81
93
  }
82
94
  main().catch((error) => {
package/dist/bin.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/bin.ts"],
4
- "sourcesContent": ["/**\n * CLI binary entry point for @open-mercato/cli package.\n *\n * Called from within a Next.js app directory as: yarn mercato <command>\n * Uses dynamic app resolution to find generated files at .mercato/generated/\n */\nimport { run } from './mercato.js'\n\n// Commands that can run without bootstrap (without generated files)\n// - generate: creates the generated files\n// - db: uses resolver directly to find modules and migrations\n// - init: runs yarn commands to set up the app\n// - help: just shows help text\nconst BOOTSTRAP_FREE_COMMANDS = [\n 'generate',\n 'module',\n 'deploy',\n 'db',\n 'init',\n 'agentic:init',\n 'eject',\n 'test',\n 'test:integration',\n 'test:integration:coverage',\n 'test:integration:spec-coverage',\n 'test:ephemeral',\n 'test:integration:interactive',\n 'umes:list',\n 'umes:inspect',\n 'umes:check',\n 'help',\n '--help',\n '-h',\n]\n\nfunction assertNode24Runtime(): void {\n const detectedNodeVersion = process.versions.node\n const majorVersion = Number.parseInt(detectedNodeVersion.split('.')[0] ?? '0', 10)\n if (majorVersion >= 24) {\n return\n }\n throw new Error(\n [\n 'Unsupported Node.js runtime.',\n `Cause: Detected Node ${detectedNodeVersion}, but Open Mercato requires Node 24.x.`,\n 'What to do: switch your shell to Node 24 (for example `nvm use 24`), run `yarn install`, then retry.',\n ].join(' '),\n )\n}\n\nfunction needsBootstrap(argv: string[]): boolean {\n const [, , first] = argv\n if (!first) return false // help screen\n return !BOOTSTRAP_FREE_COMMANDS.includes(first)\n}\n\nasync function tryBootstrap(): Promise<boolean> {\n try {\n const { bootstrapFromAppRoot } = await import('@open-mercato/shared/lib/bootstrap/dynamicLoader')\n const { registerCliModules } = await import('./mercato.js')\n // Use the CLI resolver to find the app directory (handles monorepo detection)\n const { createResolver } = await import('./lib/resolver.js')\n const resolver = createResolver()\n const appDir = resolver.getAppDir()\n const data = await bootstrapFromAppRoot(appDir)\n // Register CLI modules directly to avoid module resolution issues\n registerCliModules(data.modules)\n return true\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err)\n // Check if the error is about missing generated files\n if (\n message.includes('Cannot find module') &&\n (message.includes('/generated/') || message.includes('.generated') || message.includes('.mercato'))\n ) {\n return false\n }\n // Re-throw other errors\n throw err\n }\n}\n\nasync function main(): Promise<void> {\n assertNode24Runtime()\n const requiresBootstrap = needsBootstrap(process.argv)\n\n if (requiresBootstrap) {\n const bootstrapSucceeded = await tryBootstrap()\n if (!bootstrapSucceeded) {\n console.error('\u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557')\n console.error('\u2551 Generated files not found! \u2551')\n console.error('\u2551 \u2551')\n console.error('\u2551 The CLI requires generated files to discover modules. \u2551')\n console.error('\u2551 Please run the following command first: \u2551')\n console.error('\u2551 \u2551')\n console.error('\u2551 yarn mercato generate \u2551')\n console.error('\u2551 \u2551')\n console.error('\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D')\n process.exit(1)\n }\n }\n\n const code = await run(process.argv)\n process.exit(code ?? 0)\n}\n\nmain().catch((error: unknown) => {\n if (error instanceof Error) {\n console.error(error.message)\n } else {\n console.error(error)\n }\n process.exit(1)\n})\n"],
5
- "mappings": "AAMA,SAAS,WAAW;AAOpB,MAAM,0BAA0B;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,SAAS,sBAA4B;AACnC,QAAM,sBAAsB,QAAQ,SAAS;AAC7C,QAAM,eAAe,OAAO,SAAS,oBAAoB,MAAM,GAAG,EAAE,CAAC,KAAK,KAAK,EAAE;AACjF,MAAI,gBAAgB,IAAI;AACtB;AA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AM,gaAAuE;AACrF,cAAQ,KAAK,CAAC;AAAA,IAChB;AAAA,EACF;AAEA,QAAM,OAAO,MAAM,IAAI,QAAQ,IAAI;AACnC,UAAQ,KAAK,QAAQ,CAAC;AACxB;AAEA,KAAK,EAAE,MAAM,CAAC,UAAmB;AAC/B,MAAI,iBAAiB,OAAO;AAC1B,YAAQ,MAAM,MAAM,OAAO;AAAA,EAC7B,OAAO;AACL,YAAQ,MAAM,KAAK;AAAA,EACrB;AACA,UAAQ,KAAK,CAAC;AAChB,CAAC;",
4
+ "sourcesContent": ["/**\n * CLI binary entry point for @open-mercato/cli package.\n *\n * Called from within a Next.js app directory as: yarn mercato <command>\n * Uses dynamic app resolution to find generated files at .mercato/generated/\n */\nimport {\n getTelemetryRuntime,\n isTelemetryBackendEnabled,\n} from '@open-mercato/shared/lib/telemetry/runtime'\n// `run` is imported dynamically inside `main()` so telemetry can initialize\n// before the mercato entry (and its Postgres driver) loads \u2014 see main().\n\n// Commands that can run without bootstrap (without generated files)\n// - generate: creates the generated files\n// - db: uses resolver directly to find modules and migrations\n// - init: runs yarn commands to set up the app\n// - help: just shows help text\nconst BOOTSTRAP_FREE_COMMANDS = [\n 'generate',\n 'module',\n 'deploy',\n 'db',\n 'init',\n 'agentic:init',\n 'telemetry',\n 'eject',\n 'test',\n 'test:integration',\n 'test:integration:coverage',\n 'test:integration:spec-coverage',\n 'test:ephemeral',\n 'test:integration:interactive',\n 'umes:list',\n 'umes:inspect',\n 'umes:check',\n 'help',\n '--help',\n '-h',\n]\n\nfunction assertNode24Runtime(): void {\n const detectedNodeVersion = process.versions.node\n const majorVersion = Number.parseInt(detectedNodeVersion.split('.')[0] ?? '0', 10)\n if (majorVersion >= 24) {\n return\n }\n throw new Error(\n [\n 'Unsupported Node.js runtime.',\n `Cause: Detected Node ${detectedNodeVersion}, but Open Mercato requires Node 24.x.`,\n 'What to do: switch your shell to Node 24 (for example `nvm use 24`), run `yarn install`, then retry.',\n ].join(' '),\n )\n}\n\nfunction needsBootstrap(argv: string[]): boolean {\n const [, , first] = argv\n if (!first) return false // help screen\n return !BOOTSTRAP_FREE_COMMANDS.includes(first)\n}\n\nasync function tryBootstrap(): Promise<boolean> {\n try {\n const { bootstrapFromAppRoot } = await import('@open-mercato/shared/lib/bootstrap/dynamicLoader')\n const { registerCliModules } = await import('./mercato.js')\n // Use the CLI resolver to find the app directory (handles monorepo detection)\n const { createResolver } = await import('./lib/resolver.js')\n const resolver = createResolver()\n const appDir = resolver.getAppDir()\n const data = await bootstrapFromAppRoot(appDir)\n // Register CLI modules directly to avoid module resolution issues\n registerCliModules(data.modules)\n return true\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err)\n // Check if the error is about missing generated files\n if (\n message.includes('Cannot find module') &&\n (message.includes('/generated/') || message.includes('.generated') || message.includes('.mercato'))\n ) {\n return false\n }\n // Re-throw other errors\n throw err\n }\n}\n\nasync function main(): Promise<void> {\n assertNode24Runtime()\n const requiresBootstrap = needsBootstrap(process.argv)\n\n if (requiresBootstrap) {\n // Load the app's `.env` BEFORE initTelemetry(): `run()` only dotenv-loads it\n // later (ensureEnvLoaded), which is too late \u2014 TELEMETRY_BACKEND set only in\n // `.env` would silently resolve to `noop` for worker/scheduler processes.\n // The loader touches only the resolver + dotenv (no `pg`), preserving the\n // instrumentation load-order guarantee below.\n const { loadAppEnv } = await import('./lib/load-env.js')\n await loadAppEnv()\n\n // Initialize telemetry BEFORE bootstrapping the app graph. Bootstrap and the\n // per-command handlers load MikroORM's Postgres driver \u2192 `pg`, and the\n // OpenTelemetry pg/undici auto-instrumentation only records spans for a\n // driver required AFTER the SDK has started. Registering here \u2014 ahead of any\n // app module \u2014 is what lets long-running worker/scheduler processes emit DB\n // spans (not just the bullmq-otel add/process envelope). The package itself\n // is not imported unless an explicit supported backend is selected.\n if (isTelemetryBackendEnabled()) {\n const { initTelemetry } = await import('@open-mercato/telemetry')\n await initTelemetry()\n }\n\n const bootstrapSucceeded = await tryBootstrap()\n if (!bootstrapSucceeded) {\n console.error('\u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557')\n console.error('\u2551 Generated files not found! \u2551')\n console.error('\u2551 \u2551')\n console.error('\u2551 The CLI requires generated files to discover modules. \u2551')\n console.error('\u2551 Please run the following command first: \u2551')\n console.error('\u2551 \u2551')\n console.error('\u2551 yarn mercato generate \u2551')\n console.error('\u2551 \u2551')\n console.error('\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D')\n process.exit(1)\n }\n }\n\n // Dynamic import (not a top-level static import) so the mercato entry \u2014 and the\n // Postgres driver it pulls in \u2014 loads only after initTelemetry() above.\n const { run } = await import('./mercato.js')\n const code = await run(process.argv)\n // Flush spans/logs for commands that return (workers block forever and flush via\n // their own shutdown handler instead).\n await getTelemetryRuntime()?.shutdown()\n process.exit(code ?? 0)\n}\n\nmain().catch((error: unknown) => {\n if (error instanceof Error) {\n console.error(error.message)\n } else {\n console.error(error)\n }\n process.exit(1)\n})\n"],
5
+ "mappings": "AAMA;AAAA,EACE;AAAA,EACA;AAAA,OACK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A,UAAM;AAAA,EACR;AACF;AAEA,eAAe,OAAsB;AACnC,sBAAoB;AACpB,QAAM,oBAAoB,eAAe,QAAQ,IAAI;AAErD,MAAI,mBAAmB;AAMrB,UAAM,EAAE,WAAW,IAAI,MAAM,OAAO,mBAAmB;AACvD,UAAM,WAAW;AASjB,QAAI,0BAA0B,GAAG;AAC/B,YAAM,EAAE,cAAc,IAAI,MAAM,OAAO,yBAAyB;AAChE,YAAM,cAAc;AAAA,IACtB;AAEA,UAAM,qBAAqB,MAAM,aAAa;AAC9C,QAAI,CAAC,oBAAoB;AACvB,cAAQ,MAAM,gaAAuE;AACrF,cAAQ,MAAM,iFAAuE;AACrF,cAAQ,MAAM,iFAAuE;AACrF,cAAQ,MAAM,gFAAsE;AACpF,cAAQ,MAAM,gFAAsE;AACpF,cAAQ,MAAM,iFAAuE;AACrF,cAAQ,MAAM,gFAAsE;AACpF,cAAQ,MAAM,iFAAuE;AACrF,cAAQ,MAAM,gaAAuE;AACrF,cAAQ,KAAK,CAAC;AAAA,IAChB;AAAA,EACF;AAIA,QAAM,EAAE,IAAI,IAAI,MAAM,OAAO,cAAc;AAC3C,QAAM,OAAO,MAAM,IAAI,QAAQ,IAAI;AAGnC,QAAM,oBAAoB,GAAG,SAAS;AACtC,UAAQ,KAAK,QAAQ,CAAC;AACxB;AAEA,KAAK,EAAE,MAAM,CAAC,UAAmB;AAC/B,MAAI,iBAAiB,OAAO;AAC1B,YAAQ,MAAM,MAAM,OAAO;AAAA,EAC7B,OAAO;AACL,YAAQ,MAAM,KAAK;AAAA,EACrB;AACA,UAAQ,KAAK,CAAC;AAChB,CAAC;",
6
6
  "names": []
7
7
  }
@@ -13,11 +13,13 @@ const cliIntegrationRunnerPath = path.join(cliDir, "src", "lib", "testing", "int
13
13
  const standaloneTemplatePackageJsonPath = path.join(repoRoot, "packages", "create-app", "template", "package.json.template");
14
14
  const agenticRoot = path.join(repoRoot, "packages", "create-app", "agentic");
15
15
  const packagesRoot = path.join(repoRoot, "packages");
16
+ const coreVersion = JSON.parse(fs.readFileSync(path.join(packagesRoot, "core", "package.json"), "utf8")).version;
17
+ const UNROUTED_PACKAGE_GUIDES = /* @__PURE__ */ new Set(["cache", "core", "events", "queue", "search", "shared", "ui"]);
16
18
  const FIXTURE_ENABLED_MODULES = ["customers", "sales"];
17
19
  function normalizePath(value) {
18
20
  return value.split(path.sep).join("/");
19
21
  }
20
- function runCommand(command, args, cwd) {
22
+ function runCommand(command, args, cwd, env = {}) {
21
23
  return execFileSync(command, args, {
22
24
  cwd,
23
25
  encoding: "utf8",
@@ -28,7 +30,8 @@ function runCommand(command, args, cwd) {
28
30
  // Keep the test hermetic: agentic:init runs scripts/install-skills.sh,
29
31
  // whose external step (`npx skills add`) needs the network. Local tier
30
32
  // symlinks are still installed.
31
- OM_SKIP_EXTERNAL_SKILLS: "1"
33
+ OM_SKIP_EXTERNAL_SKILLS: "1",
34
+ ...env
32
35
  }
33
36
  });
34
37
  }
@@ -49,19 +52,49 @@ function createStandaloneFixture(rootDir) {
49
52
  JSON.stringify(
50
53
  {
51
54
  name: "sample-store",
52
- private: true
55
+ private: true,
56
+ dependencies: { "@open-mercato/core": coreVersion }
53
57
  },
54
58
  null,
55
59
  2
56
60
  )
57
61
  );
58
- const moduleEntries = FIXTURE_ENABLED_MODULES.map((moduleId) => ` { id: '${moduleId}' },`).join("\n");
62
+ const moduleEntries = FIXTURE_ENABLED_MODULES.map((moduleId) => ` { id: '${moduleId}', from: '@open-mercato/core' },`).join("\n");
59
63
  writeFile(path.join(appDir, "src", "modules.ts"), `export const enabledModules = [
60
64
  ${moduleEntries}
61
65
  ]
62
66
  `);
63
67
  return appDir;
64
68
  }
69
+ function installFakeFrameworkPackage(appDir) {
70
+ const packageRoot = path.join(appDir, "node_modules", "@open-mercato", "core");
71
+ writeFile(path.join(packageRoot, "package.json"), JSON.stringify({
72
+ name: "@open-mercato/core",
73
+ version: coreVersion,
74
+ type: "module",
75
+ exports: { ".": "./dist/index.js" }
76
+ }));
77
+ writeFile(path.join(packageRoot, "dist", "index.js"), "export {}\n");
78
+ writeFile(path.join(packageRoot, "AGENTS.md"), "# Installed core instructions\n");
79
+ for (const moduleId of FIXTURE_ENABLED_MODULES) {
80
+ writeFile(path.join(packageRoot, "src", "modules", moduleId, "AGENTS.md"), `# Installed ${moduleId} instructions
81
+ `);
82
+ writeFile(
83
+ path.join(packageRoot, "src", "modules", moduleId, "data", "entities.ts"),
84
+ `export class ${moduleId === "customers" ? "Person" : "Sale"} {}
85
+ `
86
+ );
87
+ }
88
+ return packageRoot;
89
+ }
90
+ function snapshotTextFiles(rootDir) {
91
+ return Object.fromEntries(
92
+ listRelativeFiles(rootDir).map((relativePath) => [
93
+ relativePath,
94
+ fs.readFileSync(path.join(rootDir, relativePath), "utf8")
95
+ ])
96
+ );
97
+ }
65
98
  function listRelativeFiles(rootDir) {
66
99
  if (!fs.existsSync(rootDir)) {
67
100
  return [];
@@ -161,7 +194,7 @@ function expectedGuideOutputNames() {
161
194
  }
162
195
  for (const packageName of fs.readdirSync(packagesRoot)) {
163
196
  const packageGuide = path.join(packagesRoot, packageName, "agentic", "standalone-guide.md");
164
- if (fs.existsSync(packageGuide)) {
197
+ if (fs.existsSync(packageGuide) && !UNROUTED_PACKAGE_GUIDES.has(packageName)) {
165
198
  collected.add(`${packageName}.md`);
166
199
  }
167
200
  const modulesRoot = path.join(packagesRoot, packageName, "src", "modules");
@@ -176,6 +209,10 @@ function expectedGuideOutputNames() {
176
209
  }
177
210
  }
178
211
  collected.add("module-facts.json");
212
+ collected.add("framework-extension-points.md");
213
+ collected.add("upstream/AGENTS.md");
214
+ collected.add("upstream/BACKWARD_COMPATIBILITY.md");
215
+ collected.add("upstream/manifest.json");
179
216
  for (const moduleId of FIXTURE_ENABLED_MODULES) {
180
217
  collected.add(normalizePath(path.join("modules", `${moduleId}.md`)));
181
218
  }
@@ -210,11 +247,14 @@ test.describe("TC-INT-008: CLI agentic init mirrors standalone scaffolding asset
210
247
  expect(generatedGuideNames).toEqual(expectedGuideOutputNames());
211
248
  const agentsSource = fs.readFileSync(path.join(appDir, "AGENTS.md"), "utf8");
212
249
  expect(agentsSource).toContain("<!-- CODEX_ENFORCEMENT_RULES_START -->");
213
- expect(agentsSource).toContain(".ai/guides/core.md");
250
+ expect(agentsSource).toContain(".ai/guides/upstream/BACKWARD_COMPATIBILITY.md");
214
251
  for (const moduleId of FIXTURE_ENABLED_MODULES) {
215
- expect(agentsSource).toContain(`.ai/guides/modules/${moduleId}.md`);
252
+ expect(agentsSource).toContain(`\`${moduleId}\``);
216
253
  }
217
- expect(agentsSource).not.toContain(".ai/guides/modules/auth.md");
254
+ expect(agentsSource).toContain("`.ai/guides/modules/<id>.md`");
255
+ expect(agentsSource.match(/\.ai\/guides\/modules\//g)).toHaveLength(1);
256
+ expect(agentsSource).not.toContain("`auth`");
257
+ expect(agentsSource).not.toContain("Core CRM capabilities");
218
258
  const specsReadmeSource = fs.readFileSync(path.join(appDir, ".ai", "specs", "README.md"), "utf8");
219
259
  expect(specsReadmeSource).toContain("sample-store");
220
260
  const cursorRulesSource = fs.readFileSync(path.join(appDir, ".cursor", "rules", "open-mercato.mdc"), "utf8");
@@ -240,5 +280,45 @@ test.describe("TC-INT-008: CLI agentic init mirrors standalone scaffolding asset
240
280
  fs.rmSync(tempRoot, { recursive: true, force: true });
241
281
  }
242
282
  });
283
+ test("emits a runnable exact-version framework context escape hatch for an installed package", () => {
284
+ const tempRoot = fs.mkdtempSync(path.join(os.tmpdir(), "mercato-cli-framework-context-"));
285
+ try {
286
+ const appDir = createStandaloneFixture(tempRoot);
287
+ const packageRoot = installFakeFrameworkPackage(appDir);
288
+ const resolvedPackageRoot = fs.realpathSync(packageRoot);
289
+ const packageBefore = snapshotTextFiles(packageRoot);
290
+ runMercato(["agentic:init", "--tool=codex"], appDir);
291
+ const generatedScript = path.join(appDir, "scripts", "framework-context.mjs");
292
+ expect(fs.existsSync(generatedScript)).toBe(true);
293
+ const output = runCommand(
294
+ process.execPath,
295
+ [generatedScript, "--module", "customers", "--query", "Person", "--json"],
296
+ appDir,
297
+ // The generated standalone helper must not depend on a globally
298
+ // installed ripgrep binary; process.execPath is already absolute.
299
+ { PATH: "", Path: "" }
300
+ );
301
+ const context = JSON.parse(output);
302
+ expect(context.module).toBe("customers");
303
+ expect(context.package).toEqual({ name: "@open-mercato/core", version: coreVersion, root: resolvedPackageRoot });
304
+ expect(context.sourceKind).toBe("source");
305
+ expect(normalizePath(context.sourceRoot)).toBe(normalizePath(path.join(resolvedPackageRoot, "src", "modules", "customers")));
306
+ expect(context.instructions.filter((entry) => entry.path).map((entry) => entry.kind)).toEqual([
307
+ "standalone-root",
308
+ "upstream-bc",
309
+ "package",
310
+ "module-1",
311
+ "upstream-root"
312
+ ]);
313
+ expect(context.instructions.filter((entry) => entry.path).every((entry) => entry.materializedPath)).toBe(true);
314
+ expect(context.boundedSearch).toMatchObject({ status: "matched", matches: 1, maxMatches: 200 });
315
+ expect(fs.existsSync(path.join(appDir, context.materializedSource))).toBe(true);
316
+ expect(fs.existsSync(path.join(appDir, context.boundedSearch.result))).toBe(true);
317
+ expect(context.warnings.some((warning) => warning.includes("Generated facts for customers are stale"))).toBe(false);
318
+ expect(snapshotTextFiles(packageRoot)).toEqual(packageBefore);
319
+ } finally {
320
+ fs.rmSync(tempRoot, { recursive: true, force: true });
321
+ }
322
+ });
243
323
  });
244
324
  //# sourceMappingURL=TC-INT-008.spec.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/lib/__integration__/TC-INT-008.spec.ts"],
4
- "sourcesContent": ["import { expect, test } from '@playwright/test'\nimport { execFileSync } from 'node:child_process'\nimport fs from 'node:fs'\nimport os from 'node:os'\nimport path from 'node:path'\nimport { fileURLToPath } from 'node:url'\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url))\nconst repoRoot = path.resolve(__dirname, '..', '..', '..', '..', '..')\nconst cliDir = path.join(repoRoot, 'packages', 'cli')\nconst cliBin = path.join(cliDir, 'dist', 'bin.js')\nconst cliBuildScript = path.join(cliDir, 'build.mjs')\nconst cliIntegrationRunnerPath = path.join(cliDir, 'src', 'lib', 'testing', 'integration.ts')\nconst standaloneTemplatePackageJsonPath = path.join(repoRoot, 'packages', 'create-app', 'template', 'package.json.template')\nconst agenticRoot = path.join(repoRoot, 'packages', 'create-app', 'agentic')\nconst packagesRoot = path.join(repoRoot, 'packages')\n\n// Modules the standalone fixture enables in src/modules.ts. Both are on the\n// fact-sheet allowlist, so agentic:init must ship exactly their fact-sheets\n// (enabled \u2229 allowlist \u2014 spec D6) and list them in the AGENTS.md marker block.\nconst FIXTURE_ENABLED_MODULES = ['customers', 'sales']\n\nfunction normalizePath(value: string): string {\n return value.split(path.sep).join('/')\n}\n\nfunction runCommand(command: string, args: string[], cwd: string): string {\n return execFileSync(command, args, {\n cwd,\n encoding: 'utf8',\n env: {\n ...process.env,\n FORCE_COLOR: '0',\n NODE_NO_WARNINGS: '1',\n // Keep the test hermetic: agentic:init runs scripts/install-skills.sh,\n // whose external step (`npx skills add`) needs the network. Local tier\n // symlinks are still installed.\n OM_SKIP_EXTERNAL_SKILLS: '1',\n },\n })\n}\n\nfunction runMercato(args: string[], cwd: string): string {\n return runCommand(process.execPath, [cliBin, ...args], cwd)\n}\n\nfunction writeFile(filePath: string, content: string): void {\n fs.mkdirSync(path.dirname(filePath), { recursive: true })\n fs.writeFileSync(filePath, content)\n}\n\nfunction ensureCliBuilt(): void {\n runCommand(process.execPath, [cliBuildScript], cliDir)\n}\n\nfunction createStandaloneFixture(rootDir: string): string {\n const appDir = path.join(rootDir, 'sample-store')\n writeFile(\n path.join(appDir, 'package.json'),\n JSON.stringify(\n {\n name: 'sample-store',\n private: true,\n },\n null,\n 2,\n ),\n )\n const moduleEntries = FIXTURE_ENABLED_MODULES.map((moduleId) => ` { id: '${moduleId}' },`).join('\\n')\n writeFile(path.join(appDir, 'src', 'modules.ts'), `export const enabledModules = [\\n${moduleEntries}\\n]\\n`)\n return appDir\n}\n\nfunction listRelativeFiles(rootDir: string): string[] {\n if (!fs.existsSync(rootDir)) {\n return []\n }\n\n const collected: string[] = []\n for (const entry of fs.readdirSync(rootDir, { withFileTypes: true })) {\n const absolutePath = path.join(rootDir, entry.name)\n if (entry.isDirectory()) {\n for (const nestedPath of listRelativeFiles(absolutePath)) {\n collected.push(path.join(entry.name, nestedPath))\n }\n continue\n }\n if (entry.isFile()) {\n collected.push(entry.name)\n }\n }\n\n return collected.map(normalizePath).sort()\n}\n\nfunction mapSharedSourceToOutput(relativePath: string): string {\n if (relativePath === 'AGENTS.md.template') {\n return 'AGENTS.md'\n }\n\n if (relativePath.startsWith('scripts/')) {\n return relativePath\n }\n\n if (!relativePath.startsWith('ai/')) {\n throw new Error(`Unexpected shared source path: ${relativePath}`)\n }\n\n return normalizePath(path.join('.ai', relativePath.slice('ai/'.length)))\n}\n\nfunction mapClaudeSourceToOutput(relativePath: string): string {\n if (relativePath === 'CLAUDE.md.template') {\n return 'CLAUDE.md'\n }\n if (relativePath === 'settings.json') {\n return '.claude/settings.json'\n }\n if (relativePath === 'mcp.json.example') {\n return '.mcp.json.example'\n }\n if (relativePath.startsWith('hooks/')) {\n return normalizePath(path.join('.claude', relativePath))\n }\n\n throw new Error(`Unexpected Claude source path: ${relativePath}`)\n}\n\nfunction mapCursorSourceToOutput(relativePath: string): string {\n if (relativePath === 'hooks.json') {\n return '.cursor/hooks.json'\n }\n if (relativePath === 'mcp.json.example') {\n return '.cursor/mcp.json.example'\n }\n if (relativePath.startsWith('hooks/') || relativePath.startsWith('rules/')) {\n return normalizePath(path.join('.cursor', relativePath))\n }\n\n throw new Error(`Unexpected Cursor source path: ${relativePath}`)\n}\n\nfunction mapCodexSourceToOutput(relativePath: string): string | null {\n if (relativePath === 'mcp.json.example') {\n return '.codex/mcp.json.example'\n }\n if (relativePath === 'enforcement-rules.md') {\n return null\n }\n\n throw new Error(`Unexpected Codex source path: ${relativePath}`)\n}\n\nfunction readPlaywrightConfigPathFromTemplate(): string {\n const packageTemplate = JSON.parse(fs.readFileSync(standaloneTemplatePackageJsonPath, 'utf8')) as {\n scripts?: Record<string, string>\n }\n const integrationScript = packageTemplate.scripts?.['test:integration']\n if (!integrationScript) {\n throw new Error('Standalone template is missing the test:integration script')\n }\n\n const configPathMatch = integrationScript.match(/--config\\s+([^\\s]+)/)\n if (!configPathMatch?.[1]) {\n throw new Error('Standalone template test:integration script is missing --config')\n }\n\n return normalizePath(configPathMatch[1])\n}\n\nfunction readPlaywrightConfigPathFromCliRunner(): string {\n const integrationRunnerSource = fs.readFileSync(cliIntegrationRunnerPath, 'utf8')\n const configPathMatch = integrationRunnerSource.match(/const PLAYWRIGHT_INTEGRATION_CONFIG_PATH = '([^']+)'/)\n if (!configPathMatch?.[1]) {\n throw new Error('CLI integration runner is missing PLAYWRIGHT_INTEGRATION_CONFIG_PATH')\n }\n\n return normalizePath(configPathMatch[1])\n}\n\nfunction expectedGuideOutputNames(): string[] {\n const collected = new Set<string>()\n\n // Static conceptual guides checked into create-app (e.g. module-system.md) are\n // bundled into dist/agentic/guides by the CLI build and copied wholesale.\n const staticGuidesRoot = path.join(agenticRoot, 'guides')\n if (fs.existsSync(staticGuidesRoot)) {\n for (const entry of fs.readdirSync(staticGuidesRoot, { withFileTypes: true })) {\n if (entry.isFile() && entry.name.endsWith('.md')) {\n collected.add(entry.name)\n }\n }\n }\n\n for (const packageName of fs.readdirSync(packagesRoot)) {\n const packageGuide = path.join(packagesRoot, packageName, 'agentic', 'standalone-guide.md')\n if (fs.existsSync(packageGuide)) {\n collected.add(`${packageName}.md`)\n }\n\n const modulesRoot = path.join(packagesRoot, packageName, 'src', 'modules')\n if (!fs.existsSync(modulesRoot)) {\n continue\n }\n\n for (const moduleName of fs.readdirSync(modulesRoot)) {\n const moduleGuide = path.join(modulesRoot, moduleName, 'agentic', 'standalone-guide.md')\n if (fs.existsSync(moduleGuide)) {\n collected.add(`${packageName}.${moduleName}.md`)\n }\n }\n }\n\n // Generated fact-sheet artifacts (spec 2026-06-27-ts-morph-module-fact-sheets):\n // the module-facts.json sidecar is copied as-is and fact-sheets are filtered to the\n // fixture's enabled modules. The legacy core.<module>.md redirect stubs are no longer\n // emitted (#3754).\n collected.add('module-facts.json')\n for (const moduleId of FIXTURE_ENABLED_MODULES) {\n collected.add(normalizePath(path.join('modules', `${moduleId}.md`)))\n }\n\n return Array.from(collected).sort()\n}\n\nfunction assertPathsExist(appDir: string, relativePaths: string[]): void {\n const missingPaths = relativePaths.filter((relativePath) => !fs.existsSync(path.join(appDir, relativePath)))\n expect(missingPaths).toEqual([])\n}\n\ntest.describe('TC-INT-008: CLI agentic init mirrors standalone scaffolding assets', () => {\n test.beforeAll(() => {\n ensureCliBuilt()\n })\n\n test('should run bootstrap-free and generate the shared, guide, and tool-specific agentic files', () => {\n const tempRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'mercato-cli-agentic-'))\n\n try {\n const appDir = createStandaloneFixture(tempRoot)\n const standalonePlaywrightConfigPath = readPlaywrightConfigPathFromTemplate()\n const cliPlaywrightConfigPath = readPlaywrightConfigPathFromCliRunner()\n const commandOutput = runMercato(['agentic:init', '--tool=claude-code,codex,cursor'], appDir)\n\n expect(cliPlaywrightConfigPath).toBe(standalonePlaywrightConfigPath)\n expect(commandOutput).toContain('Agentic setup complete:')\n expect(fs.existsSync(path.join(appDir, '.mercato', 'generated'))).toBe(false)\n\n const sharedOutputs = listRelativeFiles(path.join(agenticRoot, 'shared')).map(mapSharedSourceToOutput)\n const claudeOutputs = listRelativeFiles(path.join(agenticRoot, 'claude-code')).map(mapClaudeSourceToOutput)\n const cursorOutputs = listRelativeFiles(path.join(agenticRoot, 'cursor')).map(mapCursorSourceToOutput)\n const codexOutputs = listRelativeFiles(path.join(agenticRoot, 'codex'))\n .map(mapCodexSourceToOutput)\n .filter((relativePath): relativePath is string => relativePath !== null)\n\n expect(sharedOutputs).toContain(standalonePlaywrightConfigPath)\n assertPathsExist(appDir, [...sharedOutputs, ...claudeOutputs, ...cursorOutputs, ...codexOutputs])\n expect(fs.existsSync(path.join(appDir, standalonePlaywrightConfigPath))).toBe(true)\n\n const generatedGuideNames = listRelativeFiles(path.join(appDir, '.ai', 'guides'))\n expect(generatedGuideNames).toEqual(expectedGuideOutputNames())\n\n const agentsSource = fs.readFileSync(path.join(appDir, 'AGENTS.md'), 'utf8')\n expect(agentsSource).toContain('<!-- CODEX_ENFORCEMENT_RULES_START -->')\n expect(agentsSource).toContain('.ai/guides/core.md')\n\n // The Module-Specific Guides marker block lists exactly the enabled modules'\n // fact-sheets (enabled \u2229 allowlist), not the full bundled set.\n for (const moduleId of FIXTURE_ENABLED_MODULES) {\n expect(agentsSource).toContain(`.ai/guides/modules/${moduleId}.md`)\n }\n expect(agentsSource).not.toContain('.ai/guides/modules/auth.md')\n\n const specsReadmeSource = fs.readFileSync(path.join(appDir, '.ai', 'specs', 'README.md'), 'utf8')\n expect(specsReadmeSource).toContain('sample-store')\n\n const cursorRulesSource = fs.readFileSync(path.join(appDir, '.cursor', 'rules', 'open-mercato.mdc'), 'utf8')\n expect(cursorRulesSource).toContain('sample-store')\n\n // om-spec-writing moved to the external open-mercato/skills collection\n // (installed via `yarn install-skills`), so agentic:init must not ship a copy.\n expect(fs.existsSync(path.join(appDir, '.ai', 'skills', 'om-spec-writing'))).toBe(false)\n expect(fs.existsSync(path.join(appDir, 'scripts', 'install-skills.sh'))).toBe(true)\n\n // install-skills.sh (run by agentic:init) installs every local tier skill once,\n // into the canonical .agents/skills/. Codex and Cursor read that directory\n // natively, so they get no skills directory of their own; Claude Code cannot,\n // so it keeps a link layer pointing back at the canonical copy.\n const tiersManifest = JSON.parse(\n fs.readFileSync(path.join(agenticRoot, 'shared', 'ai', 'skills', 'tiers.json'), 'utf8'),\n ) as { default: string[]; tiers: Record<string, { skills: string[] }> }\n const defaultTierSkills = tiersManifest.default.flatMap((tierName) => tiersManifest.tiers[tierName].skills)\n expect(defaultTierSkills.length).toBeGreaterThan(0)\n\n for (const skillName of defaultTierSkills) {\n const canonicalLinkPath = path.join(appDir, '.agents', 'skills', skillName)\n expect(fs.lstatSync(canonicalLinkPath).isSymbolicLink()).toBe(true)\n expect(normalizePath(fs.readlinkSync(canonicalLinkPath))).toBe(`../../.ai/skills/${skillName}`)\n\n const claudeLinkPath = path.join(appDir, '.claude', 'skills', skillName)\n expect(fs.lstatSync(claudeLinkPath).isSymbolicLink()).toBe(true)\n expect(normalizePath(fs.readlinkSync(claudeLinkPath))).toBe(`../../.agents/skills/${skillName}`)\n }\n\n expect(fs.existsSync(path.join(appDir, '.codex', 'skills'))).toBe(false)\n expect(fs.existsSync(path.join(appDir, '.cursor', 'skills'))).toBe(false)\n } finally {\n fs.rmSync(tempRoot, { recursive: true, force: true })\n }\n })\n})\n"],
5
- "mappings": "AAAA,SAAS,QAAQ,YAAY;AAC7B,SAAS,oBAAoB;AAC7B,OAAO,QAAQ;AACf,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,SAAS,qBAAqB;AAE9B,MAAM,YAAY,KAAK,QAAQ,cAAc,YAAY,GAAG,CAAC;AAC7D,MAAM,WAAW,KAAK,QAAQ,WAAW,MAAM,MAAM,MAAM,MAAM,IAAI;AACrE,MAAM,SAAS,KAAK,KAAK,UAAU,YAAY,KAAK;AACpD,MAAM,SAAS,KAAK,KAAK,QAAQ,QAAQ,QAAQ;AACjD,MAAM,iBAAiB,KAAK,KAAK,QAAQ,WAAW;AACpD,MAAM,2BAA2B,KAAK,KAAK,QAAQ,OAAO,OAAO,WAAW,gBAAgB;AAC5F,MAAM,oCAAoC,KAAK,KAAK,UAAU,YAAY,cAAc,YAAY,uBAAuB;AAC3H,MAAM,cAAc,KAAK,KAAK,UAAU,YAAY,cAAc,SAAS;AAC3E,MAAM,eAAe,KAAK,KAAK,UAAU,UAAU;AAKnD,MAAM,0BAA0B,CAAC,aAAa,OAAO;AAErD,SAAS,cAAc,OAAuB;AAC5C,SAAO,MAAM,MAAM,KAAK,GAAG,EAAE,K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EACF,CAAC;AACH,CAAC;",
4
+ "sourcesContent": ["import { expect, test } from '@playwright/test'\nimport { execFileSync } from 'node:child_process'\nimport fs from 'node:fs'\nimport os from 'node:os'\nimport path from 'node:path'\nimport { fileURLToPath } from 'node:url'\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url))\nconst repoRoot = path.resolve(__dirname, '..', '..', '..', '..', '..')\nconst cliDir = path.join(repoRoot, 'packages', 'cli')\nconst cliBin = path.join(cliDir, 'dist', 'bin.js')\nconst cliBuildScript = path.join(cliDir, 'build.mjs')\nconst cliIntegrationRunnerPath = path.join(cliDir, 'src', 'lib', 'testing', 'integration.ts')\nconst standaloneTemplatePackageJsonPath = path.join(repoRoot, 'packages', 'create-app', 'template', 'package.json.template')\nconst agenticRoot = path.join(repoRoot, 'packages', 'create-app', 'agentic')\nconst packagesRoot = path.join(repoRoot, 'packages')\nconst coreVersion = JSON.parse(fs.readFileSync(path.join(packagesRoot, 'core', 'package.json'), 'utf8')).version as string\nconst UNROUTED_PACKAGE_GUIDES = new Set(['cache', 'core', 'events', 'queue', 'search', 'shared', 'ui'])\n\n// Modules the standalone fixture enables in src/modules.ts. Both are on the\n// fact-sheet allowlist, so agentic:init must ship exactly their fact-sheets\n// (enabled \u2229 allowlist \u2014 spec D6) and list them in the AGENTS.md marker block.\nconst FIXTURE_ENABLED_MODULES = ['customers', 'sales']\n\nfunction normalizePath(value: string): string {\n return value.split(path.sep).join('/')\n}\n\nfunction runCommand(command: string, args: string[], cwd: string, env: NodeJS.ProcessEnv = {}): string {\n return execFileSync(command, args, {\n cwd,\n encoding: 'utf8',\n env: {\n ...process.env,\n FORCE_COLOR: '0',\n NODE_NO_WARNINGS: '1',\n // Keep the test hermetic: agentic:init runs scripts/install-skills.sh,\n // whose external step (`npx skills add`) needs the network. Local tier\n // symlinks are still installed.\n OM_SKIP_EXTERNAL_SKILLS: '1',\n ...env,\n },\n })\n}\n\nfunction runMercato(args: string[], cwd: string): string {\n return runCommand(process.execPath, [cliBin, ...args], cwd)\n}\n\nfunction writeFile(filePath: string, content: string): void {\n fs.mkdirSync(path.dirname(filePath), { recursive: true })\n fs.writeFileSync(filePath, content)\n}\n\nfunction ensureCliBuilt(): void {\n runCommand(process.execPath, [cliBuildScript], cliDir)\n}\n\nfunction createStandaloneFixture(rootDir: string): string {\n const appDir = path.join(rootDir, 'sample-store')\n writeFile(\n path.join(appDir, 'package.json'),\n JSON.stringify(\n {\n name: 'sample-store',\n private: true,\n dependencies: { '@open-mercato/core': coreVersion },\n },\n null,\n 2,\n ),\n )\n const moduleEntries = FIXTURE_ENABLED_MODULES\n .map((moduleId) => ` { id: '${moduleId}', from: '@open-mercato/core' },`)\n .join('\\n')\n writeFile(path.join(appDir, 'src', 'modules.ts'), `export const enabledModules = [\\n${moduleEntries}\\n]\\n`)\n return appDir\n}\n\nfunction installFakeFrameworkPackage(appDir: string): string {\n const packageRoot = path.join(appDir, 'node_modules', '@open-mercato', 'core')\n writeFile(path.join(packageRoot, 'package.json'), JSON.stringify({\n name: '@open-mercato/core',\n version: coreVersion,\n type: 'module',\n exports: { '.': './dist/index.js' },\n }))\n writeFile(path.join(packageRoot, 'dist', 'index.js'), 'export {}\\n')\n writeFile(path.join(packageRoot, 'AGENTS.md'), '# Installed core instructions\\n')\n for (const moduleId of FIXTURE_ENABLED_MODULES) {\n writeFile(path.join(packageRoot, 'src', 'modules', moduleId, 'AGENTS.md'), `# Installed ${moduleId} instructions\\n`)\n writeFile(\n path.join(packageRoot, 'src', 'modules', moduleId, 'data', 'entities.ts'),\n `export class ${moduleId === 'customers' ? 'Person' : 'Sale'} {}\\n`,\n )\n }\n return packageRoot\n}\n\nfunction snapshotTextFiles(rootDir: string): Record<string, string> {\n return Object.fromEntries(\n listRelativeFiles(rootDir).map((relativePath) => [\n relativePath,\n fs.readFileSync(path.join(rootDir, relativePath), 'utf8'),\n ]),\n )\n}\n\nfunction listRelativeFiles(rootDir: string): string[] {\n if (!fs.existsSync(rootDir)) {\n return []\n }\n\n const collected: string[] = []\n for (const entry of fs.readdirSync(rootDir, { withFileTypes: true })) {\n const absolutePath = path.join(rootDir, entry.name)\n if (entry.isDirectory()) {\n for (const nestedPath of listRelativeFiles(absolutePath)) {\n collected.push(path.join(entry.name, nestedPath))\n }\n continue\n }\n if (entry.isFile()) {\n collected.push(entry.name)\n }\n }\n\n return collected.map(normalizePath).sort()\n}\n\nfunction mapSharedSourceToOutput(relativePath: string): string {\n if (relativePath === 'AGENTS.md.template') {\n return 'AGENTS.md'\n }\n\n if (relativePath.startsWith('scripts/')) {\n return relativePath\n }\n\n if (!relativePath.startsWith('ai/')) {\n throw new Error(`Unexpected shared source path: ${relativePath}`)\n }\n\n return normalizePath(path.join('.ai', relativePath.slice('ai/'.length)))\n}\n\nfunction mapClaudeSourceToOutput(relativePath: string): string {\n if (relativePath === 'CLAUDE.md.template') {\n return 'CLAUDE.md'\n }\n if (relativePath === 'settings.json') {\n return '.claude/settings.json'\n }\n if (relativePath === 'mcp.json.example') {\n return '.mcp.json.example'\n }\n if (relativePath.startsWith('hooks/')) {\n return normalizePath(path.join('.claude', relativePath))\n }\n\n throw new Error(`Unexpected Claude source path: ${relativePath}`)\n}\n\nfunction mapCursorSourceToOutput(relativePath: string): string {\n if (relativePath === 'hooks.json') {\n return '.cursor/hooks.json'\n }\n if (relativePath === 'mcp.json.example') {\n return '.cursor/mcp.json.example'\n }\n if (relativePath.startsWith('hooks/') || relativePath.startsWith('rules/')) {\n return normalizePath(path.join('.cursor', relativePath))\n }\n\n throw new Error(`Unexpected Cursor source path: ${relativePath}`)\n}\n\nfunction mapCodexSourceToOutput(relativePath: string): string | null {\n if (relativePath === 'mcp.json.example') {\n return '.codex/mcp.json.example'\n }\n if (relativePath === 'enforcement-rules.md') {\n return null\n }\n\n throw new Error(`Unexpected Codex source path: ${relativePath}`)\n}\n\nfunction readPlaywrightConfigPathFromTemplate(): string {\n const packageTemplate = JSON.parse(fs.readFileSync(standaloneTemplatePackageJsonPath, 'utf8')) as {\n scripts?: Record<string, string>\n }\n const integrationScript = packageTemplate.scripts?.['test:integration']\n if (!integrationScript) {\n throw new Error('Standalone template is missing the test:integration script')\n }\n\n const configPathMatch = integrationScript.match(/--config\\s+([^\\s]+)/)\n if (!configPathMatch?.[1]) {\n throw new Error('Standalone template test:integration script is missing --config')\n }\n\n return normalizePath(configPathMatch[1])\n}\n\nfunction readPlaywrightConfigPathFromCliRunner(): string {\n const integrationRunnerSource = fs.readFileSync(cliIntegrationRunnerPath, 'utf8')\n const configPathMatch = integrationRunnerSource.match(/const PLAYWRIGHT_INTEGRATION_CONFIG_PATH = '([^']+)'/)\n if (!configPathMatch?.[1]) {\n throw new Error('CLI integration runner is missing PLAYWRIGHT_INTEGRATION_CONFIG_PATH')\n }\n\n return normalizePath(configPathMatch[1])\n}\n\nfunction expectedGuideOutputNames(): string[] {\n const collected = new Set<string>()\n\n // Static conceptual guides checked into create-app (e.g. module-system.md) are\n // bundled into dist/agentic/guides by the CLI build and copied wholesale.\n const staticGuidesRoot = path.join(agenticRoot, 'guides')\n if (fs.existsSync(staticGuidesRoot)) {\n for (const entry of fs.readdirSync(staticGuidesRoot, { withFileTypes: true })) {\n if (entry.isFile() && entry.name.endsWith('.md')) {\n collected.add(entry.name)\n }\n }\n }\n\n for (const packageName of fs.readdirSync(packagesRoot)) {\n const packageGuide = path.join(packagesRoot, packageName, 'agentic', 'standalone-guide.md')\n if (fs.existsSync(packageGuide) && !UNROUTED_PACKAGE_GUIDES.has(packageName)) {\n collected.add(`${packageName}.md`)\n }\n\n const modulesRoot = path.join(packagesRoot, packageName, 'src', 'modules')\n if (!fs.existsSync(modulesRoot)) {\n continue\n }\n\n for (const moduleName of fs.readdirSync(modulesRoot)) {\n const moduleGuide = path.join(modulesRoot, moduleName, 'agentic', 'standalone-guide.md')\n if (fs.existsSync(moduleGuide)) {\n collected.add(`${packageName}.${moduleName}.md`)\n }\n }\n }\n\n // Generated fact-sheet artifacts (spec 2026-06-27-ts-morph-module-fact-sheets):\n // the module-facts.json sidecar is copied as-is and fact-sheets are filtered to the\n // fixture's enabled modules. The legacy core.<module>.md redirect stubs are no longer\n // emitted (#3754). framework-extension-points.md is likewise generated into\n // dist/agentic/guides by both build.mjs pipelines (#4810) rather than checked in\n // alongside the static conceptual guides, so it needs an explicit entry here.\n collected.add('module-facts.json')\n collected.add('framework-extension-points.md')\n collected.add('upstream/AGENTS.md')\n collected.add('upstream/BACKWARD_COMPATIBILITY.md')\n collected.add('upstream/manifest.json')\n for (const moduleId of FIXTURE_ENABLED_MODULES) {\n collected.add(normalizePath(path.join('modules', `${moduleId}.md`)))\n }\n\n return Array.from(collected).sort()\n}\n\nfunction assertPathsExist(appDir: string, relativePaths: string[]): void {\n const missingPaths = relativePaths.filter((relativePath) => !fs.existsSync(path.join(appDir, relativePath)))\n expect(missingPaths).toEqual([])\n}\n\ntest.describe('TC-INT-008: CLI agentic init mirrors standalone scaffolding assets', () => {\n test.beforeAll(() => {\n ensureCliBuilt()\n })\n\n test('should run bootstrap-free and generate the shared, guide, and tool-specific agentic files', () => {\n const tempRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'mercato-cli-agentic-'))\n\n try {\n const appDir = createStandaloneFixture(tempRoot)\n const standalonePlaywrightConfigPath = readPlaywrightConfigPathFromTemplate()\n const cliPlaywrightConfigPath = readPlaywrightConfigPathFromCliRunner()\n const commandOutput = runMercato(['agentic:init', '--tool=claude-code,codex,cursor'], appDir)\n\n expect(cliPlaywrightConfigPath).toBe(standalonePlaywrightConfigPath)\n expect(commandOutput).toContain('Agentic setup complete:')\n expect(fs.existsSync(path.join(appDir, '.mercato', 'generated'))).toBe(false)\n\n const sharedOutputs = listRelativeFiles(path.join(agenticRoot, 'shared')).map(mapSharedSourceToOutput)\n const claudeOutputs = listRelativeFiles(path.join(agenticRoot, 'claude-code')).map(mapClaudeSourceToOutput)\n const cursorOutputs = listRelativeFiles(path.join(agenticRoot, 'cursor')).map(mapCursorSourceToOutput)\n const codexOutputs = listRelativeFiles(path.join(agenticRoot, 'codex'))\n .map(mapCodexSourceToOutput)\n .filter((relativePath): relativePath is string => relativePath !== null)\n\n expect(sharedOutputs).toContain(standalonePlaywrightConfigPath)\n assertPathsExist(appDir, [...sharedOutputs, ...claudeOutputs, ...cursorOutputs, ...codexOutputs])\n expect(fs.existsSync(path.join(appDir, standalonePlaywrightConfigPath))).toBe(true)\n\n const generatedGuideNames = listRelativeFiles(path.join(appDir, '.ai', 'guides'))\n expect(generatedGuideNames).toEqual(expectedGuideOutputNames())\n\n const agentsSource = fs.readFileSync(path.join(appDir, 'AGENTS.md'), 'utf8')\n expect(agentsSource).toContain('<!-- CODEX_ENFORCEMENT_RULES_START -->')\n expect(agentsSource).toContain('.ai/guides/upstream/BACKWARD_COMPATIBILITY.md')\n\n // The Module-Specific Guides marker block is a compact enabled-module ID\n // index (enabled \u2229 bundled) plus one progressively loaded path pattern.\n for (const moduleId of FIXTURE_ENABLED_MODULES) {\n expect(agentsSource).toContain(`\\`${moduleId}\\``)\n }\n expect(agentsSource).toContain('`.ai/guides/modules/<id>.md`')\n expect(agentsSource.match(/\\.ai\\/guides\\/modules\\//g)).toHaveLength(1)\n expect(agentsSource).not.toContain('`auth`')\n expect(agentsSource).not.toContain('Core CRM capabilities')\n\n const specsReadmeSource = fs.readFileSync(path.join(appDir, '.ai', 'specs', 'README.md'), 'utf8')\n expect(specsReadmeSource).toContain('sample-store')\n\n const cursorRulesSource = fs.readFileSync(path.join(appDir, '.cursor', 'rules', 'open-mercato.mdc'), 'utf8')\n expect(cursorRulesSource).toContain('sample-store')\n\n // om-spec-writing moved to the external open-mercato/skills collection\n // (installed via `yarn install-skills`), so agentic:init must not ship a copy.\n expect(fs.existsSync(path.join(appDir, '.ai', 'skills', 'om-spec-writing'))).toBe(false)\n expect(fs.existsSync(path.join(appDir, 'scripts', 'install-skills.sh'))).toBe(true)\n\n // install-skills.sh (run by agentic:init) installs every local tier skill once,\n // into the canonical .agents/skills/. Codex and Cursor read that directory\n // natively, so they get no skills directory of their own; Claude Code cannot,\n // so it keeps a link layer pointing back at the canonical copy.\n const tiersManifest = JSON.parse(\n fs.readFileSync(path.join(agenticRoot, 'shared', 'ai', 'skills', 'tiers.json'), 'utf8'),\n ) as { default: string[]; tiers: Record<string, { skills: string[] }> }\n const defaultTierSkills = tiersManifest.default.flatMap((tierName) => tiersManifest.tiers[tierName].skills)\n expect(defaultTierSkills.length).toBeGreaterThan(0)\n\n for (const skillName of defaultTierSkills) {\n const canonicalLinkPath = path.join(appDir, '.agents', 'skills', skillName)\n expect(fs.lstatSync(canonicalLinkPath).isSymbolicLink()).toBe(true)\n expect(normalizePath(fs.readlinkSync(canonicalLinkPath))).toBe(`../../.ai/skills/${skillName}`)\n\n const claudeLinkPath = path.join(appDir, '.claude', 'skills', skillName)\n expect(fs.lstatSync(claudeLinkPath).isSymbolicLink()).toBe(true)\n expect(normalizePath(fs.readlinkSync(claudeLinkPath))).toBe(`../../.agents/skills/${skillName}`)\n }\n\n expect(fs.existsSync(path.join(appDir, '.codex', 'skills'))).toBe(false)\n expect(fs.existsSync(path.join(appDir, '.cursor', 'skills'))).toBe(false)\n } finally {\n fs.rmSync(tempRoot, { recursive: true, force: true })\n }\n })\n\n test('emits a runnable exact-version framework context escape hatch for an installed package', () => {\n const tempRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'mercato-cli-framework-context-'))\n\n try {\n const appDir = createStandaloneFixture(tempRoot)\n const packageRoot = installFakeFrameworkPackage(appDir)\n const resolvedPackageRoot = fs.realpathSync(packageRoot)\n const packageBefore = snapshotTextFiles(packageRoot)\n\n runMercato(['agentic:init', '--tool=codex'], appDir)\n const generatedScript = path.join(appDir, 'scripts', 'framework-context.mjs')\n expect(fs.existsSync(generatedScript)).toBe(true)\n\n const output = runCommand(\n process.execPath,\n [generatedScript, '--module', 'customers', '--query', 'Person', '--json'],\n appDir,\n // The generated standalone helper must not depend on a globally\n // installed ripgrep binary; process.execPath is already absolute.\n { PATH: '', Path: '' },\n )\n const context = JSON.parse(output) as {\n module: string\n package: { name: string; version: string; root: string }\n sourceKind: string\n sourceRoot: string\n materializedSource: string\n instructions: Array<{ kind: string; path: string | null; materializedPath?: string }>\n boundedSearch: { status: string; matches: number; maxMatches: number; result: string }\n warnings: string[]\n }\n\n expect(context.module).toBe('customers')\n expect(context.package).toEqual({ name: '@open-mercato/core', version: coreVersion, root: resolvedPackageRoot })\n expect(context.sourceKind).toBe('source')\n expect(normalizePath(context.sourceRoot)).toBe(normalizePath(path.join(resolvedPackageRoot, 'src', 'modules', 'customers')))\n expect(context.instructions.filter((entry) => entry.path).map((entry) => entry.kind)).toEqual([\n 'standalone-root',\n 'upstream-bc',\n 'package',\n 'module-1',\n 'upstream-root',\n ])\n expect(context.instructions.filter((entry) => entry.path).every((entry) => entry.materializedPath)).toBe(true)\n expect(context.boundedSearch).toMatchObject({ status: 'matched', matches: 1, maxMatches: 200 })\n expect(fs.existsSync(path.join(appDir, context.materializedSource))).toBe(true)\n expect(fs.existsSync(path.join(appDir, context.boundedSearch.result))).toBe(true)\n expect(context.warnings.some((warning) => warning.includes('Generated facts for customers are stale'))).toBe(false)\n expect(snapshotTextFiles(packageRoot)).toEqual(packageBefore)\n } finally {\n fs.rmSync(tempRoot, { recursive: true, force: true })\n }\n })\n})\n"],
5
+ "mappings": "AAAA,SAAS,QAAQ,YAAY;AAC7B,SAAS,oBAAoB;AAC7B,OAAO,QAAQ;AACf,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,SAAS,qBAAqB;AAE9B,MAAM,YAAY,KAAK,QAAQ,cAAc,YAAY,GAAG,CAAC;AAC7D,MAAM,WAAW,KAAK,QAAQ,WAAW,MAAM,MAAM,MAAM,MAAM,IAAI;AACrE,MAAM,SAAS,KAAK,KAAK,UAAU,YAAY,KAAK;AACpD,MAAM,SAAS,KAAK,KAAK,QAAQ,QAAQ,QAAQ;AACjD,MAAM,iBAAiB,KAAK,KAAK,QAAQ,WAAW;AACpD,MAAM,2BAA2B,KAAK,KAAK,Q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Q,UAAU,EAAE,KAAK,QAAQ;AACxC,aAAO,cAAc,QAAQ,UAAU,CAAC,EAAE,KAAK,cAAc,KAAK,KAAK,qBAAqB,OAAO,WAAW,WAAW,CAAC,CAAC;AAC3H,aAAO,QAAQ,aAAa,OAAO,CAAC,UAAU,MAAM,IAAI,EAAE,IAAI,CAAC,UAAU,MAAM,IAAI,CAAC,EAAE,QAAQ;AAAA,QAC5F;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF,CAAC;AACD,aAAO,QAAQ,aAAa,OAAO,CAAC,UAAU,MAAM,IAAI,EAAE,MAAM,CAAC,UAAU,MAAM,gBAAgB,CAAC,EAAE,KAAK,IAAI;AAC7G,aAAO,QAAQ,aAAa,EAAE,cAAc,EAAE,QAAQ,WAAW,SAAS,GAAG,YAAY,IAAI,CAAC;AAC9F,aAAO,GAAG,WAAW,KAAK,KAAK,QAAQ,QAAQ,kBAAkB,CAAC,CAAC,EAAE,KAAK,IAAI;AAC9E,aAAO,GAAG,WAAW,KAAK,KAAK,QAAQ,QAAQ,cAAc,MAAM,CAAC,CAAC,EAAE,KAAK,IAAI;AAChF,aAAO,QAAQ,SAAS,KAAK,CAAC,YAAY,QAAQ,SAAS,yCAAyC,CAAC,CAAC,EAAE,KAAK,KAAK;AAClH,aAAO,kBAAkB,WAAW,CAAC,EAAE,QAAQ,aAAa;AAAA,IAC9D,UAAE;AACA,SAAG,OAAO,UAAU,EAAE,WAAW,MAAM,OAAO,KAAK,CAAC;AAAA,IACtD;AAAA,EACF,CAAC;AACH,CAAC;",
6
6
  "names": []
7
7
  }
@@ -20,6 +20,8 @@ function parseArgs(args) {
20
20
  const arg = args[i];
21
21
  if (arg === "--force" || arg === "-f") {
22
22
  options.force = true;
23
+ } else if (arg === "--update-harness") {
24
+ options.updateHarness = true;
23
25
  } else if (arg.startsWith("--tool=")) {
24
26
  options.tool = arg.slice("--tool=".length);
25
27
  } else if (arg === "--tool") {
@@ -46,11 +48,15 @@ function resolveRelevantAgenticFiles(toolOption) {
46
48
  async function runAgenticInit(args) {
47
49
  const targetDir = resolve(".");
48
50
  const options = parseArgs(args);
51
+ if (options.force && options.updateHarness) {
52
+ console.error("\u274C --force and --update-harness are mutually exclusive");
53
+ return 1;
54
+ }
49
55
  if (!existsSync(join(targetDir, "src", "modules.ts"))) {
50
56
  console.error("\u274C Not an Open Mercato app directory (src/modules.ts not found)");
51
57
  return 1;
52
58
  }
53
- if (!options.force) {
59
+ if (!options.force && !options.updateHarness) {
54
60
  const existingFiles = resolveRelevantAgenticFiles(options.tool).filter((relativePath) => existsSync(join(targetDir, relativePath)));
55
61
  if (existingFiles.length > 0) {
56
62
  console.log("");
@@ -59,7 +65,7 @@ async function runAgenticInit(args) {
59
65
  console.log(` \u2022 ${f}`);
60
66
  }
61
67
  console.log("");
62
- console.log("Run with --force to regenerate from current templates.");
68
+ console.log("Run with --update-harness to preserve local edits, or --force to replace generated files.");
63
69
  console.log("");
64
70
  return 0;
65
71
  }
@@ -68,7 +74,11 @@ async function runAgenticInit(args) {
68
74
  const rl = createInterface({ input: process.stdin, output: process.stdout });
69
75
  const ask = (q) => new Promise((res) => rl.question(q, (a) => res(a.trim())));
70
76
  try {
71
- await runAgenticSetup(targetDir, ask, { tool: options.tool, force: options.force });
77
+ await runAgenticSetup(targetDir, ask, {
78
+ tool: options.tool,
79
+ force: options.force,
80
+ updateHarness: options.updateHarness
81
+ });
72
82
  } finally {
73
83
  rl.close();
74
84
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/lib/agentic-init.ts"],
4
- "sourcesContent": ["import { existsSync } from 'node:fs'\nimport { join, resolve } from 'node:path'\nimport { createInterface } from 'node:readline'\n\ninterface AgenticInitOptions {\n tool?: string\n force?: boolean\n}\n\nconst TOOL_EXISTING_FILES: Record<string, string[]> = {\n 'claude-code': [\n 'CLAUDE.md',\n '.claude/settings.json',\n '.mcp.json.example',\n ],\n 'codex': [\n '.codex/mcp.json.example',\n ],\n 'cursor': [\n '.cursor/hooks.json',\n ],\n}\n\nfunction parseArgs(args: string[]): AgenticInitOptions {\n const options: AgenticInitOptions = {}\n for (let i = 0; i < args.length; i++) {\n const arg = args[i]\n if (arg === '--force' || arg === '-f') {\n options.force = true\n } else if (arg.startsWith('--tool=')) {\n options.tool = arg.slice('--tool='.length)\n } else if (arg === '--tool') {\n options.tool = args[++i]\n }\n }\n return options\n}\n\nexport function resolveRelevantAgenticFiles(toolOption?: string): string[] {\n if (typeof toolOption !== 'string' || toolOption.trim().length === 0) {\n return Object.values(TOOL_EXISTING_FILES).flat()\n }\n\n const toolIds = toolOption.split(',').map((toolId) => toolId.trim()).filter(Boolean)\n const relevantFiles = new Set<string>()\n\n for (const toolId of toolIds) {\n const toolFiles = TOOL_EXISTING_FILES[toolId]\n if (!toolFiles) continue\n for (const relativePath of toolFiles) {\n relevantFiles.add(relativePath)\n }\n }\n\n return relevantFiles.size > 0 ? Array.from(relevantFiles) : Object.values(TOOL_EXISTING_FILES).flat()\n}\n\nexport async function runAgenticInit(args: string[]): Promise<number> {\n const targetDir = resolve('.')\n const options = parseArgs(args)\n\n // Validate this is an Open Mercato app directory\n if (!existsSync(join(targetDir, 'src', 'modules.ts'))) {\n console.error('\u274C Not an Open Mercato app directory (src/modules.ts not found)')\n return 1\n }\n\n // Check if agentic files already exist and warn unless --force\n if (!options.force) {\n const existingFiles = resolveRelevantAgenticFiles(options.tool)\n .filter((relativePath) => existsSync(join(targetDir, relativePath)))\n\n if (existingFiles.length > 0) {\n console.log('')\n console.log('\u26A0\uFE0F Agentic files already exist:')\n for (const f of existingFiles) {\n console.log(` \u2022 ${f}`)\n }\n console.log('')\n console.log('Run with --force to regenerate from current templates.')\n console.log('')\n return 0\n }\n }\n\n // Dynamic import of the setup wizard from create-app's agentic source\n // Since we can't import from create-app at runtime in standalone apps,\n // we inline the generator logic here using the same source files approach.\n const { runAgenticSetup } = await import('./agentic-setup.js')\n\n const rl = createInterface({ input: process.stdin, output: process.stdout })\n const ask = (q: string) => new Promise<string>((res) => rl.question(q, (a) => res(a.trim())))\n\n try {\n await runAgenticSetup(targetDir, ask, { tool: options.tool, force: options.force })\n } finally {\n rl.close()\n }\n\n return 0\n}\n"],
5
- "mappings": "AAAA,SAAS,kBAAkB;AAC3B,SAAS,MAAM,eAAe;AAC9B,SAAS,uBAAuB;AAOhC,MAAM,sBAAgD;AAAA,EACpD,eAAe;AAAA,IACb;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,SAAS;AAAA,IACP;AAAA,EACF;AAAA,EACA,UAAU;AAAA,IACR;AAAA,EACF;AACF;AAEA,SAAS,UAAU,MAAoC;AACrD,QAAM,UAA8B,CAAC;AACrC,WAAS,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;AACpC,UAAM,MAAM,KAAK,CAAC;AAClB,QAAI,QAAQ,aAAa,QAAQ,MAAM;AACrC,cAAQ,QAAQ;AAAA,IAClB,WAAW,IAAI,WAAW,SAAS,GAAG;AACpC,cAAQ,OAAO,IAAI,MAAM,UAAU,MAAM;AAAA,IAC3C,WAAW,QAAQ,UAAU;AAC3B,cAAQ,OAAO,KAAK,EAAE,CAAC;AAAA,IACzB;AAAA,EACF;AACA,SAAO;AACT;AAEO,SAAS,4BAA4B,YAA+B;AACzE,MAAI,OAAO,eAAe,YAAY,WAAW,KAAK,EAAE,WAAW,GAAG;AACpE,WAAO,OAAO,OAAO,mBAAmB,EAAE,KAAK;AAAA,EACjD;AAEA,QAAM,UAAU,WAAW,MAAM,GAAG,EAAE,IAAI,CAAC,WAAW,OAAO,KAAK,CAAC,EAAE,OAAO,OAAO;AACnF,QAAM,gBAAgB,oBAAI,IAAY;AAEtC,aAAW,UAAU,SAAS;AAC5B,UAAM,YAAY,oBAAoB,MAAM;AAC5C,QAAI,CAAC,UAAW;AAChB,eAAW,gBAAgB,WAAW;AACpC,oBAAc,IAAI,YAAY;AAAA,IAChC;AAAA,EACF;AAEA,SAAO,cAAc,OAAO,IAAI,MAAM,KAAK,aAAa,IAAI,OAAO,OAAO,mBAAmB,EAAE,KAAK;AACtG;AAEA,eAAsB,eAAe,MAAiC;AACpE,QAAM,YAAY,QAAQ,GAAG;AAC7B,QAAM,UAAU,UAAU,IAAI;AAG9B,MAAI,CAAC,WAAW,KAAK,WAAW,OAAO,YAAY,CAAC,GAAG;AACrD,YAAQ,MAAM,sEAAiE;AAC/E,WAAO;AAAA,EACT;AAGA,MAAI,CAAC,QAAQ,OAAO;AAClB,UAAM,gBAAgB,4BAA4B,QAAQ,IAAI,EAC3D,OAAO,CAAC,iBAAiB,WAAW,KAAK,WAAW,YAAY,CAAC,CAAC;AAErE,QAAI,cAAc,SAAS,GAAG;AAC5B,cAAQ,IAAI,EAAE;AACd,cAAQ,IAAI,4CAAkC;AAC9C,iBAAW,KAAK,eAAe;AAC7B,gBAAQ,IAAI,aAAQ,CAAC,EAAE;AAAA,MACzB;AACA,cAAQ,IAAI,EAAE;AACd,cAAQ,IAAI,wDAAwD;AACpE,cAAQ,IAAI,EAAE;AACd,aAAO;AAAA,IACT;AAAA,EACF;AAKA,QAAM,EAAE,gBAAgB,IAAI,MAAM,OAAO,oBAAoB;AAE7D,QAAM,KAAK,gBAAgB,EAAE,OAAO,QAAQ,OAAO,QAAQ,QAAQ,OAAO,CAAC;AAC3E,QAAM,MAAM,CAAC,MAAc,IAAI,QAAgB,CAAC,QAAQ,GAAG,SAAS,GAAG,CAAC,MAAM,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;AAE5F,MAAI;AACF,UAAM,gBAAgB,WAAW,KAAK,EAAE,MAAM,QAAQ,MAAM,OAAO,QAAQ,MAAM,CAAC;AAAA,EACpF,UAAE;AACA,OAAG,MAAM;AAAA,EACX;AAEA,SAAO;AACT;",
4
+ "sourcesContent": ["import { existsSync } from 'node:fs'\nimport { join, resolve } from 'node:path'\nimport { createInterface } from 'node:readline'\n\ninterface AgenticInitOptions {\n tool?: string\n force?: boolean\n updateHarness?: boolean\n}\n\nconst TOOL_EXISTING_FILES: Record<string, string[]> = {\n 'claude-code': [\n 'CLAUDE.md',\n '.claude/settings.json',\n '.mcp.json.example',\n ],\n 'codex': [\n '.codex/mcp.json.example',\n ],\n 'cursor': [\n '.cursor/hooks.json',\n ],\n}\n\nfunction parseArgs(args: string[]): AgenticInitOptions {\n const options: AgenticInitOptions = {}\n for (let i = 0; i < args.length; i++) {\n const arg = args[i]\n if (arg === '--force' || arg === '-f') {\n options.force = true\n } else if (arg === '--update-harness') {\n options.updateHarness = true\n } else if (arg.startsWith('--tool=')) {\n options.tool = arg.slice('--tool='.length)\n } else if (arg === '--tool') {\n options.tool = args[++i]\n }\n }\n return options\n}\n\nexport function resolveRelevantAgenticFiles(toolOption?: string): string[] {\n if (typeof toolOption !== 'string' || toolOption.trim().length === 0) {\n return Object.values(TOOL_EXISTING_FILES).flat()\n }\n\n const toolIds = toolOption.split(',').map((toolId) => toolId.trim()).filter(Boolean)\n const relevantFiles = new Set<string>()\n\n for (const toolId of toolIds) {\n const toolFiles = TOOL_EXISTING_FILES[toolId]\n if (!toolFiles) continue\n for (const relativePath of toolFiles) {\n relevantFiles.add(relativePath)\n }\n }\n\n return relevantFiles.size > 0 ? Array.from(relevantFiles) : Object.values(TOOL_EXISTING_FILES).flat()\n}\n\nexport async function runAgenticInit(args: string[]): Promise<number> {\n const targetDir = resolve('.')\n const options = parseArgs(args)\n\n if (options.force && options.updateHarness) {\n console.error('\u274C --force and --update-harness are mutually exclusive')\n return 1\n }\n\n // Validate this is an Open Mercato app directory\n if (!existsSync(join(targetDir, 'src', 'modules.ts'))) {\n console.error('\u274C Not an Open Mercato app directory (src/modules.ts not found)')\n return 1\n }\n\n // Check if agentic files already exist and warn unless --force\n if (!options.force && !options.updateHarness) {\n const existingFiles = resolveRelevantAgenticFiles(options.tool)\n .filter((relativePath) => existsSync(join(targetDir, relativePath)))\n\n if (existingFiles.length > 0) {\n console.log('')\n console.log('\u26A0\uFE0F Agentic files already exist:')\n for (const f of existingFiles) {\n console.log(` \u2022 ${f}`)\n }\n console.log('')\n console.log('Run with --update-harness to preserve local edits, or --force to replace generated files.')\n console.log('')\n return 0\n }\n }\n\n // Dynamic import of the setup wizard from create-app's agentic source\n // Since we can't import from create-app at runtime in standalone apps,\n // we inline the generator logic here using the same source files approach.\n const { runAgenticSetup } = await import('./agentic-setup.js')\n\n const rl = createInterface({ input: process.stdin, output: process.stdout })\n const ask = (q: string) => new Promise<string>((res) => rl.question(q, (a) => res(a.trim())))\n\n try {\n await runAgenticSetup(targetDir, ask, {\n tool: options.tool,\n force: options.force,\n updateHarness: options.updateHarness,\n })\n } finally {\n rl.close()\n }\n\n return 0\n}\n"],
5
+ "mappings": "AAAA,SAAS,kBAAkB;AAC3B,SAAS,MAAM,eAAe;AAC9B,SAAS,uBAAuB;AAQhC,MAAM,sBAAgD;AAAA,EACpD,eAAe;AAAA,IACb;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,SAAS;AAAA,IACP;AAAA,EACF;AAAA,EACA,UAAU;AAAA,IACR;AAAA,EACF;AACF;AAEA,SAAS,UAAU,MAAoC;AACrD,QAAM,UAA8B,CAAC;AACrC,WAAS,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;AACpC,UAAM,MAAM,KAAK,CAAC;AAClB,QAAI,QAAQ,aAAa,QAAQ,MAAM;AACrC,cAAQ,QAAQ;AAAA,IAClB,WAAW,QAAQ,oBAAoB;AACrC,cAAQ,gBAAgB;AAAA,IAC1B,WAAW,IAAI,WAAW,SAAS,GAAG;AACpC,cAAQ,OAAO,IAAI,MAAM,UAAU,MAAM;AAAA,IAC3C,WAAW,QAAQ,UAAU;AAC3B,cAAQ,OAAO,KAAK,EAAE,CAAC;AAAA,IACzB;AAAA,EACF;AACA,SAAO;AACT;AAEO,SAAS,4BAA4B,YAA+B;AACzE,MAAI,OAAO,eAAe,YAAY,WAAW,KAAK,EAAE,WAAW,GAAG;AACpE,WAAO,OAAO,OAAO,mBAAmB,EA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