create-mercato-app 0.6.7-develop.6685.1.77c0a5591b → 0.6.7-develop.6686.1.bdda5ed397

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 (316) hide show
  1. package/README.md +72 -0
  2. package/agentic/claude-code/hooks/entity-migration-check.ts +32 -88
  3. package/agentic/codex/enforcement-rules.md +2 -16
  4. package/agentic/cursor/hooks/entity-migration-check.mjs +19 -50
  5. package/agentic/cursor/rules/entity-guard.mdc +9 -21
  6. package/agentic/cursor/rules/generated-guard.mdc +3 -5
  7. package/agentic/cursor/rules/open-mercato.mdc +3 -29
  8. package/agentic/guides/ai-workflows.md +76 -0
  9. package/agentic/guides/architecture.md +107 -0
  10. package/agentic/guides/backend-ui.md +80 -0
  11. package/agentic/guides/contracts.md +92 -0
  12. package/agentic/guides/extensions.md +104 -0
  13. package/agentic/guides/integrations.md +81 -0
  14. package/agentic/guides/module-system.md +12 -127
  15. package/agentic/guides/testing-debugging.md +74 -0
  16. package/agentic/shared/AGENTS.md.template +123 -311
  17. package/agentic/shared/ai/agentic.config.json +1 -0
  18. package/agentic/shared/ai/harness/README.md +48 -0
  19. package/agentic/shared/ai/harness/RELEASE.md +57 -0
  20. package/agentic/shared/ai/harness/cases.json +13487 -0
  21. package/agentic/shared/ai/harness/cases.schema.json +132 -0
  22. package/agentic/shared/ai/harness/fixtures/index.json +49 -0
  23. package/agentic/shared/ai/harness/fixtures/seeds.json +162 -0
  24. package/agentic/shared/ai/harness/generated-code-review-policy.md +20 -0
  25. package/agentic/shared/ai/harness/generated-code-review-response.schema.json +43 -0
  26. package/agentic/shared/ai/harness/generated-code-review-result.schema.json +110 -0
  27. package/agentic/shared/ai/harness/release-matrix.json +133 -0
  28. package/agentic/shared/ai/harness/release-result.schema.json +219 -0
  29. package/agentic/shared/ai/harness/result.schema.json +76 -0
  30. package/agentic/shared/ai/harness/routing-response.schema.json +12 -0
  31. package/agentic/shared/ai/harness/target-validation-result.schema.json +73 -0
  32. package/agentic/shared/ai/harness/validators.json +78 -0
  33. package/agentic/shared/ai/harness/writable-ast-oracles.mjs +1768 -0
  34. package/agentic/shared/ai/harness/writable-behavior-oracles.mjs +1096 -0
  35. package/agentic/shared/ai/review-checklist.md +36 -0
  36. package/agentic/shared/ai/skills/om-auto-review-pr/SKILL.md +4 -0
  37. package/agentic/shared/ai/skills/om-backend-ui-design/SKILL.md +20 -241
  38. package/agentic/shared/ai/skills/om-backend-ui-design/references/crud-surfaces.md +16 -0
  39. package/agentic/shared/ai/skills/om-backend-ui-design/references/frontend-and-design-system.md +53 -0
  40. package/agentic/shared/ai/skills/om-backend-ui-design/references/page-and-navigation.md +13 -0
  41. package/agentic/shared/ai/skills/om-backend-ui-design/references/quality-states.md +11 -0
  42. package/agentic/shared/ai/skills/om-build-workflow/SKILL.md +30 -0
  43. package/agentic/shared/ai/skills/om-build-workflow/references/activity-contracts.md +12 -0
  44. package/agentic/shared/ai/skills/om-build-workflow/references/durability-and-progress.md +13 -0
  45. package/agentic/shared/ai/skills/om-build-workflow/references/workflow-design.md +14 -0
  46. package/agentic/shared/ai/skills/om-create-ai-agent/SKILL.md +28 -0
  47. package/agentic/shared/ai/skills/om-create-ai-agent/references/attachments-and-overrides.md +12 -0
  48. package/agentic/shared/ai/skills/om-create-ai-agent/references/module-agents-and-tools.md +22 -0
  49. package/agentic/shared/ai/skills/om-create-ai-agent/references/orchestrator-agents.md +12 -0
  50. package/agentic/shared/ai/skills/om-create-ai-agent/references/surface-selector.md +19 -0
  51. package/agentic/shared/ai/skills/om-data-model-design/SKILL.md +16 -601
  52. package/agentic/shared/ai/skills/om-data-model-design/references/integrity-and-concurrency.md +19 -0
  53. package/agentic/shared/ai/skills/om-data-model-design/references/migration-workflow.md +13 -0
  54. package/agentic/shared/ai/skills/om-data-model-design/references/schema-design.md +14 -0
  55. package/agentic/shared/ai/skills/om-data-model-design/references/sensitive-data.md +10 -0
  56. package/agentic/shared/ai/skills/om-eject-and-customize/SKILL.md +14 -310
  57. package/agentic/shared/ai/skills/om-eject-and-customize/references/decision-and-procedure.md +17 -0
  58. package/agentic/shared/ai/skills/om-evolve-harness/SKILL.md +28 -0
  59. package/agentic/shared/ai/skills/om-evolve-harness/references/case-template.md +89 -0
  60. package/agentic/shared/ai/skills/om-evolve-harness/references/case-workflow.md +16 -0
  61. package/agentic/shared/ai/skills/om-evolve-harness/references/owner-selection.md +17 -0
  62. package/agentic/shared/ai/skills/om-framework-context/SKILL.md +25 -0
  63. package/agentic/shared/ai/skills/om-framework-context/references/resolver-procedure.md +11 -0
  64. package/agentic/shared/ai/skills/om-framework-context/references/skew-and-escalation.md +13 -0
  65. package/agentic/shared/ai/skills/om-help/SKILL.md +15 -97
  66. package/agentic/shared/ai/skills/om-help/references/delivery-workflows.md +17 -0
  67. package/agentic/shared/ai/skills/om-help/references/task-families.md +20 -0
  68. package/agentic/shared/ai/skills/om-implement-spec/SKILL.md +15 -156
  69. package/agentic/shared/ai/skills/om-implement-spec/references/phases-and-gates.md +12 -0
  70. package/agentic/shared/ai/skills/om-integration-builder/SKILL.md +24 -708
  71. package/agentic/shared/ai/skills/om-integration-builder/references/package-and-activation.md +16 -0
  72. package/agentic/shared/ai/skills/om-integration-builder/references/provider-families.md +14 -0
  73. package/agentic/shared/ai/skills/om-integration-builder/references/security-and-reliability.md +15 -0
  74. package/agentic/shared/ai/skills/om-integration-builder/references/sync-and-files.md +12 -0
  75. package/agentic/shared/ai/skills/om-module-scaffold/SKILL.md +20 -820
  76. package/agentic/shared/ai/skills/om-module-scaffold/references/api-and-domain.md +19 -0
  77. package/agentic/shared/ai/skills/om-module-scaffold/references/business-one-shot-blueprints.md +107 -0
  78. package/agentic/shared/ai/skills/om-module-scaffold/references/data-and-migrations.md +12 -0
  79. package/agentic/shared/ai/skills/om-module-scaffold/references/discovery-surface-catalog.md +83 -0
  80. package/agentic/shared/ai/skills/om-module-scaffold/references/module-surfaces.md +21 -0
  81. package/agentic/shared/ai/skills/om-module-scaffold/references/planning.md +11 -0
  82. package/agentic/shared/ai/skills/om-module-scaffold/references/runtime-cache-and-queues.md +22 -0
  83. package/agentic/shared/ai/skills/om-module-scaffold/references/verification.md +13 -0
  84. package/agentic/shared/ai/skills/om-system-extension/SKILL.md +19 -843
  85. package/agentic/shared/ai/skills/om-system-extension/references/extension-branches.md +18 -0
  86. package/agentic/shared/ai/skills/om-system-extension/references/mechanism-selector.md +25 -0
  87. package/agentic/shared/ai/skills/om-system-extension/references/read-write-roundtrip.md +13 -0
  88. package/agentic/shared/ai/skills/om-system-extension/references/unified-overrides.md +38 -0
  89. package/agentic/shared/ai/skills/om-system-extension/references/verification.md +11 -0
  90. package/agentic/shared/ai/skills/om-trim-unused-modules/SKILL.md +15 -63
  91. package/agentic/shared/ai/skills/om-trim-unused-modules/references/dependency-and-redirect.md +15 -0
  92. package/agentic/shared/ai/skills/om-troubleshooter/SKILL.md +16 -467
  93. package/agentic/shared/ai/skills/om-troubleshooter/references/diagnosis-map.md +16 -0
  94. package/agentic/shared/ai/skills/om-troubleshooter/references/regression-oracles.md +14 -0
  95. package/agentic/shared/ai/skills/tiers.json +137 -20
  96. package/agentic/shared/ai/skills/tiers.schema.json +52 -40
  97. package/agentic/shared/scripts/agent-harness-tool-server.mjs +174 -0
  98. package/agentic/shared/scripts/evaluate-agent-harness.mjs +2783 -0
  99. package/agentic/shared/scripts/execution-sandbox.mjs +329 -0
  100. package/agentic/shared/scripts/framework-context.mjs +894 -0
  101. package/agentic/shared/scripts/install-skills.mjs +1029 -0
  102. package/agentic/shared/scripts/install-skills.sh +4 -694
  103. package/agentic/shared/scripts/prepare-agent-harness-fixture.mjs +222 -0
  104. package/agentic/shared/scripts/run-agent-harness-release.mjs +1761 -0
  105. package/dist/agentic/claude-code/hooks/entity-migration-check.ts +32 -88
  106. package/dist/agentic/codex/enforcement-rules.md +2 -16
  107. package/dist/agentic/cursor/hooks/entity-migration-check.mjs +19 -50
  108. package/dist/agentic/cursor/rules/entity-guard.mdc +9 -21
  109. package/dist/agentic/cursor/rules/generated-guard.mdc +3 -5
  110. package/dist/agentic/cursor/rules/open-mercato.mdc +3 -29
  111. package/dist/agentic/guides/ai-workflows.md +76 -0
  112. package/dist/agentic/guides/architecture.md +107 -0
  113. package/dist/agentic/guides/backend-ui.md +80 -0
  114. package/dist/agentic/guides/contracts.md +92 -0
  115. package/dist/agentic/guides/extensions.md +104 -0
  116. package/dist/agentic/guides/integrations.md +81 -0
  117. package/dist/agentic/guides/module-facts.json +217 -81
  118. package/dist/agentic/guides/module-system.md +12 -127
  119. package/dist/agentic/guides/modules/ai_assistant.md +1 -1
  120. package/dist/agentic/guides/modules/api_docs.md +1 -1
  121. package/dist/agentic/guides/modules/api_keys.md +1 -1
  122. package/dist/agentic/guides/modules/attachments.md +2 -2
  123. package/dist/agentic/guides/modules/audit_logs.md +2 -2
  124. package/dist/agentic/guides/modules/auth.md +1 -1
  125. package/dist/agentic/guides/modules/business_rules.md +1 -1
  126. package/dist/agentic/guides/modules/catalog.md +5 -5
  127. package/dist/agentic/guides/modules/channel_gmail.md +1 -1
  128. package/dist/agentic/guides/modules/channel_imap.md +1 -1
  129. package/dist/agentic/guides/modules/checkout.md +1 -1
  130. package/dist/agentic/guides/modules/communication_channels.md +1 -1
  131. package/dist/agentic/guides/modules/configs.md +1 -1
  132. package/dist/agentic/guides/modules/content.md +1 -1
  133. package/dist/agentic/guides/modules/currencies.md +1 -1
  134. package/dist/agentic/guides/modules/customer_accounts.md +1 -1
  135. package/dist/agentic/guides/modules/customers.md +2 -2
  136. package/dist/agentic/guides/modules/dashboards.md +1 -1
  137. package/dist/agentic/guides/modules/data_sync.md +1 -1
  138. package/dist/agentic/guides/modules/dictionaries.md +1 -1
  139. package/dist/agentic/guides/modules/directory.md +1 -1
  140. package/dist/agentic/guides/modules/entities.md +2 -2
  141. package/dist/agentic/guides/modules/events.md +1 -1
  142. package/dist/agentic/guides/modules/feature_toggles.md +1 -1
  143. package/dist/agentic/guides/modules/gateway_stripe.md +1 -1
  144. package/dist/agentic/guides/modules/generators.md +1 -1
  145. package/dist/agentic/guides/modules/inbox_ops.md +1 -1
  146. package/dist/agentic/guides/modules/integrations.md +1 -1
  147. package/dist/agentic/guides/modules/messages.md +1 -1
  148. package/dist/agentic/guides/modules/notifications.md +1 -1
  149. package/dist/agentic/guides/modules/onboarding.md +1 -1
  150. package/dist/agentic/guides/modules/payment_gateways.md +1 -1
  151. package/dist/agentic/guides/modules/perspectives.md +1 -1
  152. package/dist/agentic/guides/modules/planner.md +1 -1
  153. package/dist/agentic/guides/modules/portal.md +1 -1
  154. package/dist/agentic/guides/modules/progress.md +1 -1
  155. package/dist/agentic/guides/modules/query_index.md +2 -2
  156. package/dist/agentic/guides/modules/record_locks.md +1 -1
  157. package/dist/agentic/guides/modules/resources.md +1 -1
  158. package/dist/agentic/guides/modules/sales.md +17 -17
  159. package/dist/agentic/guides/modules/scheduler.md +1 -1
  160. package/dist/agentic/guides/modules/search.md +1 -1
  161. package/dist/agentic/guides/modules/security.md +1 -1
  162. package/dist/agentic/guides/modules/shipping_carriers.md +1 -1
  163. package/dist/agentic/guides/modules/sso.md +1 -1
  164. package/dist/agentic/guides/modules/staff.md +2 -2
  165. package/dist/agentic/guides/modules/storage_s3.md +1 -1
  166. package/dist/agentic/guides/modules/sync_akeneo.md +1 -1
  167. package/dist/agentic/guides/modules/sync_excel.md +1 -1
  168. package/dist/agentic/guides/modules/system_status_overlays.md +1 -1
  169. package/dist/agentic/guides/modules/translations.md +1 -1
  170. package/dist/agentic/guides/modules/webhooks.md +2 -2
  171. package/dist/agentic/guides/modules/wms.md +2 -2
  172. package/dist/agentic/guides/modules/workflows.md +1 -1
  173. package/dist/agentic/guides/testing-debugging.md +74 -0
  174. package/dist/agentic/guides/upstream/AGENTS.md +297 -0
  175. package/dist/agentic/guides/upstream/BACKWARD_COMPATIBILITY.md +303 -0
  176. package/dist/agentic/guides/upstream/manifest.json +8 -0
  177. package/dist/agentic/shared/AGENTS.md.template +123 -311
  178. package/dist/agentic/shared/ai/agentic.config.json +1 -0
  179. package/dist/agentic/shared/ai/harness/README.md +48 -0
  180. package/dist/agentic/shared/ai/harness/RELEASE.md +57 -0
  181. package/dist/agentic/shared/ai/harness/cases.json +13487 -0
  182. package/dist/agentic/shared/ai/harness/cases.schema.json +132 -0
  183. package/dist/agentic/shared/ai/harness/fixtures/index.json +49 -0
  184. package/dist/agentic/shared/ai/harness/fixtures/seeds.json +162 -0
  185. package/dist/agentic/shared/ai/harness/generated-code-review-policy.md +20 -0
  186. package/dist/agentic/shared/ai/harness/generated-code-review-response.schema.json +43 -0
  187. package/dist/agentic/shared/ai/harness/generated-code-review-result.schema.json +110 -0
  188. package/dist/agentic/shared/ai/harness/release-matrix.json +133 -0
  189. package/dist/agentic/shared/ai/harness/release-result.schema.json +219 -0
  190. package/dist/agentic/shared/ai/harness/result.schema.json +76 -0
  191. package/dist/agentic/shared/ai/harness/routing-response.schema.json +12 -0
  192. package/dist/agentic/shared/ai/harness/target-validation-result.schema.json +73 -0
  193. package/dist/agentic/shared/ai/harness/validators.json +78 -0
  194. package/dist/agentic/shared/ai/harness/writable-ast-oracles.mjs +1768 -0
  195. package/dist/agentic/shared/ai/harness/writable-behavior-oracles.mjs +1096 -0
  196. package/dist/agentic/shared/ai/review-checklist.md +36 -0
  197. package/dist/agentic/shared/ai/skills/om-auto-review-pr/SKILL.md +4 -0
  198. package/dist/agentic/shared/ai/skills/om-backend-ui-design/SKILL.md +20 -241
  199. package/dist/agentic/shared/ai/skills/om-backend-ui-design/references/crud-surfaces.md +16 -0
  200. package/dist/agentic/shared/ai/skills/om-backend-ui-design/references/frontend-and-design-system.md +53 -0
  201. package/dist/agentic/shared/ai/skills/om-backend-ui-design/references/page-and-navigation.md +13 -0
  202. package/dist/agentic/shared/ai/skills/om-backend-ui-design/references/quality-states.md +11 -0
  203. package/dist/agentic/shared/ai/skills/om-build-workflow/SKILL.md +30 -0
  204. package/dist/agentic/shared/ai/skills/om-build-workflow/references/activity-contracts.md +12 -0
  205. package/dist/agentic/shared/ai/skills/om-build-workflow/references/durability-and-progress.md +13 -0
  206. package/dist/agentic/shared/ai/skills/om-build-workflow/references/workflow-design.md +14 -0
  207. package/dist/agentic/shared/ai/skills/om-create-ai-agent/SKILL.md +28 -0
  208. package/dist/agentic/shared/ai/skills/om-create-ai-agent/references/attachments-and-overrides.md +12 -0
  209. package/dist/agentic/shared/ai/skills/om-create-ai-agent/references/module-agents-and-tools.md +22 -0
  210. package/dist/agentic/shared/ai/skills/om-create-ai-agent/references/orchestrator-agents.md +12 -0
  211. package/dist/agentic/shared/ai/skills/om-create-ai-agent/references/surface-selector.md +19 -0
  212. package/dist/agentic/shared/ai/skills/om-data-model-design/SKILL.md +16 -601
  213. package/dist/agentic/shared/ai/skills/om-data-model-design/references/integrity-and-concurrency.md +19 -0
  214. package/dist/agentic/shared/ai/skills/om-data-model-design/references/migration-workflow.md +13 -0
  215. package/dist/agentic/shared/ai/skills/om-data-model-design/references/schema-design.md +14 -0
  216. package/dist/agentic/shared/ai/skills/om-data-model-design/references/sensitive-data.md +10 -0
  217. package/dist/agentic/shared/ai/skills/om-eject-and-customize/SKILL.md +14 -310
  218. package/dist/agentic/shared/ai/skills/om-eject-and-customize/references/decision-and-procedure.md +17 -0
  219. package/dist/agentic/shared/ai/skills/om-evolve-harness/SKILL.md +28 -0
  220. package/dist/agentic/shared/ai/skills/om-evolve-harness/references/case-template.md +89 -0
  221. package/dist/agentic/shared/ai/skills/om-evolve-harness/references/case-workflow.md +16 -0
  222. package/dist/agentic/shared/ai/skills/om-evolve-harness/references/owner-selection.md +17 -0
  223. package/dist/agentic/shared/ai/skills/om-framework-context/SKILL.md +25 -0
  224. package/dist/agentic/shared/ai/skills/om-framework-context/references/resolver-procedure.md +11 -0
  225. package/dist/agentic/shared/ai/skills/om-framework-context/references/skew-and-escalation.md +13 -0
  226. package/dist/agentic/shared/ai/skills/om-help/SKILL.md +15 -97
  227. package/dist/agentic/shared/ai/skills/om-help/references/delivery-workflows.md +17 -0
  228. package/dist/agentic/shared/ai/skills/om-help/references/task-families.md +20 -0
  229. package/dist/agentic/shared/ai/skills/om-implement-spec/SKILL.md +15 -156
  230. package/dist/agentic/shared/ai/skills/om-implement-spec/references/phases-and-gates.md +12 -0
  231. package/dist/agentic/shared/ai/skills/om-integration-builder/SKILL.md +24 -708
  232. package/dist/agentic/shared/ai/skills/om-integration-builder/references/package-and-activation.md +16 -0
  233. package/dist/agentic/shared/ai/skills/om-integration-builder/references/provider-families.md +14 -0
  234. package/dist/agentic/shared/ai/skills/om-integration-builder/references/security-and-reliability.md +15 -0
  235. package/dist/agentic/shared/ai/skills/om-integration-builder/references/sync-and-files.md +12 -0
  236. package/dist/agentic/shared/ai/skills/om-module-scaffold/SKILL.md +20 -820
  237. package/dist/agentic/shared/ai/skills/om-module-scaffold/references/api-and-domain.md +19 -0
  238. package/dist/agentic/shared/ai/skills/om-module-scaffold/references/business-one-shot-blueprints.md +107 -0
  239. package/dist/agentic/shared/ai/skills/om-module-scaffold/references/data-and-migrations.md +12 -0
  240. package/dist/agentic/shared/ai/skills/om-module-scaffold/references/discovery-surface-catalog.md +83 -0
  241. package/dist/agentic/shared/ai/skills/om-module-scaffold/references/module-surfaces.md +21 -0
  242. package/dist/agentic/shared/ai/skills/om-module-scaffold/references/planning.md +11 -0
  243. package/dist/agentic/shared/ai/skills/om-module-scaffold/references/runtime-cache-and-queues.md +22 -0
  244. package/dist/agentic/shared/ai/skills/om-module-scaffold/references/verification.md +13 -0
  245. package/dist/agentic/shared/ai/skills/om-system-extension/SKILL.md +19 -843
  246. package/dist/agentic/shared/ai/skills/om-system-extension/references/extension-branches.md +18 -0
  247. package/dist/agentic/shared/ai/skills/om-system-extension/references/mechanism-selector.md +25 -0
  248. package/dist/agentic/shared/ai/skills/om-system-extension/references/read-write-roundtrip.md +13 -0
  249. package/dist/agentic/shared/ai/skills/om-system-extension/references/unified-overrides.md +38 -0
  250. package/dist/agentic/shared/ai/skills/om-system-extension/references/verification.md +11 -0
  251. package/dist/agentic/shared/ai/skills/om-trim-unused-modules/SKILL.md +15 -63
  252. package/dist/agentic/shared/ai/skills/om-trim-unused-modules/references/dependency-and-redirect.md +15 -0
  253. package/dist/agentic/shared/ai/skills/om-troubleshooter/SKILL.md +16 -467
  254. package/dist/agentic/shared/ai/skills/om-troubleshooter/references/diagnosis-map.md +16 -0
  255. package/dist/agentic/shared/ai/skills/om-troubleshooter/references/regression-oracles.md +14 -0
  256. package/dist/agentic/shared/ai/skills/tiers.json +137 -20
  257. package/dist/agentic/shared/ai/skills/tiers.schema.json +52 -40
  258. package/dist/agentic/shared/scripts/agent-harness-tool-server.mjs +174 -0
  259. package/dist/agentic/shared/scripts/evaluate-agent-harness.mjs +2783 -0
  260. package/dist/agentic/shared/scripts/execution-sandbox.mjs +329 -0
  261. package/dist/agentic/shared/scripts/framework-context.mjs +894 -0
  262. package/dist/agentic/shared/scripts/install-skills.mjs +1029 -0
  263. package/dist/agentic/shared/scripts/install-skills.sh +4 -694
  264. package/dist/agentic/shared/scripts/prepare-agent-harness-fixture.mjs +222 -0
  265. package/dist/agentic/shared/scripts/run-agent-harness-release.mjs +1761 -0
  266. package/dist/index.js +160 -183
  267. package/package.json +5 -4
  268. package/template/AGENTS.md +92 -663
  269. package/template/eslint.config.mjs +1 -0
  270. package/template/gitignore +4 -0
  271. package/template/package.json.template +5 -1
  272. package/template/scripts/evaluate-agent-harness.mjs +4 -0
  273. package/template/scripts/framework-context.mjs +4 -0
  274. package/template/scripts/install-skills.mjs +10 -0
  275. package/template/scripts/install-skills.sh +2 -19
  276. package/template/scripts/prepare-agent-harness-fixture.mjs +4 -0
  277. package/template/scripts/run-agent-harness-release.mjs +4 -0
  278. package/template/src/app/__tests__/layout.test.tsx +8 -2
  279. package/template/src/app/page.tsx +4 -1
  280. package/template/src/components/__tests__/AppProviders.test.tsx +2 -2
  281. package/template/src/modules/example/lib/__tests__/mock-gateway-adapter.test.ts +3 -3
  282. package/template/src/modules/example/lib/__tests__/mock-shipping-adapter.test.ts +3 -3
  283. package/template/src/modules/example/lib/__tests__/mock-webhook-endpoint-adapter.test.ts +3 -3
  284. package/template/src/modules.ts +1 -0
  285. package/template/tsconfig.json +0 -1
  286. package/agentic/shared/ai/skills/om-auto-continue-pr-loop/SKILL.md +0 -27
  287. package/agentic/shared/ai/skills/om-auto-create-pr-loop/SKILL.md +0 -27
  288. package/agentic/shared/ai/skills/om-backend-ui-design/references/ui-components.md +0 -260
  289. package/agentic/shared/ai/skills/om-data-model-design/references/mikro-orm-cheatsheet.md +0 -146
  290. package/agentic/shared/ai/skills/om-help/references/skills-catalog.md +0 -84
  291. package/agentic/shared/ai/skills/om-help/references/workflow-sequences.md +0 -193
  292. package/agentic/shared/ai/skills/om-integration-builder/STANDALONE.md +0 -34
  293. package/agentic/shared/ai/skills/om-integration-builder/references/adapter-contracts.md +0 -762
  294. package/agentic/shared/ai/skills/om-module-scaffold/references/naming-conventions.md +0 -50
  295. package/agentic/shared/ai/skills/om-module-scaffold/references/navigation-patterns.md +0 -97
  296. package/agentic/shared/ai/skills/om-system-extension/references/extension-contracts.md +0 -271
  297. package/agentic/shared/ai/skills/om-troubleshooter/references/diagnostic-commands.md +0 -101
  298. package/dist/agentic/guides/cache.md +0 -45
  299. package/dist/agentic/guides/core.md +0 -453
  300. package/dist/agentic/guides/events.md +0 -117
  301. package/dist/agentic/guides/queue.md +0 -53
  302. package/dist/agentic/guides/search.md +0 -115
  303. package/dist/agentic/guides/shared.md +0 -108
  304. package/dist/agentic/guides/ui.md +0 -347
  305. package/dist/agentic/shared/ai/skills/om-auto-continue-pr-loop/SKILL.md +0 -27
  306. package/dist/agentic/shared/ai/skills/om-auto-create-pr-loop/SKILL.md +0 -27
  307. package/dist/agentic/shared/ai/skills/om-backend-ui-design/references/ui-components.md +0 -260
  308. package/dist/agentic/shared/ai/skills/om-data-model-design/references/mikro-orm-cheatsheet.md +0 -146
  309. package/dist/agentic/shared/ai/skills/om-help/references/skills-catalog.md +0 -84
  310. package/dist/agentic/shared/ai/skills/om-help/references/workflow-sequences.md +0 -193
  311. package/dist/agentic/shared/ai/skills/om-integration-builder/STANDALONE.md +0 -34
  312. package/dist/agentic/shared/ai/skills/om-integration-builder/references/adapter-contracts.md +0 -762
  313. package/dist/agentic/shared/ai/skills/om-module-scaffold/references/naming-conventions.md +0 -50
  314. package/dist/agentic/shared/ai/skills/om-module-scaffold/references/navigation-patterns.md +0 -97
  315. package/dist/agentic/shared/ai/skills/om-system-extension/references/extension-contracts.md +0 -271
  316. package/dist/agentic/shared/ai/skills/om-troubleshooter/references/diagnostic-commands.md +0 -101
