@open-mercato/cli 0.10.1-develop.8227.1.33f80330f2 → 0.10.1-develop.8230.1.29770a5cd8

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 (101) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/dist/agentic/guides/module-facts.json +162 -162
  3. package/dist/agentic/guides/module-facts.v2.json +162 -162
  4. package/dist/agentic/guides/modules/agent_orchestrator/index.md +1 -1
  5. package/dist/agentic/guides/modules/ai_assistant/index.md +1 -1
  6. package/dist/agentic/guides/modules/api_docs/index.md +1 -1
  7. package/dist/agentic/guides/modules/api_keys/index.md +1 -1
  8. package/dist/agentic/guides/modules/attachments/index.md +1 -1
  9. package/dist/agentic/guides/modules/audit_logs/index.md +1 -1
  10. package/dist/agentic/guides/modules/auth/index.md +1 -1
  11. package/dist/agentic/guides/modules/availability/index.md +1 -1
  12. package/dist/agentic/guides/modules/business_rules/index.md +1 -1
  13. package/dist/agentic/guides/modules/carrier_inpost/index.md +1 -1
  14. package/dist/agentic/guides/modules/cart/index.md +1 -1
  15. package/dist/agentic/guides/modules/catalog/index.md +1 -1
  16. package/dist/agentic/guides/modules/channel_apns/index.md +1 -1
  17. package/dist/agentic/guides/modules/channel_discord/index.md +1 -1
  18. package/dist/agentic/guides/modules/channel_expo/index.md +1 -1
  19. package/dist/agentic/guides/modules/channel_fcm/index.md +1 -1
  20. package/dist/agentic/guides/modules/channel_gmail/index.md +1 -1
  21. package/dist/agentic/guides/modules/channel_imap/index.md +1 -1
  22. package/dist/agentic/guides/modules/channel_resend/index.md +1 -1
  23. package/dist/agentic/guides/modules/channel_ses/index.md +1 -1
  24. package/dist/agentic/guides/modules/channel_smtp/index.md +1 -1
  25. package/dist/agentic/guides/modules/checkout/index.md +1 -1
  26. package/dist/agentic/guides/modules/communication_channels/index.md +1 -1
  27. package/dist/agentic/guides/modules/configs/index.md +1 -1
  28. package/dist/agentic/guides/modules/content/index.md +1 -1
  29. package/dist/agentic/guides/modules/currencies/index.md +1 -1
  30. package/dist/agentic/guides/modules/customer_accounts/index.md +1 -1
  31. package/dist/agentic/guides/modules/customer_groups/index.md +1 -1
  32. package/dist/agentic/guides/modules/customers/index.md +1 -1
  33. package/dist/agentic/guides/modules/dashboards/index.md +1 -1
  34. package/dist/agentic/guides/modules/data_sync/index.md +1 -1
  35. package/dist/agentic/guides/modules/design_system/index.md +1 -1
  36. package/dist/agentic/guides/modules/devices/index.md +1 -1
  37. package/dist/agentic/guides/modules/dictionaries/index.md +1 -1
  38. package/dist/agentic/guides/modules/directory/index.md +1 -1
  39. package/dist/agentic/guides/modules/documents/index.md +1 -1
  40. package/dist/agentic/guides/modules/ecommerce/index.md +1 -1
  41. package/dist/agentic/guides/modules/entities/index.md +1 -1
  42. package/dist/agentic/guides/modules/eudr/index.md +1 -1
  43. package/dist/agentic/guides/modules/events/index.md +1 -1
  44. package/dist/agentic/guides/modules/feature_toggles/index.md +1 -1
  45. package/dist/agentic/guides/modules/forms/index.md +1 -1
  46. package/dist/agentic/guides/modules/gateway_autopay/index.md +1 -1
  47. package/dist/agentic/guides/modules/gateway_stripe/index.md +1 -1
  48. package/dist/agentic/guides/modules/gateway_tpay/index.md +1 -1
  49. package/dist/agentic/guides/modules/generators/index.md +1 -1
  50. package/dist/agentic/guides/modules/inbox_ops/index.md +1 -1
  51. package/dist/agentic/guides/modules/integrations/index.md +1 -1
  52. package/dist/agentic/guides/modules/messages/index.md +1 -1
  53. package/dist/agentic/guides/modules/notifications/index.md +1 -1
  54. package/dist/agentic/guides/modules/onboarding/index.md +1 -1
  55. package/dist/agentic/guides/modules/payment_gateways/index.md +1 -1
  56. package/dist/agentic/guides/modules/perspectives/index.md +1 -1
  57. package/dist/agentic/guides/modules/phone_calls/index.md +1 -1
  58. package/dist/agentic/guides/modules/planner/index.md +1 -1
  59. package/dist/agentic/guides/modules/portal/index.md +1 -1
  60. package/dist/agentic/guides/modules/progress/index.md +1 -1
  61. package/dist/agentic/guides/modules/promotions/index.md +1 -1
  62. package/dist/agentic/guides/modules/push_notifications/index.md +1 -1
  63. package/dist/agentic/guides/modules/query_index/index.md +1 -1
  64. package/dist/agentic/guides/modules/record_locks/index.md +1 -1
  65. package/dist/agentic/guides/modules/resources/index.md +1 -1
  66. package/dist/agentic/guides/modules/sales/index.md +1 -1
  67. package/dist/agentic/guides/modules/scheduler/index.md +1 -1
  68. package/dist/agentic/guides/modules/search/index.md +1 -1
  69. package/dist/agentic/guides/modules/security/index.md +1 -1
  70. package/dist/agentic/guides/modules/seeds/index.md +1 -1
  71. package/dist/agentic/guides/modules/shipping_carriers/index.md +1 -1
  72. package/dist/agentic/guides/modules/sso/index.md +1 -1
  73. package/dist/agentic/guides/modules/staff/index.md +1 -1
  74. package/dist/agentic/guides/modules/storage_s3/index.md +1 -1
  75. package/dist/agentic/guides/modules/sync_akeneo/index.md +1 -1
  76. package/dist/agentic/guides/modules/sync_excel/index.md +1 -1
  77. package/dist/agentic/guides/modules/system_status_overlays/index.md +1 -1
  78. package/dist/agentic/guides/modules/telemetry/index.md +1 -1
  79. package/dist/agentic/guides/modules/tillio/index.md +1 -1
  80. package/dist/agentic/guides/modules/translations/index.md +1 -1
  81. package/dist/agentic/guides/modules/warranty_claims/index.md +1 -1
  82. package/dist/agentic/guides/modules/webhooks/index.md +1 -1
  83. package/dist/agentic/guides/modules/wms/index.md +1 -1
  84. package/dist/agentic/guides/modules/workflows/index.md +1 -1
  85. package/dist/agentic/guides/reference-module-facts.json +1 -1
  86. package/dist/agentic/guides/upstream/BACKWARD_COMPATIBILITY.md +4 -0
  87. package/dist/agentic/guides/upstream/manifest.json +2 -2
  88. package/dist/lib/generate-child-process.js +23 -0
  89. package/dist/lib/generate-child-process.js.map +7 -0
  90. package/dist/lib/in-process-generate-watcher.js +11 -5
  91. package/dist/lib/in-process-generate-watcher.js.map +2 -2
  92. package/dist/mercato.js +39 -22
  93. package/dist/mercato.js.map +3 -3
  94. package/package.json +7 -7
  95. package/src/__tests__/mercato.test.ts +12 -0
  96. package/src/lib/__tests__/generate-child-process.test.ts +185 -0
  97. package/src/lib/__tests__/generate-quiet-entrypoint.test.ts +47 -0
  98. package/src/lib/__tests__/in-process-generate-watcher.test.ts +91 -0
  99. package/src/lib/generate-child-process.ts +35 -0
  100. package/src/lib/in-process-generate-watcher.ts +14 -6
  101. package/src/mercato.ts +45 -31
