codegraph-java 0.1.0

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 (866) hide show
  1. package/README.md +131 -0
  2. package/dist/base-graph/index.d.ts +57 -0
  3. package/dist/base-graph/index.d.ts.map +1 -0
  4. package/dist/base-graph/index.js +175 -0
  5. package/dist/base-graph/index.js.map +1 -0
  6. package/dist/bin/codegraph.d.ts +28 -0
  7. package/dist/bin/codegraph.d.ts.map +1 -0
  8. package/dist/bin/codegraph.js +2615 -0
  9. package/dist/bin/codegraph.js.map +1 -0
  10. package/dist/bin/command-supervision.d.ts +49 -0
  11. package/dist/bin/command-supervision.d.ts.map +1 -0
  12. package/dist/bin/command-supervision.js +95 -0
  13. package/dist/bin/command-supervision.js.map +1 -0
  14. package/dist/bin/fatal-handler.d.ts +20 -0
  15. package/dist/bin/fatal-handler.d.ts.map +1 -0
  16. package/dist/bin/fatal-handler.js +118 -0
  17. package/dist/bin/fatal-handler.js.map +1 -0
  18. package/dist/bin/node-version-check.d.ts +45 -0
  19. package/dist/bin/node-version-check.d.ts.map +1 -0
  20. package/dist/bin/node-version-check.js +98 -0
  21. package/dist/bin/node-version-check.js.map +1 -0
  22. package/dist/bin/uninstall.d.ts +14 -0
  23. package/dist/bin/uninstall.d.ts.map +1 -0
  24. package/dist/bin/uninstall.js +36 -0
  25. package/dist/bin/uninstall.js.map +1 -0
  26. package/dist/context/formatter.d.ts +36 -0
  27. package/dist/context/formatter.d.ts.map +1 -0
  28. package/dist/context/formatter.js +269 -0
  29. package/dist/context/formatter.js.map +1 -0
  30. package/dist/context/index.d.ts +131 -0
  31. package/dist/context/index.d.ts.map +1 -0
  32. package/dist/context/index.js +1378 -0
  33. package/dist/context/index.js.map +1 -0
  34. package/dist/context/markers.d.ts +19 -0
  35. package/dist/context/markers.d.ts.map +1 -0
  36. package/dist/context/markers.js +22 -0
  37. package/dist/context/markers.js.map +1 -0
  38. package/dist/db/index.d.ts +380 -0
  39. package/dist/db/index.d.ts.map +1 -0
  40. package/dist/db/index.js +854 -0
  41. package/dist/db/index.js.map +1 -0
  42. package/dist/db/migrations.d.ts +44 -0
  43. package/dist/db/migrations.d.ts.map +1 -0
  44. package/dist/db/migrations.js +255 -0
  45. package/dist/db/migrations.js.map +1 -0
  46. package/dist/db/queries.d.ts +1060 -0
  47. package/dist/db/queries.d.ts.map +1 -0
  48. package/dist/db/queries.js +3191 -0
  49. package/dist/db/queries.js.map +1 -0
  50. package/dist/db/schema.sql +209 -0
  51. package/dist/db/sqlite-adapter.d.ts +55 -0
  52. package/dist/db/sqlite-adapter.d.ts.map +1 -0
  53. package/dist/db/sqlite-adapter.js +135 -0
  54. package/dist/db/sqlite-adapter.js.map +1 -0
  55. package/dist/db/wal-valve.d.ts +119 -0
  56. package/dist/db/wal-valve.d.ts.map +1 -0
  57. package/dist/db/wal-valve.js +290 -0
  58. package/dist/db/wal-valve.js.map +1 -0
  59. package/dist/directory.d.ts +213 -0
  60. package/dist/directory.d.ts.map +1 -0
  61. package/dist/directory.js +781 -0
  62. package/dist/directory.js.map +1 -0
  63. package/dist/errors.d.ts +150 -0
  64. package/dist/errors.d.ts.map +1 -0
  65. package/dist/errors.js +234 -0
  66. package/dist/errors.js.map +1 -0
  67. package/dist/extraction/extraction-version.d.ts +25 -0
  68. package/dist/extraction/extraction-version.d.ts.map +1 -0
  69. package/dist/extraction/extraction-version.js +28 -0
  70. package/dist/extraction/extraction-version.js.map +1 -0
  71. package/dist/extraction/function-ref.d.ts +118 -0
  72. package/dist/extraction/function-ref.d.ts.map +1 -0
  73. package/dist/extraction/function-ref.js +746 -0
  74. package/dist/extraction/function-ref.js.map +1 -0
  75. package/dist/extraction/generated-detection.d.ts +66 -0
  76. package/dist/extraction/generated-detection.d.ts.map +1 -0
  77. package/dist/extraction/generated-detection.js +248 -0
  78. package/dist/extraction/generated-detection.js.map +1 -0
  79. package/dist/extraction/grammars.d.ts +148 -0
  80. package/dist/extraction/grammars.d.ts.map +1 -0
  81. package/dist/extraction/grammars.js +558 -0
  82. package/dist/extraction/grammars.js.map +1 -0
  83. package/dist/extraction/index.d.ts +367 -0
  84. package/dist/extraction/index.d.ts.map +1 -0
  85. package/dist/extraction/index.js +2833 -0
  86. package/dist/extraction/index.js.map +1 -0
  87. package/dist/extraction/kernel/decode.d.ts +9 -0
  88. package/dist/extraction/kernel/decode.d.ts.map +1 -0
  89. package/dist/extraction/kernel/decode.js +162 -0
  90. package/dist/extraction/kernel/decode.js.map +1 -0
  91. package/dist/extraction/kernel/index.d.ts +64 -0
  92. package/dist/extraction/kernel/index.d.ts.map +1 -0
  93. package/dist/extraction/kernel/index.js +204 -0
  94. package/dist/extraction/kernel/index.js.map +1 -0
  95. package/dist/extraction/kernel/layout.d.ts +101 -0
  96. package/dist/extraction/kernel/layout.d.ts.map +1 -0
  97. package/dist/extraction/kernel/layout.js +104 -0
  98. package/dist/extraction/kernel/layout.js.map +1 -0
  99. package/dist/extraction/kernel/loader.d.ts +103 -0
  100. package/dist/extraction/kernel/loader.d.ts.map +1 -0
  101. package/dist/extraction/kernel/loader.js +146 -0
  102. package/dist/extraction/kernel/loader.js.map +1 -0
  103. package/dist/extraction/languages/c-cpp.d.ts +124 -0
  104. package/dist/extraction/languages/c-cpp.d.ts.map +1 -0
  105. package/dist/extraction/languages/c-cpp.js +1689 -0
  106. package/dist/extraction/languages/c-cpp.js.map +1 -0
  107. package/dist/extraction/languages/index.d.ts +11 -0
  108. package/dist/extraction/languages/index.d.ts.map +1 -0
  109. package/dist/extraction/languages/index.js +15 -0
  110. package/dist/extraction/languages/index.js.map +1 -0
  111. package/dist/extraction/languages/java.d.ts +3 -0
  112. package/dist/extraction/languages/java.d.ts.map +1 -0
  113. package/dist/extraction/languages/java.js +315 -0
  114. package/dist/extraction/languages/java.js.map +1 -0
  115. package/dist/extraction/languages/rust.d.ts +23 -0
  116. package/dist/extraction/languages/rust.d.ts.map +1 -0
  117. package/dist/extraction/languages/rust.js +169 -0
  118. package/dist/extraction/languages/rust.js.map +1 -0
  119. package/dist/extraction/parse-pool.d.ts +167 -0
  120. package/dist/extraction/parse-pool.d.ts.map +1 -0
  121. package/dist/extraction/parse-pool.js +421 -0
  122. package/dist/extraction/parse-pool.js.map +1 -0
  123. package/dist/extraction/parse-worker.d.ts +8 -0
  124. package/dist/extraction/parse-worker.d.ts.map +1 -0
  125. package/dist/extraction/parse-worker.js +138 -0
  126. package/dist/extraction/parse-worker.js.map +1 -0
  127. package/dist/extraction/store-worker.d.ts +24 -0
  128. package/dist/extraction/store-worker.d.ts.map +1 -0
  129. package/dist/extraction/store-worker.js +139 -0
  130. package/dist/extraction/store-worker.js.map +1 -0
  131. package/dist/extraction/store-writer.d.ts +63 -0
  132. package/dist/extraction/store-writer.d.ts.map +1 -0
  133. package/dist/extraction/store-writer.js +174 -0
  134. package/dist/extraction/store-writer.js.map +1 -0
  135. package/dist/extraction/syntax-tokens.d.ts +103 -0
  136. package/dist/extraction/syntax-tokens.d.ts.map +1 -0
  137. package/dist/extraction/syntax-tokens.js +381 -0
  138. package/dist/extraction/syntax-tokens.js.map +1 -0
  139. package/dist/extraction/tree-sitter-helpers.d.ts +28 -0
  140. package/dist/extraction/tree-sitter-helpers.d.ts.map +1 -0
  141. package/dist/extraction/tree-sitter-helpers.js +153 -0
  142. package/dist/extraction/tree-sitter-helpers.js.map +1 -0
  143. package/dist/extraction/tree-sitter-types.d.ts +260 -0
  144. package/dist/extraction/tree-sitter-types.d.ts.map +1 -0
  145. package/dist/extraction/tree-sitter-types.js +10 -0
  146. package/dist/extraction/tree-sitter-types.js.map +1 -0
  147. package/dist/extraction/tree-sitter.d.ts +745 -0
  148. package/dist/extraction/tree-sitter.d.ts.map +1 -0
  149. package/dist/extraction/tree-sitter.js +6725 -0
  150. package/dist/extraction/tree-sitter.js.map +1 -0
  151. package/dist/extraction/wasm/tree-sitter-java.wasm +0 -0
  152. package/dist/extraction/wasm-runtime-flags.d.ts +53 -0
  153. package/dist/extraction/wasm-runtime-flags.d.ts.map +1 -0
  154. package/dist/extraction/wasm-runtime-flags.js +130 -0
  155. package/dist/extraction/wasm-runtime-flags.js.map +1 -0
  156. package/dist/graph/branch-guards.d.ts +248 -0
  157. package/dist/graph/branch-guards.d.ts.map +1 -0
  158. package/dist/graph/branch-guards.js +2231 -0
  159. package/dist/graph/branch-guards.js.map +1 -0
  160. package/dist/graph/dead-code.d.ts +251 -0
  161. package/dist/graph/dead-code.d.ts.map +1 -0
  162. package/dist/graph/dead-code.js +756 -0
  163. package/dist/graph/dead-code.js.map +1 -0
  164. package/dist/graph/dynamic-boundary-report.d.ts +121 -0
  165. package/dist/graph/dynamic-boundary-report.d.ts.map +1 -0
  166. package/dist/graph/dynamic-boundary-report.js +283 -0
  167. package/dist/graph/dynamic-boundary-report.js.map +1 -0
  168. package/dist/graph/index.d.ts +12 -0
  169. package/dist/graph/index.d.ts.map +1 -0
  170. package/dist/graph/index.js +28 -0
  171. package/dist/graph/index.js.map +1 -0
  172. package/dist/graph/named-symbol-flow.d.ts +153 -0
  173. package/dist/graph/named-symbol-flow.d.ts.map +1 -0
  174. package/dist/graph/named-symbol-flow.js +609 -0
  175. package/dist/graph/named-symbol-flow.js.map +1 -0
  176. package/dist/graph/queries.d.ts +106 -0
  177. package/dist/graph/queries.d.ts.map +1 -0
  178. package/dist/graph/queries.js +341 -0
  179. package/dist/graph/queries.js.map +1 -0
  180. package/dist/graph/traversal.d.ts +127 -0
  181. package/dist/graph/traversal.d.ts.map +1 -0
  182. package/dist/graph/traversal.js +599 -0
  183. package/dist/graph/traversal.js.map +1 -0
  184. package/dist/graph/type-hierarchy.d.ts +155 -0
  185. package/dist/graph/type-hierarchy.d.ts.map +1 -0
  186. package/dist/graph/type-hierarchy.js +382 -0
  187. package/dist/graph/type-hierarchy.js.map +1 -0
  188. package/dist/index.d.ts +886 -0
  189. package/dist/index.d.ts.map +1 -0
  190. package/dist/index.js +2019 -0
  191. package/dist/index.js.map +1 -0
  192. package/dist/installer/beta-signup.d.ts +54 -0
  193. package/dist/installer/beta-signup.d.ts.map +1 -0
  194. package/dist/installer/beta-signup.js +178 -0
  195. package/dist/installer/beta-signup.js.map +1 -0
  196. package/dist/installer/config-writer.d.ts +28 -0
  197. package/dist/installer/config-writer.d.ts.map +1 -0
  198. package/dist/installer/config-writer.js +91 -0
  199. package/dist/installer/config-writer.js.map +1 -0
  200. package/dist/installer/index.d.ts +143 -0
  201. package/dist/installer/index.d.ts.map +1 -0
  202. package/dist/installer/index.js +632 -0
  203. package/dist/installer/index.js.map +1 -0
  204. package/dist/installer/instructions-template.d.ts +41 -0
  205. package/dist/installer/instructions-template.d.ts.map +1 -0
  206. package/dist/installer/instructions-template.js +53 -0
  207. package/dist/installer/instructions-template.js.map +1 -0
  208. package/dist/installer/targets/antigravity.d.ts +57 -0
  209. package/dist/installer/targets/antigravity.d.ts.map +1 -0
  210. package/dist/installer/targets/antigravity.js +308 -0
  211. package/dist/installer/targets/antigravity.js.map +1 -0
  212. package/dist/installer/targets/claude.d.ts +62 -0
  213. package/dist/installer/targets/claude.d.ts.map +1 -0
  214. package/dist/installer/targets/claude.js +486 -0
  215. package/dist/installer/targets/claude.js.map +1 -0
  216. package/dist/installer/targets/codex.d.ts +32 -0
  217. package/dist/installer/targets/codex.d.ts.map +1 -0
  218. package/dist/installer/targets/codex.js +202 -0
  219. package/dist/installer/targets/codex.js.map +1 -0
  220. package/dist/installer/targets/copilot-cli.d.ts +32 -0
  221. package/dist/installer/targets/copilot-cli.d.ts.map +1 -0
  222. package/dist/installer/targets/copilot-cli.js +209 -0
  223. package/dist/installer/targets/copilot-cli.js.map +1 -0
  224. package/dist/installer/targets/copilot-jetbrains.d.ts +42 -0
  225. package/dist/installer/targets/copilot-jetbrains.d.ts.map +1 -0
  226. package/dist/installer/targets/copilot-jetbrains.js +238 -0
  227. package/dist/installer/targets/copilot-jetbrains.js.map +1 -0
  228. package/dist/installer/targets/copilot-vscode.d.ts +47 -0
  229. package/dist/installer/targets/copilot-vscode.d.ts.map +1 -0
  230. package/dist/installer/targets/copilot-vscode.js +219 -0
  231. package/dist/installer/targets/copilot-vscode.js.map +1 -0
  232. package/dist/installer/targets/cursor.d.ts +35 -0
  233. package/dist/installer/targets/cursor.d.ts.map +1 -0
  234. package/dist/installer/targets/cursor.js +254 -0
  235. package/dist/installer/targets/cursor.js.map +1 -0
  236. package/dist/installer/targets/gemini.d.ts +26 -0
  237. package/dist/installer/targets/gemini.d.ts.map +1 -0
  238. package/dist/installer/targets/gemini.js +165 -0
  239. package/dist/installer/targets/gemini.js.map +1 -0
  240. package/dist/installer/targets/hermes.d.ts +18 -0
  241. package/dist/installer/targets/hermes.d.ts.map +1 -0
  242. package/dist/installer/targets/hermes.js +359 -0
  243. package/dist/installer/targets/hermes.js.map +1 -0
  244. package/dist/installer/targets/kiro.d.ts +27 -0
  245. package/dist/installer/targets/kiro.d.ts.map +1 -0
  246. package/dist/installer/targets/kiro.js +178 -0
  247. package/dist/installer/targets/kiro.js.map +1 -0
  248. package/dist/installer/targets/opencode.d.ts +38 -0
  249. package/dist/installer/targets/opencode.d.ts.map +1 -0
  250. package/dist/installer/targets/opencode.js +288 -0
  251. package/dist/installer/targets/opencode.js.map +1 -0
  252. package/dist/installer/targets/registry.d.ts +35 -0
  253. package/dist/installer/targets/registry.d.ts.map +1 -0
  254. package/dist/installer/targets/registry.js +101 -0
  255. package/dist/installer/targets/registry.js.map +1 -0
  256. package/dist/installer/targets/shared.d.ts +101 -0
  257. package/dist/installer/targets/shared.d.ts.map +1 -0
  258. package/dist/installer/targets/shared.js +264 -0
  259. package/dist/installer/targets/shared.js.map +1 -0
  260. package/dist/installer/targets/toml.d.ts +53 -0
  261. package/dist/installer/targets/toml.d.ts.map +1 -0
  262. package/dist/installer/targets/toml.js +226 -0
  263. package/dist/installer/targets/toml.js.map +1 -0
  264. package/dist/installer/targets/trae.d.ts +30 -0
  265. package/dist/installer/targets/trae.d.ts.map +1 -0
  266. package/dist/installer/targets/trae.js +164 -0
  267. package/dist/installer/targets/trae.js.map +1 -0
  268. package/dist/installer/targets/types.d.ts +108 -0
  269. package/dist/installer/targets/types.d.ts.map +1 -0
  270. package/dist/installer/targets/types.js +16 -0
  271. package/dist/installer/targets/types.js.map +1 -0
  272. package/dist/installer/targets/workbuddy.d.ts +29 -0
  273. package/dist/installer/targets/workbuddy.d.ts.map +1 -0
  274. package/dist/installer/targets/workbuddy.js +163 -0
  275. package/dist/installer/targets/workbuddy.js.map +1 -0
  276. package/dist/mcp/daemon-manager.d.ts +42 -0
  277. package/dist/mcp/daemon-manager.d.ts.map +1 -0
  278. package/dist/mcp/daemon-manager.js +129 -0
  279. package/dist/mcp/daemon-manager.js.map +1 -0
  280. package/dist/mcp/daemon-paths.d.ts +79 -0
  281. package/dist/mcp/daemon-paths.d.ts.map +1 -0
  282. package/dist/mcp/daemon-paths.js +219 -0
  283. package/dist/mcp/daemon-paths.js.map +1 -0
  284. package/dist/mcp/daemon-registry.d.ts +57 -0
  285. package/dist/mcp/daemon-registry.d.ts.map +1 -0
  286. package/dist/mcp/daemon-registry.js +281 -0
  287. package/dist/mcp/daemon-registry.js.map +1 -0
  288. package/dist/mcp/daemon.d.ts +293 -0
  289. package/dist/mcp/daemon.d.ts.map +1 -0
  290. package/dist/mcp/daemon.js +864 -0
  291. package/dist/mcp/daemon.js.map +1 -0
  292. package/dist/mcp/dynamic-boundaries.d.ts +41 -0
  293. package/dist/mcp/dynamic-boundaries.d.ts.map +1 -0
  294. package/dist/mcp/dynamic-boundaries.js +360 -0
  295. package/dist/mcp/dynamic-boundaries.js.map +1 -0
  296. package/dist/mcp/early-ppid.d.ts +26 -0
  297. package/dist/mcp/early-ppid.d.ts.map +1 -0
  298. package/dist/mcp/early-ppid.js +29 -0
  299. package/dist/mcp/early-ppid.js.map +1 -0
  300. package/dist/mcp/engine.d.ts +125 -0
  301. package/dist/mcp/engine.d.ts.map +1 -0
  302. package/dist/mcp/engine.js +392 -0
  303. package/dist/mcp/engine.js.map +1 -0
  304. package/dist/mcp/explore-dedup.d.ts +137 -0
  305. package/dist/mcp/explore-dedup.d.ts.map +1 -0
  306. package/dist/mcp/explore-dedup.js +236 -0
  307. package/dist/mcp/explore-dedup.js.map +1 -0
  308. package/dist/mcp/explore-diagnostics.d.ts +289 -0
  309. package/dist/mcp/explore-diagnostics.d.ts.map +1 -0
  310. package/dist/mcp/explore-diagnostics.js +558 -0
  311. package/dist/mcp/explore-diagnostics.js.map +1 -0
  312. package/dist/mcp/explore-session-state.d.ts +217 -0
  313. package/dist/mcp/explore-session-state.d.ts.map +1 -0
  314. package/dist/mcp/explore-session-state.js +322 -0
  315. package/dist/mcp/explore-session-state.js.map +1 -0
  316. package/dist/mcp/index.d.ts +137 -0
  317. package/dist/mcp/index.d.ts.map +1 -0
  318. package/dist/mcp/index.js +567 -0
  319. package/dist/mcp/index.js.map +1 -0
  320. package/dist/mcp/liveness-watchdog.d.ts +35 -0
  321. package/dist/mcp/liveness-watchdog.d.ts.map +1 -0
  322. package/dist/mcp/liveness-watchdog.js +269 -0
  323. package/dist/mcp/liveness-watchdog.js.map +1 -0
  324. package/dist/mcp/ppid-watchdog.d.ts +62 -0
  325. package/dist/mcp/ppid-watchdog.d.ts.map +1 -0
  326. package/dist/mcp/ppid-watchdog.js +64 -0
  327. package/dist/mcp/ppid-watchdog.js.map +1 -0
  328. package/dist/mcp/proxy.d.ts +87 -0
  329. package/dist/mcp/proxy.d.ts.map +1 -0
  330. package/dist/mcp/proxy.js +672 -0
  331. package/dist/mcp/proxy.js.map +1 -0
  332. package/dist/mcp/query-pool.d.ts +108 -0
  333. package/dist/mcp/query-pool.d.ts.map +1 -0
  334. package/dist/mcp/query-pool.js +315 -0
  335. package/dist/mcp/query-pool.js.map +1 -0
  336. package/dist/mcp/query-worker.d.ts +24 -0
  337. package/dist/mcp/query-worker.d.ts.map +1 -0
  338. package/dist/mcp/query-worker.js +87 -0
  339. package/dist/mcp/query-worker.js.map +1 -0
  340. package/dist/mcp/server-instructions.d.ts +34 -0
  341. package/dist/mcp/server-instructions.d.ts.map +1 -0
  342. package/dist/mcp/server-instructions.js +111 -0
  343. package/dist/mcp/server-instructions.js.map +1 -0
  344. package/dist/mcp/session.d.ts +109 -0
  345. package/dist/mcp/session.d.ts.map +1 -0
  346. package/dist/mcp/session.js +380 -0
  347. package/dist/mcp/session.js.map +1 -0
  348. package/dist/mcp/startup-handshake.d.ts +44 -0
  349. package/dist/mcp/startup-handshake.d.ts.map +1 -0
  350. package/dist/mcp/startup-handshake.js +73 -0
  351. package/dist/mcp/startup-handshake.js.map +1 -0
  352. package/dist/mcp/stdin-teardown.d.ts +27 -0
  353. package/dist/mcp/stdin-teardown.d.ts.map +1 -0
  354. package/dist/mcp/stdin-teardown.js +49 -0
  355. package/dist/mcp/stdin-teardown.js.map +1 -0
  356. package/dist/mcp/tools.d.ts +877 -0
  357. package/dist/mcp/tools.d.ts.map +1 -0
  358. package/dist/mcp/tools.js +6371 -0
  359. package/dist/mcp/tools.js.map +1 -0
  360. package/dist/mcp/transport.d.ts +188 -0
  361. package/dist/mcp/transport.d.ts.map +1 -0
  362. package/dist/mcp/transport.js +377 -0
  363. package/dist/mcp/transport.js.map +1 -0
  364. package/dist/mcp/version.d.ts +19 -0
  365. package/dist/mcp/version.d.ts.map +1 -0
  366. package/dist/mcp/version.js +71 -0
  367. package/dist/mcp/version.js.map +1 -0
  368. package/dist/project-config.d.ts +158 -0
  369. package/dist/project-config.d.ts.map +1 -0
  370. package/dist/project-config.js +489 -0
  371. package/dist/project-config.js.map +1 -0
  372. package/dist/resolution/c-fnptr-synthesizer.d.ts +6 -0
  373. package/dist/resolution/c-fnptr-synthesizer.d.ts.map +1 -0
  374. package/dist/resolution/c-fnptr-synthesizer.js +1506 -0
  375. package/dist/resolution/c-fnptr-synthesizer.js.map +1 -0
  376. package/dist/resolution/callback-synthesizer.d.ts +59 -0
  377. package/dist/resolution/callback-synthesizer.d.ts.map +1 -0
  378. package/dist/resolution/callback-synthesizer.js +4066 -0
  379. package/dist/resolution/callback-synthesizer.js.map +1 -0
  380. package/dist/resolution/cooperative-yield.d.ts +40 -0
  381. package/dist/resolution/cooperative-yield.d.ts.map +1 -0
  382. package/dist/resolution/cooperative-yield.js +44 -0
  383. package/dist/resolution/cooperative-yield.js.map +1 -0
  384. package/dist/resolution/expo-router-synthesizer.d.ts +32 -0
  385. package/dist/resolution/expo-router-synthesizer.d.ts.map +1 -0
  386. package/dist/resolution/expo-router-synthesizer.js +189 -0
  387. package/dist/resolution/expo-router-synthesizer.js.map +1 -0
  388. package/dist/resolution/frameworks/astro.d.ts +9 -0
  389. package/dist/resolution/frameworks/astro.d.ts.map +1 -0
  390. package/dist/resolution/frameworks/astro.js +169 -0
  391. package/dist/resolution/frameworks/astro.js.map +1 -0
  392. package/dist/resolution/frameworks/cargo-workspace.d.ts +18 -0
  393. package/dist/resolution/frameworks/cargo-workspace.d.ts.map +1 -0
  394. package/dist/resolution/frameworks/cargo-workspace.js +225 -0
  395. package/dist/resolution/frameworks/cargo-workspace.js.map +1 -0
  396. package/dist/resolution/frameworks/cics.d.ts +20 -0
  397. package/dist/resolution/frameworks/cics.d.ts.map +1 -0
  398. package/dist/resolution/frameworks/cics.js +90 -0
  399. package/dist/resolution/frameworks/cics.js.map +1 -0
  400. package/dist/resolution/frameworks/csharp.d.ts +8 -0
  401. package/dist/resolution/frameworks/csharp.d.ts.map +1 -0
  402. package/dist/resolution/frameworks/csharp.js +335 -0
  403. package/dist/resolution/frameworks/csharp.js.map +1 -0
  404. package/dist/resolution/frameworks/drupal.d.ts +51 -0
  405. package/dist/resolution/frameworks/drupal.d.ts.map +1 -0
  406. package/dist/resolution/frameworks/drupal.js +367 -0
  407. package/dist/resolution/frameworks/drupal.js.map +1 -0
  408. package/dist/resolution/frameworks/expo-modules.d.ts +3 -0
  409. package/dist/resolution/frameworks/expo-modules.d.ts.map +1 -0
  410. package/dist/resolution/frameworks/expo-modules.js +148 -0
  411. package/dist/resolution/frameworks/expo-modules.js.map +1 -0
  412. package/dist/resolution/frameworks/expo-router.d.ts +189 -0
  413. package/dist/resolution/frameworks/expo-router.d.ts.map +1 -0
  414. package/dist/resolution/frameworks/expo-router.js +785 -0
  415. package/dist/resolution/frameworks/expo-router.js.map +1 -0
  416. package/dist/resolution/frameworks/express.d.ts +8 -0
  417. package/dist/resolution/frameworks/express.d.ts.map +1 -0
  418. package/dist/resolution/frameworks/express.js +540 -0
  419. package/dist/resolution/frameworks/express.js.map +1 -0
  420. package/dist/resolution/frameworks/fabric.d.ts +3 -0
  421. package/dist/resolution/frameworks/fabric.d.ts.map +1 -0
  422. package/dist/resolution/frameworks/fabric.js +354 -0
  423. package/dist/resolution/frameworks/fabric.js.map +1 -0
  424. package/dist/resolution/frameworks/go.d.ts +8 -0
  425. package/dist/resolution/frameworks/go.d.ts.map +1 -0
  426. package/dist/resolution/frameworks/go.js +184 -0
  427. package/dist/resolution/frameworks/go.js.map +1 -0
  428. package/dist/resolution/frameworks/goframe.d.ts +41 -0
  429. package/dist/resolution/frameworks/goframe.d.ts.map +1 -0
  430. package/dist/resolution/frameworks/goframe.js +112 -0
  431. package/dist/resolution/frameworks/goframe.js.map +1 -0
  432. package/dist/resolution/frameworks/index.d.ts +30 -0
  433. package/dist/resolution/frameworks/index.d.ts.map +1 -0
  434. package/dist/resolution/frameworks/index.js +72 -0
  435. package/dist/resolution/frameworks/index.js.map +1 -0
  436. package/dist/resolution/frameworks/java.d.ts +8 -0
  437. package/dist/resolution/frameworks/java.d.ts.map +1 -0
  438. package/dist/resolution/frameworks/java.js +517 -0
  439. package/dist/resolution/frameworks/java.js.map +1 -0
  440. package/dist/resolution/frameworks/laravel.d.ts +13 -0
  441. package/dist/resolution/frameworks/laravel.d.ts.map +1 -0
  442. package/dist/resolution/frameworks/laravel.js +257 -0
  443. package/dist/resolution/frameworks/laravel.js.map +1 -0
  444. package/dist/resolution/frameworks/nestjs.d.ts +26 -0
  445. package/dist/resolution/frameworks/nestjs.d.ts.map +1 -0
  446. package/dist/resolution/frameworks/nestjs.js +690 -0
  447. package/dist/resolution/frameworks/nestjs.js.map +1 -0
  448. package/dist/resolution/frameworks/nextjs.d.ts +76 -0
  449. package/dist/resolution/frameworks/nextjs.d.ts.map +1 -0
  450. package/dist/resolution/frameworks/nextjs.js +328 -0
  451. package/dist/resolution/frameworks/nextjs.js.map +1 -0
  452. package/dist/resolution/frameworks/object-literal.d.ts +32 -0
  453. package/dist/resolution/frameworks/object-literal.d.ts.map +1 -0
  454. package/dist/resolution/frameworks/object-literal.js +139 -0
  455. package/dist/resolution/frameworks/object-literal.js.map +1 -0
  456. package/dist/resolution/frameworks/package-deps.d.ts +14 -0
  457. package/dist/resolution/frameworks/package-deps.d.ts.map +1 -0
  458. package/dist/resolution/frameworks/package-deps.js +78 -0
  459. package/dist/resolution/frameworks/package-deps.js.map +1 -0
  460. package/dist/resolution/frameworks/play.d.ts +19 -0
  461. package/dist/resolution/frameworks/play.d.ts.map +1 -0
  462. package/dist/resolution/frameworks/play.js +111 -0
  463. package/dist/resolution/frameworks/play.js.map +1 -0
  464. package/dist/resolution/frameworks/python.d.ts +10 -0
  465. package/dist/resolution/frameworks/python.d.ts.map +1 -0
  466. package/dist/resolution/frameworks/python.js +566 -0
  467. package/dist/resolution/frameworks/python.js.map +1 -0
  468. package/dist/resolution/frameworks/react-native.d.ts +29 -0
  469. package/dist/resolution/frameworks/react-native.d.ts.map +1 -0
  470. package/dist/resolution/frameworks/react-native.js +549 -0
  471. package/dist/resolution/frameworks/react-native.js.map +1 -0
  472. package/dist/resolution/frameworks/react-router.d.ts +46 -0
  473. package/dist/resolution/frameworks/react-router.d.ts.map +1 -0
  474. package/dist/resolution/frameworks/react-router.js +187 -0
  475. package/dist/resolution/frameworks/react-router.js.map +1 -0
  476. package/dist/resolution/frameworks/react.d.ts +9 -0
  477. package/dist/resolution/frameworks/react.d.ts.map +1 -0
  478. package/dist/resolution/frameworks/react.js +257 -0
  479. package/dist/resolution/frameworks/react.js.map +1 -0
  480. package/dist/resolution/frameworks/ruby.d.ts +8 -0
  481. package/dist/resolution/frameworks/ruby.d.ts.map +1 -0
  482. package/dist/resolution/frameworks/ruby.js +302 -0
  483. package/dist/resolution/frameworks/ruby.js.map +1 -0
  484. package/dist/resolution/frameworks/rust.d.ts +8 -0
  485. package/dist/resolution/frameworks/rust.d.ts.map +1 -0
  486. package/dist/resolution/frameworks/rust.js +304 -0
  487. package/dist/resolution/frameworks/rust.js.map +1 -0
  488. package/dist/resolution/frameworks/svelte.d.ts +9 -0
  489. package/dist/resolution/frameworks/svelte.d.ts.map +1 -0
  490. package/dist/resolution/frameworks/svelte.js +258 -0
  491. package/dist/resolution/frameworks/svelte.js.map +1 -0
  492. package/dist/resolution/frameworks/sveltekit-router.d.ts +36 -0
  493. package/dist/resolution/frameworks/sveltekit-router.d.ts.map +1 -0
  494. package/dist/resolution/frameworks/sveltekit-router.js +156 -0
  495. package/dist/resolution/frameworks/sveltekit-router.js.map +1 -0
  496. package/dist/resolution/frameworks/swift-objc.d.ts +37 -0
  497. package/dist/resolution/frameworks/swift-objc.d.ts.map +1 -0
  498. package/dist/resolution/frameworks/swift-objc.js +252 -0
  499. package/dist/resolution/frameworks/swift-objc.js.map +1 -0
  500. package/dist/resolution/frameworks/swift.d.ts +10 -0
  501. package/dist/resolution/frameworks/swift.d.ts.map +1 -0
  502. package/dist/resolution/frameworks/swift.js +410 -0
  503. package/dist/resolution/frameworks/swift.js.map +1 -0
  504. package/dist/resolution/frameworks/tanstack-router.d.ts +84 -0
  505. package/dist/resolution/frameworks/tanstack-router.d.ts.map +1 -0
  506. package/dist/resolution/frameworks/tanstack-router.js +437 -0
  507. package/dist/resolution/frameworks/tanstack-router.js.map +1 -0
  508. package/dist/resolution/frameworks/terraform.d.ts +38 -0
  509. package/dist/resolution/frameworks/terraform.d.ts.map +1 -0
  510. package/dist/resolution/frameworks/terraform.js +277 -0
  511. package/dist/resolution/frameworks/terraform.js.map +1 -0
  512. package/dist/resolution/frameworks/vue-router.d.ts +82 -0
  513. package/dist/resolution/frameworks/vue-router.d.ts.map +1 -0
  514. package/dist/resolution/frameworks/vue-router.js +377 -0
  515. package/dist/resolution/frameworks/vue-router.js.map +1 -0
  516. package/dist/resolution/frameworks/vue.d.ts +9 -0
  517. package/dist/resolution/frameworks/vue.d.ts.map +1 -0
  518. package/dist/resolution/frameworks/vue.js +303 -0
  519. package/dist/resolution/frameworks/vue.js.map +1 -0
  520. package/dist/resolution/go-module.d.ts +26 -0
  521. package/dist/resolution/go-module.d.ts.map +1 -0
  522. package/dist/resolution/go-module.js +78 -0
  523. package/dist/resolution/go-module.js.map +1 -0
  524. package/dist/resolution/goframe-synthesizer.d.ts +29 -0
  525. package/dist/resolution/goframe-synthesizer.d.ts.map +1 -0
  526. package/dist/resolution/goframe-synthesizer.js +163 -0
  527. package/dist/resolution/goframe-synthesizer.js.map +1 -0
  528. package/dist/resolution/import-resolver.d.ts +84 -0
  529. package/dist/resolution/import-resolver.d.ts.map +1 -0
  530. package/dist/resolution/import-resolver.js +2240 -0
  531. package/dist/resolution/import-resolver.js.map +1 -0
  532. package/dist/resolution/index.d.ts +343 -0
  533. package/dist/resolution/index.d.ts.map +1 -0
  534. package/dist/resolution/index.js +2352 -0
  535. package/dist/resolution/index.js.map +1 -0
  536. package/dist/resolution/lru-cache.d.ts +24 -0
  537. package/dist/resolution/lru-cache.d.ts.map +1 -0
  538. package/dist/resolution/lru-cache.js +62 -0
  539. package/dist/resolution/lru-cache.js.map +1 -0
  540. package/dist/resolution/memory-budget.d.ts +48 -0
  541. package/dist/resolution/memory-budget.d.ts.map +1 -0
  542. package/dist/resolution/memory-budget.js +162 -0
  543. package/dist/resolution/memory-budget.js.map +1 -0
  544. package/dist/resolution/name-matcher.d.ts +153 -0
  545. package/dist/resolution/name-matcher.d.ts.map +1 -0
  546. package/dist/resolution/name-matcher.js +2412 -0
  547. package/dist/resolution/name-matcher.js.map +1 -0
  548. package/dist/resolution/next-router-synthesizer.d.ts +27 -0
  549. package/dist/resolution/next-router-synthesizer.d.ts.map +1 -0
  550. package/dist/resolution/next-router-synthesizer.js +113 -0
  551. package/dist/resolution/next-router-synthesizer.js.map +1 -0
  552. package/dist/resolution/path-aliases.d.ts +70 -0
  553. package/dist/resolution/path-aliases.d.ts.map +1 -0
  554. package/dist/resolution/path-aliases.js +346 -0
  555. package/dist/resolution/path-aliases.js.map +1 -0
  556. package/dist/resolution/react-router-synthesizer.d.ts +33 -0
  557. package/dist/resolution/react-router-synthesizer.d.ts.map +1 -0
  558. package/dist/resolution/react-router-synthesizer.js +126 -0
  559. package/dist/resolution/react-router-synthesizer.js.map +1 -0
  560. package/dist/resolution/resolver-pool.d.ts +106 -0
  561. package/dist/resolution/resolver-pool.d.ts.map +1 -0
  562. package/dist/resolution/resolver-pool.js +344 -0
  563. package/dist/resolution/resolver-pool.js.map +1 -0
  564. package/dist/resolution/resolver-worker.d.ts +17 -0
  565. package/dist/resolution/resolver-worker.d.ts.map +1 -0
  566. package/dist/resolution/resolver-worker.js +141 -0
  567. package/dist/resolution/resolver-worker.js.map +1 -0
  568. package/dist/resolution/strip-comments.d.ts +27 -0
  569. package/dist/resolution/strip-comments.d.ts.map +1 -0
  570. package/dist/resolution/strip-comments.js +492 -0
  571. package/dist/resolution/strip-comments.js.map +1 -0
  572. package/dist/resolution/sveltekit-synthesizer.d.ts +58 -0
  573. package/dist/resolution/sveltekit-synthesizer.d.ts.map +1 -0
  574. package/dist/resolution/sveltekit-synthesizer.js +173 -0
  575. package/dist/resolution/sveltekit-synthesizer.js.map +1 -0
  576. package/dist/resolution/swift-objc-bridge.d.ts +134 -0
  577. package/dist/resolution/swift-objc-bridge.d.ts.map +1 -0
  578. package/dist/resolution/swift-objc-bridge.js +256 -0
  579. package/dist/resolution/swift-objc-bridge.js.map +1 -0
  580. package/dist/resolution/synth-utils.d.ts +26 -0
  581. package/dist/resolution/synth-utils.d.ts.map +1 -0
  582. package/dist/resolution/synth-utils.js +75 -0
  583. package/dist/resolution/synth-utils.js.map +1 -0
  584. package/dist/resolution/tanstack-router-synthesizer.d.ts +31 -0
  585. package/dist/resolution/tanstack-router-synthesizer.d.ts.map +1 -0
  586. package/dist/resolution/tanstack-router-synthesizer.js +114 -0
  587. package/dist/resolution/tanstack-router-synthesizer.js.map +1 -0
  588. package/dist/resolution/tier-synthesizer.d.ts +48 -0
  589. package/dist/resolution/tier-synthesizer.d.ts.map +1 -0
  590. package/dist/resolution/tier-synthesizer.js +907 -0
  591. package/dist/resolution/tier-synthesizer.js.map +1 -0
  592. package/dist/resolution/types.d.ts +290 -0
  593. package/dist/resolution/types.d.ts.map +1 -0
  594. package/dist/resolution/types.js +8 -0
  595. package/dist/resolution/types.js.map +1 -0
  596. package/dist/resolution/vue-router-synthesizer.d.ts +30 -0
  597. package/dist/resolution/vue-router-synthesizer.d.ts.map +1 -0
  598. package/dist/resolution/vue-router-synthesizer.js +115 -0
  599. package/dist/resolution/vue-router-synthesizer.js.map +1 -0
  600. package/dist/resolution/workspace-packages.d.ts +58 -0
  601. package/dist/resolution/workspace-packages.d.ts.map +1 -0
  602. package/dist/resolution/workspace-packages.js +346 -0
  603. package/dist/resolution/workspace-packages.js.map +1 -0
  604. package/dist/search/identifier-segments.d.ts +70 -0
  605. package/dist/search/identifier-segments.d.ts.map +1 -0
  606. package/dist/search/identifier-segments.js +205 -0
  607. package/dist/search/identifier-segments.js.map +1 -0
  608. package/dist/search/query-parser.d.ts +57 -0
  609. package/dist/search/query-parser.d.ts.map +1 -0
  610. package/dist/search/query-parser.js +177 -0
  611. package/dist/search/query-parser.js.map +1 -0
  612. package/dist/search/query-paths.d.ts +57 -0
  613. package/dist/search/query-paths.d.ts.map +1 -0
  614. package/dist/search/query-paths.js +298 -0
  615. package/dist/search/query-paths.js.map +1 -0
  616. package/dist/search/query-utils.d.ts +102 -0
  617. package/dist/search/query-utils.d.ts.map +1 -0
  618. package/dist/search/query-utils.js +487 -0
  619. package/dist/search/query-utils.js.map +1 -0
  620. package/dist/sync/git-hooks.d.ts +45 -0
  621. package/dist/sync/git-hooks.d.ts.map +1 -0
  622. package/dist/sync/git-hooks.js +227 -0
  623. package/dist/sync/git-hooks.js.map +1 -0
  624. package/dist/sync/index.d.ts +19 -0
  625. package/dist/sync/index.d.ts.map +1 -0
  626. package/dist/sync/index.js +35 -0
  627. package/dist/sync/index.js.map +1 -0
  628. package/dist/sync/watch-policy.d.ts +48 -0
  629. package/dist/sync/watch-policy.d.ts.map +1 -0
  630. package/dist/sync/watch-policy.js +124 -0
  631. package/dist/sync/watch-policy.js.map +1 -0
  632. package/dist/sync/watcher.d.ts +401 -0
  633. package/dist/sync/watcher.d.ts.map +1 -0
  634. package/dist/sync/watcher.js +967 -0
  635. package/dist/sync/watcher.js.map +1 -0
  636. package/dist/sync/worktree.d.ts +63 -0
  637. package/dist/sync/worktree.d.ts.map +1 -0
  638. package/dist/sync/worktree.js +182 -0
  639. package/dist/sync/worktree.js.map +1 -0
  640. package/dist/telemetry/index.d.ts +143 -0
  641. package/dist/telemetry/index.d.ts.map +1 -0
  642. package/dist/telemetry/index.js +541 -0
  643. package/dist/telemetry/index.js.map +1 -0
  644. package/dist/types.d.ts +486 -0
  645. package/dist/types.d.ts.map +1 -0
  646. package/dist/types.js +118 -0
  647. package/dist/types.js.map +1 -0
  648. package/dist/ui/color.d.ts +21 -0
  649. package/dist/ui/color.d.ts.map +1 -0
  650. package/dist/ui/color.js +42 -0
  651. package/dist/ui/color.js.map +1 -0
  652. package/dist/ui/glyphs.d.ts +67 -0
  653. package/dist/ui/glyphs.d.ts.map +1 -0
  654. package/dist/ui/glyphs.js +125 -0
  655. package/dist/ui/glyphs.js.map +1 -0
  656. package/dist/ui/shimmer-progress.d.ts +11 -0
  657. package/dist/ui/shimmer-progress.d.ts.map +1 -0
  658. package/dist/ui/shimmer-progress.js +164 -0
  659. package/dist/ui/shimmer-progress.js.map +1 -0
  660. package/dist/ui/shimmer-worker.d.ts +2 -0
  661. package/dist/ui/shimmer-worker.d.ts.map +1 -0
  662. package/dist/ui/shimmer-worker.js +126 -0
  663. package/dist/ui/shimmer-worker.js.map +1 -0
  664. package/dist/ui/types.d.ts +15 -0
  665. package/dist/ui/types.d.ts.map +1 -0
  666. package/dist/ui/types.js +3 -0
  667. package/dist/ui/types.js.map +1 -0
  668. package/dist/ui-server/api/deadcode.d.ts +84 -0
  669. package/dist/ui-server/api/deadcode.d.ts.map +1 -0
  670. package/dist/ui-server/api/deadcode.js +136 -0
  671. package/dist/ui-server/api/deadcode.js.map +1 -0
  672. package/dist/ui-server/api/effects.d.ts +87 -0
  673. package/dist/ui-server/api/effects.d.ts.map +1 -0
  674. package/dist/ui-server/api/effects.js +499 -0
  675. package/dist/ui-server/api/effects.js.map +1 -0
  676. package/dist/ui-server/api/entrypoints.d.ts +86 -0
  677. package/dist/ui-server/api/entrypoints.d.ts.map +1 -0
  678. package/dist/ui-server/api/entrypoints.js +279 -0
  679. package/dist/ui-server/api/entrypoints.js.map +1 -0
  680. package/dist/ui-server/api/events.d.ts +183 -0
  681. package/dist/ui-server/api/events.d.ts.map +1 -0
  682. package/dist/ui-server/api/events.js +430 -0
  683. package/dist/ui-server/api/events.js.map +1 -0
  684. package/dist/ui-server/api/file.d.ts +66 -0
  685. package/dist/ui-server/api/file.d.ts.map +1 -0
  686. package/dist/ui-server/api/file.js +222 -0
  687. package/dist/ui-server/api/file.js.map +1 -0
  688. package/dist/ui-server/api/filecode.d.ts +126 -0
  689. package/dist/ui-server/api/filecode.d.ts.map +1 -0
  690. package/dist/ui-server/api/filecode.js +205 -0
  691. package/dist/ui-server/api/filecode.js.map +1 -0
  692. package/dist/ui-server/api/flow.d.ts +226 -0
  693. package/dist/ui-server/api/flow.d.ts.map +1 -0
  694. package/dist/ui-server/api/flow.js +611 -0
  695. package/dist/ui-server/api/flow.js.map +1 -0
  696. package/dist/ui-server/api/hierarchy.d.ts +81 -0
  697. package/dist/ui-server/api/hierarchy.d.ts.map +1 -0
  698. package/dist/ui-server/api/hierarchy.js +92 -0
  699. package/dist/ui-server/api/hierarchy.js.map +1 -0
  700. package/dist/ui-server/api/index.d.ts +90 -0
  701. package/dist/ui-server/api/index.d.ts.map +1 -0
  702. package/dist/ui-server/api/index.js +332 -0
  703. package/dist/ui-server/api/index.js.map +1 -0
  704. package/dist/ui-server/api/map.d.ts +187 -0
  705. package/dist/ui-server/api/map.d.ts.map +1 -0
  706. package/dist/ui-server/api/map.js +498 -0
  707. package/dist/ui-server/api/map.js.map +1 -0
  708. package/dist/ui-server/api/node.d.ts +81 -0
  709. package/dist/ui-server/api/node.d.ts.map +1 -0
  710. package/dist/ui-server/api/node.js +388 -0
  711. package/dist/ui-server/api/node.js.map +1 -0
  712. package/dist/ui-server/api/nodes.d.ts +25 -0
  713. package/dist/ui-server/api/nodes.d.ts.map +1 -0
  714. package/dist/ui-server/api/nodes.js +45 -0
  715. package/dist/ui-server/api/nodes.js.map +1 -0
  716. package/dist/ui-server/api/program.d.ts +139 -0
  717. package/dist/ui-server/api/program.d.ts.map +1 -0
  718. package/dist/ui-server/api/program.js +315 -0
  719. package/dist/ui-server/api/program.js.map +1 -0
  720. package/dist/ui-server/api/respond.d.ts +76 -0
  721. package/dist/ui-server/api/respond.d.ts.map +1 -0
  722. package/dist/ui-server/api/respond.js +186 -0
  723. package/dist/ui-server/api/respond.js.map +1 -0
  724. package/dist/ui-server/api/route-roots.d.ts +39 -0
  725. package/dist/ui-server/api/route-roots.d.ts.map +1 -0
  726. package/dist/ui-server/api/route-roots.js +96 -0
  727. package/dist/ui-server/api/route-roots.js.map +1 -0
  728. package/dist/ui-server/api/routes.d.ts +59 -0
  729. package/dist/ui-server/api/routes.d.ts.map +1 -0
  730. package/dist/ui-server/api/routes.js +112 -0
  731. package/dist/ui-server/api/routes.js.map +1 -0
  732. package/dist/ui-server/api/screens.d.ts +117 -0
  733. package/dist/ui-server/api/screens.d.ts.map +1 -0
  734. package/dist/ui-server/api/screens.js +611 -0
  735. package/dist/ui-server/api/screens.js.map +1 -0
  736. package/dist/ui-server/api/search.d.ts +29 -0
  737. package/dist/ui-server/api/search.d.ts.map +1 -0
  738. package/dist/ui-server/api/search.js +232 -0
  739. package/dist/ui-server/api/search.js.map +1 -0
  740. package/dist/ui-server/api/session.d.ts +52 -0
  741. package/dist/ui-server/api/session.d.ts.map +1 -0
  742. package/dist/ui-server/api/session.js +196 -0
  743. package/dist/ui-server/api/session.js.map +1 -0
  744. package/dist/ui-server/api/source.d.ts +200 -0
  745. package/dist/ui-server/api/source.d.ts.map +1 -0
  746. package/dist/ui-server/api/source.js +419 -0
  747. package/dist/ui-server/api/source.js.map +1 -0
  748. package/dist/ui-server/api/stats.d.ts +27 -0
  749. package/dist/ui-server/api/stats.d.ts.map +1 -0
  750. package/dist/ui-server/api/stats.js +164 -0
  751. package/dist/ui-server/api/stats.js.map +1 -0
  752. package/dist/ui-server/api/steps.d.ts +274 -0
  753. package/dist/ui-server/api/steps.d.ts.map +1 -0
  754. package/dist/ui-server/api/steps.js +1446 -0
  755. package/dist/ui-server/api/steps.js.map +1 -0
  756. package/dist/ui-server/api/trail-store.d.ts +142 -0
  757. package/dist/ui-server/api/trail-store.d.ts.map +1 -0
  758. package/dist/ui-server/api/trail-store.js +323 -0
  759. package/dist/ui-server/api/trail-store.js.map +1 -0
  760. package/dist/ui-server/api/trails.d.ts +163 -0
  761. package/dist/ui-server/api/trails.d.ts.map +1 -0
  762. package/dist/ui-server/api/trails.js +369 -0
  763. package/dist/ui-server/api/trails.js.map +1 -0
  764. package/dist/ui-server/api/when.d.ts +125 -0
  765. package/dist/ui-server/api/when.d.ts.map +1 -0
  766. package/dist/ui-server/api/when.js +251 -0
  767. package/dist/ui-server/api/when.js.map +1 -0
  768. package/dist/ui-server/api/wire.d.ts +179 -0
  769. package/dist/ui-server/api/wire.d.ts.map +1 -0
  770. package/dist/ui-server/api/wire.js +231 -0
  771. package/dist/ui-server/api/wire.js.map +1 -0
  772. package/dist/ui-server/assets.d.ts +40 -0
  773. package/dist/ui-server/assets.d.ts.map +1 -0
  774. package/dist/ui-server/assets.js +110 -0
  775. package/dist/ui-server/assets.js.map +1 -0
  776. package/dist/ui-server/constants.d.ts +32 -0
  777. package/dist/ui-server/constants.d.ts.map +1 -0
  778. package/dist/ui-server/constants.js +35 -0
  779. package/dist/ui-server/constants.js.map +1 -0
  780. package/dist/ui-server/highlight/index.d.ts +113 -0
  781. package/dist/ui-server/highlight/index.d.ts.map +1 -0
  782. package/dist/ui-server/highlight/index.js +307 -0
  783. package/dist/ui-server/highlight/index.js.map +1 -0
  784. package/dist/ui-server/highlight/languages.d.ts +36 -0
  785. package/dist/ui-server/highlight/languages.d.ts.map +1 -0
  786. package/dist/ui-server/highlight/languages.js +50 -0
  787. package/dist/ui-server/highlight/languages.js.map +1 -0
  788. package/dist/ui-server/index.d.ts +92 -0
  789. package/dist/ui-server/index.d.ts.map +1 -0
  790. package/dist/ui-server/index.js +399 -0
  791. package/dist/ui-server/index.js.map +1 -0
  792. package/dist/ui-server/open-browser.d.ts +31 -0
  793. package/dist/ui-server/open-browser.d.ts.map +1 -0
  794. package/dist/ui-server/open-browser.js +79 -0
  795. package/dist/ui-server/open-browser.js.map +1 -0
  796. package/dist/ui-server/security.d.ts +127 -0
  797. package/dist/ui-server/security.d.ts.map +1 -0
  798. package/dist/ui-server/security.js +332 -0
  799. package/dist/ui-server/security.js.map +1 -0
  800. package/dist/ui-server/static.d.ts +45 -0
  801. package/dist/ui-server/static.d.ts.map +1 -0
  802. package/dist/ui-server/static.js +165 -0
  803. package/dist/ui-server/static.js.map +1 -0
  804. package/dist/upgrade/index.d.ts +177 -0
  805. package/dist/upgrade/index.d.ts.map +1 -0
  806. package/dist/upgrade/index.js +665 -0
  807. package/dist/upgrade/index.js.map +1 -0
  808. package/dist/upgrade/remove-binary.d.ts +87 -0
  809. package/dist/upgrade/remove-binary.d.ts.map +1 -0
  810. package/dist/upgrade/remove-binary.js +289 -0
  811. package/dist/upgrade/remove-binary.js.map +1 -0
  812. package/dist/upgrade/update-check.d.ts +92 -0
  813. package/dist/upgrade/update-check.d.ts.map +1 -0
  814. package/dist/upgrade/update-check.js +258 -0
  815. package/dist/upgrade/update-check.js.map +1 -0
  816. package/dist/utils.d.ts +224 -0
  817. package/dist/utils.d.ts.map +1 -0
  818. package/dist/utils.js +583 -0
  819. package/dist/utils.js.map +1 -0
  820. package/dist/viewer/assets/archivo-latin-ext-wght-normal-C4zznr8T.woff2 +0 -0
  821. package/dist/viewer/assets/archivo-latin-wght-normal-E0tuGl4L.woff2 +0 -0
  822. package/dist/viewer/assets/archivo-vietnamese-wght-normal-XAtsl5Q_.woff2 +0 -0
  823. package/dist/viewer/assets/ibm-plex-mono-cyrillic-400-italic-2syK4fUT.woff +0 -0
  824. package/dist/viewer/assets/ibm-plex-mono-cyrillic-400-italic-CBJ8pzag.woff2 +0 -0
  825. package/dist/viewer/assets/ibm-plex-mono-cyrillic-400-normal-BSMlKf0J.woff2 +0 -0
  826. package/dist/viewer/assets/ibm-plex-mono-cyrillic-400-normal-CEL4l2ZJ.woff +0 -0
  827. package/dist/viewer/assets/ibm-plex-mono-cyrillic-500-normal-Ael50iVv.woff +0 -0
  828. package/dist/viewer/assets/ibm-plex-mono-cyrillic-500-normal-Bq9vWWag.woff2 +0 -0
  829. package/dist/viewer/assets/ibm-plex-mono-cyrillic-600-normal-CTOM6hUh.woff2 +0 -0
  830. package/dist/viewer/assets/ibm-plex-mono-cyrillic-600-normal-fLZuRloM.woff +0 -0
  831. package/dist/viewer/assets/ibm-plex-mono-cyrillic-ext-400-italic-B4oTjJdl.woff +0 -0
  832. package/dist/viewer/assets/ibm-plex-mono-cyrillic-ext-400-italic-CBjNughH.woff2 +0 -0
  833. package/dist/viewer/assets/ibm-plex-mono-cyrillic-ext-400-normal-DMdlQ8Kv.woff +0 -0
  834. package/dist/viewer/assets/ibm-plex-mono-cyrillic-ext-400-normal-xuaO2J-f.woff2 +0 -0
  835. package/dist/viewer/assets/ibm-plex-mono-cyrillic-ext-500-normal-BIfNGwUT.woff +0 -0
  836. package/dist/viewer/assets/ibm-plex-mono-cyrillic-ext-500-normal-BqneJy0T.woff2 +0 -0
  837. package/dist/viewer/assets/ibm-plex-mono-cyrillic-ext-600-normal-9HEixskS.woff +0 -0
  838. package/dist/viewer/assets/ibm-plex-mono-cyrillic-ext-600-normal-V-xxqcpd.woff2 +0 -0
  839. package/dist/viewer/assets/ibm-plex-mono-latin-400-italic-66oory27.woff +0 -0
  840. package/dist/viewer/assets/ibm-plex-mono-latin-400-italic-BqAiT5Ww.woff2 +0 -0
  841. package/dist/viewer/assets/ibm-plex-mono-latin-400-normal-CvHOgSBP.woff +0 -0
  842. package/dist/viewer/assets/ibm-plex-mono-latin-400-normal-DMJ8VG8y.woff2 +0 -0
  843. package/dist/viewer/assets/ibm-plex-mono-latin-500-normal-CB9ihrfo.woff +0 -0
  844. package/dist/viewer/assets/ibm-plex-mono-latin-500-normal-DSY6xOcd.woff2 +0 -0
  845. package/dist/viewer/assets/ibm-plex-mono-latin-600-normal-BgSNZQsw.woff2 +0 -0
  846. package/dist/viewer/assets/ibm-plex-mono-latin-600-normal-DWFSQ4vo.woff +0 -0
  847. package/dist/viewer/assets/ibm-plex-mono-latin-ext-400-italic-B7_fu1kp.woff2 +0 -0
  848. package/dist/viewer/assets/ibm-plex-mono-latin-ext-400-italic-Bg0ZHwF4.woff +0 -0
  849. package/dist/viewer/assets/ibm-plex-mono-latin-ext-400-normal-BmRBH3aV.woff2 +0 -0
  850. package/dist/viewer/assets/ibm-plex-mono-latin-ext-400-normal-D3D2R8hC.woff +0 -0
  851. package/dist/viewer/assets/ibm-plex-mono-latin-ext-500-normal-CAhNIIs5.woff2 +0 -0
  852. package/dist/viewer/assets/ibm-plex-mono-latin-ext-500-normal-CZ70TYgx.woff +0 -0
  853. package/dist/viewer/assets/ibm-plex-mono-latin-ext-600-normal-D38SheWl.woff2 +0 -0
  854. package/dist/viewer/assets/ibm-plex-mono-latin-ext-600-normal-DmB0ttJJ.woff +0 -0
  855. package/dist/viewer/assets/ibm-plex-mono-vietnamese-400-italic-D6eaYXMU.woff +0 -0
  856. package/dist/viewer/assets/ibm-plex-mono-vietnamese-400-italic-DRuN92E5.woff2 +0 -0
  857. package/dist/viewer/assets/ibm-plex-mono-vietnamese-400-normal-BulugwFq.woff2 +0 -0
  858. package/dist/viewer/assets/ibm-plex-mono-vietnamese-400-normal-DDuiU_S-.woff +0 -0
  859. package/dist/viewer/assets/ibm-plex-mono-vietnamese-500-normal-C8zxqsMH.woff +0 -0
  860. package/dist/viewer/assets/ibm-plex-mono-vietnamese-500-normal-DZ4AoWbu.woff2 +0 -0
  861. package/dist/viewer/assets/ibm-plex-mono-vietnamese-600-normal-D2EvbN8M.woff2 +0 -0
  862. package/dist/viewer/assets/ibm-plex-mono-vietnamese-600-normal-iLQfcSjf.woff +0 -0
  863. package/dist/viewer/assets/index-2IPslW5t.js +13 -0
  864. package/dist/viewer/assets/index-DSwi2Seu.css +1 -0
  865. package/dist/viewer/index.html +16 -0
  866. package/package.json +67 -0
