@open-mercato/cli 0.6.7 → 0.6.8-develop.6874.1.982d6097d8

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
@@ -1,6 +1,5 @@
1
- [build:cli] found 96 entry points
1
+ [build:cli] found 101 entry points
2
2
  Copied create-app/agentic/ → dist/agentic/
3
- Discovered 7 standalone guides → dist/agentic/guides/
4
3
  [module-facts] module registry unavailable (registryPath not provided); API route auth omitted for ai_assistant
5
4
  [module-facts] module registry unavailable (registryPath not provided); API route auth omitted for channel_gmail
6
5
  [module-facts] module registry unavailable (registryPath not provided); API route auth omitted for channel_imap
@@ -20,14 +19,13 @@ Discovered 7 standalone guides → dist/agentic/guides/
20
19
  [module-facts] module registry unavailable (registryPath not provided); API route auth omitted for customers
21
20
  [module-facts] module registry unavailable (registryPath not provided); API route auth omitted for dashboards
22
21
  [module-facts] module registry unavailable (registryPath not provided); API route auth omitted for data_sync
22
+ [module-facts] module registry unavailable (registryPath not provided); API route auth omitted for design_system
23
23
  [module-facts] module registry unavailable (registryPath not provided); API route auth omitted for dictionaries
24
24
  [module-facts] module registry unavailable (registryPath not provided); API route auth omitted for directory
25
25
  [module-facts] module registry unavailable (registryPath not provided); API route auth omitted for entities
26
- Generated 54 module fact-sheets → dist/agentic/guides/modules/
27
26
  [module-facts] module registry unavailable (registryPath not provided); API route auth omitted for feature_toggles
28
27
  [module-facts] module registry unavailable (registryPath not provided); API route auth omitted for inbox_ops
29
28
  [module-facts] module registry unavailable (registryPath not provided); API route auth omitted for integrations
30
- [build:cli] built successfully
31
29
  [module-facts] module registry unavailable (registryPath not provided); API route auth omitted for messages
32
30
  [module-facts] module registry unavailable (registryPath not provided); API route auth omitted for notifications
33
31
  [module-facts] module registry unavailable (registryPath not provided); API route auth omitted for payment_gateways
@@ -57,3 +55,5 @@ Generated 54 module fact-sheets → dist/agentic/guides/modules/
57
55
  [module-facts] module registry unavailable (registryPath not provided); API route auth omitted for storage_s3
58
56
  [module-facts] module registry unavailable (registryPath not provided); API route auth omitted for sync_akeneo
59
57
  [module-facts] module registry unavailable (registryPath not provided); API route auth omitted for webhooks