package/README.md CHANGED
@@ -35,6 +35,8 @@ npx create-mercato-app <app-name> [options]
35
35
  |--------|-------------|
36
36
  | `--app <name>` | Bootstrap an official Open Mercato ready app from `open-mercato/ready-app-<name>` |
37
37
  | `--app-url <url>` | Bootstrap a ready app from a GitHub repository URL |
38
+ | `--preset <id>` | Select the `classic`, `empty`, or `crm` starter without prompting |
39
+ | `--agents <list>` | Set up `claude-code`, `codex`, `cursor`, a comma-separated subset, `all`, or `none` without prompting |
38
40
  | `--skip-agentic-setup` | Skip the interactive agentic setup wizard |
39
41
  | `--init-git` | Initialize a local Git repository after scaffolding |
40
42
  | `--no-init-git` | Do not prompt for or initialize a local Git repository |
@@ -64,6 +66,12 @@ npx create-mercato-app my-store --registry http://localhost:4873
64
66
  # Create a new app without the agentic setup wizard
65
67
  npx create-mercato-app my-store --skip-agentic-setup
66
68
 
69
+ # Create a classic app with every supported AI coding-tool configuration
70
+ npx create-mercato-app my-store --preset classic --agents all
71
+
72
+ # Set up only Claude Code and Codex
73
+ npx create-mercato-app my-store --agents claude-code,codex
74
+
67
75
  # Create a new app and initialize a local Git repository
