@vizalice/codegraph 1.5.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 (821) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +872 -0
  3. package/dist/bin/codegraph.d.ts +26 -0
  4. package/dist/bin/codegraph.d.ts.map +1 -0
  5. package/dist/bin/codegraph.js +2324 -0
  6. package/dist/bin/codegraph.js.map +1 -0
  7. package/dist/bin/command-supervision.d.ts +49 -0
  8. package/dist/bin/command-supervision.d.ts.map +1 -0
  9. package/dist/bin/command-supervision.js +95 -0
  10. package/dist/bin/command-supervision.js.map +1 -0
  11. package/dist/bin/fatal-handler.d.ts +20 -0
  12. package/dist/bin/fatal-handler.d.ts.map +1 -0
  13. package/dist/bin/fatal-handler.js +118 -0
  14. package/dist/bin/fatal-handler.js.map +1 -0
  15. package/dist/bin/node-version-check.d.ts +37 -0
  16. package/dist/bin/node-version-check.d.ts.map +1 -0
  17. package/dist/bin/node-version-check.js +79 -0
  18. package/dist/bin/node-version-check.js.map +1 -0
  19. package/dist/bin/uninstall.d.ts +14 -0
  20. package/dist/bin/uninstall.d.ts.map +1 -0
  21. package/dist/bin/uninstall.js +36 -0
  22. package/dist/bin/uninstall.js.map +1 -0
  23. package/dist/context/formatter.d.ts +36 -0
  24. package/dist/context/formatter.d.ts.map +1 -0
  25. package/dist/context/formatter.js +269 -0
  26. package/dist/context/formatter.js.map +1 -0
  27. package/dist/context/index.d.ts +119 -0
  28. package/dist/context/index.d.ts.map +1 -0
  29. package/dist/context/index.js +1333 -0
  30. package/dist/context/index.js.map +1 -0
  31. package/dist/context/markers.d.ts +19 -0
  32. package/dist/context/markers.d.ts.map +1 -0
  33. package/dist/context/markers.js +22 -0
  34. package/dist/context/markers.js.map +1 -0
  35. package/dist/db/index.d.ts +378 -0
  36. package/dist/db/index.d.ts.map +1 -0
  37. package/dist/db/index.js +831 -0
  38. package/dist/db/index.js.map +1 -0
  39. package/dist/db/migrations.d.ts +44 -0
  40. package/dist/db/migrations.d.ts.map +1 -0
  41. package/dist/db/migrations.js +236 -0
  42. package/dist/db/migrations.js.map +1 -0
  43. package/dist/db/queries.d.ts +705 -0
  44. package/dist/db/queries.d.ts.map +1 -0
  45. package/dist/db/queries.js +2435 -0
  46. package/dist/db/queries.js.map +1 -0
  47. package/dist/db/schema.sql +207 -0
  48. package/dist/db/sqlite-adapter.d.ts +55 -0
  49. package/dist/db/sqlite-adapter.d.ts.map +1 -0
  50. package/dist/db/sqlite-adapter.js +135 -0
  51. package/dist/db/sqlite-adapter.js.map +1 -0
  52. package/dist/db/wal-valve.d.ts +119 -0
  53. package/dist/db/wal-valve.d.ts.map +1 -0
  54. package/dist/db/wal-valve.js +290 -0
  55. package/dist/db/wal-valve.js.map +1 -0
  56. package/dist/directory.d.ts +183 -0
  57. package/dist/directory.d.ts.map +1 -0
  58. package/dist/directory.js +797 -0
  59. package/dist/directory.js.map +1 -0
  60. package/dist/errors.d.ts +136 -0
  61. package/dist/errors.d.ts.map +1 -0
  62. package/dist/errors.js +219 -0
  63. package/dist/errors.js.map +1 -0
  64. package/dist/extraction/astro-extractor.d.ts +79 -0
  65. package/dist/extraction/astro-extractor.d.ts.map +1 -0
  66. package/dist/extraction/astro-extractor.js +320 -0
  67. package/dist/extraction/astro-extractor.js.map +1 -0
  68. package/dist/extraction/cfml-extractor.d.ts +107 -0
  69. package/dist/extraction/cfml-extractor.d.ts.map +1 -0
  70. package/dist/extraction/cfml-extractor.js +494 -0
  71. package/dist/extraction/cfml-extractor.js.map +1 -0
  72. package/dist/extraction/dfm-extractor.d.ts +31 -0
  73. package/dist/extraction/dfm-extractor.d.ts.map +1 -0
  74. package/dist/extraction/dfm-extractor.js +151 -0
  75. package/dist/extraction/dfm-extractor.js.map +1 -0
  76. package/dist/extraction/extraction-version.d.ts +25 -0
  77. package/dist/extraction/extraction-version.d.ts.map +1 -0
  78. package/dist/extraction/extraction-version.js +28 -0
  79. package/dist/extraction/extraction-version.js.map +1 -0
  80. package/dist/extraction/function-ref.d.ts +118 -0
  81. package/dist/extraction/function-ref.d.ts.map +1 -0
  82. package/dist/extraction/function-ref.js +733 -0
  83. package/dist/extraction/function-ref.js.map +1 -0
  84. package/dist/extraction/generated-detection.d.ts +66 -0
  85. package/dist/extraction/generated-detection.d.ts.map +1 -0
  86. package/dist/extraction/generated-detection.js +248 -0
  87. package/dist/extraction/generated-detection.js.map +1 -0
  88. package/dist/extraction/grammars.d.ts +138 -0
  89. package/dist/extraction/grammars.d.ts.map +1 -0
  90. package/dist/extraction/grammars.js +694 -0
  91. package/dist/extraction/grammars.js.map +1 -0
  92. package/dist/extraction/index.d.ts +308 -0
  93. package/dist/extraction/index.d.ts.map +1 -0
  94. package/dist/extraction/index.js +2711 -0
  95. package/dist/extraction/index.js.map +1 -0
  96. package/dist/extraction/kernel/decode.d.ts +9 -0
  97. package/dist/extraction/kernel/decode.d.ts.map +1 -0
  98. package/dist/extraction/kernel/decode.js +162 -0
  99. package/dist/extraction/kernel/decode.js.map +1 -0
  100. package/dist/extraction/kernel/index.d.ts +64 -0
  101. package/dist/extraction/kernel/index.d.ts.map +1 -0
  102. package/dist/extraction/kernel/index.js +279 -0
  103. package/dist/extraction/kernel/index.js.map +1 -0
  104. package/dist/extraction/kernel/layout.d.ts +101 -0
  105. package/dist/extraction/kernel/layout.d.ts.map +1 -0
  106. package/dist/extraction/kernel/layout.js +104 -0
  107. package/dist/extraction/kernel/layout.js.map +1 -0
  108. package/dist/extraction/kernel/loader.d.ts +103 -0
  109. package/dist/extraction/kernel/loader.d.ts.map +1 -0
  110. package/dist/extraction/kernel/loader.js +146 -0
  111. package/dist/extraction/kernel/loader.js.map +1 -0
  112. package/dist/extraction/languages/arkts.d.ts +3 -0
  113. package/dist/extraction/languages/arkts.d.ts.map +1 -0
  114. package/dist/extraction/languages/arkts.js +127 -0
  115. package/dist/extraction/languages/arkts.js.map +1 -0
  116. package/dist/extraction/languages/c-cpp.d.ts +124 -0
  117. package/dist/extraction/languages/c-cpp.d.ts.map +1 -0
  118. package/dist/extraction/languages/c-cpp.js +1689 -0
  119. package/dist/extraction/languages/c-cpp.js.map +1 -0
  120. package/dist/extraction/languages/cfquery.d.ts +12 -0
  121. package/dist/extraction/languages/cfquery.d.ts.map +1 -0
  122. package/dist/extraction/languages/cfquery.js +28 -0
  123. package/dist/extraction/languages/cfquery.js.map +1 -0
  124. package/dist/extraction/languages/cfscript.d.ts +3 -0
  125. package/dist/extraction/languages/cfscript.d.ts.map +1 -0
  126. package/dist/extraction/languages/cfscript.js +73 -0
  127. package/dist/extraction/languages/cfscript.js.map +1 -0
  128. package/dist/extraction/languages/cobol.d.ts +33 -0
  129. package/dist/extraction/languages/cobol.d.ts.map +1 -0
  130. package/dist/extraction/languages/cobol.js +499 -0
  131. package/dist/extraction/languages/cobol.js.map +1 -0
  132. package/dist/extraction/languages/csharp.d.ts +25 -0
  133. package/dist/extraction/languages/csharp.d.ts.map +1 -0
  134. package/dist/extraction/languages/csharp.js +175 -0
  135. package/dist/extraction/languages/csharp.js.map +1 -0
  136. package/dist/extraction/languages/dart.d.ts +3 -0
  137. package/dist/extraction/languages/dart.d.ts.map +1 -0
  138. package/dist/extraction/languages/dart.js +374 -0
  139. package/dist/extraction/languages/dart.js.map +1 -0
  140. package/dist/extraction/languages/erlang.d.ts +3 -0
  141. package/dist/extraction/languages/erlang.d.ts.map +1 -0
  142. package/dist/extraction/languages/erlang.js +350 -0
  143. package/dist/extraction/languages/erlang.js.map +1 -0
  144. package/dist/extraction/languages/go.d.ts +3 -0
  145. package/dist/extraction/languages/go.d.ts.map +1 -0
  146. package/dist/extraction/languages/go.js +111 -0
  147. package/dist/extraction/languages/go.js.map +1 -0
  148. package/dist/extraction/languages/index.d.ts +10 -0
  149. package/dist/extraction/languages/index.d.ts.map +1 -0
  150. package/dist/extraction/languages/index.js +71 -0
  151. package/dist/extraction/languages/index.js.map +1 -0
  152. package/dist/extraction/languages/java.d.ts +3 -0
  153. package/dist/extraction/languages/java.d.ts.map +1 -0
  154. package/dist/extraction/languages/java.js +315 -0
  155. package/dist/extraction/languages/java.js.map +1 -0
  156. package/dist/extraction/languages/javascript.d.ts +3 -0
  157. package/dist/extraction/languages/javascript.d.ts.map +1 -0
  158. package/dist/extraction/languages/javascript.js +106 -0
  159. package/dist/extraction/languages/javascript.js.map +1 -0
  160. package/dist/extraction/languages/kotlin.d.ts +3 -0
  161. package/dist/extraction/languages/kotlin.d.ts.map +1 -0
  162. package/dist/extraction/languages/kotlin.js +379 -0
  163. package/dist/extraction/languages/kotlin.js.map +1 -0
  164. package/dist/extraction/languages/lua.d.ts +3 -0
  165. package/dist/extraction/languages/lua.d.ts.map +1 -0
  166. package/dist/extraction/languages/lua.js +150 -0
  167. package/dist/extraction/languages/lua.js.map +1 -0
  168. package/dist/extraction/languages/luau.d.ts +3 -0
  169. package/dist/extraction/languages/luau.d.ts.map +1 -0
  170. package/dist/extraction/languages/luau.js +37 -0
  171. package/dist/extraction/languages/luau.js.map +1 -0
  172. package/dist/extraction/languages/nix.d.ts +3 -0
  173. package/dist/extraction/languages/nix.d.ts.map +1 -0
  174. package/dist/extraction/languages/nix.js +294 -0
  175. package/dist/extraction/languages/nix.js.map +1 -0
  176. package/dist/extraction/languages/objc.d.ts +3 -0
  177. package/dist/extraction/languages/objc.d.ts.map +1 -0
  178. package/dist/extraction/languages/objc.js +179 -0
  179. package/dist/extraction/languages/objc.js.map +1 -0
  180. package/dist/extraction/languages/pascal.d.ts +3 -0
  181. package/dist/extraction/languages/pascal.d.ts.map +1 -0
  182. package/dist/extraction/languages/pascal.js +77 -0
  183. package/dist/extraction/languages/pascal.js.map +1 -0
  184. package/dist/extraction/languages/php.d.ts +3 -0
  185. package/dist/extraction/languages/php.d.ts.map +1 -0
  186. package/dist/extraction/languages/php.js +196 -0
  187. package/dist/extraction/languages/php.js.map +1 -0
  188. package/dist/extraction/languages/python.d.ts +3 -0
  189. package/dist/extraction/languages/python.d.ts.map +1 -0
  190. package/dist/extraction/languages/python.js +56 -0
  191. package/dist/extraction/languages/python.js.map +1 -0
  192. package/dist/extraction/languages/r.d.ts +3 -0
  193. package/dist/extraction/languages/r.d.ts.map +1 -0
  194. package/dist/extraction/languages/r.js +314 -0
  195. package/dist/extraction/languages/r.js.map +1 -0
  196. package/dist/extraction/languages/ruby.d.ts +3 -0
  197. package/dist/extraction/languages/ruby.d.ts.map +1 -0
  198. package/dist/extraction/languages/ruby.js +149 -0
  199. package/dist/extraction/languages/ruby.js.map +1 -0
  200. package/dist/extraction/languages/rust.d.ts +3 -0
  201. package/dist/extraction/languages/rust.d.ts.map +1 -0
  202. package/dist/extraction/languages/rust.js +145 -0
  203. package/dist/extraction/languages/rust.js.map +1 -0
  204. package/dist/extraction/languages/scala.d.ts +3 -0
  205. package/dist/extraction/languages/scala.d.ts.map +1 -0
  206. package/dist/extraction/languages/scala.js +209 -0
  207. package/dist/extraction/languages/scala.js.map +1 -0
  208. package/dist/extraction/languages/solidity.d.ts +3 -0
  209. package/dist/extraction/languages/solidity.d.ts.map +1 -0
  210. package/dist/extraction/languages/solidity.js +293 -0
  211. package/dist/extraction/languages/solidity.js.map +1 -0
  212. package/dist/extraction/languages/swift.d.ts +3 -0
  213. package/dist/extraction/languages/swift.d.ts.map +1 -0
  214. package/dist/extraction/languages/swift.js +152 -0
  215. package/dist/extraction/languages/swift.js.map +1 -0
  216. package/dist/extraction/languages/terraform.d.ts +3 -0
  217. package/dist/extraction/languages/terraform.d.ts.map +1 -0
  218. package/dist/extraction/languages/terraform.js +641 -0
  219. package/dist/extraction/languages/terraform.js.map +1 -0
  220. package/dist/extraction/languages/typescript.d.ts +16 -0
  221. package/dist/extraction/languages/typescript.d.ts.map +1 -0
  222. package/dist/extraction/languages/typescript.js +167 -0
  223. package/dist/extraction/languages/typescript.js.map +1 -0
  224. package/dist/extraction/languages/vbnet.d.ts +11 -0
  225. package/dist/extraction/languages/vbnet.d.ts.map +1 -0
  226. package/dist/extraction/languages/vbnet.js +141 -0
  227. package/dist/extraction/languages/vbnet.js.map +1 -0
  228. package/dist/extraction/liquid-extractor.d.ts +59 -0
  229. package/dist/extraction/liquid-extractor.d.ts.map +1 -0
  230. package/dist/extraction/liquid-extractor.js +357 -0
  231. package/dist/extraction/liquid-extractor.js.map +1 -0
  232. package/dist/extraction/mybatis-extractor.d.ts +68 -0
  233. package/dist/extraction/mybatis-extractor.d.ts.map +1 -0
  234. package/dist/extraction/mybatis-extractor.js +300 -0
  235. package/dist/extraction/mybatis-extractor.js.map +1 -0
  236. package/dist/extraction/parse-pool.d.ts +160 -0
  237. package/dist/extraction/parse-pool.d.ts.map +1 -0
  238. package/dist/extraction/parse-pool.js +402 -0
  239. package/dist/extraction/parse-pool.js.map +1 -0
  240. package/dist/extraction/parse-worker.d.ts +8 -0
  241. package/dist/extraction/parse-worker.d.ts.map +1 -0
  242. package/dist/extraction/parse-worker.js +138 -0
  243. package/dist/extraction/parse-worker.js.map +1 -0
  244. package/dist/extraction/razor-extractor.d.ts +42 -0
  245. package/dist/extraction/razor-extractor.d.ts.map +1 -0
  246. package/dist/extraction/razor-extractor.js +285 -0
  247. package/dist/extraction/razor-extractor.js.map +1 -0
  248. package/dist/extraction/store-worker.d.ts +24 -0
  249. package/dist/extraction/store-worker.d.ts.map +1 -0
  250. package/dist/extraction/store-worker.js +139 -0
  251. package/dist/extraction/store-worker.js.map +1 -0
  252. package/dist/extraction/store-writer.d.ts +63 -0
  253. package/dist/extraction/store-writer.d.ts.map +1 -0
  254. package/dist/extraction/store-writer.js +174 -0
  255. package/dist/extraction/store-writer.js.map +1 -0
  256. package/dist/extraction/svelte-extractor.d.ts +56 -0
  257. package/dist/extraction/svelte-extractor.d.ts.map +1 -0
  258. package/dist/extraction/svelte-extractor.js +275 -0
  259. package/dist/extraction/svelte-extractor.js.map +1 -0
  260. package/dist/extraction/tree-sitter-helpers.d.ts +28 -0
  261. package/dist/extraction/tree-sitter-helpers.d.ts.map +1 -0
  262. package/dist/extraction/tree-sitter-helpers.js +153 -0
  263. package/dist/extraction/tree-sitter-helpers.js.map +1 -0
  264. package/dist/extraction/tree-sitter-types.d.ts +260 -0
  265. package/dist/extraction/tree-sitter-types.d.ts.map +1 -0
  266. package/dist/extraction/tree-sitter-types.js +10 -0
  267. package/dist/extraction/tree-sitter-types.js.map +1 -0
  268. package/dist/extraction/tree-sitter.d.ts +728 -0
  269. package/dist/extraction/tree-sitter.d.ts.map +1 -0
  270. package/dist/extraction/tree-sitter.js +6676 -0
  271. package/dist/extraction/tree-sitter.js.map +1 -0
  272. package/dist/extraction/vue-extractor.d.ts +51 -0
  273. package/dist/extraction/vue-extractor.d.ts.map +1 -0
  274. package/dist/extraction/vue-extractor.js +254 -0
  275. package/dist/extraction/vue-extractor.js.map +1 -0
  276. package/dist/extraction/wasm/tree-sitter-arkts.wasm +0 -0
  277. package/dist/extraction/wasm/tree-sitter-c.wasm +0 -0
  278. package/dist/extraction/wasm/tree-sitter-c_sharp.wasm +0 -0
  279. package/dist/extraction/wasm/tree-sitter-cfml.wasm +0 -0
  280. package/dist/extraction/wasm/tree-sitter-cfquery.wasm +0 -0
  281. package/dist/extraction/wasm/tree-sitter-cfscript.wasm +0 -0
  282. package/dist/extraction/wasm/tree-sitter-cobol.wasm +0 -0
  283. package/dist/extraction/wasm/tree-sitter-cpp.wasm +0 -0
  284. package/dist/extraction/wasm/tree-sitter-dart.wasm +0 -0
  285. package/dist/extraction/wasm/tree-sitter-erlang.wasm +0 -0
  286. package/dist/extraction/wasm/tree-sitter-go.wasm +0 -0
  287. package/dist/extraction/wasm/tree-sitter-java.wasm +0 -0
  288. package/dist/extraction/wasm/tree-sitter-javascript.wasm +0 -0
  289. package/dist/extraction/wasm/tree-sitter-kotlin.wasm +0 -0
  290. package/dist/extraction/wasm/tree-sitter-lua.wasm +0 -0
  291. package/dist/extraction/wasm/tree-sitter-luau.wasm +0 -0
  292. package/dist/extraction/wasm/tree-sitter-nix.wasm +0 -0
  293. package/dist/extraction/wasm/tree-sitter-pascal.wasm +0 -0
  294. package/dist/extraction/wasm/tree-sitter-php.wasm +0 -0
  295. package/dist/extraction/wasm/tree-sitter-python.wasm +0 -0
  296. package/dist/extraction/wasm/tree-sitter-r.wasm +0 -0
  297. package/dist/extraction/wasm/tree-sitter-ruby.wasm +0 -0
  298. package/dist/extraction/wasm/tree-sitter-rust.wasm +0 -0
  299. package/dist/extraction/wasm/tree-sitter-scala.wasm +0 -0
  300. package/dist/extraction/wasm/tree-sitter-swift.wasm +0 -0
  301. package/dist/extraction/wasm/tree-sitter-terraform.wasm +0 -0
  302. package/dist/extraction/wasm/tree-sitter-tsx.wasm +0 -0
  303. package/dist/extraction/wasm/tree-sitter-typescript.wasm +0 -0
  304. package/dist/extraction/wasm/tree-sitter-vbnet.wasm +0 -0
  305. package/dist/extraction/wasm-runtime-flags.d.ts +53 -0
  306. package/dist/extraction/wasm-runtime-flags.d.ts.map +1 -0
  307. package/dist/extraction/wasm-runtime-flags.js +130 -0
  308. package/dist/extraction/wasm-runtime-flags.js.map +1 -0
  309. package/dist/graph/index.d.ts +8 -0
  310. package/dist/graph/index.d.ts.map +1 -0
  311. package/dist/graph/index.js +13 -0
  312. package/dist/graph/index.js.map +1 -0
  313. package/dist/graph/queries.d.ts +106 -0
  314. package/dist/graph/queries.d.ts.map +1 -0
  315. package/dist/graph/queries.js +341 -0
  316. package/dist/graph/queries.js.map +1 -0
  317. package/dist/graph/traversal.d.ts +127 -0
  318. package/dist/graph/traversal.d.ts.map +1 -0
  319. package/dist/graph/traversal.js +599 -0
  320. package/dist/graph/traversal.js.map +1 -0
  321. package/dist/index.d.ts +677 -0
  322. package/dist/index.d.ts.map +1 -0
  323. package/dist/index.js +1718 -0
  324. package/dist/index.js.map +1 -0
  325. package/dist/installer/beta-signup.d.ts +54 -0
  326. package/dist/installer/beta-signup.d.ts.map +1 -0
  327. package/dist/installer/beta-signup.js +178 -0
  328. package/dist/installer/beta-signup.js.map +1 -0
  329. package/dist/installer/config-writer.d.ts +28 -0
  330. package/dist/installer/config-writer.d.ts.map +1 -0
  331. package/dist/installer/config-writer.js +91 -0
  332. package/dist/installer/config-writer.js.map +1 -0
  333. package/dist/installer/index.d.ts +144 -0
  334. package/dist/installer/index.d.ts.map +1 -0
  335. package/dist/installer/index.js +634 -0
  336. package/dist/installer/index.js.map +1 -0
  337. package/dist/installer/instructions-template.d.ts +41 -0
  338. package/dist/installer/instructions-template.d.ts.map +1 -0
  339. package/dist/installer/instructions-template.js +53 -0
  340. package/dist/installer/instructions-template.js.map +1 -0
  341. package/dist/installer/targets/antigravity.d.ts +57 -0
  342. package/dist/installer/targets/antigravity.d.ts.map +1 -0
  343. package/dist/installer/targets/antigravity.js +308 -0
  344. package/dist/installer/targets/antigravity.js.map +1 -0
  345. package/dist/installer/targets/claude.d.ts +62 -0
  346. package/dist/installer/targets/claude.d.ts.map +1 -0
  347. package/dist/installer/targets/claude.js +486 -0
  348. package/dist/installer/targets/claude.js.map +1 -0
  349. package/dist/installer/targets/codex.d.ts +18 -0
  350. package/dist/installer/targets/codex.d.ts.map +1 -0
  351. package/dist/installer/targets/codex.js +185 -0
  352. package/dist/installer/targets/codex.js.map +1 -0
  353. package/dist/installer/targets/copilot-cli.d.ts +32 -0
  354. package/dist/installer/targets/copilot-cli.d.ts.map +1 -0
  355. package/dist/installer/targets/copilot-cli.js +209 -0
  356. package/dist/installer/targets/copilot-cli.js.map +1 -0
  357. package/dist/installer/targets/copilot-jetbrains.d.ts +42 -0
  358. package/dist/installer/targets/copilot-jetbrains.d.ts.map +1 -0
  359. package/dist/installer/targets/copilot-jetbrains.js +238 -0
  360. package/dist/installer/targets/copilot-jetbrains.js.map +1 -0
  361. package/dist/installer/targets/copilot-vscode.d.ts +47 -0
  362. package/dist/installer/targets/copilot-vscode.d.ts.map +1 -0
  363. package/dist/installer/targets/copilot-vscode.js +219 -0
  364. package/dist/installer/targets/copilot-vscode.js.map +1 -0
  365. package/dist/installer/targets/cursor.d.ts +35 -0
  366. package/dist/installer/targets/cursor.d.ts.map +1 -0
  367. package/dist/installer/targets/cursor.js +254 -0
  368. package/dist/installer/targets/cursor.js.map +1 -0
  369. package/dist/installer/targets/dsh.d.ts +97 -0
  370. package/dist/installer/targets/dsh.d.ts.map +1 -0
  371. package/dist/installer/targets/dsh.js +358 -0
  372. package/dist/installer/targets/dsh.js.map +1 -0
  373. package/dist/installer/targets/gemini.d.ts +26 -0
  374. package/dist/installer/targets/gemini.d.ts.map +1 -0
  375. package/dist/installer/targets/gemini.js +165 -0
  376. package/dist/installer/targets/gemini.js.map +1 -0
  377. package/dist/installer/targets/hermes.d.ts +18 -0
  378. package/dist/installer/targets/hermes.d.ts.map +1 -0
  379. package/dist/installer/targets/hermes.js +359 -0
  380. package/dist/installer/targets/hermes.js.map +1 -0
  381. package/dist/installer/targets/kiro.d.ts +27 -0
  382. package/dist/installer/targets/kiro.d.ts.map +1 -0
  383. package/dist/installer/targets/kiro.js +178 -0
  384. package/dist/installer/targets/kiro.js.map +1 -0
  385. package/dist/installer/targets/opencode.d.ts +38 -0
  386. package/dist/installer/targets/opencode.d.ts.map +1 -0
  387. package/dist/installer/targets/opencode.js +288 -0
  388. package/dist/installer/targets/opencode.js.map +1 -0
  389. package/dist/installer/targets/registry.d.ts +35 -0
  390. package/dist/installer/targets/registry.d.ts.map +1 -0
  391. package/dist/installer/targets/registry.js +101 -0
  392. package/dist/installer/targets/registry.js.map +1 -0
  393. package/dist/installer/targets/shared.d.ts +132 -0
  394. package/dist/installer/targets/shared.d.ts.map +1 -0
  395. package/dist/installer/targets/shared.js +314 -0
  396. package/dist/installer/targets/shared.js.map +1 -0
  397. package/dist/installer/targets/toml.d.ts +53 -0
  398. package/dist/installer/targets/toml.d.ts.map +1 -0
  399. package/dist/installer/targets/toml.js +226 -0
  400. package/dist/installer/targets/toml.js.map +1 -0
  401. package/dist/installer/targets/types.d.ts +109 -0
  402. package/dist/installer/targets/types.d.ts.map +1 -0
  403. package/dist/installer/targets/types.js +16 -0
  404. package/dist/installer/targets/types.js.map +1 -0
  405. package/dist/installer/targets/zcode.d.ts +106 -0
  406. package/dist/installer/targets/zcode.d.ts.map +1 -0
  407. package/dist/installer/targets/zcode.js +451 -0
  408. package/dist/installer/targets/zcode.js.map +1 -0
  409. package/dist/mcp/daemon-manager.d.ts +42 -0
  410. package/dist/mcp/daemon-manager.d.ts.map +1 -0
  411. package/dist/mcp/daemon-manager.js +129 -0
  412. package/dist/mcp/daemon-manager.js.map +1 -0
  413. package/dist/mcp/daemon-paths.d.ts +73 -0
  414. package/dist/mcp/daemon-paths.d.ts.map +1 -0
  415. package/dist/mcp/daemon-paths.js +165 -0
  416. package/dist/mcp/daemon-paths.js.map +1 -0
  417. package/dist/mcp/daemon-registry.d.ts +47 -0
  418. package/dist/mcp/daemon-registry.d.ts.map +1 -0
  419. package/dist/mcp/daemon-registry.js +233 -0
  420. package/dist/mcp/daemon-registry.js.map +1 -0
  421. package/dist/mcp/daemon.d.ts +290 -0
  422. package/dist/mcp/daemon.d.ts.map +1 -0
  423. package/dist/mcp/daemon.js +862 -0
  424. package/dist/mcp/daemon.js.map +1 -0
  425. package/dist/mcp/dynamic-boundaries.d.ts +41 -0
  426. package/dist/mcp/dynamic-boundaries.d.ts.map +1 -0
  427. package/dist/mcp/dynamic-boundaries.js +360 -0
  428. package/dist/mcp/dynamic-boundaries.js.map +1 -0
  429. package/dist/mcp/early-ppid.d.ts +26 -0
  430. package/dist/mcp/early-ppid.d.ts.map +1 -0
  431. package/dist/mcp/early-ppid.js +29 -0
  432. package/dist/mcp/early-ppid.js.map +1 -0
  433. package/dist/mcp/engine.d.ts +122 -0
  434. package/dist/mcp/engine.d.ts.map +1 -0
  435. package/dist/mcp/engine.js +350 -0
  436. package/dist/mcp/engine.js.map +1 -0
  437. package/dist/mcp/explore-dedup.d.ts +137 -0
  438. package/dist/mcp/explore-dedup.d.ts.map +1 -0
  439. package/dist/mcp/explore-dedup.js +236 -0
  440. package/dist/mcp/explore-dedup.js.map +1 -0
  441. package/dist/mcp/explore-diagnostics.d.ts +287 -0
  442. package/dist/mcp/explore-diagnostics.d.ts.map +1 -0
  443. package/dist/mcp/explore-diagnostics.js +555 -0
  444. package/dist/mcp/explore-diagnostics.js.map +1 -0
  445. package/dist/mcp/explore-session-state.d.ts +217 -0
  446. package/dist/mcp/explore-session-state.d.ts.map +1 -0
  447. package/dist/mcp/explore-session-state.js +322 -0
  448. package/dist/mcp/explore-session-state.js.map +1 -0
  449. package/dist/mcp/index.d.ts +137 -0
  450. package/dist/mcp/index.d.ts.map +1 -0
  451. package/dist/mcp/index.js +554 -0
  452. package/dist/mcp/index.js.map +1 -0
  453. package/dist/mcp/liveness-watchdog.d.ts +35 -0
  454. package/dist/mcp/liveness-watchdog.d.ts.map +1 -0
  455. package/dist/mcp/liveness-watchdog.js +269 -0
  456. package/dist/mcp/liveness-watchdog.js.map +1 -0
  457. package/dist/mcp/ppid-watchdog.d.ts +62 -0
  458. package/dist/mcp/ppid-watchdog.d.ts.map +1 -0
  459. package/dist/mcp/ppid-watchdog.js +64 -0
  460. package/dist/mcp/ppid-watchdog.js.map +1 -0
  461. package/dist/mcp/proxy.d.ts +87 -0
  462. package/dist/mcp/proxy.d.ts.map +1 -0
  463. package/dist/mcp/proxy.js +672 -0
  464. package/dist/mcp/proxy.js.map +1 -0
  465. package/dist/mcp/query-pool.d.ts +108 -0
  466. package/dist/mcp/query-pool.d.ts.map +1 -0
  467. package/dist/mcp/query-pool.js +315 -0
  468. package/dist/mcp/query-pool.js.map +1 -0
  469. package/dist/mcp/query-worker.d.ts +24 -0
  470. package/dist/mcp/query-worker.d.ts.map +1 -0
  471. package/dist/mcp/query-worker.js +87 -0
  472. package/dist/mcp/query-worker.js.map +1 -0
  473. package/dist/mcp/server-instructions.d.ts +34 -0
  474. package/dist/mcp/server-instructions.d.ts.map +1 -0
  475. package/dist/mcp/server-instructions.js +111 -0
  476. package/dist/mcp/server-instructions.js.map +1 -0
  477. package/dist/mcp/session.d.ts +109 -0
  478. package/dist/mcp/session.d.ts.map +1 -0
  479. package/dist/mcp/session.js +375 -0
  480. package/dist/mcp/session.js.map +1 -0
  481. package/dist/mcp/startup-handshake.d.ts +44 -0
  482. package/dist/mcp/startup-handshake.d.ts.map +1 -0
  483. package/dist/mcp/startup-handshake.js +73 -0
  484. package/dist/mcp/startup-handshake.js.map +1 -0
  485. package/dist/mcp/stdin-teardown.d.ts +27 -0
  486. package/dist/mcp/stdin-teardown.d.ts.map +1 -0
  487. package/dist/mcp/stdin-teardown.js +49 -0
  488. package/dist/mcp/stdin-teardown.js.map +1 -0
  489. package/dist/mcp/tools.d.ts +862 -0
  490. package/dist/mcp/tools.d.ts.map +1 -0
  491. package/dist/mcp/tools.js +6526 -0
  492. package/dist/mcp/tools.js.map +1 -0
  493. package/dist/mcp/transport.d.ts +188 -0
  494. package/dist/mcp/transport.d.ts.map +1 -0
  495. package/dist/mcp/transport.js +377 -0
  496. package/dist/mcp/transport.js.map +1 -0
  497. package/dist/mcp/version.d.ts +19 -0
  498. package/dist/mcp/version.d.ts.map +1 -0
  499. package/dist/mcp/version.js +71 -0
  500. package/dist/mcp/version.js.map +1 -0
  501. package/dist/project-config.d.ts +94 -0
  502. package/dist/project-config.d.ts.map +1 -0
  503. package/dist/project-config.js +374 -0
  504. package/dist/project-config.js.map +1 -0
  505. package/dist/prompt-hook-output.d.ts +23 -0
  506. package/dist/prompt-hook-output.d.ts.map +1 -0
  507. package/dist/prompt-hook-output.js +35 -0
  508. package/dist/prompt-hook-output.js.map +1 -0
  509. package/dist/resolution/c-fnptr-synthesizer.d.ts +6 -0
  510. package/dist/resolution/c-fnptr-synthesizer.d.ts.map +1 -0
  511. package/dist/resolution/c-fnptr-synthesizer.js +1506 -0
  512. package/dist/resolution/c-fnptr-synthesizer.js.map +1 -0
  513. package/dist/resolution/callback-synthesizer.d.ts +59 -0
  514. package/dist/resolution/callback-synthesizer.d.ts.map +1 -0
  515. package/dist/resolution/callback-synthesizer.js +4030 -0
  516. package/dist/resolution/callback-synthesizer.js.map +1 -0
  517. package/dist/resolution/cooperative-yield.d.ts +40 -0
  518. package/dist/resolution/cooperative-yield.d.ts.map +1 -0
  519. package/dist/resolution/cooperative-yield.js +44 -0
  520. package/dist/resolution/cooperative-yield.js.map +1 -0
  521. package/dist/resolution/frameworks/astro.d.ts +9 -0
  522. package/dist/resolution/frameworks/astro.d.ts.map +1 -0
  523. package/dist/resolution/frameworks/astro.js +169 -0
  524. package/dist/resolution/frameworks/astro.js.map +1 -0
  525. package/dist/resolution/frameworks/cargo-workspace.d.ts +18 -0
  526. package/dist/resolution/frameworks/cargo-workspace.d.ts.map +1 -0
  527. package/dist/resolution/frameworks/cargo-workspace.js +225 -0
  528. package/dist/resolution/frameworks/cargo-workspace.js.map +1 -0
  529. package/dist/resolution/frameworks/cics.d.ts +20 -0
  530. package/dist/resolution/frameworks/cics.d.ts.map +1 -0
  531. package/dist/resolution/frameworks/cics.js +90 -0
  532. package/dist/resolution/frameworks/cics.js.map +1 -0
  533. package/dist/resolution/frameworks/csharp.d.ts +8 -0
  534. package/dist/resolution/frameworks/csharp.d.ts.map +1 -0
  535. package/dist/resolution/frameworks/csharp.js +241 -0
  536. package/dist/resolution/frameworks/csharp.js.map +1 -0
  537. package/dist/resolution/frameworks/drupal.d.ts +51 -0
  538. package/dist/resolution/frameworks/drupal.d.ts.map +1 -0
  539. package/dist/resolution/frameworks/drupal.js +367 -0
  540. package/dist/resolution/frameworks/drupal.js.map +1 -0
  541. package/dist/resolution/frameworks/expo-modules.d.ts +3 -0
  542. package/dist/resolution/frameworks/expo-modules.d.ts.map +1 -0
  543. package/dist/resolution/frameworks/expo-modules.js +148 -0
  544. package/dist/resolution/frameworks/expo-modules.js.map +1 -0
  545. package/dist/resolution/frameworks/express.d.ts +8 -0
  546. package/dist/resolution/frameworks/express.d.ts.map +1 -0
  547. package/dist/resolution/frameworks/express.js +308 -0
  548. package/dist/resolution/frameworks/express.js.map +1 -0
  549. package/dist/resolution/frameworks/fabric.d.ts +3 -0
  550. package/dist/resolution/frameworks/fabric.d.ts.map +1 -0
  551. package/dist/resolution/frameworks/fabric.js +354 -0
  552. package/dist/resolution/frameworks/fabric.js.map +1 -0
  553. package/dist/resolution/frameworks/go.d.ts +8 -0
  554. package/dist/resolution/frameworks/go.d.ts.map +1 -0
  555. package/dist/resolution/frameworks/go.js +184 -0
  556. package/dist/resolution/frameworks/go.js.map +1 -0
  557. package/dist/resolution/frameworks/goframe.d.ts +41 -0
  558. package/dist/resolution/frameworks/goframe.d.ts.map +1 -0
  559. package/dist/resolution/frameworks/goframe.js +112 -0
  560. package/dist/resolution/frameworks/goframe.js.map +1 -0
  561. package/dist/resolution/frameworks/index.d.ts +50 -0
  562. package/dist/resolution/frameworks/index.d.ts.map +1 -0
  563. package/dist/resolution/frameworks/index.js +175 -0
  564. package/dist/resolution/frameworks/index.js.map +1 -0
  565. package/dist/resolution/frameworks/java.d.ts +8 -0
  566. package/dist/resolution/frameworks/java.d.ts.map +1 -0
  567. package/dist/resolution/frameworks/java.js +517 -0
  568. package/dist/resolution/frameworks/java.js.map +1 -0
  569. package/dist/resolution/frameworks/laravel.d.ts +13 -0
  570. package/dist/resolution/frameworks/laravel.d.ts.map +1 -0
  571. package/dist/resolution/frameworks/laravel.js +257 -0
  572. package/dist/resolution/frameworks/laravel.js.map +1 -0
  573. package/dist/resolution/frameworks/nestjs.d.ts +26 -0
  574. package/dist/resolution/frameworks/nestjs.d.ts.map +1 -0
  575. package/dist/resolution/frameworks/nestjs.js +698 -0
  576. package/dist/resolution/frameworks/nestjs.js.map +1 -0
  577. package/dist/resolution/frameworks/play.d.ts +19 -0
  578. package/dist/resolution/frameworks/play.d.ts.map +1 -0
  579. package/dist/resolution/frameworks/play.js +111 -0
  580. package/dist/resolution/frameworks/play.js.map +1 -0
  581. package/dist/resolution/frameworks/python.d.ts +10 -0
  582. package/dist/resolution/frameworks/python.d.ts.map +1 -0
  583. package/dist/resolution/frameworks/python.js +400 -0
  584. package/dist/resolution/frameworks/python.js.map +1 -0
  585. package/dist/resolution/frameworks/react-native.d.ts +3 -0
  586. package/dist/resolution/frameworks/react-native.d.ts.map +1 -0
  587. package/dist/resolution/frameworks/react-native.js +410 -0
  588. package/dist/resolution/frameworks/react-native.js.map +1 -0
  589. package/dist/resolution/frameworks/react.d.ts +8 -0
  590. package/dist/resolution/frameworks/react.d.ts.map +1 -0
  591. package/dist/resolution/frameworks/react.js +334 -0
  592. package/dist/resolution/frameworks/react.js.map +1 -0
  593. package/dist/resolution/frameworks/ruby.d.ts +8 -0
  594. package/dist/resolution/frameworks/ruby.d.ts.map +1 -0
  595. package/dist/resolution/frameworks/ruby.js +302 -0
  596. package/dist/resolution/frameworks/ruby.js.map +1 -0
  597. package/dist/resolution/frameworks/rust.d.ts +8 -0
  598. package/dist/resolution/frameworks/rust.d.ts.map +1 -0
  599. package/dist/resolution/frameworks/rust.js +304 -0
  600. package/dist/resolution/frameworks/rust.js.map +1 -0
  601. package/dist/resolution/frameworks/svelte.d.ts +9 -0
  602. package/dist/resolution/frameworks/svelte.d.ts.map +1 -0
  603. package/dist/resolution/frameworks/svelte.js +253 -0
  604. package/dist/resolution/frameworks/svelte.js.map +1 -0
  605. package/dist/resolution/frameworks/swift-objc.d.ts +37 -0
  606. package/dist/resolution/frameworks/swift-objc.d.ts.map +1 -0
  607. package/dist/resolution/frameworks/swift-objc.js +252 -0
  608. package/dist/resolution/frameworks/swift-objc.js.map +1 -0
  609. package/dist/resolution/frameworks/swift.d.ts +10 -0
  610. package/dist/resolution/frameworks/swift.d.ts.map +1 -0
  611. package/dist/resolution/frameworks/swift.js +400 -0
  612. package/dist/resolution/frameworks/swift.js.map +1 -0
  613. package/dist/resolution/frameworks/terraform.d.ts +38 -0
  614. package/dist/resolution/frameworks/terraform.d.ts.map +1 -0
  615. package/dist/resolution/frameworks/terraform.js +277 -0
  616. package/dist/resolution/frameworks/terraform.js.map +1 -0
  617. package/dist/resolution/frameworks/vue.d.ts +9 -0
  618. package/dist/resolution/frameworks/vue.d.ts.map +1 -0
  619. package/dist/resolution/frameworks/vue.js +303 -0
  620. package/dist/resolution/frameworks/vue.js.map +1 -0
  621. package/dist/resolution/go-module.d.ts +26 -0
  622. package/dist/resolution/go-module.d.ts.map +1 -0
  623. package/dist/resolution/go-module.js +78 -0
  624. package/dist/resolution/go-module.js.map +1 -0
  625. package/dist/resolution/goframe-synthesizer.d.ts +29 -0
  626. package/dist/resolution/goframe-synthesizer.d.ts.map +1 -0
  627. package/dist/resolution/goframe-synthesizer.js +163 -0
  628. package/dist/resolution/goframe-synthesizer.js.map +1 -0
  629. package/dist/resolution/import-resolver.d.ts +84 -0
  630. package/dist/resolution/import-resolver.d.ts.map +1 -0
  631. package/dist/resolution/import-resolver.js +2134 -0
  632. package/dist/resolution/import-resolver.js.map +1 -0
  633. package/dist/resolution/index.d.ts +343 -0
  634. package/dist/resolution/index.d.ts.map +1 -0
  635. package/dist/resolution/index.js +2339 -0
  636. package/dist/resolution/index.js.map +1 -0
  637. package/dist/resolution/lru-cache.d.ts +24 -0
  638. package/dist/resolution/lru-cache.d.ts.map +1 -0
  639. package/dist/resolution/lru-cache.js +62 -0
  640. package/dist/resolution/lru-cache.js.map +1 -0
  641. package/dist/resolution/memory-budget.d.ts +48 -0
  642. package/dist/resolution/memory-budget.d.ts.map +1 -0
  643. package/dist/resolution/memory-budget.js +162 -0
  644. package/dist/resolution/memory-budget.js.map +1 -0
  645. package/dist/resolution/name-matcher.d.ts +123 -0
  646. package/dist/resolution/name-matcher.d.ts.map +1 -0
  647. package/dist/resolution/name-matcher.js +2134 -0
  648. package/dist/resolution/name-matcher.js.map +1 -0
  649. package/dist/resolution/path-aliases.d.ts +68 -0
  650. package/dist/resolution/path-aliases.d.ts.map +1 -0
  651. package/dist/resolution/path-aliases.js +238 -0
  652. package/dist/resolution/path-aliases.js.map +1 -0
  653. package/dist/resolution/resolver-pool.d.ts +106 -0
  654. package/dist/resolution/resolver-pool.d.ts.map +1 -0
  655. package/dist/resolution/resolver-pool.js +344 -0
  656. package/dist/resolution/resolver-pool.js.map +1 -0
  657. package/dist/resolution/resolver-worker.d.ts +17 -0
  658. package/dist/resolution/resolver-worker.d.ts.map +1 -0
  659. package/dist/resolution/resolver-worker.js +141 -0
  660. package/dist/resolution/resolver-worker.js.map +1 -0
  661. package/dist/resolution/strip-comments.d.ts +27 -0
  662. package/dist/resolution/strip-comments.d.ts.map +1 -0
  663. package/dist/resolution/strip-comments.js +492 -0
  664. package/dist/resolution/strip-comments.js.map +1 -0
  665. package/dist/resolution/swift-objc-bridge.d.ts +134 -0
  666. package/dist/resolution/swift-objc-bridge.d.ts.map +1 -0
  667. package/dist/resolution/swift-objc-bridge.js +256 -0
  668. package/dist/resolution/swift-objc-bridge.js.map +1 -0
  669. package/dist/resolution/types.d.ts +265 -0
  670. package/dist/resolution/types.d.ts.map +1 -0
  671. package/dist/resolution/types.js +8 -0
  672. package/dist/resolution/types.js.map +1 -0
  673. package/dist/resolution/workspace-packages.d.ts +58 -0
  674. package/dist/resolution/workspace-packages.d.ts.map +1 -0
  675. package/dist/resolution/workspace-packages.js +346 -0
  676. package/dist/resolution/workspace-packages.js.map +1 -0
  677. package/dist/search/identifier-segments.d.ts +60 -0
  678. package/dist/search/identifier-segments.d.ts.map +1 -0
  679. package/dist/search/identifier-segments.js +176 -0
  680. package/dist/search/identifier-segments.js.map +1 -0
  681. package/dist/search/query-parser.d.ts +57 -0
  682. package/dist/search/query-parser.d.ts.map +1 -0
  683. package/dist/search/query-parser.js +177 -0
  684. package/dist/search/query-parser.js.map +1 -0
  685. package/dist/search/query-utils.d.ts +87 -0
  686. package/dist/search/query-utils.d.ts.map +1 -0
  687. package/dist/search/query-utils.js +450 -0
  688. package/dist/search/query-utils.js.map +1 -0
  689. package/dist/sync/git-hooks.d.ts +45 -0
  690. package/dist/sync/git-hooks.d.ts.map +1 -0
  691. package/dist/sync/git-hooks.js +227 -0
  692. package/dist/sync/git-hooks.js.map +1 -0
  693. package/dist/sync/index.d.ts +19 -0
  694. package/dist/sync/index.d.ts.map +1 -0
  695. package/dist/sync/index.js +35 -0
  696. package/dist/sync/index.js.map +1 -0
  697. package/dist/sync/watch-policy.d.ts +48 -0
  698. package/dist/sync/watch-policy.d.ts.map +1 -0
  699. package/dist/sync/watch-policy.js +124 -0
  700. package/dist/sync/watch-policy.js.map +1 -0
  701. package/dist/sync/watcher.d.ts +379 -0
  702. package/dist/sync/watcher.d.ts.map +1 -0
  703. package/dist/sync/watcher.js +921 -0
  704. package/dist/sync/watcher.js.map +1 -0
  705. package/dist/sync/worktree.d.ts +63 -0
  706. package/dist/sync/worktree.d.ts.map +1 -0
  707. package/dist/sync/worktree.js +182 -0
  708. package/dist/sync/worktree.js.map +1 -0
  709. package/dist/telemetry/index.d.ts +143 -0
  710. package/dist/telemetry/index.d.ts.map +1 -0
  711. package/dist/telemetry/index.js +541 -0
  712. package/dist/telemetry/index.js.map +1 -0
  713. package/dist/types.d.ts +465 -0
  714. package/dist/types.d.ts.map +1 -0
  715. package/dist/types.js +117 -0
  716. package/dist/types.js.map +1 -0
  717. package/dist/ui/color.d.ts +21 -0
  718. package/dist/ui/color.d.ts.map +1 -0
  719. package/dist/ui/color.js +42 -0
  720. package/dist/ui/color.js.map +1 -0
  721. package/dist/ui/glyphs.d.ts +67 -0
  722. package/dist/ui/glyphs.d.ts.map +1 -0
  723. package/dist/ui/glyphs.js +125 -0
  724. package/dist/ui/glyphs.js.map +1 -0
  725. package/dist/ui/shimmer-progress.d.ts +11 -0
  726. package/dist/ui/shimmer-progress.d.ts.map +1 -0
  727. package/dist/ui/shimmer-progress.js +164 -0
  728. package/dist/ui/shimmer-progress.js.map +1 -0
  729. package/dist/ui/shimmer-worker.d.ts +2 -0
  730. package/dist/ui/shimmer-worker.d.ts.map +1 -0
  731. package/dist/ui/shimmer-worker.js +126 -0
  732. package/dist/ui/shimmer-worker.js.map +1 -0
  733. package/dist/ui/types.d.ts +15 -0
  734. package/dist/ui/types.d.ts.map +1 -0
  735. package/dist/ui/types.js +3 -0
  736. package/dist/ui/types.js.map +1 -0
  737. package/dist/upgrade/index.d.ts +171 -0
  738. package/dist/upgrade/index.d.ts.map +1 -0
  739. package/dist/upgrade/index.js +659 -0
  740. package/dist/upgrade/index.js.map +1 -0
  741. package/dist/upgrade/remove-binary.d.ts +87 -0
  742. package/dist/upgrade/remove-binary.d.ts.map +1 -0
  743. package/dist/upgrade/remove-binary.js +289 -0
  744. package/dist/upgrade/remove-binary.js.map +1 -0
  745. package/dist/upgrade/update-check.d.ts +92 -0
  746. package/dist/upgrade/update-check.d.ts.map +1 -0
  747. package/dist/upgrade/update-check.js +258 -0
  748. package/dist/upgrade/update-check.js.map +1 -0
  749. package/dist/utils.d.ts +224 -0
  750. package/dist/utils.d.ts.map +1 -0
  751. package/dist/utils.js +583 -0
  752. package/dist/utils.js.map +1 -0
  753. package/package.json +61 -0
  754. package/scripts/add-lang/bench.sh +60 -0
  755. package/scripts/add-lang/check-grammar.mjs +75 -0
  756. package/scripts/add-lang/dump-ast.mjs +103 -0
  757. package/scripts/add-lang/verify-extraction.mjs +70 -0
  758. package/scripts/agent-eval/ab-adoption.sh +91 -0
  759. package/scripts/agent-eval/ab-hook.sh +86 -0
  760. package/scripts/agent-eval/ab-impl.sh +78 -0
  761. package/scripts/agent-eval/ab-new-vs-baseline.sh +161 -0
  762. package/scripts/agent-eval/ab-sufficiency.sh +78 -0
  763. package/scripts/agent-eval/allocation-fixtures.json +344 -0
  764. package/scripts/agent-eval/arms-F.sh +21 -0
  765. package/scripts/agent-eval/arms-matrix.sh +37 -0
  766. package/scripts/agent-eval/audit.sh +68 -0
  767. package/scripts/agent-eval/bench-readme.sh +48 -0
  768. package/scripts/agent-eval/bench-why-repo.sh +22 -0
  769. package/scripts/agent-eval/block-read-hook.sh +19 -0
  770. package/scripts/agent-eval/compare-arms.mjs +209 -0
  771. package/scripts/agent-eval/diff-index-drift.mjs +102 -0
  772. package/scripts/agent-eval/hook-settings.json +15 -0
  773. package/scripts/agent-eval/itrun.sh +120 -0
  774. package/scripts/agent-eval/no-cli-shim.sh +96 -0
  775. package/scripts/agent-eval/offload-eval-3arm.sh +72 -0
  776. package/scripts/agent-eval/offload-eval-cost.mjs +133 -0
  777. package/scripts/agent-eval/offload-eval-effort.mjs +108 -0
  778. package/scripts/agent-eval/offload-eval-frontload-matrix.sh +25 -0
  779. package/scripts/agent-eval/offload-eval-frontload.sh +47 -0
  780. package/scripts/agent-eval/offload-eval-ground-truth.json +18 -0
  781. package/scripts/agent-eval/offload-eval-hook.mjs +84 -0
  782. package/scripts/agent-eval/offload-eval-judge.mjs +103 -0
  783. package/scripts/agent-eval/offload-eval-matrix.sh +20 -0
  784. package/scripts/agent-eval/offload-eval-metrics.mjs +94 -0
  785. package/scripts/agent-eval/offload-eval-refs1.sh +50 -0
  786. package/scripts/agent-eval/offload-eval-setup.sh +24 -0
  787. package/scripts/agent-eval/offload-eval-styles.sh +72 -0
  788. package/scripts/agent-eval/offload-eval-summarize.mjs +68 -0
  789. package/scripts/agent-eval/offload-eval.md +76 -0
  790. package/scripts/agent-eval/parse-arms.mjs +116 -0
  791. package/scripts/agent-eval/parse-bench-readme.mjs +238 -0
  792. package/scripts/agent-eval/parse-run.mjs +1401 -0
  793. package/scripts/agent-eval/parse-session.mjs +130 -0
  794. package/scripts/agent-eval/probe-allocation.mjs +335 -0
  795. package/scripts/agent-eval/probe-context.mjs +21 -0
  796. package/scripts/agent-eval/probe-decl-only.mjs +198 -0
  797. package/scripts/agent-eval/probe-explore.mjs +40 -0
  798. package/scripts/agent-eval/probe-factory-closure.mjs +147 -0
  799. package/scripts/agent-eval/probe-file-spend.mjs +195 -0
  800. package/scripts/agent-eval/probe-named-symbol.mjs +163 -0
  801. package/scripts/agent-eval/probe-node.mjs +20 -0
  802. package/scripts/agent-eval/probe-suite-envelope.mjs +124 -0
  803. package/scripts/agent-eval/probe-sweep.mjs +119 -0
  804. package/scripts/agent-eval/probe-trace.mjs +20 -0
  805. package/scripts/agent-eval/redirect-read-hook.sh +38 -0
  806. package/scripts/agent-eval/repro-concurrent-explore.mjs +119 -0
  807. package/scripts/agent-eval/repro-daemon-clients.mjs +125 -0
  808. package/scripts/agent-eval/run-agent.sh +34 -0
  809. package/scripts/agent-eval/run-all.sh +149 -0
  810. package/scripts/agent-eval/run-arms.sh +56 -0
  811. package/scripts/agent-eval/seq-matrix.mjs +137 -0
  812. package/scripts/build-bundle.sh +145 -0
  813. package/scripts/build-kernel.sh +87 -0
  814. package/scripts/dump-graph.mjs +57 -0
  815. package/scripts/extract-release-notes.mjs +130 -0
  816. package/scripts/kernel-parity.mjs +283 -0
  817. package/scripts/local-install.sh +41 -0
  818. package/scripts/npm-sdk.js +75 -0
  819. package/scripts/npm-shim.js +279 -0
  820. package/scripts/pack-npm.sh +123 -0
  821. package/scripts/prepare-release.mjs +270 -0