@@ -1,5 +1,5 @@
1
1
  # staff — module facts (generated, do not edit)
2
- <!-- generated from @open-mercato/core 0.10.1-develop.8227.1.33f80330f2; core 0.10.1-develop.8227.1.33f80330f2 — R1 staleness stamp -->
2
+ <!-- generated from @open-mercato/core 0.10.1-develop.8230.1.29770a5cd8; core 0.10.1-develop.8230.1.29770a5cd8 — R1 staleness stamp -->
3
3
  Source root: node_modules/@open-mercato/core/src/modules/staff
4
4
 
5
5
  ## Sections
@@ -1,5 +1,5 @@
1
1
  # storage_s3 — module facts (generated, do not edit)
2
- <!-- generated from @open-mercato/storage-s3 0.10.1-develop.8227.1.33f80330f2; core 0.10.1-develop.8227.1.33f80330f2 — R1 staleness stamp -->
2
+ <!-- generated from @open-mercato/storage-s3 0.10.1-develop.8230.1.29770a5cd8; core 0.10.1-develop.8230.1.29770a5cd8 — R1 staleness stamp -->
3
3
  Source root: node_modules/@open-mercato/storage-s3/src/modules/storage_s3
4
4
 
5
5
  ## Sections
@@ -1,5 +1,5 @@
1
1
  # sync_akeneo — module facts (generated, do not edit)
2
- <!-- generated from @open-mercato/sync-akeneo 0.10.1-develop.8227.1.33f80330f2; core 0.10.1-develop.8227.1.33f80330f2 — R1 staleness stamp -->
2
+ <!-- generated from @open-mercato/sync-akeneo 0.10.1-develop.8230.1.29770a5cd8; core 0.10.1-develop.8230.1.29770a5cd8 — R1 staleness stamp -->
3
3
  Source root: node_modules/@open-mercato/sync-akeneo/src/modules/sync_akeneo
4
4
 
5
5
  ## Sections
@@ -1,5 +1,5 @@
1
1
  # sync_excel — module facts (generated, do not edit)
2
- <!-- generated from @open-mercato/core 0.10.1-develop.8227.1.33f80330f2; core 0.10.1-develop.8227.1.33f80330f2 — R1 staleness stamp -->
2
+ <!-- generated from @open-mercato/core 0.10.1-develop.8230.1.29770a5cd8; core 0.10.1-develop.8230.1.29770a5cd8 — R1 staleness stamp -->
3
3
  Source root: node_modules/@open-mercato/core/src/modules/sync_excel
4
4
 
5
5
  ## Sections
@@ -1,5 +1,5 @@
1
1
  # system_status_overlays — module facts (generated, do not edit)
2
- <!-- generated from @open-mercato/enterprise 0.10.1-develop.8227.1.33f80330f2; core 0.10.1-develop.8227.1.33f80330f2 — R1 staleness stamp -->
2
+ <!-- generated from @open-mercato/enterprise 0.10.1-develop.8230.1.29770a5cd8; core 0.10.1-develop.8230.1.29770a5cd8 — R1 staleness stamp -->
3
3
  Source root: node_modules/@open-mercato/enterprise/src/modules/system_status_overlays
4
4
 
5
5
  ## Sections
@@ -1,5 +1,5 @@
1
1
  # telemetry — module facts (generated, do not edit)
2
- <!-- generated from @open-mercato/telemetry 0.10.1-develop.8227.1.33f80330f2; core 0.10.1-develop.8227.1.33f80330f2 — R1 staleness stamp -->
2
+ <!-- generated from @open-mercato/telemetry 0.10.1-develop.8230.1.29770a5cd8; core 0.10.1-develop.8230.1.29770a5cd8 — R1 staleness stamp -->
3
3
  Source root: node_modules/@open-mercato/telemetry/src/modules/telemetry
4
4
 
5
5
  ## Sections
@@ -1,5 +1,5 @@
1
1
  # tillio — module facts (generated, do not edit)
2
- <!-- generated from @open-mercato/tillio 0.10.1-develop.8227.1.33f80330f2; core 0.10.1-develop.8227.1.33f80330f2 — R1 staleness stamp -->
2
+ <!-- generated from @open-mercato/tillio 0.10.1-develop.8230.1.29770a5cd8; core 0.10.1-develop.8230.1.29770a5cd8 — R1 staleness stamp -->
3
3
  Source root: node_modules/@open-mercato/tillio/src/modules/tillio
4
4
 
5
5
  ## Sections
@@ -1,5 +1,5 @@
1
1
  # translations — module facts (generated, do not edit)
2
- <!-- generated from @open-mercato/core 0.10.1-develop.8227.1.33f80330f2; core 0.10.1-develop.8227.1.33f80330f2 — R1 staleness stamp -->
2
+ <!-- generated from @open-mercato/core 0.10.1-develop.8230.1.29770a5cd8; core 0.10.1-develop.8230.1.29770a5cd8 — R1 staleness stamp -->
3
3
  Source root: node_modules/@open-mercato/core/src/modules/translations
4
4
 
5
5
  ## Sections
@@ -1,5 +1,5 @@
1
1
  # warranty_claims — module facts (generated, do not edit)
2
- <!-- generated from @open-mercato/core 0.10.1-develop.8227.1.33f80330f2; core 0.10.1-develop.8227.1.33f80330f2 — R1 staleness stamp -->
2
+ <!-- generated from @open-mercato/core 0.10.1-develop.8230.1.29770a5cd8; core 0.10.1-develop.8230.1.29770a5cd8 — R1 staleness stamp -->
3
3
  Source root: node_modules/@open-mercato/core/src/modules/warranty_claims
