@open-mercato/cli 0.11.1-develop.8587.1.5952ba9ee6 → 0.11.1-develop.8593.1.50784dae35

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 (133) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/AGENTS.md +1 -0
  3. package/dist/agentic/guides/module-facts.json +164 -164
  4. package/dist/agentic/guides/module-facts.v2.json +164 -164
  5. package/dist/agentic/guides/modules/agent_orchestrator/index.md +1 -1
  6. package/dist/agentic/guides/modules/ai_assistant/index.md +1 -1
  7. package/dist/agentic/guides/modules/api_docs/index.md +1 -1
  8. package/dist/agentic/guides/modules/api_keys/index.md +1 -1
  9. package/dist/agentic/guides/modules/attachments/index.md +1 -1
  10. package/dist/agentic/guides/modules/audit_logs/index.md +1 -1
  11. package/dist/agentic/guides/modules/auth/index.md +1 -1
  12. package/dist/agentic/guides/modules/availability/index.md +1 -1
  13. package/dist/agentic/guides/modules/backups/index.md +1 -1
  14. package/dist/agentic/guides/modules/business_rules/index.md +1 -1
  15. package/dist/agentic/guides/modules/carrier_inpost/index.md +1 -1
  16. package/dist/agentic/guides/modules/cart/index.md +1 -1
  17. package/dist/agentic/guides/modules/catalog/index.md +1 -1
  18. package/dist/agentic/guides/modules/channel_apns/index.md +1 -1
  19. package/dist/agentic/guides/modules/channel_discord/index.md +1 -1
  20. package/dist/agentic/guides/modules/channel_expo/index.md +1 -1
  21. package/dist/agentic/guides/modules/channel_fcm/index.md +1 -1
  22. package/dist/agentic/guides/modules/channel_gmail/index.md +1 -1
  23. package/dist/agentic/guides/modules/channel_imap/index.md +1 -1
  24. package/dist/agentic/guides/modules/channel_resend/index.md +1 -1
  25. package/dist/agentic/guides/modules/channel_ses/index.md +1 -1
  26. package/dist/agentic/guides/modules/channel_smtp/index.md +1 -1
  27. package/dist/agentic/guides/modules/checkout/index.md +1 -1
  28. package/dist/agentic/guides/modules/communication_channels/index.md +1 -1
  29. package/dist/agentic/guides/modules/configs/index.md +1 -1
  30. package/dist/agentic/guides/modules/content/index.md +1 -1
  31. package/dist/agentic/guides/modules/currencies/index.md +1 -1
  32. package/dist/agentic/guides/modules/customer_accounts/index.md +1 -1
  33. package/dist/agentic/guides/modules/customer_groups/index.md +1 -1
  34. package/dist/agentic/guides/modules/customers/index.md +1 -1
  35. package/dist/agentic/guides/modules/dashboards/index.md +1 -1
  36. package/dist/agentic/guides/modules/data_sync/index.md +1 -1
  37. package/dist/agentic/guides/modules/design_system/index.md +1 -1
  38. package/dist/agentic/guides/modules/devices/index.md +1 -1
  39. package/dist/agentic/guides/modules/dictionaries/index.md +1 -1
  40. package/dist/agentic/guides/modules/directory/index.md +1 -1
  41. package/dist/agentic/guides/modules/documents/index.md +1 -1
  42. package/dist/agentic/guides/modules/ecommerce/index.md +1 -1
  43. package/dist/agentic/guides/modules/entities/index.md +1 -1
  44. package/dist/agentic/guides/modules/eudr/index.md +1 -1
  45. package/dist/agentic/guides/modules/events/index.md +1 -1
  46. package/dist/agentic/guides/modules/feature_toggles/index.md +1 -1
  47. package/dist/agentic/guides/modules/forms/index.md +1 -1
  48. package/dist/agentic/guides/modules/gateway_autopay/index.md +1 -1
  49. package/dist/agentic/guides/modules/gateway_stripe/index.md +1 -1
  50. package/dist/agentic/guides/modules/gateway_tpay/index.md +1 -1
  51. package/dist/agentic/guides/modules/generators/index.md +1 -1
  52. package/dist/agentic/guides/modules/inbox_ops/index.md +1 -1
  53. package/dist/agentic/guides/modules/integrations/index.md +1 -1
  54. package/dist/agentic/guides/modules/messages/index.md +1 -1
  55. package/dist/agentic/guides/modules/notifications/index.md +1 -1
  56. package/dist/agentic/guides/modules/onboarding/index.md +1 -1
  57. package/dist/agentic/guides/modules/payment_gateways/index.md +1 -1
  58. package/dist/agentic/guides/modules/perspectives/index.md +1 -1
  59. package/dist/agentic/guides/modules/phone_calls/index.md +1 -1
  60. package/dist/agentic/guides/modules/planner/index.md +1 -1
  61. package/dist/agentic/guides/modules/portal/index.md +1 -1
  62. package/dist/agentic/guides/modules/progress/index.md +1 -1
  63. package/dist/agentic/guides/modules/promotions/index.md +1 -1
  64. package/dist/agentic/guides/modules/push_notifications/index.md +1 -1
  65. package/dist/agentic/guides/modules/query_index/index.md +1 -1
  66. package/dist/agentic/guides/modules/record_locks/index.md +1 -1
  67. package/dist/agentic/guides/modules/resources/index.md +1 -1
  68. package/dist/agentic/guides/modules/sales/index.md +1 -1
  69. package/dist/agentic/guides/modules/scheduler/index.md +1 -1
  70. package/dist/agentic/guides/modules/search/index.md +1 -1
  71. package/dist/agentic/guides/modules/security/index.md +1 -1
  72. package/dist/agentic/guides/modules/seeds/index.md +1 -1
  73. package/dist/agentic/guides/modules/shipping_carriers/index.md +1 -1
  74. package/dist/agentic/guides/modules/sso/index.md +1 -1
  75. package/dist/agentic/guides/modules/staff/index.md +1 -1
  76. package/dist/agentic/guides/modules/storage_s3/index.md +1 -1
  77. package/dist/agentic/guides/modules/sync_akeneo/index.md +1 -1
  78. package/dist/agentic/guides/modules/sync_excel/index.md +1 -1
  79. package/dist/agentic/guides/modules/system_status_overlays/index.md +1 -1
  80. package/dist/agentic/guides/modules/telemetry/index.md +1 -1
  81. package/dist/agentic/guides/modules/tillio/index.md +1 -1
  82. package/dist/agentic/guides/modules/translations/index.md +1 -1
  83. package/dist/agentic/guides/modules/warranty_claims/index.md +1 -1
  84. package/dist/agentic/guides/modules/webhooks/index.md +1 -1
  85. package/dist/agentic/guides/modules/wms/index.md +1 -1
  86. package/dist/agentic/guides/modules/workflows/index.md +1 -1
  87. package/dist/agentic/guides/reference-module-facts.json +1 -1
  88. package/dist/agentic/guides/upstream/manifest.json +1 -1
  89. package/dist/lib/generate-child-process.js +21 -3
  90. package/dist/lib/generate-child-process.js.map +2 -2
  91. package/dist/lib/generate-watch-events.js +135 -19
  92. package/dist/lib/generate-watch-events.js.map +2 -2
  93. package/dist/lib/generate-watch-plan.js +166 -0
  94. package/dist/lib/generate-watch-plan.js.map +7 -0
  95. package/dist/lib/generate-watch-runner.js +53 -0
  96. package/dist/lib/generate-watch-runner.js.map +7 -0
  97. package/dist/lib/generate-watch-structure.js +576 -203
  98. package/dist/lib/generate-watch-structure.js.map +3 -3
  99. package/dist/lib/generators/extensions/agent-files.js +1 -0
  100. package/dist/lib/generators/extensions/agent-files.js.map +2 -2
  101. package/dist/lib/generators/module-registry.js +148 -191
  102. package/dist/lib/generators/module-registry.js.map +3 -3
  103. package/dist/lib/generators/openapi.js +24 -1
  104. package/dist/lib/generators/openapi.js.map +2 -2
  105. package/dist/lib/generators/web-research-adapters.js +54 -22
  106. package/dist/lib/generators/web-research-adapters.js.map +2 -2
  107. package/dist/lib/in-process-generate-watcher.js +98 -75
  108. package/dist/lib/in-process-generate-watcher.js.map +2 -2
  109. package/dist/mercato.js +74 -46
  110. package/dist/mercato.js.map +2 -2
  111. package/package.json +7 -7
  112. package/src/lib/__tests__/generate-child-process.test.ts +30 -0
  113. package/src/lib/__tests__/generate-watch-events.test.ts +377 -8
  114. package/src/lib/__tests__/generate-watch-plan.test.ts +98 -0
  115. package/src/lib/__tests__/generate-watch-runner.test.ts +126 -0
  116. package/src/lib/__tests__/generate-watch-structure.test.ts +522 -1
  117. package/src/lib/__tests__/in-process-generate-watcher.test.ts +393 -6
  118. package/src/lib/__tests__/module-inspection.test.ts +17 -11
  119. package/src/lib/generate-child-process.ts +26 -3
  120. package/src/lib/generate-watch-events.ts +189 -17
  121. package/src/lib/generate-watch-plan.ts +177 -0
  122. package/src/lib/generate-watch-runner.ts +62 -0
  123. package/src/lib/generate-watch-structure.ts +666 -227
  124. package/src/lib/generators/__tests__/incremental-registry.test.ts +262 -0
  125. package/src/lib/generators/__tests__/openapi.test.ts +91 -1
  126. package/src/lib/generators/__tests__/web-research-adapters.test.ts +298 -87
  127. package/src/lib/generators/extension.ts +2 -0
  128. package/src/lib/generators/extensions/agent-files.ts +1 -0
  129. package/src/lib/generators/module-registry.ts +168 -200
  130. package/src/lib/generators/openapi.ts +34 -0
  131. package/src/lib/generators/web-research-adapters.ts +76 -21
  132. package/src/lib/in-process-generate-watcher.ts +151 -96
  133. package/src/mercato.ts +85 -53
