create-mercato-app 0.6.7-develop.6863.1.61001cf9a8 → 0.6.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (418) hide show
  1. package/README.md +0 -72
  2. package/agentic/claude-code/hooks/entity-migration-check.ts +88 -32
  3. package/agentic/codex/enforcement-rules.md +16 -2
  4. package/agentic/cursor/hooks/entity-migration-check.mjs +50 -19
  5. package/agentic/cursor/rules/entity-guard.mdc +21 -9
  6. package/agentic/cursor/rules/generated-guard.mdc +5 -3
  7. package/agentic/cursor/rules/open-mercato.mdc +29 -3
  8. package/agentic/guides/module-system.md +127 -12
  9. package/agentic/shared/AGENTS.md.template +311 -124
  10. package/agentic/shared/ai/agentic.config.json +0 -2
  11. package/agentic/shared/ai/lessons.md +3 -26
  12. package/agentic/shared/ai/skills/om-auto-continue-pr-loop/SKILL.md +27 -0
  13. package/agentic/shared/ai/skills/om-auto-create-pr-loop/SKILL.md +27 -0
  14. package/agentic/shared/ai/skills/om-auto-review-pr/SKILL.md +0 -4
  15. package/agentic/shared/ai/skills/om-backend-ui-design/SKILL.md +241 -20
  16. package/agentic/shared/ai/skills/om-backend-ui-design/references/ui-components.md +260 -0
  17. package/agentic/shared/ai/skills/om-data-model-design/SKILL.md +601 -16
  18. package/agentic/shared/ai/skills/om-data-model-design/references/mikro-orm-cheatsheet.md +146 -0
  19. package/agentic/shared/ai/skills/om-eject-and-customize/SKILL.md +310 -14
  20. package/agentic/shared/ai/skills/om-help/SKILL.md +97 -15
  21. package/agentic/shared/ai/skills/om-help/references/skills-catalog.md +84 -0
  22. package/agentic/shared/ai/skills/om-help/references/workflow-sequences.md +193 -0
  23. package/agentic/shared/ai/skills/om-implement-spec/SKILL.md +152 -33
  24. package/agentic/shared/ai/skills/om-integration-builder/SKILL.md +708 -24
  25. package/agentic/shared/ai/skills/om-integration-builder/STANDALONE.md +34 -0
  26. package/agentic/shared/ai/skills/om-integration-builder/references/adapter-contracts.md +762 -0
  27. package/agentic/shared/ai/skills/om-module-scaffold/SKILL.md +820 -20
  28. package/agentic/shared/ai/skills/om-module-scaffold/references/naming-conventions.md +50 -0
  29. package/agentic/shared/ai/skills/om-module-scaffold/references/navigation-patterns.md +97 -0
  30. package/agentic/shared/ai/skills/om-system-extension/SKILL.md +843 -19
  31. package/agentic/shared/ai/skills/om-system-extension/references/extension-contracts.md +271 -0
  32. package/agentic/shared/ai/skills/om-trim-unused-modules/SKILL.md +63 -15
  33. package/agentic/shared/ai/skills/om-troubleshooter/SKILL.md +467 -16
  34. package/agentic/shared/ai/skills/om-troubleshooter/references/diagnostic-commands.md +101 -0
  35. package/agentic/shared/ai/skills/tiers.json +21 -143
  36. package/agentic/shared/ai/skills/tiers.schema.json +40 -52
  37. package/agentic/shared/ai/specs/README.md +3 -4
  38. package/agentic/shared/ai/specs/SPEC-000-template.md +10 -226
  39. package/agentic/shared/ai/trackers/github.md +4 -108
  40. package/agentic/shared/scripts/install-skills.sh +694 -4
  41. package/dist/agentic/claude-code/hooks/entity-migration-check.ts +88 -32
  42. package/dist/agentic/codex/enforcement-rules.md +16 -2
  43. package/dist/agentic/cursor/hooks/entity-migration-check.mjs +50 -19
  44. package/dist/agentic/cursor/rules/entity-guard.mdc +21 -9
  45. package/dist/agentic/cursor/rules/generated-guard.mdc +5 -3
  46. package/dist/agentic/cursor/rules/open-mercato.mdc +29 -3
  47. package/dist/agentic/guides/cache.md +45 -0
  48. package/dist/agentic/guides/core.md +453 -0
  49. package/dist/agentic/guides/events.md +117 -0
  50. package/dist/agentic/guides/module-facts.json +3833 -115419
  51. package/dist/agentic/guides/module-system.md +127 -12
  52. package/dist/agentic/guides/modules/ai_assistant.md +28 -227
  53. package/dist/agentic/guides/modules/api_docs.md +2 -58
  54. package/dist/agentic/guides/modules/api_keys.md +7 -92
  55. package/dist/agentic/guides/modules/attachments.md +14 -119
  56. package/dist/agentic/guides/modules/audit_logs.md +10 -131
  57. package/dist/agentic/guides/modules/auth.md +33 -276
  58. package/dist/agentic/guides/modules/business_rules.md +14 -149
  59. package/dist/agentic/guides/modules/catalog.md +43 -475
  60. package/dist/agentic/guides/modules/channel_gmail.md +3 -82
  61. package/dist/agentic/guides/modules/channel_imap.md +3 -82
  62. package/dist/agentic/guides/modules/checkout.md +27 -299
  63. package/dist/agentic/guides/modules/communication_channels.md +33 -315
  64. package/dist/agentic/guides/modules/configs.md +8 -104
  65. package/dist/agentic/guides/modules/content.md +2 -57
  66. package/dist/agentic/guides/modules/currencies.md +17 -152
  67. package/dist/agentic/guides/modules/customer_accounts.md +45 -387
  68. package/dist/agentic/guides/modules/customers.md +85 -746
  69. package/dist/agentic/guides/modules/dashboards.md +10 -155
  70. package/dist/agentic/guides/modules/data_sync.md +16 -149
  71. package/dist/agentic/guides/modules/dictionaries.md +12 -107
  72. package/dist/agentic/guides/modules/directory.md +15 -148
  73. package/dist/agentic/guides/modules/entities.md +13 -145
  74. package/dist/agentic/guides/modules/events.md +2 -59
  75. package/dist/agentic/guides/modules/feature_toggles.md +9 -119
  76. package/dist/agentic/guides/modules/gateway_stripe.md +4 -92
  77. package/dist/agentic/guides/modules/generators.md +2 -45
  78. package/dist/agentic/guides/modules/inbox_ops.md +27 -207
  79. package/dist/agentic/guides/modules/integrations.md +16 -146
  80. package/dist/agentic/guides/modules/messages.md +24 -223
  81. package/dist/agentic/guides/modules/notifications.md +8 -96
  82. package/dist/agentic/guides/modules/onboarding.md +6 -77
  83. package/dist/agentic/guides/modules/payment_gateways.md +21 -164
  84. package/dist/agentic/guides/modules/perspectives.md +7 -77
  85. package/dist/agentic/guides/modules/planner.md +18 -136
  86. package/dist/agentic/guides/modules/portal.md +2 -93
  87. package/dist/agentic/guides/modules/progress.md +14 -104
  88. package/dist/agentic/guides/modules/query_index.md +15 -154
  89. package/dist/agentic/guides/modules/record_locks.md +21 -206
  90. package/dist/agentic/guides/modules/resources.md +30 -197
  91. package/dist/agentic/guides/modules/sales.md +84 -678
  92. package/dist/agentic/guides/modules/scheduler.md +14 -133
  93. package/dist/agentic/guides/modules/search.md +6 -170
  94. package/dist/agentic/guides/modules/security.md +35 -294
  95. package/dist/agentic/guides/modules/shipping_carriers.md +18 -134
  96. package/dist/agentic/guides/modules/sso.md +26 -151
  97. package/dist/agentic/guides/modules/staff.md +57 -369
  98. package/dist/agentic/guides/modules/storage_s3.md +5 -95
  99. package/dist/agentic/guides/modules/sync_akeneo.md +3 -85
  100. package/dist/agentic/guides/modules/sync_excel.md +6 -75
  101. package/dist/agentic/guides/modules/system_status_overlays.md +2 -60
  102. package/dist/agentic/guides/modules/translations.md +10 -104
  103. package/dist/agentic/guides/modules/webhooks.md +24 -203
  104. package/dist/agentic/guides/modules/wms.md +46 -441
  105. package/dist/agentic/guides/modules/workflows.md +43 -302
  106. package/dist/agentic/guides/queue.md +53 -0
  107. package/dist/agentic/guides/search.md +115 -0
  108. package/dist/agentic/guides/shared.md +108 -0
  109. package/dist/agentic/guides/ui.md +347 -0
  110. package/dist/agentic/shared/AGENTS.md.template +311 -124
  111. package/dist/agentic/shared/ai/agentic.config.json +0 -2
  112. package/dist/agentic/shared/ai/lessons.md +3 -26
  113. package/dist/agentic/shared/ai/skills/om-auto-continue-pr-loop/SKILL.md +27 -0
  114. package/dist/agentic/shared/ai/skills/om-auto-create-pr-loop/SKILL.md +27 -0
  115. package/dist/agentic/shared/ai/skills/om-auto-review-pr/SKILL.md +0 -4
  116. package/dist/agentic/shared/ai/skills/om-backend-ui-design/SKILL.md +241 -20
  117. package/dist/agentic/shared/ai/skills/om-backend-ui-design/references/ui-components.md +260 -0
  118. package/dist/agentic/shared/ai/skills/om-data-model-design/SKILL.md +601 -16
  119. package/dist/agentic/shared/ai/skills/om-data-model-design/references/mikro-orm-cheatsheet.md +146 -0
  120. package/dist/agentic/shared/ai/skills/om-eject-and-customize/SKILL.md +310 -14
  121. package/dist/agentic/shared/ai/skills/om-help/SKILL.md +97 -15
  122. package/dist/agentic/shared/ai/skills/om-help/references/skills-catalog.md +84 -0
  123. package/dist/agentic/shared/ai/skills/om-help/references/workflow-sequences.md +193 -0
  124. package/dist/agentic/shared/ai/skills/om-implement-spec/SKILL.md +152 -33
  125. package/dist/agentic/shared/ai/skills/om-integration-builder/SKILL.md +708 -24
  126. package/dist/agentic/shared/ai/skills/om-integration-builder/STANDALONE.md +34 -0
  127. package/dist/agentic/shared/ai/skills/om-integration-builder/references/adapter-contracts.md +762 -0
  128. package/dist/agentic/shared/ai/skills/om-module-scaffold/SKILL.md +820 -20
  129. package/dist/agentic/shared/ai/skills/om-module-scaffold/references/naming-conventions.md +50 -0
  130. package/dist/agentic/shared/ai/skills/om-module-scaffold/references/navigation-patterns.md +97 -0
  131. package/dist/agentic/shared/ai/skills/om-system-extension/SKILL.md +843 -19
  132. package/dist/agentic/shared/ai/skills/om-system-extension/references/extension-contracts.md +271 -0
  133. package/dist/agentic/shared/ai/skills/om-trim-unused-modules/SKILL.md +63 -15
  134. package/dist/agentic/shared/ai/skills/om-troubleshooter/SKILL.md +467 -16
  135. package/dist/agentic/shared/ai/skills/om-troubleshooter/references/diagnostic-commands.md +101 -0
  136. package/dist/agentic/shared/ai/skills/tiers.json +21 -143
  137. package/dist/agentic/shared/ai/skills/tiers.schema.json +40 -52
  138. package/dist/agentic/shared/ai/specs/README.md +3 -4
  139. package/dist/agentic/shared/ai/specs/SPEC-000-template.md +10 -226
  140. package/dist/agentic/shared/ai/trackers/github.md +4 -108
  141. package/dist/agentic/shared/scripts/install-skills.sh +694 -4
  142. package/dist/index.js +183 -160
  143. package/package.json +7 -9
  144. package/template/.env.example +2 -59
  145. package/template/.yarnrc.yml.template +0 -9
  146. package/template/AGENTS.md +663 -93
  147. package/template/eslint.config.mjs +0 -1
  148. package/template/gitignore +0 -8
  149. package/template/jest.config.cjs +1 -2
  150. package/template/next.config.ts +0 -55
  151. package/template/package.json.template +25 -31
  152. package/template/scripts/dev-runtime-log-policy.mjs +0 -33
  153. package/template/scripts/dev-runtime.mjs +76 -142
  154. package/template/scripts/dev.mjs +7 -88
  155. package/template/scripts/install-skills.sh +19 -2
  156. package/template/src/app/(backend)/backend/__tests__/layout-route-registry.test.tsx +0 -1
  157. package/template/src/app/(backend)/backend/layout.tsx +3 -5
  158. package/template/src/app/(frontend)/layout.tsx +1 -1
  159. package/template/src/app/api/[...slug]/route.ts +0 -9
  160. package/template/src/app/globals.css +3 -61
  161. package/template/src/app/layout.tsx +18 -14
  162. package/template/src/app/page.tsx +1 -4
  163. package/template/src/components/AppProviders.tsx +1 -4
  164. package/template/src/components/DemoFeedbackWidget.tsx +1 -1
  165. package/template/src/components/__tests__/AppProviders.test.tsx +2 -11
  166. package/template/src/i18n/de.json +1 -21
  167. package/template/src/i18n/en.json +1 -21
  168. package/template/src/i18n/es.json +1 -21
  169. package/template/src/i18n/pl.json +1 -21
  170. package/template/src/instrumentation.ts +1 -14
  171. package/template/src/lib/i18n/register-dictionary-loader.ts +0 -2
  172. package/template/src/modules/example/__integration__/TC-UMES-003.spec.ts +3 -7
  173. package/template/src/modules/example/__integration__/TC-UMES-005.spec.ts +1 -7
  174. package/template/src/modules/example/__integration__/TC-UMES-009.spec.ts +10 -11
  175. package/template/src/modules/example/__integration__/todo-priority-validation.spec.ts +1 -31
  176. package/template/src/modules/example/acl.ts +0 -6
  177. package/template/src/modules/example/backend/mutation-lifecycle/page.meta.ts +9 -1
  178. package/template/src/modules/example/backend/page.meta.ts +10 -1
  179. package/template/src/modules/example/backend/payments/page.meta.ts +10 -1
  180. package/template/src/modules/example/backend/todos/create/page.meta.ts +11 -1
  181. package/template/src/modules/example/backend/todos/page.meta.ts +10 -1
  182. package/template/src/modules/example/backend/umes-extensions/page.meta.ts +9 -1
  183. package/template/src/modules/example/backend/umes-handlers/page.meta.ts +10 -1
  184. package/template/src/modules/example/backend/umes-integrations/page.meta.ts +10 -1
  185. package/template/src/modules/example/backend/umes-next-phases/page.meta.ts +11 -1
  186. package/template/src/modules/example/backend/umes-query-extensions/page.meta.ts +11 -1
  187. package/template/src/modules/example/commands/todos.ts +2 -47
  188. package/template/src/modules/example/i18n/pl.json +68 -68
  189. package/template/src/modules/example/lib/__tests__/mock-webhook-endpoint-adapter.test.ts +0 -14
  190. package/template/src/modules.ts +0 -17
  191. package/template/tsconfig.json +2 -3
  192. package/agentic/guides/ai-workflows.md +0 -76
  193. package/agentic/guides/architecture.md +0 -107
  194. package/agentic/guides/backend-ui.md +0 -80
  195. package/agentic/guides/contracts.md +0 -92
  196. package/agentic/guides/extensions.md +0 -121
  197. package/agentic/guides/integrations.md +0 -81
  198. package/agentic/guides/spec-delivery.md +0 -22
  199. package/agentic/guides/testing-debugging.md +0 -80
  200. package/agentic/shared/ai/harness/README.md +0 -50
  201. package/agentic/shared/ai/harness/RELEASE.md +0 -57
  202. package/agentic/shared/ai/harness/cases.json +0 -13680
  203. package/agentic/shared/ai/harness/cases.schema.json +0 -133
  204. package/agentic/shared/ai/harness/fixtures/index.json +0 -49
  205. package/agentic/shared/ai/harness/fixtures/seeds.json +0 -162
  206. package/agentic/shared/ai/harness/generated-code-review-policy.md +0 -21
  207. package/agentic/shared/ai/harness/generated-code-review-response.schema.json +0 -96
  208. package/agentic/shared/ai/harness/generated-code-review-result.schema.json +0 -172
  209. package/agentic/shared/ai/harness/release-matrix.json +0 -158
  210. package/agentic/shared/ai/harness/release-result.schema.json +0 -219
  211. package/agentic/shared/ai/harness/result.schema.json +0 -76
  212. package/agentic/shared/ai/harness/routing-response.schema.json +0 -12
  213. package/agentic/shared/ai/harness/target-validation-result.schema.json +0 -73
  214. package/agentic/shared/ai/harness/validators.json +0 -78
  215. package/agentic/shared/ai/harness/writable-ast-oracles.mjs +0 -2121
  216. package/agentic/shared/ai/harness/writable-behavior-oracles.mjs +0 -1096
  217. package/agentic/shared/ai/lessons/_template.md +0 -16
  218. package/agentic/shared/ai/review-checklist.md +0 -36
  219. package/agentic/shared/ai/skills/om-auto-implement-spec/SKILL.md +0 -21
  220. package/agentic/shared/ai/skills/om-auto-upgrade-0.6.6-to-0.6.7/SKILL.md +0 -98
  221. package/agentic/shared/ai/skills/om-backend-ui-design/references/crud-surfaces.md +0 -16
  222. package/agentic/shared/ai/skills/om-backend-ui-design/references/frontend-and-design-system.md +0 -53
  223. package/agentic/shared/ai/skills/om-backend-ui-design/references/page-and-navigation.md +0 -13
  224. package/agentic/shared/ai/skills/om-backend-ui-design/references/quality-states.md +0 -11
  225. package/agentic/shared/ai/skills/om-build-workflow/SKILL.md +0 -30
  226. package/agentic/shared/ai/skills/om-build-workflow/references/activity-contracts.md +0 -12
  227. package/agentic/shared/ai/skills/om-build-workflow/references/durability-and-progress.md +0 -13
  228. package/agentic/shared/ai/skills/om-build-workflow/references/workflow-design.md +0 -14
  229. package/agentic/shared/ai/skills/om-create-ai-agent/SKILL.md +0 -28
  230. package/agentic/shared/ai/skills/om-create-ai-agent/references/attachments-and-overrides.md +0 -12
  231. package/agentic/shared/ai/skills/om-create-ai-agent/references/module-agents-and-tools.md +0 -22
  232. package/agentic/shared/ai/skills/om-create-ai-agent/references/orchestrator-agents.md +0 -12
  233. package/agentic/shared/ai/skills/om-create-ai-agent/references/surface-selector.md +0 -19
  234. package/agentic/shared/ai/skills/om-data-model-design/references/integrity-and-concurrency.md +0 -19
  235. package/agentic/shared/ai/skills/om-data-model-design/references/migration-workflow.md +0 -13
  236. package/agentic/shared/ai/skills/om-data-model-design/references/schema-design.md +0 -14
  237. package/agentic/shared/ai/skills/om-data-model-design/references/sensitive-data.md +0 -10
  238. package/agentic/shared/ai/skills/om-eject-and-customize/references/decision-and-procedure.md +0 -17
  239. package/agentic/shared/ai/skills/om-evolve-harness/SKILL.md +0 -29
  240. package/agentic/shared/ai/skills/om-evolve-harness/references/case-template.md +0 -100
  241. package/agentic/shared/ai/skills/om-evolve-harness/references/case-workflow.md +0 -16
  242. package/agentic/shared/ai/skills/om-evolve-harness/references/owner-selection.md +0 -17
  243. package/agentic/shared/ai/skills/om-framework-context/SKILL.md +0 -25
  244. package/agentic/shared/ai/skills/om-framework-context/references/resolver-procedure.md +0 -11
  245. package/agentic/shared/ai/skills/om-framework-context/references/skew-and-escalation.md +0 -13
  246. package/agentic/shared/ai/skills/om-help/references/delivery-workflows.md +0 -18
  247. package/agentic/shared/ai/skills/om-help/references/task-families.md +0 -20
  248. package/agentic/shared/ai/skills/om-implement-spec/references/phases-and-gates.md +0 -33
  249. package/agentic/shared/ai/skills/om-implement-spec/references/planning-and-progress.md +0 -40
  250. package/agentic/shared/ai/skills/om-implement-spec/references/report-templates.md +0 -27
  251. package/agentic/shared/ai/skills/om-implement-spec/references/spec-resolution.md +0 -24
  252. package/agentic/shared/ai/skills/om-integration-builder/references/package-and-activation.md +0 -16
  253. package/agentic/shared/ai/skills/om-integration-builder/references/provider-families.md +0 -14
  254. package/agentic/shared/ai/skills/om-integration-builder/references/security-and-reliability.md +0 -15
  255. package/agentic/shared/ai/skills/om-integration-builder/references/sync-and-files.md +0 -12
  256. package/agentic/shared/ai/skills/om-judge-agent-session/SKILL.md +0 -34
  257. package/agentic/shared/ai/skills/om-judge-agent-session/agents/openai.yaml +0 -4
  258. package/agentic/shared/ai/skills/om-judge-agent-session/references/agentic-setup.md +0 -11
  259. package/agentic/shared/ai/skills/om-judge-agent-session/references/input-normalization.md +0 -31
  260. package/agentic/shared/ai/skills/om-judge-agent-session/references/judge-workflow.md +0 -39
  261. package/agentic/shared/ai/skills/om-judge-agent-session/references/report-template.md +0 -43
  262. package/agentic/shared/ai/skills/om-judge-agent-session/references/rules.md +0 -11
  263. package/agentic/shared/ai/skills/om-module-scaffold/references/api-and-domain.md +0 -19
  264. package/agentic/shared/ai/skills/om-module-scaffold/references/business-one-shot-blueprints.md +0 -172
  265. package/agentic/shared/ai/skills/om-module-scaffold/references/data-and-migrations.md +0 -12
  266. package/agentic/shared/ai/skills/om-module-scaffold/references/discovery-surface-catalog.md +0 -83
  267. package/agentic/shared/ai/skills/om-module-scaffold/references/module-surfaces.md +0 -21
  268. package/agentic/shared/ai/skills/om-module-scaffold/references/planning.md +0 -11
  269. package/agentic/shared/ai/skills/om-module-scaffold/references/runtime-cache-and-queues.md +0 -22
  270. package/agentic/shared/ai/skills/om-module-scaffold/references/verification.md +0 -13
  271. package/agentic/shared/ai/skills/om-share-this-session/SKILL.md +0 -41
  272. package/agentic/shared/ai/skills/om-share-this-session/references/agentic-setup.md +0 -19
  273. package/agentic/shared/ai/skills/om-share-this-session/references/bundle-preparation.md +0 -44
  274. package/agentic/shared/ai/skills/om-share-this-session/references/consent-and-review.md +0 -39
  275. package/agentic/shared/ai/skills/om-share-this-session/references/publication.md +0 -20
  276. package/agentic/shared/ai/skills/om-share-this-session/references/report-templates.md +0 -57
  277. package/agentic/shared/ai/skills/om-share-this-session/references/rules.md +0 -11
  278. package/agentic/shared/ai/skills/om-share-this-session/scripts/prepare-share-bundle.mjs +0 -486
  279. package/agentic/shared/ai/skills/om-system-extension/references/extension-branches.md +0 -18
  280. package/agentic/shared/ai/skills/om-system-extension/references/mechanism-selector.md +0 -27
  281. package/agentic/shared/ai/skills/om-system-extension/references/read-write-roundtrip.md +0 -13
  282. package/agentic/shared/ai/skills/om-system-extension/references/unified-overrides.md +0 -41
  283. package/agentic/shared/ai/skills/om-system-extension/references/verification.md +0 -11
  284. package/agentic/shared/ai/skills/om-trim-unused-modules/references/dependency-and-redirect.md +0 -15
  285. package/agentic/shared/ai/skills/om-troubleshooter/references/diagnosis-map.md +0 -16
  286. package/agentic/shared/ai/skills/om-troubleshooter/references/regression-oracles.md +0 -14
  287. package/agentic/shared/scripts/agent-harness-tool-server.mjs +0 -187
  288. package/agentic/shared/scripts/check-lessons.mjs +0 -178
  289. package/agentic/shared/scripts/evaluate-agent-harness.mjs +0 -2958
  290. package/agentic/shared/scripts/execution-sandbox.mjs +0 -329
  291. package/agentic/shared/scripts/framework-context.mjs +0 -888
  292. package/agentic/shared/scripts/install-skills.mjs +0 -1029
  293. package/agentic/shared/scripts/prepare-agent-harness-fixture.mjs +0 -222
  294. package/agentic/shared/scripts/run-agent-harness-release.mjs +0 -1774
  295. package/dist/agentic/guides/ai-workflows.md +0 -76
  296. package/dist/agentic/guides/architecture.md +0 -107
  297. package/dist/agentic/guides/backend-ui.md +0 -80
  298. package/dist/agentic/guides/contracts.md +0 -92
  299. package/dist/agentic/guides/extensions.md +0 -121
  300. package/dist/agentic/guides/framework-extension-points.md +0 -36
  301. package/dist/agentic/guides/integrations.md +0 -81
  302. package/dist/agentic/guides/modules/design_system.md +0 -102
  303. package/dist/agentic/guides/spec-delivery.md +0 -22
  304. package/dist/agentic/guides/testing-debugging.md +0 -80
  305. package/dist/agentic/guides/upstream/AGENTS.md +0 -298
  306. package/dist/agentic/guides/upstream/BACKWARD_COMPATIBILITY.md +0 -316
  307. package/dist/agentic/guides/upstream/manifest.json +0 -8
  308. package/dist/agentic/shared/ai/harness/README.md +0 -50
  309. package/dist/agentic/shared/ai/harness/RELEASE.md +0 -57
  310. package/dist/agentic/shared/ai/harness/cases.json +0 -13680
  311. package/dist/agentic/shared/ai/harness/cases.schema.json +0 -133
  312. package/dist/agentic/shared/ai/harness/fixtures/index.json +0 -49
  313. package/dist/agentic/shared/ai/harness/fixtures/seeds.json +0 -162
  314. package/dist/agentic/shared/ai/harness/generated-code-review-policy.md +0 -21
  315. package/dist/agentic/shared/ai/harness/generated-code-review-response.schema.json +0 -96
  316. package/dist/agentic/shared/ai/harness/generated-code-review-result.schema.json +0 -172
  317. package/dist/agentic/shared/ai/harness/release-matrix.json +0 -158
  318. package/dist/agentic/shared/ai/harness/release-result.schema.json +0 -219
  319. package/dist/agentic/shared/ai/harness/result.schema.json +0 -76
  320. package/dist/agentic/shared/ai/harness/routing-response.schema.json +0 -12
  321. package/dist/agentic/shared/ai/harness/target-validation-result.schema.json +0 -73
  322. package/dist/agentic/shared/ai/harness/validators.json +0 -78
  323. package/dist/agentic/shared/ai/harness/writable-ast-oracles.mjs +0 -2121
  324. package/dist/agentic/shared/ai/harness/writable-behavior-oracles.mjs +0 -1096
  325. package/dist/agentic/shared/ai/lessons/_template.md +0 -16
  326. package/dist/agentic/shared/ai/review-checklist.md +0 -36
  327. package/dist/agentic/shared/ai/skills/om-auto-implement-spec/SKILL.md +0 -21
  328. package/dist/agentic/shared/ai/skills/om-auto-upgrade-0.6.6-to-0.6.7/SKILL.md +0 -98
  329. package/dist/agentic/shared/ai/skills/om-backend-ui-design/references/crud-surfaces.md +0 -16
  330. package/dist/agentic/shared/ai/skills/om-backend-ui-design/references/frontend-and-design-system.md +0 -53
  331. package/dist/agentic/shared/ai/skills/om-backend-ui-design/references/page-and-navigation.md +0 -13
  332. package/dist/agentic/shared/ai/skills/om-backend-ui-design/references/quality-states.md +0 -11
  333. package/dist/agentic/shared/ai/skills/om-build-workflow/SKILL.md +0 -30
  334. package/dist/agentic/shared/ai/skills/om-build-workflow/references/activity-contracts.md +0 -12
  335. package/dist/agentic/shared/ai/skills/om-build-workflow/references/durability-and-progress.md +0 -13
  336. package/dist/agentic/shared/ai/skills/om-build-workflow/references/workflow-design.md +0 -14
  337. package/dist/agentic/shared/ai/skills/om-create-ai-agent/SKILL.md +0 -28
  338. package/dist/agentic/shared/ai/skills/om-create-ai-agent/references/attachments-and-overrides.md +0 -12
  339. package/dist/agentic/shared/ai/skills/om-create-ai-agent/references/module-agents-and-tools.md +0 -22
  340. package/dist/agentic/shared/ai/skills/om-create-ai-agent/references/orchestrator-agents.md +0 -12
  341. package/dist/agentic/shared/ai/skills/om-create-ai-agent/references/surface-selector.md +0 -19
  342. package/dist/agentic/shared/ai/skills/om-data-model-design/references/integrity-and-concurrency.md +0 -19
  343. package/dist/agentic/shared/ai/skills/om-data-model-design/references/migration-workflow.md +0 -13
  344. package/dist/agentic/shared/ai/skills/om-data-model-design/references/schema-design.md +0 -14
  345. package/dist/agentic/shared/ai/skills/om-data-model-design/references/sensitive-data.md +0 -10
  346. package/dist/agentic/shared/ai/skills/om-eject-and-customize/references/decision-and-procedure.md +0 -17
  347. package/dist/agentic/shared/ai/skills/om-evolve-harness/SKILL.md +0 -29
  348. package/dist/agentic/shared/ai/skills/om-evolve-harness/references/case-template.md +0 -100
  349. package/dist/agentic/shared/ai/skills/om-evolve-harness/references/case-workflow.md +0 -16
  350. package/dist/agentic/shared/ai/skills/om-evolve-harness/references/owner-selection.md +0 -17
  351. package/dist/agentic/shared/ai/skills/om-framework-context/SKILL.md +0 -25
  352. package/dist/agentic/shared/ai/skills/om-framework-context/references/resolver-procedure.md +0 -11
  353. package/dist/agentic/shared/ai/skills/om-framework-context/references/skew-and-escalation.md +0 -13
  354. package/dist/agentic/shared/ai/skills/om-help/references/delivery-workflows.md +0 -18
  355. package/dist/agentic/shared/ai/skills/om-help/references/task-families.md +0 -20
  356. package/dist/agentic/shared/ai/skills/om-implement-spec/references/phases-and-gates.md +0 -33
  357. package/dist/agentic/shared/ai/skills/om-implement-spec/references/planning-and-progress.md +0 -40
  358. package/dist/agentic/shared/ai/skills/om-implement-spec/references/report-templates.md +0 -27
  359. package/dist/agentic/shared/ai/skills/om-implement-spec/references/spec-resolution.md +0 -24
  360. package/dist/agentic/shared/ai/skills/om-integration-builder/references/package-and-activation.md +0 -16
  361. package/dist/agentic/shared/ai/skills/om-integration-builder/references/provider-families.md +0 -14
  362. package/dist/agentic/shared/ai/skills/om-integration-builder/references/security-and-reliability.md +0 -15
  363. package/dist/agentic/shared/ai/skills/om-integration-builder/references/sync-and-files.md +0 -12
  364. package/dist/agentic/shared/ai/skills/om-judge-agent-session/SKILL.md +0 -34
  365. package/dist/agentic/shared/ai/skills/om-judge-agent-session/agents/openai.yaml +0 -4
  366. package/dist/agentic/shared/ai/skills/om-judge-agent-session/references/agentic-setup.md +0 -11
  367. package/dist/agentic/shared/ai/skills/om-judge-agent-session/references/input-normalization.md +0 -31
  368. package/dist/agentic/shared/ai/skills/om-judge-agent-session/references/judge-workflow.md +0 -39
  369. package/dist/agentic/shared/ai/skills/om-judge-agent-session/references/report-template.md +0 -43
  370. package/dist/agentic/shared/ai/skills/om-judge-agent-session/references/rules.md +0 -11
  371. package/dist/agentic/shared/ai/skills/om-module-scaffold/references/api-and-domain.md +0 -19
  372. package/dist/agentic/shared/ai/skills/om-module-scaffold/references/business-one-shot-blueprints.md +0 -172
  373. package/dist/agentic/shared/ai/skills/om-module-scaffold/references/data-and-migrations.md +0 -12
  374. package/dist/agentic/shared/ai/skills/om-module-scaffold/references/discovery-surface-catalog.md +0 -83
  375. package/dist/agentic/shared/ai/skills/om-module-scaffold/references/module-surfaces.md +0 -21
  376. package/dist/agentic/shared/ai/skills/om-module-scaffold/references/planning.md +0 -11
  377. package/dist/agentic/shared/ai/skills/om-module-scaffold/references/runtime-cache-and-queues.md +0 -22
  378. package/dist/agentic/shared/ai/skills/om-module-scaffold/references/verification.md +0 -13
  379. package/dist/agentic/shared/ai/skills/om-share-this-session/SKILL.md +0 -41
  380. package/dist/agentic/shared/ai/skills/om-share-this-session/references/agentic-setup.md +0 -19
  381. package/dist/agentic/shared/ai/skills/om-share-this-session/references/bundle-preparation.md +0 -44
  382. package/dist/agentic/shared/ai/skills/om-share-this-session/references/consent-and-review.md +0 -39
  383. package/dist/agentic/shared/ai/skills/om-share-this-session/references/publication.md +0 -20
  384. package/dist/agentic/shared/ai/skills/om-share-this-session/references/report-templates.md +0 -57
  385. package/dist/agentic/shared/ai/skills/om-share-this-session/references/rules.md +0 -11
  386. package/dist/agentic/shared/ai/skills/om-share-this-session/scripts/prepare-share-bundle.mjs +0 -486
  387. package/dist/agentic/shared/ai/skills/om-system-extension/references/extension-branches.md +0 -18
  388. package/dist/agentic/shared/ai/skills/om-system-extension/references/mechanism-selector.md +0 -27
  389. package/dist/agentic/shared/ai/skills/om-system-extension/references/read-write-roundtrip.md +0 -13
  390. package/dist/agentic/shared/ai/skills/om-system-extension/references/unified-overrides.md +0 -41
  391. package/dist/agentic/shared/ai/skills/om-system-extension/references/verification.md +0 -11
  392. package/dist/agentic/shared/ai/skills/om-trim-unused-modules/references/dependency-and-redirect.md +0 -15
  393. package/dist/agentic/shared/ai/skills/om-troubleshooter/references/diagnosis-map.md +0 -16
  394. package/dist/agentic/shared/ai/skills/om-troubleshooter/references/regression-oracles.md +0 -14
  395. package/dist/agentic/shared/scripts/agent-harness-tool-server.mjs +0 -187
  396. package/dist/agentic/shared/scripts/check-lessons.mjs +0 -178
  397. package/dist/agentic/shared/scripts/evaluate-agent-harness.mjs +0 -2958
  398. package/dist/agentic/shared/scripts/execution-sandbox.mjs +0 -329
  399. package/dist/agentic/shared/scripts/framework-context.mjs +0 -888
  400. package/dist/agentic/shared/scripts/install-skills.mjs +0 -1029
  401. package/dist/agentic/shared/scripts/prepare-agent-harness-fixture.mjs +0 -222
  402. package/dist/agentic/shared/scripts/run-agent-harness-release.mjs +0 -1774
  403. package/template/jest.setup.ts +0 -29
  404. package/template/scripts/dev-memory-monitor.mjs +0 -92
  405. package/template/scripts/dev-memory-sampler.mjs +0 -464
  406. package/template/scripts/evaluate-agent-harness.mjs +0 -4
  407. package/template/scripts/framework-context.mjs +0 -4
  408. package/template/scripts/install-skills.mjs +0 -10
  409. package/template/scripts/prepare-agent-harness-fixture.mjs +0 -4
  410. package/template/scripts/run-agent-harness-release.mjs +0 -4
  411. package/template/src/components/__tests__/StartPageContent.test.tsx +0 -69
  412. package/template/src/components/__tests__/starter-chrome-ds.test.ts +0 -35
  413. package/template/src/i18n/ko.json +0 -970
  414. package/template/src/modules/example/__integration__/TC-EXAMPLE-001-todo-label-edit.spec.ts +0 -123
  415. package/template/src/modules/example/__integration__/TC-EXAMPLE-002-query-index-failure.spec.ts +0 -155
  416. package/template/src/modules/example/commands/__tests__/todos.prepare-scope.test.ts +0 -77
  417. package/template/src/modules/example/i18n/ko.json +0 -481
  418. package/template/src/modules/example_customers_sync/i18n/ko.json +0 -11