@@ -0,0 +1,2711 @@
1
+ "use strict";
2
+ /**
3
+ * Extraction Orchestrator
4
+ *
5
+ * Coordinates file scanning, parsing, and database storage.
6
+ */
7
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
8
+ if (k2 === undefined) k2 = k;
9
+ var desc = Object.getOwnPropertyDescriptor(m, k);
10
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
11
+ desc = { enumerable: true, get: function() { return m[k]; } };
12
+ }
13
+ Object.defineProperty(o, k2, desc);
14
+ }) : (function(o, m, k, k2) {
15
+ if (k2 === undefined) k2 = k;
16
+ o[k2] = m[k];
17
+ }));
18
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
19
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
20
+ }) : function(o, v) {
21
+ o["default"] = v;
22
+ });
23
+ var __importStar = (this && this.__importStar) || (function () {
24
+ var ownKeys = function(o) {
25
+ ownKeys = Object.getOwnPropertyNames || function (o) {
26
+ var ar = [];
27
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
28
+ return ar;
29
+ };
30
+ return ownKeys(o);
31
+ };
32
+ return function (mod) {
33
+ if (mod && mod.__esModule) return mod;
34
+ var result = {};
35
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
36
+ __setModuleDefault(result, mod);
37
+ return result;
38
+ };
39
+ })();
40
+ var __importDefault = (this && this.__importDefault) || function (mod) {
41
+ return (mod && mod.__esModule) ? mod : { "default": mod };
42
+ };
43
+ Object.defineProperty(exports, "__esModule", { value: true });
44
+ exports.loadAllGrammars = exports.loadGrammarsForLanguages = exports.initGrammars = exports.getSupportedLanguages = exports.isGrammarLoaded = exports.isLanguageSupported = exports.isSourceFile = exports.detectLanguage = exports.extractFromSource = exports.ExtractionOrchestrator = exports.ScopeIgnore = void 0;
45
+ exports.hashContent = hashContent;
46
+ exports.buildDefaultIgnore = buildDefaultIgnore;
47
+ exports.buildScopeIgnore = buildScopeIgnore;
48
+ exports.discoverEmbeddedRepoRoots = discoverEmbeddedRepoRoots;
49
+ exports.findUnindexedIgnoredRepos = findUnindexedIgnoredRepos;
50
+ exports.scanDirectory = scanDirectory;
51
+ exports.scanDirectoryAsync = scanDirectoryAsync;
52
+ const fs = __importStar(require("fs"));
53
+ const fsp = __importStar(require("fs/promises"));
54
+ const path = __importStar(require("path"));
55
+ const os = __importStar(require("os"));
56
+ const crypto = __importStar(require("crypto"));
57
+ const child_process_1 = require("child_process");
58
+ const tree_sitter_1 = require("./tree-sitter");
59
+ const parse_pool_1 = require("./parse-pool");
60
+ const store_writer_1 = require("./store-writer");
61
+ const kernel_1 = require("./kernel");
62
+ const generated_detection_1 = require("./generated-detection");
63
+ const grammars_1 = require("./grammars");
64
+ const project_config_1 = require("../project-config");
65
+ const directory_1 = require("../directory");
66
+ const errors_1 = require("../errors");
67
+ const utils_1 = require("../utils");
68
+ const ignore_1 = __importDefault(require("ignore"));
69
+ const frameworks_1 = require("../resolution/frameworks");
70
+ const cooperative_yield_1 = require("../resolution/cooperative-yield");
71
+ /**
72
+ * Number of files to read in parallel during indexing.
73
+ * File reads are I/O-bound; batching overlaps I/O wait with CPU parse work.
74
+ */
75
+ const FILE_IO_BATCH_SIZE = 10;
76
+ /**
77
+ * How many files the `sync()` reconcile processes between cooperative yields to
78
+ * the event loop. The reconcile runs two O(files) loops of synchronous `fs`
79
+ * calls (existsSync for removals, statSync for adds/mods); on a very large repo
80
+ * (~100k files) an un-yielded run wedges the main thread for minutes, which both
81
+ * trips the liveness watchdog (it SIGKILLs a process whose loop stops turning)
82
+ * and blocks the first MCP tool call behind the catch-up gate (issue #905).
83
+ * Yielding every N files keeps the socket, the watchdog heartbeat, and any
84
+ * concurrent read query responsive while the reconcile runs.
85
+ */
86
+ const SYNC_RECONCILE_YIELD_INTERVAL = 1000;
87
+ // PARSER_RESET_INTERVAL moved to parse-worker.ts (runs in worker thread)
88
+ /**
89
+ * Maximum time (ms) to wait for a single file to parse in the worker thread.
90
+ * If tree-sitter hangs or WASM runs out of memory, this prevents the entire
91
+ * indexing run from freezing. The worker is restarted after a (hard) timeout.
92
+ * Env-overridable via CODEGRAPH_PARSE_TIMEOUT_MS for slow storage (#1231).
93
+ */
94
+ const PARSE_TIMEOUT_MS = (0, parse_pool_1.resolveParseTimeoutMs)(process.env.CODEGRAPH_PARSE_TIMEOUT_MS);
95
+ /**
96
+ * Number of files to parse before recycling the worker thread.
97
+ * WASM linear memory can grow but NEVER shrink (WebAssembly spec limitation).
98
+ * The only way to reclaim tree-sitter's WASM heap is to destroy the entire
99
+ * V8 isolate by terminating the worker thread and spawning a fresh one.
100
+ * This interval balances memory usage against the cost of reloading grammars.
101
+ */
102
+ const WORKER_RECYCLE_INTERVAL = 250;
103
+ /**
104
+ * Calculate SHA256 hash of file contents
105
+ */
106
+ function hashContent(content) {
107
+ return crypto.createHash('sha256').update(content).digest('hex');
108
+ }
109
+ /**
110
+ * Skip files larger than this (bytes). Generated bundles, minified JS, and
111
+ * vendored blobs blow the WASM heap and the worker-recycle budget for no useful
112
+ * symbols. 1 MB covers essentially all hand-written source.
113
+ */
114
+ const MAX_FILE_SIZE = 1024 * 1024;
115
+ /**
116
+ * Directory names that are dependency, build, cache, or tooling output across the
117
+ * languages/frameworks CodeGraph supports — curated from the canonical
118
+ * github/gitignore templates. Excluded by default so the graph reflects your code,
119
+ * not third-party noise, without requiring a `.gitignore` (issue #407). The
120
+ * exclusion applies uniformly (git or not, tracked or not); the only opt-in is an
121
+ * explicit `.gitignore` negation (e.g. `!vendor/`). First-party-prone or generic
122
+ * names (`packages`, `lib`, `app`, `bin`, `src`, `deps`, `env`, `tmp`, `storage`,
123
+ * `Library`) are deliberately NOT listed, to avoid ever hiding real source.
124
+ *
125
+ * Only dirs that actually contain *indexable source* (or are enormous) earn a slot
126
+ * — IDE/state dirs like `.idea`/`.vs` are omitted because CodeGraph indexes only
127
+ * recognized source extensions, so they produce no symbols regardless.
128
+ */
129
+ const DEFAULT_IGNORE_DIRS = new Set([
130
+ // JS / TS — dependency directories
131
+ 'node_modules', 'bower_components', 'jspm_packages', 'web_modules',
132
+ '.yarn', '.pnpm-store',
133
+ // JS / TS — framework & bundler build / cache / deploy output
134
+ '.next', '.nuxt', '.svelte-kit', '.turbo', '.vite', '.parcel-cache', '.angular',
135
+ '.docusaurus', 'storybook-static', '.vinxi', '.nitro', 'out-tsc',
136
+ '.vercel', '.netlify', '.wrangler',
137
+ // Build output (common across ecosystems)
138
+ 'dist', 'build', 'out', '.output',
139
+ // Test / coverage
140
+ 'coverage', '.nyc_output',
141
+ // Python
142
+ '__pycache__', '__pypackages__', '.venv', 'venv', '.pixi', '.pdm-build',
143
+ '.mypy_cache', '.pytest_cache', '.ruff_cache', '.tox', '.nox', '.hypothesis',
144
+ '.ipynb_checkpoints', '.eggs',
145
+ // Rust / JVM (Maven, Gradle, Scala)
146
+ 'target', '.gradle',
147
+ // .NET
148
+ 'obj',
149
+ // Vendored deps (Go, PHP/Composer, Ruby/Bundler)
150
+ 'vendor',
151
+ // Swift / iOS
152
+ '.build', 'Pods', 'Carthage', 'DerivedData', '.swiftpm',
153
+ // Dart / Flutter
154
+ '.dart_tool', '.pub-cache',
155
+ // Native (Android NDK, C/C++ deps)
156
+ '.cxx', '.externalNativeBuild', 'vcpkg_installed',
157
+ // Scala tooling
158
+ '.bloop', '.metals',
159
+ // Lua / Luau (LuaRocks)
160
+ 'lua_modules', '.luarocks',
161
+ // Delphi / RAD Studio IDE backups (duplicate .pas source — would double-count)
162
+ '__history', '__recovery',
163
+ // Generic cache
164
+ '.cache',
165
+ ]);
166
+ /**
167
+ * Android resource directory types. A `res/` tree holds ONLY non-code resources —
168
+ * layouts, drawables, value bags (strings/colors/styles), menus, navigation
169
+ * graphs — split into one typed subdirectory per kind, optionally density/locale/
170
+ * version-qualified (`values-es`, `drawable-hdpi`, `layout-v21`, …). None of it
171
+ * yields an extractable code symbol, yet on an Android app it DOMINATES the tree
172
+ * (one report: 26k XML files = 97% of the project, 0 symbols), bloating the DB,
173
+ * slowing indexing, and skewing both the file count and `codegraph_explore`
174
+ * results (#1047). So these are excluded by default. The structure is
175
+ * self-identifying — a non-Android project has no `res/layout/` etc., so it's
176
+ * untouched — and the only XML that DOES produce symbols (MyBatis mappers) lives
177
+ * under `src/main/resources/`, never `res/`, so nothing useful is dropped.
178
+ * `res/raw/` is deliberately NOT here: it holds arbitrary bundled assets that can
179
+ * be code-ish (a `.sql` schema, a `.js`), so we leave it indexed. Override any of
180
+ * these with a `.gitignore` negation (e.g. `!res/values/`).
181
+ */
182
+ const ANDROID_RES_TYPES = [
183
+ 'anim', 'animator', 'color', 'drawable', 'font', 'layout',
184
+ 'menu', 'mipmap', 'navigation', 'transition', 'values', 'xml',
185
+ ];
186
+ /** Gitignore-style patterns for the `ignore` matcher: the dirs above plus a few globs. */
187
+ const DEFAULT_IGNORE_PATTERNS = [
188
+ ...Array.from(DEFAULT_IGNORE_DIRS, (d) => `${d}/`),
189
+ '*.egg-info/', // Python packaging metadata
190
+ 'cmake-build-*/', // CLion / CMake build trees
191
+ 'bazel-*/', // Bazel output symlink trees
192
+ // Android resource dirs at any depth, with their qualifier variants (#1047).
193
+ ...ANDROID_RES_TYPES.map((t) => `**/res/${t}*/`),
194
+ ];
195
+ /** True if `buf` decodes as strict UTF-8 (no invalid byte sequences). */
196
+ function isValidUtf8(buf) {
197
+ try {
198
+ new TextDecoder('utf-8', { fatal: true }).decode(buf);
199
+ return true;
200
+ }
201
+ catch {
202
+ return false;
203
+ }
204
+ }
205
+ /**
206
+ * Read a `.gitignore` and return patterns safe to hand to the `ignore` matcher —
207
+ * never throwing, even when the file isn't real gitignore text. Two failure
208
+ * modes, both seen in the wild (issue #682):
209
+ *
210
+ * - The file isn't valid UTF-8 — e.g. transparently encrypted in place by
211
+ * corporate DLP / endpoint-security software, leaving a UTF-16 header plus
212
+ * ciphertext. None of it is meaningful patterns, so the whole file is skipped.
213
+ * - The file is text but a single line can't be compiled to a regex by the
214
+ * `ignore` library — `\\[` and friends throw "Unterminated character class".
215
+ * Crucially the throw is LAZY (at match time, not `.add()`), so it would
216
+ * otherwise escape mid-scan. That one pattern is dropped; the rest are kept.
217
+ *
218
+ * Either way a warning that NAMES the file is logged (the reporter couldn't tell
219
+ * which `.gitignore` was at fault) and indexing continues instead of aborting.
220
+ * Returns '' when there's nothing usable.
221
+ */
222
+ function readGitignorePatterns(giPath) {
223
+ let buf;
224
+ try {
225
+ buf = fs.readFileSync(giPath);
226
+ }
227
+ catch {
228
+ return ''; // unreadable (permissions / race) — treat as absent
229
+ }
230
+ // A NUL byte never appears in real gitignore text, and a fatal UTF-8 decode
231
+ // catches the rest. Such a file isn't ignore patterns at all.
232
+ if (buf.includes(0) || !isValidUtf8(buf)) {
233
+ (0, errors_1.logWarn)('Ignoring a .gitignore that is not valid UTF-8 text — it may have been encrypted ' +
234
+ 'in place by endpoint-security software. Indexing continues without it.', { file: giPath });
235
+ return '';
236
+ }
237
+ const content = buf.toString('utf-8');
238
+ // Fast path: one `.ignores()` call forces the library to compile EVERY rule,
239
+ // so if it doesn't throw, the whole file is safe to use verbatim.
240
+ try {
241
+ (0, ignore_1.default)().add(content).ignores('.codegraph-probe');
242
+ return content;
243
+ }
244
+ catch {
245
+ // Fall through: a line is uncompilable — keep the good ones, drop the bad.
246
+ }
247
+ const kept = [];
248
+ let dropped = 0;
249
+ for (const line of content.split(/\r?\n/)) {
250
+ try {
251
+ (0, ignore_1.default)().add(line).ignores('.codegraph-probe');
252
+ kept.push(line);
253
+ }
254
+ catch {
255
+ dropped++;
256
+ }
257
+ }
258
+ if (dropped > 0) {
259
+ (0, errors_1.logWarn)(`Skipped ${dropped} unparseable pattern(s) in a .gitignore; the rest are applied.`, { file: giPath });
260
+ }
261
+ return kept.join('\n');
262
+ }
263
+ /**
264
+ * An `ignore` matcher seeded with the built-in defaults, merged with the project's
265
+ * root .gitignore so a negation there (e.g. `!vendor/`) overrides a default. Shared
266
+ * by both enumeration paths so behavior is identical with or without git — and so
267
+ * the defaults apply to tracked files too (committing a dependency dir doesn't make
268
+ * it project code; the explicit `.gitignore` negation is the only opt-in).
269
+ */
270
+ function buildDefaultIgnore(rootDir) {
271
+ const ig = (0, ignore_1.default)().add(DEFAULT_IGNORE_PATTERNS);
272
+ const rootGitignore = path.join(rootDir, '.gitignore');
273
+ if (fs.existsSync(rootGitignore))
274
+ ig.add(readGitignorePatterns(rootGitignore));
275
+ return ig;
276
+ }
277
+ /**
278
+ * Defaults-only ignore matcher (no root `.gitignore` merged). Used wherever the
279
+ * parent repo's own ignore rules must NOT apply — inside embedded child repos,
280
+ * whose gitignore semantics their own `git ls-files` already enforced (#514).
281
+ */
282
+ function defaultsOnlyIgnore() {
283
+ return (0, ignore_1.default)().add(DEFAULT_IGNORE_PATTERNS);
284
+ }
285
+ /**
286
+ * Matcher for the project's `codegraph.json` `includeIgnored` patterns — the
287
+ * explicit opt-in to index embedded git repos living inside gitignored
288
+ * directories (#622, #699). Returns `null` when the project opted in nothing,
289
+ * which is the zero-config DEFAULT: `.gitignore` is then fully respected and a
290
+ * gitignored directory (even one holding nested repos) is never walked or
291
+ * indexed (#970, #976). Built once per scan/sync/scope operation from the scan
292
+ * root and threaded down — never global, so multi-project daemons stay isolated.
293
+ */
294
+ function loadIncludeIgnoredMatcher(rootDir) {
295
+ const patterns = (0, project_config_1.loadIncludeIgnoredPatterns)(rootDir);
296
+ return patterns.length > 0 ? (0, ignore_1.default)().add(patterns) : null;
297
+ }
298
+ /**
299
+ * Matcher for the project's `codegraph.json` `exclude` patterns — paths to keep
300
+ * OUT of the index even when git-tracked, which `.gitignore` cannot do (#999).
301
+ * The escape hatch for a committed vendor/theme/SDK directory. Returns `null`
302
+ * when nothing is excluded (the zero-config default → no overhead). Matched
303
+ * against project-root-relative paths, so it applies uniformly across the whole
304
+ * workspace, including inside embedded repos (excluding `static/` means gone
305
+ * everywhere). Built once per scan/sync/scope operation from the scan root.
306
+ */
307
+ function loadExcludeMatcher(rootDir) {
308
+ const patterns = (0, project_config_1.loadExcludePatterns)(rootDir);
309
+ return patterns.length > 0 ? (0, ignore_1.default)().add(patterns) : null;
310
+ }
311
+ /**
312
+ * Matcher for the project's `codegraph.json` `include` patterns — first-party
313
+ * source to force INTO the index even when `.gitignore` drops it (the general
314
+ * whitelist `includeIgnored` never was — that one only revives *embedded git
315
+ * repos*). The case it exists for: a project under a second VCS (SVN/Perforce)
316
+ * `.gitignore`s its own real source so it stays out of Git, yet we still want it
317
+ * indexed. Returns `null` when nothing is force-included (the zero-config
318
+ * default → no overhead, no extra walk). Built once per scan/sync/scope
319
+ * operation from the scan root.
320
+ */
321
+ function loadIncludeMatcher(rootDir) {
322
+ const patterns = (0, project_config_1.loadIncludePatterns)(rootDir);
323
+ return patterns.length > 0 ? (0, ignore_1.default)().add(patterns) : null;
324
+ }
325
+ /** Glob metacharacters that end the static (literal) prefix of an `include` pattern. */
326
+ const GLOB_META = /[*?[\]{}!]/;
327
+ /**
328
+ * The static directory prefix of each `include` pattern — the literal leading
329
+ * path up to the first glob segment — trailing-slashed, used to (a) walk only
330
+ * the opted-in subtrees in `collectIncludedFiles` and (b) let `ScopeIgnore` keep
331
+ * the watcher descending toward them. `Tools/` stays `Tools/`; a recursive
332
+ * `Tools/**` glob yields `Tools/`; `src/local/file.ts` yields `src/local/` (the
333
+ * file's dir); a pattern that starts with a glob (like a leading `**`) yields
334
+ * `''`, meaning "no static root — walk the whole tree". Duplicates and roots
335
+ * nested under a broader root are collapsed so each subtree is walked once.
336
+ */
337
+ function includeStaticRoots(patterns) {
338
+ const roots = new Set();
339
+ for (const pattern of patterns) {
340
+ let p = pattern.replace(/^\/+/, '');
341
+ const trailingSlash = p.endsWith('/');
342
+ if (trailingSlash)
343
+ p = p.slice(0, -1);
344
+ const segs = p.split('/').filter(Boolean);
345
+ const lead = [];
346
+ for (const s of segs) {
347
+ if (GLOB_META.test(s))
348
+ break;
349
+ lead.push(s);
350
+ }
351
+ const hadWildcard = lead.length < segs.length;
352
+ // A wholly-literal pattern with no trailing slash names a file (or a dir we
353
+ // can't tell apart) — drop its last segment so we walk the containing dir
354
+ // and let the matcher pick the file. A trailing slash or a glob means the
355
+ // remaining `lead` is already the directory to walk.
356
+ if (!hadWildcard && !trailingSlash && lead.length > 0)
357
+ lead.pop();
358
+ if (lead.length === 0) {
359
+ roots.clear();
360
+ roots.add('');
361
+ return ['']; // a top-level glob forces a whole-tree walk; nothing narrower matters
362
+ }
363
+ roots.add(lead.join('/') + '/');
364
+ }
365
+ // Collapse roots nested under a broader one (e.g. drop `a/b/` if `a/` is present).
366
+ const all = [...roots];
367
+ return all.filter((r) => !all.some((other) => other !== r && r.startsWith(other)));
368
+ }
369
+ /**
370
+ * Actively discover the source files an `include` whitelist forces in. `git
371
+ * ls-files` never lists gitignored files, so a filtered filesystem walk of just
372
+ * the opted-in subtrees (`includeStaticRoots`) is the only way to find them.
373
+ * Returns project-root-relative, normalized source-file paths.
374
+ *
375
+ * A file is collected when it MATCHES `include`, is NOT hit by `exclude` (an
376
+ * explicit exclude always wins), is a recognized source file, and does not live
377
+ * under a built-in default-ignored dir (`node_modules`, `dist`, …), `.git`, or
378
+ * CodeGraph's data dir — those are never resurfaced, mirroring `ScopeIgnore`.
379
+ * `.gitignore` is deliberately NOT consulted: overriding it is the whole point.
380
+ */
381
+ function collectIncludedFiles(rootDir, include, exclude, roots, overrides) {
382
+ const out = new Set();
383
+ const defaults = defaultsOnlyIgnore();
384
+ const visited = new Set();
385
+ const consider = (abs, rel, isDir) => {
386
+ if (isDir) {
387
+ if (defaults.ignores(rel + '/'))
388
+ return; // never node_modules/dist/… via include
389
+ // An explicit `exclude` always wins over `include`; prune the whole subtree
390
+ // here so a large excluded dir (a committed frontend's own vendored deps,
391
+ // build output, …) is never walked — the per-file guard below still catches
392
+ // anything a directory pattern doesn't, so this is a pure efficiency win.
393
+ if (exclude && exclude.ignores(rel + '/'))
394
+ return;
395
+ walk(abs);
396
+ }
397
+ else {
398
+ if (defaults.ignores(rel))
399
+ return;
400
+ if (!include.ignores(rel))
401
+ return;
402
+ if (exclude && exclude.ignores(rel))
403
+ return;
404
+ if (!(0, grammars_1.isSourceFile)(rel, overrides))
405
+ return;
406
+ out.add(rel);
407
+ }
408
+ };
409
+ function walk(absDir) {
410
+ let realDir;
411
+ try {
412
+ realDir = fs.realpathSync(absDir);
413
+ }
414
+ catch {
415
+ return;
416
+ }
417
+ if (visited.has(realDir))
418
+ return; // symlink-cycle guard
419
+ visited.add(realDir);
420
+ let entries;
421
+ try {
422
+ entries = fs.readdirSync(absDir, { withFileTypes: true });
423
+ }
424
+ catch {
425
+ return;
426
+ }
427
+ for (const entry of entries) {
428
+ if (entry.name === '.git' || (0, directory_1.isCodeGraphDataDir)(entry.name))
429
+ continue;
430
+ const abs = path.join(absDir, entry.name);
431
+ const rel = (0, utils_1.normalizePath)(path.relative(rootDir, abs));
432
+ if (!rel || rel.startsWith('..'))
433
+ continue;
434
+ if (entry.isSymbolicLink()) {
435
+ try {
436
+ const st = fs.statSync(fs.realpathSync(abs));
437
+ consider(abs, rel, st.isDirectory());
438
+ }
439
+ catch {
440
+ // broken symlink — skip
441
+ }
442
+ continue;
443
+ }
444
+ consider(abs, rel, entry.isDirectory());
445
+ }
446
+ }
447
+ for (const root of roots) {
448
+ walk(root === '' ? rootDir : path.join(rootDir, root));
449
+ }
450
+ return out;
451
+ }
452
+ /**
453
+ * The included source files (`codegraph.json` `include`) for a scan root, or an
454
+ * empty set when nothing is force-included. Centralizes loading the matcher,
455
+ * roots, exclude, and overrides so both enumeration paths (git and filesystem
456
+ * walk) add the same files.
457
+ */
458
+ function collectIncludedFilesForRoot(rootDir) {
459
+ const include = loadIncludeMatcher(rootDir);
460
+ if (!include)
461
+ return new Set();
462
+ const roots = includeStaticRoots((0, project_config_1.loadIncludePatterns)(rootDir));
463
+ return collectIncludedFiles(rootDir, include, loadExcludeMatcher(rootDir), roots, (0, project_config_1.loadExtensionOverrides)(rootDir));
464
+ }
465
+ /**
466
+ * `git ls-files --directory` collapses a wholly-untracked/ignored directory into
467
+ * one entry — and when the command's own cwd is such a directory (the indexed
468
+ * root is itself a git-ignored subdir of an enclosing repo), git emits the
469
+ * literal `./` meaning "this entire directory". That sentinel is not a real
470
+ * nested path: feeding it to the `ignore` matcher throws ("path should be a
471
+ * `path.relative()`d string, but got "./""), which used to abort `buildScopeIgnore`
472
+ * and so break the MCP daemon's watcher/auto-sync on connect; and joining it back
473
+ * onto `repoDir` would just re-point at the cwd. Drop it wherever we consume
474
+ * `--directory` output. (#936)
475
+ */
476
+ function isWholeCwdEntry(entry) {
477
+ return entry === './' || entry === '.' || entry === '';
478
+ }
479
+ /**
480
+ * List the gitignored DIRECTORIES of a repo (collapsed, trailing-slash form),
481
+ * relative to `repoDir`. These are invisible to every other `git ls-files` /
482
+ * `git status` mode — and in a multi-repo workspace they are exactly where the
483
+ * nested project repos live (a super-repo `.gitignore`s its child repos to keep
484
+ * `git status` quiet; that does not make them third-party code). (#514)
485
+ */
486
+ function listIgnoredDirs(repoDir) {
487
+ try {
488
+ const out = (0, child_process_1.execFileSync)('git', ['ls-files', '-z', '-o', '-i', '--exclude-standard', '--directory'], { cwd: repoDir, encoding: 'utf-8', timeout: 30000, maxBuffer: 50 * 1024 * 1024, stdio: ['pipe', 'pipe', 'pipe'], windowsHide: true });
489
+ return out.split('\0').filter((e) => e.endsWith('/') && !isWholeCwdEntry(e));
490
+ }
491
+ catch {
492
+ return [];
493
+ }
494
+ }
495
+ /** Max directory depth searched below an ignored dir for nested `.git` roots. */
496
+ const EMBEDDED_REPO_SEARCH_DEPTH = 4;
497
+ /** Max directories examined per search — a huge ignored data dir must never stall a scan/sync. */
498
+ const EMBEDDED_REPO_SEARCH_ENTRIES = 2000;
499
+ /**
500
+ * Classify a directory's `.git` entry for embedded-repo discovery.
501
+ *
502
+ * - A `.git` **directory** is an embedded clone — distinct first-party code a
503
+ * super-repo merely hides from git; index it (#193, #514).
504
+ * - A `.git` **file** is a pointer (`gitdir: …`). A git **worktree** points into
505
+ * the host repo's own `.git/worktrees/<name>`, so it is a second working view
506
+ * of a repo CodeGraph already indexes — indexing it just duplicates the whole
507
+ * graph N times; skip it (#848). A **submodule worktree** points into
508
+ * `.git/modules/<module>/worktrees/<name>` — same duplication, so skip it too
509
+ * (#945). A **submodule** checkout points into `.git/modules/<module>` (no
510
+ * `worktrees/` segment) and is distinct code, so index it as before.
511
+ *
512
+ * Returns `'none'` when there is no `.git` entry here.
513
+ */
514
+ function classifyGitDir(absDir) {
515
+ let st;
516
+ try {
517
+ st = fs.statSync(path.join(absDir, '.git'));
518
+ }
519
+ catch {
520
+ return 'none';
521
+ }
522
+ if (st.isDirectory())
523
+ return 'embedded';
524
+ if (!st.isFile())
525
+ return 'none';
526
+ try {
527
+ const gitdir = fs.readFileSync(path.join(absDir, '.git'), 'utf8').match(/^gitdir:\s*(.+)$/m)?.[1]?.trim();
528
+ // A worktree's gitdir lives under some repo's `.git/worktrees/<name>` —
529
+ // either the top-level repo's (`.git/worktrees/`) or, for a worktree of a
530
+ // submodule, that submodule's gitdir (`.git/modules/<module>/worktrees/`).
531
+ // The optional `modules/<module>` segment covers the submodule case (#945).
532
+ // Match both separators so a Windows-style pointer is recognized too.
533
+ if (gitdir && /(^|[\\/])\.git[\\/](modules[\\/][^\\/]+[\\/])?worktrees[\\/]/.test(gitdir))
534
+ return 'worktree';
535
+ }
536
+ catch {
537
+ // Unreadable `.git` pointer — fall back to the prior "index it" behavior.
538
+ }
539
+ return 'embedded';
540
+ }
541
+ /**
542
+ * Find git repositories nested under `absDir` (inclusive), shallow bounded BFS.
543
+ * Stops descending at each repo root found — contents belong to that repo's own
544
+ * enumeration. Skips default-ignored dirs (`node_modules` can contain `.git`
545
+ * from npm git-dependencies — that never makes it project code) and CodeGraph
546
+ * data dirs. Depth- and entry-capped so a huge ignored tree can't stall the scan.
547
+ */
548
+ function findNestedGitRepos(absDir, relPrefix) {
549
+ const found = [];
550
+ const defaults = defaultsOnlyIgnore();
551
+ const queue = [
552
+ { abs: absDir, rel: relPrefix, depth: 0 },
553
+ ];
554
+ let examined = 0;
555
+ while (queue.length > 0) {
556
+ const { abs, rel, depth } = queue.shift();
557
+ if (++examined > EMBEDDED_REPO_SEARCH_ENTRIES) {
558
+ (0, errors_1.logDebug)('Embedded-repo search entry cap hit — deeper repos (if any) not discovered', { under: relPrefix });
559
+ break;
560
+ }
561
+ const cls = classifyGitDir(abs);
562
+ if (cls === 'worktree') {
563
+ continue; // a git worktree duplicates an already-indexed repo (#848) — skip
564
+ }
565
+ if (cls === 'embedded') {
566
+ found.push(rel);
567
+ continue; // its own git handles everything below
568
+ }
569
+ if (depth >= EMBEDDED_REPO_SEARCH_DEPTH)
570
+ continue;
571
+ let entries;
572
+ try {
573
+ entries = fs.readdirSync(abs, { withFileTypes: true });
574
+ }
575
+ catch {
576
+ continue;
577
+ }
578
+ for (const entry of entries) {
579
+ if (!entry.isDirectory())
580
+ continue;
581
+ if (entry.name === '.git' || (0, directory_1.isCodeGraphDataDir)(entry.name))
582
+ continue;
583
+ const childRel = rel + entry.name + '/';
584
+ if (defaults.ignores(childRel))
585
+ continue;
586
+ queue.push({ abs: path.join(abs, entry.name), rel: childRel, depth: depth + 1 });
587
+ }
588
+ }
589
+ return found;
590
+ }
591
+ /**
592
+ * Workspace-scope ignore matcher. Ordinary paths get the root's matcher
593
+ * (built-in defaults + root `.gitignore`); paths inside an EMBEDDED repo get
594
+ * that repo's own matcher (defaults + its root `.gitignore`) — the parent's
595
+ * `.gitignore` hides a child repo from git, not from the index (#514). A
596
+ * directory path (trailing slash) that is an ANCESTOR of an embedded root is
597
+ * never ignored, so directory-pruning callers (the Linux per-directory
598
+ * watcher) still descend to reach the embedded repos.
599
+ *
600
+ * Single source of truth for indexer and watcher scope — they must not diverge.
601
+ */
602
+ class ScopeIgnore {
603
+ rootMatcher;
604
+ exclude;
605
+ include;
606
+ includeRoots;
607
+ embedded;
608
+ defaults = defaultsOnlyIgnore();
609
+ constructor(rootMatcher, embedded,
610
+ /**
611
+ * Project `codegraph.json` `exclude` patterns (#999), matched against the
612
+ * full root-relative path. Wins over everything else — an explicit user
613
+ * exclude applies even to tracked files and even inside embedded repos.
614
+ */
615
+ exclude = null,
616
+ /**
617
+ * Project `codegraph.json` `include` patterns — first-party source forced
618
+ * INTO the index despite `.gitignore`. When a path matches, it is NOT
619
+ * ignored (so the watcher watches it), overriding `.gitignore`/`rootMatcher`
620
+ * — but never `exclude` (checked first) and never a built-in default-ignored
621
+ * dir. `includeRoots` are the static prefixes so a gitignored ANCESTOR
622
+ * directory of an included subtree still isn't pruned by the directory
623
+ * walker/watcher.
624
+ */
625
+ include = null, includeRoots = []) {
626
+ this.rootMatcher = rootMatcher;
627
+ this.exclude = exclude;
628
+ this.include = include;
629
+ this.includeRoots = includeRoots;
630
+ // Longest root first so paths in nested embedded repos hit the innermost matcher.
631
+ this.embedded = [...embedded].sort((a, b) => b.root.length - a.root.length);
632
+ }
633
+ ignores(rel) {
634
+ // User `exclude` (#999) is checked first and against the full root-relative
635
+ // path: it must drop git-TRACKED paths (which `.gitignore` can't) and apply
636
+ // everywhere, including ancestors of embedded repos.
637
+ if (this.exclude && this.exclude.ignores(rel))
638
+ return true;
639
+ // User `include`: force first-party source in despite `.gitignore`. Never
640
+ // resurfaces a built-in default-ignored dir (node_modules/dist/…), so an
641
+ // include pattern can't accidentally pull in dependency/build trees.
642
+ if (this.include && !this.defaults.ignores(rel)) {
643
+ if (rel.endsWith('/')) {
644
+ // A directory on (or leading to) an included subtree must stay walkable
645
+ // so the watcher/walker descends to reach the forced-in files.
646
+ if (this.includeRoots.some((r) => r.startsWith(rel) || rel.startsWith(r)))
647
+ return false;
648
+ }
649
+ else if (this.include.ignores(rel)) {
650
+ return false;
651
+ }
652
+ }
653
+ for (const { root, matcher } of this.embedded) {
654
+ if (rel.startsWith(root)) {
655
+ const inner = rel.slice(root.length);
656
+ if (inner === '')
657
+ return false;
658
+ // Built-in defaults apply to the FULL path uniformly (#407) — an
659
+ // embedded repo inside node_modules (an npm git-dependency) must stay
660
+ // excluded even though its own rules wouldn't ignore its files.
661
+ return this.defaults.ignores(rel) || matcher.ignores(inner);
662
+ }
663
+ }
664
+ // Never prune a directory that leads to an embedded repo.
665
+ if (rel.endsWith('/') && this.embedded.some(({ root }) => root.startsWith(rel))) {
666
+ return false;
667
+ }
668
+ return this.rootMatcher.ignores(rel);
669
+ }
670
+ }
671
+ exports.ScopeIgnore = ScopeIgnore;
672
+ /**
673
+ * Build the workspace-scope matcher. When the caller already knows the
674
+ * embedded roots (the scanner discovers them during collection), pass them to
675
+ * skip rediscovery; otherwise they're discovered here (the watcher path).
676
+ */
677
+ function buildScopeIgnore(rootDir, embeddedRoots) {
678
+ const roots = embeddedRoots ? [...embeddedRoots] : discoverEmbeddedRepoRoots(rootDir);
679
+ const include = loadIncludeMatcher(rootDir);
680
+ return new ScopeIgnore(buildDefaultIgnore(rootDir), roots.map((root) => ({ root, matcher: buildDefaultIgnore(path.join(rootDir, root)) })), loadExcludeMatcher(rootDir), include, include ? includeStaticRoots((0, project_config_1.loadIncludePatterns)(rootDir)) : []);
681
+ }
682
+ /**
683
+ * Whether an embedded repo found as a tracked gitlink (mode 160000, #1031/#1033)
684
+ * must be SKIPPED rather than indexed. A gitlink is tracked, so `.gitignore`
685
+ * can't untrack it — but the discovery passes for it must still honor the same
686
+ * scope rules as every other path, or a gitignored reference/data dir full of
687
+ * `git add`ed clones gets pulled into the index against the user's stated intent
688
+ * (#1065). Two reasons to skip:
689
+ * 1. It sits in a built-in default-ignored location — an npm git-dependency
690
+ * under `node_modules` is never project code; not even an explicit opt-in
691
+ * revives it (matches `findIgnoredEmbeddedRepos`).
692
+ * 2. The parent repo's own `.gitignore` covers its path and the project did
693
+ * NOT opt that path in via `codegraph.json` `includeIgnored`. The gitignore
694
+ * rule is the user's stated intent to keep that path out of scope, exactly
695
+ * as for an UNtracked embedded repo — respect it by default, opt back in
696
+ * with `includeIgnored` (#514, #970, #976).
697
+ * `relDir` is repoDir-relative (trailing-slashed); `prefix` is repoDir's
698
+ * scan-root-relative path so the `includeIgnored` pattern is matched on the full
699
+ * scan-root-relative path. `defaults` is `defaultsOnlyIgnore()` and `repoIgnore`
700
+ * is `buildDefaultIgnore(repoDir)` (defaults + the repo's own `.gitignore`),
701
+ * both passed in so they're built once per repo level rather than per gitlink.
702
+ */
703
+ function gitlinkEmbeddedRepoSkipped(relDir, prefix, defaults, repoIgnore, includeIgnored) {
704
+ if (defaults.ignores(relDir))
705
+ return true; // default-ignored — never index, opt-in can't revive
706
+ if (!repoIgnore.ignores(relDir))
707
+ return false; // not ignored at all — index as before (#1031/#1033)
708
+ // Gitignored by the repo's own rules — skip unless the project opted it in.
709
+ return !includeIgnored?.ignores((0, utils_1.normalizePath)(prefix + relDir));
710
+ }
711
+ /**
712
+ * Standalone discovery of every embedded repo root under `rootDir` (relative,
713
+ * trailing-slashed) — the untracked kind (#193) always, and the gitignored kind
714
+ * (#514) only for directories the project opted in via `codegraph.json`
715
+ * `includeIgnored` (#622, #699); otherwise `.gitignore` is respected and they
716
+ * are not discovered (#970, #976). Recursive (an embedded repo can embed further
717
+ * repos). Returns [] for non-git roots: the filesystem walk handles nested repos
718
+ * there already.
719
+ */
720
+ function discoverEmbeddedRepoRoots(rootDir) {
721
+ try {
722
+ (0, child_process_1.execFileSync)('git', ['rev-parse', '--git-dir'], { cwd: rootDir, encoding: 'utf-8', timeout: 5000, stdio: ['pipe', 'pipe', 'pipe'], windowsHide: true });
723
+ }
724
+ catch {
725
+ return [];
726
+ }
727
+ const out = [];
728
+ const defaults = defaultsOnlyIgnore();
729
+ const includeIgnored = loadIncludeIgnoredMatcher(rootDir);
730
+ const visit = (repoAbs, prefix) => {
731
+ const candidates = [];
732
+ try {
733
+ const o = (0, child_process_1.execFileSync)('git', ['ls-files', '-z', '-o', '--exclude-standard', '--directory'], { cwd: repoAbs, encoding: 'utf-8', timeout: 30000, maxBuffer: 50 * 1024 * 1024, stdio: ['pipe', 'pipe', 'pipe'], windowsHide: true });
734
+ for (const e of o.split('\0')) {
735
+ if (e.endsWith('/') && !isWholeCwdEntry(e) && !defaults.ignores(e)) {
736
+ candidates.push(...findNestedGitRepos(path.join(repoAbs, e), e));
737
+ }
738
+ }
739
+ }
740
+ catch { /* untracked listing failed — ignored-side discovery still runs */ }
741
+ // Unexpanded gitlinks (mode 160000) with a real checkout on disk — embedded
742
+ // repos `git add`ed without `.gitmodules`, or submodules not active here. The
743
+ // untracked listing above can't see them (they're tracked), so find them the
744
+ // same way collectGitFiles does, keeping watcher scope == indexer scope.
745
+ // (#1031, #1033)
746
+ try {
747
+ const staged = (0, child_process_1.execFileSync)('git', ['ls-files', '-z', '-s', '--recurse-submodules'], { cwd: repoAbs, encoding: 'utf-8', timeout: 30000, maxBuffer: 50 * 1024 * 1024, stdio: ['pipe', 'pipe', 'pipe'], windowsHide: true });
748
+ const repoIgnore = buildDefaultIgnore(repoAbs);
749
+ for (const entry of staged.split('\0')) {
750
+ if (!entry || entry.slice(0, 6) !== '160000')
751
+ continue;
752
+ const tab = entry.indexOf('\t');
753
+ if (tab === -1)
754
+ continue;
755
+ const rel = entry.slice(tab + 1);
756
+ const relDir = rel.endsWith('/') ? rel : rel + '/';
757
+ // A gitlink under a gitignored path is respected (not indexed) unless the
758
+ // project opted it in — same rule as the untracked-ignored kind (#1065).
759
+ if (gitlinkEmbeddedRepoSkipped(relDir, prefix, defaults, repoIgnore, includeIgnored))
760
+ continue;
761
+ if (classifyGitDir(path.join(repoAbs, rel)) === 'embedded')
762
+ candidates.push(relDir);
763
+ }
764
+ }
765
+ catch { /* staged listing failed — other discovery still runs */ }
766
+ candidates.push(...findIgnoredEmbeddedRepos(repoAbs, includeIgnored, prefix));
767
+ for (const rel of candidates) {
768
+ const full = (0, utils_1.normalizePath)(prefix + rel);
769
+ out.push(full);
770
+ visit(path.join(repoAbs, rel), full);
771
+ }
772
+ };
773
+ visit(rootDir, '');
774
+ return out;
775
+ }
776
+ /**
777
+ * Cap on how many skipped gitignored repos the CLI hint enumerates — a huge
778
+ * gitignored data dir full of clones must never turn the hint scan into a long
779
+ * walk. Enough to make the point; the caller says "+N more" past this.
780
+ */
781
+ const UNINDEXED_IGNORED_REPO_HINT_CAP = 100;
782
+ /**
783
+ * The INVERSE of the gitignored side of {@link discoverEmbeddedRepoRoots}:
784
+ * nested git repositories under a gitignored directory that the project has NOT
785
+ * opted into via `codegraph.json` `includeIgnored`. These are real repos the
786
+ * default `init`/`index` deliberately skips because `.gitignore` excludes them
787
+ * (#970, #976) — most visibly the "super-repo `.gitignore`s its child repos"
788
+ * layout (#1156), where `init` at the parent correctly indexes ~nothing while
789
+ * `init` inside each child works. The CLI uses this to turn that silent empty
790
+ * index into an actionable hint: it names the skipped repos and offers to opt
791
+ * them in. Paths are `rootDir`-relative and trailing-slashed (valid
792
+ * `includeIgnored` patterns as-is). Returns `[]` for a non-git root (a
793
+ * filesystem walk already descends into nested repos there), skips built-in
794
+ * default-ignored dirs (`node_modules`, …), and is bounded so it never stalls
795
+ * on a giant ignored tree.
796
+ */
797
+ function findUnindexedIgnoredRepos(rootDir) {
798
+ try {
799
+ (0, child_process_1.execFileSync)('git', ['rev-parse', '--git-dir'], { cwd: rootDir, encoding: 'utf-8', timeout: 5000, stdio: ['pipe', 'pipe', 'pipe'], windowsHide: true });
800
+ }
801
+ catch {
802
+ return [];
803
+ }
804
+ const defaults = defaultsOnlyIgnore();
805
+ const includeIgnored = loadIncludeIgnoredMatcher(rootDir);
806
+ const repos = [];
807
+ for (const dir of listIgnoredDirs(rootDir)) {
808
+ if (defaults.ignores(dir))
809
+ continue; // node_modules etc. — never project code
810
+ if (includeIgnored?.ignores((0, utils_1.normalizePath)(dir)))
811
+ continue; // already opted in — nothing to nag about
812
+ for (const repo of findNestedGitRepos(path.join(rootDir, dir), dir)) {
813
+ // Per-repo opt-in check, mirroring findIgnoredEmbeddedRepos: a child
814
+ // pattern (`repos/a/`) doesn't match the parent dir above but DOES
815
+ // cover this repo — it's indexed, so don't nag about it (#1295).
816
+ if (includeIgnored?.ignores((0, utils_1.normalizePath)(repo)))
817
+ continue;
818
+ repos.push(repo);
819
+ if (repos.length >= UNINDEXED_IGNORED_REPO_HINT_CAP)
820
+ return repos;
821
+ }
822
+ }
823
+ return repos;
824
+ }
825
+ /**
826
+ * Discover embedded repos hidden by `repoDir`'s OWN gitignore rules: for each
827
+ * gitignored directory, search for nested `.git` roots. Returns repo paths
828
+ * relative to `repoDir`, trailing-slashed.
829
+ *
830
+ * OPT-IN ONLY. Walking into a gitignored directory contradicts what every other
831
+ * tool (and CodeGraph's own `git ls-files` foundation) does — `.gitignore`
832
+ * excludes. So this returns `[]` unless the project opted the directory in via
833
+ * `codegraph.json` `includeIgnored`; without that, a gitignored dir — including
834
+ * a huge reference/data dir full of nested clones — is left untouched (#970,
835
+ * #976). When opted in, it restores the super-repo-of-clones behavior (#622,
836
+ * #699). `prefix` is the scan-root-relative path of `repoDir`, so a pattern like
837
+ * `services/` opts that whole subtree in at any recursion depth. Built-in
838
+ * default excludes (`node_modules`, …) are always skipped.
839
+ */
840
+ function findIgnoredEmbeddedRepos(repoDir, includeIgnored, prefix) {
841
+ if (!includeIgnored)
842
+ return [];
843
+ const defaults = defaultsOnlyIgnore();
844
+ const repos = [];
845
+ for (const dir of listIgnoredDirs(repoDir)) {
846
+ if (defaults.ignores(dir))
847
+ continue;
848
+ const nested = findNestedGitRepos(path.join(repoDir, dir), dir);
849
+ if (includeIgnored.ignores((0, utils_1.normalizePath)(prefix + dir))) {
850
+ // The whole ignored dir is opted in — every nested repo under it counts.
851
+ repos.push(...nested);
852
+ }
853
+ else {
854
+ // A single gitignore rule often covers the PARENT of the opted-in
855
+ // repos: `.gitignore: /repos/` lists `repos/` as ONE ignored entry,
856
+ // while `includeIgnored: ["repos/a/"]` (the CLI hint's own suggested
857
+ // spelling) names the child — which never matches the parent path, so
858
+ // the opt-in silently did nothing (#1295). Match each nested repo
859
+ // root individually so both spellings work. The walk is bounded
860
+ // (depth/entry caps in findNestedGitRepos) and only runs when
861
+ // includeIgnored is configured at all.
862
+ repos.push(...nested.filter((r) => includeIgnored.ignores((0, utils_1.normalizePath)(prefix + r))));
863
+ }
864
+ }
865
+ return repos;
866
+ }
867
+ /**
868
+ * Collect git-visible files (tracked + untracked, .gitignore-respected) from the
869
+ * git repository rooted at `repoDir`, adding each to `files` with `prefix`
870
+ * prepended so paths stay relative to the original scan root.
871
+ *
872
+ * Recurses into embedded git repositories — nested repos that are NOT submodules
873
+ * (independent clones living inside the workspace, common in CMake "super-repo"
874
+ * layouts). The parent repo's `git ls-files` cannot see into them: tracked output
875
+ * skips them entirely, and untracked output reports them only as an opaque
876
+ * "subdir/" entry (trailing slash) rather than expanding their files. Each
877
+ * embedded repo is its own git boundary, so we re-run `git ls-files` inside it.
878
+ * (See issue #193.) GITIGNORED embedded repos are invisible even to that; they
879
+ * are discovered separately via `findIgnoredEmbeddedRepos` (#514) but ONLY for
880
+ * directories the project opted in through `codegraph.json` `includeIgnored`
881
+ * (`includeIgnored` here, threaded from the scan root) — by default `.gitignore`
882
+ * is respected and they stay out (#970, #976). Every embedded repo root (however
883
+ * found) is recorded in `embeddedRoots` so callers can exempt its files from the
884
+ * parent's own gitignore rules.
885
+ */
886
+ function collectGitFiles(repoDir, prefix, files, embeddedRoots, includeIgnored = null) {
887
+ const gitOpts = { cwd: repoDir, encoding: 'utf-8', timeout: 30000, maxBuffer: 50 * 1024 * 1024, stdio: ['pipe', 'pipe', 'pipe'], windowsHide: true };
888
+ // Tracked files. --recurse-submodules pulls in files from active submodules,
889
+ // which the index would otherwise represent only as a commit pointer.
890
+ // Without this, monorepos using submodules index 0 files. (See issue #147.)
891
+ // Note: --recurse-submodules only supports -c/--cached and --stage modes — it
892
+ // can't be combined with -o, so untracked files are gathered separately below.
893
+ //
894
+ // We use --stage (-s) rather than -c so each entry carries its file mode. That
895
+ // lets us spot gitlink entries (mode 160000) that --recurse-submodules did NOT
896
+ // expand: a nested repo `git add`ed without a `.gitmodules` entry, or a
897
+ // submodule that isn't active/initialized in this checkout. Such a gitlink
898
+ // falls through every pass — it's tracked, so the untracked `-o` listing below
899
+ // never reports it, and --recurse-submodules only expands ACTIVE submodules —
900
+ // so its source would be silently skipped, leaving only the super-repo's own
901
+ // files indexed. We collect those gitlinks here and recurse into them below.
902
+ // (An active submodule is expanded inline by --recurse-submodules and so never
903
+ // surfaces as a 160000 entry — only the unhandled gitlinks do.) (#1031, #1033)
904
+ //
905
+ // -z gives NUL-separated, unquoted output so non-ASCII (e.g. CJK) paths
906
+ // survive verbatim. Without it git octal-escapes and double-quotes such paths
907
+ // (the core.quotepath default), and the quoted form never matches a real file
908
+ // on disk → those files are silently dropped from the index. (#541) With -s the
909
+ // path follows a TAB after the `<mode> <object> <stage>` prefix.
910
+ const gitlinkRels = [];
911
+ const tracked = (0, child_process_1.execFileSync)('git', ['ls-files', '-z', '-s', '--recurse-submodules'], gitOpts);
912
+ for (const entry of tracked.split('\0')) {
913
+ if (!entry)
914
+ continue;
915
+ const tab = entry.indexOf('\t');
916
+ if (tab === -1)
917
+ continue; // --stage always emits "<mode> <object> <stage>\t<path>"
918
+ const rel = entry.slice(tab + 1);
919
+ if (entry.slice(0, 6) === '160000') {
920
+ gitlinkRels.push(rel); // an unexpanded gitlink — recursed into below, not a source file itself
921
+ continue;
922
+ }
923
+ files.add((0, utils_1.normalizePath)(prefix + rel));
924
+ }
925
+ // Untracked files (submodules manage their own untracked state). Embedded git
926
+ // repos surface here as a single "subdir/" entry that git refuses to descend
927
+ // into — recurse into those as their own repos so their source gets indexed.
928
+ const untracked = (0, child_process_1.execFileSync)('git', ['ls-files', '-z', '-o', '--exclude-standard'], gitOpts);
929
+ for (const rel of untracked.split('\0')) {
930
+ if (!rel)
931
+ continue;
932
+ if (rel.endsWith('/')) {
933
+ // git only emits a trailing-slash directory entry for an embedded repo.
934
+ // Guard with a .git check anyway, and skip anything else exactly as git
935
+ // itself skips it (we never descend into a non-repo opaque dir). Never
936
+ // descend into default-ignored locations — an embedded repo inside
937
+ // node_modules is an npm git-dependency, not project code.
938
+ const childDir = path.join(repoDir, rel);
939
+ // A git worktree surfaces here as an opaque untracked dir too — skip it,
940
+ // it's a duplicate working view of an already-indexed repo (#848).
941
+ if (classifyGitDir(childDir) === 'embedded' && !defaultsOnlyIgnore().ignores(rel)) {
942
+ embeddedRoots?.add((0, utils_1.normalizePath)(prefix + rel));
943
+ collectGitFiles(childDir, prefix + rel, files, embeddedRoots, includeIgnored);
944
+ }
945
+ continue;
946
+ }
947
+ files.add((0, utils_1.normalizePath)(prefix + rel));
948
+ }
949
+ // Gitlink entries (mode 160000) that --recurse-submodules left unexpanded —
950
+ // an embedded repo `git add`ed without `.gitmodules`, or a submodule not
951
+ // active/initialized in this checkout. When such a gitlink has a real working
952
+ // tree on disk it is distinct first-party code we must index as its own
953
+ // embedded repo: the tracked pass skipped its contents and the untracked pass
954
+ // never sees it (it's tracked, not "other"). A gitlink with no checkout on disk
955
+ // (an uninitialized submodule — empty dir, no `.git`) has nothing to index and
956
+ // is left alone, as is a submodule worktree (a duplicate view, #945). (#1031, #1033)
957
+ if (gitlinkRels.length > 0) {
958
+ const defaults = defaultsOnlyIgnore();
959
+ const repoIgnore = buildDefaultIgnore(repoDir);
960
+ for (const rel of gitlinkRels) {
961
+ const relDir = rel.endsWith('/') ? rel : rel + '/';
962
+ // A gitlink under a gitignored path is respected (not indexed) unless the
963
+ // project opted it in via `includeIgnored` — keep tracked gitlinks under
964
+ // the same scope rule as the untracked-ignored kind below (#1065).
965
+ if (gitlinkEmbeddedRepoSkipped(relDir, prefix, defaults, repoIgnore, includeIgnored))
966
+ continue;
967
+ const childDir = path.join(repoDir, rel);
968
+ // 'embedded' = a real .git checkout on disk; 'worktree' and 'none' are skipped.
969
+ if (classifyGitDir(childDir) !== 'embedded')
970
+ continue;
971
+ embeddedRoots?.add((0, utils_1.normalizePath)(prefix + relDir));
972
+ collectGitFiles(childDir, prefix + relDir, files, embeddedRoots, includeIgnored);
973
+ }
974
+ }
975
+ // Embedded repos hidden by THIS repo's ignore rules (`/packages/` in a
976
+ // super-repo .gitignore) never appear in any listing above. By default they
977
+ // stay hidden — `.gitignore` is respected (#970, #976). They are recursed into
978
+ // only when the project opted the directory in via `codegraph.json`
979
+ // `includeIgnored` (#622, #699), which `findIgnoredEmbeddedRepos` enforces.
980
+ for (const rel of findIgnoredEmbeddedRepos(repoDir, includeIgnored, prefix)) {
981
+ embeddedRoots?.add((0, utils_1.normalizePath)(prefix + rel));
982
+ collectGitFiles(path.join(repoDir, rel), prefix + rel, files, embeddedRoots, includeIgnored);
983
+ }
984
+ }
985
+ /**
986
+ * Get all files visible to git (tracked + untracked but not ignored).
987
+ * Respects .gitignore at all levels (root, subdirectories) and descends into
988
+ * embedded (nested, non-submodule) git repos. Returns null on failure
989
+ * (non-git project) so callers can fall back to a filesystem walk.
990
+ */
991
+ function getGitVisibleFiles(rootDir) {
992
+ try {
993
+ // Check if the project directory is gitignored by a parent repo.
994
+ // When rootDir lives inside a parent git repo that ignores it,
995
+ // `git ls-files` returns nothing — fall back to filesystem walk.
996
+ const gitRoot = (0, child_process_1.execFileSync)('git', ['rev-parse', '--show-toplevel'], { cwd: rootDir, encoding: 'utf-8', timeout: 5000, stdio: ['pipe', 'pipe', 'pipe'], windowsHide: true }).trim();
997
+ if (path.resolve(gitRoot) !== path.resolve(rootDir)) {
998
+ try {
999
+ // git check-ignore exits 0 if the path IS ignored, 1 if not
1000
+ (0, child_process_1.execFileSync)('git', ['check-ignore', '-q', path.resolve(rootDir)], { cwd: rootDir, encoding: 'utf-8', timeout: 5000, stdio: ['pipe', 'pipe', 'pipe'], windowsHide: true });
1001
+ // Directory is gitignored by parent repo — fall back to filesystem walk
1002
+ return null;
1003
+ }
1004
+ catch {
1005
+ // Not ignored — safe to use git ls-files
1006
+ }
1007
+ }
1008
+ const files = new Set();
1009
+ const embeddedRoots = new Set();
1010
+ collectGitFiles(rootDir, '', files, embeddedRoots, loadIncludeIgnoredMatcher(rootDir));
1011
+ // Apply built-in default ignores uniformly — to tracked files too, since
1012
+ // committing a dependency/build dir doesn't make it project code. A
1013
+ // `.gitignore` negation (e.g. `!vendor/`) is the explicit opt-in. (issue #407)
1014
+ // Files inside an EMBEDDED repo are matched against that repo's own rules,
1015
+ // not the parent's: the parent's .gitignore hides the child repo from git,
1016
+ // not from the index. (#514)
1017
+ const ig = buildScopeIgnore(rootDir, embeddedRoots);
1018
+ const visible = new Set([...files].filter((f) => !ig.ignores(f)));
1019
+ // Force-include first-party source the project whitelisted in
1020
+ // `codegraph.json` `include`. These are gitignored, so `git ls-files` never
1021
+ // listed them above — discover them directly off disk and add them. (The
1022
+ // common SVN+Git dual-VCS case: source committed to SVN, gitignored out of
1023
+ // Git, but still wanted in the graph.)
1024
+ for (const f of collectIncludedFilesForRoot(rootDir))
1025
+ visible.add(f);
1026
+ return visible;
1027
+ }
1028
+ catch {
1029
+ return null;
1030
+ }
1031
+ }
1032
+ /**
1033
+ * Use `git status` to detect changed files instead of scanning every file.
1034
+ * Returns null on failure so callers fall back to full scan.
1035
+ *
1036
+ * Recurses into embedded repos — the untracked kind (#193: the parent's status
1037
+ * collapses them to an opaque `?? subdir/` entry) always, and the gitignored
1038
+ * kind (#514: they never appear in the parent's status at all) only for
1039
+ * directories opted in via `codegraph.json` `includeIgnored` (#622, #699) —
1040
+ * running `git status` inside each, so changes in a multi-repo workspace sync
1041
+ * without a full rescan. By default a gitignored dir is left alone, matching the
1042
+ * full-index scan (#970, #976). Deleting an ENTIRE embedded repo dir is the one
1043
+ * case this cannot see (the child status that would report the deletions is gone
1044
+ * with it); a full `codegraph index` reconciles that.
1045
+ */
1046
+ function getGitChangedFiles(rootDir) {
1047
+ try {
1048
+ const changes = { modified: [], added: [], deleted: [] };
1049
+ // Custom extension → language overrides from the project's codegraph.json,
1050
+ // so change detection sees the same custom-extension files the full index does.
1051
+ const overrides = (0, project_config_1.loadExtensionOverrides)(rootDir);
1052
+ collectGitStatus(rootDir, '', changes, overrides, loadIncludeIgnoredMatcher(rootDir), loadExcludeMatcher(rootDir));
1053
+ return changes;
1054
+ }
1055
+ catch {
1056
+ return null;
1057
+ }
1058
+ }
1059
+ function collectGitStatus(repoDir, prefix, out, overrides, includeIgnored = null, exclude = null) {
1060
+ const output = (0, child_process_1.execFileSync)('git', ['status', '--porcelain', '--no-renames'], { cwd: repoDir, encoding: 'utf-8', timeout: 10000, maxBuffer: 50 * 1024 * 1024, stdio: ['pipe', 'pipe', 'pipe'], windowsHide: true });
1061
+ // This repo's own ignore rules — built-in defaults (#407) plus its .gitignore.
1062
+ // Change detection must exclude the SAME files the full index does, but git
1063
+ // status hides neither: it ignores nothing for *tracked* paths, and the
1064
+ // built-in defaults aren't gitignore at all. Without this filter a committed
1065
+ // vendor/ dir, or a tracked file under a .gitignored dir, surfaces here as a
1066
+ // change — so `codegraph status` (which reads getChangedFiles) reports a
1067
+ // pending edit the full index never tracks and `sync` never clears. Matching
1068
+ // repo-relative `rel` at each recursion level mirrors getGitVisibleFiles'
1069
+ // ScopeIgnore: every embedded repo is judged by ITS OWN rules, never the
1070
+ // parent's. (#766)
1071
+ const ig = buildDefaultIgnore(repoDir);
1072
+ const untrackedDirs = [];
1073
+ for (const line of output.split('\n')) {
1074
+ if (line.length < 4)
1075
+ continue; // Minimum: "XY file"
1076
+ const statusCode = line.substring(0, 2);
1077
+ const rel = (0, utils_1.normalizePath)(line.substring(3));
1078
+ // Untracked directory entries (trailing slash) may hide an embedded repo —
1079
+ // collect for the recursion below instead of treating as a file.
1080
+ if (statusCode === '??' && rel.endsWith('/')) {
1081
+ untrackedDirs.push(rel);
1082
+ continue;
1083
+ }
1084
+ const filePath = (0, utils_1.normalizePath)(prefix + rel);
1085
+ if (!(0, grammars_1.isSourceFile)(filePath, overrides))
1086
+ continue;
1087
+ if (statusCode.includes('D')) {
1088
+ // Deletions stay unfiltered: getChangedFiles acts on one only when the
1089
+ // path is already tracked in the DB, where removal is always correct — and
1090
+ // that lets a newly-excluded dir's stale rows clean themselves up. (#766)
1091
+ out.deleted.push(filePath);
1092
+ continue;
1093
+ }
1094
+ // Added (`??`) / modified files inside an excluded dir must not enter the
1095
+ // index — match against the repo-relative path, same as the full scan. (#766)
1096
+ if (ig.ignores(rel))
1097
+ continue;
1098
+ // User `codegraph.json` `exclude` (#999) is project-root-relative, so it's
1099
+ // matched against the full path — sync must not re-add a tracked file the
1100
+ // full index now keeps out. Deletions above stay unfiltered so a file that
1101
+ // WAS indexed before an exclude was added still cleans itself out.
1102
+ if (exclude && exclude.ignores(filePath))
1103
+ continue;
1104
+ if (statusCode === '??') {
1105
+ out.added.push(filePath);
1106
+ }
1107
+ else {
1108
+ // M, MM, AM, A (staged), etc. — treat as modified
1109
+ out.modified.push(filePath);
1110
+ }
1111
+ }
1112
+ // Recurse embedded repos found under untracked dirs (at the dir itself or
1113
+ // nested deeper). Gitignored dirs are walked only for the directories the
1114
+ // project opted in via `includeIgnored`; by default `.gitignore` is respected
1115
+ // and they are left alone (#970, #976), mirroring the full-index scan.
1116
+ for (const rel of untrackedDirs) {
1117
+ for (const repoRel of findNestedGitRepos(path.join(repoDir, rel), rel)) {
1118
+ collectGitStatus(path.join(repoDir, repoRel), prefix + repoRel, out, overrides, includeIgnored, exclude);
1119
+ }
1120
+ }
1121
+ for (const rel of findIgnoredEmbeddedRepos(repoDir, includeIgnored, prefix)) {
1122
+ collectGitStatus(path.join(repoDir, rel), prefix + rel, out, overrides, includeIgnored, exclude);
1123
+ }
1124
+ }
1125
+ /**
1126
+ * Recursively scan a directory for source files.
1127
+ *
1128
+ * In git repos, uses `git ls-files` (inherently respects .gitignore at all
1129
+ * levels), then keeps files with a supported source extension. For non-git
1130
+ * projects, falls back to a filesystem walk that parses .gitignore itself.
1131
+ */
1132
+ function scanDirectory(rootDir, onProgress) {
1133
+ // Custom extension → language overrides from the project's codegraph.json.
1134
+ const overrides = (0, project_config_1.loadExtensionOverrides)(rootDir);
1135
+ // Fast path: use git to get all visible files (respects .gitignore everywhere)
1136
+ const gitFiles = getGitVisibleFiles(rootDir);
1137
+ if (gitFiles) {
1138
+ const files = [];
1139
+ let count = 0;
1140
+ for (const filePath of gitFiles) {
1141
+ if ((0, grammars_1.isSourceFile)(filePath, overrides)) {
1142
+ files.push(filePath);
1143
+ count++;
1144
+ onProgress?.(count, filePath);
1145
+ }
1146
+ }
1147
+ return files;
1148
+ }
1149
+ // Fallback: walk filesystem for non-git projects
1150
+ return scanDirectoryWalk(rootDir, onProgress);
1151
+ }
1152
+ /**
1153
+ * Async variant of scanDirectory that yields to the event loop periodically,
1154
+ * allowing worker threads to receive and render progress messages.
1155
+ */
1156
+ async function scanDirectoryAsync(rootDir, onProgress) {
1157
+ // Custom extension → language overrides from the project's codegraph.json.
1158
+ const overrides = (0, project_config_1.loadExtensionOverrides)(rootDir);
1159
+ const gitFiles = getGitVisibleFiles(rootDir);
1160
+ if (gitFiles) {
1161
+ const files = [];
1162
+ let count = 0;
1163
+ for (const filePath of gitFiles) {
1164
+ if ((0, grammars_1.isSourceFile)(filePath, overrides)) {
1165
+ files.push(filePath);
1166
+ count++;
1167
+ onProgress?.(count, filePath);
1168
+ // Yield every 100 files so worker threads can render progress
1169
+ if (count % 100 === 0) {
1170
+ await new Promise(r => setImmediate(r));
1171
+ }
1172
+ }
1173
+ }
1174
+ return files;
1175
+ }
1176
+ return scanDirectoryWalk(rootDir, onProgress);
1177
+ }
1178
+ /**
1179
+ * Filesystem walk fallback for non-git projects.
1180
+ */
1181
+ function scanDirectoryWalk(rootDir, onProgress) {
1182
+ const files = [];
1183
+ let count = 0;
1184
+ const visitedDirs = new Set();
1185
+ // Custom extension → language overrides from the project's codegraph.json.
1186
+ const overrides = (0, project_config_1.loadExtensionOverrides)(rootDir);
1187
+ const loadIgnore = (dir) => {
1188
+ const giPath = path.join(dir, '.gitignore');
1189
+ if (!fs.existsSync(giPath))
1190
+ return null;
1191
+ // readGitignorePatterns is defensive: a non-UTF-8 (DLP-encrypted) or
1192
+ // uncompilable .gitignore is skipped/filtered with a warning, never thrown
1193
+ // (issue #682) — so the per-file `.ignores()` calls below can't crash.
1194
+ const patterns = readGitignorePatterns(giPath);
1195
+ return patterns ? { dir, ig: (0, ignore_1.default)().add(patterns) } : null;
1196
+ };
1197
+ const isIgnored = (fullPath, isDir, matchers) => {
1198
+ for (const { dir, ig } of matchers) {
1199
+ let rel = (0, utils_1.normalizePath)(path.relative(dir, fullPath));
1200
+ if (!rel || rel.startsWith('..'))
1201
+ continue; // not under this matcher's dir
1202
+ if (isDir)
1203
+ rel += '/'; // dir-only rules (e.g. `build/`) only match with the slash
1204
+ if (ig.ignores(rel))
1205
+ return true;
1206
+ }
1207
+ return false;
1208
+ };
1209
+ function walk(dir, matchers) {
1210
+ let realDir;
1211
+ try {
1212
+ realDir = fs.realpathSync(dir);
1213
+ }
1214
+ catch {
1215
+ (0, errors_1.logDebug)('Skipping unresolvable directory', { dir });
1216
+ return;
1217
+ }
1218
+ if (visitedDirs.has(realDir)) {
1219
+ (0, errors_1.logDebug)('Skipping already-visited directory (symlink cycle)', { dir, realDir });
1220
+ return;
1221
+ }
1222
+ visitedDirs.add(realDir);
1223
+ // This directory's own .gitignore (if present) applies to everything below it.
1224
+ // The root's .gitignore is already merged into the seeded base matcher (so a
1225
+ // negation there can override a built-in default), so skip it here.
1226
+ const own = dir === rootDir ? null : loadIgnore(dir);
1227
+ const active = own ? [...matchers, own] : matchers;
1228
+ let entries;
1229
+ try {
1230
+ entries = fs.readdirSync(dir, { withFileTypes: true });
1231
+ }
1232
+ catch (error) {
1233
+ (0, errors_1.logDebug)('Skipping unreadable directory', { dir, error: String(error) });
1234
+ return;
1235
+ }
1236
+ for (const entry of entries) {
1237
+ // Never descend into git internals or any CodeGraph data directory
1238
+ // (the active one or a sibling another environment created — #636).
1239
+ if (entry.name === '.git' || (0, directory_1.isCodeGraphDataDir)(entry.name))
1240
+ continue;
1241
+ const fullPath = path.join(dir, entry.name);
1242
+ const relativePath = (0, utils_1.normalizePath)(path.relative(rootDir, fullPath));
1243
+ if (entry.isSymbolicLink()) {
1244
+ try {
1245
+ const realTarget = fs.realpathSync(fullPath);
1246
+ const stat = fs.statSync(realTarget);
1247
+ if (stat.isDirectory()) {
1248
+ if (!isIgnored(fullPath, true, active)) {
1249
+ walk(fullPath, active);
1250
+ }
1251
+ }
1252
+ else if (stat.isFile()) {
1253
+ if (!isIgnored(fullPath, false, active) && (0, grammars_1.isSourceFile)(relativePath, overrides)) {
1254
+ files.push(relativePath);
1255
+ count++;
1256
+ onProgress?.(count, relativePath);
1257
+ }
1258
+ }
1259
+ }
1260
+ catch {
1261
+ (0, errors_1.logDebug)('Skipping broken symlink', { path: fullPath });
1262
+ }
1263
+ continue;
1264
+ }
1265
+ if (entry.isDirectory()) {
1266
+ if (!isIgnored(fullPath, true, active)) {
1267
+ walk(fullPath, active);
1268
+ }
1269
+ }
1270
+ else if (entry.isFile()) {
1271
+ if (!isIgnored(fullPath, false, active) && (0, grammars_1.isSourceFile)(relativePath, overrides)) {
1272
+ files.push(relativePath);
1273
+ count++;
1274
+ onProgress?.(count, relativePath);
1275
+ }
1276
+ }
1277
+ }
1278
+ }
1279
+ // Seed a base matcher with the built-in default ignores (merged with the root
1280
+ // .gitignore so a negation can override). Nested .gitignores still layer per-dir.
1281
+ const baseMatchers = [{ dir: rootDir, ig: buildDefaultIgnore(rootDir) }];
1282
+ // Project `codegraph.json` `exclude` patterns (#999), rooted at the project so
1283
+ // `isIgnored` matches them against root-relative paths — same coverage the
1284
+ // git path gets via ScopeIgnore, for non-git projects.
1285
+ const exclude = loadExcludeMatcher(rootDir);
1286
+ if (exclude)
1287
+ baseMatchers.push({ dir: rootDir, ig: exclude });
1288
+ walk(rootDir, baseMatchers);
1289
+ // Force-include first-party source whitelisted in `codegraph.json` `include`
1290
+ // — the walk above honours `.gitignore`, so anything gitignored was dropped;
1291
+ // add it back here (deduped). Mirrors the git path's union.
1292
+ const included = collectIncludedFilesForRoot(rootDir);
1293
+ if (included.size > 0) {
1294
+ const seen = new Set(files);
1295
+ for (const f of included) {
1296
+ if (!seen.has(f)) {
1297
+ files.push(f);
1298
+ seen.add(f);
1299
+ }
1300
+ }
1301
+ }
1302
+ return files;
1303
+ }
1304
+ /**
1305
+ * Resurrect a resolution edge that is about to be dropped (its target symbol
1306
+ * was removed, renamed, or its whole file deleted) as the ORIGINAL unresolved
1307
+ * reference that created it, read from the refName/refKind stamp
1308
+ * `createEdges` writes into edge metadata. Inserted as status='pending', the
1309
+ * ref is consumed by the same sync's resolution sweep: it rebinds to an
1310
+ * alternative definition if one exists, or parks as status='failed' where the
1311
+ * #1240 retry finds it if the symbol later reappears.
1312
+ *
1313
+ * Returns null — drop silently, the pre-#1240 behavior — for edges without a
1314
+ * refName stamp (created before the stamp existed, or synthesized): rebuilding
1315
+ * a ref from the target's plain node name would strip the receiver/qualifier
1316
+ * context the original text carried (`h.greet` → `greet`) and could rebind
1317
+ * somewhere a full re-index never would. Silent beats wrong.
1318
+ */
1319
+ function resurrectRefFromDroppedEdge(e) {
1320
+ const refName = e.metadata?.refName;
1321
+ if (typeof refName !== 'string' || refName.length === 0)
1322
+ return null;
1323
+ const refKind = typeof e.metadata?.refKind === 'string' ? e.metadata.refKind : e.kind;
1324
+ return {
1325
+ fromNodeId: e.source,
1326
+ referenceName: refName,
1327
+ referenceKind: refKind,
1328
+ line: e.line ?? 0,
1329
+ column: e.column ?? 0,
1330
+ filePath: e.sourceFilePath,
1331
+ language: e.sourceLanguage,
1332
+ };
1333
+ }
1334
+ /**
1335
+ * Extraction orchestrator
1336
+ */
1337
+ class ExtractionOrchestrator {
1338
+ rootDir;
1339
+ queries;
1340
+ /**
1341
+ * Names of frameworks detected for this project, populated by indexAll().
1342
+ * Passed to extractFromSource so framework-specific extractors (route nodes,
1343
+ * middleware, etc.) run after the tree-sitter pass. Cleared if detection
1344
+ * hasn't run yet so single-file re-index paths can detect on the spot.
1345
+ */
1346
+ detectedFrameworkNames = null;
1347
+ constructor(rootDir, queries) {
1348
+ this.rootDir = rootDir;
1349
+ this.queries = queries;
1350
+ }
1351
+ /**
1352
+ * Build a filesystem-backed ResolutionContext sufficient for framework
1353
+ * detection. Graph-query methods (getNodesByName etc.) return empty because
1354
+ * the DB hasn't been populated yet, but detect() only uses readFile,
1355
+ * fileExists, and getAllFiles, so that's fine.
1356
+ */
1357
+ buildDetectionContext(files) {
1358
+ const rootDir = this.rootDir;
1359
+ return {
1360
+ getNodesInFile: () => [],
1361
+ getNodesByName: () => [],
1362
+ getNodesByQualifiedName: () => [],
1363
+ getNodesByKind: () => [],
1364
+ getNodesByLowerName: () => [],
1365
+ getImportMappings: () => [],
1366
+ getAllFiles: () => files,
1367
+ getProjectRoot: () => rootDir,
1368
+ fileExists: (relativePath) => {
1369
+ const full = (0, utils_1.validatePathWithinRoot)(rootDir, relativePath);
1370
+ if (!full)
1371
+ return false;
1372
+ try {
1373
+ return fs.existsSync(full);
1374
+ }
1375
+ catch {
1376
+ return false;
1377
+ }
1378
+ },
1379
+ readFile: (relativePath) => {
1380
+ const full = (0, utils_1.validatePathWithinRoot)(rootDir, relativePath);
1381
+ if (!full)
1382
+ return null;
1383
+ try {
1384
+ return fs.readFileSync(full, 'utf-8');
1385
+ }
1386
+ catch {
1387
+ return null;
1388
+ }
1389
+ },
1390
+ // Monorepo support — needed by framework detect()s that probe
1391
+ // subpackage manifests (e.g. fabric-view looking at
1392
+ // packages/<sub>/package.json when the root manifest is just a
1393
+ // workspace declaration). Matches the resolver-context shape.
1394
+ listDirectories: (relativePath) => {
1395
+ const target = relativePath === '.' || relativePath === ''
1396
+ ? rootDir
1397
+ : path.join(rootDir, relativePath);
1398
+ try {
1399
+ return fs
1400
+ .readdirSync(target, { withFileTypes: true })
1401
+ .filter((entry) => entry.isDirectory())
1402
+ .map((entry) => entry.name);
1403
+ }
1404
+ catch {
1405
+ return [];
1406
+ }
1407
+ },
1408
+ };
1409
+ }
1410
+ /**
1411
+ * Detect frameworks on demand using the current scanned files (or a fresh
1412
+ * scan if none are provided). Cached on the orchestrator so repeat calls
1413
+ * inside a single run don't re-scan.
1414
+ */
1415
+ ensureDetectedFrameworks(files) {
1416
+ if (this.detectedFrameworkNames !== null)
1417
+ return this.detectedFrameworkNames;
1418
+ const fileList = files ?? scanDirectory(this.rootDir);
1419
+ const context = this.buildDetectionContext(fileList);
1420
+ this.detectedFrameworkNames = (0, frameworks_1.detectFrameworks)(context).map((r) => r.name);
1421
+ return this.detectedFrameworkNames;
1422
+ }
1423
+ /**
1424
+ * Index all files in the project
1425
+ */
1426
+ async indexAll(onProgress, signal, verbose,
1427
+ // Writer-side backstop for deferred WAL checkpointing (#1231): returns
1428
+ // null in the normal case, or a promise to await (at this safe,
1429
+ // between-transactions boundary) when the WAL has outrun the off-thread
1430
+ // checkpointer past its hard cap. See db/wal-valve.ts.
1431
+ walBackpressure,
1432
+ // Fresh-DB store offload (perf): when set, per-file store bundles are
1433
+ // applied by a dedicated writer thread instead of the main thread. Only
1434
+ // passed for a COMPLETELY fresh database, where the main thread performs
1435
+ // no reads/writes during the parse loop, so one writer applying bundles
1436
+ // in file order preserves the #1015 determinism exactly.
1437
+ storeWriterOpts) {
1438
+ const tGrammar = Date.now();
1439
+ await (0, grammars_1.initGrammars)();
1440
+ if (process.env.CODEGRAPH_SYNTH_TIMINGS)
1441
+ console.error(`[phase-timing] grammar-init: ${Date.now() - tGrammar}ms`);
1442
+ const startTime = Date.now();
1443
+ const errors = [];
1444
+ let filesIndexed = 0;
1445
+ let filesSkipped = 0;
1446
+ let filesErrored = 0;
1447
+ let totalNodes = 0;
1448
+ let totalEdges = 0;
1449
+ // Custom extension → language overrides from the project's codegraph.json.
1450
+ // Threaded into language detection so custom-extension files load the right
1451
+ // grammar and store under the mapped language.
1452
+ const overrides = (0, project_config_1.loadExtensionOverrides)(this.rootDir);
1453
+ const log = verbose
1454
+ ? (msg) => { console.log(`[worker] ${msg}`); }
1455
+ : (_msg) => { };
1456
+ // Phase 1: Scan for files
1457
+ onProgress?.({
1458
+ phase: 'scanning',
1459
+ current: 0,
1460
+ total: 0,
1461
+ });
1462
+ // Phase attribution to stderr (same opt-in as the synthesis timings):
1463
+ // early-run 5-10s single stalls were observed on 95k-file repos but never
1464
+ // attributed — these labels settle scan vs framework-detect vs grammars.
1465
+ const tScan = Date.now();
1466
+ const files = await scanDirectoryAsync(this.rootDir, (current, file) => {
1467
+ onProgress?.({
1468
+ phase: 'scanning',
1469
+ current,
1470
+ total: 0,
1471
+ currentFile: file,
1472
+ });
1473
+ });
1474
+ if (process.env.CODEGRAPH_SYNTH_TIMINGS)
1475
+ console.error(`[phase-timing] scan: ${Date.now() - tScan}ms (${files.length} files)`);
1476
+ // Detect frameworks once per indexAll run using the scanned file list.
1477
+ // Names are passed to each parse call so framework-specific extractors
1478
+ // (route nodes, middleware, etc.) run after the tree-sitter pass.
1479
+ // Framework detection is reset each run so adding e.g. requirements.txt
1480
+ // between runs is picked up without restarting the process.
1481
+ this.detectedFrameworkNames = null;
1482
+ const tFw = Date.now();
1483
+ const frameworkNames = this.ensureDetectedFrameworks(files);
1484
+ if (process.env.CODEGRAPH_SYNTH_TIMINGS)
1485
+ console.error(`[phase-timing] framework-detect: ${Date.now() - tFw}ms`);
1486
+ if (signal?.aborted) {
1487
+ return {
1488
+ success: false,
1489
+ filesIndexed: 0,
1490
+ filesSkipped: 0,
1491
+ filesErrored: 0,
1492
+ nodesCreated: 0,
1493
+ edgesCreated: 0,
1494
+ errors: [{ message: 'Aborted', severity: 'error' }],
1495
+ durationMs: Date.now() - startTime,
1496
+ };
1497
+ }
1498
+ // Phase 2: Parse files in a worker thread (keeps main thread unblocked for UI)
1499
+ const total = files.length;
1500
+ let processed = 0;
1501
+ // Emit parsing phase immediately so the progress bar appears during worker setup.
1502
+ // The yield lets the shimmer worker flush the phase transition to stdout before
1503
+ // the main thread starts synchronous grammar detection work.
1504
+ onProgress?.({
1505
+ phase: 'parsing',
1506
+ current: 0,
1507
+ total,
1508
+ });
1509
+ await new Promise(resolve => setImmediate(resolve));
1510
+ // Detect needed languages and load grammars in the parse worker
1511
+ const neededLanguages = [...new Set(files.map((f) => (0, grammars_1.detectLanguage)(f, undefined, overrides)))];
1512
+ // .h files default to 'c' but may be C++ — ensure cpp grammar is loaded when c is needed
1513
+ if (neededLanguages.includes('c') && !neededLanguages.includes('cpp')) {
1514
+ neededLanguages.push('cpp');
1515
+ }
1516
+ // Parse files on a pool of worker threads (keeps the main thread free for UI
1517
+ // and uses every core). Falls back to in-process parsing when the compiled
1518
+ // worker is unavailable (e.g. running from source in tests).
1519
+ const parseWorkerPath = path.join(__dirname, 'parse-worker.js');
1520
+ const useWorker = fs.existsSync(parseWorkerPath);
1521
+ let pool = null;
1522
+ if (useWorker) {
1523
+ // CODEGRAPH_PARSE_WORKERS: explicit worker count; 1 = the old single-worker
1524
+ // behaviour (the conservative rollback). Unset → clamp(cores-1, 1, 8),
1525
+ // with cores from availableParallelism — cpuset/affinity-honest, where
1526
+ // os.cpus() enumerates the host's CPUs and spawned 8 wasm workers (and
1527
+ // their grammar heaps) inside a 2-CPU container for zero extra
1528
+ // throughput (§7a.1). Floored so a 2-core box still gets 2 workers:
1529
+ // parse is worker-side CPU, and 1 worker measured 34% slower than the
1530
+ // old oversubscribed pool on the kernel-scale 2-cpuset envelope
1531
+ // (493s vs 369s) — main + store-worker don't fill the second core.
1532
+ const poolSize = (0, parse_pool_1.resolveParsePoolSize)(process.env.CODEGRAPH_PARSE_WORKERS, Math.max(3, os.availableParallelism()));
1533
+ // Read each needed grammar's WASM ONCE here and hand the bytes to every
1534
+ // worker, so spawns/respawns load grammars from memory instead of
1535
+ // re-reading them from disk (#1231: on an HDD, respawn re-reads amplify
1536
+ // the very I/O contention that caused the respawn).
1537
+ const grammarBuffers = await (0, grammars_1.readGrammarWasmBytes)(neededLanguages);
1538
+ pool = new parse_pool_1.ParseWorkerPool({
1539
+ languages: neededLanguages,
1540
+ size: poolSize,
1541
+ workerScriptPath: parseWorkerPath,
1542
+ recycleInterval: WORKER_RECYCLE_INTERVAL,
1543
+ parseTimeoutMs: PARSE_TIMEOUT_MS,
1544
+ log,
1545
+ grammarBuffers,
1546
+ });
1547
+ log(`Parse worker pool: ${poolSize} worker(s)`);
1548
+ // Bulk index: every core will be needed — spawn the whole pool now so
1549
+ // worker boot overlaps the first read batches instead of trickling in
1550
+ // behind queue-pressure growth.
1551
+ pool.prewarm();
1552
+ }
1553
+ else {
1554
+ // In-process fallback: load grammars locally and parse on the main thread.
1555
+ await (0, grammars_1.loadGrammarsForLanguages)(neededLanguages);
1556
+ }
1557
+ // Dedicated store writer thread (fresh DB only — see the parameter doc).
1558
+ // Same availability rule as the parse pool: needs the compiled worker
1559
+ // (absent when running from source in tests → main-thread fallback).
1560
+ const storeWorkerPath = path.join(__dirname, 'store-worker.js');
1561
+ let storeWriter = null;
1562
+ if (storeWriterOpts &&
1563
+ process.env.CODEGRAPH_NO_STORE_WORKER !== '1' &&
1564
+ fs.existsSync(storeWorkerPath)) {
1565
+ // Deliberately NOT awaiting ready(): worker_threads delivers messages in
1566
+ // order, so bundles posted while the worker is still booting queue
1567
+ // behind 'open'. A boot failure surfaces at the first drain() — same
1568
+ // propagation point as a store error.
1569
+ storeWriter = new store_writer_1.StoreWriter(storeWorkerPath, storeWriterOpts.dbPath, storeWriterOpts.fastInit);
1570
+ log('Store writer thread active');
1571
+ }
1572
+ /** Queue-depth bound for un-acked bundles (bundles hold whole node/edge arrays). */
1573
+ const STORE_WRITER_WINDOW = 64;
1574
+ /**
1575
+ * Parse one file: on the pool when available (the promise REJECTS on a worker
1576
+ * crash/timeout — the caller records it and the retry pass re-attempts), or
1577
+ * in-process synchronously as the no-worker fallback. The language is resolved
1578
+ * here on the main thread, where the codegraph.json overrides are loaded.
1579
+ */
1580
+ const parseFile = (filePath, content) => {
1581
+ const language = (0, grammars_1.detectLanguage)(filePath, content, overrides);
1582
+ if (!pool)
1583
+ return Promise.resolve((0, tree_sitter_1.extractFromSource)(filePath, content, language, frameworkNames));
1584
+ return pool.requestParse({ filePath, content, language, frameworkNames });
1585
+ };
1586
+ // --- Bounded rolling-window dispatch, ordered commit ---
1587
+ // Reads stay batched/parallel; parses run concurrently across the pool; the
1588
+ // SQLite store stays on the main thread (it isn't thread-safe). Crucially we
1589
+ // COMMIT results in original file order, not parse-completion order: the
1590
+ // resolution phase (run after indexing) resolves an ambiguous reference to one
1591
+ // of several same-named candidates by the nodes' DB insertion order, so a
1592
+ // stable commit order keeps the resulting graph deterministic — byte-identical
1593
+ // to the single-worker path — instead of drifting with parse timing. The
1594
+ // `completed` buffer holds at most ~windowSize out-of-order results, so memory
1595
+ // stays bounded.
1596
+ const windowSize = pool ? Math.max(4, pool.size * 2) : 1;
1597
+ const inFlight = new Set();
1598
+ const completed = new Map();
1599
+ let nextSeq = 0; // file-order sequence assigned at dispatch
1600
+ let nextToStore = 0; // cursor: next sequence to commit
1601
+ let aborted = false;
1602
+ // Yielder for the in-order commit path: a single giant generated file's
1603
+ // store is otherwise one unyielding multi-second transaction span on the
1604
+ // main thread (5–14s single stalls measured on llvm-project), starving
1605
+ // the #850 watchdog heartbeat on slow hardware.
1606
+ const commitYield = (0, cooperative_yield_1.createYielder)();
1607
+ const storeResult = async (filePath, content, stats, result) => {
1608
+ processed++;
1609
+ // WAL hard-cap backstop: between files (never mid-transaction), pause
1610
+ // the store until the off-thread checkpoint catches up. Resolves to
1611
+ // null in the normal case — a single size check, no cost.
1612
+ const bp = walBackpressure?.();
1613
+ if (bp)
1614
+ await bp;
1615
+ // Kernel deferred-decode results carry table sizes in kernelCounts
1616
+ // (their object arrays are empty — decode happens at the store).
1617
+ const nodeCount = result.kernelCounts?.nodes ?? result.nodes.length;
1618
+ const edgeCount = result.kernelCounts?.edges ?? result.edges.length;
1619
+ // Store: on the writer thread when active (fresh DB — bundles applied
1620
+ // in the same file order this chain dispatches them), else on the main
1621
+ // thread (SQLite connections are per-thread).
1622
+ if (nodeCount > 0 || result.errors.length === 0) {
1623
+ const language = (0, grammars_1.detectLanguage)(filePath, content, overrides);
1624
+ if (storeWriter) {
1625
+ if (result.kernelBuffers) {
1626
+ // Buffers go to the writer as-is; the worker decodes + finalizes.
1627
+ // The main thread's only per-file work stays O(1) + the content hash.
1628
+ storeWriter.send({
1629
+ kernel: true,
1630
+ filePath,
1631
+ language,
1632
+ buffers: result.kernelBuffers,
1633
+ file: this.buildFileRecord(filePath, content, language, stats, nodeCount, result.errors),
1634
+ });
1635
+ }
1636
+ else {
1637
+ storeWriter.send(this.buildFreshStoreBundle(filePath, content, language, stats, result));
1638
+ }
1639
+ await storeWriter.waitBelow(STORE_WRITER_WINDOW);
1640
+ }
1641
+ else {
1642
+ const materialized = (0, kernel_1.materializeKernelResult)(result, filePath, language);
1643
+ await this.storeExtractionResult(filePath, content, language, stats, materialized, commitYield);
1644
+ }
1645
+ }
1646
+ if (result.errors.length > 0) {
1647
+ for (const err of result.errors) {
1648
+ if (!err.filePath)
1649
+ err.filePath = filePath;
1650
+ }
1651
+ errors.push(...result.errors);
1652
+ }
1653
+ if (nodeCount > 0) {
1654
+ filesIndexed++;
1655
+ totalNodes += nodeCount;
1656
+ totalEdges += edgeCount;
1657
+ }
1658
+ else if (result.errors.some((e) => e.severity === 'error')) {
1659
+ filesErrored++;
1660
+ }
1661
+ else {
1662
+ // Files with no symbols but no errors (yaml, twig, properties) are
1663
+ // tracked at the file level — count them as indexed so the CLI doesn't
1664
+ // misleadingly report "No files found to index".
1665
+ const lang = (0, grammars_1.detectLanguage)(filePath, content, overrides);
1666
+ if ((0, grammars_1.isFileLevelOnlyLanguage)(lang)) {
1667
+ filesIndexed++;
1668
+ }
1669
+ else {
1670
+ filesSkipped++;
1671
+ }
1672
+ }
1673
+ onProgress?.({ phase: 'parsing', current: processed, total, currentFile: filePath });
1674
+ };
1675
+ const recordParseFailure = (filePath, err) => {
1676
+ processed++;
1677
+ filesErrored++;
1678
+ errors.push({
1679
+ message: err instanceof Error ? err.message : String(err),
1680
+ filePath,
1681
+ severity: 'error',
1682
+ code: 'parse_error',
1683
+ });
1684
+ onProgress?.({ phase: 'parsing', current: processed, total });
1685
+ };
1686
+ // Commit buffered parses to the DB in file order, advancing the cursor over
1687
+ // contiguous completed results. Runs after each parse settles (and once more
1688
+ // after the drain). storeResult is now async (it yields between chunked
1689
+ // inserts), so commits are SERIALIZED on a promise chain — concurrent parse
1690
+ // completions append to the chain instead of interleaving mid-store, which
1691
+ // preserves both the file-order commit invariant (#1015: resolution
1692
+ // disambiguates same-named candidates by insertion order) and the
1693
+ // single-writer discipline for SQLite. Errors are recorded and re-thrown
1694
+ // at the drain, matching the old synchronous propagation.
1695
+ let flushChain = Promise.resolve();
1696
+ let flushError = null;
1697
+ const flushOrdered = () => {
1698
+ flushChain = flushChain.then(async () => {
1699
+ if (aborted || flushError)
1700
+ return;
1701
+ try {
1702
+ while (completed.has(nextToStore)) {
1703
+ const item = completed.get(nextToStore);
1704
+ completed.delete(nextToStore);
1705
+ nextToStore++;
1706
+ if (item.ok)
1707
+ await storeResult(item.filePath, item.content, item.stats, item.result);
1708
+ else
1709
+ recordParseFailure(item.filePath, item.err);
1710
+ }
1711
+ }
1712
+ catch (err) {
1713
+ flushError = err;
1714
+ }
1715
+ });
1716
+ return flushChain;
1717
+ };
1718
+ // Dispatch one file's parse (parses run concurrently across the pool), tagged
1719
+ // with its file-order sequence so flushOrdered commits results in order. The
1720
+ // backpressure below bounds how far parsing runs ahead of the in-order commit.
1721
+ const feed = async (filePath, content, stats) => {
1722
+ const seq = nextSeq++;
1723
+ const p = (async () => {
1724
+ try {
1725
+ const result = await parseFile(filePath, content);
1726
+ completed.set(seq, { ok: true, filePath, content, stats, result });
1727
+ }
1728
+ catch (parseErr) {
1729
+ completed.set(seq, { ok: false, filePath, err: parseErr });
1730
+ }
1731
+ flushOrdered();
1732
+ })();
1733
+ const tracked = p.finally(() => { inFlight.delete(tracked); });
1734
+ inFlight.add(tracked);
1735
+ // Backpressure on the dispatched-but-not-yet-committed count (in-flight +
1736
+ // buffered), not just in-flight: a slow file sitting at the commit cursor
1737
+ // lets later parses finish and buffer, which would otherwise grow without
1738
+ // bound. Wait for parses to settle (each may advance the cursor) until the
1739
+ // window has room. When nothing is in flight but the window is still full,
1740
+ // the async commit chain is what's behind — await it so the cursor
1741
+ // advances (buffered items hold whole file contents, so this bound is
1742
+ // load-bearing for memory).
1743
+ while (nextSeq - nextToStore >= windowSize) {
1744
+ if (inFlight.size > 0)
1745
+ await Promise.race(inFlight);
1746
+ else
1747
+ await flushOrdered();
1748
+ }
1749
+ };
1750
+ const tParseLoop = Date.now();
1751
+ for (let i = 0; i < files.length; i += FILE_IO_BATCH_SIZE) {
1752
+ if (signal?.aborted) {
1753
+ aborted = true;
1754
+ break;
1755
+ }
1756
+ const batch = files.slice(i, i + FILE_IO_BATCH_SIZE);
1757
+ // Read files in parallel (with path validation before any I/O)
1758
+ const fileContents = await Promise.all(batch.map(async (fp) => {
1759
+ try {
1760
+ // Indexing read: follow in-root symlinks the directory walk already
1761
+ // descended into (the `../` guard still applies) so files reached
1762
+ // via an in-root symlink-to-outside still index (#935).
1763
+ const fullPath = (0, utils_1.validatePathWithinRoot)(this.rootDir, fp, { allowSymlinkEscape: true });
1764
+ if (!fullPath) {
1765
+ (0, errors_1.logWarn)('Path traversal blocked in batch reader', { filePath: fp });
1766
+ return { filePath: fp, content: null, stats: null, error: new Error('Path traversal blocked') };
1767
+ }
1768
+ const content = await fsp.readFile(fullPath, 'utf-8');
1769
+ const stats = await fsp.stat(fullPath);
1770
+ return { filePath: fp, content, stats, error: null };
1771
+ }
1772
+ catch (err) {
1773
+ return { filePath: fp, content: null, stats: null, error: err };
1774
+ }
1775
+ }));
1776
+ // Dispatch each readable file into the bounded parse window; the window
1777
+ // stores results on the main thread as they arrive.
1778
+ for (const { filePath, content, stats, error } of fileContents) {
1779
+ if (signal?.aborted) {
1780
+ aborted = true;
1781
+ break;
1782
+ }
1783
+ if (error || content === null || stats === null) {
1784
+ processed++;
1785
+ filesErrored++;
1786
+ errors.push({
1787
+ message: `Failed to read file: ${error instanceof Error ? error.message : String(error)}`,
1788
+ filePath,
1789
+ severity: 'error',
1790
+ code: 'read_error',
1791
+ });
1792
+ onProgress?.({ phase: 'parsing', current: processed, total });
1793
+ continue;
1794
+ }
1795
+ // Honour MAX_FILE_SIZE. Without this check, vendored generated
1796
+ // headers, minified bundles, and other multi-MB files get indexed,
1797
+ // wasting WASM heap and the worker recycle budget on inputs with no
1798
+ // useful symbols. The single-file extractFile path already enforces
1799
+ // this; the bulk path used to silently skip the check.
1800
+ if (stats.size > MAX_FILE_SIZE) {
1801
+ processed++;
1802
+ filesSkipped++;
1803
+ errors.push({
1804
+ message: `File exceeds max size (${stats.size} > ${MAX_FILE_SIZE})`,
1805
+ filePath,
1806
+ severity: 'warning',
1807
+ code: 'size_exceeded',
1808
+ });
1809
+ onProgress?.({ phase: 'parsing', current: processed, total });
1810
+ continue;
1811
+ }
1812
+ // Parse on the pool (main thread stays unblocked). Errors/timeouts are
1813
+ // handled inside feed() → recordParseFailure, feeding the retry pass.
1814
+ await feed(filePath, content, stats);
1815
+ }
1816
+ if (aborted)
1817
+ break;
1818
+ }
1819
+ // Drain parses still in flight (skip on abort — we tear down below instead),
1820
+ // then commit any results the cursor hasn't reached yet.
1821
+ if (!aborted) {
1822
+ await Promise.all(inFlight);
1823
+ await flushOrdered();
1824
+ if (flushError) {
1825
+ if (storeWriter)
1826
+ await storeWriter.close();
1827
+ throw flushError;
1828
+ }
1829
+ // All bundles are posted; wait for the writer to apply them, then close
1830
+ // its connection BEFORE any main-thread DB work below (retry pass,
1831
+ // resolution) so exactly one connection writes at a time.
1832
+ if (storeWriter) {
1833
+ try {
1834
+ await storeWriter.drain();
1835
+ }
1836
+ finally {
1837
+ await storeWriter.close();
1838
+ storeWriter = null;
1839
+ }
1840
+ }
1841
+ }
1842
+ if (process.env.CODEGRAPH_SYNTH_TIMINGS)
1843
+ console.error(`[phase-timing] parse-loop: ${Date.now() - tParseLoop}ms`);
1844
+ if (signal?.aborted || aborted) {
1845
+ if (storeWriter)
1846
+ await storeWriter.close();
1847
+ if (pool)
1848
+ await pool.destroy();
1849
+ return {
1850
+ success: false,
1851
+ filesIndexed,
1852
+ filesSkipped,
1853
+ filesErrored,
1854
+ filesDiscovered: total,
1855
+ nodesCreated: totalNodes,
1856
+ edgesCreated: totalEdges,
1857
+ errors: [{ message: 'Aborted', severity: 'error' }, ...errors],
1858
+ durationMs: Date.now() - startTime,
1859
+ };
1860
+ }
1861
+ // Report 100% so the progress bar doesn't hang at 99%
1862
+ onProgress?.({
1863
+ phase: 'parsing',
1864
+ current: total,
1865
+ total,
1866
+ });
1867
+ // Yield so the shimmer worker's buffered stdout writes can flush.
1868
+ // Worker thread stdout is proxied through the main thread's event loop,
1869
+ // so synchronous work here blocks the animation from rendering.
1870
+ await new Promise(resolve => setImmediate(resolve));
1871
+ // Retry pass: files that failed due to WASM memory corruption may succeed
1872
+ // on a fresh worker with a clean heap. Recycle before each attempt so
1873
+ // every file gets the absolute cleanest WASM state possible. Timeouts are
1874
+ // retried too (#1231): most are main-thread-stall artifacts, not slow
1875
+ // parses, and this pass parses one file at a time with the store strictly
1876
+ // after each parse resolves, so the stall window can't recur here.
1877
+ const retryableErrors = errors.filter((e) => e.code === 'parse_error' && e.filePath &&
1878
+ (e.message.includes('Worker exited') ||
1879
+ e.message.includes('memory access out of bounds') ||
1880
+ e.message.includes('timed out')));
1881
+ if (retryableErrors.length > 0 && pool) {
1882
+ log(`Retrying ${retryableErrors.length} files that failed due to WASM memory errors or timeouts...`);
1883
+ // Fresh WASM heaps for the retry phase. A retry that still crashes its
1884
+ // worker makes the pool respawn it, so later retries keep landing on clean
1885
+ // workers too.
1886
+ pool.recycleAll();
1887
+ const stillFailing = [];
1888
+ for (const errEntry of retryableErrors) {
1889
+ const filePath = errEntry.filePath;
1890
+ if (signal?.aborted)
1891
+ break;
1892
+ let content;
1893
+ try {
1894
+ const fullPath = (0, utils_1.validatePathWithinRoot)(this.rootDir, filePath);
1895
+ if (!fullPath)
1896
+ continue;
1897
+ content = await fsp.readFile(fullPath, 'utf-8');
1898
+ }
1899
+ catch {
1900
+ continue;
1901
+ }
1902
+ let result;
1903
+ try {
1904
+ result = await parseFile(filePath, content);
1905
+ }
1906
+ catch {
1907
+ stillFailing.push(errEntry);
1908
+ continue;
1909
+ }
1910
+ if (result.nodes.length > 0 || result.errors.length === 0) {
1911
+ const language = (0, grammars_1.detectLanguage)(filePath, content, overrides);
1912
+ const stats = await fsp.stat(path.join(this.rootDir, filePath));
1913
+ await this.storeExtractionResult(filePath, content, language, stats, result, commitYield);
1914
+ const idx = errors.indexOf(errEntry);
1915
+ if (idx >= 0)
1916
+ errors.splice(idx, 1);
1917
+ filesErrored--;
1918
+ filesIndexed++;
1919
+ totalNodes += result.nodes.length;
1920
+ totalEdges += result.edges.length;
1921
+ log(`Retry OK: ${filePath} (${result.nodes.length} nodes)`);
1922
+ }
1923
+ }
1924
+ // Last resort: for files that still crash on a clean worker, strip
1925
+ // comment-only lines to reduce WASM memory pressure. Many compiler
1926
+ // test files are 90%+ comments (CHECK directives) that don't contribute
1927
+ // code nodes but consume parser memory.
1928
+ if (stillFailing.length > 0) {
1929
+ log(`${stillFailing.length} files still failing — retrying with comments stripped...`);
1930
+ pool.recycleAll();
1931
+ for (const errEntry of stillFailing) {
1932
+ const filePath = errEntry.filePath;
1933
+ if (signal?.aborted)
1934
+ break;
1935
+ let fullContent;
1936
+ try {
1937
+ const fullPath = (0, utils_1.validatePathWithinRoot)(this.rootDir, filePath);
1938
+ if (!fullPath)
1939
+ continue;
1940
+ fullContent = await fsp.readFile(fullPath, 'utf-8');
1941
+ }
1942
+ catch {
1943
+ continue;
1944
+ }
1945
+ // Strip lines that are entirely comments (preserving line numbers
1946
+ // by replacing with empty lines so node positions stay correct)
1947
+ const stripped = fullContent
1948
+ .split('\n')
1949
+ .map(line => /^\s*\/\//.test(line) ? '' : line)
1950
+ .join('\n');
1951
+ let result;
1952
+ try {
1953
+ result = await parseFile(filePath, stripped);
1954
+ }
1955
+ catch {
1956
+ continue;
1957
+ }
1958
+ if (result.nodes.length > 0 || result.errors.length === 0) {
1959
+ const language = (0, grammars_1.detectLanguage)(filePath, fullContent, overrides);
1960
+ const stats = await fsp.stat(path.join(this.rootDir, filePath));
1961
+ await this.storeExtractionResult(filePath, fullContent, language, stats, result, commitYield);
1962
+ const idx = errors.indexOf(errEntry);
1963
+ if (idx >= 0)
1964
+ errors.splice(idx, 1);
1965
+ filesErrored--;
1966
+ filesIndexed++;
1967
+ totalNodes += result.nodes.length;
1968
+ totalEdges += result.edges.length;
1969
+ log(`Retry (stripped) OK: ${filePath} (${result.nodes.length} nodes)`);
1970
+ }
1971
+ }
1972
+ }
1973
+ }
1974
+ // Shut down the parse worker pool.
1975
+ if (pool)
1976
+ await pool.destroy();
1977
+ return {
1978
+ success: filesIndexed > 0 || errors.filter((e) => e.severity === 'error').length === 0,
1979
+ filesIndexed,
1980
+ filesSkipped,
1981
+ filesErrored,
1982
+ filesDiscovered: total,
1983
+ nodesCreated: totalNodes,
1984
+ edgesCreated: totalEdges,
1985
+ errors,
1986
+ durationMs: Date.now() - startTime,
1987
+ };
1988
+ }
1989
+ /**
1990
+ * Index specific files
1991
+ */
1992
+ async indexFiles(filePaths) {
1993
+ const startTime = Date.now();
1994
+ const errors = [];
1995
+ let filesIndexed = 0;
1996
+ let filesSkipped = 0;
1997
+ let filesErrored = 0;
1998
+ let totalNodes = 0;
1999
+ let totalEdges = 0;
2000
+ for (const filePath of filePaths) {
2001
+ const result = await this.indexFile(filePath);
2002
+ if (result.errors.length > 0) {
2003
+ errors.push(...result.errors);
2004
+ }
2005
+ if (result.nodes.length > 0) {
2006
+ filesIndexed++;
2007
+ totalNodes += result.nodes.length;
2008
+ totalEdges += result.edges.length;
2009
+ }
2010
+ else if (result.errors.some((e) => e.severity === 'error')) {
2011
+ filesErrored++;
2012
+ }
2013
+ else {
2014
+ const tracked = this.queries.getFileByPath(filePath);
2015
+ if (tracked && (0, grammars_1.isFileLevelOnlyLanguage)(tracked.language)) {
2016
+ filesIndexed++;
2017
+ }
2018
+ else {
2019
+ filesSkipped++;
2020
+ }
2021
+ }
2022
+ }
2023
+ return {
2024
+ success: filesIndexed > 0 || errors.filter((e) => e.severity === 'error').length === 0,
2025
+ filesIndexed,
2026
+ filesSkipped,
2027
+ filesErrored,
2028
+ nodesCreated: totalNodes,
2029
+ edgesCreated: totalEdges,
2030
+ errors,
2031
+ durationMs: Date.now() - startTime,
2032
+ };
2033
+ }
2034
+ /**
2035
+ * Index a single file
2036
+ */
2037
+ async indexFile(relativePath) {
2038
+ // Indexing read: follow in-root symlinks (the `../` guard still applies), #935.
2039
+ const fullPath = (0, utils_1.validatePathWithinRoot)(this.rootDir, relativePath, { allowSymlinkEscape: true });
2040
+ if (!fullPath) {
2041
+ return {
2042
+ nodes: [],
2043
+ edges: [],
2044
+ unresolvedReferences: [],
2045
+ errors: [{ message: `Path traversal blocked: ${relativePath}`, filePath: relativePath, severity: 'error', code: 'path_traversal' }],
2046
+ durationMs: 0,
2047
+ };
2048
+ }
2049
+ // Read file content and stats
2050
+ let content;
2051
+ let stats;
2052
+ try {
2053
+ stats = await fsp.stat(fullPath);
2054
+ content = await fsp.readFile(fullPath, 'utf-8');
2055
+ }
2056
+ catch (error) {
2057
+ return {
2058
+ nodes: [],
2059
+ edges: [],
2060
+ unresolvedReferences: [],
2061
+ errors: [
2062
+ {
2063
+ message: `Failed to read file: ${error instanceof Error ? error.message : String(error)}`,
2064
+ filePath: relativePath,
2065
+ severity: 'error',
2066
+ code: 'read_error',
2067
+ },
2068
+ ],
2069
+ durationMs: 0,
2070
+ };
2071
+ }
2072
+ return this.indexFileWithContent(relativePath, content, stats);
2073
+ }
2074
+ /**
2075
+ * Index a single file with pre-read content and stats.
2076
+ * Used by the parallel batch reader to avoid redundant file I/O.
2077
+ */
2078
+ async indexFileWithContent(relativePath, content, stats) {
2079
+ // Prevent `../` traversal; follow in-root symlinks like the directory walk (#935).
2080
+ const fullPath = (0, utils_1.validatePathWithinRoot)(this.rootDir, relativePath, { allowSymlinkEscape: true });
2081
+ if (!fullPath) {
2082
+ (0, errors_1.logWarn)('Path traversal blocked in indexFileWithContent', { relativePath });
2083
+ return {
2084
+ nodes: [],
2085
+ edges: [],
2086
+ unresolvedReferences: [],
2087
+ errors: [{ message: 'Path traversal blocked', filePath: relativePath, severity: 'error', code: 'path_traversal' }],
2088
+ durationMs: 0,
2089
+ };
2090
+ }
2091
+ // Check file size
2092
+ if (stats.size > MAX_FILE_SIZE) {
2093
+ return {
2094
+ nodes: [],
2095
+ edges: [],
2096
+ unresolvedReferences: [],
2097
+ errors: [
2098
+ {
2099
+ message: `File exceeds max size (${stats.size} > ${MAX_FILE_SIZE})`,
2100
+ filePath: relativePath,
2101
+ severity: 'warning',
2102
+ code: 'size_exceeded',
2103
+ },
2104
+ ],
2105
+ durationMs: 0,
2106
+ };
2107
+ }
2108
+ // Detect language (honoring the project's codegraph.json extension overrides)
2109
+ const language = (0, grammars_1.detectLanguage)(relativePath, content, (0, project_config_1.loadExtensionOverrides)(this.rootDir));
2110
+ if (!(0, grammars_1.isLanguageSupported)(language)) {
2111
+ return {
2112
+ nodes: [],
2113
+ edges: [],
2114
+ unresolvedReferences: [],
2115
+ errors: [],
2116
+ durationMs: 0,
2117
+ };
2118
+ }
2119
+ // Extract from source. Use cached framework names if indexAll has run,
2120
+ // otherwise detect on the spot so single-file re-index paths still emit
2121
+ // route nodes / middleware / etc.
2122
+ const frameworkNames = this.ensureDetectedFrameworks();
2123
+ const result = (0, tree_sitter_1.extractFromSource)(relativePath, content, language, frameworkNames);
2124
+ // Store in database
2125
+ if (result.nodes.length > 0 || result.errors.length === 0) {
2126
+ await this.storeExtractionResult(relativePath, content, language, stats, result, (0, cooperative_yield_1.createYielder)());
2127
+ }
2128
+ return result;
2129
+ }
2130
+ /**
2131
+ * Store extraction result in database
2132
+ */
2133
+ async storeExtractionResult(filePath, content, language, stats, result, onYield) {
2134
+ // Bulk inserts run in bounded sub-transactions with a yield between, so a
2135
+ // giant generated file (tens of thousands of symbols) can't block the
2136
+ // event loop — and the #850 watchdog heartbeat — for the whole store.
2137
+ // The file was NEVER one atomic transaction (each insert call has its
2138
+ // own), and the files-table record still lands last, so crash recovery
2139
+ // is unchanged: a partially-stored file has no record and re-indexes.
2140
+ const STORE_CHUNK = 2000;
2141
+ const contentHash = hashContent(content);
2142
+ // Check if file already exists and hasn't changed
2143
+ const existingFile = this.queries.getFileByPath(filePath);
2144
+ if (existingFile && existingFile.contentHash === contentHash) {
2145
+ return; // No changes
2146
+ }
2147
+ // Re-decided on every re-index of a changed file, so a banner added (or
2148
+ // removed) by an edit is reflected on the next sync (#1500). Computed after
2149
+ // the unchanged-file early return so untouched files pay nothing.
2150
+ const generated = (0, generated_detection_1.detectGeneratedFile)(filePath, content);
2151
+ // Snapshot incoming cross-file edges BEFORE deleting this file's nodes.
2152
+ // `deleteFile` cascades to delete every edge whose source OR target is a
2153
+ // node in this file (edges.FK ... ON DELETE CASCADE). Edges whose SOURCE is
2154
+ // in this file are re-emitted by the extractor below, but edges whose SOURCE
2155
+ // is in a *different* (unchanged) file are not — they would be silently
2156
+ // dropped, which is issue #899: re-indexing a callee file severs `calls`/
2157
+ // `references` edges from callers that import it via module-attribute
2158
+ // access (`pkg.mod.fn(...)`).
2159
+ //
2160
+ // We snapshot the edge plus the target node's (name, kind) so we can
2161
+ // re-resolve to the re-indexed target's NEW id. Node ids are
2162
+ // `sha256(filePath:kind:name:line)`, so any line shift in the callee file
2163
+ // (e.g. a docstring-only edit above the symbol) changes every target id and
2164
+ // a naive re-insert by old id would silently drop every edge. Matching by
2165
+ // (filePath, kind, name) is stable across line shifts; if the symbol was
2166
+ // renamed/removed, no match is found and the edge stays dropped (correct).
2167
+ const crossFileIncomingEdges = existingFile
2168
+ ? this.queries.getCrossFileIncomingEdgesWithTarget(filePath)
2169
+ : [];
2170
+ // Delete existing data for this file
2171
+ if (existingFile) {
2172
+ this.queries.deleteFile(filePath);
2173
+ }
2174
+ // Filter out nodes with missing required fields before insertion.
2175
+ // This prevents FK violations when edges reference nodes that would
2176
+ // be silently skipped by insertNode() (see issue #42).
2177
+ const validNodes = result.nodes.filter((n) => n.id && n.kind && n.name && n.filePath && n.language);
2178
+ const insertedIds = new Set(validNodes.map((n) => n.id));
2179
+ const validEdges = result.edges.filter((e) => insertedIds.has(e.source) && insertedIds.has(e.target));
2180
+ const validRefs = result.unresolvedReferences
2181
+ .filter((ref) => insertedIds.has(ref.fromNodeId))
2182
+ .map((ref) => ({
2183
+ ...ref,
2184
+ filePath: ref.filePath ?? filePath,
2185
+ language: ref.language ?? language,
2186
+ }));
2187
+ // Fast path for the common case (everything fits one chunk): the whole
2188
+ // file — nodes, edges, refs, file record — lands in ONE transaction with
2189
+ // no event-loop yields in between. Giant generated files keep the chunked
2190
+ // + yielding path below so the #850 watchdog heartbeat stays serviced.
2191
+ const fitsOneChunk = validNodes.length <= STORE_CHUNK &&
2192
+ validEdges.length <= STORE_CHUNK &&
2193
+ validRefs.length <= STORE_CHUNK;
2194
+ if (fitsOneChunk) {
2195
+ // Snapshot/re-resolution of cross-file incoming edges (below) still runs
2196
+ // for the sync path; on a fresh bulk index crossFileIncomingEdges is [].
2197
+ this.queries.storeFileBundle({
2198
+ nodes: validNodes,
2199
+ edges: validEdges,
2200
+ refs: validRefs,
2201
+ file: {
2202
+ path: filePath,
2203
+ contentHash,
2204
+ language,
2205
+ size: stats.size,
2206
+ modifiedAt: stats.mtimeMs,
2207
+ indexedAt: Date.now(),
2208
+ nodeCount: result.nodes.length,
2209
+ errors: result.errors.length > 0 ? result.errors : undefined,
2210
+ generated,
2211
+ },
2212
+ });
2213
+ if (crossFileIncomingEdges.length > 0) {
2214
+ this.reattachCrossFileEdges(crossFileIncomingEdges, validNodes);
2215
+ }
2216
+ return;
2217
+ }
2218
+ // Insert nodes (chunked — see STORE_CHUNK above)
2219
+ for (let i = 0; i < validNodes.length; i += STORE_CHUNK) {
2220
+ this.queries.insertNodes(validNodes.slice(i, i + STORE_CHUNK));
2221
+ await onYield?.();
2222
+ }
2223
+ // Filter edges to only reference nodes that were actually inserted
2224
+ if (validEdges.length > 0) {
2225
+ for (let i = 0; i < validEdges.length; i += STORE_CHUNK) {
2226
+ this.queries.insertEdges(validEdges.slice(i, i + STORE_CHUNK));
2227
+ await onYield?.();
2228
+ }
2229
+ }
2230
+ // Re-insert cross-file incoming edges snapshotted before the delete,
2231
+ // re-resolving each edge's target to the re-indexed node's new id by
2232
+ // (filePath, kind, name). Node ids include the source line, so any line
2233
+ // shift in the callee file (e.g. a docstring-only edit above the symbol)
2234
+ // changes every target id and a naive re-insert by old id would drop them
2235
+ // all. `insertEdges` still filters to endpoints that exist. This closes
2236
+ // the #899 edge-drop on `sync`.
2237
+ //
2238
+ // Edges whose callee (target) was renamed/removed during the re-index (no
2239
+ // match in `newNodesByKindName`) are not silently dropped anymore: each is
2240
+ // resurrected as its ORIGINAL unresolved ref (stamped on the edge as
2241
+ // metadata.refName/refKind at creation) so the same sync's resolution
2242
+ // sweep can rebind it to an alternative definition elsewhere, or park it
2243
+ // as status='failed' to be retried when the symbol reappears — the
2244
+ // removal-side counterpart of #1240. Edges without refName (built before
2245
+ // the stamp existed, or synthesized) still drop silently: reconstructing
2246
+ // a ref from the target's plain name would strip receiver/qualifier
2247
+ // context and risk a rebind a full re-index would never make.
2248
+ if (crossFileIncomingEdges.length > 0) {
2249
+ this.reattachCrossFileEdges(crossFileIncomingEdges, validNodes);
2250
+ }
2251
+ // Insert unresolved references in batch with denormalized filePath/language
2252
+ for (let i = 0; i < validRefs.length; i += STORE_CHUNK) {
2253
+ this.queries.insertUnresolvedRefsBatch(validRefs.slice(i, i + STORE_CHUNK));
2254
+ await onYield?.();
2255
+ }
2256
+ // Insert file record
2257
+ const fileRecord = {
2258
+ path: filePath,
2259
+ contentHash,
2260
+ language,
2261
+ size: stats.size,
2262
+ modifiedAt: stats.mtimeMs,
2263
+ indexedAt: Date.now(),
2264
+ nodeCount: result.nodes.length,
2265
+ errors: result.errors.length > 0 ? result.errors : undefined,
2266
+ generated,
2267
+ };
2268
+ this.queries.upsertFile(fileRecord);
2269
+ }
2270
+ /**
2271
+ * Build one file's store bundle for the FRESH-DB path: no existing-file
2272
+ * check, no cross-file edge snapshot (both are re-index concerns — a fresh
2273
+ * database has neither). Filters mirror storeExtractionResult exactly.
2274
+ */
2275
+ /** The FileRecord for a fresh-index store (nodeCount is the PRE-filter count). */
2276
+ buildFileRecord(filePath, content, language, stats, nodeCount, resultErrors) {
2277
+ return {
2278
+ path: filePath,
2279
+ contentHash: hashContent(content),
2280
+ language,
2281
+ size: stats.size,
2282
+ modifiedAt: stats.mtimeMs,
2283
+ indexedAt: Date.now(),
2284
+ nodeCount,
2285
+ errors: resultErrors.length > 0 ? resultErrors : undefined,
2286
+ // Decided here, once, while the content is already in memory — never at
2287
+ // query time (#1500). The header scan short-circuits on a single
2288
+ // substring test for ~every hand-written file.
2289
+ generated: (0, generated_detection_1.detectGeneratedFile)(filePath, content),
2290
+ };
2291
+ }
2292
+ buildFreshStoreBundle(filePath, content, language, stats, result) {
2293
+ return (0, store_writer_1.finalizeStoreBundle)(result, filePath, language, this.buildFileRecord(filePath, content, language, stats, result.nodes.length, result.errors));
2294
+ }
2295
+ /**
2296
+ * Re-attach cross-file incoming edges snapshotted before a re-index delete
2297
+ * (#899): re-resolve each edge's target to the re-indexed node's new id by
2298
+ * (kind, name); targets that vanished are resurrected as their original
2299
+ * unresolved ref (#1240's removal-side counterpart) when the edge carries
2300
+ * its refName stamp.
2301
+ */
2302
+ reattachCrossFileEdges(crossFileIncomingEdges, validNodes) {
2303
+ const newNodesByKindName = new Map();
2304
+ for (const n of validNodes) {
2305
+ newNodesByKindName.set(`${n.kind}\0${n.name}`, n.id);
2306
+ }
2307
+ const reinserted = [];
2308
+ const resurrected = [];
2309
+ for (const e of crossFileIncomingEdges) {
2310
+ const newTargetId = newNodesByKindName.get(`${e.targetKind}\0${e.targetName}`);
2311
+ if (newTargetId) {
2312
+ reinserted.push({ source: e.source, target: newTargetId, kind: e.kind, metadata: e.metadata, line: e.line, column: e.column, provenance: e.provenance });
2313
+ }
2314
+ else {
2315
+ const ref = resurrectRefFromDroppedEdge(e);
2316
+ if (ref)
2317
+ resurrected.push(ref);
2318
+ }
2319
+ }
2320
+ if (reinserted.length > 0) {
2321
+ this.queries.insertEdges(reinserted);
2322
+ }
2323
+ if (resurrected.length > 0) {
2324
+ this.queries.insertUnresolvedRefsBatch(resurrected);
2325
+ }
2326
+ }
2327
+ /**
2328
+ * Re-open, for re-resolution, every resolution edge whose answer this sync
2329
+ * may have changed — the fix for index drift (CG-33).
2330
+ *
2331
+ * Incremental sync re-resolves only the references IN the changed files, but
2332
+ * resolution's answer is a function of the WHOLE graph: a reference binds to
2333
+ * one of the same-named definitions project-wide, so adding or removing a
2334
+ * definition of `pct` can change which `pct` every other file's `pct(...)`
2335
+ * should bind to. Those other files are never revisited, and their references
2336
+ * resolved successfully once and were deleted from `unresolved_refs`, so
2337
+ * nothing existed to revisit them with — the index kept an answer that was
2338
+ * correct against an older graph. Measured on codegraph's own long-lived
2339
+ * index: 4.3% of distinct edges differed from a clean rebuild, in BOTH
2340
+ * directions, overwhelmingly `calls`. See docs/benchmarks/index-drift-cg33.md.
2341
+ *
2342
+ * This deletes each affected edge and re-inserts it as the reference that
2343
+ * created it (the refName/refKind stamp), status='pending', for the sync's
2344
+ * resolution sweep to bind against the post-sync graph — the same input a
2345
+ * full rebuild resolves from, which is what makes the two converge.
2346
+ *
2347
+ * Deliberately conservative in three ways, because a wrong deletion is a
2348
+ * permanent edge loss while a missed rebind is only residual drift:
2349
+ * - an edge with no refName stamp (synthesized, or built by an engine older
2350
+ * than the stamp) is left ALONE rather than reconstructed from the target's
2351
+ * plain name, same rule as `resurrectRefFromDroppedEdge`;
2352
+ * - edges whose source is in a file this sync already re-extracted are
2353
+ * skipped — their references were re-resolved from scratch moments ago;
2354
+ * - very common names are skipped by the per-name ceiling in
2355
+ * `getResolutionEdgesByTargetName`.
2356
+ *
2357
+ * Returns the number of references resurrected.
2358
+ */
2359
+ resurrectStaleResolutionEdges(definitionDelta, changedFilePaths) {
2360
+ if (definitionDelta.length === 0)
2361
+ return 0;
2362
+ const alreadyFresh = new Set(changedFilePaths);
2363
+ const candidates = this.queries.getResolutionEdgesByTargetName(definitionDelta);
2364
+ const edgeIds = [];
2365
+ const refs = [];
2366
+ for (const e of candidates) {
2367
+ if (alreadyFresh.has(e.sourceFilePath))
2368
+ continue;
2369
+ const ref = resurrectRefFromDroppedEdge(e);
2370
+ if (!ref)
2371
+ continue; // no stamp — never delete what we cannot restore
2372
+ edgeIds.push(e.edgeId);
2373
+ refs.push(ref);
2374
+ }
2375
+ if (refs.length === 0)
2376
+ return 0;
2377
+ // Delete first. The sweep re-inserts whichever edge resolution now picks,
2378
+ // and `insertEdges` is INSERT OR IGNORE against idx_edges_identity — so a
2379
+ // rebind to the same target is a clean no-op, but leaving the old row in
2380
+ // place for a rebind ELSEWHERE would keep both, turning drift into
2381
+ // duplication.
2382
+ this.queries.deleteEdgesByIds(edgeIds);
2383
+ this.queries.insertUnresolvedRefsBatch(refs);
2384
+ return refs.length;
2385
+ }
2386
+ /**
2387
+ * Sync the index with the current file state.
2388
+ *
2389
+ * Change detection is filesystem-based, never git: a (size, mtime) stat
2390
+ * pre-filter skips unchanged files, then a content-hash compare confirms real
2391
+ * changes. This works in non-git projects and catches committed changes from
2392
+ * `git pull`/`checkout`/`merge`/`rebase` that `git status` cannot see.
2393
+ */
2394
+ async sync(onProgress,
2395
+ /**
2396
+ * Watcher fast path: the exact project-relative paths the OS reported as
2397
+ * changed. When provided, reconciliation runs over ONLY these paths —
2398
+ * per-path logic identical to the full walk (stat pre-filter, hash
2399
+ * confirm, the #1240 removal/resurrection flow) — skipping the O(repo)
2400
+ * scan and tracked-load. Callers must pass undefined whenever the change
2401
+ * set is not exactly known (directory removals, event overflow): the full
2402
+ * scan-diff remains the ground truth those cases need (#1285).
2403
+ */
2404
+ scopedPaths) {
2405
+ await (0, grammars_1.initGrammars)(); // Initialize WASM runtime (grammars loaded lazily below)
2406
+ const startTime = Date.now();
2407
+ let filesChecked = 0;
2408
+ let filesAdded = 0;
2409
+ let filesModified = 0;
2410
+ let filesRemoved = 0;
2411
+ let nodesUpdated = 0;
2412
+ const changedFilePaths = [];
2413
+ // `file\0name` definition pairs for the files this sync touches, sampled
2414
+ // BEFORE their nodes are replaced/deleted. Compared against the post-store
2415
+ // pairs below to derive `definitionDelta` (CG-33).
2416
+ const pairsBefore = new Set();
2417
+ onProgress?.({
2418
+ phase: 'scanning',
2419
+ current: 0,
2420
+ total: 0,
2421
+ });
2422
+ const filesToIndex = [];
2423
+ // === Filesystem reconcile (git-independent) ===
2424
+ // The source of truth for "what changed" is the filesystem vs the indexed
2425
+ // state — never git. We enumerate the current source files and reconcile
2426
+ // each against the DB. A cheap (size, mtime) stat pre-filter skips unchanged
2427
+ // files without reading or hashing them, so the expensive read+hash+parse
2428
+ // only runs for files that actually changed. This catches edits/adds/deletes
2429
+ // whether or not the project uses git, and crucially also catches committed
2430
+ // changes from `git pull`/`checkout`/`merge`/`rebase` — which `git status`
2431
+ // cannot see, because the working tree is clean afterward.
2432
+ const tSyncScan = Date.now();
2433
+ let currentFiles;
2434
+ let trackedFiles;
2435
+ if (scopedPaths && scopedPaths.length > 0) {
2436
+ // Scoped reconcile: stat only the reported paths. filesChecked counts
2437
+ // the PATHS examined (not the files found) — it must stay non-zero even
2438
+ // when every scoped path was a deletion, because CodeGraph.watch()
2439
+ // reads `filesChecked === 0 && durationMs === 0` as the
2440
+ // lock-unavailable signature (#449).
2441
+ const unique = [...new Set(scopedPaths)];
2442
+ currentFiles = unique.filter((p) => fs.existsSync(path.join(this.rootDir, p)));
2443
+ trackedFiles = [];
2444
+ for (const p of unique) {
2445
+ const rec = this.queries.getFileByPath(p);
2446
+ if (rec)
2447
+ trackedFiles.push(rec);
2448
+ }
2449
+ filesChecked = unique.length;
2450
+ if (process.env.CODEGRAPH_SYNTH_TIMINGS)
2451
+ console.error(`[phase-timing] sync-scoped: ${Date.now() - tSyncScan}ms (${unique.length} paths, ${trackedFiles.length} tracked)`);
2452
+ }
2453
+ else {
2454
+ currentFiles = await scanDirectoryAsync(this.rootDir);
2455
+ if (process.env.CODEGRAPH_SYNTH_TIMINGS)
2456
+ console.error(`[phase-timing] sync-scan: ${Date.now() - tSyncScan}ms (${currentFiles.length} files)`);
2457
+ filesChecked = currentFiles.length;
2458
+ const tTracked = Date.now();
2459
+ trackedFiles = this.queries.getAllFiles();
2460
+ if (process.env.CODEGRAPH_SYNTH_TIMINGS)
2461
+ console.error(`[phase-timing] sync-tracked-load: ${Date.now() - tTracked}ms (${trackedFiles.length} tracked)`);
2462
+ }
2463
+ const currentSet = new Set(currentFiles);
2464
+ const trackedMap = new Map();
2465
+ for (const f of trackedFiles) {
2466
+ trackedMap.set(f.path, f);
2467
+ }
2468
+ // Removals: tracked in the DB but no longer a present source file. Check the
2469
+ // filesystem directly — `scanDirectory` (via `git ls-files`) still lists a
2470
+ // file deleted from disk but not yet staged, so set membership alone misses it.
2471
+ // `reconcileChecks` drives the cooperative yield shared with the adds/mods loop
2472
+ // below (see SYNC_RECONCILE_YIELD_INTERVAL / issue #905).
2473
+ let reconcileChecks = 0;
2474
+ for (const tracked of trackedFiles) {
2475
+ if (!currentSet.has(tracked.path) || !fs.existsSync(path.join(this.rootDir, tracked.path))) {
2476
+ // Before the cascade deletes them, resurrect incoming cross-file
2477
+ // resolution edges as their original refs (#1240 removal case): the
2478
+ // callers live in files this sync will NOT revisit, so this is their
2479
+ // only chance to rebind to an alternative definition — or to park as
2480
+ // failed until the symbol reappears somewhere. (A deleted file whose
2481
+ // CALLERS are also being deleted is fine: their nodes cascade later
2482
+ // in this loop and take the resurrected rows with them.)
2483
+ // Every name this file defined is about to stop existing here, which
2484
+ // narrows the candidate set for that name repo-wide (CG-33).
2485
+ for (const pair of this.queries.getNodeNamePairsByFiles([tracked.path]))
2486
+ pairsBefore.add(pair);
2487
+ const incoming = this.queries.getCrossFileIncomingEdgesWithTarget(tracked.path);
2488
+ if (incoming.length > 0) {
2489
+ const resurrected = incoming
2490
+ .map((e) => resurrectRefFromDroppedEdge(e))
2491
+ .filter((r) => r !== null);
2492
+ if (resurrected.length > 0) {
2493
+ this.queries.insertUnresolvedRefsBatch(resurrected);
2494
+ }
2495
+ }
2496
+ this.queries.deleteFile(tracked.path);
2497
+ filesRemoved++;
2498
+ }
2499
+ if (++reconcileChecks % SYNC_RECONCILE_YIELD_INTERVAL === 0) {
2500
+ await new Promise((resolve) => setImmediate(resolve));
2501
+ }
2502
+ }
2503
+ // Adds / modifications.
2504
+ for (const filePath of currentFiles) {
2505
+ // Same cooperative yield as the removals loop — this is the other O(files)
2506
+ // synchronous-stat loop that wedges the main thread on a large repo (#905).
2507
+ // Yield at the top of the body so the `continue` fast-paths below still hit it.
2508
+ if (++reconcileChecks % SYNC_RECONCILE_YIELD_INTERVAL === 0) {
2509
+ await new Promise((resolve) => setImmediate(resolve));
2510
+ }
2511
+ const fullPath = path.join(this.rootDir, filePath);
2512
+ const tracked = trackedMap.get(filePath);
2513
+ // Cheap pre-filter: an already-indexed file whose size AND mtime both match
2514
+ // the DB is unchanged — skip it without reading or hashing. (A content
2515
+ // change that preserves both exactly is the blind spot every mtime-based
2516
+ // incremental tool accepts; `index --force` is the escape hatch. Git bumps
2517
+ // mtime on every file it writes during checkout/merge, so pulls are caught.)
2518
+ if (tracked) {
2519
+ try {
2520
+ const stat = fs.statSync(fullPath);
2521
+ if (stat.size === tracked.size && Math.floor(stat.mtimeMs) === Math.floor(tracked.modifiedAt)) {
2522
+ continue;
2523
+ }
2524
+ }
2525
+ catch (error) {
2526
+ (0, errors_1.logDebug)('Skipping unstattable file during sync', { filePath, error: String(error) });
2527
+ continue;
2528
+ }
2529
+ }
2530
+ // New, or size/mtime changed — read + hash to confirm a real content change.
2531
+ let content;
2532
+ try {
2533
+ content = fs.readFileSync(fullPath, 'utf-8');
2534
+ }
2535
+ catch (error) {
2536
+ (0, errors_1.logDebug)('Skipping unreadable file during sync', { filePath, error: String(error) });
2537
+ continue;
2538
+ }
2539
+ const contentHash = hashContent(content);
2540
+ if (!tracked) {
2541
+ filesToIndex.push(filePath);
2542
+ changedFilePaths.push(filePath);
2543
+ filesAdded++;
2544
+ }
2545
+ else if (tracked.contentHash !== contentHash) {
2546
+ filesToIndex.push(filePath);
2547
+ changedFilePaths.push(filePath);
2548
+ filesModified++;
2549
+ }
2550
+ }
2551
+ // Sampled here — after the add/modify classification, before any file is
2552
+ // re-extracted — because `storeExtractionResult` deletes a file's nodes
2553
+ // before inserting the new ones, so this is the last point the pre-edit
2554
+ // definition set is readable (CG-33).
2555
+ if (filesToIndex.length > 0) {
2556
+ for (const pair of this.queries.getNodeNamePairsByFiles(filesToIndex))
2557
+ pairsBefore.add(pair);
2558
+ }
2559
+ // Load only grammars needed for changed files
2560
+ if (filesToIndex.length > 0) {
2561
+ const overrides = (0, project_config_1.loadExtensionOverrides)(this.rootDir);
2562
+ const neededLanguages = [...new Set(filesToIndex.map((f) => (0, grammars_1.detectLanguage)(f, undefined, overrides)))];
2563
+ // .h files default to 'c' but may be C++ — ensure cpp grammar is loaded
2564
+ if (neededLanguages.includes('c') && !neededLanguages.includes('cpp')) {
2565
+ neededLanguages.push('cpp');
2566
+ }
2567
+ await (0, grammars_1.loadGrammarsForLanguages)(neededLanguages);
2568
+ }
2569
+ // Index changed files
2570
+ const total = filesToIndex.length;
2571
+ for (let i = 0; i < filesToIndex.length; i++) {
2572
+ const filePath = filesToIndex[i];
2573
+ onProgress?.({
2574
+ phase: 'parsing',
2575
+ current: i + 1,
2576
+ total,
2577
+ currentFile: filePath,
2578
+ });
2579
+ const result = await this.indexFile(filePath);
2580
+ nodesUpdated += result.nodes.length;
2581
+ }
2582
+ // Names whose definition set this sync changed: a `file\0name` pair present
2583
+ // before but not after (removed/renamed away) or after but not before
2584
+ // (added). A pair on both sides is untouched as far as resolution's
2585
+ // candidate set is concerned — only its node id moved, which
2586
+ // reattachCrossFileEdges already follows — so an edit that only changes
2587
+ // bodies yields an empty delta and no downstream rebind work (CG-33).
2588
+ //
2589
+ // Compared per FILE, not as one name set over the whole batch: a commit
2590
+ // that adds `collect` to a new file while an unrelated changed file already
2591
+ // defined `collect` must still flag the name, and a bare name set cancels
2592
+ // exactly that case out. That miss left the largest residual class in the
2593
+ // first measurement of this fix.
2594
+ const pairsAfter = this.queries.getNodeNamePairsByFiles(filesToIndex);
2595
+ const deltaNames = new Set();
2596
+ const nameOf = (pair) => pair.slice(pair.indexOf('\0') + 1);
2597
+ for (const pair of pairsBefore)
2598
+ if (!pairsAfter.has(pair))
2599
+ deltaNames.add(nameOf(pair));
2600
+ for (const pair of pairsAfter)
2601
+ if (!pairsBefore.has(pair))
2602
+ deltaNames.add(nameOf(pair));
2603
+ const definitionDelta = [...deltaNames];
2604
+ return {
2605
+ filesChecked,
2606
+ filesAdded,
2607
+ filesModified,
2608
+ filesRemoved,
2609
+ nodesUpdated,
2610
+ durationMs: Date.now() - startTime,
2611
+ changedFilePaths: changedFilePaths.length > 0 ? changedFilePaths : undefined,
2612
+ definitionDelta: definitionDelta.length > 0 ? definitionDelta : undefined,
2613
+ };
2614
+ }
2615
+ /**
2616
+ * Get files that have changed since last index.
2617
+ * Uses git status as a fast path when available, falling back to full scan.
2618
+ */
2619
+ getChangedFiles() {
2620
+ const gitChanges = getGitChangedFiles(this.rootDir);
2621
+ if (gitChanges) {
2622
+ // === Git fast path ===
2623
+ const added = [];
2624
+ const modified = [];
2625
+ const removed = [];
2626
+ // Deleted files — only report if tracked in DB
2627
+ for (const filePath of gitChanges.deleted) {
2628
+ const tracked = this.queries.getFileByPath(filePath);
2629
+ if (tracked) {
2630
+ removed.push(filePath);
2631
+ }
2632
+ }
2633
+ // Modified + added files — read + hash, compare with DB. Untracked (`??`)
2634
+ // files stay untracked in git even after indexing, so they must be
2635
+ // hash-compared like modified files instead of always counting as added —
2636
+ // otherwise status reports them as pending forever. (See issue #206.)
2637
+ for (const filePath of [...gitChanges.modified, ...gitChanges.added]) {
2638
+ const fullPath = path.join(this.rootDir, filePath);
2639
+ let content;
2640
+ try {
2641
+ content = fs.readFileSync(fullPath, 'utf-8');
2642
+ }
2643
+ catch (error) {
2644
+ (0, errors_1.logDebug)('Skipping unreadable file while detecting changes', { filePath, error: String(error) });
2645
+ continue;
2646
+ }
2647
+ const contentHash = hashContent(content);
2648
+ const tracked = this.queries.getFileByPath(filePath);
2649
+ if (!tracked) {
2650
+ added.push(filePath);
2651
+ }
2652
+ else if (tracked.contentHash !== contentHash) {
2653
+ modified.push(filePath);
2654
+ }
2655
+ }
2656
+ return { added, modified, removed };
2657
+ }
2658
+ // === Fallback: full scan (non-git project or git failure) ===
2659
+ const currentFiles = new Set(scanDirectory(this.rootDir));
2660
+ const trackedFiles = this.queries.getAllFiles();
2661
+ // Build Map for O(1) lookups
2662
+ const trackedMap = new Map();
2663
+ for (const f of trackedFiles) {
2664
+ trackedMap.set(f.path, f);
2665
+ }
2666
+ const added = [];
2667
+ const modified = [];
2668
+ const removed = [];
2669
+ // Find removed files
2670
+ for (const tracked of trackedFiles) {
2671
+ if (!currentFiles.has(tracked.path)) {
2672
+ removed.push(tracked.path);
2673
+ }
2674
+ }
2675
+ // Find added and modified files
2676
+ for (const filePath of currentFiles) {
2677
+ const fullPath = path.join(this.rootDir, filePath);
2678
+ let content;
2679
+ try {
2680
+ content = fs.readFileSync(fullPath, 'utf-8');
2681
+ }
2682
+ catch (error) {
2683
+ (0, errors_1.logDebug)('Skipping unreadable file while detecting changes', { filePath, error: String(error) });
2684
+ continue;
2685
+ }
2686
+ const contentHash = hashContent(content);
2687
+ const tracked = trackedMap.get(filePath);
2688
+ if (!tracked) {
2689
+ added.push(filePath);
2690
+ }
2691
+ else if (tracked.contentHash !== contentHash) {
2692
+ modified.push(filePath);
2693
+ }
2694
+ }
2695
+ return { added, modified, removed };
2696
+ }
2697
+ }
2698
+ exports.ExtractionOrchestrator = ExtractionOrchestrator;
2699
+ // Re-export useful types and functions
2700
+ var tree_sitter_2 = require("./tree-sitter");
2701
+ Object.defineProperty(exports, "extractFromSource", { enumerable: true, get: function () { return tree_sitter_2.extractFromSource; } });
2702
+ var grammars_2 = require("./grammars");
2703
+ Object.defineProperty(exports, "detectLanguage", { enumerable: true, get: function () { return grammars_2.detectLanguage; } });
2704
+ Object.defineProperty(exports, "isSourceFile", { enumerable: true, get: function () { return grammars_2.isSourceFile; } });
2705
+ Object.defineProperty(exports, "isLanguageSupported", { enumerable: true, get: function () { return grammars_2.isLanguageSupported; } });
2706
+ Object.defineProperty(exports, "isGrammarLoaded", { enumerable: true, get: function () { return grammars_2.isGrammarLoaded; } });
2707
+ Object.defineProperty(exports, "getSupportedLanguages", { enumerable: true, get: function () { return grammars_2.getSupportedLanguages; } });
2708
+ Object.defineProperty(exports, "initGrammars", { enumerable: true, get: function () { return grammars_2.initGrammars; } });
2709
+ Object.defineProperty(exports, "loadGrammarsForLanguages", { enumerable: true, get: function () { return grammars_2.loadGrammarsForLanguages; } });
2710
+ Object.defineProperty(exports, "loadAllGrammars", { enumerable: true, get: function () { return grammars_2.loadAllGrammars; } });
2711
+ //# sourceMappingURL=index.js.map