@@ -1,5 +1,5 @@
1
1
  # sso — module facts (generated, do not edit)
2
- <!-- generated from @open-mercato/enterprise 0.11.1-develop.8587.1.5952ba9ee6; core 0.11.1-develop.8587.1.5952ba9ee6 — R1 staleness stamp -->
2
+ <!-- generated from @open-mercato/enterprise 0.11.1-develop.8593.1.50784dae35; core 0.11.1-develop.8593.1.50784dae35 — R1 staleness stamp -->
3
3
  Source root: node_modules/@open-mercato/enterprise/src/modules/sso
4
4
 
5
5
  ## Sections
@@ -1,5 +1,5 @@
1
1
  # staff — module facts (generated, do not edit)
2
- <!-- generated from @open-mercato/core 0.11.1-develop.8587.1.5952ba9ee6; core 0.11.1-develop.8587.1.5952ba9ee6 — R1 staleness stamp -->
2
+ <!-- generated from @open-mercato/core 0.11.1-develop.8593.1.50784dae35; core 0.11.1-develop.8593.1.50784dae35 — 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.11.1-develop.8587.1.5952ba9ee6; core 0.11.1-develop.8587.1.5952ba9ee6 — R1 staleness stamp -->
2
+ <!-- generated from @open-mercato/storage-s3 0.11.1-develop.8593.1.50784dae35; core 0.11.1-develop.8593.1.50784dae35 — 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.11.1-develop.8587.1.5952ba9ee6; core 0.11.1-develop.8587.1.5952ba9ee6 — R1 staleness stamp -->
2
+ <!-- generated from @open-mercato/sync-akeneo 0.11.1-develop.8593.1.50784dae35; core 0.11.1-develop.8593.1.50784dae35 — 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.11.1-develop.8587.1.5952ba9ee6; core 0.11.1-develop.8587.1.5952ba9ee6 — R1 staleness stamp -->
2
+ <!-- generated from @open-mercato/core 0.11.1-develop.8593.1.50784dae35; core 0.11.1-develop.8593.1.50784dae35 — 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.11.1-develop.8587.1.5952ba9ee6; core 0.11.1-develop.8587.1.5952ba9ee6 — R1 staleness stamp -->
2
+ <!-- generated from @open-mercato/enterprise 0.11.1-develop.8593.1.50784dae35; core 0.11.1-develop.8593.1.50784dae35 — 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.11.1-develop.8587.1.5952ba9ee6; core 0.11.1-develop.8587.1.5952ba9ee6 — R1 staleness stamp -->
2
+ <!-- generated from @open-mercato/telemetry 0.11.1-develop.8593.1.50784dae35; core 0.11.1-develop.8593.1.50784dae35 — 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.11.1-develop.8587.1.5952ba9ee6; core 0.11.1-develop.8587.1.5952ba9ee6 — R1 staleness stamp -->
2
+ <!-- generated from @open-mercato/tillio 0.11.1-develop.8593.1.50784dae35; core 0.11.1-develop.8593.1.50784dae35 — 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.11.1-develop.8587.1.5952ba9ee6; core 0.11.1-develop.8587.1.5952ba9ee6 — R1 staleness stamp -->
2
+ <!-- generated from @open-mercato/core 0.11.1-develop.8593.1.50784dae35; core 0.11.1-develop.8593.1.50784dae35 — 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.11.1-develop.8587.1.5952ba9ee6; core 0.11.1-develop.8587.1.5952ba9ee6 — R1 staleness stamp -->
2
+ <!-- generated from @open-mercato/core 0.11.1-develop.8593.1.50784dae35; core 0.11.1-develop.8593.1.50784dae35 — 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.11.1-develop.8587.1.5952ba9ee6; core 0.11.1-develop.8587.1.5952ba9ee6 — R1 staleness stamp -->
2
+ <!-- generated from @open-mercato/webhooks 0.11.1-develop.8593.1.50784dae35; core 0.11.1-develop.8593.1.50784dae35 — 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.11.1-develop.8587.1.5952ba9ee6; core 0.11.1-develop.8587.1.5952ba9ee6 — R1 staleness stamp -->
2
+ <!-- generated from @open-mercato/core 0.11.1-develop.8593.1.50784dae35; core 0.11.1-develop.8593.1.50784dae35 — 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.11.1-develop.8587.1.5952ba9ee6; core 0.11.1-develop.8587.1.5952ba9ee6 — R1 staleness stamp -->
2
+ <!-- generated from @open-mercato/core 0.11.1-develop.8593.1.50784dae35; core 0.11.1-develop.8593.1.50784dae35 — 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.11.1-develop.8587.1.5952ba9ee6",
1188
+ "coreVersion": "0.11.1-develop.8593.1.50784dae35",
1189
1189
  "sourcePackage": null,