68
76
  npx create-mercato-app my-store --init-git
69
77
  ```
@@ -76,8 +84,72 @@ npx create-mercato-app my-store --init-git
76
84
  - `--skip-agentic-setup` skips only the interactive agentic setup wizard
77
85
  - Imported ready apps are copied as raw source snapshots: the CLI does not rewrite dependency versions, package names, or application source files
78
86
  - Imported ready apps skip the interactive agentic setup wizard; if you want agentic tooling later, run `yarn mercato agentic:init` inside the generated app
87
+ - `--agents` is only supported for bare scaffolds; use `yarn mercato agentic:init` after importing a ready app
79
88
  - Imported ready apps must not contain `.template` files; the scaffold fails closed if template files are found
80
89
 
90
+ ## Standalone AI Harness
91
+
92
+ A bare scaffold can install a standalone-specific AI development harness for Claude Code, Codex, Cursor, or any selected subset. It combines a compact task router, module/task guides, local skills, an integrity-pinned subset of `open-mercato/skills`, exact installed-framework context, and a reproducible evaluation catalog.
93
+
94
+ ### Install or refresh skills
95
+
96
+ Agentic setup attempts installation automatically. Re-run it after cloning, after an offline setup, or when selecting another tier:
97
+
98
+ ```bash
99
+ yarn install-skills --list
100
+ yarn install-skills
101
+ yarn install-skills --with automation # opt in to loop/issue/release-maintenance workflows
102
+ ```
103
+
104
+ The default is the 13 local core skills plus the 15-skill dependency-closed daily external tier. Advanced loop engines, issue authoring, and upgrade-note maintenance stay opt-in through `--with automation` (or `--all`). `.agents/skills/` is canonical; Claude Code receives compatibility links. The installer downloads the exact pinned `open-mercato/skills` archive, copies only individually hash-attested skill directories, and never executes archive or package-runner code. It activates the selected external set as one transaction: any failure restores the complete previous set before local installation continues. It preserves unknown user-owned skills and quarantines stale or modified installer-owned content.
105
+
106
+ ### Upgrade an existing generated harness
107
+
108
+ After upgrading Open Mercato, refresh generated harness assets without overwriting local context:
109
+
110
+ ```bash
111
+ yarn mercato agentic:init --update-harness
112
+ ```
113
+
114
+ The ownership-aware update replaces unchanged generated files, recreates missing owned files, and refreshes the manifest atomically. Modified or unknown files remain in place; exact generated-path conflicts get an adjacent `.incoming` candidate. Managed paths are resolved below the canonical app root and a symlinked ancestor is rejected before publication. Use `--force` only when intentionally replacing known generated targets. External skill installation is a separate retryable phase, so offline installation does not roll back the harness update.
115
+
116
+ ### Resolve installed framework context
117
+
118
+ Use the escape hatch when the routed guides do not contain an exact contract. It resolves the package versions selected by the app and their source/`AGENTS.md` chain without bulk-loading dependencies:
119
+
120
+ ```bash
121
+ yarn framework:context --module customers --query makeCrudRoute
122
+ yarn framework:context --package @open-mercato/ui --query CrudForm
123
+ yarn framework:context --root
124
+ ```
125
+
126
+ Bounded snapshots are written under ignored `.ai/framework-context/`; warnings make degraded dist/type-only context explicit.
127
+
128
+ ### Evaluate and maintain the harness
129
+
130
+ Use deterministic checks during development:
131
+
132
+ ```bash
133
+ yarn harness:validate --case OMH-009
134
+ yarn harness:validate --family testing
135
+ yarn harness:validate --all
136
+ ```
137
+
138
+ `harness:validate --all` is the deterministic catalog gate, not the full release suite. Authenticated `--runner codex` / `--runner claude` live routing uses host filesystem containment on macOS (`sandbox-exec`) and Linux (Bubblewrap). The model gets no shell, process, environment, discovery, browser, or network tool: both CLIs receive only an evaluator-owned, `env -i` MCP server for exact-path reads and case-allowlisted writes. The selected app is intentionally readable through that narrow tool, so use a fresh or otherwise non-sensitive generated app. macOS `sandbox-exec` can enforce network-free lanes but cannot isolate loopback from the host; native macOS and Windows must use a contained Linux VM/container with Bubblewrap for the complete release gate.
139
+
140
+ Run the full matrix once per Open Mercato release from a fresh scaffold:
141
+
142
+ ```bash
143
+ yarn install-skills
144
+ yarn harness:release --runner codex --prepare-targets /absolute/empty-release-targets --acknowledge-writes
145
+ ```
146
+
147
+ The target directory must be absolute, new or empty, and outside the controller app. Select one blocking primary runner with `--runner codex` or `--runner claude`; it owns all 192 routing cases and every writable/review lane, with no per-case fallback. Optionally add the different authenticated runner through `--portability-runner` for the exact 45-case representative read-only lane. Omitting it is valid and recorded as not requested; once requested, its failures are blocking. Use a fresh, sanitized controller: automatic preparation fails before copying `.env`/`.env.*` local configuration (safe example/sample/template files remain allowed), credential files, or private-key files. The complete gate requires Linux with trusted system Bubblewrap (`bwrap`) and user namespaces because its Playwright API/browser lanes need a loopback namespace isolated from the host. Preflight rejects untrusted/no-op/pass-through executables and proves isolated loopback plus a capability-free payload before target preparation, provider invocation, or writes; native macOS and Windows therefore fail closed. The command also fails closed when a required runner, browser, or test runtime is unavailable. The 192-case catalog includes 92 framework-neutral business prompts and 45 writable implementation/regression cases (23.4%). The release command runs live routing, writable trusted oracles, per-target `generate`/`typecheck`/`lint`/`build`, any declared generated test, and isolated generated-code review for every writable result. Foundation and target validation—including `yarn build`—receive a minimal environment with network access denied, and persisted diagnostics redact sensitive environment values and URL userinfo. Test-authoring coverage executes a Jest unit test plus Linux/Bubblewrap loopback-only Playwright API and browser tests through fixed controller-owned commands against a read-only target; runtime reports must attest at least one passed test and zero skipped, todo, focused, flaky, or expected-failure tests. The suite then writes a schema-valid sanitized mode-`0600` report under `.ai/harness/results/` with the selected primary and optional portability runner policy.
148
+
149
+ Use the bundled `om-evolve-harness` skill to add a real case: reproduce failure first, select one smallest knowledge owner, run any generated unit/integration tests plus target checks, require code review, and finish with the full release suite. Open Mercato framework maintainers use the monorepo-only `$om-refresh-standalone-harness --from <ref> --to <ref>` workflow for every release range and retain its sanitized maintenance report.
150
+
151
+ For normal app changes, describe the business outcome directly or use the installed spec workflow for multi-phase work. Before handoff, run `yarn generate`, the smallest affected unit/integration tests, `yarn typecheck`, `yarn lint`, and `yarn build` as appropriate; applying migrations still requires explicit approval.
152
+
81
153
  ## Git And GitHub
82
154
 
83
155
  Interactive scaffolds ask whether to initialize a local Git repository after the app is created. Non-interactive scaffolds skip Git initialization unless `--init-git` is passed.
@@ -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.
@@ -0,0 +1,107 @@
1
+ # Standalone Architecture and Discovery
2
+
3
+ Use this guide to choose ownership, locate module surfaces, and keep generated discovery correct.
4
+
5
+ ## Context Ownership and Scattering
6
+
7
+ The harness is intentionally layered so an agent can assemble precise context without paying for the whole framework:
8
+
9
+ | Layer | Owns | Loading rule |
10
+ |---|---|---|
11
+ | Root `AGENTS.md` | Non-negotiable safety, validation, precedence, and the three-axis router | Load first and always; it is the only initial bundle. |
12
+ | `.ai/guides/*.md` | Stable framework concepts and contracts by area | Load the de-duplicated set selected by the area and primitive axes. |
13
+ | Thin task skills | Branching procedure and links to focused references | Load only matched skills; open only the references needed by the chosen branch. |
14
+ | `.ai/guides/modules/*.md` | Generated identifiers and discovered surfaces for an exact installed module/version | Load only for installed modules named, changed, integrated with, or used as hosts. |
15
+ | `om-framework-context` output | Exact installed instructions, source/types, and bounded search results | Last-mile escalation after app call sites, facts, and concept guides cannot answer the question. |
16
+ | External `open-mercato/skills` | SDLC and delivery workflows | Select independently only when the requested lifecycle needs one. |
17
+
18
+ Match area, work units, and delivery independently, then de-duplicate their union by path and skill. A business one-shot is not one giant context category: split it into units such as entity, command, API, admin UI, public capture, CRM extension, event, and provider, and give each unit only its owning area and contract. Do not preload all module facts, skill references, upstream guides, or installed package source.
19
+
20
+ Keep facts and source in different roles. Facts answer “what identifier or surface exists?”; exact installed source answers “how does this version implement or type the contract?” The latter is read-only evidence, never a writable escape hatch.
21
+
22
+ ## Ownership Decision
23
+
24
+ | Need | Choose |
25
+ |---|---|
26
+ | App-specific domain capability | Create `src/modules/<id>/` and register `{ id, from: '@app' }` in `src/modules.ts`. |
27
+ | Additive change to an installed module | Use the smallest UMES mechanism from `.ai/guides/extensions.md`. |
28
+ | Disable/replace a supported installed contract | Use the target module entry's `overrides` in `src/modules.ts`. |
29
+ | Reusable external provider | Add/install a dedicated provider package; do not place provider logic in a generic core module. |
30
+ | Change unsupported by UMES/overrides | Inspect exact installed context, then use `om-eject-and-customize` only with user approval. |
31
+ | Framework defect affecting all consumers | Reproduce against the installed version and report an upstream change; never patch `node_modules`. |
32
+
33
+ ## Writable and Read-Only Trees
34
+
35
+ ```text
36
+ src/modules/<id>/ writable app modules
37
+ src/modules.ts enabled modules and supported overrides
38
+ .mercato/generated/ generated, never edit
39
+ .ai/guides/modules/ generated facts, never edit
40
+ node_modules/@open-mercato/*/ exact installed packages, read-only
41
+ ```
42
+
43
+ Do not copy an installed module merely to learn it. Generated facts and the context resolver expose the exact installed source without widening the writable surface.
44
+
45
+ ## Canonical Module Shape
46
+
47
+ ```text
48
+ src/modules/<id>/
49
+ ├── index.ts
50
+ ├── data/{entities,validators,extensions,enrichers}.ts
51
+ ├── api/**/route.ts
52
+ ├── backend/**/{page.tsx,page.meta.ts}
53
+ ├── frontend/**/{page.tsx,page.meta.ts}
54
+ ├── commands/
55
+ ├── subscribers/
56
+ ├── workers/
57
+ ├── widgets/{injection,injection-table.ts,components.ts}
58
+ ├── acl.ts
59
+ ├── setup.ts
60
+ ├── di.ts
61
+ ├── events.ts
62
+ ├── search.ts
63
+ ├── ce.ts
64
+ ├── translations.ts
65
+ ├── notifications.ts
66
+ ├── encryption.ts
67
+ ├── ai-agents.ts
68
+ └── ai-tools.ts
69
+ ```
70
+
71
+ Create only files required by the capability. Keep the module id plural `snake_case`; keep entity/event/feature/spot/agent/tool identifiers stable once used.
72
+ For the complete current convention-file catalog, load `om-module-scaffold` → `references/discovery-surface-catalog.md`; do not expand this always-routed guide into the full catalog.
73
+
74
+ ## Auto-Discovery
75
+
76
+ - Put backend routes under `backend/**/page.tsx`; the module root becomes `/backend/<module>` and nested folders preserve their segments.
77
+ - Put public routes under `frontend/**/page.tsx`. Portal routes require `frontend/[orgSlug]/portal/**/page.tsx` with `[orgSlug]` first.
78
+ - Put API handlers under `api/**/route.ts`. Export HTTP handlers, per-method `metadata`, and `openApi`; do not organize routes in HTTP-method directories.
79
+ - Put subscribers and workers in their named directories with `metadata` plus a default handler.
80
+ - Keep convention files at the module root. Root files such as `events.ts`, `search.ts`, `ai-agents.ts`, and `ai-tools.ts` are exact discovery names.
81
+ - Run `yarn generate` after any structural/discovered change; never repair a registry by hand.
82
+
83
+ ## Installed Framework Context
84
+
85
+ 1. Read `.ai/guides/modules/<id>.md` for entity IDs, events, routes/auth, ACL, DI, search, notifications, and host spots.
86
+ 2. When facts are insufficient, invoke `om-framework-context` or run `yarn framework:context --module <id> --query <term>`.
87
+ 3. Confirm the resolved package/version matches the fact sheet stamp.
88
+ 4. Read the reported instruction chain in precedence order, then search only the reported package/module root with the bounded `rg --no-ignore --hidden` command.
89
+ 5. Treat source and installed `AGENTS.md` files as read-only evidence. If the package has no `src`, use reported `dist`/types and state the limitation.
90
+ 6. If duplicate packages, version skew, or conflicting rules remain, stop instead of combining contracts from different versions.
91
+
92
+ The app root governs writable locations and safety. The compatibility snapshot governs stable public identifiers. The nearest installed package/module guide governs version-specific implementation details.
93
+
94
+ ## Package and Bootstrap Boundaries
95
+
96
+ - Import public package exports; do not reach through monorepo-only relative paths or app-generated registries from a package.
97
+ - Ensure package-backed modules are dependencies and enabled in `src/modules.ts` before assuming their services or files exist.
98
+ - Optional modules must degrade safely: the optional consumer owns glue and uses events, IDs/snapshots, widgets/enrichers, or a guarded DI resolve.
99
+ - Validate browser, API, CLI, worker, and queue bootstrap paths when a registry/global/service is consumed by more than one runtime.
100
+ - Prefer `globalThis` registries or structural type guards over chunk-local singleton/`instanceof` assumptions where bundlers may duplicate modules.
101
+
102
+ ## Completion Check
103
+
104
+ 1. Verify app code is under `src/modules/` and installed packages remain unchanged.
105
+ 2. Verify every new discovered file uses its exact filename/export contract.
106
+ 3. Run `yarn generate` and inspect warnings and the affected generated registration.
107
+ 4. Run focused type/tests, then exercise every relevant runtime bootstrap.