4
4
 
5
5
  ## Sections
@@ -1,5 +1,5 @@
1
1
  # webhooks — module facts (generated, do not edit)
2
- <!-- generated from @open-mercato/webhooks 0.10.1-develop.8227.1.33f80330f2; core 0.10.1-develop.8227.1.33f80330f2 — R1 staleness stamp -->
2
+ <!-- generated from @open-mercato/webhooks 0.10.1-develop.8230.1.29770a5cd8; core 0.10.1-develop.8230.1.29770a5cd8 — R1 staleness stamp -->
3
3
  Source root: node_modules/@open-mercato/webhooks/src/modules/webhooks
4
4
 
5
5
  ## Sections
@@ -1,5 +1,5 @@
1
1
  # wms — module facts (generated, do not edit)
2
- <!-- generated from @open-mercato/core 0.10.1-develop.8227.1.33f80330f2; core 0.10.1-develop.8227.1.33f80330f2 — R1 staleness stamp -->
2
+ <!-- generated from @open-mercato/core 0.10.1-develop.8230.1.29770a5cd8; core 0.10.1-develop.8230.1.29770a5cd8 — R1 staleness stamp -->
3
3
  Source root: node_modules/@open-mercato/core/src/modules/wms
4
4
 
5
5
  ## Sections
@@ -1,5 +1,5 @@
1
1
  # workflows — module facts (generated, do not edit)
2
- <!-- generated from @open-mercato/core 0.10.1-develop.8227.1.33f80330f2; core 0.10.1-develop.8227.1.33f80330f2 — R1 staleness stamp -->
2
+ <!-- generated from @open-mercato/core 0.10.1-develop.8230.1.29770a5cd8; core 0.10.1-develop.8230.1.29770a5cd8 — R1 staleness stamp -->
3
3
  Source root: node_modules/@open-mercato/core/src/modules/workflows
4
4
 
5
5
  ## Sections
