@bharanidev/bhgraph-win32-arm64 1.0.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 (842) hide show
  1. package/bin/bhgraph.cmd +1 -0
  2. package/lib/dist/bin/bhgraph.d.ts +26 -0
  3. package/lib/dist/bin/bhgraph.d.ts.map +1 -0
  4. package/lib/dist/bin/bhgraph.js +2207 -0
  5. package/lib/dist/bin/bhgraph.js.map +1 -0
  6. package/lib/dist/bin/command-supervision.d.ts +12 -0
  7. package/lib/dist/bin/command-supervision.d.ts.map +1 -0
  8. package/lib/dist/bin/command-supervision.js +89 -0
  9. package/lib/dist/bin/command-supervision.js.map +1 -0
  10. package/lib/dist/bin/fatal-handler.d.ts +20 -0
  11. package/lib/dist/bin/fatal-handler.d.ts.map +1 -0
  12. package/lib/dist/bin/fatal-handler.js +118 -0
  13. package/lib/dist/bin/fatal-handler.js.map +1 -0
  14. package/lib/dist/bin/node-version-check.d.ts +37 -0
  15. package/lib/dist/bin/node-version-check.d.ts.map +1 -0
  16. package/lib/dist/bin/node-version-check.js +79 -0
  17. package/lib/dist/bin/node-version-check.js.map +1 -0
  18. package/lib/dist/bin/uninstall.d.ts +14 -0
  19. package/lib/dist/bin/uninstall.d.ts.map +1 -0
  20. package/lib/dist/bin/uninstall.js +36 -0
  21. package/lib/dist/bin/uninstall.js.map +1 -0
  22. package/lib/dist/context/formatter.d.ts +30 -0
  23. package/lib/dist/context/formatter.d.ts.map +1 -0
  24. package/lib/dist/context/formatter.js +263 -0
  25. package/lib/dist/context/formatter.js.map +1 -0
  26. package/lib/dist/context/index.d.ts +119 -0
  27. package/lib/dist/context/index.d.ts.map +1 -0
  28. package/lib/dist/context/index.js +1296 -0
  29. package/lib/dist/context/index.js.map +1 -0
  30. package/lib/dist/context/markers.d.ts +19 -0
  31. package/lib/dist/context/markers.d.ts.map +1 -0
  32. package/lib/dist/context/markers.js +22 -0
  33. package/lib/dist/context/markers.js.map +1 -0
  34. package/lib/dist/db/index.d.ts +142 -0
  35. package/lib/dist/db/index.d.ts.map +1 -0
  36. package/lib/dist/db/index.js +335 -0
  37. package/lib/dist/db/index.js.map +1 -0
  38. package/lib/dist/db/migrations.d.ts +44 -0
  39. package/lib/dist/db/migrations.d.ts.map +1 -0
  40. package/lib/dist/db/migrations.js +182 -0
  41. package/lib/dist/db/migrations.js.map +1 -0
  42. package/lib/dist/db/queries.d.ts +452 -0
  43. package/lib/dist/db/queries.d.ts.map +1 -0
  44. package/lib/dist/db/queries.js +1740 -0
  45. package/lib/dist/db/queries.js.map +1 -0
  46. package/lib/dist/db/schema.sql +182 -0
  47. package/lib/dist/db/sqlite-adapter.d.ts +53 -0
  48. package/lib/dist/db/sqlite-adapter.d.ts.map +1 -0
  49. package/lib/dist/db/sqlite-adapter.js +117 -0
  50. package/lib/dist/db/sqlite-adapter.js.map +1 -0
  51. package/lib/dist/directory.d.ts +183 -0
  52. package/lib/dist/directory.d.ts.map +1 -0
  53. package/lib/dist/directory.js +797 -0
  54. package/lib/dist/directory.js.map +1 -0
  55. package/lib/dist/errors.d.ts +136 -0
  56. package/lib/dist/errors.d.ts.map +1 -0
  57. package/lib/dist/errors.js +219 -0
  58. package/lib/dist/errors.js.map +1 -0
  59. package/lib/dist/extraction/astro-extractor.d.ts +79 -0
  60. package/lib/dist/extraction/astro-extractor.d.ts.map +1 -0
  61. package/lib/dist/extraction/astro-extractor.js +320 -0
  62. package/lib/dist/extraction/astro-extractor.js.map +1 -0
  63. package/lib/dist/extraction/cfml-extractor.d.ts +107 -0
  64. package/lib/dist/extraction/cfml-extractor.d.ts.map +1 -0
  65. package/lib/dist/extraction/cfml-extractor.js +494 -0
  66. package/lib/dist/extraction/cfml-extractor.js.map +1 -0
  67. package/lib/dist/extraction/dfm-extractor.d.ts +31 -0
  68. package/lib/dist/extraction/dfm-extractor.d.ts.map +1 -0
  69. package/lib/dist/extraction/dfm-extractor.js +151 -0
  70. package/lib/dist/extraction/dfm-extractor.js.map +1 -0
  71. package/lib/dist/extraction/extraction-version.d.ts +25 -0
  72. package/lib/dist/extraction/extraction-version.d.ts.map +1 -0
  73. package/lib/dist/extraction/extraction-version.js +28 -0
  74. package/lib/dist/extraction/extraction-version.js.map +1 -0
  75. package/lib/dist/extraction/function-ref.d.ts +118 -0
  76. package/lib/dist/extraction/function-ref.d.ts.map +1 -0
  77. package/lib/dist/extraction/function-ref.js +727 -0
  78. package/lib/dist/extraction/function-ref.js.map +1 -0
  79. package/lib/dist/extraction/generated-detection.d.ts +30 -0
  80. package/lib/dist/extraction/generated-detection.d.ts.map +1 -0
  81. package/lib/dist/extraction/generated-detection.js +83 -0
  82. package/lib/dist/extraction/generated-detection.js.map +1 -0
  83. package/lib/dist/extraction/grammars.d.ts +123 -0
  84. package/lib/dist/extraction/grammars.d.ts.map +1 -0
  85. package/lib/dist/extraction/grammars.js +589 -0
  86. package/lib/dist/extraction/grammars.js.map +1 -0
  87. package/lib/dist/extraction/index.d.ts +232 -0
  88. package/lib/dist/extraction/index.d.ts.map +1 -0
  89. package/lib/dist/extraction/index.js +2269 -0
  90. package/lib/dist/extraction/index.js.map +1 -0
  91. package/lib/dist/extraction/languages/arkts.d.ts +3 -0
  92. package/lib/dist/extraction/languages/arkts.d.ts.map +1 -0
  93. package/lib/dist/extraction/languages/arkts.js +127 -0
  94. package/lib/dist/extraction/languages/arkts.js.map +1 -0
  95. package/lib/dist/extraction/languages/c-cpp.d.ts +110 -0
  96. package/lib/dist/extraction/languages/c-cpp.d.ts.map +1 -0
  97. package/lib/dist/extraction/languages/c-cpp.js +837 -0
  98. package/lib/dist/extraction/languages/c-cpp.js.map +1 -0
  99. package/lib/dist/extraction/languages/cfquery.d.ts +12 -0
  100. package/lib/dist/extraction/languages/cfquery.d.ts.map +1 -0
  101. package/lib/dist/extraction/languages/cfquery.js +28 -0
  102. package/lib/dist/extraction/languages/cfquery.js.map +1 -0
  103. package/lib/dist/extraction/languages/cfscript.d.ts +3 -0
  104. package/lib/dist/extraction/languages/cfscript.d.ts.map +1 -0
  105. package/lib/dist/extraction/languages/cfscript.js +73 -0
  106. package/lib/dist/extraction/languages/cfscript.js.map +1 -0
  107. package/lib/dist/extraction/languages/cobol.d.ts +33 -0
  108. package/lib/dist/extraction/languages/cobol.d.ts.map +1 -0
  109. package/lib/dist/extraction/languages/cobol.js +499 -0
  110. package/lib/dist/extraction/languages/cobol.js.map +1 -0
  111. package/lib/dist/extraction/languages/csharp.d.ts +25 -0
  112. package/lib/dist/extraction/languages/csharp.d.ts.map +1 -0
  113. package/lib/dist/extraction/languages/csharp.js +175 -0
  114. package/lib/dist/extraction/languages/csharp.js.map +1 -0
  115. package/lib/dist/extraction/languages/dart.d.ts +3 -0
  116. package/lib/dist/extraction/languages/dart.d.ts.map +1 -0
  117. package/lib/dist/extraction/languages/dart.js +374 -0
  118. package/lib/dist/extraction/languages/dart.js.map +1 -0
  119. package/lib/dist/extraction/languages/erlang.d.ts +3 -0
  120. package/lib/dist/extraction/languages/erlang.d.ts.map +1 -0
  121. package/lib/dist/extraction/languages/erlang.js +350 -0
  122. package/lib/dist/extraction/languages/erlang.js.map +1 -0
  123. package/lib/dist/extraction/languages/go.d.ts +3 -0
  124. package/lib/dist/extraction/languages/go.d.ts.map +1 -0
  125. package/lib/dist/extraction/languages/go.js +111 -0
  126. package/lib/dist/extraction/languages/go.js.map +1 -0
  127. package/lib/dist/extraction/languages/index.d.ts +10 -0
  128. package/lib/dist/extraction/languages/index.d.ts.map +1 -0
  129. package/lib/dist/extraction/languages/index.js +71 -0
  130. package/lib/dist/extraction/languages/index.js.map +1 -0
  131. package/lib/dist/extraction/languages/java.d.ts +3 -0
  132. package/lib/dist/extraction/languages/java.d.ts.map +1 -0
  133. package/lib/dist/extraction/languages/java.js +315 -0
  134. package/lib/dist/extraction/languages/java.js.map +1 -0
  135. package/lib/dist/extraction/languages/javascript.d.ts +3 -0
  136. package/lib/dist/extraction/languages/javascript.d.ts.map +1 -0
  137. package/lib/dist/extraction/languages/javascript.js +106 -0
  138. package/lib/dist/extraction/languages/javascript.js.map +1 -0
  139. package/lib/dist/extraction/languages/kotlin.d.ts +3 -0
  140. package/lib/dist/extraction/languages/kotlin.d.ts.map +1 -0
  141. package/lib/dist/extraction/languages/kotlin.js +379 -0
  142. package/lib/dist/extraction/languages/kotlin.js.map +1 -0
  143. package/lib/dist/extraction/languages/lua.d.ts +3 -0
  144. package/lib/dist/extraction/languages/lua.d.ts.map +1 -0
  145. package/lib/dist/extraction/languages/lua.js +150 -0
  146. package/lib/dist/extraction/languages/lua.js.map +1 -0
  147. package/lib/dist/extraction/languages/luau.d.ts +3 -0
  148. package/lib/dist/extraction/languages/luau.d.ts.map +1 -0
  149. package/lib/dist/extraction/languages/luau.js +37 -0
  150. package/lib/dist/extraction/languages/luau.js.map +1 -0
  151. package/lib/dist/extraction/languages/nix.d.ts +3 -0
  152. package/lib/dist/extraction/languages/nix.d.ts.map +1 -0
  153. package/lib/dist/extraction/languages/nix.js +294 -0
  154. package/lib/dist/extraction/languages/nix.js.map +1 -0
  155. package/lib/dist/extraction/languages/objc.d.ts +3 -0
  156. package/lib/dist/extraction/languages/objc.d.ts.map +1 -0
  157. package/lib/dist/extraction/languages/objc.js +175 -0
  158. package/lib/dist/extraction/languages/objc.js.map +1 -0
  159. package/lib/dist/extraction/languages/pascal.d.ts +3 -0
  160. package/lib/dist/extraction/languages/pascal.d.ts.map +1 -0
  161. package/lib/dist/extraction/languages/pascal.js +77 -0
  162. package/lib/dist/extraction/languages/pascal.js.map +1 -0
  163. package/lib/dist/extraction/languages/php.d.ts +3 -0
  164. package/lib/dist/extraction/languages/php.d.ts.map +1 -0
  165. package/lib/dist/extraction/languages/php.js +196 -0
  166. package/lib/dist/extraction/languages/php.js.map +1 -0
  167. package/lib/dist/extraction/languages/python.d.ts +3 -0
  168. package/lib/dist/extraction/languages/python.d.ts.map +1 -0
  169. package/lib/dist/extraction/languages/python.js +56 -0
  170. package/lib/dist/extraction/languages/python.js.map +1 -0
  171. package/lib/dist/extraction/languages/r.d.ts +3 -0
  172. package/lib/dist/extraction/languages/r.d.ts.map +1 -0
  173. package/lib/dist/extraction/languages/r.js +314 -0
  174. package/lib/dist/extraction/languages/r.js.map +1 -0
  175. package/lib/dist/extraction/languages/ruby.d.ts +3 -0
  176. package/lib/dist/extraction/languages/ruby.d.ts.map +1 -0
  177. package/lib/dist/extraction/languages/ruby.js +149 -0
  178. package/lib/dist/extraction/languages/ruby.js.map +1 -0
  179. package/lib/dist/extraction/languages/rust.d.ts +3 -0
  180. package/lib/dist/extraction/languages/rust.d.ts.map +1 -0
  181. package/lib/dist/extraction/languages/rust.js +142 -0
  182. package/lib/dist/extraction/languages/rust.js.map +1 -0
  183. package/lib/dist/extraction/languages/scala.d.ts +3 -0
  184. package/lib/dist/extraction/languages/scala.d.ts.map +1 -0
  185. package/lib/dist/extraction/languages/scala.js +209 -0
  186. package/lib/dist/extraction/languages/scala.js.map +1 -0
  187. package/lib/dist/extraction/languages/solidity.d.ts +3 -0
  188. package/lib/dist/extraction/languages/solidity.d.ts.map +1 -0
  189. package/lib/dist/extraction/languages/solidity.js +293 -0
  190. package/lib/dist/extraction/languages/solidity.js.map +1 -0
  191. package/lib/dist/extraction/languages/swift.d.ts +3 -0
  192. package/lib/dist/extraction/languages/swift.d.ts.map +1 -0
  193. package/lib/dist/extraction/languages/swift.js +152 -0
  194. package/lib/dist/extraction/languages/swift.js.map +1 -0
  195. package/lib/dist/extraction/languages/terraform.d.ts +3 -0
  196. package/lib/dist/extraction/languages/terraform.d.ts.map +1 -0
  197. package/lib/dist/extraction/languages/terraform.js +641 -0
  198. package/lib/dist/extraction/languages/terraform.js.map +1 -0
  199. package/lib/dist/extraction/languages/typescript.d.ts +16 -0
  200. package/lib/dist/extraction/languages/typescript.d.ts.map +1 -0
  201. package/lib/dist/extraction/languages/typescript.js +167 -0
  202. package/lib/dist/extraction/languages/typescript.js.map +1 -0
  203. package/lib/dist/extraction/languages/vbnet.d.ts +11 -0
  204. package/lib/dist/extraction/languages/vbnet.d.ts.map +1 -0
  205. package/lib/dist/extraction/languages/vbnet.js +141 -0
  206. package/lib/dist/extraction/languages/vbnet.js.map +1 -0
  207. package/lib/dist/extraction/liquid-extractor.d.ts +59 -0
  208. package/lib/dist/extraction/liquid-extractor.d.ts.map +1 -0
  209. package/lib/dist/extraction/liquid-extractor.js +357 -0
  210. package/lib/dist/extraction/liquid-extractor.js.map +1 -0
  211. package/lib/dist/extraction/mybatis-extractor.d.ts +68 -0
  212. package/lib/dist/extraction/mybatis-extractor.d.ts.map +1 -0
  213. package/lib/dist/extraction/mybatis-extractor.js +300 -0
  214. package/lib/dist/extraction/mybatis-extractor.js.map +1 -0
  215. package/lib/dist/extraction/parse-pool.d.ts +126 -0
  216. package/lib/dist/extraction/parse-pool.d.ts.map +1 -0
  217. package/lib/dist/extraction/parse-pool.js +319 -0
  218. package/lib/dist/extraction/parse-pool.js.map +1 -0
  219. package/lib/dist/extraction/parse-worker.d.ts +8 -0
  220. package/lib/dist/extraction/parse-worker.d.ts.map +1 -0
  221. package/lib/dist/extraction/parse-worker.js +97 -0
  222. package/lib/dist/extraction/parse-worker.js.map +1 -0
  223. package/lib/dist/extraction/razor-extractor.d.ts +42 -0
  224. package/lib/dist/extraction/razor-extractor.d.ts.map +1 -0
  225. package/lib/dist/extraction/razor-extractor.js +285 -0
  226. package/lib/dist/extraction/razor-extractor.js.map +1 -0
  227. package/lib/dist/extraction/svelte-extractor.d.ts +56 -0
  228. package/lib/dist/extraction/svelte-extractor.d.ts.map +1 -0
  229. package/lib/dist/extraction/svelte-extractor.js +275 -0
  230. package/lib/dist/extraction/svelte-extractor.js.map +1 -0
  231. package/lib/dist/extraction/tree-sitter-helpers.d.ts +28 -0
  232. package/lib/dist/extraction/tree-sitter-helpers.d.ts.map +1 -0
  233. package/lib/dist/extraction/tree-sitter-helpers.js +153 -0
  234. package/lib/dist/extraction/tree-sitter-helpers.js.map +1 -0
  235. package/lib/dist/extraction/tree-sitter-types.d.ts +258 -0
  236. package/lib/dist/extraction/tree-sitter-types.d.ts.map +1 -0
  237. package/lib/dist/extraction/tree-sitter-types.js +10 -0
  238. package/lib/dist/extraction/tree-sitter-types.js.map +1 -0
  239. package/lib/dist/extraction/tree-sitter.d.ts +706 -0
  240. package/lib/dist/extraction/tree-sitter.d.ts.map +1 -0
  241. package/lib/dist/extraction/tree-sitter.js +6506 -0
  242. package/lib/dist/extraction/tree-sitter.js.map +1 -0
  243. package/lib/dist/extraction/vue-extractor.d.ts +51 -0
  244. package/lib/dist/extraction/vue-extractor.d.ts.map +1 -0
  245. package/lib/dist/extraction/vue-extractor.js +254 -0
  246. package/lib/dist/extraction/vue-extractor.js.map +1 -0
  247. package/lib/dist/extraction/wasm/tree-sitter-arkts.wasm +0 -0
  248. package/lib/dist/extraction/wasm/tree-sitter-c_sharp.wasm +0 -0
  249. package/lib/dist/extraction/wasm/tree-sitter-cfml.wasm +0 -0
  250. package/lib/dist/extraction/wasm/tree-sitter-cfquery.wasm +0 -0
  251. package/lib/dist/extraction/wasm/tree-sitter-cfscript.wasm +0 -0
  252. package/lib/dist/extraction/wasm/tree-sitter-cobol.wasm +0 -0
  253. package/lib/dist/extraction/wasm/tree-sitter-erlang.wasm +0 -0
  254. package/lib/dist/extraction/wasm/tree-sitter-lua.wasm +0 -0
  255. package/lib/dist/extraction/wasm/tree-sitter-luau.wasm +0 -0
  256. package/lib/dist/extraction/wasm/tree-sitter-nix.wasm +0 -0
  257. package/lib/dist/extraction/wasm/tree-sitter-pascal.wasm +0 -0
  258. package/lib/dist/extraction/wasm/tree-sitter-r.wasm +0 -0
  259. package/lib/dist/extraction/wasm/tree-sitter-scala.wasm +0 -0
  260. package/lib/dist/extraction/wasm/tree-sitter-terraform.wasm +0 -0
  261. package/lib/dist/extraction/wasm/tree-sitter-vbnet.wasm +0 -0
  262. package/lib/dist/extraction/wasm-runtime-flags.d.ts +38 -0
  263. package/lib/dist/extraction/wasm-runtime-flags.d.ts.map +1 -0
  264. package/lib/dist/extraction/wasm-runtime-flags.js +106 -0
  265. package/lib/dist/extraction/wasm-runtime-flags.js.map +1 -0
  266. package/lib/dist/graph/index.d.ts +8 -0
  267. package/lib/dist/graph/index.d.ts.map +1 -0
  268. package/lib/dist/graph/index.js +13 -0
  269. package/lib/dist/graph/index.js.map +1 -0
  270. package/lib/dist/graph/queries.d.ts +106 -0
  271. package/lib/dist/graph/queries.d.ts.map +1 -0
  272. package/lib/dist/graph/queries.js +339 -0
  273. package/lib/dist/graph/queries.js.map +1 -0
  274. package/lib/dist/graph/traversal.d.ts +127 -0
  275. package/lib/dist/graph/traversal.d.ts.map +1 -0
  276. package/lib/dist/graph/traversal.js +599 -0
  277. package/lib/dist/graph/traversal.js.map +1 -0
  278. package/lib/dist/index.d.ts +642 -0
  279. package/lib/dist/index.d.ts.map +1 -0
  280. package/lib/dist/index.js +1387 -0
  281. package/lib/dist/index.js.map +1 -0
  282. package/lib/dist/installer/config-writer.d.ts +28 -0
  283. package/lib/dist/installer/config-writer.d.ts.map +1 -0
  284. package/lib/dist/installer/config-writer.js +91 -0
  285. package/lib/dist/installer/config-writer.js.map +1 -0
  286. package/lib/dist/installer/index.d.ts +100 -0
  287. package/lib/dist/installer/index.d.ts.map +1 -0
  288. package/lib/dist/installer/index.js +526 -0
  289. package/lib/dist/installer/index.js.map +1 -0
  290. package/lib/dist/installer/instructions-template.d.ts +41 -0
  291. package/lib/dist/installer/instructions-template.d.ts.map +1 -0
  292. package/lib/dist/installer/instructions-template.js +53 -0
  293. package/lib/dist/installer/instructions-template.js.map +1 -0
  294. package/lib/dist/installer/targets/antigravity.d.ts +57 -0
  295. package/lib/dist/installer/targets/antigravity.d.ts.map +1 -0
  296. package/lib/dist/installer/targets/antigravity.js +308 -0
  297. package/lib/dist/installer/targets/antigravity.js.map +1 -0
  298. package/lib/dist/installer/targets/claude.d.ts +62 -0
  299. package/lib/dist/installer/targets/claude.d.ts.map +1 -0
  300. package/lib/dist/installer/targets/claude.js +454 -0
  301. package/lib/dist/installer/targets/claude.js.map +1 -0
  302. package/lib/dist/installer/targets/codex.d.ts +18 -0
  303. package/lib/dist/installer/targets/codex.d.ts.map +1 -0
  304. package/lib/dist/installer/targets/codex.js +185 -0
  305. package/lib/dist/installer/targets/codex.js.map +1 -0
  306. package/lib/dist/installer/targets/cursor.d.ts +35 -0
  307. package/lib/dist/installer/targets/cursor.d.ts.map +1 -0
  308. package/lib/dist/installer/targets/cursor.js +254 -0
  309. package/lib/dist/installer/targets/cursor.js.map +1 -0
  310. package/lib/dist/installer/targets/gemini.d.ts +26 -0
  311. package/lib/dist/installer/targets/gemini.d.ts.map +1 -0
  312. package/lib/dist/installer/targets/gemini.js +165 -0
  313. package/lib/dist/installer/targets/gemini.js.map +1 -0
  314. package/lib/dist/installer/targets/hermes.d.ts +18 -0
  315. package/lib/dist/installer/targets/hermes.d.ts.map +1 -0
  316. package/lib/dist/installer/targets/hermes.js +359 -0
  317. package/lib/dist/installer/targets/hermes.js.map +1 -0
  318. package/lib/dist/installer/targets/kiro.d.ts +27 -0
  319. package/lib/dist/installer/targets/kiro.d.ts.map +1 -0
  320. package/lib/dist/installer/targets/kiro.js +178 -0
  321. package/lib/dist/installer/targets/kiro.js.map +1 -0
  322. package/lib/dist/installer/targets/opencode.d.ts +38 -0
  323. package/lib/dist/installer/targets/opencode.d.ts.map +1 -0
  324. package/lib/dist/installer/targets/opencode.js +288 -0
  325. package/lib/dist/installer/targets/opencode.js.map +1 -0
  326. package/lib/dist/installer/targets/registry.d.ts +35 -0
  327. package/lib/dist/installer/targets/registry.d.ts.map +1 -0
  328. package/lib/dist/installer/targets/registry.js +91 -0
  329. package/lib/dist/installer/targets/registry.js.map +1 -0
  330. package/lib/dist/installer/targets/shared.d.ts +101 -0
  331. package/lib/dist/installer/targets/shared.d.ts.map +1 -0
  332. package/lib/dist/installer/targets/shared.js +264 -0
  333. package/lib/dist/installer/targets/shared.js.map +1 -0
  334. package/lib/dist/installer/targets/toml.d.ts +52 -0
  335. package/lib/dist/installer/targets/toml.d.ts.map +1 -0
  336. package/lib/dist/installer/targets/toml.js +147 -0
  337. package/lib/dist/installer/targets/toml.js.map +1 -0
  338. package/lib/dist/installer/targets/types.d.ts +108 -0
  339. package/lib/dist/installer/targets/types.d.ts.map +1 -0
  340. package/lib/dist/installer/targets/types.js +16 -0
  341. package/lib/dist/installer/targets/types.js.map +1 -0
  342. package/lib/dist/mcp/daemon-manager.d.ts +42 -0
  343. package/lib/dist/mcp/daemon-manager.d.ts.map +1 -0
  344. package/lib/dist/mcp/daemon-manager.js +129 -0
  345. package/lib/dist/mcp/daemon-manager.js.map +1 -0
  346. package/lib/dist/mcp/daemon-paths.d.ts +73 -0
  347. package/lib/dist/mcp/daemon-paths.d.ts.map +1 -0
  348. package/lib/dist/mcp/daemon-paths.js +165 -0
  349. package/lib/dist/mcp/daemon-paths.js.map +1 -0
  350. package/lib/dist/mcp/daemon-registry.d.ts +47 -0
  351. package/lib/dist/mcp/daemon-registry.d.ts.map +1 -0
  352. package/lib/dist/mcp/daemon-registry.js +233 -0
  353. package/lib/dist/mcp/daemon-registry.js.map +1 -0
  354. package/lib/dist/mcp/daemon.d.ts +290 -0
  355. package/lib/dist/mcp/daemon.d.ts.map +1 -0
  356. package/lib/dist/mcp/daemon.js +840 -0
  357. package/lib/dist/mcp/daemon.js.map +1 -0
  358. package/lib/dist/mcp/dynamic-boundaries.d.ts +41 -0
  359. package/lib/dist/mcp/dynamic-boundaries.d.ts.map +1 -0
  360. package/lib/dist/mcp/dynamic-boundaries.js +360 -0
  361. package/lib/dist/mcp/dynamic-boundaries.js.map +1 -0
  362. package/lib/dist/mcp/early-ppid.d.ts +26 -0
  363. package/lib/dist/mcp/early-ppid.d.ts.map +1 -0
  364. package/lib/dist/mcp/early-ppid.js +29 -0
  365. package/lib/dist/mcp/early-ppid.js.map +1 -0
  366. package/lib/dist/mcp/engine.d.ts +122 -0
  367. package/lib/dist/mcp/engine.d.ts.map +1 -0
  368. package/lib/dist/mcp/engine.js +350 -0
  369. package/lib/dist/mcp/engine.js.map +1 -0
  370. package/lib/dist/mcp/index.d.ts +113 -0
  371. package/lib/dist/mcp/index.d.ts.map +1 -0
  372. package/lib/dist/mcp/index.js +498 -0
  373. package/lib/dist/mcp/index.js.map +1 -0
  374. package/lib/dist/mcp/liveness-watchdog.d.ts +18 -0
  375. package/lib/dist/mcp/liveness-watchdog.d.ts.map +1 -0
  376. package/lib/dist/mcp/liveness-watchdog.js +207 -0
  377. package/lib/dist/mcp/liveness-watchdog.js.map +1 -0
  378. package/lib/dist/mcp/ppid-watchdog.d.ts +62 -0
  379. package/lib/dist/mcp/ppid-watchdog.d.ts.map +1 -0
  380. package/lib/dist/mcp/ppid-watchdog.js +64 -0
  381. package/lib/dist/mcp/ppid-watchdog.js.map +1 -0
  382. package/lib/dist/mcp/proxy.d.ts +87 -0
  383. package/lib/dist/mcp/proxy.d.ts.map +1 -0
  384. package/lib/dist/mcp/proxy.js +659 -0
  385. package/lib/dist/mcp/proxy.js.map +1 -0
  386. package/lib/dist/mcp/query-pool.d.ts +94 -0
  387. package/lib/dist/mcp/query-pool.d.ts.map +1 -0
  388. package/lib/dist/mcp/query-pool.js +297 -0
  389. package/lib/dist/mcp/query-pool.js.map +1 -0
  390. package/lib/dist/mcp/query-worker.d.ts +24 -0
  391. package/lib/dist/mcp/query-worker.d.ts.map +1 -0
  392. package/lib/dist/mcp/query-worker.js +87 -0
  393. package/lib/dist/mcp/query-worker.js.map +1 -0
  394. package/lib/dist/mcp/server-instructions.d.ts +34 -0
  395. package/lib/dist/mcp/server-instructions.d.ts.map +1 -0
  396. package/lib/dist/mcp/server-instructions.js +106 -0
  397. package/lib/dist/mcp/server-instructions.js.map +1 -0
  398. package/lib/dist/mcp/session.d.ts +79 -0
  399. package/lib/dist/mcp/session.d.ts.map +1 -0
  400. package/lib/dist/mcp/session.js +330 -0
  401. package/lib/dist/mcp/session.js.map +1 -0
  402. package/lib/dist/mcp/startup-handshake.d.ts +44 -0
  403. package/lib/dist/mcp/startup-handshake.d.ts.map +1 -0
  404. package/lib/dist/mcp/startup-handshake.js +73 -0
  405. package/lib/dist/mcp/startup-handshake.js.map +1 -0
  406. package/lib/dist/mcp/stdin-teardown.d.ts +27 -0
  407. package/lib/dist/mcp/stdin-teardown.d.ts.map +1 -0
  408. package/lib/dist/mcp/stdin-teardown.js +49 -0
  409. package/lib/dist/mcp/stdin-teardown.js.map +1 -0
  410. package/lib/dist/mcp/tools.d.ts +613 -0
  411. package/lib/dist/mcp/tools.d.ts.map +1 -0
  412. package/lib/dist/mcp/tools.js +4424 -0
  413. package/lib/dist/mcp/tools.js.map +1 -0
  414. package/lib/dist/mcp/transport.d.ts +188 -0
  415. package/lib/dist/mcp/transport.d.ts.map +1 -0
  416. package/lib/dist/mcp/transport.js +359 -0
  417. package/lib/dist/mcp/transport.js.map +1 -0
  418. package/lib/dist/mcp/version.d.ts +19 -0
  419. package/lib/dist/mcp/version.d.ts.map +1 -0
  420. package/lib/dist/mcp/version.js +71 -0
  421. package/lib/dist/mcp/version.js.map +1 -0
  422. package/lib/dist/project-config.d.ts +94 -0
  423. package/lib/dist/project-config.d.ts.map +1 -0
  424. package/lib/dist/project-config.js +374 -0
  425. package/lib/dist/project-config.js.map +1 -0
  426. package/lib/dist/resolution/c-fnptr-synthesizer.d.ts +5 -0
  427. package/lib/dist/resolution/c-fnptr-synthesizer.d.ts.map +1 -0
  428. package/lib/dist/resolution/c-fnptr-synthesizer.js +1038 -0
  429. package/lib/dist/resolution/c-fnptr-synthesizer.js.map +1 -0
  430. package/lib/dist/resolution/callback-synthesizer.d.ts +15 -0
  431. package/lib/dist/resolution/callback-synthesizer.d.ts.map +1 -0
  432. package/lib/dist/resolution/callback-synthesizer.js +3658 -0
  433. package/lib/dist/resolution/callback-synthesizer.js.map +1 -0
  434. package/lib/dist/resolution/cooperative-yield.d.ts +32 -0
  435. package/lib/dist/resolution/cooperative-yield.d.ts.map +1 -0
  436. package/lib/dist/resolution/cooperative-yield.js +42 -0
  437. package/lib/dist/resolution/cooperative-yield.js.map +1 -0
  438. package/lib/dist/resolution/frameworks/astro.d.ts +9 -0
  439. package/lib/dist/resolution/frameworks/astro.d.ts.map +1 -0
  440. package/lib/dist/resolution/frameworks/astro.js +169 -0
  441. package/lib/dist/resolution/frameworks/astro.js.map +1 -0
  442. package/lib/dist/resolution/frameworks/cargo-workspace.d.ts +18 -0
  443. package/lib/dist/resolution/frameworks/cargo-workspace.d.ts.map +1 -0
  444. package/lib/dist/resolution/frameworks/cargo-workspace.js +225 -0
  445. package/lib/dist/resolution/frameworks/cargo-workspace.js.map +1 -0
  446. package/lib/dist/resolution/frameworks/cics.d.ts +20 -0
  447. package/lib/dist/resolution/frameworks/cics.d.ts.map +1 -0
  448. package/lib/dist/resolution/frameworks/cics.js +90 -0
  449. package/lib/dist/resolution/frameworks/cics.js.map +1 -0
  450. package/lib/dist/resolution/frameworks/csharp.d.ts +8 -0
  451. package/lib/dist/resolution/frameworks/csharp.d.ts.map +1 -0
  452. package/lib/dist/resolution/frameworks/csharp.js +241 -0
  453. package/lib/dist/resolution/frameworks/csharp.js.map +1 -0
  454. package/lib/dist/resolution/frameworks/drupal.d.ts +51 -0
  455. package/lib/dist/resolution/frameworks/drupal.d.ts.map +1 -0
  456. package/lib/dist/resolution/frameworks/drupal.js +367 -0
  457. package/lib/dist/resolution/frameworks/drupal.js.map +1 -0
  458. package/lib/dist/resolution/frameworks/expo-modules.d.ts +3 -0
  459. package/lib/dist/resolution/frameworks/expo-modules.d.ts.map +1 -0
  460. package/lib/dist/resolution/frameworks/expo-modules.js +148 -0
  461. package/lib/dist/resolution/frameworks/expo-modules.js.map +1 -0
  462. package/lib/dist/resolution/frameworks/express.d.ts +8 -0
  463. package/lib/dist/resolution/frameworks/express.d.ts.map +1 -0
  464. package/lib/dist/resolution/frameworks/express.js +308 -0
  465. package/lib/dist/resolution/frameworks/express.js.map +1 -0
  466. package/lib/dist/resolution/frameworks/fabric.d.ts +3 -0
  467. package/lib/dist/resolution/frameworks/fabric.d.ts.map +1 -0
  468. package/lib/dist/resolution/frameworks/fabric.js +354 -0
  469. package/lib/dist/resolution/frameworks/fabric.js.map +1 -0
  470. package/lib/dist/resolution/frameworks/go.d.ts +8 -0
  471. package/lib/dist/resolution/frameworks/go.d.ts.map +1 -0
  472. package/lib/dist/resolution/frameworks/go.js +161 -0
  473. package/lib/dist/resolution/frameworks/go.js.map +1 -0
  474. package/lib/dist/resolution/frameworks/goframe.d.ts +41 -0
  475. package/lib/dist/resolution/frameworks/goframe.d.ts.map +1 -0
  476. package/lib/dist/resolution/frameworks/goframe.js +112 -0
  477. package/lib/dist/resolution/frameworks/goframe.js.map +1 -0
  478. package/lib/dist/resolution/frameworks/index.d.ts +50 -0
  479. package/lib/dist/resolution/frameworks/index.d.ts.map +1 -0
  480. package/lib/dist/resolution/frameworks/index.js +175 -0
  481. package/lib/dist/resolution/frameworks/index.js.map +1 -0
  482. package/lib/dist/resolution/frameworks/java.d.ts +8 -0
  483. package/lib/dist/resolution/frameworks/java.d.ts.map +1 -0
  484. package/lib/dist/resolution/frameworks/java.js +517 -0
  485. package/lib/dist/resolution/frameworks/java.js.map +1 -0
  486. package/lib/dist/resolution/frameworks/laravel.d.ts +13 -0
  487. package/lib/dist/resolution/frameworks/laravel.d.ts.map +1 -0
  488. package/lib/dist/resolution/frameworks/laravel.js +257 -0
  489. package/lib/dist/resolution/frameworks/laravel.js.map +1 -0
  490. package/lib/dist/resolution/frameworks/nestjs.d.ts +26 -0
  491. package/lib/dist/resolution/frameworks/nestjs.d.ts.map +1 -0
  492. package/lib/dist/resolution/frameworks/nestjs.js +698 -0
  493. package/lib/dist/resolution/frameworks/nestjs.js.map +1 -0
  494. package/lib/dist/resolution/frameworks/play.d.ts +19 -0
  495. package/lib/dist/resolution/frameworks/play.d.ts.map +1 -0
  496. package/lib/dist/resolution/frameworks/play.js +111 -0
  497. package/lib/dist/resolution/frameworks/play.js.map +1 -0
  498. package/lib/dist/resolution/frameworks/python.d.ts +10 -0
  499. package/lib/dist/resolution/frameworks/python.d.ts.map +1 -0
  500. package/lib/dist/resolution/frameworks/python.js +400 -0
  501. package/lib/dist/resolution/frameworks/python.js.map +1 -0
  502. package/lib/dist/resolution/frameworks/react-native.d.ts +3 -0
  503. package/lib/dist/resolution/frameworks/react-native.d.ts.map +1 -0
  504. package/lib/dist/resolution/frameworks/react-native.js +410 -0
  505. package/lib/dist/resolution/frameworks/react-native.js.map +1 -0
  506. package/lib/dist/resolution/frameworks/react.d.ts +8 -0
  507. package/lib/dist/resolution/frameworks/react.d.ts.map +1 -0
  508. package/lib/dist/resolution/frameworks/react.js +334 -0
  509. package/lib/dist/resolution/frameworks/react.js.map +1 -0
  510. package/lib/dist/resolution/frameworks/ruby.d.ts +8 -0
  511. package/lib/dist/resolution/frameworks/ruby.d.ts.map +1 -0
  512. package/lib/dist/resolution/frameworks/ruby.js +302 -0
  513. package/lib/dist/resolution/frameworks/ruby.js.map +1 -0
  514. package/lib/dist/resolution/frameworks/rust.d.ts +8 -0
  515. package/lib/dist/resolution/frameworks/rust.d.ts.map +1 -0
  516. package/lib/dist/resolution/frameworks/rust.js +304 -0
  517. package/lib/dist/resolution/frameworks/rust.js.map +1 -0
  518. package/lib/dist/resolution/frameworks/svelte.d.ts +9 -0
  519. package/lib/dist/resolution/frameworks/svelte.d.ts.map +1 -0
  520. package/lib/dist/resolution/frameworks/svelte.js +253 -0
  521. package/lib/dist/resolution/frameworks/svelte.js.map +1 -0
  522. package/lib/dist/resolution/frameworks/swift-objc.d.ts +37 -0
  523. package/lib/dist/resolution/frameworks/swift-objc.d.ts.map +1 -0
  524. package/lib/dist/resolution/frameworks/swift-objc.js +252 -0
  525. package/lib/dist/resolution/frameworks/swift-objc.js.map +1 -0
  526. package/lib/dist/resolution/frameworks/swift.d.ts +10 -0
  527. package/lib/dist/resolution/frameworks/swift.d.ts.map +1 -0
  528. package/lib/dist/resolution/frameworks/swift.js +400 -0
  529. package/lib/dist/resolution/frameworks/swift.js.map +1 -0
  530. package/lib/dist/resolution/frameworks/terraform.d.ts +38 -0
  531. package/lib/dist/resolution/frameworks/terraform.d.ts.map +1 -0
  532. package/lib/dist/resolution/frameworks/terraform.js +277 -0
  533. package/lib/dist/resolution/frameworks/terraform.js.map +1 -0
  534. package/lib/dist/resolution/frameworks/vue.d.ts +9 -0
  535. package/lib/dist/resolution/frameworks/vue.d.ts.map +1 -0
  536. package/lib/dist/resolution/frameworks/vue.js +303 -0
  537. package/lib/dist/resolution/frameworks/vue.js.map +1 -0
  538. package/lib/dist/resolution/go-module.d.ts +26 -0
  539. package/lib/dist/resolution/go-module.d.ts.map +1 -0
  540. package/lib/dist/resolution/go-module.js +78 -0
  541. package/lib/dist/resolution/go-module.js.map +1 -0
  542. package/lib/dist/resolution/goframe-synthesizer.d.ts +28 -0
  543. package/lib/dist/resolution/goframe-synthesizer.d.ts.map +1 -0
  544. package/lib/dist/resolution/goframe-synthesizer.js +158 -0
  545. package/lib/dist/resolution/goframe-synthesizer.js.map +1 -0
  546. package/lib/dist/resolution/import-resolver.d.ts +85 -0
  547. package/lib/dist/resolution/import-resolver.d.ts.map +1 -0
  548. package/lib/dist/resolution/import-resolver.js +1974 -0
  549. package/lib/dist/resolution/import-resolver.js.map +1 -0
  550. package/lib/dist/resolution/index.d.ts +238 -0
  551. package/lib/dist/resolution/index.d.ts.map +1 -0
  552. package/lib/dist/resolution/index.js +1633 -0
  553. package/lib/dist/resolution/index.js.map +1 -0
  554. package/lib/dist/resolution/lru-cache.d.ts +24 -0
  555. package/lib/dist/resolution/lru-cache.d.ts.map +1 -0
  556. package/lib/dist/resolution/lru-cache.js +62 -0
  557. package/lib/dist/resolution/lru-cache.js.map +1 -0
  558. package/lib/dist/resolution/name-matcher.d.ts +112 -0
  559. package/lib/dist/resolution/name-matcher.d.ts.map +1 -0
  560. package/lib/dist/resolution/name-matcher.js +1701 -0
  561. package/lib/dist/resolution/name-matcher.js.map +1 -0
  562. package/lib/dist/resolution/path-aliases.d.ts +68 -0
  563. package/lib/dist/resolution/path-aliases.d.ts.map +1 -0
  564. package/lib/dist/resolution/path-aliases.js +238 -0
  565. package/lib/dist/resolution/path-aliases.js.map +1 -0
  566. package/lib/dist/resolution/strip-comments.d.ts +27 -0
  567. package/lib/dist/resolution/strip-comments.d.ts.map +1 -0
  568. package/lib/dist/resolution/strip-comments.js +492 -0
  569. package/lib/dist/resolution/strip-comments.js.map +1 -0
  570. package/lib/dist/resolution/swift-objc-bridge.d.ts +134 -0
  571. package/lib/dist/resolution/swift-objc-bridge.d.ts.map +1 -0
  572. package/lib/dist/resolution/swift-objc-bridge.js +256 -0
  573. package/lib/dist/resolution/swift-objc-bridge.js.map +1 -0
  574. package/lib/dist/resolution/types.d.ts +253 -0
  575. package/lib/dist/resolution/types.d.ts.map +1 -0
  576. package/lib/dist/resolution/types.js +8 -0
  577. package/lib/dist/resolution/types.js.map +1 -0
  578. package/lib/dist/resolution/workspace-packages.d.ts +58 -0
  579. package/lib/dist/resolution/workspace-packages.d.ts.map +1 -0
  580. package/lib/dist/resolution/workspace-packages.js +346 -0
  581. package/lib/dist/resolution/workspace-packages.js.map +1 -0
  582. package/lib/dist/search/identifier-segments.d.ts +60 -0
  583. package/lib/dist/search/identifier-segments.d.ts.map +1 -0
  584. package/lib/dist/search/identifier-segments.js +176 -0
  585. package/lib/dist/search/identifier-segments.js.map +1 -0
  586. package/lib/dist/search/query-parser.d.ts +57 -0
  587. package/lib/dist/search/query-parser.d.ts.map +1 -0
  588. package/lib/dist/search/query-parser.js +177 -0
  589. package/lib/dist/search/query-parser.js.map +1 -0
  590. package/lib/dist/search/query-utils.d.ts +87 -0
  591. package/lib/dist/search/query-utils.d.ts.map +1 -0
  592. package/lib/dist/search/query-utils.js +449 -0
  593. package/lib/dist/search/query-utils.js.map +1 -0
  594. package/lib/dist/sync/git-hooks.d.ts +45 -0
  595. package/lib/dist/sync/git-hooks.d.ts.map +1 -0
  596. package/lib/dist/sync/git-hooks.js +227 -0
  597. package/lib/dist/sync/git-hooks.js.map +1 -0
  598. package/lib/dist/sync/index.d.ts +19 -0
  599. package/lib/dist/sync/index.d.ts.map +1 -0
  600. package/lib/dist/sync/index.js +35 -0
  601. package/lib/dist/sync/index.js.map +1 -0
  602. package/lib/dist/sync/watch-policy.d.ts +48 -0
  603. package/lib/dist/sync/watch-policy.d.ts.map +1 -0
  604. package/lib/dist/sync/watch-policy.js +124 -0
  605. package/lib/dist/sync/watch-policy.js.map +1 -0
  606. package/lib/dist/sync/watcher.d.ts +355 -0
  607. package/lib/dist/sync/watcher.d.ts.map +1 -0
  608. package/lib/dist/sync/watcher.js +848 -0
  609. package/lib/dist/sync/watcher.js.map +1 -0
  610. package/lib/dist/sync/worktree.d.ts +63 -0
  611. package/lib/dist/sync/worktree.d.ts.map +1 -0
  612. package/lib/dist/sync/worktree.js +182 -0
  613. package/lib/dist/sync/worktree.js.map +1 -0
  614. package/lib/dist/telemetry/index.d.ts +143 -0
  615. package/lib/dist/telemetry/index.d.ts.map +1 -0
  616. package/lib/dist/telemetry/index.js +541 -0
  617. package/lib/dist/telemetry/index.js.map +1 -0
  618. package/lib/dist/types.d.ts +415 -0
  619. package/lib/dist/types.d.ts.map +1 -0
  620. package/lib/dist/types.js +91 -0
  621. package/lib/dist/types.js.map +1 -0
  622. package/lib/dist/ui/glyphs.d.ts +42 -0
  623. package/lib/dist/ui/glyphs.d.ts.map +1 -0
  624. package/lib/dist/ui/glyphs.js +78 -0
  625. package/lib/dist/ui/glyphs.js.map +1 -0
  626. package/lib/dist/ui/shimmer-progress.d.ts +11 -0
  627. package/lib/dist/ui/shimmer-progress.d.ts.map +1 -0
  628. package/lib/dist/ui/shimmer-progress.js +90 -0
  629. package/lib/dist/ui/shimmer-progress.js.map +1 -0
  630. package/lib/dist/ui/shimmer-worker.d.ts +2 -0
  631. package/lib/dist/ui/shimmer-worker.d.ts.map +1 -0
  632. package/lib/dist/ui/shimmer-worker.js +118 -0
  633. package/lib/dist/ui/shimmer-worker.js.map +1 -0
  634. package/lib/dist/ui/types.d.ts +17 -0
  635. package/lib/dist/ui/types.d.ts.map +1 -0
  636. package/lib/dist/ui/types.js +3 -0
  637. package/lib/dist/ui/types.js.map +1 -0
  638. package/lib/dist/upgrade/index.d.ts +132 -0
  639. package/lib/dist/upgrade/index.d.ts.map +1 -0
  640. package/lib/dist/upgrade/index.js +498 -0
  641. package/lib/dist/upgrade/index.js.map +1 -0
  642. package/lib/dist/utils.d.ts +224 -0
  643. package/lib/dist/utils.d.ts.map +1 -0
  644. package/lib/dist/utils.js +583 -0
  645. package/lib/dist/utils.js.map +1 -0
  646. package/lib/node_modules/.package-lock.json +125 -0
  647. package/lib/node_modules/@clack/core/CHANGELOG.md +348 -0
  648. package/lib/node_modules/@clack/core/LICENSE +9 -0
  649. package/lib/node_modules/@clack/core/README.md +22 -0
  650. package/lib/node_modules/@clack/core/dist/index.d.mts +363 -0
  651. package/lib/node_modules/@clack/core/dist/index.mjs +17 -0
  652. package/lib/node_modules/@clack/core/dist/index.mjs.map +1 -0
  653. package/lib/node_modules/@clack/core/package.json +63 -0
  654. package/lib/node_modules/@clack/prompts/CHANGELOG.md +591 -0
  655. package/lib/node_modules/@clack/prompts/LICENSE +9 -0
  656. package/lib/node_modules/@clack/prompts/README.md +375 -0
  657. package/lib/node_modules/@clack/prompts/dist/index.d.mts +396 -0
  658. package/lib/node_modules/@clack/prompts/dist/index.mjs +144 -0
  659. package/lib/node_modules/@clack/prompts/dist/index.mjs.map +1 -0
  660. package/lib/node_modules/@clack/prompts/package.json +68 -0
  661. package/lib/node_modules/commander/LICENSE +22 -0
  662. package/lib/node_modules/commander/Readme.md +1176 -0
  663. package/lib/node_modules/commander/esm.mjs +16 -0
  664. package/lib/node_modules/commander/index.js +24 -0
  665. package/lib/node_modules/commander/lib/argument.js +150 -0
  666. package/lib/node_modules/commander/lib/command.js +2777 -0
  667. package/lib/node_modules/commander/lib/error.js +39 -0
  668. package/lib/node_modules/commander/lib/help.js +747 -0
  669. package/lib/node_modules/commander/lib/option.js +380 -0
  670. package/lib/node_modules/commander/lib/suggestSimilar.js +101 -0
  671. package/lib/node_modules/commander/package-support.json +19 -0
  672. package/lib/node_modules/commander/package.json +82 -0
  673. package/lib/node_modules/commander/typings/esm.d.mts +3 -0
  674. package/lib/node_modules/commander/typings/index.d.ts +1113 -0
  675. package/lib/node_modules/fast-string-truncated-width/dist/index.d.ts +4 -0
  676. package/lib/node_modules/fast-string-truncated-width/dist/index.js +111 -0
  677. package/lib/node_modules/fast-string-truncated-width/dist/types.d.ts +19 -0
  678. package/lib/node_modules/fast-string-truncated-width/dist/types.js +2 -0
  679. package/lib/node_modules/fast-string-truncated-width/dist/utils.d.ts +4 -0
  680. package/lib/node_modules/fast-string-truncated-width/dist/utils.js +20 -0
  681. package/lib/node_modules/fast-string-truncated-width/license +21 -0
  682. package/lib/node_modules/fast-string-truncated-width/package.json +35 -0
  683. package/lib/node_modules/fast-string-truncated-width/readme.md +59 -0
  684. package/lib/node_modules/fast-string-width/dist/index.d.ts +4 -0
  685. package/lib/node_modules/fast-string-width/dist/index.js +14 -0
  686. package/lib/node_modules/fast-string-width/license +21 -0
  687. package/lib/node_modules/fast-string-width/package.json +34 -0
  688. package/lib/node_modules/fast-string-width/readme.md +42 -0
  689. package/lib/node_modules/fast-wrap-ansi/LICENSE +23 -0
  690. package/lib/node_modules/fast-wrap-ansi/README.md +26 -0
  691. package/lib/node_modules/fast-wrap-ansi/lib/main.d.ts +6 -0
  692. package/lib/node_modules/fast-wrap-ansi/lib/main.js +219 -0
  693. package/lib/node_modules/fast-wrap-ansi/lib/main.js.map +1 -0
  694. package/lib/node_modules/fast-wrap-ansi/package.json +51 -0
  695. package/lib/node_modules/ignore/LICENSE-MIT +21 -0
  696. package/lib/node_modules/ignore/README.md +452 -0
  697. package/lib/node_modules/ignore/index.d.ts +81 -0
  698. package/lib/node_modules/ignore/index.js +784 -0
  699. package/lib/node_modules/ignore/legacy.js +681 -0
  700. package/lib/node_modules/ignore/package.json +87 -0
  701. package/lib/node_modules/jsonc-parser/CHANGELOG.md +76 -0
  702. package/lib/node_modules/jsonc-parser/LICENSE.md +21 -0
  703. package/lib/node_modules/jsonc-parser/README.md +364 -0
  704. package/lib/node_modules/jsonc-parser/SECURITY.md +41 -0
  705. package/lib/node_modules/jsonc-parser/lib/esm/impl/edit.js +185 -0
  706. package/lib/node_modules/jsonc-parser/lib/esm/impl/format.js +261 -0
  707. package/lib/node_modules/jsonc-parser/lib/esm/impl/parser.js +659 -0
  708. package/lib/node_modules/jsonc-parser/lib/esm/impl/scanner.js +443 -0
  709. package/lib/node_modules/jsonc-parser/lib/esm/impl/string-intern.js +29 -0
  710. package/lib/node_modules/jsonc-parser/lib/esm/main.d.ts +351 -0
  711. package/lib/node_modules/jsonc-parser/lib/esm/main.js +178 -0
  712. package/lib/node_modules/jsonc-parser/lib/umd/impl/edit.js +201 -0
  713. package/lib/node_modules/jsonc-parser/lib/umd/impl/format.js +275 -0
  714. package/lib/node_modules/jsonc-parser/lib/umd/impl/parser.js +682 -0
  715. package/lib/node_modules/jsonc-parser/lib/umd/impl/scanner.js +456 -0
  716. package/lib/node_modules/jsonc-parser/lib/umd/impl/string-intern.js +42 -0
  717. package/lib/node_modules/jsonc-parser/lib/umd/main.d.ts +351 -0
  718. package/lib/node_modules/jsonc-parser/lib/umd/main.js +194 -0
  719. package/lib/node_modules/jsonc-parser/package.json +37 -0
  720. package/lib/node_modules/picomatch/LICENSE +21 -0
  721. package/lib/node_modules/picomatch/README.md +738 -0
  722. package/lib/node_modules/picomatch/index.js +17 -0
  723. package/lib/node_modules/picomatch/lib/constants.js +180 -0
  724. package/lib/node_modules/picomatch/lib/parse.js +1085 -0
  725. package/lib/node_modules/picomatch/lib/picomatch.js +341 -0
  726. package/lib/node_modules/picomatch/lib/scan.js +391 -0
  727. package/lib/node_modules/picomatch/lib/utils.js +72 -0
  728. package/lib/node_modules/picomatch/package.json +83 -0
  729. package/lib/node_modules/picomatch/posix.js +3 -0
  730. package/lib/node_modules/sisteransi/license +21 -0
  731. package/lib/node_modules/sisteransi/package.json +34 -0
  732. package/lib/node_modules/sisteransi/readme.md +113 -0
  733. package/lib/node_modules/sisteransi/src/index.js +58 -0
  734. package/lib/node_modules/sisteransi/src/sisteransi.d.ts +35 -0
  735. package/lib/node_modules/tree-sitter-wasms/LICENSE +24 -0
  736. package/lib/node_modules/tree-sitter-wasms/README.md +23 -0
  737. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-bash.wasm +0 -0
  738. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-c.wasm +0 -0
  739. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-c_sharp.wasm +0 -0
  740. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-cpp.wasm +0 -0
  741. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-css.wasm +0 -0
  742. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-dart.wasm +0 -0
  743. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-elisp.wasm +0 -0
  744. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-elixir.wasm +0 -0
  745. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-elm.wasm +0 -0
  746. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-embedded_template.wasm +0 -0
  747. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-go.wasm +0 -0
  748. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-html.wasm +0 -0
  749. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-java.wasm +0 -0
  750. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-javascript.wasm +0 -0
  751. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-json.wasm +0 -0
  752. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-kotlin.wasm +0 -0
  753. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-lua.wasm +0 -0
  754. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-objc.wasm +0 -0
  755. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-ocaml.wasm +0 -0
  756. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-php.wasm +0 -0
  757. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-python.wasm +0 -0
  758. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-ql.wasm +0 -0
  759. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-rescript.wasm +0 -0
  760. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-ruby.wasm +0 -0
  761. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-rust.wasm +0 -0
  762. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-scala.wasm +0 -0
  763. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-solidity.wasm +0 -0
  764. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-swift.wasm +0 -0
  765. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-systemrdl.wasm +0 -0
  766. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-tlaplus.wasm +0 -0
  767. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-toml.wasm +0 -0
  768. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-tsx.wasm +0 -0
  769. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-typescript.wasm +0 -0
  770. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-vue.wasm +0 -0
  771. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-yaml.wasm +0 -0
  772. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-zig.wasm +0 -0
  773. package/lib/node_modules/tree-sitter-wasms/package.json +64 -0
  774. package/lib/node_modules/web-tree-sitter/LICENSE +21 -0
  775. package/lib/node_modules/web-tree-sitter/README.md +269 -0
  776. package/lib/node_modules/web-tree-sitter/debug/tree-sitter.cjs +4558 -0
  777. package/lib/node_modules/web-tree-sitter/debug/tree-sitter.cjs.map +7 -0
  778. package/lib/node_modules/web-tree-sitter/debug/tree-sitter.js +4516 -0
  779. package/lib/node_modules/web-tree-sitter/debug/tree-sitter.js.map +7 -0
  780. package/lib/node_modules/web-tree-sitter/debug/tree-sitter.wasm +0 -0
  781. package/lib/node_modules/web-tree-sitter/debug/tree-sitter.wasm.map +31 -0
  782. package/lib/node_modules/web-tree-sitter/lib/alloc.c +48 -0
  783. package/lib/node_modules/web-tree-sitter/lib/alloc.h +41 -0
  784. package/lib/node_modules/web-tree-sitter/lib/array.h +291 -0
  785. package/lib/node_modules/web-tree-sitter/lib/atomic.h +68 -0
  786. package/lib/node_modules/web-tree-sitter/lib/clock.h +146 -0
  787. package/lib/node_modules/web-tree-sitter/lib/error_costs.h +11 -0
  788. package/lib/node_modules/web-tree-sitter/lib/get_changed_ranges.c +523 -0
  789. package/lib/node_modules/web-tree-sitter/lib/get_changed_ranges.h +36 -0
  790. package/lib/node_modules/web-tree-sitter/lib/host.h +21 -0
  791. package/lib/node_modules/web-tree-sitter/lib/language.c +293 -0
  792. package/lib/node_modules/web-tree-sitter/lib/language.h +293 -0
  793. package/lib/node_modules/web-tree-sitter/lib/length.h +52 -0
  794. package/lib/node_modules/web-tree-sitter/lib/lexer.c +483 -0
  795. package/lib/node_modules/web-tree-sitter/lib/lexer.h +54 -0
  796. package/lib/node_modules/web-tree-sitter/lib/lib.c +12 -0
  797. package/lib/node_modules/web-tree-sitter/lib/node.c +875 -0
  798. package/lib/node_modules/web-tree-sitter/lib/parser.c +2297 -0
  799. package/lib/node_modules/web-tree-sitter/lib/parser.h +286 -0
  800. package/lib/node_modules/web-tree-sitter/lib/point.h +48 -0
  801. package/lib/node_modules/web-tree-sitter/lib/query.c +4347 -0
  802. package/lib/node_modules/web-tree-sitter/lib/reduce_action.h +34 -0
  803. package/lib/node_modules/web-tree-sitter/lib/reusable_node.h +95 -0
  804. package/lib/node_modules/web-tree-sitter/lib/stack.c +912 -0
  805. package/lib/node_modules/web-tree-sitter/lib/stack.h +133 -0
  806. package/lib/node_modules/web-tree-sitter/lib/subtree.c +1034 -0
  807. package/lib/node_modules/web-tree-sitter/lib/subtree.h +399 -0
  808. package/lib/node_modules/web-tree-sitter/lib/tree-sitter.c +987 -0
  809. package/lib/node_modules/web-tree-sitter/lib/tree-sitter.cjs +2988 -0
  810. package/lib/node_modules/web-tree-sitter/lib/tree-sitter.wasm +0 -0
  811. package/lib/node_modules/web-tree-sitter/lib/tree-sitter.wasm.map +1 -0
  812. package/lib/node_modules/web-tree-sitter/lib/tree.c +170 -0
  813. package/lib/node_modules/web-tree-sitter/lib/tree.h +31 -0
  814. package/lib/node_modules/web-tree-sitter/lib/tree_cursor.c +716 -0
  815. package/lib/node_modules/web-tree-sitter/lib/tree_cursor.h +48 -0
  816. package/lib/node_modules/web-tree-sitter/lib/ts_assert.h +11 -0
  817. package/lib/node_modules/web-tree-sitter/lib/unicode.h +75 -0
  818. package/lib/node_modules/web-tree-sitter/lib/wasm_store.c +1937 -0
  819. package/lib/node_modules/web-tree-sitter/lib/wasm_store.h +31 -0
  820. package/lib/node_modules/web-tree-sitter/package.json +98 -0
  821. package/lib/node_modules/web-tree-sitter/src/bindings.ts +26 -0
  822. package/lib/node_modules/web-tree-sitter/src/constants.ts +133 -0
  823. package/lib/node_modules/web-tree-sitter/src/index.ts +31 -0
  824. package/lib/node_modules/web-tree-sitter/src/language.ts +291 -0
  825. package/lib/node_modules/web-tree-sitter/src/lookahead_iterator.ts +75 -0
  826. package/lib/node_modules/web-tree-sitter/src/marshal.ts +176 -0
  827. package/lib/node_modules/web-tree-sitter/src/node.ts +646 -0
  828. package/lib/node_modules/web-tree-sitter/src/parser.ts +325 -0
  829. package/lib/node_modules/web-tree-sitter/src/query.ts +973 -0
  830. package/lib/node_modules/web-tree-sitter/src/tree.ts +145 -0
  831. package/lib/node_modules/web-tree-sitter/src/tree_cursor.ts +318 -0
  832. package/lib/node_modules/web-tree-sitter/tree-sitter.cjs +4031 -0
  833. package/lib/node_modules/web-tree-sitter/tree-sitter.cjs.map +7 -0
  834. package/lib/node_modules/web-tree-sitter/tree-sitter.js +3980 -0
  835. package/lib/node_modules/web-tree-sitter/tree-sitter.js.map +7 -0
  836. package/lib/node_modules/web-tree-sitter/tree-sitter.wasm +0 -0
  837. package/lib/node_modules/web-tree-sitter/tree-sitter.wasm.map +30 -0
  838. package/lib/node_modules/web-tree-sitter/web-tree-sitter.d.ts +1030 -0
  839. package/lib/node_modules/web-tree-sitter/web-tree-sitter.d.ts.map +56 -0
  840. package/lib/package.json +64 -0
  841. package/node.exe +0 -0
  842. package/package.json +17 -0