@@ -0,0 +1,967 @@
1
+ "use strict";
2
+ /**
3
+ * File Watcher
4
+ *
5
+ * Watches the project directory for file changes and triggers debounced sync
6
+ * operations to keep the code graph up-to-date.
7
+ *
8
+ * Uses Node's built-in `fs.watch` directly (no third-party watcher, no native
9
+ * addon) with a per-platform strategy chosen to keep the open-descriptor /
10
+ * kernel-watch cost BOUNDED rather than growing with the number of files:
11
+ *
12
+ * - macOS / Windows: a SINGLE recursive `fs.watch(root, {recursive:true})`.
13
+ * libuv maps this to one FSEvents stream (macOS) / one
14
+ * ReadDirectoryChangesW handle (Windows), so it costs O(1) descriptors no
15
+ * matter how large the tree. This is the fix for the macOS file-table
16
+ * exhaustion (#644 / #496 / #555 / #628): the previous watcher held one
17
+ * open fd PER WATCHED FILE on macOS (tens of thousands of REG fds), which
18
+ * exhausted `kern.maxfiles` and crashed unrelated processes system-wide.
19
+ *
20
+ * - Linux: recursive `fs.watch` is unsupported, so we watch each (non-ignored)
21
+ * DIRECTORY with one inotify watch — O(directories), NOT O(files). New
22
+ * directories are picked up dynamically and an overall watch cap bounds
23
+ * inotify usage on pathological monorepos (#579). A single inotify watch on
24
+ * a directory already reports create/modify/delete for its children, so
25
+ * per-file watches are never needed.
26
+ *
27
+ * Excluded trees (node_modules/, dist/, .git/, …) are filtered via the
28
+ * indexer's `buildScopeIgnore` (built-in default-ignore dirs + the project's
29
+ * .gitignore) — on Linux they're never descended into (so they cost no watch),
30
+ * and on macOS/Windows the single recursive stream still covers them but their
31
+ * events are dropped before any sync is scheduled. Either way the watcher's
32
+ * scope matches the indexer's (#276 / #407).
33
+ */
34
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
35
+ if (k2 === undefined) k2 = k;
36
+ var desc = Object.getOwnPropertyDescriptor(m, k);
37
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
38
+ desc = { enumerable: true, get: function() { return m[k]; } };
39
+ }
40
+ Object.defineProperty(o, k2, desc);
41
+ }) : (function(o, m, k, k2) {
42
+ if (k2 === undefined) k2 = k;
43
+ o[k2] = m[k];
44
+ }));
45
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
46
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
47
+ }) : function(o, v) {
48
+ o["default"] = v;
49
+ });
50
+ var __importStar = (this && this.__importStar) || (function () {
51
+ var ownKeys = function(o) {
52
+ ownKeys = Object.getOwnPropertyNames || function (o) {
53
+ var ar = [];
54
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
55
+ return ar;
56
+ };
57
+ return ownKeys(o);
58
+ };
59
+ return function (mod) {
60
+ if (mod && mod.__esModule) return mod;
61
+ var result = {};
62
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
63
+ __setModuleDefault(result, mod);
64
+ return result;
65
+ };
66
+ })();
67
+ Object.defineProperty(exports, "__esModule", { value: true });
68
+ exports.FileWatcher = exports.LockUnavailableError = void 0;
69
+ exports.__setFsWatchForTests = __setFsWatchForTests;
70
+ exports.__emitWatchEventForTests = __emitWatchEventForTests;
71
+ const fs = __importStar(require("fs"));
72
+ const path = __importStar(require("path"));
73
+ const extraction_1 = require("../extraction");
74
+ const project_config_1 = require("../project-config");
75
+ const errors_1 = require("../errors");
76
+ const utils_1 = require("../utils");
77
+ const directory_1 = require("../directory");
78
+ const watch_policy_1 = require("./watch-policy");
79
+ /**
80
+ * Number of consecutive lock-contention retries the watcher tolerates before
81
+ * it gives up and degrades auto-sync. Brief contention (another writer for a
82
+ * few cycles) stays under this; a long-lived external writer crosses it.
83
+ */
84
+ const MAX_LOCK_RETRIES = 5;
85
+ /**
86
+ * Number of consecutive GENERIC (non-lock) sync failures the watcher tolerates
87
+ * before it degrades auto-sync. A deterministic failure — a tree-sitter
88
+ * extractor that crashes on one file, DB corruption, `SQLITE_FULL`, an OOM in
89
+ * batched resolution — recurs every debounce cycle, so left unbounded it would
90
+ * retry forever (log + work spam) while the auto-update guarantee is silently
91
+ * dead (#1127). A single clean sync resets the streak, so a transient hiccup
92
+ * that recovers within the budget never degrades.
93
+ */
94
+ const MAX_SYNC_FAILURE_RETRIES = 5;
95
+ /** Cap on the exponential retry backoff (either mode) so it never sleeps absurdly long. */
96
+ const MAX_RETRY_BACKOFF_MS = 30_000;
97
+ /**
98
+ * Adaptive debounce: a pending set this small fires after the quick quiet
99
+ * window instead of the full debounce — a lone save (or editor + test file
100
+ * pair) syncs near-instantly, while larger bursts keep the full window and
101
+ * coalesce exactly as before.
102
+ */
103
+ const QUICK_SYNC_MAX_PENDING = 2;
104
+ const QUICK_SYNC_QUIET_MS = 300;
105
+ /**
106
+ * Scoped-sync ceiling: above this many pending files a full scan-diff is
107
+ * simpler and comparably fast (a branch checkout emits thousands of events),
108
+ * and it self-heals anything event coalescing dropped along the way.
109
+ */
110
+ const SCOPED_SYNC_MAX_PENDING = 500;
111
+ /** Actionable degrade message; both exhaustion paths share it verbatim. */
112
+ const EXHAUSTION_REASON = 'OS watch/file limit exhausted; auto-sync disabled. Run `cg sync` ' +
113
+ '(or install git sync hooks) to refresh the graph after changes.';
114
+ /**
115
+ * Actionable, NON-fatal warning for Linux inotify watch-count exhaustion.
116
+ * Unlike {@link EXHAUSTION_REASON} this does not disable the watcher — the
117
+ * watches already installed keep working — so it names the exact kernel knob to
118
+ * raise instead.
119
+ */
120
+ const INOTIFY_LIMIT_REASON = 'Linux inotify watch limit reached (fs.inotify.max_user_watches); live ' +
121
+ 'watching now covers only part of the project, so edits in unwatched ' +
122
+ 'directories will not auto-sync. Raise the limit (e.g. `sudo sysctl ' +
123
+ 'fs.inotify.max_user_watches=1048576`, persisted in /etc/sysctl.d) and ' +
124
+ 'restart, or run `cg sync` (or install git sync hooks) to refresh.';
125
+ /**
126
+ * True when an error is OS watch/file-descriptor exhaustion (EMFILE/ENFILE).
127
+ * Prefers the structured `err.code`; falls back to message matching ONLY when
128
+ * no code is present (some platforms surface a bare Error from `fs.watch`).
129
+ */
130
+ function isWatchResourceExhaustion(err) {
131
+ const e = err;
132
+ if (e?.code === 'EMFILE' || e?.code === 'ENFILE')
133
+ return true;
134
+ if (!e?.code && e?.message) {
135
+ return /EMFILE|ENFILE|too many open files/i.test(e.message);
136
+ }
137
+ return false;
138
+ }
139
+ /**
140
+ * True when an error is Linux inotify *watch-count* exhaustion. `fs.watch`
141
+ * surfaces a hit `fs.inotify.max_user_watches` as ENOSPC ("no space" = no watch
142
+ * descriptors left, NOT disk space). This only arises on the Linux
143
+ * per-directory path; it is non-fatal (raise the limit and partial watching
144
+ * keeps working), so it warns rather than degrading.
145
+ */
146
+ function isInotifyWatchExhaustion(err) {
147
+ return err?.code === 'ENOSPC';
148
+ }
149
+ /**
150
+ * Native recursive `fs.watch` is only reliable on macOS and Windows; on Linux
151
+ * (and AIX) it throws `ERR_FEATURE_UNAVAILABLE_ON_PLATFORM`. We branch on this
152
+ * to pick the recursive vs per-directory strategy.
153
+ */
154
+ function supportsRecursiveWatch() {
155
+ return process.platform === 'darwin' || process.platform === 'win32';
156
+ }
157
+ let watchImpl = fs.watch;
158
+ /** @internal Test-only seam to inject a fake fs.watch implementation. */
159
+ function __setFsWatchForTests(fn) {
160
+ watchImpl = fn ?? fs.watch;
161
+ }
162
+ /**
163
+ * Upper bound on simultaneously-watched directories on the Linux per-directory
164
+ * path. Each is one inotify watch; the kernel's `fs.inotify.max_user_watches`
165
+ * is the hard limit (commonly 8k–128k). We stop adding watches past this and
166
+ * log once — partial live-watch (with `cg sync` as the backstop) is far
167
+ * better than exhausting the user's inotify budget and breaking watching
168
+ * system-wide (#579). Tunable via CODEGRAPH_MAX_DIR_WATCHES.
169
+ */
170
+ const DEFAULT_MAX_DIR_WATCHES = 50_000;
171
+ function maxDirWatches() {
172
+ const raw = process.env.CODEGRAPH_MAX_DIR_WATCHES;
173
+ if (raw && /^\d+$/.test(raw)) {
174
+ const n = Number(raw);
175
+ if (n > 0)
176
+ return n;
177
+ }
178
+ return DEFAULT_MAX_DIR_WATCHES;
179
+ }
180
+ /**
181
+ * Test seam (see {@link __emitWatchEventForTests}). Maps a watcher's project
182
+ * root to its live instance so tests can synthesize a change event
183
+ * deterministically — real fs.watch delivery latency races under parallel
184
+ * vitest (the reason the previous chokidar mock existed). Only populated under
185
+ * a test runner, so production carries no bookkeeping or retained references.
186
+ */
187
+ const liveWatchersForTests = new Map();
188
+ const IS_TEST_RUNTIME = !!(process.env.VITEST || process.env.NODE_ENV === 'test');
189
+ /**
190
+ * Thrown by a `syncFn` to signal that the underlying sync couldn't acquire
191
+ * the cross-process write lock (#449). The watcher treats this as "no
192
+ * progress" — preserves `pendingFiles`, skips `onSyncComplete`, and the
193
+ * `finally` block reschedules. Quiet (debug-only) because a long-running
194
+ * external indexer can hit this every debounce cycle.
195
+ */
196
+ class LockUnavailableError extends Error {
197
+ constructor(message = 'CodeGraph file lock unavailable; another process is writing') {
198
+ super(message);
199
+ this.name = 'LockUnavailableError';
200
+ }
201
+ }
202
+ exports.LockUnavailableError = LockUnavailableError;
203
+ /**
204
+ * FileWatcher monitors a project directory for changes and triggers
205
+ * debounced sync operations via a provided callback.
206
+ *
207
+ * Design goals:
208
+ * - Bounded resource usage: O(1) descriptors on macOS/Windows (one recursive
209
+ * watch), O(directories) inotify watches on Linux — never O(files), which
210
+ * was the system-crashing fd leak on macOS (#644/#496/#555/#628).
211
+ * - Debounced to avoid thrashing on rapid saves
212
+ * - Filters to supported source files by extension
213
+ * - Ignores .codegraph/ and .git/ regardless of .gitignore
214
+ * - Tracks per-file pending state so MCP tools can flag stale results
215
+ * without blocking on a sync (issue #403)
216
+ */
217
+ class FileWatcher {
218
+ /** macOS/Windows: the single recursive watcher. Null on Linux. */
219
+ recursiveWatcher = null;
220
+ /** Linux: one watcher per watched directory (keyed by absolute path). */
221
+ dirWatchers = new Map();
222
+ /** Set once the per-directory watch cap is hit, so we log only once. */
223
+ dirCapWarned = false;
224
+ /**
225
+ * Set once the Linux inotify watch limit (ENOSPC) is hit. Double duty: we
226
+ * warn only once, AND we stop attempting new directory watches for the rest
227
+ * of the session — once the kernel budget is exhausted every further
228
+ * `inotify_add_watch` fails too, so trying the rest of the tree is pure
229
+ * waste. NON-fatal (does not degrade): installed watches keep working.
230
+ */
231
+ inotifyLimitWarned = false;
232
+ /**
233
+ * One-way latch: the reason live watching was permanently disabled at runtime
234
+ * (watch-resource exhaustion, lock contention past the retry budget, or a
235
+ * persistent generic sync failure past the retry budget), or null while
236
+ * healthy. Set by {@link degrade}; cleared only by a fresh start().
237
+ */
238
+ degradedReason = null;
239
+ /** Consecutive lock-contention retries for watcher-triggered syncs. */
240
+ lockRetryCount = 0;
241
+ /** Consecutive generic (non-lock) sync failures; reset only by a clean sync. */
242
+ syncFailureRetryCount = 0;
243
+ /** Test-only inert mode: started, but with no OS watcher installed. */
244
+ inert = false;
245
+ debounceTimer = null;
246
+ /**
247
+ * True when the pending set does NOT exactly describe the change (a
248
+ * directory removal's children are unknown from the event, #1285) — the
249
+ * next sync must be a full scan-diff. Cleared only after a successful FULL
250
+ * sync reconciles the tree.
251
+ */
252
+ needsFullScan = false;
253
+ /**
254
+ * Files seen by the watcher since the last successful sync — populated on
255
+ * every change event, cleared at the start of a sync, and re-populated by
256
+ * events that arrive mid-sync (or restored on sync failure). Keyed by the
257
+ * same project-relative POSIX path the rest of the codebase uses, so a
258
+ * caller can intersect tool-response file paths against this map cheaply.
259
+ */
260
+ pendingFiles = new Map();
261
+ /**
262
+ * Wall-clock ms at which the in-flight sync began. Combined with
263
+ * {@link pendingFiles}'s `lastSeenMs`, this distinguishes "still in the
264
+ * debounce window" (lastSeen > syncStarted, sync hasn't started yet for
265
+ * this edit) from "currently being indexed" (lastSeen <= syncStarted).
266
+ */
267
+ syncStartedMs = 0;
268
+ syncing = false;
269
+ stopped = false;
270
+ /**
271
+ * True once the initial watch set is established. Unlike the previous
272
+ * chokidar implementation there is no asynchronous initial "crawl" emitting
273
+ * an `add` per existing file — `fs.watch` only reports changes from the
274
+ * moment it's installed — so this flips to true synchronously at the end of
275
+ * `start()`. The startup reconcile against on-disk state is handled
276
+ * separately by the engine's catch-up sync, not by the watcher.
277
+ */
278
+ ready = false;
279
+ /**
280
+ * Callbacks that resolve when the watch set is established. Used by tests
281
+ * (and any production caller that cares about a clean baseline) to
282
+ * deterministically gate on watcher readiness.
283
+ */
284
+ readyWaiters = [];
285
+ // The shared scope matcher (built-in defaults + project .gitignore + the
286
+ // `codegraph.json` exclude/include rules, with embedded child repos matched
287
+ // by their OWN rules — #514), built at start() and REBUILT whenever one of
288
+ // the files it is derived from changes (see `refreshScope`, #1590). Same
289
+ // source of truth the indexer uses, so watcher scope can never diverge from
290
+ // index scope. An embedded repo created after start() joins the scope on
291
+ // the next scope refresh / watcher restart / re-index.
292
+ ignoreMatcher = null;
293
+ projectRoot;
294
+ debounceMs;
295
+ syncFn;
296
+ onSyncComplete;
297
+ onSyncError;
298
+ onDegraded;
299
+ inertForTests;
300
+ constructor(projectRoot, syncFn, options = {}) {
301
+ this.projectRoot = projectRoot;
302
+ this.syncFn = syncFn;
303
+ this.debounceMs = options.debounceMs ?? 2000;
304
+ this.onSyncComplete = options.onSyncComplete;
305
+ this.onSyncError = options.onSyncError;
306
+ this.onDegraded = options.onDegraded;
307
+ this.inertForTests = options.inertForTests ?? false;
308
+ }
309
+ /**
310
+ * Start watching for file changes.
311
+ * Returns true if watching started successfully, false otherwise.
312
+ */
313
+ start() {
314
+ if (this.recursiveWatcher || this.dirWatchers.size > 0 || this.inert)
315
+ return true; // Already watching
316
+ this.stopped = false;
317
+ this.degradedReason = null;
318
+ this.lockRetryCount = 0;
319
+ this.syncFailureRetryCount = 0;
320
+ // Some environments make filesystem watching unusable — most notably
321
+ // WSL2 /mnt/ drives, where the underlying fs.watch calls block long
322
+ // enough to break MCP startup handshakes (issue #199). Skip watching
323
+ // there; callers fall back to manual `cg sync` or git sync hooks.
324
+ const disabledReason = (0, watch_policy_1.watchDisabledReason)(this.projectRoot);
325
+ if (disabledReason) {
326
+ (0, errors_1.logDebug)('File watcher disabled', { reason: disabledReason, projectRoot: this.projectRoot });
327
+ return false;
328
+ }
329
+ // Reuse the indexer's ignore set so the watcher and indexer agree on scope.
330
+ this.ignoreMatcher = (0, extraction_1.buildScopeIgnore)(this.projectRoot);
331
+ try {
332
+ if (this.inertForTests) {
333
+ // Test-only: install no OS watcher; the seam drives events instead.
334
+ this.inert = true;
335
+ }
336
+ else if (supportsRecursiveWatch()) {
337
+ this.startRecursive();
338
+ }
339
+ else {
340
+ this.startPerDirectory();
341
+ }
342
+ // The per-directory (Linux) path catches watch-resource exhaustion inside
343
+ // watchTree and degrades synchronously rather than throwing, so it never
344
+ // reaches the catch below. Surface that as a failed start here so both
345
+ // strategies report exhaustion identically (start() === false).
346
+ if (this.degradedReason)
347
+ return false;
348
+ // No async crawl to wait on: as soon as the watch set is installed we
349
+ // have a clean baseline (pendingFiles is only populated by post-start
350
+ // events). Clear defensively and flip ready.
351
+ this.pendingFiles.clear();
352
+ this.ready = true;
353
+ for (const cb of this.readyWaiters)
354
+ cb();
355
+ this.readyWaiters.length = 0;
356
+ if (IS_TEST_RUNTIME)
357
+ liveWatchersForTests.set(this.projectRoot, this);
358
+ (0, errors_1.logDebug)('File watcher started', {
359
+ projectRoot: this.projectRoot,
360
+ debounceMs: this.debounceMs,
361
+ mode: this.inertForTests ? 'inert' : supportsRecursiveWatch() ? 'recursive' : 'per-directory',
362
+ watchedDirs: this.dirWatchers.size || undefined,
363
+ });
364
+ return true;
365
+ }
366
+ catch (err) {
367
+ // Watcher setup failed. Watch-resource exhaustion (EMFILE/ENFILE on the
368
+ // recursive path) is terminal — degrade cleanly with one actionable
369
+ // warning instead of leaving a half-broken watcher. Everything else
370
+ // (permission denied, missing directory) keeps the prior quiet-stop.
371
+ if (isWatchResourceExhaustion(err)) {
372
+ this.degrade(EXHAUSTION_REASON, { error: String(err) });
373
+ }
374
+ else {
375
+ (0, errors_1.logWarn)('Could not start file watcher', { error: String(err) });
376
+ this.stop();
377
+ }
378
+ return false;
379
+ }
380
+ }
381
+ /**
382
+ * macOS/Windows: one recursive watcher for the whole tree. O(1) descriptors.
383
+ * `filename` arrives relative to the project root (with subdirectories), so
384
+ * it maps straight to a project-relative path.
385
+ */
386
+ startRecursive() {
387
+ this.recursiveWatcher = watchImpl(this.projectRoot, { recursive: true, persistent: true }, (_event, filename) => {
388
+ if (this.stopped || filename == null)
389
+ return;
390
+ this.handleChange((0, utils_1.normalizePath)(String(filename)));
391
+ });
392
+ this.recursiveWatcher.on('error', (err) => {
393
+ if (isWatchResourceExhaustion(err)) {
394
+ this.degrade(EXHAUSTION_REASON, { error: String(err) });
395
+ return;
396
+ }
397
+ (0, errors_1.logWarn)('File watcher error', { error: String(err) });
398
+ });
399
+ }
400
+ /**
401
+ * Linux: walk the (non-ignored) tree and watch each directory. One inotify
402
+ * watch per directory reports create/modify/delete for that directory's
403
+ * direct children, so we never watch individual files.
404
+ */
405
+ startPerDirectory() {
406
+ this.watchTree(this.projectRoot, /* markExisting */ false);
407
+ }
408
+ /**
409
+ * Add an inotify watch for `dir` and recurse into its non-ignored
410
+ * subdirectories. When `markExisting` is true (a directory that appeared
411
+ * AFTER startup), the source files already inside it are recorded as pending
412
+ * — this closes the `mkdir + write` race where files created before the new
413
+ * directory's watch is installed would otherwise be missed until the next
414
+ * full sync. The initial startup walk passes false (the engine's catch-up
415
+ * sync owns the baseline).
416
+ */
417
+ watchTree(dir, markExisting) {
418
+ // A degrade() mid-walk (exhaustion on an earlier directory) calls stop(),
419
+ // which sets `stopped`; bail so the recursion unwinds without adding more
420
+ // watches to a watcher that is shutting down. `inotifyLimitWarned` does the
421
+ // same after ENOSPC — the kernel budget is gone, so stop trying the rest of
422
+ // the tree (every add would fail) while keeping the watches already set.
423
+ if (this.stopped || this.degradedReason || this.inotifyLimitWarned)
424
+ return;
425
+ if (this.dirWatchers.has(dir))
426
+ return;
427
+ if (this.dirWatchers.size >= maxDirWatches()) {
428
+ if (!this.dirCapWarned) {
429
+ this.dirCapWarned = true;
430
+ (0, errors_1.logWarn)('File watcher hit directory-watch cap; remaining subtrees rely on manual/periodic sync', {
431
+ cap: maxDirWatches(),
432
+ });
433
+ }
434
+ return;
435
+ }
436
+ let w;
437
+ try {
438
+ w = watchImpl(dir, { persistent: true }, (_event, filename) => this.handleDirEvent(dir, filename));
439
+ }
440
+ catch (err) {
441
+ // EMFILE/ENFILE means the PROCESS is out of descriptors — every further
442
+ // directory would fail too, so degrade the whole watcher rather than
443
+ // limping along with a partial watch set.
444
+ if (isWatchResourceExhaustion(err)) {
445
+ this.degrade(EXHAUSTION_REASON, { error: String(err), dir });
446
+ }
447
+ else if (isInotifyWatchExhaustion(err)) {
448
+ // ENOSPC = inotify watch budget exhausted. NON-fatal: keep the watches
449
+ // we have and tell the user the knob to raise (warn once).
450
+ this.warnInotifyLimit({ error: String(err), dir });
451
+ }
452
+ // ENOENT / EACCES on a single directory stays non-fatal: skip it quietly.
453
+ return;
454
+ }
455
+ w.on('error', (err) => {
456
+ if (isWatchResourceExhaustion(err)) {
457
+ this.degrade(EXHAUSTION_REASON, { error: String(err), dir });
458
+ return;
459
+ }
460
+ if (isInotifyWatchExhaustion(err)) {
461
+ this.warnInotifyLimit({ error: String(err), dir });
462
+ }
463
+ this.unwatchDir(dir);
464
+ });
465
+ this.dirWatchers.set(dir, w);
466
+ let entries;
467
+ try {
468
+ entries = fs.readdirSync(dir, { withFileTypes: true });
469
+ }
470
+ catch {
471
+ return;
472
+ }
473
+ for (const entry of entries) {
474
+ const child = path.join(dir, entry.name);
475
+ if (entry.isDirectory()) {
476
+ if (this.shouldIgnoreDir(child))
477
+ continue;
478
+ this.watchTree(child, markExisting);
479
+ }
480
+ else if (markExisting && entry.isFile()) {
481
+ this.handleChange((0, utils_1.normalizePath)(path.relative(this.projectRoot, child)));
482
+ }
483
+ }
484
+ }
485
+ /**
486
+ * Linux per-directory event handler. `filename` is relative to `dir`. A new
487
+ * sub-directory is picked up by extending the watch tree; everything else is
488
+ * routed through the shared change handler.
489
+ */
490
+ handleDirEvent(dir, filename) {
491
+ if (this.stopped || filename == null)
492
+ return;
493
+ const full = path.join(dir, String(filename));
494
+ // A newly-created directory needs its own watch (recursive isn't available
495
+ // on Linux). statSync is cheap and these events are rare relative to file
496
+ // edits. If the path vanished (rapid create/delete) the stat throws and we
497
+ // fall through to the change handler, which no-ops on a non-source path.
498
+ try {
499
+ if (fs.statSync(full).isDirectory()) {
500
+ if (!this.shouldIgnoreDir(full))
501
+ this.watchTree(full, /* markExisting */ true);
502
+ return;
503
+ }
504
+ }
505
+ catch {
506
+ // deleted/inaccessible — treat as a normal change below
507
+ }
508
+ this.handleChange((0, utils_1.normalizePath)(path.relative(this.projectRoot, full)));
509
+ }
510
+ /**
511
+ * Shared change handler for both watch strategies. `rel` is a
512
+ * project-relative POSIX path. Applies the ignore + source-file filters and,
513
+ * for a real source change, records it as pending (#403) and schedules a
514
+ * debounced sync.
515
+ *
516
+ * The recursive (macOS/Windows) watcher reports events for ignored trees too
517
+ * (one stream covers the whole repo), so the ignore check here is load-bearing
518
+ * — it drops node_modules/dist/.git churn before any sync is scheduled.
519
+ */
520
+ handleChange(rel) {
521
+ if (!rel || rel === '.' || rel.startsWith('..'))
522
+ return;
523
+ if (this.isAlwaysIgnored(rel))
524
+ return;
525
+ // The two root files the scope matcher is derived from are handled BEFORE
526
+ // the matcher is consulted: a user `exclude` pattern that happens to cover
527
+ // them (`*.json`, `.*`) must not be able to hide their own edits (#1590).
528
+ if (rel === project_config_1.PROJECT_CONFIG_FILENAME || rel === '.gitignore') {
529
+ this.refreshScope(rel);
530
+ return;
531
+ }
532
+ if (this.ignoreMatcher && this.ignoreMatcher.ignores(rel))
533
+ return;
534
+ // A nested `.gitignore` (an embedded child repo's own rules, #514, or a
535
+ // subdirectory rule the git-backed full scan honors) is only a scope
536
+ // change when it sits INSIDE the current scope — checked after the matcher
537
+ // on purpose, so the thousands of package-local `.gitignore`s an
538
+ // `npm install` writes under an ignored `node_modules/` never trigger a
539
+ // rebuild storm.
540
+ if (rel.endsWith('/.gitignore')) {
541
+ this.refreshScope(rel);
542
+ return;
543
+ }
544
+ if (!(0, extraction_1.isSourceFile)(rel, (0, project_config_1.loadExtensionOverrides)(this.projectRoot))) {
545
+ this.maybeScheduleForRemovedDir(rel);
546
+ return;
547
+ }
548
+ (0, errors_1.logDebug)('File change detected', { file: rel });
549
+ if (this.ready) {
550
+ const now = Date.now();
551
+ const existing = this.pendingFiles.get(rel);
552
+ this.pendingFiles.set(rel, {
553
+ firstSeenMs: existing?.firstSeenMs ?? now,
554
+ lastSeenMs: now,
555
+ });
556
+ }
557
+ this.scheduleSync();
558
+ }
559
+ /**
560
+ * A scope-defining file changed (`codegraph.json`, a `.gitignore`): rebuild
561
+ * the ignore matcher and make the next sync a FULL reconcile (#1590).
562
+ *
563
+ * The matcher used to be built once in `start()` and kept for the watcher's
564
+ * lifetime — in a long-lived MCP daemon that meant a `codegraph.json`
565
+ * created or edited after startup was invisible to the live watcher, while
566
+ * `cg sync` (a fresh process) honoured it immediately: the CLI
567
+ * removed a newly excluded file and the watcher re-added it seconds later.
568
+ * `loadExtensionOverrides()` on the same filter line was already read live
569
+ * (mtime-cached), so two fields of the same config file disagreed.
570
+ *
571
+ * Rebuilding costs one `git ls-files` pass (embedded-repo discovery), which
572
+ * is fine per config edit — never per event. Replacing the field is enough
573
+ * for both strategies: the recursive handler and the per-directory
574
+ * `shouldIgnoreDir` walk read `this.ignoreMatcher` on every call. The full
575
+ * scan is required because a scope change has no per-file events: newly
576
+ * excluded files must be REMOVED from the index and newly included ones
577
+ * added, and only the scan-diff (which builds its own fresh matcher) knows
578
+ * which those are.
579
+ */
580
+ refreshScope(rel) {
581
+ (0, errors_1.logDebug)('Scope config changed; rebuilding watcher scope', { file: rel });
582
+ this.ignoreMatcher = (0, extraction_1.buildScopeIgnore)(this.projectRoot);
583
+ this.needsFullScan = true;
584
+ this.scheduleSync();
585
+ }
586
+ /**
587
+ * A deleted DIRECTORY arrives as one event on the directory's own path —
588
+ * no source extension, so the source-file filter drops it, and the files
589
+ * underneath may never get events of their own (Windows's recursive
590
+ * watcher reports only the top-most removed entry; macOS FSEvents can
591
+ * coalesce a tree deletion the same way). The index then kept every child
592
+ * record until some unrelated edit happened to trigger a sync (#1285).
593
+ *
594
+ * If a non-source path no longer exists on disk, treat it as a potential
595
+ * subtree removal and schedule the debounced sync — its scan-diff removes
596
+ * whatever is gone, which is the ground truth for what was underneath.
597
+ * pendingFiles is left alone (we can't know the children from the event).
598
+ * An event for an EXISTING non-source file stays fully ignored, so build
599
+ * churn on live files never schedules work; a deleted non-source file
600
+ * costs at most one no-op scan-diff, absorbed by the debounce.
601
+ */
602
+ maybeScheduleForRemovedDir(rel) {
603
+ try {
604
+ fs.statSync(path.join(this.projectRoot, rel));
605
+ return; // still on disk — an ordinary non-source change, ignore
606
+ }
607
+ catch {
608
+ /* gone — fall through */
609
+ }
610
+ (0, errors_1.logDebug)('Non-source path removed; scheduling sync for possible directory removal', {
611
+ path: rel,
612
+ });
613
+ this.needsFullScan = true;
614
+ this.scheduleSync();
615
+ }
616
+ /** Close and forget the watch for a directory that errored/was removed. */
617
+ unwatchDir(dir) {
618
+ const w = this.dirWatchers.get(dir);
619
+ if (w) {
620
+ try {
621
+ w.close();
622
+ }
623
+ catch {
624
+ /* already closed */
625
+ }
626
+ this.dirWatchers.delete(dir);
627
+ }
628
+ }
629
+ /** Our own dirs are always ignored, regardless of .gitignore. */
630
+ isAlwaysIgnored(rel) {
631
+ // First path segment. Ignore any CodeGraph data dir — the active one AND a
632
+ // sibling like `.codegraph-win` a second environment (Windows/WSL) created
633
+ // in the same tree, so neither side watches the other's index (#636).
634
+ const top = rel.split('/')[0] ?? rel;
635
+ return ((0, directory_1.isCodeGraphDataDir)(top) ||
636
+ rel === '.git' || rel.startsWith('.git/'));
637
+ }
638
+ /**
639
+ * True for any directory that should NOT be watched (used while building the
640
+ * Linux per-directory watch tree). Tests the directory form of the path so a
641
+ * dir-only ignore rule like `build/` matches.
642
+ */
643
+ shouldIgnoreDir(dirPath) {
644
+ const rel = (0, utils_1.normalizePath)(path.relative(this.projectRoot, dirPath));
645
+ if (!rel || rel === '.' || rel.startsWith('..'))
646
+ return false; // root / outside
647
+ if (this.isAlwaysIgnored(rel))
648
+ return true;
649
+ if (!this.ignoreMatcher)
650
+ return false;
651
+ return this.ignoreMatcher.ignores(rel + '/');
652
+ }
653
+ /**
654
+ * Permanently disable live watching after a terminal runtime failure
655
+ * (watch-resource exhaustion, lock contention past the retry budget, or a
656
+ * persistent generic sync failure past the retry budget).
657
+ * Idempotent: logs one actionable warning, fires {@link WatchOptions.onDegraded}
658
+ * once, and stops the watcher. A subsequent start() clears the latch.
659
+ */
660
+ degrade(reason, context = {}) {
661
+ if (this.degradedReason)
662
+ return;
663
+ this.degradedReason = reason;
664
+ (0, errors_1.logWarn)('File watcher disabled', { projectRoot: this.projectRoot, reason, ...context });
665
+ this.onDegraded?.(reason);
666
+ this.stop();
667
+ }
668
+ /**
669
+ * Warn ONCE that the Linux inotify watch budget is exhausted (ENOSPC), and
670
+ * stop adding new watches for the rest of this session — every further
671
+ * `inotify_add_watch` would fail too, so walking the rest of the tree is
672
+ * waste. Unlike {@link degrade} this is NON-fatal: the watches already
673
+ * installed keep firing, and `cg sync` covers the unwatched remainder.
674
+ * The message names the kernel knob to raise (`fs.inotify.max_user_watches`).
675
+ */
676
+ warnInotifyLimit(context = {}) {
677
+ if (this.inotifyLimitWarned)
678
+ return;
679
+ this.inotifyLimitWarned = true;
680
+ (0, errors_1.logWarn)(INOTIFY_LIMIT_REASON, { watchedDirs: this.dirWatchers.size, ...context });
681
+ }
682
+ /**
683
+ * Whether live watching has degraded permanently (until the next start()).
684
+ * Distinct from {@link isActive}: a degraded watcher is inactive, but an
685
+ * inactive watcher is not necessarily degraded (it may simply be stopped or
686
+ * never started). Hosts use this to tell the user auto-sync is off.
687
+ */
688
+ isDegraded() {
689
+ return this.degradedReason !== null;
690
+ }
691
+ /** The reason live watching degraded, or null if it is healthy. */
692
+ getDegradedReason() {
693
+ return this.degradedReason;
694
+ }
695
+ /**
696
+ * Stop watching for file changes.
697
+ */
698
+ stop() {
699
+ this.stopped = true;
700
+ if (this.debounceTimer) {
701
+ clearTimeout(this.debounceTimer);
702
+ this.debounceTimer = null;
703
+ }
704
+ if (this.recursiveWatcher) {
705
+ try {
706
+ this.recursiveWatcher.close();
707
+ }
708
+ catch {
709
+ /* already closed */
710
+ }
711
+ this.recursiveWatcher = null;
712
+ }
713
+ for (const w of this.dirWatchers.values()) {
714
+ try {
715
+ w.close();
716
+ }
717
+ catch {
718
+ /* already closed */
719
+ }
720
+ }
721
+ this.dirWatchers.clear();
722
+ this.dirCapWarned = false;
723
+ this.inotifyLimitWarned = false;
724
+ this.lockRetryCount = 0;
725
+ this.syncFailureRetryCount = 0;
726
+ // NB: degradedReason is intentionally NOT reset here — it must survive the
727
+ // stop() that degrade() triggers so isDegraded() stays true. start() clears it.
728
+ this.inert = false;
729
+ this.pendingFiles.clear();
730
+ this.ready = false;
731
+ this.ignoreMatcher = null;
732
+ if (IS_TEST_RUNTIME)
733
+ liveWatchersForTests.delete(this.projectRoot);
734
+ (0, errors_1.logDebug)('File watcher stopped');
735
+ }
736
+ /**
737
+ * @internal Test-only: feed a synthetic project-relative change through the
738
+ * same filter → pendingFiles → debounced-sync path a real fs.watch event
739
+ * takes. Lets the watcher / staleness-banner suites stay deterministic
740
+ * instead of racing on OS watch-delivery latency. See
741
+ * {@link __emitWatchEventForTests}.
742
+ */
743
+ ingestEventForTests(relPath) {
744
+ this.handleChange((0, utils_1.normalizePath)(relPath));
745
+ }
746
+ /**
747
+ * Whether the watcher is currently active.
748
+ */
749
+ isActive() {
750
+ return (this.recursiveWatcher !== null || this.dirWatchers.size > 0 || this.inert) && !this.stopped;
751
+ }
752
+ /**
753
+ * Resolves once the watch set has been installed (or immediately if it
754
+ * already has). Useful for tests that need a deterministic boundary before
755
+ * asserting on `pendingFiles`.
756
+ *
757
+ * Production callers don't need this: `pendingFiles` is read continuously,
758
+ * the staleness banner is always correct (empty or populated), and there is
759
+ * no asynchronous initial-scan window with `fs.watch`.
760
+ */
761
+ waitUntilReady(timeoutMs = 10000) {
762
+ if (this.ready)
763
+ return Promise.resolve();
764
+ return new Promise((resolve, reject) => {
765
+ const t = setTimeout(() => {
766
+ const idx = this.readyWaiters.indexOf(handler);
767
+ if (idx >= 0)
768
+ this.readyWaiters.splice(idx, 1);
769
+ reject(new Error(`FileWatcher.waitUntilReady timed out after ${timeoutMs}ms`));
770
+ }, timeoutMs);
771
+ const handler = () => { clearTimeout(t); resolve(); };
772
+ this.readyWaiters.push(handler);
773
+ });
774
+ }
775
+ /**
776
+ * Schedule a normal debounced sync after a source edit.
777
+ */
778
+ scheduleSync() {
779
+ if (this.debounceTimer) {
780
+ clearTimeout(this.debounceTimer);
781
+ }
782
+ // Adaptive quiet window: a lone save (or a pair — editor + its test file)
783
+ // fires fast so the graph feels instant; anything bigger keeps the full
784
+ // configured window so an agent's multi-file burst still coalesces into
785
+ // one sync exactly as before. Re-arming on each event preserves the
786
+ // trailing-edge semantics either way: if more events arrive inside the
787
+ // quick window, the reschedule sees the larger pending set and extends to
788
+ // the full window. Never exceeds the configured debounce (a user-lowered
789
+ // CODEGRAPH_WATCH_DEBOUNCE_MS stays authoritative), floor 100ms.
790
+ const quickMs = Math.max(100, Math.min(QUICK_SYNC_QUIET_MS, this.debounceMs));
791
+ const delay = this.pendingFiles.size <= QUICK_SYNC_MAX_PENDING ? quickMs : this.debounceMs;
792
+ this.debounceTimer = setTimeout(() => {
793
+ this.debounceTimer = null;
794
+ this.flush();
795
+ }, delay);
796
+ }
797
+ /**
798
+ * Schedule a retry after a recoverable sync failure (lock contention). Kept
799
+ * separate from {@link scheduleSync} so prolonged contention backs off
800
+ * exponentially instead of hammering the lock every debounce cycle.
801
+ */
802
+ scheduleRetrySync(delayMs) {
803
+ if (this.debounceTimer) {
804
+ clearTimeout(this.debounceTimer);
805
+ }
806
+ this.debounceTimer = setTimeout(() => {
807
+ this.debounceTimer = null;
808
+ this.flush();
809
+ }, delayMs);
810
+ }
811
+ /**
812
+ * Flush pending changes by running sync.
813
+ *
814
+ * pendingFiles is NOT cleared at the start of sync — entries are removed
815
+ * only after sync commits successfully, and only for entries whose
816
+ * lastSeenMs <= syncStartedMs. That way, a query that arrives mid-sync
817
+ * still sees the affected files marked stale (the DB hasn't been updated
818
+ * yet), and an event that lands mid-sync persists into the follow-up.
819
+ *
820
+ * On sync failure pendingFiles is left untouched — every edit is still
821
+ * unindexed, and the rescheduled sync will absorb the same set next time.
822
+ */
823
+ async flush() {
824
+ // If already syncing, the post-sync check will re-trigger
825
+ if (this.syncing || this.stopped)
826
+ return;
827
+ this.syncStartedMs = Date.now();
828
+ this.syncing = true;
829
+ // Scoped fast path: when every pending change is a known file event, hand
830
+ // the exact paths to sync and skip its O(repo) scan-diff. Anything the
831
+ // events can't fully describe — a directory removal, an empty pending set
832
+ // (retry paths), or an event storm past the ceiling — runs the full
833
+ // scan-diff, which remains the ground truth.
834
+ const scoped = !this.needsFullScan && this.pendingFiles.size > 0 && this.pendingFiles.size <= SCOPED_SYNC_MAX_PENDING
835
+ ? [...this.pendingFiles.keys()]
836
+ : undefined;
837
+ try {
838
+ const result = await this.syncFn(scoped);
839
+ if (!scoped)
840
+ this.needsFullScan = false;
841
+ this.lockRetryCount = 0; // a clean sync clears any contention backoff
842
+ this.syncFailureRetryCount = 0; // ...and any generic-failure backoff
843
+ // Remove entries whose most recent event predates this sync — those
844
+ // edits are now in the DB. Entries with lastSeenMs > syncStartedMs
845
+ // arrived mid-sync; whether the in-flight sync captured them depends
846
+ // on when sync read that file, so we keep them as pending and let
847
+ // the follow-up sync handle them. We prefer false positives ("shown
848
+ // stale, actually fresh" → at worst one extra Read) over false
849
+ // negatives ("shown fresh, actually stale" → misleads the agent).
850
+ for (const [filePath, info] of this.pendingFiles) {
851
+ if (info.lastSeenMs <= this.syncStartedMs) {
852
+ this.pendingFiles.delete(filePath);
853
+ }
854
+ }
855
+ this.onSyncComplete?.(result);
856
+ }
857
+ catch (err) {
858
+ if (err instanceof LockUnavailableError) {
859
+ this.lockRetryCount += 1;
860
+ // Lock-failure no-op (another writer holds the lock). pendingFiles
861
+ // stays intact and the `finally` block reschedules with backoff. Keep
862
+ // brief contention quiet (debug-only — a long external index would
863
+ // otherwise spam stderr every cycle), but stop retrying forever: once a
864
+ // writer holds the lock past the budget, degrade auto-sync explicitly.
865
+ (0, errors_1.logDebug)('Watch sync skipped: file lock unavailable', {
866
+ pendingFiles: this.pendingFiles.size,
867
+ retryCount: this.lockRetryCount,
868
+ });
869
+ if (this.lockRetryCount > MAX_LOCK_RETRIES) {
870
+ this.degrade('CodeGraph file lock held by another process past the retry budget; ' +
871
+ 'auto-sync disabled. Run `cg sync` once the other writer finishes ' +
872
+ '(or install git sync hooks) to refresh the graph.', { pendingFiles: this.pendingFiles.size, retryCount: this.lockRetryCount });
873
+ }
874
+ }
875
+ else {
876
+ this.lockRetryCount = 0; // a non-lock failure isn't contention; reset that streak
877
+ this.syncFailureRetryCount += 1;
878
+ const error = err instanceof Error ? err : new Error(String(err));
879
+ (0, errors_1.logWarn)('Watch sync failed', {
880
+ error: error.message,
881
+ retryCount: this.syncFailureRetryCount,
882
+ });
883
+ this.onSyncError?.(error);
884
+ // A persistent (deterministic) sync failure — a broken extractor on a
885
+ // specific file, DB corruption, SQLITE_FULL, an OOM in resolution —
886
+ // would otherwise retry forever at the debounce cadence, spamming logs
887
+ // and work while the auto-update guarantee is silently dead (#1127).
888
+ // Bound it exactly like lock contention: the `finally` block backs off
889
+ // exponentially, and past the budget we degrade so the dead guarantee
890
+ // is surfaced (onDegraded / isDegraded) instead of hidden. A single
891
+ // clean sync resets the streak, so a transient hiccup never degrades.
892
+ if (this.syncFailureRetryCount > MAX_SYNC_FAILURE_RETRIES) {
893
+ this.degrade(`CodeGraph auto-sync failed ${this.syncFailureRetryCount} times in a row; ` +
894
+ 'auto-sync disabled. Run `cg sync` (or install git sync hooks) to ' +
895
+ `refresh the graph after changes. Last error: ${error.message}`, { error: error.message, retryCount: this.syncFailureRetryCount });
896
+ }
897
+ }
898
+ // Failure: leave pendingFiles untouched. Every edit it tracks is
899
+ // still unindexed; the rescheduled sync sees the same set.
900
+ }
901
+ finally {
902
+ this.syncing = false;
903
+ // If pending files remain (mid-sync events, or this sync failed),
904
+ // schedule another pass. After EITHER failure mode — lock contention or a
905
+ // generic sync failure — back off exponentially (debounceMs · 2^(n-1),
906
+ // capped) instead of retrying at the normal debounce cadence; a clean
907
+ // sync resets both counters so normal edits keep the fast debounce. Use
908
+ // the larger streak so interleaved failures still back off. A degrade()
909
+ // above already set `stopped`, so this won't reschedule a watcher that
910
+ // has given up.
911
+ if (this.pendingFiles.size > 0 && !this.stopped) {
912
+ const retryCount = Math.max(this.lockRetryCount, this.syncFailureRetryCount);
913
+ if (retryCount > 0) {
914
+ const retryDelayMs = Math.min(this.debounceMs * 2 ** Math.max(0, retryCount - 1), MAX_RETRY_BACKOFF_MS);
915
+ this.scheduleRetrySync(retryDelayMs);
916
+ }
917
+ else {
918
+ this.scheduleSync();
919
+ }
920
+ }
921
+ }
922
+ }
923
+ /**
924
+ * Snapshot of files seen by the watcher since the last successful sync.
925
+ *
926
+ * Used by MCP tool responses to mark stale results without blocking on a
927
+ * sync: a tool that returns a hit in `src/foo.ts` while `src/foo.ts` is in
928
+ * this list tells the agent "Read this file directly, the index lags."
929
+ *
930
+ * `indexing` is true when a sync is currently in flight whose start time is
931
+ * AFTER this file's most recent event — i.e. that sync will absorb the
932
+ * edit. False means the file is still inside the debounce window and no
933
+ * sync has started yet (a follow-up call a few hundred ms later may show
934
+ * `indexing: true` or the file may have left the list entirely).
935
+ *
936
+ * Cheap: O(pendingFiles.size), no I/O, no locks.
937
+ */
938
+ getPendingFiles() {
939
+ const result = [];
940
+ for (const [filePath, info] of this.pendingFiles) {
941
+ result.push({
942
+ path: filePath,
943
+ firstSeenMs: info.firstSeenMs,
944
+ lastSeenMs: info.lastSeenMs,
945
+ indexing: this.syncing && this.syncStartedMs >= info.lastSeenMs,
946
+ });
947
+ }
948
+ return result;
949
+ }
950
+ }
951
+ exports.FileWatcher = FileWatcher;
952
+ /**
953
+ * Test-only: synthesize a source-file change for the live watcher running at
954
+ * `projectRoot`, exercising the real filter → pendingFiles → debounced-sync
955
+ * logic without depending on fs.watch delivery timing (which races under
956
+ * parallel vitest). `relPath` is project-relative POSIX (e.g. "src/foo.ts").
957
+ * Returns false if no live watcher is registered for that root (e.g. outside a
958
+ * test runtime, where the registry is intentionally not populated).
959
+ */
960
+ function __emitWatchEventForTests(projectRoot, relPath) {
961
+ const w = liveWatchersForTests.get(projectRoot);
962
+ if (!w)
963
+ return false;
964
+ w.ingestEventForTests(relPath);
965
+ return true;
966
+ }
967
+ //# sourceMappingURL=watcher.js.map