package/README.md CHANGED
@@ -35,8 +35,6 @@ 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 |
40
38
  | `--skip-agentic-setup` | Skip the interactive agentic setup wizard |
41
39
  | `--init-git` | Initialize a local Git repository after scaffolding |
42
40
  | `--no-init-git` | Do not prompt for or initialize a local Git repository |
@@ -66,12 +64,6 @@ npx create-mercato-app my-store --registry http://localhost:4873
66
64
  # Create a new app without the agentic setup wizard
67
65
  npx create-mercato-app my-store --skip-agentic-setup
68
66
 
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
-
75
67
  # Create a new app and initialize a local Git repository
76
68
  npx create-mercato-app my-store --init-git
77
69
  ```
@@ -84,72 +76,8 @@ npx create-mercato-app my-store --init-git
84
76
  - `--skip-agentic-setup` skips only the interactive agentic setup wizard
85
77
  - Imported ready apps are copied as raw source snapshots: the CLI does not rewrite dependency versions, package names, or application source files
86
78
  - 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
88
79
  - Imported ready apps must not contain `.template` files; the scaffold fails closed if template files are found
89
80
 
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 203 routing cases and every writable/review lane, with no per-case fallback. Optionally add the different authenticated runner through `--portability-runner` for the exact 46-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 203-case catalog includes 93 framework-neutral business prompts and 46 writable implementation/regression cases (22.7%). 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
-
153
81
  ## Git And GitHub
154
82
 
155
83
  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,65 +1,121 @@
1
- /** Remind Claude Code to generate and review a schema diff after entity edits. */
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
+
2
13
  import { readdirSync, statSync } from 'node:fs'
3
14
  import { join, relative } from 'node:path'
4
15
 
5
- const ENTITY_PATTERN = /^src\/modules\/([^/]+)\/data\/entities\.ts$/
6
- const MIGRATION_PATTERN = /^src\/modules\/([^/]+)\/migrations\/[^/]+\.ts$/
16
+ const ENTITY_PATTERN = /^src\/modules\/([^/]+)\/entities\/.*\.ts$/
17
+ const MIGRATION_PATTERN = /^src\/modules\/([^/]+)\/migrations\/.*\.ts$/
7
18
 
8
19
  interface PostToolUseInput {
9
- tool_input?: { file_path?: string }
10
- }
11
-
12
- function projectDir(): string {
13
- return process.env.CLAUDE_PROJECT_DIR || process.cwd()
20
+ tool_input?: {
21
+ file_path?: string
22
+ content?: string
23
+ }
24
+ tool_name?: string
14
25
  }
15
26
 
16
- function normalizedRelative(filePath: string): string {
17
- const value = filePath.startsWith('/') ? relative(projectDir(), filePath) : filePath
18
- return value.replaceAll('\\', '/')
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
19
33
  }
20
34
 
21
35
  function hasFreshMigration(moduleId: string): boolean {
22
- const migrationsDir = join(projectDir(), 'src', 'modules', moduleId, 'migrations')
36
+ const projectDir = process.env.CLAUDE_PROJECT_DIR || process.cwd()
37
+ const migrationsDir = join(projectDir, 'src', 'modules', moduleId, 'migrations')
38
+
23
39
  try {
24
- const cutoff = Date.now() - 30_000
25
- return readdirSync(migrationsDir).some((file) =>
26
- file.endsWith('.ts') && statSync(join(migrationsDir, file)).mtimeMs > cutoff,
27
- )
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
+ }
28
51
  } catch {
29
- return false
52
+ // migrations directory doesn't exist yet — that's fine
30
53
  }
54
+
55
+ return false
31
56
  }
32
57
 
33
58
  async function main(): Promise<void> {
34
59
  let input = ''
35
- for await (const chunk of process.stdin) input += chunk
36
- if (!input.trim()) return
60
+ for await (const chunk of process.stdin) {
61
+ input += chunk
62
+ }
63
+
64
+ if (!input.trim()) {
65
+ process.exit(0)
66
+ }
37
67
 
38
68
  let data: PostToolUseInput
39
69
  try {
40
70
  data = JSON.parse(input)
41
71
  } catch {
42
- return
72
+ process.exit(0)
43
73
  }
44
74
 
45
75
  const filePath = data.tool_input?.file_path
46
- if (!filePath) return
47
- const rel = normalizedRelative(filePath)
48
- if (MIGRATION_PATTERN.test(rel)) return
76
+ if (!filePath) {
77
+ process.exit(0)
78
+ }
49
79
 
50
- const match = rel.match(ENTITY_PATTERN)
51
- if (!match || hasFreshMigration(match[1])) return
80
+ const rel = getRelativePath(filePath)
52
81
 
53
- process.stdout.write(JSON.stringify({
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 = {
54
102
  decision: 'block',
55
103
  reason: [
56
- `Entity contract changed: ${rel}`,
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',
57
110
  '',
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.',
111
+ 'Then regenerate registries:',
112
+ ' yarn generate',
113
+ '',
114
+ 'Do NOT run migrations automatically — always confirm with the user first.',
61
115
  ].join('\n'),
62
- }))
116
+ }
117
+
118
+ process.stdout.write(JSON.stringify(result))
63
119
  }
64
120
 
65
- void main()
121
+ main()
@@ -1,6 +1,20 @@
1
1
  <!-- CODEX_ENFORCEMENT_RULES_START -->
2
- ## Codex enforcement
2
+ ## CRITICAL rules — always follow without exception
3
3
 
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.
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
5
11
 
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
+ ---
6
20
  <!-- CODEX_ENFORCEMENT_RULES_END -->
@@ -1,38 +1,69 @@
1
- /** Remind Cursor to generate and review a schema diff after entity edits. */
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
+
2
13
  import { readdirSync, statSync } from 'node:fs'
3
- import { join, relative, resolve } from 'node:path'
14
+ import { join, resolve } from 'node:path'
4
15
 
5
- const ENTITY_RE = /^src\/modules\/([^/]+)\/data\/entities\.ts$/
6
- const MIGRATION_RE = /^src\/modules\/([^/]+)\/migrations\/[^/]+\.ts$/
16
+ const ENTITY_RE = /^src\/modules\/([^/]+)\/entities\/.*\.ts$/
17
+ const MIGRATION_RE = /^src\/modules\/([^/]+)\/migrations\/.*\.ts$/
7
18
 
8
19
  function hasFreshMigration(projectDir, moduleId) {
9
20
  const migrationsDir = join(projectDir, 'src', 'modules', moduleId, 'migrations')
10
21
  try {
22
+ const files = readdirSync(migrationsDir)
11
23
  const cutoff = Date.now() - 30_000
12
- return readdirSync(migrationsDir).some((file) =>
13
- file.endsWith('.ts') && statSync(join(migrationsDir, file)).mtimeMs > cutoff,
14
- )
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
+ }
15
29
  } catch {
16
- return false
30
+ // migrations directory doesn't exist yet
17
31
  }
32
+ return false
18
33
  }
19
34
 
20
35
  const filePath = process.argv[2]
21
36
  if (!filePath) process.exit(0)
22
37
 
23
38
  const projectDir = resolve('.')
24
- const rel = (filePath.startsWith('/') ? relative(projectDir, filePath) : filePath).replaceAll('\\', '/')
39
+ const rel = filePath.startsWith('/') ? filePath.slice(projectDir.length + 1) : filePath
40
+
41
+ // State 1: Migration file written
25
42
  if (MIGRATION_RE.test(rel)) process.exit(0)
26
43
 
44
+ // State 2: Not an entity file
27
45
  const match = rel.match(ENTITY_RE)
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'))
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
+ )
38
69
  process.exit(1)
@@ -1,17 +1,29 @@
1
1
  ---
2
- description: Entity schema-diff guard for the canonical standalone entity file
2
+ description: Entity modification guard — triggers migration workflow
3
3
  globs:
4
- - src/modules/*/data/entities.ts
4
+ - src/modules/*/entities/**/*.ts
5
5
  alwaysApply: false
6
6
  ---
7
7
 
8
- # Entity Schema Change
8
+ # Entity Modification — Migration Required
9
9
 
10
- Follow root `AGENTS.md` and `om-data-model-design`:
10
+ You are editing an entity file. After saving, you MUST:
11
11
 
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`.
12
+ 1. **Create a migration** — ask the user before running:
13
+ ```
14
+ yarn db:generate
15
+ ```
16
16
 