1190
1190
  "sourceVersion": null,
1191
1191
  "sourceRoot": "src/modules/example",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 1,
3
- "generator": "@open-mercato/cli@0.11.1-develop.8587.1.5952ba9ee6",
3
+ "generator": "@open-mercato/cli@0.11.1-develop.8593.1.50784dae35",
4
4
  "files": {
5
5
  "AGENTS.md": "35c948a32e06ca64b4706970c55ec60946412b410938b22478233a2c5c43df56",
6
6
  "BACKWARD_COMPATIBILITY.md": "81752dde63a698597dd9f60bf1ca2b2738d3641a0a788f59c50e761ca0d42807"
@@ -1,16 +1,33 @@
1
1
  import { spawn } from "node:child_process";
2
+ import fs from "node:fs";
3
+ function readGenerateWatchRequest() {
4
+ if (process.env.OM_INTERNAL_GENERATE_WATCH_REQUEST !== "1") return void 0;
5
+ delete process.env.OM_INTERNAL_GENERATE_WATCH_REQUEST;
6
+ return JSON.parse(fs.readFileSync(0, "utf8"));
7
+ }
2
8
  async function runGenerateChildProcess(options) {
3
9
  const args = [options.mercatoBin, "generate", "all"];
4
10
  if (options.quiet) args.push("--quiet");
5
11
  await new Promise((resolve, reject) => {
12
+ let inputError;
6
13
  const child = spawn(process.execPath, args, {
7
14
  cwd: options.cwd,
8
- env: options.env ?? process.env,
9
- stdio: ["ignore", "inherit", "inherit"]
15
+ env: {
16
+ ...options.env ?? process.env,
17
+ OM_INTERNAL_GENERATE_WATCH_REQUEST: options.watchRequest ? "1" : void 0
18
+ },
19
+ stdio: [options.watchRequest ? "pipe" : "ignore", "inherit", "inherit"]
10
20
  });
11
21
  child.once("error", reject);
22
+ if (options.watchRequest) {
23
+ child.stdin?.on("error", (error) => {
24
+ inputError = error;
25
+ });
26
+ child.stdin?.end(JSON.stringify(options.watchRequest));
27
+ }
12
28
  child.once("close", (code, signal) => {
13
- if (code === 0) resolve();
29
+ if (inputError) reject(inputError);
30
+ else if (code === 0) resolve();
14
31
  else reject(new Error(
15
32
  signal ? `Generator process terminated by ${signal}` : `Generator process exited with code ${code ?? "unknown"}`
16
33
  ));
@@ -18,6 +35,7 @@ async function runGenerateChildProcess(options) {
18
35
  });
19
36
  }
20
37
  export {
38
+ readGenerateWatchRequest,
21
39
  runGenerateChildProcess
22
40
  };
23
41
  //# sourceMappingURL=generate-child-process.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
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;",
4
+ "sourcesContent": ["import { spawn } from 'node:child_process'\nimport fs from 'node:fs'\nimport type { GenerateWatchPlan } from './generate-watch-plan'\n\ntype GenerateWatchRequest = {\n plan?: GenerateWatchPlan\n logCascade: boolean\n}\n\nexport function readGenerateWatchRequest(): GenerateWatchRequest | undefined {\n if (process.env.OM_INTERNAL_GENERATE_WATCH_REQUEST !== '1') return undefined\n delete process.env.OM_INTERNAL_GENERATE_WATCH_REQUEST\n return JSON.parse(fs.readFileSync(0, 'utf8')) as GenerateWatchRequest\n}\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 watchRequest?: GenerateWatchRequest\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 let inputError: Error | undefined\n const child = spawn(process.execPath, args, {\n cwd: options.cwd,\n env: {\n ...(options.env ?? process.env),\n OM_INTERNAL_GENERATE_WATCH_REQUEST: options.watchRequest ? '1' : undefined,\n },\n stdio: [options.watchRequest ? 'pipe' : 'ignore', 'inherit', 'inherit'],\n })\n child.once('error', reject)\n if (options.watchRequest) {\n child.stdin?.on('error', (error: Error) => { inputError = error })\n child.stdin?.end(JSON.stringify(options.watchRequest))\n }\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 (inputError) reject(inputError)\n else 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;AACtB,OAAO,QAAQ;AAQR,SAAS,2BAA6D;AAC3E,MAAI,QAAQ,IAAI,uCAAuC,IAAK,QAAO;AACnE,SAAO,QAAQ,IAAI;AACnB,SAAO,KAAK,MAAM,GAAG,aAAa,GAAG,MAAM,CAAC;AAC9C;AAOA,eAAsB,wBAAwB,SAM5B;AAChB,QAAM,OAAO,CAAC,QAAQ,YAAY,YAAY,KAAK;AACnD,MAAI,QAAQ,MAAO,MAAK,KAAK,SAAS;AAEtC,QAAM,IAAI,QAAc,CAAC,SAAS,WAAW;AAC3C,QAAI;AACJ,UAAM,QAAQ,MAAM,QAAQ,UAAU,MAAM;AAAA,MAC1C,KAAK,QAAQ;AAAA,MACb,KAAK;AAAA,QACH,GAAI,QAAQ,OAAO,QAAQ;AAAA,QAC3B,oCAAoC,QAAQ,eAAe,MAAM;AAAA,MACnE;AAAA,MACA,OAAO,CAAC,QAAQ,eAAe,SAAS,UAAU,WAAW,SAAS;AAAA,IACxE,CAAC;AACD,UAAM,KAAK,SAAS,MAAM;AAC1B,QAAI,QAAQ,cAAc;AACxB,YAAM,OAAO,GAAG,SAAS,CAAC,UAAiB;AAAE,qBAAa;AAAA,MAAM,CAAC;AACjE,YAAM,OAAO,IAAI,KAAK,UAAU,QAAQ,YAAY,CAAC;AAAA,IACvD;AAGA,UAAM,KAAK,SAAS,CAAC,MAAM,WAAW;AACpC,UAAI,WAAY,QAAO,UAAU;AAAA,eACxB,SAAS,EAAG,SAAQ;AAAA,UACxB,QAAO,IAAI;AAAA,QACd,SACI,mCAAmC,MAAM,KACzC,sCAAsC,QAAQ,SAAS;AAAA,MAC7D,CAAC;AAAA,IACH,CAAC;AAAA,EACH,CAAC;AACH;",
6
6
  "names": []
7
7
  }
@@ -1,27 +1,134 @@
1
1
  import fs from "node:fs";
2
2
  import path from "node:path";
3
+ function comparePaths(left, right) {
4
+ return left < right ? -1 : left > right ? 1 : 0;
5
+ }
6
+ function isWithinDirectory(candidate, directory) {
7
+ const relative = path.relative(directory, candidate);
8
+ return relative === "" || !path.isAbsolute(relative) && relative !== ".." && !relative.startsWith(`..${path.sep}`);
9
+ }
10
+ function normalizeExcludedDirectories(target) {
11
+ if (!target.recursive) return [];
12
+ return [...new Set(
13
+ (target.excludedDirectories ?? []).map((directory) => path.resolve(directory)).filter((directory) => isWithinDirectory(directory, target.directory))
14
+ )].sort(comparePaths);
15
+ }
16
+ function normalizeGenerateWatchTargets(targets) {
17
+ const unique = /* @__PURE__ */ new Map();
18
+ for (const target of targets) {
19
+ const directory = path.resolve(target.directory);
20
+ const excludedDirectories = normalizeExcludedDirectories({ ...target, directory });
21
+ const normalized = {
22
+ directory,
23
+ recursive: target.recursive,
24
+ ...target.fileName === void 0 ? {} : { fileName: target.fileName },
25
+ ...excludedDirectories.length > 0 ? { excludedDirectories } : {}
26
+ };
27
+ unique.set(targetKey(normalized), normalized);
28
+ }
29
+ const recursiveDirectories = new Set(
30
+ [...unique.values()].filter((target) => target.recursive).map((target) => target.directory)
31
+ );
32
+ const allExcludedDirectories = [...new Set(
33
+ [...unique.values()].flatMap((target) => target.excludedDirectories ?? [])
34
+ )].sort(comparePaths);
35
+ const recursiveRoots = [...recursiveDirectories].filter((directory) => {
36
+ let ancestor = path.dirname(directory);
37
+ while (ancestor !== directory) {
38
+ if (recursiveDirectories.has(ancestor)) return false;
39
+ const parent = path.dirname(ancestor);
40
+ if (parent === ancestor) break;
41
+ ancestor = parent;
42
+ }
43
+ return true;
44
+ }).sort(comparePaths).map((directory) => {
45
+ const excludedDirectories = allExcludedDirectories.filter((excluded) => isWithinDirectory(excluded, directory));
46
+ return {
47
+ directory,
48
+ recursive: true,
49
+ ...excludedDirectories.length > 0 ? { excludedDirectories } : {}
50
+ };
51
+ });
52
+ const collapsed = [...recursiveRoots];
53
+ for (const target of unique.values()) {
54
+ if (target.recursive) continue;
55
+ if (!target.fileName && recursiveRoots.some((root) => isWithinDirectory(target.directory, root.directory))) continue;
56
+ collapsed.push(target);
57
+ }
58
+ return collapsed.sort((left, right) => comparePaths(left.directory, right.directory) || Number(left.recursive) - Number(right.recursive) || comparePaths(left.fileName ?? "", right.fileName ?? "") || comparePaths(
59
+ JSON.stringify(left.excludedDirectories ?? []),
60
+ JSON.stringify(right.excludedDirectories ?? [])
61
+ ));
62
+ }
3
63
  function resolveGenerateWatchTargets(options) {
4
- const targets = [{
5
- directory: path.dirname(options.modulesFile),
64
+ const targets = [options.modulesFile, ...options.additionalInputs ?? []].map((filePath) => ({
65
+ directory: path.dirname(filePath),
6
66
  recursive: false,
7
- fileName: path.basename(options.modulesFile)
8
- }];
67
+ fileName: path.basename(filePath)
68
+ }));
69
+ if (options.appSourceDir) targets.push({ directory: options.appSourceDir, recursive: true });
70
+ for (const directory of options.shallowDirectories ?? []) {
71
+ targets.push({ directory, recursive: false });
72
+ }
9
73
  for (const roots of options.moduleRoots) {
10
74
  targets.push({ directory: path.dirname(roots.appBase), recursive: true });
11
75
  if (!roots.watchPackageBase) continue;
12
76
  targets.push({ directory: path.dirname(roots.pkgBase), recursive: true });
13
- const sourceMirror = options.resolveSourceMirrorBase(roots.pkgBase);
77
+ for (const base of roots.additionalModuleBases ?? []) {
78
+ targets.push({ directory: path.dirname(base), recursive: true });
79
+ }
80
+ const distMarker = `${path.sep}dist${path.sep}modules${path.sep}`;
81
+ const distIndex = roots.pkgBase.lastIndexOf(distMarker);
82
+ const sourceMirror = options.resolveSourceMirrorBase(roots.pkgBase) ?? (distIndex < 0 ? null : `${roots.pkgBase.slice(0, distIndex)}${path.sep}src${path.sep}modules${path.sep}${roots.pkgBase.slice(distIndex + distMarker.length)}`);
14
83
  if (sourceMirror) {
15
84
  targets.push({ directory: path.dirname(sourceMirror), recursive: true });
16
85
  }
17
86
  }
18
- return targets;
87
+ const outputRoots = [...new Set(
88
+ [options.outputDir, ...options.outputDirectories ?? []].filter((directory) => Boolean(directory)).map((directory) => path.resolve(directory))
89
+ )].sort(comparePaths);
90
+ const baseRecursiveRoots = normalizeGenerateWatchTargets(targets).filter((target) => target.recursive).map((target) => target.directory);
91
+ const snapshotInputs = [...new Set(
92
+ [...options.snapshot?.records.values() ?? []].filter((record) => !(options.shallowDirectories?.length && record.category === "web-research-adapters")).map((record) => path.resolve(record.path))
93
+ )].filter((input) => !outputRoots.some((outputRoot) => isWithinDirectory(input, outputRoot))).filter((input) => !baseRecursiveRoots.some((root) => isWithinDirectory(input, root))).sort(comparePaths);
94
+ const snapshotStats = snapshotInputs.map((input) => {
95
+ try {
96
+ return { input, stat: fs.statSync(input) };
97
+ } catch {
98
+ return { input, stat: void 0 };
99
+ }
100
+ });
101
+ for (const { input, stat } of snapshotStats) {
102
+ if (stat?.isDirectory()) targets.push({ directory: input, recursive: true });
103
+ }
104
+ const recursiveRoots = normalizeGenerateWatchTargets(targets).filter((target) => target.recursive).map((target) => target.directory);
105
+ for (const { input, stat } of snapshotStats) {
106
+ if (stat?.isDirectory() || recursiveRoots.some((root) => isWithinDirectory(input, root))) continue;
107
+ const parent = path.dirname(input);
108
+ targets.push({
109
+ directory: parent,
110
+ recursive: false,
111
+ // A missing extensionless import can become foo.ts or foo/index.ts.
112
+ ...!stat && !path.extname(input) ? {} : { fileName: path.basename(input) }
113
+ });
114
+ if (!fs.existsSync(parent)) {
115
+ let ancestor = path.dirname(parent);
116
+ while (!fs.existsSync(ancestor) && path.dirname(ancestor) !== ancestor) ancestor = path.dirname(ancestor);
117
+ targets.push({ directory: ancestor, recursive: false });
118
+ }
119
+ }
120
+ return normalizeGenerateWatchTargets(targets.map((target) => {
121
+ if (!target.recursive) return target;
122
+ const excludedDirectories = outputRoots.filter((outputRoot) => isWithinDirectory(outputRoot, path.resolve(target.directory)));
123
+ return excludedDirectories.length > 0 ? { ...target, excludedDirectories } : target;
124
+ }));
19
125
  }
20
126
  function targetKey(target) {
21
127
  return JSON.stringify([
22
128
  path.resolve(target.directory),
23
129
  target.recursive,
24
- target.fileName ?? ""
130
+ target.fileName ?? "",
131
+ target.excludedDirectories ?? []
25
132
  ]);
26
133
  }
27
134
  const defaultWatchDirectory = (target, onChange, onError) => {
@@ -45,6 +152,8 @@ function createGenerateWatchChangeSignal(options) {
45
152
  let version = 0;
46
153
  let pollingFallback = false;
47
154
  let closed = false;
155
+ let lastUnknownVersion = -1;
156
+ let initialized = false;
48
157
  const closeWatchers = () => {
49
158
  for (const watcher of watchers.values()) {
50
159
  try {
@@ -55,13 +164,14 @@ function createGenerateWatchChangeSignal(options) {
55
164
  watchers.clear();
56
165
  };
57
166
  const enterPollingFallback = () => {
58
- if (pollingFallback) return;
167
+ if (closed || pollingFallback) return;
59
168
  pollingFallback = true;
60
169
  version += 1;
61
170
  closeWatchers();
62
171
  };
63
172
  return {
64
173
  currentVersion: () => version,
174
+ fullGenerationReasonSince: (capturedVersion) => lastUnknownVersion > capturedVersion ? "filesystem event did not identify a path" : void 0,
65
175
  hasSkippedTargets: () => skippedDirectories.size > 0,
66
176
  usesPollingFallback: () => pollingFallback,
67
177
  refresh: async () => {
@@ -73,24 +183,21 @@ function createGenerateWatchChangeSignal(options) {
73
183
  enterPollingFallback();
74
184
  return;
75
185
  }
186
+ if (closed || pollingFallback) return;
76
187
  const normalizedTargets = /* @__PURE__ */ new Map();
77
188
  const nextSkippedDirectories = /* @__PURE__ */ new Set();
78
- for (const target of targets) {
79
- const normalized = {
80
- ...target,
81
- directory: path.resolve(target.directory)
82
- };
83
- if (!directoryExists(normalized.directory)) {
84
- nextSkippedDirectories.add(normalized.directory);
85
- if (!skippedDirectories.has(normalized.directory)) {
189
+ for (const target of normalizeGenerateWatchTargets(targets)) {
190
+ if (!directoryExists(target.directory)) {
191
+ nextSkippedDirectories.add(target.directory);
192
+ if (!skippedDirectories.has(target.directory)) {
86
193
  try {
87
- options.onSkippedDirectory?.(normalized.directory);
194
+ options.onSkippedDirectory?.(target.directory);
88
195
  } catch {
89
196
  }
90
197
  }
91
198
  continue;
92
199
  }
93
- normalizedTargets.set(targetKey(normalized), normalized);
200
+ normalizedTargets.set(targetKey(target), target);
94
201
  }
95
202
  skippedDirectories = nextSkippedDirectories;
96
203
  for (const [key, watcher] of watchers) {
@@ -100,14 +207,21 @@ function createGenerateWatchChangeSignal(options) {
100
207
  } catch {
101
208
  }
102
209
  watchers.delete(key);
210
+ version += 1;
103
211
  }
104
212
  for (const [key, target] of normalizedTargets) {
105
213
  if (watchers.has(key)) continue;
106
214
  try {
107
215
  const watcher = watchDirectory(
108
216
  target,
109
- () => {
217
+ (fileName) => {
218
+ if (closed || pollingFallback) return;
219
+ if (fileName && target.recursive && target.excludedDirectories?.length) {
220
+ const changedPath = path.resolve(target.directory, fileName);
221
+ if (target.excludedDirectories.some((directory) => isWithinDirectory(changedPath, directory))) return;
222
+ }
110
223
  version += 1;
224
+ if (!fileName) lastUnknownVersion = version;
111
225
  },
112
226
  enterPollingFallback
113
227
  );
@@ -119,11 +233,13 @@ function createGenerateWatchChangeSignal(options) {
119
233
  continue;
120
234
  }
121
235
  watchers.set(key, watcher);
236
+ if (initialized) version += 1;
122
237
  } catch {
123
238
  enterPollingFallback();
124
239
  return;
125
240
  }
126
241
  }
242
+ initialized = true;
127
243
  },
128
244
  close: () => {
129
245
  if (closed) return;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/lib/generate-watch-events.ts"],
4
- "sourcesContent": ["import fs from 'node:fs'\nimport path from 'node:path'\nimport type { GenerateWatcherChangeSignal } from './in-process-generate-watcher'\n\nexport type GenerateWatchTarget = {\n directory: string\n recursive: boolean\n fileName?: string\n}\n\ntype WatchHandle = {\n close(): void\n}\n\ntype WatchDirectory = (\n target: GenerateWatchTarget,\n onChange: (fileName?: string) => void,\n onError: () => void,\n) => WatchHandle\n\nexport type GenerateWatchChangeSignalOptions = {\n getWatchTargets: () => Promise<GenerateWatchTarget[]> | GenerateWatchTarget[]\n watchDirectory?: WatchDirectory\n directoryExists?: (directory: string) => boolean\n onSkippedDirectory?: (directory: string) => void\n}\n\nexport type GenerateWatchModuleTarget = {\n appBase: string\n pkgBase: string\n watchPackageBase: boolean\n}\n\nexport function resolveGenerateWatchTargets(options: {\n modulesFile: string\n moduleRoots: GenerateWatchModuleTarget[]\n resolveSourceMirrorBase: (packageBase: string) => string | null\n}): GenerateWatchTarget[] {\n const targets: GenerateWatchTarget[] = [{\n directory: path.dirname(options.modulesFile),\n recursive: false,\n fileName: path.basename(options.modulesFile),\n }]\n\n for (const roots of options.moduleRoots) {\n targets.push({ directory: path.dirname(roots.appBase), recursive: true })\n if (!roots.watchPackageBase) continue\n\n targets.push({ directory: path.dirname(roots.pkgBase), recursive: true })\n const sourceMirror = options.resolveSourceMirrorBase(roots.pkgBase)\n if (sourceMirror) {\n targets.push({ directory: path.dirname(sourceMirror), recursive: true })\n }\n }\n\n return targets\n}\n\nfunction targetKey(target: GenerateWatchTarget): string {\n return JSON.stringify([\n path.resolve(target.directory),\n target.recursive,\n target.fileName ?? '',\n ])\n}\n\nconst defaultWatchDirectory: WatchDirectory = (target, onChange, onError) => {\n const watcher = fs.watch(\n target.directory,\n { recursive: target.recursive },\n (_eventType, fileName) => {\n const normalizedName = String(fileName ?? '')\n if (target.fileName && normalizedName && normalizedName !== target.fileName) return\n onChange(normalizedName || undefined)\n },\n )\n watcher.on('error', onError)\n return watcher\n}\n\nexport function createGenerateWatchChangeSignal(\n options: GenerateWatchChangeSignalOptions,\n): GenerateWatcherChangeSignal {\n const watchDirectory = options.watchDirectory ?? defaultWatchDirectory\n const directoryExists = options.directoryExists ?? fs.existsSync\n const watchers = new Map<string, WatchHandle>()\n let skippedDirectories = new Set<string>()\n let version = 0\n let pollingFallback = false\n let closed = false\n\n const closeWatchers = () => {\n for (const watcher of watchers.values()) {\n try { watcher.close() } catch {}\n }\n watchers.clear()\n }\n\n const enterPollingFallback = () => {\n if (pollingFallback) return\n pollingFallback = true\n version += 1\n closeWatchers()\n }\n\n return {\n currentVersion: () => version,\n hasSkippedTargets: () => skippedDirectories.size > 0,\n usesPollingFallback: () => pollingFallback,\n refresh: async () => {\n if (closed || pollingFallback) return\n\n let targets: GenerateWatchTarget[]\n try {\n targets = await options.getWatchTargets()\n } catch {\n enterPollingFallback()\n return\n }\n\n const normalizedTargets = new Map<string, GenerateWatchTarget>()\n const nextSkippedDirectories = new Set<string>()\n for (const target of targets) {\n const normalized: GenerateWatchTarget = {\n ...target,\n directory: path.resolve(target.directory),\n }\n if (!directoryExists(normalized.directory)) {\n nextSkippedDirectories.add(normalized.directory)\n if (!skippedDirectories.has(normalized.directory)) {\n try { options.onSkippedDirectory?.(normalized.directory) } catch {}\n }\n continue\n }\n normalizedTargets.set(targetKey(normalized), normalized)\n }\n skippedDirectories = nextSkippedDirectories\n\n for (const [key, watcher] of watchers) {\n if (normalizedTargets.has(key)) continue\n try { watcher.close() } catch {}\n watchers.delete(key)\n }\n\n for (const [key, target] of normalizedTargets) {\n if (watchers.has(key)) continue\n try {\n const watcher = watchDirectory(\n target,\n () => { version += 1 },\n enterPollingFallback,\n )\n if (closed || pollingFallback) {\n try { watcher.close() } catch {}\n continue\n }\n watchers.set(key, watcher)\n } catch {\n enterPollingFallback()\n return\n }\n }\n },\n close: () => {\n if (closed) return\n closed = true\n closeWatchers()\n },\n }\n}\n"],
5
- "mappings": "AAAA,OAAO,QAAQ;AACf,OAAO,UAAU;AAgCV,SAAS,4BAA4B,SAIlB;AACxB,QAAM,UAAiC,CAAC;AAAA,IACtC,WAAW,KAAK,QAAQ,QAAQ,WAAW;AAAA,IAC3C,WAAW;AAAA,IACX,UAAU,KAAK,SAAS,QAAQ,WAAW;AAAA,EAC7C,CAAC;AAED,aAAW,SAAS,QAAQ,aAAa;AACvC,YAAQ,KAAK,EAAE,WAAW,KAAK,QAAQ,MAAM,OAAO,GAAG,WAAW,KAAK,CAAC;AACxE,QAAI,CAAC,MAAM,iBAAkB;AAE7B,YAAQ,KAAK,EAAE,WAAW,KAAK,QAAQ,MAAM,OAAO,GAAG,WAAW,KAAK,CAAC;AACxE,UAAM,eAAe,QAAQ,wBAAwB,MAAM,OAAO;AAClE,QAAI,cAAc;AAChB,cAAQ,KAAK,EAAE,WAAW,KAAK,QAAQ,YAAY,GAAG,WAAW,KAAK,CAAC;AAAA,IACzE;AAAA,EACF;AAEA,SAAO;AACT;AAEA,SAAS,UAAU,QAAqC;AACtD,SAAO,KAAK,UAAU;AAAA,IACpB,KAAK,QAAQ,OAAO,SAAS;AAAA,IAC7B,OAAO;AAAA,IACP,OAAO,YAAY;AAAA,EACrB,CAAC;AACH;AAEA,MAAM,wBAAwC,CAAC,QAAQ,UAAU,YAAY;AAC3E,QAAM,UAAU,GAAG;AAAA,IACjB,OAAO;AAAA,IACP,EAAE,WAAW,OAAO,UAAU;AAAA,IAC9B,CAAC,YAAY,aAAa;AACxB,YAAM,iBAAiB,OAAO,YAAY,EAAE;AAC5C,UAAI,OAAO,YAAY,kBAAkB,mBAAmB,OAAO,SAAU;AAC7E,eAAS,kBAAkB,MAAS;AAAA,IACtC;AAAA,EACF;AACA,UAAQ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AkB,IAAI,UAAU,UAAU,GAAG,UAAU;AAAA,MACzD;AACA,2BAAqB;AAErB,iBAAW,CAAC,KAAK,OAAO,KAAK,UAAU;AACrC,YAAI,kBAAkB,IAAI,GAAG,EAAG;AAChC,YAAI;AAAE,kBAAQ,MAAM;AAAA,QAAE,QAAQ;AAAA,QAAC;AAC/B,iBAAS,OAAO,GAAG;AAAA,MACrB;AAEA,iBAAW,CAAC,KAAK,MAAM,KAAK,mBAAmB;AAC7C,YAAI,SAAS,IAAI,GAAG,EAAG;AACvB,YAAI;AACF,gBAAM,UAAU;AAAA,YACd;AAAA,YACA,MAAM;AAAE,yBAAW;AAAA,YAAE;AAAA,YACrB;AAAA,UACF;AACA,cAAI,UAAU,iBAAiB;AAC7B,gBAAI;AAAE,sBAAQ,MAAM;AAAA,YAAE,QAAQ;AAAA,YAAC;AAC/B;AAAA,UACF;AACA,mBAAS,IAAI,KAAK,OAAO;AAAA,QAC3B,QAAQ;AACN,+BAAqB;AACrB;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,IACA,OAAO,MAAM;AACX,UAAI,OAAQ;AACZ,eAAS;AACT,oBAAc;AAAA,IAChB;AAAA,EACF;AACF;",
4
+ "sourcesContent": ["import fs from 'node:fs'\nimport path from 'node:path'\nimport type { GenerateWatcherChangeSignal } from './in-process-generate-watcher'\nimport type { GenerateWatchSnapshot } from './generate-watch-plan'\n\nexport type GenerateWatchTarget = {\n directory: string\n recursive: boolean\n fileName?: string\n /** Generator-owned directories whose attributed events must not trigger this recursive watch. */\n excludedDirectories?: readonly string[]\n}\n\ntype WatchHandle = {\n close(): void\n}\n\ntype WatchDirectory = (\n target: GenerateWatchTarget,\n onChange: (fileName?: string) => void,\n onError: () => void,\n) => WatchHandle\n\nexport type GenerateWatchChangeSignalOptions = {\n getWatchTargets: () => Promise<GenerateWatchTarget[]> | GenerateWatchTarget[]\n watchDirectory?: WatchDirectory\n directoryExists?: (directory: string) => boolean\n onSkippedDirectory?: (directory: string) => void\n}\n\nexport type GenerateWatchModuleTarget = {\n appBase: string\n pkgBase: string\n watchPackageBase: boolean\n /** Both installed source/runtime roots, including roots not present yet. */\n additionalModuleBases?: readonly string[]\n}\n\nfunction comparePaths(left: string, right: string): number {\n return left < right ? -1 : left > right ? 1 : 0\n}\n\nfunction isWithinDirectory(candidate: string, directory: string): boolean {\n const relative = path.relative(directory, candidate)\n return relative === '' || (!path.isAbsolute(relative) && relative !== '..' && !relative.startsWith(`..${path.sep}`))\n}\n\nfunction normalizeExcludedDirectories(\n target: Pick<GenerateWatchTarget, 'directory' | 'recursive' | 'excludedDirectories'>,\n): string[] {\n if (!target.recursive) return []\n return [...new Set(\n (target.excludedDirectories ?? [])\n .map((directory) => path.resolve(directory))\n .filter((directory) => isWithinDirectory(directory, target.directory)),\n )].sort(comparePaths)\n}\n\nfunction normalizeGenerateWatchTargets(targets: readonly GenerateWatchTarget[]): GenerateWatchTarget[] {\n const unique = new Map<string, GenerateWatchTarget>()\n for (const target of targets) {\n const directory = path.resolve(target.directory)\n const excludedDirectories = normalizeExcludedDirectories({ ...target, directory })\n const normalized: GenerateWatchTarget = {\n directory,\n recursive: target.recursive,\n ...(target.fileName === undefined ? {} : { fileName: target.fileName }),\n ...(excludedDirectories.length > 0 ? { excludedDirectories } : {}),\n }\n unique.set(targetKey(normalized), normalized)\n }\n\n const recursiveDirectories = new Set(\n [...unique.values()].filter((target) => target.recursive).map((target) => target.directory),\n )\n const allExcludedDirectories = [...new Set(\n [...unique.values()].flatMap((target) => target.excludedDirectories ?? []),\n )].sort(comparePaths)\n const recursiveRoots = [...recursiveDirectories]\n .filter((directory) => {\n let ancestor = path.dirname(directory)\n while (ancestor !== directory) {\n if (recursiveDirectories.has(ancestor)) return false\n const parent = path.dirname(ancestor)\n if (parent === ancestor) break\n ancestor = parent\n }\n return true\n })\n .sort(comparePaths)\n .map((directory): GenerateWatchTarget => {\n const excludedDirectories = allExcludedDirectories.filter((excluded) => (\n isWithinDirectory(excluded, directory)\n ))\n return {\n directory,\n recursive: true,\n ...(excludedDirectories.length > 0 ? { excludedDirectories } : {}),\n }\n })\n const collapsed = [...recursiveRoots]\n for (const target of unique.values()) {\n if (target.recursive) continue\n if (!target.fileName && recursiveRoots.some((root) => isWithinDirectory(target.directory, root.directory))) continue\n collapsed.push(target)\n }\n return collapsed.sort((left, right) => (\n comparePaths(left.directory, right.directory)\n || Number(left.recursive) - Number(right.recursive)\n || comparePaths(left.fileName ?? '', right.fileName ?? '')\n || comparePaths(\n JSON.stringify(left.excludedDirectories ?? []),\n JSON.stringify(right.excludedDirectories ?? []),\n )\n ))\n}\n\nexport function resolveGenerateWatchTargets(options: {\n modulesFile: string\n moduleRoots: GenerateWatchModuleTarget[]\n resolveSourceMirrorBase: (packageBase: string) => string | null\n additionalInputs?: readonly string[]\n /** Watched without recursion; their per-file snapshot records are covered by these entries. */\n shallowDirectories?: readonly string[]\n appSourceDir?: string\n outputDir?: string\n outputDirectories?: readonly string[]\n snapshot?: GenerateWatchSnapshot\n}): GenerateWatchTarget[] {\n const targets: GenerateWatchTarget[] = [options.modulesFile, ...(options.additionalInputs ?? [])].map((filePath) => ({\n directory: path.dirname(filePath),\n recursive: false,\n fileName: path.basename(filePath),\n }))\n if (options.appSourceDir) targets.push({ directory: options.appSourceDir, recursive: true })\n for (const directory of options.shallowDirectories ?? []) {\n targets.push({ directory, recursive: false })\n }\n\n for (const roots of options.moduleRoots) {\n targets.push({ directory: path.dirname(roots.appBase), recursive: true })\n if (!roots.watchPackageBase) continue\n\n targets.push({ directory: path.dirname(roots.pkgBase), recursive: true })\n for (const base of roots.additionalModuleBases ?? []) {\n targets.push({ directory: path.dirname(base), recursive: true })\n }\n const distMarker = `${path.sep}dist${path.sep}modules${path.sep}`\n const distIndex = roots.pkgBase.lastIndexOf(distMarker)\n const sourceMirror = options.resolveSourceMirrorBase(roots.pkgBase)\n ?? (distIndex < 0 ? null : `${roots.pkgBase.slice(0, distIndex)}${path.sep}src${path.sep}modules${path.sep}${roots.pkgBase.slice(distIndex + distMarker.length)}`)\n if (sourceMirror) {\n targets.push({ directory: path.dirname(sourceMirror), recursive: true })\n }\n }\n\n const outputRoots = [...new Set(\n [options.outputDir, ...(options.outputDirectories ?? [])]\n .filter((directory): directory is string => Boolean(directory))\n .map((directory) => path.resolve(directory)),\n )].sort(comparePaths)\n const baseRecursiveRoots = normalizeGenerateWatchTargets(targets)\n .filter((target) => target.recursive)\n .map((target) => target.directory)\n const snapshotInputs = [...new Set(\n [...(options.snapshot?.records.values() ?? [])]\n // Adapter manifests change through installs (watched lockfiles) or by appearing\n // in a shallow scan directory; one watcher per installed package would not scale.\n .filter((record) => !(options.shallowDirectories?.length && record.category === 'web-research-adapters'))\n .map((record) => path.resolve(record.path)),\n )]\n .filter((input) => !outputRoots.some((outputRoot) => isWithinDirectory(input, outputRoot)))\n .filter((input) => !baseRecursiveRoots.some((root) => isWithinDirectory(input, root)))\n .sort(comparePaths)\n const snapshotStats = snapshotInputs.map((input) => {\n try {\n return { input, stat: fs.statSync(input) }\n } catch {\n return { input, stat: undefined }\n }\n })\n\n for (const { input, stat } of snapshotStats) {\n if (stat?.isDirectory()) targets.push({ directory: input, recursive: true })\n }\n const recursiveRoots = normalizeGenerateWatchTargets(targets)\n .filter((target) => target.recursive)\n .map((target) => target.directory)\n\n for (const { input, stat } of snapshotStats) {\n if (stat?.isDirectory() || recursiveRoots.some((root) => isWithinDirectory(input, root))) continue\n const parent = path.dirname(input)\n targets.push({\n directory: parent,\n recursive: false,\n // A missing extensionless import can become foo.ts or foo/index.ts.\n ...(!stat && !path.extname(input) ? {} : { fileName: path.basename(input) }),\n })\n if (!fs.existsSync(parent)) {\n let ancestor = path.dirname(parent)\n while (!fs.existsSync(ancestor) && path.dirname(ancestor) !== ancestor) ancestor = path.dirname(ancestor)\n targets.push({ directory: ancestor, recursive: false })\n }\n }\n\n return normalizeGenerateWatchTargets(targets.map((target) => {\n if (!target.recursive) return target\n const excludedDirectories = outputRoots.filter((outputRoot) => (\n isWithinDirectory(outputRoot, path.resolve(target.directory))\n ))\n return excludedDirectories.length > 0 ? { ...target, excludedDirectories } : target\n }))\n}\n\nfunction targetKey(target: GenerateWatchTarget): string {\n return JSON.stringify([\n path.resolve(target.directory),\n target.recursive,\n target.fileName ?? '',\n target.excludedDirectories ?? [],\n ])\n}\n\nconst defaultWatchDirectory: WatchDirectory = (target, onChange, onError) => {\n const watcher = fs.watch(\n target.directory,\n { recursive: target.recursive },\n (_eventType, fileName) => {\n const normalizedName = String(fileName ?? '')\n if (target.fileName && normalizedName && normalizedName !== target.fileName) return\n onChange(normalizedName || undefined)\n },\n )\n watcher.on('error', onError)\n return watcher\n}\n\nexport function createGenerateWatchChangeSignal(\n options: GenerateWatchChangeSignalOptions,\n): GenerateWatcherChangeSignal {\n const watchDirectory = options.watchDirectory ?? defaultWatchDirectory\n const directoryExists = options.directoryExists ?? fs.existsSync\n const watchers = new Map<string, WatchHandle>()\n let skippedDirectories = new Set<string>()\n let version = 0\n let pollingFallback = false\n let closed = false\n let lastUnknownVersion = -1\n let initialized = false\n\n const closeWatchers = () => {\n for (const watcher of watchers.values()) {\n try { watcher.close() } catch {}\n }\n watchers.clear()\n }\n\n const enterPollingFallback = () => {\n if (closed || pollingFallback) return\n pollingFallback = true\n version += 1\n closeWatchers()\n }\n\n return {\n currentVersion: () => version,\n fullGenerationReasonSince: (capturedVersion) => lastUnknownVersion > capturedVersion\n ? 'filesystem event did not identify a path'\n : undefined,\n hasSkippedTargets: () => skippedDirectories.size > 0,\n usesPollingFallback: () => pollingFallback,\n refresh: async () => {\n if (closed || pollingFallback) return\n\n let targets: GenerateWatchTarget[]\n try {\n targets = await options.getWatchTargets()\n } catch {\n enterPollingFallback()\n return\n }\n if (closed || pollingFallback) return\n\n const normalizedTargets = new Map<string, GenerateWatchTarget>()\n const nextSkippedDirectories = new Set<string>()\n for (const target of normalizeGenerateWatchTargets(targets)) {\n if (!directoryExists(target.directory)) {\n nextSkippedDirectories.add(target.directory)\n if (!skippedDirectories.has(target.directory)) {\n try { options.onSkippedDirectory?.(target.directory) } catch {}\n }\n continue\n }\n normalizedTargets.set(targetKey(target), target)\n }\n skippedDirectories = nextSkippedDirectories\n\n for (const [key, watcher] of watchers) {\n if (normalizedTargets.has(key)) continue\n try { watcher.close() } catch {}\n watchers.delete(key)\n version += 1\n }\n\n for (const [key, target] of normalizedTargets) {\n if (watchers.has(key)) continue\n try {\n const watcher = watchDirectory(\n target,\n (fileName) => {\n if (closed || pollingFallback) return\n if (fileName && target.recursive && target.excludedDirectories?.length) {\n const changedPath = path.resolve(target.directory, fileName)\n if (target.excludedDirectories.some((directory) => (\n isWithinDirectory(changedPath, directory)\n ))) return\n }\n version += 1\n if (!fileName) lastUnknownVersion = version\n },\n enterPollingFallback,\n )\n if (closed || pollingFallback) {\n try { watcher.close() } catch {}\n continue\n }\n watchers.set(key, watcher)\n if (initialized) version += 1\n } catch {\n enterPollingFallback()\n return\n }\n }\n initialized = true\n },\n close: () => {\n if (closed) return\n closed = true\n closeWatchers()\n },\n }\n}\n"],
5
+ "mappings": "AAAA,OAAO,QAAQ;AACf,OAAO,UAAU;AAqCjB,SAAS,aAAa,MAAc,OAAuB;AACzD,SAAO,OAAO,QAAQ,KAAK,OAAO,QAAQ,IAAI;AAChD;AAEA,SAAS,kBAAkB,WAAmB,WAA4B;AACxE,QAAM,WAAW,KAAK,SAAS,WAAW,SAAS;AACnD,SAAO,aAAa,MAAO,CAAC,KAAK,WAAW,QAAQ,KAAK,aAAa,QAAQ,CAAC,SAAS,WAAW,KAAK,KAAK,GAAG,EAAE;AACpH;AAEA,SAAS,6BACP,QACU;AACV,MAAI,CAAC,OAAO,UAAW,QAAO,CAAC;AAC/B,SAAO,CAAC,GAAG,IAAI;AAAA,KACZ,OAAO,uBAAuB,CAAC,GAC7B,IAAI,CAAC,cAAc,KAAK,QAAQ,SAAS,CAAC,EAC1C,OAAO,CAAC,cAAc,kBAAkB,WAAW,OAAO,SAAS,CAAC;AAAA,EACzE,CAA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