@@ -1185,7 +1185,7 @@
1185
1185
  "facts": {
1186
1186
  "title": "Example Module",
1187
1187
  "description": "Demonstrates pages, APIs, entities and DI.",
1188
- "coreVersion": "0.10.1-develop.8227.1.33f80330f2",
1188
+ "coreVersion": "0.10.1-develop.8230.1.29770a5cd8",
1189
1189
  "sourcePackage": null,
1190
1190
  "sourceVersion": null,
1191
1191
  "sourceRoot": "src/modules/example",
@@ -631,6 +631,10 @@ STABLE tools/execute writes bypass approval; no bridge. [Migrate](UPGRADE_NOTES.
631
631
 
632
632
  SCIM adds 429/503 before credentials; honor Retry-After. Optional `beforeAuth: ApiRouteBeforeAuth` is additive. See [contract and migration](.ai/specs/enterprise/implemented/SPEC-ENT-004-2026-02-19-sso-directory-sync.md#migration--backward-compatibility).
633
633
 
634
+ ## Encrypted search contexts (#7872)
635
+
636
+ STABLE: encrypted custom fields are omitted; missing/failing resolver excludes all. A bridge preserves disclosure; human exception approval is pending. [Contract/migration](.ai/specs/2026-10-30-search-build-context-encrypted-custom-fields.md).
637
+
634
638
  ## Compose encryption (2026-11-01, #7231)
635
639
 
636
640
  STABLE: unsafe keys/HTTP Vault rejected; bridges retain exposure. [Migration](UPGRADE_NOTES.md).
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "version": 1,
3
- "generator": "@open-mercato/cli@0.10.1-develop.8227.1.33f80330f2",
3
+ "generator": "@open-mercato/cli@0.10.1-develop.8230.1.29770a5cd8",
4
4
  "files": {
5
5
  "AGENTS.md": "35c948a32e06ca64b4706970c55ec60946412b410938b22478233a2c5c43df56",
6
- "BACKWARD_COMPATIBILITY.md": "f90cf78c940d9cbb6e945f9845f9880bf77f756fcbafc40ac4d24080cfd7b32a"
6
+ "BACKWARD_COMPATIBILITY.md": "cff7b28bb7a71cc446f9f12e5f1534b6573aa7984ac8b8a20e2084ea1265038a"
7
7
  }
8
8
  }
@@ -0,0 +1,23 @@
1
+ import { spawn } from "node:child_process";
2
+ async function runGenerateChildProcess(options) {
3
+ const args = [options.mercatoBin, "generate", "all"];
4
+ if (options.quiet) args.push("--quiet");
5
+ await new Promise((resolve, reject) => {
6
+ const child = spawn(process.execPath, args, {
7
+ cwd: options.cwd,
8
+ env: options.env ?? process.env,
9
+ stdio: ["ignore", "inherit", "inherit"]
10
+ });
11
+ child.once("error", reject);
12
+ child.once("close", (code, signal) => {
13
+ if (code === 0) resolve();
14
+ else reject(new Error(
15
+ signal ? `Generator process terminated by ${signal}` : `Generator process exited with code ${code ?? "unknown"}`
16
+ ));
17
+ });
18
+ });
19
+ }
20
+ export {
21
+ runGenerateChildProcess
22
+ };
23
+ //# sourceMappingURL=generate-child-process.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/lib/generate-child-process.ts"],
4
+ "sourcesContent": ["import { spawn } from 'node:child_process'\n\n/**\n * Evaluate application modules in a disposable process, never in the watcher.\n * Native ESM keeps every cache-busted module revision until its process exits;\n * a fresh process also observes edits to unchanged modules' imported dependencies.\n */\nexport async function runGenerateChildProcess(options: {\n mercatoBin: string\n cwd: string\n env?: NodeJS.ProcessEnv\n quiet?: boolean\n}): Promise<void> {\n const args = [options.mercatoBin, 'generate', 'all']\n if (options.quiet) args.push('--quiet')\n\n await new Promise<void>((resolve, reject) => {\n const child = spawn(process.execPath, args, {\n cwd: options.cwd,\n env: options.env ?? process.env,\n stdio: ['ignore', 'inherit', 'inherit'],\n })\n child.once('error', reject)\n // Wait for close, not just exit: generation and inherited stream cleanup\n // must finish before another cycle or supervisor restart can proceed.\n child.once('close', (code, signal) => {\n if (code === 0) resolve()\n else reject(new Error(\n signal\n ? `Generator process terminated by ${signal}`\n : `Generator process exited with code ${code ?? 'unknown'}`,\n ))\n })\n })\n}\n"],
5
+ "mappings": "AAAA,SAAS,aAAa;AAOtB,eAAsB,wBAAwB,SAK5B;AAChB,QAAM,OAAO,CAAC,QAAQ,YAAY,YAAY,KAAK;AACnD,MAAI,QAAQ,MAAO,MAAK,KAAK,SAAS;AAEtC,QAAM,IAAI,QAAc,CAAC,SAAS,WAAW;AAC3C,UAAM,QAAQ,MAAM,QAAQ,UAAU,MAAM;AAAA,MAC1C,KAAK,QAAQ;AAAA,MACb,KAAK,QAAQ,OAAO,QAAQ;AAAA,MAC5B,OAAO,CAAC,UAAU,WAAW,SAAS;AAAA,IACxC,CAAC;AACD,UAAM,KAAK,SAAS,MAAM;AAG1B,UAAM,KAAK,SAAS,CAAC,MAAM,WAAW;AACpC,UAAI,SAAS,EAAG,SAAQ;AAAA,UACnB,QAAO,IAAI;AAAA,QACd,SACI,mCAAmC,MAAM,KACzC,sCAAsC,QAAQ,SAAS;AAAA,MAC7D,CAAC;AAAA,IACH,CAAC;AAAA,EACH,CAAC;AACH;",
6
+ "names": []
7
+ }
@@ -13,6 +13,7 @@ function startInProcessGenerateWatcher(options) {
13
13
  const { changeSignal, computeStructureChecksum, runGenerators } = options;
14
14
  let stopping = false;
15
15
  let pollTimer = null;
16
+ let activeCycle = null;
16
17
  let running = false;
17
18
  let pendingReason = null;
18
19
  let previousChecksum = "";
@@ -22,6 +23,7 @@ function startInProcessGenerateWatcher(options) {
22
23
  doneResolve = resolve;
23
24
  });
24
25
  async function runOnce(reason) {
26
+ if (stopping) return;
25
27
  if (running) {
26
28
  pendingReason = reason;
27
29
  return;
@@ -50,7 +52,7 @@ function startInProcessGenerateWatcher(options) {
50
52
  function scheduleNext() {
51
53
  if (stopping) return;
52
54
  pollTimer = setTimeout(() => {
53
- void (async () => {
55
+ activeCycle = (async () => {
54
56
  if (stopping) return;
55
57
  try {
56
58
  const changeVersion = changeSignal?.currentVersion() ?? 0;
@@ -83,13 +85,15 @@ function startInProcessGenerateWatcher(options) {
83
85
  }, pollMs);
84
86
  pollTimer.unref?.();
85
87
  }
86
- void (async () => {
88
+ activeCycle = (async () => {
87
89
  try {
88
90
  await changeSignal?.refresh();
91
+ if (stopping) return;
89
92
  const initialChangeVersion = changeSignal?.currentVersion() ?? 0;
90
93
  if (!skipInitial) {
91
94
  await runOnce("initial");
92
95
  }
96
+ if (stopping) return;
93
97
  previousChecksum = await computeStructureChecksum();
94
98
  observedChangeVersion = initialChangeVersion;
95
99
  if (!quiet) {
@@ -115,9 +119,11 @@ function startInProcessGenerateWatcher(options) {
115
119
  clearTimeout(pollTimer);
116
120
  pollTimer = null;
117
121
  }
118
- await changeSignal?.close();
119
- if (doneResolve) {
120
- doneResolve();
122
+ try {
123
+ await activeCycle;
124
+ await changeSignal?.close();
125
+ } finally {
126
+ doneResolve?.();
121
127
  doneResolve = null;
122
128
  }
123
129
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/lib/in-process-generate-watcher.ts"],
4
- "sourcesContent": ["/**\n * In-process generate watcher.\n *\n * Coalesces filesystem events on a configurable interval, then verifies them\n * with the existing structural fingerprint before invoking the generator.\n * If filesystem watching is unavailable, it falls back to fingerprint polling.\n * The polling loop is identical to the legacy standalone watcher; the only\n * difference is that it now runs inside whatever process calls it\n * (typically `mercato server dev`), so the dev runtime no longer needs a\n * sidecar `mercato generate watch` Node process.\n *\n * Contract preserved from the prior standalone watcher:\n * - Default debounce/fallback poll interval 1000 ms (minimum 250 ms).\n * - One initial generator run unless `skipInitial` is true.\n * - Concurrent regeneration requests are coalesced (running + pending).\n * - Generator errors are logged but never crash the watcher.\n * - The polling timer uses `.unref()` so it never blocks process exit.\n */\n\nexport type GenerateWatcherLogger = Pick<Console, 'log' | 'error'>\n\nexport type GenerateWatcherChangeSignal = {\n /** Monotonic event generation. Changes indicate that a checksum may be stale. */\n currentVersion(): number\n /** Refresh filesystem subscriptions after module configuration changes. */\n refresh(): Promise<void> | void\n /** Whether configured roots are missing and should be retried on idle polls. */\n hasSkippedTargets?(): boolean\n /** When true, preserve the legacy full-checksum-on-every-poll behavior. */\n usesPollingFallback(): boolean\n /** Close filesystem subscriptions. Idempotent. */\n close(): Promise<void> | void\n}\n\nexport type GenerateWatcherOptions = {\n /**\n * Function that returns the current structural fingerprint of the module\n * tree. The watcher re-runs `runGenerators` whenever this value changes.\n */\n computeStructureChecksum: () => Promise<string> | string\n /** Optional event signal that avoids full checksum work during idle polls. */\n changeSignal?: GenerateWatcherChangeSignal\n /**\n * Function that performs the actual regeneration work. Called once on\n * startup (unless `skipInitial`) and again whenever the checksum changes.\n * The `reason` argument is suitable for logging (`'initial'`,\n * `'structure change'`, `'queued change'`).\n */\n runGenerators: (reason: string) => Promise<void>\n /** Poll interval in milliseconds. Defaults to 1000. Clamped to >= 250. */\n pollMs?: number\n /** Skip the initial regeneration on startup. Defaults to false. */\n skipInitial?: boolean\n /** Suppress informational logs. Errors are always logged. */\n quiet?: boolean\n /** Logger override. Defaults to `console`. */\n logger?: GenerateWatcherLogger\n}\n\nexport type GenerateWatcherHandle = {\n /** Resolves when the watcher loop has stopped (after `close()`). */\n readonly done: Promise<void>\n /** Stop the polling loop and resolve `done`. Idempotent. */\n close(): Promise<void>\n}\n\nconst MIN_POLL_MS = 250\nconst DEFAULT_POLL_MS = 1000\n\nfunction resolvePollMs(value: number | undefined): number {\n if (typeof value !== 'number' || !Number.isFinite(value)) return DEFAULT_POLL_MS\n const numeric = Math.floor(value)\n return numeric >= MIN_POLL_MS ? numeric : DEFAULT_POLL_MS\n}\n\n/**\n * Start an in-process generate watcher. The returned handle exposes a\n * `close()` to stop polling and a `done` promise that resolves once the\n * watcher loop has finished.\n */\nexport function startInProcessGenerateWatcher(\n options: GenerateWatcherOptions,\n): GenerateWatcherHandle {\n const logger = options.logger ?? console\n const quiet = options.quiet === true\n const pollMs = resolvePollMs(options.pollMs)\n const skipInitial = options.skipInitial === true\n const { changeSignal, computeStructureChecksum, runGenerators } = options\n\n let stopping = false\n let pollTimer: ReturnType<typeof setTimeout> | null = null\n let running = false\n let pendingReason: string | null = null\n let previousChecksum = ''\n let observedChangeVersion = -1\n let doneResolve: (() => void) | null = null\n const done = new Promise<void>((resolve) => {\n doneResolve = resolve\n })\n\n async function runOnce(reason: string): Promise<void> {\n if (running) {\n pendingReason = reason\n return\n }\n running = true\n try {\n if (!quiet) {\n logger.log(`[generate:watch] Regenerating (${reason})...`)\n }\n await runGenerators(reason)\n if (!quiet) {\n logger.log('[generate:watch] Generators completed.')\n }\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error)\n logger.error(`[generate:watch] Generation failed: ${message}`)\n } finally {\n running = false\n if (pendingReason && !stopping) {\n const queued = pendingReason\n pendingReason = null\n await runOnce(queued)\n }\n }\n }\n\n function scheduleNext(): void {\n if (stopping) return\n pollTimer = setTimeout(() => {\n void (async () => {\n if (stopping) return\n try {\n const changeVersion = changeSignal?.currentVersion() ?? 0\n const eventGatedIdle = Boolean(\n changeSignal\n && !changeSignal.usesPollingFallback()\n && changeVersion === observedChangeVersion\n )\n let refreshedSkippedTargets = false\n if (eventGatedIdle) {\n if (!changeSignal?.hasSkippedTargets?.()) return\n await changeSignal.refresh()\n refreshedSkippedTargets = true\n if (changeSignal.hasSkippedTargets?.()) return\n }\n const nextChecksum = await computeStructureChecksum()\n observedChangeVersion = changeVersion\n if (!refreshedSkippedTargets) {\n await changeSignal?.refresh()\n }\n if (nextChecksum !== previousChecksum) {\n previousChecksum = nextChecksum\n await runOnce('structure change')\n }\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error)\n logger.error(`[generate:watch] Poll cycle failed: ${message}`)\n } finally {\n if (!stopping) scheduleNext()\n }\n })()\n }, pollMs)\n pollTimer.unref?.()\n }\n\n void (async () => {\n try {\n await changeSignal?.refresh()\n const initialChangeVersion = changeSignal?.currentVersion() ?? 0\n if (!skipInitial) {\n await runOnce('initial')\n }\n previousChecksum = await computeStructureChecksum()\n observedChangeVersion = initialChangeVersion\n if (!quiet) {\n if (skipInitial) {\n logger.log('[generate:watch] Skipping initial regeneration and watching the current generated state.')\n }\n logger.log(`[generate:watch] Watching structural module files with a ${pollMs}ms debounce (in-process).`)\n }\n scheduleNext()\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error)\n logger.error(`[generate:watch] Initial setup failed: ${message}`)\n // Even if the initial bootstrap fails, schedule polling so a later\n // checksum recovery still picks up the next change on disk.\n scheduleNext()\n }\n })()\n\n async function close(): Promise<void> {\n if (stopping) {\n await done\n return\n }\n stopping = true\n if (pollTimer) {\n clearTimeout(pollTimer)\n pollTimer = null\n }\n await changeSignal?.close()\n if (doneResolve) {\n doneResolve()\n doneResolve = null\n }\n }\n\n return {\n done,\n close,\n }\n}\n"],
5
- "mappings": "AAkEA,MAAM,cAAc;AACpB,MAAM,kBAAkB;AAExB,SAAS,cAAc,OAAmC;AACxD,MAAI,OAAO,UAAU,YAAY,CAAC,OAAO,SAAS,KAAK,EAAG,QAAO;AACjE,QAAM,UAAU,KAAK,MAAM,KAAK;AAChC,SAAO,WAAW,cAAc,UAAU;AAC5C;AAOO,SAAS,8BACd,SACuB;AACvB,QAAM,SAAS,QAAQ,UAAU;AACjC,QAAM,QAAQ,QAAQ,UAAU;AAChC,QAAM,SAAS,cAAc,QAAQ,MAAM;AAC3C,QAAM,cAAc,QAAQ,gBAAgB;AAC5C,QAAM,EAAE,cAAc,0BAA0B,cAAc,IAAI;AAElE,MAAI,WAAW;AACf,MAAI,YAAkD;AACtD,MAAI,UAAU;AACd,MAAI,gBAA+B;AACnC,MAAI,mBAAmB;AACvB,MAAI,wBAAwB;AAC5B,MAAI,cAAmC;AACvC,QAAM,OAAO,IAAI,QAAc,CAAC,YAAY;AAC1C,kBAAc;AAAA,EAChB,CAAC;AAED,iBAAe,QAAQ,QAA+B;AACpD,QAAI,SAAS;AACX,sBAAgB;AAChB;AAAA,IACF;AACA,cAAU;AACV,QAAI;AACF,UAAI,CAAC,OAAO;AACV,eAAO,IAAI,kCAAkC,MAAM,MAAM;AAAA,MAC3D;AACA,YAAM,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;AACF,YAAM,cAAc,QAAQ;AAC5B,YAAM,uBAAuB,cAAc,eAAe,KAAK;AAC/D,UAAI,CAAC,aAAa;AAChB,cAAM,QAAQ,SAAS;AAAA,MACzB;AACA,yBAAmB,MAAM,yBAAyB;AAClD,8BAAwB;AACxB,UAAI,CAAC,OAAO;AACV,YAAI,aAAa;AACf,iBAAO,IAAI,0FAA0F;AAAA,QACvG;AACA,eAAO,IAAI,4DAA4D,MAAM,2BAA2B;AAAA,MAC1G;AACA,mBAAa;AAAA,IACf,SAAS,OAAO;AACd,YAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AACrE,aAAO,MAAM,0CAA0C,OAAO,EAAE;AAGhE,mBAAa;AAAA,IACf;AAAA,EACF,GAAG;AAEH,iBAAe,QAAuB;AACpC,QAAI,UAAU;AACZ,YAAM;AACN;AAAA,IACF;AACA,eAAW;AACX,QAAI,WAAW;AACb,mBAAa,SAAS;AACtB,kBAAY;AAAA,IACd;AACA,UAAM,cAAc,MAAM;AAC1B,QAAI,aAAa;AACf,kBAAY;AACZ,oBAAc;AAAA,IAChB;AAAA,EACF;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF;",
4
+ "sourcesContent": ["/**\n * In-process generate watcher.\n *\n * Coalesces filesystem events on a configurable interval, then verifies them\n * with the existing structural fingerprint before invoking the generator.\n * If filesystem watching is unavailable, it falls back to fingerprint polling.\n * The polling loop is identical to the legacy standalone watcher; the only\n * difference is that it now runs inside whatever process calls it\n * (typically `mercato server dev`), so the dev runtime no longer needs a\n * sidecar `mercato generate watch` Node process.\n *\n * Contract preserved from the prior standalone watcher:\n * - Default debounce/fallback poll interval 1000 ms (minimum 250 ms).\n * - One initial generator run unless `skipInitial` is true.\n * - Concurrent regeneration requests are coalesced (running + pending).\n * - Generator errors are logged but never crash the watcher.\n * - The polling timer uses `.unref()` so it never blocks process exit.\n */\n\nexport type GenerateWatcherLogger = Pick<Console, 'log' | 'error'>\n\nexport type GenerateWatcherChangeSignal = {\n /** Monotonic event generation. Changes indicate that a checksum may be stale. */\n currentVersion(): number\n /** Refresh filesystem subscriptions after module configuration changes. */\n refresh(): Promise<void> | void\n /** Whether configured roots are missing and should be retried on idle polls. */\n hasSkippedTargets?(): boolean\n /** When true, preserve the legacy full-checksum-on-every-poll behavior. */\n usesPollingFallback(): boolean\n /** Close filesystem subscriptions. Idempotent. */\n close(): Promise<void> | void\n}\n\nexport type GenerateWatcherOptions = {\n /**\n * Function that returns the current structural fingerprint of the module\n * tree. The watcher re-runs `runGenerators` whenever this value changes.\n */\n computeStructureChecksum: () => Promise<string> | string\n /** Optional event signal that avoids full checksum work during idle polls. */\n changeSignal?: GenerateWatcherChangeSignal\n /**\n * Function that performs the actual regeneration work. Called once on\n * startup (unless `skipInitial`) and again whenever the checksum changes.\n * The `reason` argument is suitable for logging (`'initial'`,\n * `'structure change'`, `'queued change'`).\n */\n runGenerators: (reason: string) => Promise<void>\n /** Poll interval in milliseconds. Defaults to 1000. Clamped to >= 250. */\n pollMs?: number\n /** Skip the initial regeneration on startup. Defaults to false. */\n skipInitial?: boolean\n /** Suppress informational logs. Errors are always logged. */\n quiet?: boolean\n /** Logger override. Defaults to `console`. */\n logger?: GenerateWatcherLogger\n}\n\nexport type GenerateWatcherHandle = {\n /** Resolves when the watcher loop has stopped (after `close()`). */\n readonly done: Promise<void>\n /** Stop polling, drain the active cycle, and resolve `done`. Idempotent. */\n close(): Promise<void>\n}\n\nconst MIN_POLL_MS = 250\nconst DEFAULT_POLL_MS = 1000\n\nfunction resolvePollMs(value: number | undefined): number {\n if (typeof value !== 'number' || !Number.isFinite(value)) return DEFAULT_POLL_MS\n const numeric = Math.floor(value)\n return numeric >= MIN_POLL_MS ? numeric : DEFAULT_POLL_MS\n}\n\n/**\n * Start an in-process generate watcher. The returned handle exposes a\n * `close()` to stop polling and a `done` promise that resolves once the\n * watcher loop has finished.\n */\nexport function startInProcessGenerateWatcher(\n options: GenerateWatcherOptions,\n): GenerateWatcherHandle {\n const logger = options.logger ?? console\n const quiet = options.quiet === true\n const pollMs = resolvePollMs(options.pollMs)\n const skipInitial = options.skipInitial === true\n const { changeSignal, computeStructureChecksum, runGenerators } = options\n\n let stopping = false\n let pollTimer: ReturnType<typeof setTimeout> | null = null\n let activeCycle: Promise<void> | null = null\n let running = false\n let pendingReason: string | null = null\n let previousChecksum = ''\n let observedChangeVersion = -1\n let doneResolve: (() => void) | null = null\n const done = new Promise<void>((resolve) => {\n doneResolve = resolve\n })\n\n async function runOnce(reason: string): Promise<void> {\n if (stopping) return\n if (running) {\n pendingReason = reason\n return\n }\n running = true\n try {\n if (!quiet) {\n logger.log(`[generate:watch] Regenerating (${reason})...`)\n }\n await runGenerators(reason)\n if (!quiet) {\n logger.log('[generate:watch] Generators completed.')\n }\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error)\n logger.error(`[generate:watch] Generation failed: ${message}`)\n } finally {\n running = false\n if (pendingReason && !stopping) {\n const queued = pendingReason\n pendingReason = null\n await runOnce(queued)\n }\n }\n }\n\n function scheduleNext(): void {\n if (stopping) return\n pollTimer = setTimeout(() => {\n activeCycle = (async () => {\n if (stopping) return\n try {\n const changeVersion = changeSignal?.currentVersion() ?? 0\n const eventGatedIdle = Boolean(\n changeSignal\n && !changeSignal.usesPollingFallback()\n && changeVersion === observedChangeVersion\n )\n let refreshedSkippedTargets = false\n if (eventGatedIdle) {\n if (!changeSignal?.hasSkippedTargets?.()) return\n await changeSignal.refresh()\n refreshedSkippedTargets = true\n if (changeSignal.hasSkippedTargets?.()) return\n }\n const nextChecksum = await computeStructureChecksum()\n observedChangeVersion = changeVersion\n if (!refreshedSkippedTargets) {\n await changeSignal?.refresh()\n }\n if (nextChecksum !== previousChecksum) {\n previousChecksum = nextChecksum\n await runOnce('structure change')\n }\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error)\n logger.error(`[generate:watch] Poll cycle failed: ${message}`)\n } finally {\n if (!stopping) scheduleNext()\n }\n })()\n }, pollMs)\n pollTimer.unref?.()\n }\n\n activeCycle = (async () => {\n try {\n await changeSignal?.refresh()\n if (stopping) return\n const initialChangeVersion = changeSignal?.currentVersion() ?? 0\n if (!skipInitial) {\n await runOnce('initial')\n }\n if (stopping) return\n previousChecksum = await computeStructureChecksum()\n observedChangeVersion = initialChangeVersion\n if (!quiet) {\n if (skipInitial) {\n logger.log('[generate:watch] Skipping initial regeneration and watching the current generated state.')\n }\n logger.log(`[generate:watch] Watching structural module files with a ${pollMs}ms debounce (in-process).`)\n }\n scheduleNext()\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error)\n logger.error(`[generate:watch] Initial setup failed: ${message}`)\n // Even if the initial bootstrap fails, schedule polling so a later\n // checksum recovery still picks up the next change on disk.\n scheduleNext()\n }\n })()\n\n async function close(): Promise<void> {\n if (stopping) {\n await done\n return\n }\n stopping = true\n if (pollTimer) {\n clearTimeout(pollTimer)\n pollTimer = null\n }\n // Drain before closing subscriptions: an in-flight capture can refresh\n // them, and a generator child must exit before dev restarts its group.\n try {\n await activeCycle\n await changeSignal?.close()\n } finally {\n doneResolve?.()\n doneResolve = null\n }\n }\n\n return {\n done,\n close,\n }\n}\n"],
5
+ "mappings": "AAkEA,MAAM,cAAc;AACpB,MAAM,kBAAkB;AAExB,SAAS,cAAc,OAAmC;AACxD,MAAI,OAAO,UAAU,YAAY,CAAC,OAAO,SAAS,KAAK,EAAG,QAAO;AACjE,QAAM,UAAU,KAAK,MAAM,KAAK;AAChC,SAAO,WAAW,cAAc,UAAU;AAC5C;AAOO,SAAS,8BACd,SACuB;AACvB,QAAM,SAAS,QAAQ,UAAU;AACjC,QAAM,QAAQ,QAAQ,UAAU;AAChC,QAAM,SAAS,cAAc,QAAQ,MAAM;AAC3C,QAAM,cAAc,QAAQ,gBAAgB;AAC5C,QAAM,EAAE,cAAc,0BAA0B,cAAc,IAAI;AAElE,MAAI,WAAW;AACf,MAAI,YAAkD;AACtD,MAAI,cAAoC;AACxC,MAAI,UAAU;AACd,M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LazySchedulerSupervisor } from "./lib/sched
29
29
  import {
30
30
  startInProcessGenerateWatcher
31
31
  } from "./lib/in-process-generate-watcher.js";
32
+ import { runGenerateChildProcess } from "./lib/generate-child-process.js";
32
33
  import {
33
34
  resolveGenerateWatcherMode
34
35
  } from "./lib/in-process-generate-watcher-mode.js";
@@ -276,9 +277,16 @@ async function ensureEnvLoaded(options = {}) {
276
277
  }
277
278
  } catch {
278
279
  }
280
+ const previousDotenvQuiet = process.env.DOTENV_CONFIG_QUIET;
279
281
  try {
282
+ if (quietDotenv) process.env.DOTENV_CONFIG_QUIET = "true";
280
283
  await import("dotenv/config");
281
284
  } catch {
285
+ } finally {
286
+ if (quietDotenv) {
287
+ if (previousDotenvQuiet === void 0) delete process.env.DOTENV_CONFIG_QUIET;
288
+ else process.env.DOTENV_CONFIG_QUIET = previousDotenvQuiet;
289
+ }
282
290
  }
283
291
  }
284
292
  function resolveInstalledBinary(baseDirs, relativeBinPath) {
@@ -648,6 +656,15 @@ async function runGeneratorSuiteWithStructuralInvalidation(quiet) {
648
656
  }
649
657
  await runPostGenerateStructuralInvalidation(quiet);
650
658
  }
659
+ async function runWatchGeneratorSuite() {
660
+ const { resolveEnvironment } = await import("./lib/resolver.js");
661
+ const { rootDir, appDir } = resolveEnvironment();
662
+ await runGenerateChildProcess({
663
+ mercatoBin: resolveInstalledBinary([rootDir, appDir], "@open-mercato/cli/bin/mercato"),
664
+ cwd: process.cwd(),
665
+ quiet: true
666
+ });
667
+ }
651
668
  async function createGenerateWatchRuntime(quiet = false) {
652
669
  const [
653
670
  { createResolver },
@@ -740,15 +757,17 @@ function resolveEnvBootstrapOptions(parts) {
740
757
  const opaqueEnvCommand = first === "deploy" || first === "telemetry";
741
758
  const readOnlyModuleCommand = first === "module" && (parts[1] === "search" || parts[1] === "info");
742
759
  const jsonOutput = parts.includes("--json");
760
+ const quietGeneration = first === "generate" && (parts.includes("--quiet") || parts.includes("-q"));
743
761
  const helpRequested = isHelpRequest(parts);
744
762
  return {
745
763
  createIfMissing: !helpRequested && !opaqueEnvCommand && !readOnlyModuleCommand,
746
- quiet: helpRequested || opaqueEnvCommand || readOnlyModuleCommand || jsonOutput
764
+ quiet: helpRequested || opaqueEnvCommand || readOnlyModuleCommand || jsonOutput || quietGeneration
747
765
  };
748
766
  }
749
767
  async function run(argv = process.argv) {
750
768
  const [, , ...parts] = argv;
751
769
  const [first, second, ...remaining] = parts;
770
+ const quietGeneration = first === "generate" && (parts.includes("--quiet") || parts.includes("-q"));
752
771
  const helpRequested = isHelpRequest(parts);
753
772
  await ensureEnvLoaded(resolveEnvBootstrapOptions(parts));
754
773
  if (helpRequested && first && Object.hasOwn(TOP_LEVEL_COMMAND_HELP, first)) {
@@ -1178,7 +1197,7 @@ async function run(argv = process.argv) {
1178
1197
  if (first === "module") {
1179
1198
  try {
1180
1199
  const subcommand = second;
1181
- const commandArgs2 = remaining.filter(Boolean);
1200
+ const commandArgs = remaining.filter(Boolean);
1182
1201
  if (!subcommand || subcommand === "help" || subcommand === "--help" || subcommand === "-h") {
1183
1202
  console.log("Usage: yarn mercato module <add|enable|eject|search|info> ...");
1184
1203
  console.log(" yarn mercato module add <packageSpec> [--module <moduleId>] [--eject] [--allow-third-party]");
@@ -1192,12 +1211,12 @@ async function run(argv = process.argv) {
1192
1211
  const { runModuleSearch, runModuleInfo } = await import("./lib/module-search.js");
1193
1212
  const { readEnabledModules } = await import("./lib/modules-config.js");
1194
1213
  const deps = { readEnabledModules };
1195
- return subcommand === "search" ? await runModuleSearch(commandArgs2, deps) : await runModuleInfo(commandArgs2, deps);
1214
+ return subcommand === "search" ? await runModuleSearch(commandArgs, deps) : await runModuleInfo(commandArgs, deps);
1196
1215
  }
1197
1216
  if (subcommand === "add") {
1198
1217
  const { createResolver } = await import("./lib/resolver.js");
1199
1218
  const { addOfficialModule } = await import("./lib/module-install.js");
1200
- const { packageSpec, eject, moduleId, allowThirdParty } = parseModuleInstallArgs(commandArgs2);
1219
+ const { packageSpec, eject, moduleId, allowThirdParty } = parseModuleInstallArgs(commandArgs);
1201
1220
  if (!packageSpec) {
1202
1221
  console.error("Usage: yarn mercato module add <packageSpec> [--module <moduleId>] [--eject] [--allow-third-party]");
1203
1222
  return 1;
@@ -1207,20 +1226,20 @@ async function run(argv = process.argv) {
1207
1226
  return 0;
1208
1227
  }
1209
1228
  if (subcommand === "enable") {
1210
- const packageName = commandArgs2.find((arg) => !arg.startsWith("-"));
1229
+ const packageName = commandArgs.find((arg) => !arg.startsWith("-"));
1211
1230
  if (!packageName) {
1212
1231
  console.error("Usage: yarn mercato module enable <packageName> [--module <moduleId>] [--eject] [--allow-third-party]");
1213
1232
  return 1;
1214
1233
  }
1215
1234
  const { createResolver } = await import("./lib/resolver.js");
1216
1235
  const { enableOfficialModule } = await import("./lib/module-install.js");
1217
- const { moduleId, eject, allowThirdParty } = parseModuleInstallArgs(commandArgs2);
1236
+ const { moduleId, eject, allowThirdParty } = parseModuleInstallArgs(commandArgs);
1218
1237
  const result = await enableOfficialModule(createResolver(), packageName, moduleId ?? void 0, eject, allowThirdParty);
1219
1238
  printModuleCommandResult(result);
1220
1239
  return 0;
1221
1240
  }
1222
1241
  if (subcommand === "eject") {
1223
- return handleDirectEjectCommand(commandArgs2);
1242
+ return handleDirectEjectCommand(commandArgs);
1224
1243
  }
1225
1244
  console.error(`Unknown module subcommand "${subcommand}".`);
1226
1245
  return 1;
@@ -1601,9 +1620,9 @@ async function run(argv = process.argv) {
1601
1620
  command: "all",
1602
1621
  run: async (args) => {
1603
1622
  const quiet = args.includes("--quiet") || args.includes("-q");
1604
- console.log("Running all generators...");
1623
+ if (!quiet) console.log("Running all generators...");
1605
1624
  await runGeneratorSuiteWithStructuralInvalidation(quiet);
1606
- console.log("All generators completed.");
1625
+ if (!quiet) console.log("All generators completed.");
1607
1626
  }
1608
1627
  },
1609
1628
  {
@@ -1620,9 +1639,7 @@ async function run(argv = process.argv) {
1620
1639
  skipInitial,
1621
1640
  quiet,
1622
1641
  ...generateWatchRuntime,
1623
- runGenerators: async () => {
1624
- await runGeneratorSuiteWithStructuralInvalidation(true);
1625
- }
1642
+ runGenerators: runWatchGeneratorSuite
1626
1643
  });
1627
1644
  const shutdownSignals = ["SIGINT", "SIGTERM"];
1628
1645
  let shuttingDown = false;
@@ -2006,7 +2023,7 @@ async function run(argv = process.argv) {
2006
2023
  void startBackgroundServices();
2007
2024
  });
2008
2025
  if (generateWatcherMode === "in-process") {
2009
- console.log("[server] In-process generate watcher enabled \u2014 structural changes will regenerate without a sidecar process.");
2026
+ console.log("[server] In-process generate watcher enabled \u2014 structural changes regenerate in a one-shot child.");
2010
2027
  const generateWatchRuntime = await createGenerateWatchRuntime();
2011
2028
  activeGenerateWatcher = startInProcessGenerateWatcher({
2012
2029
  // `--skip-initial` equivalent: `yarn dev` always runs an
@@ -2017,9 +2034,7 @@ async function run(argv = process.argv) {
2017
2034
  skipInitial: true,
2018
2035
  quiet: false,
2019
2036
  ...generateWatchRuntime,
2020
- runGenerators: async () => {
2021
- await runGeneratorSuiteWithStructuralInvalidation(true);
2022
- }
2037
+ runGenerators: runWatchGeneratorSuite
2023
2038
  });
2024
2039
  } else {
2025
2040
  console.log("[server] Legacy out-of-process generate watcher selected via OM_DEV_GENERATE_WATCH_MODE=legacy \u2014 expect the dev orchestrator to spawn `mercato generate watch --skip-initial`.");
@@ -2228,7 +2243,7 @@ async function run(argv = process.argv) {
2228
2243
  ]
2229
2244
  });
2230
2245
  if (appCli.length) all.push({ id: "app", cli: appCli });
2231
- const quietBanner = process.env.OM_CLI_QUIET === "1";
2246
+ const quietBanner = process.env.OM_CLI_QUIET === "1" || quietGeneration;
2232
2247
  const banner = "\u{1F9E9} Open Mercato CLI";
2233
2248
  if (!quietBanner) {
2234
2249
  const header = [
@@ -2283,16 +2298,18 @@ async function run(argv = process.argv) {
2283
2298
  console.log(pad(`Commands for "${modName}": ${mod.cli.map((c) => c.command).join(", ")}`));
2284
2299
  return 0;
2285
2300
  }
2286
- console.log("");
2301
+ if (!quietGeneration) console.log("");
2287
2302
  const started = Date.now();
2288
- const commandArgs = modName === "deploy" && cmdName === "railway" ? (await import("./lib/deploy/railway/options.js")).redactRailwayCliArgs(rest) : rest;
2289
- const loggedArgs = redactSensitiveModuleCliArgs(commandArgs, `${modName}:${cmdName}`);
2290
- console.log(`\u{1F680} Running ${modName}:${cmdName} ${loggedArgs.join(" ")}`);
2303
+ if (!quietGeneration) {
2304
+ const commandArgs = modName === "deploy" && cmdName === "railway" ? (await import("./lib/deploy/railway/options.js")).redactRailwayCliArgs(rest) : rest;
2305
+ const loggedArgs = redactSensitiveModuleCliArgs(commandArgs, `${modName}:${cmdName}`);
2306
+ console.log(`\u{1F680} Running ${modName}:${cmdName} ${loggedArgs.join(" ")}`);
2307
+ }
2291
2308
  try {
2292
2309
  const commandExitCode = await runWithCapturedExitCode(async () => {
2293
2310
  await cmd.run(rest);
2294
2311
  });
2295
- if (modName !== "deploy" || cmdName !== "railway") {
2312
+ if (!quietGeneration && (modName !== "deploy" || cmdName !== "railway")) {
2296
2313
  const ms = Date.now() - started;
2297
2314
  console.log(`\u23F1\uFE0F Done in ${ms}ms`);
2298
2315
  }