58
+ Generated 55 module fact-sheets → dist/agentic/guides/modules/
59
+ [build:cli] built successfully
package/build.mjs CHANGED
@@ -1,4 +1,5 @@
1
1
  import { chmodSync, cpSync, existsSync, mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs'
2
+ import { createHash } from 'node:crypto'
2
3
  import { dirname, join } from 'node:path'
3
4
  import { fileURLToPath, pathToFileURL } from 'node:url'
4
5
  import { atomicWriteFileSync } from '../../scripts/lib/add-js-extension.mjs'
@@ -26,11 +27,26 @@ await buildPackage(packageDir, {
26
27
  // Copy agentic source files from create-app so generators can read them at runtime.
27
28
  const agenticSrc = join(packageDir, '..', 'create-app', 'agentic')
28
29
  if (existsSync(agenticSrc)) {
30
+ rmSync(join(outdir, 'agentic'), { recursive: true, force: true })
29
31
  cpSync(agenticSrc, join(outdir, 'agentic'), { recursive: true })
30
32
  console.log('Copied create-app/agentic/ → dist/agentic/')
31
33
  }
32
34
 
33
- // Discover standalone guides across sibling packages.
35
+ const repositoryRoot = join(packageDir, '..', '..')
36
+ const upstreamDir = join(outdir, 'agentic', 'guides', 'upstream')
37
+ mkdirSync(upstreamDir, { recursive: true })
38
+ const cliVersion = JSON.parse(readFileSync(join(packageDir, 'package.json'), 'utf8')).version ?? null
39
+ const upstreamManifest = { version: 1, generator: `@open-mercato/cli@${cliVersion ?? 'unknown'}`, files: {} }
40
+ for (const file of ['AGENTS.md', 'BACKWARD_COMPATIBILITY.md']) {
41
+ const source = join(repositoryRoot, file)
42
+ const destination = join(upstreamDir, file)
43
+ cpSync(source, destination)
44
+ upstreamManifest.files[file] = createHash('sha256').update(readFileSync(source)).digest('hex')
45
+ }
46
+ writeFileSync(join(upstreamDir, 'manifest.json'), `${JSON.stringify(upstreamManifest, null, 2)}\n`)
47
+
48
+ // Discover module-specific standalone guides across sibling packages. Package-level
49
+ // guides are intentionally not shipped because they duplicate routed conceptual guides.
34
50
  const packagesDir = join(packageDir, '..')
35
51
  const guidesDestDir = join(outdir, 'agentic', 'guides')
36
52
  mkdirSync(guidesDestDir, { recursive: true })
@@ -39,8 +55,7 @@ await buildPackage(packageDir, {
39
55
  // retains a removed module's full guide or fact-sheet. The legacy `core.<module>.md`
40
56
  // redirect stubs are no longer emitted (#3754); this purge also deletes any that linger
41
57
  // in an incremental `dist/` from an older build. Mirrors packages/create-app/build.mjs;
42
- // the conceptual `module-system.md` and the single-dot package guides are
43
- // re-copied/re-discovered below.
58
+ // conceptual guides remain while stale single-dot package guides are removed below.
44
59
  rmSync(join(guidesDestDir, 'modules'), { recursive: true, force: true })
45
60
  for (const entry of readdirSync(guidesDestDir)) {
46
61
  if (/^core\..+\.md$/.test(entry)) {
@@ -50,10 +65,11 @@ await buildPackage(packageDir, {
50
65
 
51
66
  let guidesFound = 0
52
67
  for (const pkg of readdirSync(packagesDir)) {
68
+ // Package-level source guides remain for monorepo context, but standalone apps route
69
+ // through conceptual and module-level guides, so remove their stale emitted copies.
53
70
  const guideSource = join(packagesDir, pkg, 'agentic', 'standalone-guide.md')
54
71
  if (existsSync(guideSource)) {
55
- cpSync(guideSource, join(guidesDestDir, `${pkg}.md`))
56
- guidesFound++
72
+ rmSync(join(guidesDestDir, `${pkg}.md`), { force: true })
57
73
  }
58
74
 
59
75
  const modulesDir = join(packagesDir, pkg, 'src', 'modules')
@@ -76,7 +92,7 @@ await buildPackage(packageDir, {
76
92
  // the freshly built ts-morph extractor + resolver-routed discovery, so
77
93
  // `mercato agentic:init` bundles the same guides as a create-mercato-app scaffold
78
94
  // (packages/create-app/build.mjs). Discovery goes through the resolver, never a
79
- // hardcoded packages/* path (.ai/lessons.md §161-169).
95
+ // hardcoded packages/* path (.ai/lessons/standalone-scaffolding-and-generators-must-not-assume.md).
80
96
  const { extractAllModuleFacts, renderModuleFactsJson } = await import(
81
97
  pathToFileURL(join(outdir, 'lib', 'generators', 'module-facts.js')).href
82
98
  )
@@ -95,7 +111,7 @@ await buildPackage(packageDir, {
95
111
  coreVersion = null
96
112
  }
97
113
 
98
- const { factsByModule, markdownByModule, warnings } = extractAllModuleFacts({
114
+ const { factsByModule, markdownByModule, frameworkMarkdown, warnings } = extractAllModuleFacts({
99
115
  sources,
100
116
  registryPath: existsSync(registryPath) ? registryPath : null,
101
117
  coreVersion,
@@ -107,6 +123,7 @@ await buildPackage(packageDir, {
107
123
  writeFileSync(join(modulesGuidesDir, `${moduleId}.md`), markdown)
108
124
  }
109
125
  writeFileSync(join(guidesDestDir, 'module-facts.json'), renderModuleFactsJson(factsByModule))
126
+ writeFileSync(join(guidesDestDir, 'framework-extension-points.md'), frameworkMarkdown)
110
127
 
111
128
  for (const warning of warnings) console.warn(warning)
112
129
  console.log(`Generated ${Object.keys(markdownByModule).length} module fact-sheets → dist/agentic/guides/modules/`)
@@ -1,121 +1,65 @@
1
- /**
2
- * Claude Code PostToolUse hook: entity-migration-check
3
- *
4
- * Fires after Write/Edit/MultiEdit. Detects entity file modifications
5
- * without an accompanying migration and blocks the agent with a reminder.
6
- *
7
- * Three-state logic:
8
- * 1. Migration file was written → exit 0 (agent is already on it)
9
- * 2. Not an entity file → exit 0 (not relevant)
10
- * 3. Entity written, no fresh migration → block with migration instructions
11
- */
12
-
1
+ /** Remind Claude Code to generate and review a schema diff after entity edits. */
13
2
  import { readdirSync, statSync } from 'node:fs'
14
3
  import { join, relative } from 'node:path'
15
4
 
16
- const ENTITY_PATTERN = /^src\/modules\/([^/]+)\/entities\/.*\.ts$/
17
- const MIGRATION_PATTERN = /^src\/modules\/([^/]+)\/migrations\/.*\.ts$/
5
+ const ENTITY_PATTERN = /^src\/modules\/([^/]+)\/data\/entities\.ts$/
6
+ const MIGRATION_PATTERN = /^src\/modules\/([^/]+)\/migrations\/[^/]+\.ts$/
18
7
 
19
8
  interface PostToolUseInput {
20
- tool_input?: {
21
- file_path?: string
22
- content?: string
23
- }
24
- tool_name?: string
9
+ tool_input?: { file_path?: string }
25
10
  }
26
11
 
27
- function getRelativePath(filePath: string): string {
28
- const projectDir = process.env.CLAUDE_PROJECT_DIR || process.cwd()
29
- if (filePath.startsWith('/')) {
30
- return relative(projectDir, filePath)
31
- }
32
- return filePath
12
+ function projectDir(): string {
13
+ return process.env.CLAUDE_PROJECT_DIR || process.cwd()
33
14
  }
34
15
 
35
- function hasFreshMigration(moduleId: string): boolean {
36
- const projectDir = process.env.CLAUDE_PROJECT_DIR || process.cwd()
37
- const migrationsDir = join(projectDir, 'src', 'modules', moduleId, 'migrations')
16
+ function normalizedRelative(filePath: string): string {
17
+ const value = filePath.startsWith('/') ? relative(projectDir(), filePath) : filePath
18
+ return value.replaceAll('\\', '/')
19
+ }
38
20
 
21
+ function hasFreshMigration(moduleId: string): boolean {
22
+ const migrationsDir = join(projectDir(), 'src', 'modules', moduleId, 'migrations')
39
23
  try {
40
- const files = readdirSync(migrationsDir)
41
- const now = Date.now()
42
- const thirtySecondsAgo = now - 30_000
43
-
44
- for (const file of files) {
45
- if (!file.endsWith('.ts')) continue
46
- const stat = statSync(join(migrationsDir, file))
47
- if (stat.mtimeMs > thirtySecondsAgo) {
48
- return true
49
- }
50
- }
24
+ const cutoff = Date.now() - 30_000
25
+ return readdirSync(migrationsDir).some((file) =>
26
+ file.endsWith('.ts') && statSync(join(migrationsDir, file)).mtimeMs > cutoff,
27
+ )
51
28
  } catch {
52
- // migrations directory doesn't exist yet — that's fine
29
+ return false
53
30
  }
54
-
55
- return false
56
31
  }
57
32
 
58
33
  async function main(): Promise<void> {
59
34
  let input = ''
60
- for await (const chunk of process.stdin) {
61
- input += chunk
62
- }
63
-
64
- if (!input.trim()) {
65
- process.exit(0)
66
- }
35
+ for await (const chunk of process.stdin) input += chunk
36
+ if (!input.trim()) return
67
37
 
68
38
  let data: PostToolUseInput
69
39
  try {
70
40
  data = JSON.parse(input)
71
41
  } catch {
72
- process.exit(0)
42
+ return
73
43
  }
74
44
 
75
45
  const filePath = data.tool_input?.file_path
76
- if (!filePath) {
77
- process.exit(0)
78
- }
46
+ if (!filePath) return
47
+ const rel = normalizedRelative(filePath)
48
+ if (MIGRATION_PATTERN.test(rel)) return
79
49
 
80
- const rel = getRelativePath(filePath)
50
+ const match = rel.match(ENTITY_PATTERN)
51
+ if (!match || hasFreshMigration(match[1])) return
81
52
 
82
- // State 1: Migration file was written → agent is already handling it
83
- if (MIGRATION_PATTERN.test(rel)) {
84
- process.exit(0)
85
- }
86
-
87
- // State 2: Not an entity file → not relevant
88
- const entityMatch = rel.match(ENTITY_PATTERN)
89
- if (!entityMatch) {
90
- process.exit(0)
91
- }
92
-
93
- const moduleId = entityMatch[1]
94
-
95
- // State 3: Entity written — check for fresh migration
96
- if (hasFreshMigration(moduleId)) {
97
- process.exit(0)
98
- }
99
-
100
- // Block: entity modified without migration
101
- const result = {
53
+ process.stdout.write(JSON.stringify({
102
54
  decision: 'block',
103
55
  reason: [
104
- `Entity file modified: ${rel}`,
105
- '',
106
- `Affected module: ${moduleId}`,
107
- '',
108
- 'A database migration is likely needed. Ask the user whether to run:',
109
- ' yarn db:generate',
56
+ `Entity contract changed: ${rel}`,
110
57
  '',
111
- 'Then regenerate registries:',
112
- ' yarn generate',
113
- '',
114
- 'Do NOT run migrations automatically — always confirm with the user first.',
58
+ 'Run `yarn db:generate` as a schema-diff probe and review only the scoped migration plus module snapshot.',
59
+ 'Run `yarn generate` when discovery changed.',
60
+ 'Do not apply the migration with `yarn db:migrate` without explicit user approval.',
115
61
  ].join('\n'),
116
- }
117
-
118
- process.stdout.write(JSON.stringify(result))
62
+ }))
119
63
  }
120
64
 
121
- main()
65
+ void main()
@@ -1,20 +1,6 @@
1
1
  <!-- CODEX_ENFORCEMENT_RULES_START -->
2
- ## CRITICAL rules — always follow without exception
2
+ ## Codex enforcement
3
3
 
4
- 1. **After editing any entity file** (`src/modules/<id>/entities/*.ts`):
5
- - STOP immediately before any further action
6
- - Tell the user: "I modified an entity in module <id>. Should I create a migration?"
7
- - If yes: run `yarn mercato db generate`
8
- - Show the generated migration to the user before applying
9
- - Ask for confirmation, then run `yarn mercato db migrate`
10
- - Run `yarn generate` after migration is applied
4
+ Read and route through the rest of this file; its `Always`, `Never`, and Task Router sections are the authority for Codex too. They are stated once below rather than duplicated here, so this prelude costs the router no budget.
11
5
 
12
- 2. **After editing `src/modules.ts`**: immediately run `yarn generate`
13
-
14
- 3. **Never edit `.mercato/generated/*`**: edit the source and run `yarn generate` instead
15
-
16
- 4. **Before significant features**: check `.ai/specs/` for an existing spec.
17
- If none exists, ask the user whether to create one first.
18
-
19
- ---
20
6
  <!-- CODEX_ENFORCEMENT_RULES_END -->
@@ -1,69 +1,38 @@
1
- /**
2
- * Cursor afterFileEdit hook: entity-migration-check
3
- *
4
- * Detects entity file modifications without an accompanying migration
5
- * and exits non-zero to block the agent with a reminder.
6
- *
7
- * Three-state logic:
8
- * 1. Migration file was written → exit 0 (agent is already on it)
9
- * 2. Not an entity file → exit 0 (not relevant)
10
- * 3. Entity written, no fresh migration → exit 1 with warning
11
- */
12
-
1
+ /** Remind Cursor to generate and review a schema diff after entity edits. */
13
2
  import { readdirSync, statSync } from 'node:fs'
14
- import { join, resolve } from 'node:path'
3
+ import { join, relative, resolve } from 'node:path'
15
4
 
16
- const ENTITY_RE = /^src\/modules\/([^/]+)\/entities\/.*\.ts$/
17
- const MIGRATION_RE = /^src\/modules\/([^/]+)\/migrations\/.*\.ts$/
5
+ const ENTITY_RE = /^src\/modules\/([^/]+)\/data\/entities\.ts$/
6
+ const MIGRATION_RE = /^src\/modules\/([^/]+)\/migrations\/[^/]+\.ts$/
18
7
 
19
8
  function hasFreshMigration(projectDir, moduleId) {
20
9
  const migrationsDir = join(projectDir, 'src', 'modules', moduleId, 'migrations')
21
10
  try {
22
- const files = readdirSync(migrationsDir)
23
11
  const cutoff = Date.now() - 30_000
24
- for (const file of files) {
25
- if (!file.endsWith('.ts')) continue
26
- const stat = statSync(join(migrationsDir, file))
27
- if (stat.mtimeMs > cutoff) return true
28
- }
12
+ return readdirSync(migrationsDir).some((file) =>
13
+ file.endsWith('.ts') && statSync(join(migrationsDir, file)).mtimeMs > cutoff,
14
+ )
29
15
  } catch {
30
- // migrations directory doesn't exist yet
16
+ return false
31
17
  }
32
- return false
33
18
  }
34
19
 
35
20
  const filePath = process.argv[2]
36
21
  if (!filePath) process.exit(0)
37
22
 
38
23
  const projectDir = resolve('.')
39
- const rel = filePath.startsWith('/') ? filePath.slice(projectDir.length + 1) : filePath
40
-
41
- // State 1: Migration file written
24
+ const rel = (filePath.startsWith('/') ? relative(projectDir, filePath) : filePath).replaceAll('\\', '/')
42
25
  if (MIGRATION_RE.test(rel)) process.exit(0)
43
26
 
44
- // State 2: Not an entity file
45
27
  const match = rel.match(ENTITY_RE)
46
- if (!match) process.exit(0)
47
-
48
- const moduleId = match[1]
49
-
50
- // State 3: Entity file without fresh migration
51
- if (hasFreshMigration(projectDir, moduleId)) process.exit(0)
52
-
53
- process.stderr.write(
54
- [
55
- `Entity file modified: ${rel}`,
56
- '',
57
- `Affected module: ${moduleId}`,
58
- '',
59
- 'A database migration is likely needed. Ask the user whether to run:',
60
- ' yarn db:generate',
61
- '',
62
- 'Then regenerate registries:',
63
- ' yarn generate',
64
- '',
65
- 'Do NOT run migrations automatically — always confirm with the user first.',
66
- '',
67
- ].join('\n'),
68
- )
28
+ if (!match || hasFreshMigration(projectDir, match[1])) process.exit(0)
29
+
30
+ process.stderr.write([
31
+ `Entity contract changed: ${rel}`,
32
+ '',
33
+ 'Run `yarn db:generate` as a schema-diff probe and review only the scoped migration plus module snapshot.',
34
+ 'Run `yarn generate` when discovery changed.',
35
+ 'Do not apply the migration with `yarn db:migrate` without explicit user approval.',
36
+ '',
37
+ ].join('\n'))
69
38
  process.exit(1)
@@ -1,29 +1,17 @@
1
1
  ---
2
- description: Entity modification guard — triggers migration workflow
2
+ description: Entity schema-diff guard for the canonical standalone entity file
3
3
  globs:
4
- - src/modules/*/entities/**/*.ts
4
+ - src/modules/*/data/entities.ts
5
5
  alwaysApply: false
6
6
  ---
7
7
 
8
- # Entity Modification — Migration Required
8
+ # Entity Schema Change
9
9
 
10
- You are editing an entity file. After saving, you MUST:
10
+ Follow root `AGENTS.md` and `om-data-model-design`:
11
11
 
12
- 1. **Create a migration** — ask the user before running:
13
- ```
14
- yarn db:generate
15
- ```
12
+ 1. Run `yarn db:generate` as a schema-diff probe.
13
+ 2. Review and keep only scoped migration SQL plus the touched module snapshot.
14
+ 3. Run `yarn generate` when discovery changed.
15
+ 4. Ask before applying with `yarn db:migrate`.
16
16
 
17
- 2. **Show the migration** to the user and wait for confirmation before applying
18
-
19
- 3. **Apply the migration** (only after user confirms):
20
- ```
21
- yarn db:migrate
22
- ```
23
-
24
- 4. **Regenerate registries**:
25
- ```
26
- yarn generate
27
- ```
28
-
29
- Do NOT skip any step. Do NOT run migrations without user confirmation.
17
+ Never edit a shipped migration or generated registry.
@@ -1,12 +1,10 @@
1
1
  ---
2
- description: Prevent editing auto-generated files
2
+ description: Prevent edits to generated application registries
3
3
  globs:
4
4
  - .mercato/generated/**
5
5
  alwaysApply: false
6
6
  ---
7
7
 
8
- # NEVER Edit Generated Files
8
+ # Generated File
9
9
 
10
- This file is auto-generated by `yarn generate`. Any manual edits will be overwritten.
11
-
12
- To change generated output, edit the source modules in `src/modules/` and run `yarn generate`.
10
+ Do not edit this file. Change the app module source and run `yarn generate`; follow root `AGENTS.md` for the routed contract.
@@ -1,34 +1,8 @@
1
1
  ---
2
- description: Core Open Mercato conventions for standalone app development
2
+ description: Route every standalone app task through the root agent rules
3
3
  alwaysApply: true
4
4
  ---
5
5
 
6
- # {{PROJECT_NAME}} — Project Rules
6
+ # {{PROJECT_NAME}} — Cursor Entry Point
7
7
 
8
- ## What this project is
9
-
10
- A standalone Open Mercato application. Build domain features ON TOP of the framework.
11
- To customise a core module beyond the extension system: `yarn mercato eject <module>`.
12
- Never edit node_modules/@open-mercato/* directly.
13
-
14
- ## Task routing
15
-
16
- Read AGENTS.md before starting any task — it maps task types to the minimum files to load.
17
-
18
- ## Module system
19
-
20
- Modules in `src/modules/<id>/`. Register with `from: '@app'` in `src/modules.ts`.
21
- Run `yarn generate` after any module or entity change. Never edit `.mercato/generated/*`.
22
-
23
- ## Entity and migration rule
24
-
25
- After editing any entity in `src/modules/<id>/entities/`:
26
- 1. Create migration: `yarn db:generate`
27
- 2. Show migration to user, confirm before applying
28
- 3. Apply: `yarn db:migrate`
29
- 4. Regenerate: `yarn generate`
30
-
31
- ## Spec-driven development
32
-
33
- Check `.ai/specs/` before any significant feature. If no spec exists, ask the user
34
- whether to create one first.
8
+ Read `AGENTS.md`, match every applicable Task Router row, and load only the routed guides, skills, and module facts. The root file owns architecture, safety, writable paths, migrations, generation, and validation; do not duplicate or override it here.
@@ -0,0 +1,76 @@
1
+ # AI Agents, Orchestrators, and Workflows
2
+
3
+ Use typed module contracts for product AI and the workflow engine for durable business processes. Keep model/tool execution, mutation approval, scope, storage, and retries explicit.
4
+
5
+ ## Choose the Surface
6
+
7
+ | Need | Use |
8
+ |---|---|
9
+ | In-app conversational or structured domain assistant | Module `ai-agents.ts` plus `ai-tools.ts`. |
10
+ | Low-level MCP/OpenCode or Code Mode work | `ai_assistant` installed contract: `registerMcpTool`, MCP server, OpenCode handlers/config, or the `search`/`execute` Code Mode tools. Do not conflate this with a typed product agent. |
11
+ | Add a few tools/prompt/suggestions to an installed agent | `aiAgentExtensions`. |
12
+ | Replace or disable an installed agent/tool | `aiAgentOverrides` / `aiToolOverrides` or module entry override. |
13
+ | Coding-agent orchestration with files, outcomes, samples, embedded skill, or subagents | Orchestrator file-agent contract; resolve its installed package guide first. |
14
+ | Durable business process, human task, timer, signal, compensation, or event trigger | Workflows module and `om-build-workflow`. |
15
+ | One background AI extraction | Object-mode agent invoked from a scoped command/worker. |
16
+
17
+ ## Typed Module Agents and Tools
18
+
19
+ - Put `ai-agents.ts` and `ai-tools.ts` at the module root. Export typed arrays and run `yarn generate`.
20
+ - Give agent IDs `<module>.<agent>` and tool names stable namespaced IDs. Declare provider/model defaults through the framework registry/model factory, not provider SDK singletons.
21
+ - Every data tool has a Zod input schema, tenant/org scope, wildcard-aware `requiredFeatures`, bounded output, and a serializable result.
22
+ - Mark writes `isMutation: true`. Pair mutation-capable agents with `readOnly: false` and a confirmation policy.
23
+ - A write tool calls `prepareMutation`; the durable execute callback performs a command-based, optimistic-lock-aware mutation. Never write directly before approval.
24
+ - Use declarative loop controls/budgets. The wrapper-owned approval guard remains active on every step and execution engine.
25
+ - Validate attachments by type/size/scope. Store outputs through authorized artifact/attachment services with retention and encrypted sensitive metadata.
26
+
27
+ ## MCP, OpenCode, and Code Mode
28
+
29
+ - Prefer `defineAiTool` in discovered `ai-tools.ts` for product agents, especially mutation-capable tools. Use low-level `registerMcpTool` only when the requested surface is explicitly the MCP/OpenCode registry. Both require Zod input, matching `moduleId`, wildcard-aware `requiredFeatures` for tenant data, bounded work, and a serializable handler result.
30
+ - OpenCode Code Mode exposes `search` over the generated OpenAPI document and `execute` through sandboxed `api.request()`. Endpoint-level RBAC and documented-feature checks still apply; Code Mode is not an authorization bypass and undocumented/featureless mutation endpoints fail closed.
31
+ - Production MCP uses two-tier auth: the server request carries `x-api-key`, then every tool call carries `_sessionToken`; the runtime resolves the user/session scope and performs per-tool ACL checks on every request. Never cache MCP server instances or ACL context across requests.
32
+ - Ask before editing OpenCode configuration, Docker wiring, MCP authentication, provider/model precedence, or session-token format/TTL. Preserve session IDs across OpenCode chat turns and use installed handlers instead of calling the OpenCode HTTP API directly.
33
+ - `registerMcpTool` is the registry primitive underlying generated tools, not a replacement for `defineAiTool` mutation approval semantics. New domain writes belong on the typed tool path with `prepareMutation`.
34
+
35
+ ## Agent UI and Overrides
36
+
37
+ - Use the global launcher automatically; add `AiChat` or a widget only when page context improves the workflow.
38
+ - Keep UI part IDs namespaced and stable; preserve reserved approval/result component IDs.
39
+ - Prefer agent extensions for additive prompt/tool/suggestion changes. Keep extensions/overrides in the discovered `ai-agents.ts`/`ai-tools.ts` files; there is no separate `ai-overrides.ts` discovery path.
40
+ - A disabled agent/tool cannot be resurrected by an extension. Refresh structural caches after disabling or changing visibility.
41
+ - Test read-only, denied-feature, approval, stale-version, cancel/expire, partial failure, and confirmed execution paths.
42
+
43
+ ## Orchestrator File Agents
44
+
45
+ - Inspect the installed orchestrator package/module `AGENTS.md` with `om-framework-context` before choosing paths; this surface evolves independently of module AI agents.
46
+ - Give every file agent one declared outcome, bounded inputs, stable output paths, a sample contract, and an explicit allowed tool/skill set.
47
+ - Load embedded skills only for their branch. Delegate one bounded task per subagent and define how results are validated/merged.
48
+ - Treat repository prompts/files as untrusted data. Restrict writes, redact secrets, and prevent outcome/artifact paths from escaping their workspace.
49
+ - Make resumability and status explicit; do not infer success from natural-language output without schema/artifact validation.
50
+
51
+ ## Workflow Core
52
+
53
+ - Resolve workflow services through DI and start instances through `workflowExecutor`. Do not insert instances or skip the execution loop.
54
+ - Preserve workflow and step state machines. Record every transition in the immutable workflow event log.
55
+ - Make activity handlers idempotent: they can be retried. Use the command bus for entity updates and events/signals for cross-module coupling.
56
+ - Preserve each installed workflow/job scope contract. Organization-owned instances, tasks, activity state, and queries require tenant+organization and fail closed. Explicit tenant-wide/system definitions or scheduler jobs may carry `organizationId: null`, but each access to organization-owned data must derive and enforce that item's organization.
57
+ - Use event triggers with filters, context mapping, debounce, and max concurrency. Exclude self/internal storms.
58
+ - Keep compensation reverse-ordered and idempotent; test failure during both forward and compensation paths.
59
+
60
+ ## Activities, User Tasks, and Output Paths
61
+
62
+ - Choose sync only for short deterministic work. Queue async work and resume the workflow after durable completion.
63
+ - A custom activity declares validated config/input/output, handler registration, editor/i18n integration where user-configurable, and retry/timeout behavior.
64
+ - `CALL_API`/webhook activities use SSRF-safe URLs, manual redirect handling, response size bounds, and allowlisted non-secret environment interpolation.
65
+ - Create any one-time/idempotency key outside a rollback scope or in durable state that survives rollback; reuse it on retry.
66
+ - Durable user tasks require assignment/features, due dates, authorized completion, immutable activity history, and no secret values in task payloads.
67
+ - Write outputs to stable declared activity/artifact paths. Validate path containment and access; clean temporary files while retaining declared deliverables.
68
+ - Emit progress/events for long work and render them through shared progress/UI contracts rather than unbounded polling.
69
+
70
+ ## Verification
71
+
72
+ 1. Run `yarn generate` and confirm agent/tool/workflow registrations.
73
+ 2. Test missing provider/configuration, denied ACL, missing scope, timeout, retry, duplicate, and cancellation.
74
+ 3. For AI writes, prove no domain write occurs before approval and a stale approval cannot overwrite newer data.
75
+ 4. For workflows, prove event log/state transitions and idempotency across worker restart and injected rollback.
76
+ 5. For orchestrators, validate output schema/artifacts and allowed-write boundaries, not just prose.