17
- Never edit a shipped migration or generated registry.
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.
@@ -1,10 +1,12 @@
1
1
  ---
2
- description: Prevent edits to generated application registries
2
+ description: Prevent editing auto-generated files
3
3
  globs:
4
4
  - .mercato/generated/**
5
5
  alwaysApply: false
6
6
  ---
7
7
 
8
- # Generated File
8
+ # NEVER Edit Generated Files
9
9
 
10
- Do not edit this file. Change the app module source and run `yarn generate`; follow root `AGENTS.md` for the routed contract.
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`.
@@ -1,8 +1,34 @@
1
1
  ---
2
- description: Route every standalone app task through the root agent rules
2
+ description: Core Open Mercato conventions for standalone app development
3
3
  alwaysApply: true
4
4
  ---
5
5
 
6
- # {{PROJECT_NAME}} — Cursor Entry Point
6
+ # {{PROJECT_NAME}} — Project Rules
7
7
 
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.
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.
@@ -1,15 +1,130 @@
1
- # Module System Compatibility Router
1
+ # Open Mercato Module System — Conceptual Guide
2
2
 
3
- Use the concern guides below. This path remains only so older prompts and links do not load a stale module tutorial.
3
+ This is the **hand-written, conceptual** layer of the module guides. It explains how an Open Mercato module is structured and how to build or extend one — the timeless concepts that rarely change. It is framework-wide; it does **not** describe any single module's data.
4
4
 
5
- | When you need | Load |
5
+ ## How the guides are layered
6
+
7
+ - **Layer 1 — this file (`.ai/guides/module-system.md`):** conceptual and framework-wide. Module anatomy, auto-discovery, naming, the mandatory mechanisms, data-integrity rules, and the generate/migration workflow.
8
+ - **Layer 2 — generated per-module fact-sheets (`.ai/guides/modules/<module>.md` + `.ai/guides/module-facts.json`):** the concrete **facts** for one module, extracted from its source — entity IDs, events, ACL features, API routes with per-method auth, DI service tokens, searchable entities, host extension tokens, notifications, and CLI commands. These are generated; never hand-write them here.
9
+ - **Package guides (`.ai/guides/core.md`, `ui.md`, `shared.md`, …):** package-specific depth (patterns, helpers, deeper APIs).
10
+
11
+ When you need a concrete fact about a specific module — which events it emits, its entity IDs, which feature gates a route — open that module's fact-sheet. Do not infer module facts from this conceptual guide.
12
+
13
+ ## Module anatomy
14
+
15
+ Each module lives in `src/modules/<id>/` and is **auto-discovered**. The only registration is one entry in `src/modules.ts` (`{ id: '<id>', from: '@app' }`). Run `yarn generate` after adding or changing any auto-discovered file.
16
+
17
+ ```
18
+ src/modules/<id>/
19
+ ├── index.ts # Module metadata
20
+ ├── data/
21
+ │ ├── entities.ts # MikroORM entity classes (decorators from @mikro-orm/decorators/legacy)
22
+ │ ├── validators.ts # Zod validation schemas
23
+ │ ├── extensions.ts # Cross-module entity links (export `extensions`)
24
+ │ └── enrichers.ts # Response enrichers (export `enrichers`)
25
+ ├── api/
26
+ │ ├── <resource>/route.ts # REST handlers (auto-discovered by method) + `metadata` + `openApi`
27
+ │ └── interceptors.ts # API route interception hooks (export `interceptors`)
28
+ ├── backend/ # Admin UI pages (auto-discovered) + paired `page.meta.ts`
29
+ ├── frontend/ # Public pages (auto-discovered); customer portal under `[orgSlug]/portal/`
30
+ ├── subscribers/ # Event handlers (export `metadata` + default handler)
31
+ ├── workers/ # Background jobs (export `metadata` + default handler)
32
+ ├── widgets/
33
+ │ ├── injection/ # UI widgets injected into other modules
34
+ │ ├── injection-table.ts # Widget-to-slot mappings
35
+ │ └── components.ts # Component replacement/wrapper definitions (export `componentOverrides`)
36
+ ├── di.ts # Awilix DI registrations (export `register(container)`)
37
+ ├── acl.ts # Permission features (export `features`)
38
+ ├── setup.ts # Tenant init, role features, seed data (export `setup`)
39
+ ├── events.ts # Typed event declarations (export `eventsConfig`)
40
+ ├── search.ts # Search indexing configuration (export `searchConfig`)
41
+ ├── ce.ts # Custom entities / custom field sets (export `entities`)
42
+ ├── translations.ts # Translatable fields per entity
43
+ ├── notifications.ts # Notification type definitions (export `notificationTypes`)
44
+ └── encryption.ts # Tenant data encryption maps for sensitive / GDPR fields
45
+ ```
46
+
47
+ ### Auto-discovery paths
48
+
49
+ | Path pattern | Becomes |
50
+ |---|---|
51
+ | `frontend/<path>.tsx` | `/<path>` (public page) |
52
+ | `frontend/[orgSlug]/portal/<path>/page.tsx` | `/{orgSlug}/portal/<path>` (customer portal page; `[orgSlug]` MUST be first) |
53
+ | `backend/<path>.tsx` | `/backend/<path>` (admin page) |
54
+ | `backend/page.tsx` | `/backend/<module>` (module root page) |
55
+ | `api/<method>/<path>.ts` | `/api/<path>` dispatched by HTTP method |
56
+ | `subscribers/*.ts` | event subscriber (export `metadata` + default handler) |
57
+ | `workers/*.ts` | background worker (export `metadata` + default handler) |
58
+
59
+ ### Convention-file reference
60
+
61
+ | File | Export | Purpose |
62
+ |------|--------|---------|
63
+ | `index.ts` | `metadata` | Module metadata |
64
+ | `di.ts` | `register(container)` | DI registrations (Awilix) |
65
+ | `acl.ts` | `features` | Permission features (`['mod.view', 'mod.manage', …]`) |
66
+ | `setup.ts` | `setup` | Tenant init, default role features, seed data |
67
+ | `ce.ts` | `entities` | Custom entities / custom field sets |
68
+ | `events.ts` | `eventsConfig` | Typed event declarations (`createModuleEvents`) |
69
+ | `search.ts` | `searchConfig` | Search indexing config |
70
+ | `translations.ts` | `translatableFields` | Translatable fields per entity |
71
+ | `notifications.ts` | `notificationTypes` | Notification type definitions |
72
+ | `data/entities.ts` | — | MikroORM entity classes |
73
+ | `data/validators.ts` | — | Zod validation schemas |
74
+ | `data/extensions.ts` | `extensions` | Entity extensions (cross-module links) |
75
+ | `data/enrichers.ts` | `enrichers` | Response enrichers |
76
+ | `api/interceptors.ts` | `interceptors` | API route interception hooks |
77
+ | `widgets/components.ts` | `componentOverrides` | Component replacement/wrapper definitions |
78
+
79
+ ## Naming conventions
80
+
81
+ - **Module IDs:** plural, snake_case (`order_items`). Special cases: `auth`, `example`.
82
+ - **Event IDs:** `module.entity.action` (singular entity, past-tense action, e.g. `sales.order.created`).
83
+ - **Entity IDs:** colon form `module:entity` (e.g. `customers:customer_person_profile`) — the canonical interop token, **not** the raw class name and **not** the dotted friendly alias some enrichers use.
84
+ - **DB tables:** plural, snake_case with a module prefix (`catalog_products`).
85
+ - **DB columns:** snake_case (`created_at`, `organization_id`). Common columns: `id`, `created_at`, `updated_at`, `deleted_at`, `is_active`, `organization_id`, `tenant_id`.
86
+ - **Feature IDs:** `<module>.<action>` (`my_module.view`, `my_module.manage`). FROZEN once shipped — rename by adding the new ID alongside and keeping the old as a deprecated alias.
87
+ - **JS/TS identifiers:** camelCase. UUID primary keys, explicit foreign keys, junction tables for M2M.
88
+
89
+ ## Mandatory module mechanisms
90
+
91
+ The framework provides **one canonical primitive per concern**. Do not invent your own routing, auth, persistence, forms, caching, or cross-module calls. If a feature is not listed here, ask before rolling your own.
92
+
93
+ | Concern | Canonical mechanism |
6
94
  |---|---|
7
- | Module ownership, layout, discovery, registration, or installed source | `.ai/guides/architecture.md` |
8
- | Entities, CRUD/API, commands, scoping, ACL, setup, events, workers, search, cache, or migrations | `.ai/guides/contracts.md` |
9
- | Forms, tables, pages, navigation, portal, translations, or design-system behavior | `.ai/guides/backend-ui.md` |
10
- | Enrichers, interceptors, guards, widgets, extensions, menus, replacements, or overrides | `.ai/guides/extensions.md` |
11
- | Provider packages, data sync, webhooks, import/export, shipping, payment, or email | `.ai/guides/integrations.md` |
12
- | AI agents/tools/orchestrators or workflows | `.ai/guides/ai-workflows.md` |
13
- | Diagnosis and regression verification | `.ai/guides/testing-debugging.md` |
14
-
15
- For a complete new module, invoke `om-module-scaffold`; it loads the relevant branches. For a concrete installed-module fact, read its generated `.ai/guides/modules/<id>.md` first. Invoke `om-framework-context` only when generated facts cannot answer the implementation question.
95
+ | Module structure & auto-discovery | `src/modules/<id>/{api,backend,frontend,data,subscribers,workers,widgets}` + `index.ts` + one line in `src/modules.ts` — discovered by `yarn generate` |
96
+ | API routes | Files under `api/**/route.ts` exporting handlers + per-method `metadata` (`requireAuth` / `requireFeatures`) + `openApi`. NEVER a top-level `export const requireAuth` — the registry ignores it |
97
+ | CRUD APIs | `makeCrudRoute({ orm, list, create, update, del, indexer })` from `@open-mercato/shared/lib/crud/factory`. Always set `indexer` for query-index coverage. Custom (non-factory) write routes MUST run the mutation guard registry (`runMutationGuards`) |
98
+ | CRUD forms | `<CrudForm />` from `@open-mercato/ui/backend/CrudForm` + `createCrud`/`updateCrud`/`deleteCrud`. Never raw `<form>`, never raw `fetch` |
99
+ | Data tables | `<DataTable entityId apiPath … />` from `@open-mercato/ui/backend/DataTable`. Keep `entityId` / `extensionTableId` stable so widget injection keeps working |
100
+ | HTTP from the client | `apiCall` / `apiCallOrThrow` from `@open-mercato/ui/backend/utils/apiCall` — never raw `fetch` |
101
+ | Authorization (RBAC) | Declare features in `acl.ts`, grant in `setup.ts` `defaultRoleFeatures`, gate with `requireFeatures` in `metadata` / `page.meta.ts`. NEVER `requireRoles` (role names mutate). Treat `module.*` / `*` wildcard grants as part of the contract |
102
+ | Multi-tenant scoping | Every tenant-scoped entity has indexed `organization_id` + `tenant_id`; every read/write filters by them. The CRUD factory injects scope — do not bypass it. Ad-hoc queries use `withScopedPayload` |
103
+ | Encryption for sensitive data | Declare `encryption.ts` `defaultEncryptionMaps`; read via `findWithDecryption` / `findOneWithDecryption`. NEVER hand-roll AES/KMS, NEVER `em.find` on encrypted columns |
104
+ | Cache | Resolve from DI (`container.resolve('cache')`) — never `new Redis(...)`. Tag with `tenant:<id>` / `org:<id>` so invalidation stays tenant-scoped |
105
+ | Background workers | `workers/*.ts` exporting `metadata: { queue, id?, concurrency? }` + default handler. Never spin up custom queues |
106
+ | Events between modules | `events.ts` with `createModuleEvents({ moduleId, events } as const)`; subscribe in `subscribers/`. Never call another module's services directly across boundaries |
107
+ | Domain writes | Implement through the Command pattern so audit, undo, cache, events, and indexing stay consistent — do not mutate domain state directly in route handlers |
108
+ | i18n | `useT()` client-side, `resolveTranslations()` server-side; keys in `src/i18n/<locale>.json`. Never hard-code user-facing strings |
109
+
110
+ > Rule of thumb: if you reach for raw `fetch`, raw `<form>`, ad-hoc `crypto`, ad-hoc `Redis`, or a manual cross-module join, stop and check the row above — there is a canonical helper.
111
+
112
+ ## Entity-update safety & data integrity
113
+
114
+ - **`withAtomicFlush`.** MikroORM can silently discard pending scalar changes when a query (`em.find`/`em.findOne`/sync helper) runs on the same `EntityManager` between a scalar mutation and `em.flush()`. Multi-phase mutations MUST use `withAtomicFlush(em, phases, { transaction: true })` from `@open-mercato/shared/lib/commands/flush`. Keep `emitCrudSideEffects` and cache invalidation **outside** the block — they fire only after the DB write commits. For entity + custom fields + side effects in one write, prefer `runCrudCommandWrite`.
115
+ - **Optimistic locking (default ON).** Every **new user-editable entity** MUST carry an `updated_at` column and return `updatedAt` in its list/detail responses, so the OSS optimistic lock can detect concurrent edits. `CrudForm` auto-derives the lock header from `initialValues.updatedAt` (covers update and delete). Append-only logs, junction/assignment tables, session/token rows, and parent-guarded sub-resource lines are exempt.
116
+ - **Encryption.** Sensitive / GDPR fields go through the encryption-maps mechanism (`encryption.ts` + `findWithDecryption`), never hand-rolled crypto. Always pass `tenantId` and `organizationId` to the decryption helpers.
117
+ - **Tenant isolation.** Never expose cross-tenant data; always filter by `organization_id` (and `tenant_id`). Never create direct ORM relationships between modules — reference by FK id and fetch separately.
118
+
119
+ ## Generate & migration workflow
120
+
121
+ - **After editing `src/modules.ts` or any structural module file:** run `yarn generate`. Never hand-edit anything under `.mercato/generated/*`.
122
+ - **After editing `data/entities.ts`:** run `yarn db:generate` as a schema-diff probe. Default to the generated SQL; if it emits unrelated churn from another module's stale snapshot, keep only the SQL for your change and update that module's `migrations/.snapshot-open-mercato.json` in the same commit.
123
+ - **Do not run `yarn db:migrate`** unless the user explicitly asks. A PR should normally include the migration file plus snapshot, not local DB state. Never hand-edit a migration that has already shipped — add a new one.
124
+ - **New ACL features must be visible immediately:** add the feature to `acl.ts` **and** to `setup.ts` `defaultRoleFeatures`, then run `yarn mercato auth sync-role-acls` so existing tenants pick it up.
125
+
126
+ ## Where to go next
127
+
128
+ - A specific module's surface (entities, events, routes, auth, search, CLI): its **fact-sheet** at `.ai/guides/modules/<module>.md`.
129
+ - Deeper package patterns: the matching **package guide** (`core.md`, `ui.md`, `shared.md`, `events.md`, `queue.md`, `cache.md`, `search.md`).
130
+ - Scaffolding a module end-to-end: the `om-module-scaffold` skill.