@@ -0,0 +1,848 @@
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
+ /** Actionable degrade message; both exhaustion paths share it verbatim. */
98
+ const EXHAUSTION_REASON = 'OS watch/file limit exhausted; auto-sync disabled. Run `bhgraph sync` ' +
99
+ '(or install git sync hooks) to refresh the graph after changes.';
100
+ /**
101
+ * Actionable, NON-fatal warning for Linux inotify watch-count exhaustion.
102
+ * Unlike {@link EXHAUSTION_REASON} this does not disable the watcher — the
103
+ * watches already installed keep working — so it names the exact kernel knob to
104
+ * raise instead.
105
+ */
106
+ const INOTIFY_LIMIT_REASON = 'Linux inotify watch limit reached (fs.inotify.max_user_watches); live ' +
107
+ 'watching now covers only part of the project, so edits in unwatched ' +
108
+ 'directories will not auto-sync. Raise the limit (e.g. `sudo sysctl ' +
109
+ 'fs.inotify.max_user_watches=1048576`, persisted in /etc/sysctl.d) and ' +
110
+ 'restart, or run `bhgraph sync` (or install git sync hooks) to refresh.';
111
+ /**
112
+ * True when an error is OS watch/file-descriptor exhaustion (EMFILE/ENFILE).
113
+ * Prefers the structured `err.code`; falls back to message matching ONLY when
114
+ * no code is present (some platforms surface a bare Error from `fs.watch`).
115
+ */
116
+ function isWatchResourceExhaustion(err) {
117
+ const e = err;
118
+ if (e?.code === 'EMFILE' || e?.code === 'ENFILE')
119
+ return true;
120
+ if (!e?.code && e?.message) {
121
+ return /EMFILE|ENFILE|too many open files/i.test(e.message);
122
+ }
123
+ return false;
124
+ }
125
+ /**
126
+ * True when an error is Linux inotify *watch-count* exhaustion. `fs.watch`
127
+ * surfaces a hit `fs.inotify.max_user_watches` as ENOSPC ("no space" = no watch
128
+ * descriptors left, NOT disk space). This only arises on the Linux
129
+ * per-directory path; it is non-fatal (raise the limit and partial watching
130
+ * keeps working), so it warns rather than degrading.
131
+ */
132
+ function isInotifyWatchExhaustion(err) {
133
+ return err?.code === 'ENOSPC';
134
+ }
135
+ /**
136
+ * Native recursive `fs.watch` is only reliable on macOS and Windows; on Linux
137
+ * (and AIX) it throws `ERR_FEATURE_UNAVAILABLE_ON_PLATFORM`. We branch on this
138
+ * to pick the recursive vs per-directory strategy.
139
+ */
140
+ function supportsRecursiveWatch() {
141
+ return process.platform === 'darwin' || process.platform === 'win32';
142
+ }
143
+ let watchImpl = fs.watch;
144
+ /** @internal Test-only seam to inject a fake fs.watch implementation. */
145
+ function __setFsWatchForTests(fn) {
146
+ watchImpl = fn ?? fs.watch;
147
+ }
148
+ /**
149
+ * Upper bound on simultaneously-watched directories on the Linux per-directory
150
+ * path. Each is one inotify watch; the kernel's `fs.inotify.max_user_watches`
151
+ * is the hard limit (commonly 8k–128k). We stop adding watches past this and
152
+ * log once — partial live-watch (with `bhgraph sync` as the backstop) is far
153
+ * better than exhausting the user's inotify budget and breaking watching
154
+ * system-wide (#579). Tunable via BHGRAPH_MAX_DIR_WATCHES.
155
+ */
156
+ const DEFAULT_MAX_DIR_WATCHES = 50_000;
157
+ function maxDirWatches() {
158
+ const raw = process.env.BHGRAPH_MAX_DIR_WATCHES;
159
+ if (raw && /^\d+$/.test(raw)) {
160
+ const n = Number(raw);
161
+ if (n > 0)
162
+ return n;
163
+ }
164
+ return DEFAULT_MAX_DIR_WATCHES;
165
+ }
166
+ /**
167
+ * Test seam (see {@link __emitWatchEventForTests}). Maps a watcher's project
168
+ * root to its live instance so tests can synthesize a change event
169
+ * deterministically — real fs.watch delivery latency races under parallel
170
+ * vitest (the reason the previous chokidar mock existed). Only populated under
171
+ * a test runner, so production carries no bookkeeping or retained references.
172
+ */
173
+ const liveWatchersForTests = new Map();
174
+ const IS_TEST_RUNTIME = !!(process.env.VITEST || process.env.NODE_ENV === 'test');
175
+ /**
176
+ * Thrown by a `syncFn` to signal that the underlying sync couldn't acquire
177
+ * the cross-process write lock (#449). The watcher treats this as "no
178
+ * progress" — preserves `pendingFiles`, skips `onSyncComplete`, and the
179
+ * `finally` block reschedules. Quiet (debug-only) because a long-running
180
+ * external indexer can hit this every debounce cycle.
181
+ */
182
+ class LockUnavailableError extends Error {
183
+ constructor(message = 'BHGraph file lock unavailable; another process is writing') {
184
+ super(message);
185
+ this.name = 'LockUnavailableError';
186
+ }
187
+ }
188
+ exports.LockUnavailableError = LockUnavailableError;
189
+ /**
190
+ * FileWatcher monitors a project directory for changes and triggers
191
+ * debounced sync operations via a provided callback.
192
+ *
193
+ * Design goals:
194
+ * - Bounded resource usage: O(1) descriptors on macOS/Windows (one recursive
195
+ * watch), O(directories) inotify watches on Linux — never O(files), which
196
+ * was the system-crashing fd leak on macOS (#644/#496/#555/#628).
197
+ * - Debounced to avoid thrashing on rapid saves
198
+ * - Filters to supported source files by extension
199
+ * - Ignores .bhgraph/ and .git/ regardless of .gitignore
200
+ * - Tracks per-file pending state so MCP tools can flag stale results
201
+ * without blocking on a sync (issue #403)
202
+ */
203
+ class FileWatcher {
204
+ /** macOS/Windows: the single recursive watcher. Null on Linux. */
205
+ recursiveWatcher = null;
206
+ /** Linux: one watcher per watched directory (keyed by absolute path). */
207
+ dirWatchers = new Map();
208
+ /** Set once the per-directory watch cap is hit, so we log only once. */
209
+ dirCapWarned = false;
210
+ /**
211
+ * Set once the Linux inotify watch limit (ENOSPC) is hit. Double duty: we
212
+ * warn only once, AND we stop attempting new directory watches for the rest
213
+ * of the session — once the kernel budget is exhausted every further
214
+ * `inotify_add_watch` fails too, so trying the rest of the tree is pure
215
+ * waste. NON-fatal (does not degrade): installed watches keep working.
216
+ */
217
+ inotifyLimitWarned = false;
218
+ /**
219
+ * One-way latch: the reason live watching was permanently disabled at runtime
220
+ * (watch-resource exhaustion, lock contention past the retry budget, or a
221
+ * persistent generic sync failure past the retry budget), or null while
222
+ * healthy. Set by {@link degrade}; cleared only by a fresh start().
223
+ */
224
+ degradedReason = null;
225
+ /** Consecutive lock-contention retries for watcher-triggered syncs. */
226
+ lockRetryCount = 0;
227
+ /** Consecutive generic (non-lock) sync failures; reset only by a clean sync. */
228
+ syncFailureRetryCount = 0;
229
+ /** Test-only inert mode: started, but with no OS watcher installed. */
230
+ inert = false;
231
+ debounceTimer = null;
232
+ /**
233
+ * Files seen by the watcher since the last successful sync — populated on
234
+ * every change event, cleared at the start of a sync, and re-populated by
235
+ * events that arrive mid-sync (or restored on sync failure). Keyed by the
236
+ * same project-relative POSIX path the rest of the codebase uses, so a
237
+ * caller can intersect tool-response file paths against this map cheaply.
238
+ */
239
+ pendingFiles = new Map();
240
+ /**
241
+ * Wall-clock ms at which the in-flight sync began. Combined with
242
+ * {@link pendingFiles}'s `lastSeenMs`, this distinguishes "still in the
243
+ * debounce window" (lastSeen > syncStarted, sync hasn't started yet for
244
+ * this edit) from "currently being indexed" (lastSeen <= syncStarted).
245
+ */
246
+ syncStartedMs = 0;
247
+ syncing = false;
248
+ stopped = false;
249
+ /**
250
+ * True once the initial watch set is established. Unlike the previous
251
+ * chokidar implementation there is no asynchronous initial "crawl" emitting
252
+ * an `add` per existing file — `fs.watch` only reports changes from the
253
+ * moment it's installed — so this flips to true synchronously at the end of
254
+ * `start()`. The startup reconcile against on-disk state is handled
255
+ * separately by the engine's catch-up sync, not by the watcher.
256
+ */
257
+ ready = false;
258
+ /**
259
+ * Callbacks that resolve when the watch set is established. Used by tests
260
+ * (and any production caller that cares about a clean baseline) to
261
+ * deterministically gate on watcher readiness.
262
+ */
263
+ readyWaiters = [];
264
+ // The shared scope matcher (built-in defaults + project .gitignore, with
265
+ // embedded child repos matched by their OWN rules — #514), built once at
266
+ // start(). Same source of truth the indexer uses, so watcher scope can
267
+ // never diverge from index scope. An embedded repo created after start()
268
+ // joins the scope on the next watcher restart / re-index.
269
+ ignoreMatcher = null;
270
+ projectRoot;
271
+ debounceMs;
272
+ syncFn;
273
+ onSyncComplete;
274
+ onSyncError;
275
+ onDegraded;
276
+ inertForTests;
277
+ constructor(projectRoot, syncFn, options = {}) {
278
+ this.projectRoot = projectRoot;
279
+ this.syncFn = syncFn;
280
+ this.debounceMs = options.debounceMs ?? 2000;
281
+ this.onSyncComplete = options.onSyncComplete;
282
+ this.onSyncError = options.onSyncError;
283
+ this.onDegraded = options.onDegraded;
284
+ this.inertForTests = options.inertForTests ?? false;
285
+ }
286
+ /**
287
+ * Start watching for file changes.
288
+ * Returns true if watching started successfully, false otherwise.
289
+ */
290
+ start() {
291
+ if (this.recursiveWatcher || this.dirWatchers.size > 0 || this.inert)
292
+ return true; // Already watching
293
+ this.stopped = false;
294
+ this.degradedReason = null;
295
+ this.lockRetryCount = 0;
296
+ this.syncFailureRetryCount = 0;
297
+ // Some environments make filesystem watching unusable — most notably
298
+ // WSL2 /mnt/ drives, where the underlying fs.watch calls block long
299
+ // enough to break MCP startup handshakes (issue #199). Skip watching
300
+ // there; callers fall back to manual `bhgraph sync` or git sync hooks.
301
+ const disabledReason = (0, watch_policy_1.watchDisabledReason)(this.projectRoot);
302
+ if (disabledReason) {
303
+ (0, errors_1.logDebug)('File watcher disabled', { reason: disabledReason, projectRoot: this.projectRoot });
304
+ return false;
305
+ }
306
+ // Reuse the indexer's ignore set so the watcher and indexer agree on scope.
307
+ this.ignoreMatcher = (0, extraction_1.buildScopeIgnore)(this.projectRoot);
308
+ try {
309
+ if (this.inertForTests) {
310
+ // Test-only: install no OS watcher; the seam drives events instead.
311
+ this.inert = true;
312
+ }
313
+ else if (supportsRecursiveWatch()) {
314
+ this.startRecursive();
315
+ }
316
+ else {
317
+ this.startPerDirectory();
318
+ }
319
+ // The per-directory (Linux) path catches watch-resource exhaustion inside
320
+ // watchTree and degrades synchronously rather than throwing, so it never
321
+ // reaches the catch below. Surface that as a failed start here so both
322
+ // strategies report exhaustion identically (start() === false).
323
+ if (this.degradedReason)
324
+ return false;
325
+ // No async crawl to wait on: as soon as the watch set is installed we
326
+ // have a clean baseline (pendingFiles is only populated by post-start
327
+ // events). Clear defensively and flip ready.
328
+ this.pendingFiles.clear();
329
+ this.ready = true;
330
+ for (const cb of this.readyWaiters)
331
+ cb();
332
+ this.readyWaiters.length = 0;
333
+ if (IS_TEST_RUNTIME)
334
+ liveWatchersForTests.set(this.projectRoot, this);
335
+ (0, errors_1.logDebug)('File watcher started', {
336
+ projectRoot: this.projectRoot,
337
+ debounceMs: this.debounceMs,
338
+ mode: this.inertForTests ? 'inert' : supportsRecursiveWatch() ? 'recursive' : 'per-directory',
339
+ watchedDirs: this.dirWatchers.size || undefined,
340
+ });
341
+ return true;
342
+ }
343
+ catch (err) {
344
+ // Watcher setup failed. Watch-resource exhaustion (EMFILE/ENFILE on the
345
+ // recursive path) is terminal — degrade cleanly with one actionable
346
+ // warning instead of leaving a half-broken watcher. Everything else
347
+ // (permission denied, missing directory) keeps the prior quiet-stop.
348
+ if (isWatchResourceExhaustion(err)) {
349
+ this.degrade(EXHAUSTION_REASON, { error: String(err) });
350
+ }
351
+ else {
352
+ (0, errors_1.logWarn)('Could not start file watcher', { error: String(err) });
353
+ this.stop();
354
+ }
355
+ return false;
356
+ }
357
+ }
358
+ /**
359
+ * macOS/Windows: one recursive watcher for the whole tree. O(1) descriptors.
360
+ * `filename` arrives relative to the project root (with subdirectories), so
361
+ * it maps straight to a project-relative path.
362
+ */
363
+ startRecursive() {
364
+ this.recursiveWatcher = watchImpl(this.projectRoot, { recursive: true, persistent: true }, (_event, filename) => {
365
+ if (this.stopped || filename == null)
366
+ return;
367
+ this.handleChange((0, utils_1.normalizePath)(String(filename)));
368
+ });
369
+ this.recursiveWatcher.on('error', (err) => {
370
+ if (isWatchResourceExhaustion(err)) {
371
+ this.degrade(EXHAUSTION_REASON, { error: String(err) });
372
+ return;
373
+ }
374
+ (0, errors_1.logWarn)('File watcher error', { error: String(err) });
375
+ });
376
+ }
377
+ /**
378
+ * Linux: walk the (non-ignored) tree and watch each directory. One inotify
379
+ * watch per directory reports create/modify/delete for that directory's
380
+ * direct children, so we never watch individual files.
381
+ */
382
+ startPerDirectory() {
383
+ this.watchTree(this.projectRoot, /* markExisting */ false);
384
+ }
385
+ /**
386
+ * Add an inotify watch for `dir` and recurse into its non-ignored
387
+ * subdirectories. When `markExisting` is true (a directory that appeared
388
+ * AFTER startup), the source files already inside it are recorded as pending
389
+ * — this closes the `mkdir + write` race where files created before the new
390
+ * directory's watch is installed would otherwise be missed until the next
391
+ * full sync. The initial startup walk passes false (the engine's catch-up
392
+ * sync owns the baseline).
393
+ */
394
+ watchTree(dir, markExisting) {
395
+ // A degrade() mid-walk (exhaustion on an earlier directory) calls stop(),
396
+ // which sets `stopped`; bail so the recursion unwinds without adding more
397
+ // watches to a watcher that is shutting down. `inotifyLimitWarned` does the
398
+ // same after ENOSPC — the kernel budget is gone, so stop trying the rest of
399
+ // the tree (every add would fail) while keeping the watches already set.
400
+ if (this.stopped || this.degradedReason || this.inotifyLimitWarned)
401
+ return;
402
+ if (this.dirWatchers.has(dir))
403
+ return;
404
+ if (this.dirWatchers.size >= maxDirWatches()) {
405
+ if (!this.dirCapWarned) {
406
+ this.dirCapWarned = true;
407
+ (0, errors_1.logWarn)('File watcher hit directory-watch cap; remaining subtrees rely on manual/periodic sync', {
408
+ cap: maxDirWatches(),
409
+ });
410
+ }
411
+ return;
412
+ }
413
+ let w;
414
+ try {
415
+ w = watchImpl(dir, { persistent: true }, (_event, filename) => this.handleDirEvent(dir, filename));
416
+ }
417
+ catch (err) {
418
+ // EMFILE/ENFILE means the PROCESS is out of descriptors — every further
419
+ // directory would fail too, so degrade the whole watcher rather than
420
+ // limping along with a partial watch set.
421
+ if (isWatchResourceExhaustion(err)) {
422
+ this.degrade(EXHAUSTION_REASON, { error: String(err), dir });
423
+ }
424
+ else if (isInotifyWatchExhaustion(err)) {
425
+ // ENOSPC = inotify watch budget exhausted. NON-fatal: keep the watches
426
+ // we have and tell the user the knob to raise (warn once).
427
+ this.warnInotifyLimit({ error: String(err), dir });
428
+ }
429
+ // ENOENT / EACCES on a single directory stays non-fatal: skip it quietly.
430
+ return;
431
+ }
432
+ w.on('error', (err) => {
433
+ if (isWatchResourceExhaustion(err)) {
434
+ this.degrade(EXHAUSTION_REASON, { error: String(err), dir });
435
+ return;
436
+ }
437
+ if (isInotifyWatchExhaustion(err)) {
438
+ this.warnInotifyLimit({ error: String(err), dir });
439
+ }
440
+ this.unwatchDir(dir);
441
+ });
442
+ this.dirWatchers.set(dir, w);
443
+ let entries;
444
+ try {
445
+ entries = fs.readdirSync(dir, { withFileTypes: true });
446
+ }
447
+ catch {
448
+ return;
449
+ }
450
+ for (const entry of entries) {
451
+ const child = path.join(dir, entry.name);
452
+ if (entry.isDirectory()) {
453
+ if (this.shouldIgnoreDir(child))
454
+ continue;
455
+ this.watchTree(child, markExisting);
456
+ }
457
+ else if (markExisting && entry.isFile()) {
458
+ this.handleChange((0, utils_1.normalizePath)(path.relative(this.projectRoot, child)));
459
+ }
460
+ }
461
+ }
462
+ /**
463
+ * Linux per-directory event handler. `filename` is relative to `dir`. A new
464
+ * sub-directory is picked up by extending the watch tree; everything else is
465
+ * routed through the shared change handler.
466
+ */
467
+ handleDirEvent(dir, filename) {
468
+ if (this.stopped || filename == null)
469
+ return;
470
+ const full = path.join(dir, String(filename));
471
+ // A newly-created directory needs its own watch (recursive isn't available
472
+ // on Linux). statSync is cheap and these events are rare relative to file
473
+ // edits. If the path vanished (rapid create/delete) the stat throws and we
474
+ // fall through to the change handler, which no-ops on a non-source path.
475
+ try {
476
+ if (fs.statSync(full).isDirectory()) {
477
+ if (!this.shouldIgnoreDir(full))
478
+ this.watchTree(full, /* markExisting */ true);
479
+ return;
480
+ }
481
+ }
482
+ catch {
483
+ // deleted/inaccessible — treat as a normal change below
484
+ }
485
+ this.handleChange((0, utils_1.normalizePath)(path.relative(this.projectRoot, full)));
486
+ }
487
+ /**
488
+ * Shared change handler for both watch strategies. `rel` is a
489
+ * project-relative POSIX path. Applies the ignore + source-file filters and,
490
+ * for a real source change, records it as pending (#403) and schedules a
491
+ * debounced sync.
492
+ *
493
+ * The recursive (macOS/Windows) watcher reports events for ignored trees too
494
+ * (one stream covers the whole repo), so the ignore check here is load-bearing
495
+ * — it drops node_modules/dist/.git churn before any sync is scheduled.
496
+ */
497
+ handleChange(rel) {
498
+ if (!rel || rel === '.' || rel.startsWith('..'))
499
+ return;
500
+ if (this.isAlwaysIgnored(rel))
501
+ return;
502
+ if (this.ignoreMatcher && this.ignoreMatcher.ignores(rel))
503
+ return;
504
+ if (!(0, extraction_1.isSourceFile)(rel, (0, project_config_1.loadExtensionOverrides)(this.projectRoot)))
505
+ return;
506
+ (0, errors_1.logDebug)('File change detected', { file: rel });
507
+ if (this.ready) {
508
+ const now = Date.now();
509
+ const existing = this.pendingFiles.get(rel);
510
+ this.pendingFiles.set(rel, {
511
+ firstSeenMs: existing?.firstSeenMs ?? now,
512
+ lastSeenMs: now,
513
+ });
514
+ }
515
+ this.scheduleSync();
516
+ }
517
+ /** Close and forget the watch for a directory that errored/was removed. */
518
+ unwatchDir(dir) {
519
+ const w = this.dirWatchers.get(dir);
520
+ if (w) {
521
+ try {
522
+ w.close();
523
+ }
524
+ catch {
525
+ /* already closed */
526
+ }
527
+ this.dirWatchers.delete(dir);
528
+ }
529
+ }
530
+ /** Our own dirs are always ignored, regardless of .gitignore. */
531
+ isAlwaysIgnored(rel) {
532
+ // First path segment. Ignore any BHGraph data dir — the active one AND a
533
+ // sibling like `.bhgraph-win` a second environment (Windows/WSL) created
534
+ // in the same tree, so neither side watches the other's index (#636).
535
+ const top = rel.split('/')[0] ?? rel;
536
+ return ((0, directory_1.isBHGraphDataDir)(top) ||
537
+ rel === '.git' || rel.startsWith('.git/'));
538
+ }
539
+ /**
540
+ * True for any directory that should NOT be watched (used while building the
541
+ * Linux per-directory watch tree). Tests the directory form of the path so a
542
+ * dir-only ignore rule like `build/` matches.
543
+ */
544
+ shouldIgnoreDir(dirPath) {
545
+ const rel = (0, utils_1.normalizePath)(path.relative(this.projectRoot, dirPath));
546
+ if (!rel || rel === '.' || rel.startsWith('..'))
547
+ return false; // root / outside
548
+ if (this.isAlwaysIgnored(rel))
549
+ return true;
550
+ if (!this.ignoreMatcher)
551
+ return false;
552
+ return this.ignoreMatcher.ignores(rel + '/');
553
+ }
554
+ /**
555
+ * Permanently disable live watching after a terminal runtime failure
556
+ * (watch-resource exhaustion, lock contention past the retry budget, or a
557
+ * persistent generic sync failure past the retry budget).
558
+ * Idempotent: logs one actionable warning, fires {@link WatchOptions.onDegraded}
559
+ * once, and stops the watcher. A subsequent start() clears the latch.
560
+ */
561
+ degrade(reason, context = {}) {
562
+ if (this.degradedReason)
563
+ return;
564
+ this.degradedReason = reason;
565
+ (0, errors_1.logWarn)('File watcher disabled', { projectRoot: this.projectRoot, reason, ...context });
566
+ this.onDegraded?.(reason);
567
+ this.stop();
568
+ }
569
+ /**
570
+ * Warn ONCE that the Linux inotify watch budget is exhausted (ENOSPC), and
571
+ * stop adding new watches for the rest of this session — every further
572
+ * `inotify_add_watch` would fail too, so walking the rest of the tree is
573
+ * waste. Unlike {@link degrade} this is NON-fatal: the watches already
574
+ * installed keep firing, and `bhgraph sync` covers the unwatched remainder.
575
+ * The message names the kernel knob to raise (`fs.inotify.max_user_watches`).
576
+ */
577
+ warnInotifyLimit(context = {}) {
578
+ if (this.inotifyLimitWarned)
579
+ return;
580
+ this.inotifyLimitWarned = true;
581
+ (0, errors_1.logWarn)(INOTIFY_LIMIT_REASON, { watchedDirs: this.dirWatchers.size, ...context });
582
+ }
583
+ /**
584
+ * Whether live watching has degraded permanently (until the next start()).
585
+ * Distinct from {@link isActive}: a degraded watcher is inactive, but an
586
+ * inactive watcher is not necessarily degraded (it may simply be stopped or
587
+ * never started). Hosts use this to tell the user auto-sync is off.
588
+ */
589
+ isDegraded() {
590
+ return this.degradedReason !== null;
591
+ }
592
+ /** The reason live watching degraded, or null if it is healthy. */
593
+ getDegradedReason() {
594
+ return this.degradedReason;
595
+ }
596
+ /**
597
+ * Stop watching for file changes.
598
+ */
599
+ stop() {
600
+ this.stopped = true;
601
+ if (this.debounceTimer) {
602
+ clearTimeout(this.debounceTimer);
603
+ this.debounceTimer = null;
604
+ }
605
+ if (this.recursiveWatcher) {
606
+ try {
607
+ this.recursiveWatcher.close();
608
+ }
609
+ catch {
610
+ /* already closed */
611
+ }
612
+ this.recursiveWatcher = null;
613
+ }
614
+ for (const w of this.dirWatchers.values()) {
615
+ try {
616
+ w.close();
617
+ }
618
+ catch {
619
+ /* already closed */
620
+ }
621
+ }
622
+ this.dirWatchers.clear();
623
+ this.dirCapWarned = false;
624
+ this.inotifyLimitWarned = false;
625
+ this.lockRetryCount = 0;
626
+ this.syncFailureRetryCount = 0;
627
+ // NB: degradedReason is intentionally NOT reset here — it must survive the
628
+ // stop() that degrade() triggers so isDegraded() stays true. start() clears it.
629
+ this.inert = false;
630
+ this.pendingFiles.clear();
631
+ this.ready = false;
632
+ this.ignoreMatcher = null;
633
+ if (IS_TEST_RUNTIME)
634
+ liveWatchersForTests.delete(this.projectRoot);
635
+ (0, errors_1.logDebug)('File watcher stopped');
636
+ }
637
+ /**
638
+ * @internal Test-only: feed a synthetic project-relative change through the
639
+ * same filter → pendingFiles → debounced-sync path a real fs.watch event
640
+ * takes. Lets the watcher / staleness-banner suites stay deterministic
641
+ * instead of racing on OS watch-delivery latency. See
642
+ * {@link __emitWatchEventForTests}.
643
+ */
644
+ ingestEventForTests(relPath) {
645
+ this.handleChange((0, utils_1.normalizePath)(relPath));
646
+ }
647
+ /**
648
+ * Whether the watcher is currently active.
649
+ */
650
+ isActive() {
651
+ return (this.recursiveWatcher !== null || this.dirWatchers.size > 0 || this.inert) && !this.stopped;
652
+ }
653
+ /**
654
+ * Resolves once the watch set has been installed (or immediately if it
655
+ * already has). Useful for tests that need a deterministic boundary before
656
+ * asserting on `pendingFiles`.
657
+ *
658
+ * Production callers don't need this: `pendingFiles` is read continuously,
659
+ * the staleness banner is always correct (empty or populated), and there is
660
+ * no asynchronous initial-scan window with `fs.watch`.
661
+ */
662
+ waitUntilReady(timeoutMs = 10000) {
663
+ if (this.ready)
664
+ return Promise.resolve();
665
+ return new Promise((resolve, reject) => {
666
+ const t = setTimeout(() => {
667
+ const idx = this.readyWaiters.indexOf(handler);
668
+ if (idx >= 0)
669
+ this.readyWaiters.splice(idx, 1);
670
+ reject(new Error(`FileWatcher.waitUntilReady timed out after ${timeoutMs}ms`));
671
+ }, timeoutMs);
672
+ const handler = () => { clearTimeout(t); resolve(); };
673
+ this.readyWaiters.push(handler);
674
+ });
675
+ }
676
+ /**
677
+ * Schedule a normal debounced sync after a source edit.
678
+ */
679
+ scheduleSync() {
680
+ if (this.debounceTimer) {
681
+ clearTimeout(this.debounceTimer);
682
+ }
683
+ this.debounceTimer = setTimeout(() => {
684
+ this.debounceTimer = null;
685
+ this.flush();
686
+ }, this.debounceMs);
687
+ }
688
+ /**
689
+ * Schedule a retry after a recoverable sync failure (lock contention). Kept
690
+ * separate from {@link scheduleSync} so prolonged contention backs off
691
+ * exponentially instead of hammering the lock every debounce cycle.
692
+ */
693
+ scheduleRetrySync(delayMs) {
694
+ if (this.debounceTimer) {
695
+ clearTimeout(this.debounceTimer);
696
+ }
697
+ this.debounceTimer = setTimeout(() => {
698
+ this.debounceTimer = null;
699
+ this.flush();
700
+ }, delayMs);
701
+ }
702
+ /**
703
+ * Flush pending changes by running sync.
704
+ *
705
+ * pendingFiles is NOT cleared at the start of sync — entries are removed
706
+ * only after sync commits successfully, and only for entries whose
707
+ * lastSeenMs <= syncStartedMs. That way, a query that arrives mid-sync
708
+ * still sees the affected files marked stale (the DB hasn't been updated
709
+ * yet), and an event that lands mid-sync persists into the follow-up.
710
+ *
711
+ * On sync failure pendingFiles is left untouched — every edit is still
712
+ * unindexed, and the rescheduled sync will absorb the same set next time.
713
+ */
714
+ async flush() {
715
+ // If already syncing, the post-sync check will re-trigger
716
+ if (this.syncing || this.stopped)
717
+ return;
718
+ this.syncStartedMs = Date.now();
719
+ this.syncing = true;
720
+ try {
721
+ const result = await this.syncFn();
722
+ this.lockRetryCount = 0; // a clean sync clears any contention backoff
723
+ this.syncFailureRetryCount = 0; // ...and any generic-failure backoff
724
+ // Remove entries whose most recent event predates this sync — those
725
+ // edits are now in the DB. Entries with lastSeenMs > syncStartedMs
726
+ // arrived mid-sync; whether the in-flight sync captured them depends
727
+ // on when sync read that file, so we keep them as pending and let
728
+ // the follow-up sync handle them. We prefer false positives ("shown
729
+ // stale, actually fresh" → at worst one extra Read) over false
730
+ // negatives ("shown fresh, actually stale" → misleads the agent).
731
+ for (const [filePath, info] of this.pendingFiles) {
732
+ if (info.lastSeenMs <= this.syncStartedMs) {
733
+ this.pendingFiles.delete(filePath);
734
+ }
735
+ }
736
+ this.onSyncComplete?.(result);
737
+ }
738
+ catch (err) {
739
+ if (err instanceof LockUnavailableError) {
740
+ this.lockRetryCount += 1;
741
+ // Lock-failure no-op (another writer holds the lock). pendingFiles
742
+ // stays intact and the `finally` block reschedules with backoff. Keep
743
+ // brief contention quiet (debug-only — a long external index would
744
+ // otherwise spam stderr every cycle), but stop retrying forever: once a
745
+ // writer holds the lock past the budget, degrade auto-sync explicitly.
746
+ (0, errors_1.logDebug)('Watch sync skipped: file lock unavailable', {
747
+ pendingFiles: this.pendingFiles.size,
748
+ retryCount: this.lockRetryCount,
749
+ });
750
+ if (this.lockRetryCount > MAX_LOCK_RETRIES) {
751
+ this.degrade('BHGraph file lock held by another process past the retry budget; ' +
752
+ 'auto-sync disabled. Run `bhgraph sync` once the other writer finishes ' +
753
+ '(or install git sync hooks) to refresh the graph.', { pendingFiles: this.pendingFiles.size, retryCount: this.lockRetryCount });
754
+ }
755
+ }
756
+ else {
757
+ this.lockRetryCount = 0; // a non-lock failure isn't contention; reset that streak
758
+ this.syncFailureRetryCount += 1;
759
+ const error = err instanceof Error ? err : new Error(String(err));
760
+ (0, errors_1.logWarn)('Watch sync failed', {
761
+ error: error.message,
762
+ retryCount: this.syncFailureRetryCount,
763
+ });
764
+ this.onSyncError?.(error);
765
+ // A persistent (deterministic) sync failure — a broken extractor on a
766
+ // specific file, DB corruption, SQLITE_FULL, an OOM in resolution —
767
+ // would otherwise retry forever at the debounce cadence, spamming logs
768
+ // and work while the auto-update guarantee is silently dead (#1127).
769
+ // Bound it exactly like lock contention: the `finally` block backs off
770
+ // exponentially, and past the budget we degrade so the dead guarantee
771
+ // is surfaced (onDegraded / isDegraded) instead of hidden. A single
772
+ // clean sync resets the streak, so a transient hiccup never degrades.
773
+ if (this.syncFailureRetryCount > MAX_SYNC_FAILURE_RETRIES) {
774
+ this.degrade(`BHGraph auto-sync failed ${this.syncFailureRetryCount} times in a row; ` +
775
+ 'auto-sync disabled. Run `bhgraph sync` (or install git sync hooks) to ' +
776
+ `refresh the graph after changes. Last error: ${error.message}`, { error: error.message, retryCount: this.syncFailureRetryCount });
777
+ }
778
+ }
779
+ // Failure: leave pendingFiles untouched. Every edit it tracks is
780
+ // still unindexed; the rescheduled sync sees the same set.
781
+ }
782
+ finally {
783
+ this.syncing = false;
784
+ // If pending files remain (mid-sync events, or this sync failed),
785
+ // schedule another pass. After EITHER failure mode — lock contention or a
786
+ // generic sync failure — back off exponentially (debounceMs · 2^(n-1),
787
+ // capped) instead of retrying at the normal debounce cadence; a clean
788
+ // sync resets both counters so normal edits keep the fast debounce. Use
789
+ // the larger streak so interleaved failures still back off. A degrade()
790
+ // above already set `stopped`, so this won't reschedule a watcher that
791
+ // has given up.
792
+ if (this.pendingFiles.size > 0 && !this.stopped) {
793
+ const retryCount = Math.max(this.lockRetryCount, this.syncFailureRetryCount);
794
+ if (retryCount > 0) {
795
+ const retryDelayMs = Math.min(this.debounceMs * 2 ** Math.max(0, retryCount - 1), MAX_RETRY_BACKOFF_MS);
796
+ this.scheduleRetrySync(retryDelayMs);
797
+ }
798
+ else {
799
+ this.scheduleSync();
800
+ }
801
+ }
802
+ }
803
+ }
804
+ /**
805
+ * Snapshot of files seen by the watcher since the last successful sync.
806
+ *
807
+ * Used by MCP tool responses to mark stale results without blocking on a
808
+ * sync: a tool that returns a hit in `src/foo.ts` while `src/foo.ts` is in
809
+ * this list tells the agent "Read this file directly, the index lags."
810
+ *
811
+ * `indexing` is true when a sync is currently in flight whose start time is
812
+ * AFTER this file's most recent event — i.e. that sync will absorb the
813
+ * edit. False means the file is still inside the debounce window and no
814
+ * sync has started yet (a follow-up call a few hundred ms later may show
815
+ * `indexing: true` or the file may have left the list entirely).
816
+ *
817
+ * Cheap: O(pendingFiles.size), no I/O, no locks.
818
+ */
819
+ getPendingFiles() {
820
+ const result = [];
821
+ for (const [filePath, info] of this.pendingFiles) {
822
+ result.push({
823
+ path: filePath,
824
+ firstSeenMs: info.firstSeenMs,
825
+ lastSeenMs: info.lastSeenMs,
826
+ indexing: this.syncing && this.syncStartedMs >= info.lastSeenMs,
827
+ });
828
+ }
829
+ return result;
830
+ }
831
+ }
832
+ exports.FileWatcher = FileWatcher;
833
+ /**
834
+ * Test-only: synthesize a source-file change for the live watcher running at
835
+ * `projectRoot`, exercising the real filter → pendingFiles → debounced-sync
836
+ * logic without depending on fs.watch delivery timing (which races under
837
+ * parallel vitest). `relPath` is project-relative POSIX (e.g. "src/foo.ts").
838
+ * Returns false if no live watcher is registered for that root (e.g. outside a
839
+ * test runtime, where the registry is intentionally not populated).
840
+ */
841
+ function __emitWatchEventForTests(projectRoot, relPath) {
842
+ const w = liveWatchersForTests.get(projectRoot);
843
+ if (!w)
844
+ return false;
845
+ w.ingestEventForTests(relPath);
846
+ return true;
847
+ }
848
+ //# sourceMappingURL=watcher.js.map