@aroman22/codegraph-vba-darwin-arm64 1.3.3

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 (800) hide show
  1. package/bin/codegraph +14 -0
  2. package/lib/dist/bin/codegraph.d.ts +26 -0
  3. package/lib/dist/bin/codegraph.d.ts.map +1 -0
  4. package/lib/dist/bin/codegraph.js +2018 -0
  5. package/lib/dist/bin/codegraph.js.map +1 -0
  6. package/lib/dist/bin/command-supervision.d.ts +12 -0
  7. package/lib/dist/bin/command-supervision.d.ts.map +1 -0
  8. package/lib/dist/bin/command-supervision.js +76 -0
  9. package/lib/dist/bin/command-supervision.js.map +1 -0
  10. package/lib/dist/bin/fatal-handler.d.ts +20 -0
  11. package/lib/dist/bin/fatal-handler.d.ts.map +1 -0
  12. package/lib/dist/bin/fatal-handler.js +118 -0
  13. package/lib/dist/bin/fatal-handler.js.map +1 -0
  14. package/lib/dist/bin/node-version-check.d.ts +37 -0
  15. package/lib/dist/bin/node-version-check.d.ts.map +1 -0
  16. package/lib/dist/bin/node-version-check.js +79 -0
  17. package/lib/dist/bin/node-version-check.js.map +1 -0
  18. package/lib/dist/bin/uninstall.d.ts +14 -0
  19. package/lib/dist/bin/uninstall.d.ts.map +1 -0
  20. package/lib/dist/bin/uninstall.js +36 -0
  21. package/lib/dist/bin/uninstall.js.map +1 -0
  22. package/lib/dist/context/formatter.d.ts +30 -0
  23. package/lib/dist/context/formatter.d.ts.map +1 -0
  24. package/lib/dist/context/formatter.js +263 -0
  25. package/lib/dist/context/formatter.js.map +1 -0
  26. package/lib/dist/context/index.d.ts +119 -0
  27. package/lib/dist/context/index.d.ts.map +1 -0
  28. package/lib/dist/context/index.js +1296 -0
  29. package/lib/dist/context/index.js.map +1 -0
  30. package/lib/dist/context/markers.d.ts +19 -0
  31. package/lib/dist/context/markers.d.ts.map +1 -0
  32. package/lib/dist/context/markers.js +22 -0
  33. package/lib/dist/context/markers.js.map +1 -0
  34. package/lib/dist/db/index.d.ts +122 -0
  35. package/lib/dist/db/index.d.ts.map +1 -0
  36. package/lib/dist/db/index.js +296 -0
  37. package/lib/dist/db/index.js.map +1 -0
  38. package/lib/dist/db/migrations.d.ts +44 -0
  39. package/lib/dist/db/migrations.d.ts.map +1 -0
  40. package/lib/dist/db/migrations.js +140 -0
  41. package/lib/dist/db/migrations.js.map +1 -0
  42. package/lib/dist/db/queries.d.ts +402 -0
  43. package/lib/dist/db/queries.d.ts.map +1 -0
  44. package/lib/dist/db/queries.js +1626 -0
  45. package/lib/dist/db/queries.js.map +1 -0
  46. package/lib/dist/db/schema.sql +152 -0
  47. package/lib/dist/db/sqlite-adapter.d.ts +53 -0
  48. package/lib/dist/db/sqlite-adapter.d.ts.map +1 -0
  49. package/lib/dist/db/sqlite-adapter.js +117 -0
  50. package/lib/dist/db/sqlite-adapter.js.map +1 -0
  51. package/lib/dist/directory.d.ts +179 -0
  52. package/lib/dist/directory.d.ts.map +1 -0
  53. package/lib/dist/directory.js +625 -0
  54. package/lib/dist/directory.js.map +1 -0
  55. package/lib/dist/errors.d.ts +136 -0
  56. package/lib/dist/errors.d.ts.map +1 -0
  57. package/lib/dist/errors.js +219 -0
  58. package/lib/dist/errors.js.map +1 -0
  59. package/lib/dist/extraction/astro-extractor.d.ts +79 -0
  60. package/lib/dist/extraction/astro-extractor.d.ts.map +1 -0
  61. package/lib/dist/extraction/astro-extractor.js +320 -0
  62. package/lib/dist/extraction/astro-extractor.js.map +1 -0
  63. package/lib/dist/extraction/dfm-extractor.d.ts +31 -0
  64. package/lib/dist/extraction/dfm-extractor.d.ts.map +1 -0
  65. package/lib/dist/extraction/dfm-extractor.js +151 -0
  66. package/lib/dist/extraction/dfm-extractor.js.map +1 -0
  67. package/lib/dist/extraction/extraction-version.d.ts +25 -0
  68. package/lib/dist/extraction/extraction-version.d.ts.map +1 -0
  69. package/lib/dist/extraction/extraction-version.js +28 -0
  70. package/lib/dist/extraction/extraction-version.js.map +1 -0
  71. package/lib/dist/extraction/function-ref.d.ts +118 -0
  72. package/lib/dist/extraction/function-ref.d.ts.map +1 -0
  73. package/lib/dist/extraction/function-ref.js +727 -0
  74. package/lib/dist/extraction/function-ref.js.map +1 -0
  75. package/lib/dist/extraction/generated-detection.d.ts +30 -0
  76. package/lib/dist/extraction/generated-detection.d.ts.map +1 -0
  77. package/lib/dist/extraction/generated-detection.js +83 -0
  78. package/lib/dist/extraction/generated-detection.js.map +1 -0
  79. package/lib/dist/extraction/grammars.d.ts +128 -0
  80. package/lib/dist/extraction/grammars.d.ts.map +1 -0
  81. package/lib/dist/extraction/grammars.js +537 -0
  82. package/lib/dist/extraction/grammars.js.map +1 -0
  83. package/lib/dist/extraction/index.d.ts +187 -0
  84. package/lib/dist/extraction/index.d.ts.map +1 -0
  85. package/lib/dist/extraction/index.js +1951 -0
  86. package/lib/dist/extraction/index.js.map +1 -0
  87. package/lib/dist/extraction/languages/c-cpp.d.ts +12 -0
  88. package/lib/dist/extraction/languages/c-cpp.d.ts.map +1 -0
  89. package/lib/dist/extraction/languages/c-cpp.js +275 -0
  90. package/lib/dist/extraction/languages/c-cpp.js.map +1 -0
  91. package/lib/dist/extraction/languages/csharp.d.ts +25 -0
  92. package/lib/dist/extraction/languages/csharp.d.ts.map +1 -0
  93. package/lib/dist/extraction/languages/csharp.js +175 -0
  94. package/lib/dist/extraction/languages/csharp.js.map +1 -0
  95. package/lib/dist/extraction/languages/dart.d.ts +3 -0
  96. package/lib/dist/extraction/languages/dart.d.ts.map +1 -0
  97. package/lib/dist/extraction/languages/dart.js +374 -0
  98. package/lib/dist/extraction/languages/dart.js.map +1 -0
  99. package/lib/dist/extraction/languages/go.d.ts +3 -0
  100. package/lib/dist/extraction/languages/go.d.ts.map +1 -0
  101. package/lib/dist/extraction/languages/go.js +111 -0
  102. package/lib/dist/extraction/languages/go.js.map +1 -0
  103. package/lib/dist/extraction/languages/index.d.ts +10 -0
  104. package/lib/dist/extraction/languages/index.d.ts.map +1 -0
  105. package/lib/dist/extraction/languages/index.js +53 -0
  106. package/lib/dist/extraction/languages/index.js.map +1 -0
  107. package/lib/dist/extraction/languages/java.d.ts +3 -0
  108. package/lib/dist/extraction/languages/java.d.ts.map +1 -0
  109. package/lib/dist/extraction/languages/java.js +315 -0
  110. package/lib/dist/extraction/languages/java.js.map +1 -0
  111. package/lib/dist/extraction/languages/javascript.d.ts +3 -0
  112. package/lib/dist/extraction/languages/javascript.d.ts.map +1 -0
  113. package/lib/dist/extraction/languages/javascript.js +106 -0
  114. package/lib/dist/extraction/languages/javascript.js.map +1 -0
  115. package/lib/dist/extraction/languages/kotlin.d.ts +3 -0
  116. package/lib/dist/extraction/languages/kotlin.d.ts.map +1 -0
  117. package/lib/dist/extraction/languages/kotlin.js +379 -0
  118. package/lib/dist/extraction/languages/kotlin.js.map +1 -0
  119. package/lib/dist/extraction/languages/lua.d.ts +3 -0
  120. package/lib/dist/extraction/languages/lua.d.ts.map +1 -0
  121. package/lib/dist/extraction/languages/lua.js +150 -0
  122. package/lib/dist/extraction/languages/lua.js.map +1 -0
  123. package/lib/dist/extraction/languages/luau.d.ts +3 -0
  124. package/lib/dist/extraction/languages/luau.d.ts.map +1 -0
  125. package/lib/dist/extraction/languages/luau.js +37 -0
  126. package/lib/dist/extraction/languages/luau.js.map +1 -0
  127. package/lib/dist/extraction/languages/objc.d.ts +3 -0
  128. package/lib/dist/extraction/languages/objc.d.ts.map +1 -0
  129. package/lib/dist/extraction/languages/objc.js +175 -0
  130. package/lib/dist/extraction/languages/objc.js.map +1 -0
  131. package/lib/dist/extraction/languages/pascal.d.ts +3 -0
  132. package/lib/dist/extraction/languages/pascal.d.ts.map +1 -0
  133. package/lib/dist/extraction/languages/pascal.js +77 -0
  134. package/lib/dist/extraction/languages/pascal.js.map +1 -0
  135. package/lib/dist/extraction/languages/php.d.ts +3 -0
  136. package/lib/dist/extraction/languages/php.d.ts.map +1 -0
  137. package/lib/dist/extraction/languages/php.js +196 -0
  138. package/lib/dist/extraction/languages/php.js.map +1 -0
  139. package/lib/dist/extraction/languages/python.d.ts +3 -0
  140. package/lib/dist/extraction/languages/python.d.ts.map +1 -0
  141. package/lib/dist/extraction/languages/python.js +56 -0
  142. package/lib/dist/extraction/languages/python.js.map +1 -0
  143. package/lib/dist/extraction/languages/r.d.ts +3 -0
  144. package/lib/dist/extraction/languages/r.d.ts.map +1 -0
  145. package/lib/dist/extraction/languages/r.js +314 -0
  146. package/lib/dist/extraction/languages/r.js.map +1 -0
  147. package/lib/dist/extraction/languages/ruby.d.ts +3 -0
  148. package/lib/dist/extraction/languages/ruby.d.ts.map +1 -0
  149. package/lib/dist/extraction/languages/ruby.js +149 -0
  150. package/lib/dist/extraction/languages/ruby.js.map +1 -0
  151. package/lib/dist/extraction/languages/rust.d.ts +3 -0
  152. package/lib/dist/extraction/languages/rust.d.ts.map +1 -0
  153. package/lib/dist/extraction/languages/rust.js +142 -0
  154. package/lib/dist/extraction/languages/rust.js.map +1 -0
  155. package/lib/dist/extraction/languages/scala.d.ts +3 -0
  156. package/lib/dist/extraction/languages/scala.d.ts.map +1 -0
  157. package/lib/dist/extraction/languages/scala.js +209 -0
  158. package/lib/dist/extraction/languages/scala.js.map +1 -0
  159. package/lib/dist/extraction/languages/swift.d.ts +3 -0
  160. package/lib/dist/extraction/languages/swift.d.ts.map +1 -0
  161. package/lib/dist/extraction/languages/swift.js +152 -0
  162. package/lib/dist/extraction/languages/swift.js.map +1 -0
  163. package/lib/dist/extraction/languages/typescript.d.ts +16 -0
  164. package/lib/dist/extraction/languages/typescript.d.ts.map +1 -0
  165. package/lib/dist/extraction/languages/typescript.js +167 -0
  166. package/lib/dist/extraction/languages/typescript.js.map +1 -0
  167. package/lib/dist/extraction/liquid-extractor.d.ts +59 -0
  168. package/lib/dist/extraction/liquid-extractor.d.ts.map +1 -0
  169. package/lib/dist/extraction/liquid-extractor.js +357 -0
  170. package/lib/dist/extraction/liquid-extractor.js.map +1 -0
  171. package/lib/dist/extraction/mybatis-extractor.d.ts +48 -0
  172. package/lib/dist/extraction/mybatis-extractor.d.ts.map +1 -0
  173. package/lib/dist/extraction/mybatis-extractor.js +198 -0
  174. package/lib/dist/extraction/mybatis-extractor.js.map +1 -0
  175. package/lib/dist/extraction/parse-pool.d.ts +126 -0
  176. package/lib/dist/extraction/parse-pool.d.ts.map +1 -0
  177. package/lib/dist/extraction/parse-pool.js +319 -0
  178. package/lib/dist/extraction/parse-pool.js.map +1 -0
  179. package/lib/dist/extraction/parse-worker.d.ts +8 -0
  180. package/lib/dist/extraction/parse-worker.d.ts.map +1 -0
  181. package/lib/dist/extraction/parse-worker.js +97 -0
  182. package/lib/dist/extraction/parse-worker.js.map +1 -0
  183. package/lib/dist/extraction/razor-extractor.d.ts +42 -0
  184. package/lib/dist/extraction/razor-extractor.d.ts.map +1 -0
  185. package/lib/dist/extraction/razor-extractor.js +285 -0
  186. package/lib/dist/extraction/razor-extractor.js.map +1 -0
  187. package/lib/dist/extraction/sql-query-extractor.d.ts +25 -0
  188. package/lib/dist/extraction/sql-query-extractor.d.ts.map +1 -0
  189. package/lib/dist/extraction/sql-query-extractor.js +177 -0
  190. package/lib/dist/extraction/sql-query-extractor.js.map +1 -0
  191. package/lib/dist/extraction/svelte-extractor.d.ts +56 -0
  192. package/lib/dist/extraction/svelte-extractor.d.ts.map +1 -0
  193. package/lib/dist/extraction/svelte-extractor.js +275 -0
  194. package/lib/dist/extraction/svelte-extractor.js.map +1 -0
  195. package/lib/dist/extraction/tree-sitter-helpers.d.ts +28 -0
  196. package/lib/dist/extraction/tree-sitter-helpers.d.ts.map +1 -0
  197. package/lib/dist/extraction/tree-sitter-helpers.js +152 -0
  198. package/lib/dist/extraction/tree-sitter-helpers.js.map +1 -0
  199. package/lib/dist/extraction/tree-sitter-types.d.ts +239 -0
  200. package/lib/dist/extraction/tree-sitter-types.d.ts.map +1 -0
  201. package/lib/dist/extraction/tree-sitter-types.js +10 -0
  202. package/lib/dist/extraction/tree-sitter-types.js.map +1 -0
  203. package/lib/dist/extraction/tree-sitter.d.ts +647 -0
  204. package/lib/dist/extraction/tree-sitter.d.ts.map +1 -0
  205. package/lib/dist/extraction/tree-sitter.js +5647 -0
  206. package/lib/dist/extraction/tree-sitter.js.map +1 -0
  207. package/lib/dist/extraction/vba-extractor.d.ts +394 -0
  208. package/lib/dist/extraction/vba-extractor.d.ts.map +1 -0
  209. package/lib/dist/extraction/vba-extractor.js +1716 -0
  210. package/lib/dist/extraction/vba-extractor.js.map +1 -0
  211. package/lib/dist/extraction/vba-form-extractor.d.ts +89 -0
  212. package/lib/dist/extraction/vba-form-extractor.d.ts.map +1 -0
  213. package/lib/dist/extraction/vba-form-extractor.js +367 -0
  214. package/lib/dist/extraction/vba-form-extractor.js.map +1 -0
  215. package/lib/dist/extraction/vba-preprocess.d.ts +81 -0
  216. package/lib/dist/extraction/vba-preprocess.d.ts.map +1 -0
  217. package/lib/dist/extraction/vba-preprocess.js +287 -0
  218. package/lib/dist/extraction/vba-preprocess.js.map +1 -0
  219. package/lib/dist/extraction/vue-extractor.d.ts +51 -0
  220. package/lib/dist/extraction/vue-extractor.d.ts.map +1 -0
  221. package/lib/dist/extraction/vue-extractor.js +254 -0
  222. package/lib/dist/extraction/vue-extractor.js.map +1 -0
  223. package/lib/dist/extraction/wasm/tree-sitter-c_sharp.wasm +0 -0
  224. package/lib/dist/extraction/wasm/tree-sitter-lua.wasm +0 -0
  225. package/lib/dist/extraction/wasm/tree-sitter-luau.wasm +0 -0
  226. package/lib/dist/extraction/wasm/tree-sitter-pascal.wasm +0 -0
  227. package/lib/dist/extraction/wasm/tree-sitter-r.wasm +0 -0
  228. package/lib/dist/extraction/wasm/tree-sitter-scala.wasm +0 -0
  229. package/lib/dist/extraction/wasm-runtime-flags.d.ts +38 -0
  230. package/lib/dist/extraction/wasm-runtime-flags.d.ts.map +1 -0
  231. package/lib/dist/extraction/wasm-runtime-flags.js +106 -0
  232. package/lib/dist/extraction/wasm-runtime-flags.js.map +1 -0
  233. package/lib/dist/graph/index.d.ts +8 -0
  234. package/lib/dist/graph/index.d.ts.map +1 -0
  235. package/lib/dist/graph/index.js +13 -0
  236. package/lib/dist/graph/index.js.map +1 -0
  237. package/lib/dist/graph/queries.d.ts +106 -0
  238. package/lib/dist/graph/queries.d.ts.map +1 -0
  239. package/lib/dist/graph/queries.js +339 -0
  240. package/lib/dist/graph/queries.js.map +1 -0
  241. package/lib/dist/graph/traversal.d.ts +127 -0
  242. package/lib/dist/graph/traversal.d.ts.map +1 -0
  243. package/lib/dist/graph/traversal.js +540 -0
  244. package/lib/dist/graph/traversal.js.map +1 -0
  245. package/lib/dist/index.d.ts +563 -0
  246. package/lib/dist/index.d.ts.map +1 -0
  247. package/lib/dist/index.js +1041 -0
  248. package/lib/dist/index.js.map +1 -0
  249. package/lib/dist/installer/config-writer.d.ts +28 -0
  250. package/lib/dist/installer/config-writer.d.ts.map +1 -0
  251. package/lib/dist/installer/config-writer.js +91 -0
  252. package/lib/dist/installer/config-writer.js.map +1 -0
  253. package/lib/dist/installer/index.d.ts +100 -0
  254. package/lib/dist/installer/index.d.ts.map +1 -0
  255. package/lib/dist/installer/index.js +524 -0
  256. package/lib/dist/installer/index.js.map +1 -0
  257. package/lib/dist/installer/instructions-template.d.ts +41 -0
  258. package/lib/dist/installer/instructions-template.d.ts.map +1 -0
  259. package/lib/dist/installer/instructions-template.js +53 -0
  260. package/lib/dist/installer/instructions-template.js.map +1 -0
  261. package/lib/dist/installer/targets/antigravity.d.ts +57 -0
  262. package/lib/dist/installer/targets/antigravity.d.ts.map +1 -0
  263. package/lib/dist/installer/targets/antigravity.js +308 -0
  264. package/lib/dist/installer/targets/antigravity.js.map +1 -0
  265. package/lib/dist/installer/targets/claude.d.ts +62 -0
  266. package/lib/dist/installer/targets/claude.d.ts.map +1 -0
  267. package/lib/dist/installer/targets/claude.js +454 -0
  268. package/lib/dist/installer/targets/claude.js.map +1 -0
  269. package/lib/dist/installer/targets/codex.d.ts +18 -0
  270. package/lib/dist/installer/targets/codex.d.ts.map +1 -0
  271. package/lib/dist/installer/targets/codex.js +185 -0
  272. package/lib/dist/installer/targets/codex.js.map +1 -0
  273. package/lib/dist/installer/targets/cursor.d.ts +35 -0
  274. package/lib/dist/installer/targets/cursor.d.ts.map +1 -0
  275. package/lib/dist/installer/targets/cursor.js +254 -0
  276. package/lib/dist/installer/targets/cursor.js.map +1 -0
  277. package/lib/dist/installer/targets/gemini.d.ts +26 -0
  278. package/lib/dist/installer/targets/gemini.d.ts.map +1 -0
  279. package/lib/dist/installer/targets/gemini.js +165 -0
  280. package/lib/dist/installer/targets/gemini.js.map +1 -0
  281. package/lib/dist/installer/targets/hermes.d.ts +18 -0
  282. package/lib/dist/installer/targets/hermes.d.ts.map +1 -0
  283. package/lib/dist/installer/targets/hermes.js +359 -0
  284. package/lib/dist/installer/targets/hermes.js.map +1 -0
  285. package/lib/dist/installer/targets/kiro.d.ts +27 -0
  286. package/lib/dist/installer/targets/kiro.d.ts.map +1 -0
  287. package/lib/dist/installer/targets/kiro.js +178 -0
  288. package/lib/dist/installer/targets/kiro.js.map +1 -0
  289. package/lib/dist/installer/targets/opencode.d.ts +38 -0
  290. package/lib/dist/installer/targets/opencode.d.ts.map +1 -0
  291. package/lib/dist/installer/targets/opencode.js +307 -0
  292. package/lib/dist/installer/targets/opencode.js.map +1 -0
  293. package/lib/dist/installer/targets/registry.d.ts +35 -0
  294. package/lib/dist/installer/targets/registry.d.ts.map +1 -0
  295. package/lib/dist/installer/targets/registry.js +91 -0
  296. package/lib/dist/installer/targets/registry.js.map +1 -0
  297. package/lib/dist/installer/targets/shared.d.ts +101 -0
  298. package/lib/dist/installer/targets/shared.d.ts.map +1 -0
  299. package/lib/dist/installer/targets/shared.js +264 -0
  300. package/lib/dist/installer/targets/shared.js.map +1 -0
  301. package/lib/dist/installer/targets/toml.d.ts +52 -0
  302. package/lib/dist/installer/targets/toml.d.ts.map +1 -0
  303. package/lib/dist/installer/targets/toml.js +147 -0
  304. package/lib/dist/installer/targets/toml.js.map +1 -0
  305. package/lib/dist/installer/targets/types.d.ts +108 -0
  306. package/lib/dist/installer/targets/types.d.ts.map +1 -0
  307. package/lib/dist/installer/targets/types.js +16 -0
  308. package/lib/dist/installer/targets/types.js.map +1 -0
  309. package/lib/dist/mcp/daemon-manager.d.ts +42 -0
  310. package/lib/dist/mcp/daemon-manager.d.ts.map +1 -0
  311. package/lib/dist/mcp/daemon-manager.js +129 -0
  312. package/lib/dist/mcp/daemon-manager.js.map +1 -0
  313. package/lib/dist/mcp/daemon-paths.d.ts +73 -0
  314. package/lib/dist/mcp/daemon-paths.d.ts.map +1 -0
  315. package/lib/dist/mcp/daemon-paths.js +165 -0
  316. package/lib/dist/mcp/daemon-paths.js.map +1 -0
  317. package/lib/dist/mcp/daemon-registry.d.ts +47 -0
  318. package/lib/dist/mcp/daemon-registry.d.ts.map +1 -0
  319. package/lib/dist/mcp/daemon-registry.js +233 -0
  320. package/lib/dist/mcp/daemon-registry.js.map +1 -0
  321. package/lib/dist/mcp/daemon.d.ts +258 -0
  322. package/lib/dist/mcp/daemon.d.ts.map +1 -0
  323. package/lib/dist/mcp/daemon.js +770 -0
  324. package/lib/dist/mcp/daemon.js.map +1 -0
  325. package/lib/dist/mcp/dynamic-boundaries.d.ts +41 -0
  326. package/lib/dist/mcp/dynamic-boundaries.d.ts.map +1 -0
  327. package/lib/dist/mcp/dynamic-boundaries.js +359 -0
  328. package/lib/dist/mcp/dynamic-boundaries.js.map +1 -0
  329. package/lib/dist/mcp/engine.d.ts +122 -0
  330. package/lib/dist/mcp/engine.d.ts.map +1 -0
  331. package/lib/dist/mcp/engine.js +350 -0
  332. package/lib/dist/mcp/engine.js.map +1 -0
  333. package/lib/dist/mcp/index.d.ts +113 -0
  334. package/lib/dist/mcp/index.d.ts.map +1 -0
  335. package/lib/dist/mcp/index.js +481 -0
  336. package/lib/dist/mcp/index.js.map +1 -0
  337. package/lib/dist/mcp/liveness-watchdog.d.ts +18 -0
  338. package/lib/dist/mcp/liveness-watchdog.d.ts.map +1 -0
  339. package/lib/dist/mcp/liveness-watchdog.js +207 -0
  340. package/lib/dist/mcp/liveness-watchdog.js.map +1 -0
  341. package/lib/dist/mcp/ppid-watchdog.d.ts +62 -0
  342. package/lib/dist/mcp/ppid-watchdog.d.ts.map +1 -0
  343. package/lib/dist/mcp/ppid-watchdog.js +64 -0
  344. package/lib/dist/mcp/ppid-watchdog.js.map +1 -0
  345. package/lib/dist/mcp/proxy.d.ts +87 -0
  346. package/lib/dist/mcp/proxy.d.ts.map +1 -0
  347. package/lib/dist/mcp/proxy.js +641 -0
  348. package/lib/dist/mcp/proxy.js.map +1 -0
  349. package/lib/dist/mcp/query-pool.d.ts +94 -0
  350. package/lib/dist/mcp/query-pool.d.ts.map +1 -0
  351. package/lib/dist/mcp/query-pool.js +297 -0
  352. package/lib/dist/mcp/query-pool.js.map +1 -0
  353. package/lib/dist/mcp/query-worker.d.ts +24 -0
  354. package/lib/dist/mcp/query-worker.d.ts.map +1 -0
  355. package/lib/dist/mcp/query-worker.js +87 -0
  356. package/lib/dist/mcp/query-worker.js.map +1 -0
  357. package/lib/dist/mcp/server-instructions.d.ts +34 -0
  358. package/lib/dist/mcp/server-instructions.d.ts.map +1 -0
  359. package/lib/dist/mcp/server-instructions.js +126 -0
  360. package/lib/dist/mcp/server-instructions.js.map +1 -0
  361. package/lib/dist/mcp/session.d.ts +79 -0
  362. package/lib/dist/mcp/session.d.ts.map +1 -0
  363. package/lib/dist/mcp/session.js +330 -0
  364. package/lib/dist/mcp/session.js.map +1 -0
  365. package/lib/dist/mcp/stdin-teardown.d.ts +27 -0
  366. package/lib/dist/mcp/stdin-teardown.d.ts.map +1 -0
  367. package/lib/dist/mcp/stdin-teardown.js +49 -0
  368. package/lib/dist/mcp/stdin-teardown.js.map +1 -0
  369. package/lib/dist/mcp/tools.d.ts +591 -0
  370. package/lib/dist/mcp/tools.d.ts.map +1 -0
  371. package/lib/dist/mcp/tools.js +4211 -0
  372. package/lib/dist/mcp/tools.js.map +1 -0
  373. package/lib/dist/mcp/transport.d.ts +188 -0
  374. package/lib/dist/mcp/transport.d.ts.map +1 -0
  375. package/lib/dist/mcp/transport.js +359 -0
  376. package/lib/dist/mcp/transport.js.map +1 -0
  377. package/lib/dist/mcp/version.d.ts +19 -0
  378. package/lib/dist/mcp/version.d.ts.map +1 -0
  379. package/lib/dist/mcp/version.js +71 -0
  380. package/lib/dist/mcp/version.js.map +1 -0
  381. package/lib/dist/project-config.d.ts +56 -0
  382. package/lib/dist/project-config.d.ts.map +1 -0
  383. package/lib/dist/project-config.js +297 -0
  384. package/lib/dist/project-config.js.map +1 -0
  385. package/lib/dist/reasoning/config.d.ts +45 -0
  386. package/lib/dist/reasoning/config.d.ts.map +1 -0
  387. package/lib/dist/reasoning/config.js +171 -0
  388. package/lib/dist/reasoning/config.js.map +1 -0
  389. package/lib/dist/reasoning/credentials.d.ts +5 -0
  390. package/lib/dist/reasoning/credentials.d.ts.map +1 -0
  391. package/lib/dist/reasoning/credentials.js +83 -0
  392. package/lib/dist/reasoning/credentials.js.map +1 -0
  393. package/lib/dist/reasoning/login.d.ts +21 -0
  394. package/lib/dist/reasoning/login.d.ts.map +1 -0
  395. package/lib/dist/reasoning/login.js +85 -0
  396. package/lib/dist/reasoning/login.js.map +1 -0
  397. package/lib/dist/reasoning/reasoner.d.ts +43 -0
  398. package/lib/dist/reasoning/reasoner.d.ts.map +1 -0
  399. package/lib/dist/reasoning/reasoner.js +308 -0
  400. package/lib/dist/reasoning/reasoner.js.map +1 -0
  401. package/lib/dist/resolution/c-fnptr-synthesizer.d.ts +5 -0
  402. package/lib/dist/resolution/c-fnptr-synthesizer.d.ts.map +1 -0
  403. package/lib/dist/resolution/c-fnptr-synthesizer.js +1038 -0
  404. package/lib/dist/resolution/c-fnptr-synthesizer.js.map +1 -0
  405. package/lib/dist/resolution/callback-synthesizer.d.ts +15 -0
  406. package/lib/dist/resolution/callback-synthesizer.d.ts.map +1 -0
  407. package/lib/dist/resolution/callback-synthesizer.js +2926 -0
  408. package/lib/dist/resolution/callback-synthesizer.js.map +1 -0
  409. package/lib/dist/resolution/frameworks/astro.d.ts +9 -0
  410. package/lib/dist/resolution/frameworks/astro.d.ts.map +1 -0
  411. package/lib/dist/resolution/frameworks/astro.js +169 -0
  412. package/lib/dist/resolution/frameworks/astro.js.map +1 -0
  413. package/lib/dist/resolution/frameworks/cargo-workspace.d.ts +18 -0
  414. package/lib/dist/resolution/frameworks/cargo-workspace.d.ts.map +1 -0
  415. package/lib/dist/resolution/frameworks/cargo-workspace.js +225 -0
  416. package/lib/dist/resolution/frameworks/cargo-workspace.js.map +1 -0
  417. package/lib/dist/resolution/frameworks/csharp.d.ts +8 -0
  418. package/lib/dist/resolution/frameworks/csharp.d.ts.map +1 -0
  419. package/lib/dist/resolution/frameworks/csharp.js +241 -0
  420. package/lib/dist/resolution/frameworks/csharp.js.map +1 -0
  421. package/lib/dist/resolution/frameworks/drupal.d.ts +51 -0
  422. package/lib/dist/resolution/frameworks/drupal.d.ts.map +1 -0
  423. package/lib/dist/resolution/frameworks/drupal.js +367 -0
  424. package/lib/dist/resolution/frameworks/drupal.js.map +1 -0
  425. package/lib/dist/resolution/frameworks/expo-modules.d.ts +3 -0
  426. package/lib/dist/resolution/frameworks/expo-modules.d.ts.map +1 -0
  427. package/lib/dist/resolution/frameworks/expo-modules.js +148 -0
  428. package/lib/dist/resolution/frameworks/expo-modules.js.map +1 -0
  429. package/lib/dist/resolution/frameworks/express.d.ts +8 -0
  430. package/lib/dist/resolution/frameworks/express.d.ts.map +1 -0
  431. package/lib/dist/resolution/frameworks/express.js +308 -0
  432. package/lib/dist/resolution/frameworks/express.js.map +1 -0
  433. package/lib/dist/resolution/frameworks/fabric.d.ts +3 -0
  434. package/lib/dist/resolution/frameworks/fabric.d.ts.map +1 -0
  435. package/lib/dist/resolution/frameworks/fabric.js +354 -0
  436. package/lib/dist/resolution/frameworks/fabric.js.map +1 -0
  437. package/lib/dist/resolution/frameworks/go.d.ts +8 -0
  438. package/lib/dist/resolution/frameworks/go.d.ts.map +1 -0
  439. package/lib/dist/resolution/frameworks/go.js +161 -0
  440. package/lib/dist/resolution/frameworks/go.js.map +1 -0
  441. package/lib/dist/resolution/frameworks/goframe.d.ts +41 -0
  442. package/lib/dist/resolution/frameworks/goframe.d.ts.map +1 -0
  443. package/lib/dist/resolution/frameworks/goframe.js +112 -0
  444. package/lib/dist/resolution/frameworks/goframe.js.map +1 -0
  445. package/lib/dist/resolution/frameworks/index.d.ts +50 -0
  446. package/lib/dist/resolution/frameworks/index.d.ts.map +1 -0
  447. package/lib/dist/resolution/frameworks/index.js +169 -0
  448. package/lib/dist/resolution/frameworks/index.js.map +1 -0
  449. package/lib/dist/resolution/frameworks/java.d.ts +8 -0
  450. package/lib/dist/resolution/frameworks/java.d.ts.map +1 -0
  451. package/lib/dist/resolution/frameworks/java.js +509 -0
  452. package/lib/dist/resolution/frameworks/java.js.map +1 -0
  453. package/lib/dist/resolution/frameworks/laravel.d.ts +13 -0
  454. package/lib/dist/resolution/frameworks/laravel.d.ts.map +1 -0
  455. package/lib/dist/resolution/frameworks/laravel.js +257 -0
  456. package/lib/dist/resolution/frameworks/laravel.js.map +1 -0
  457. package/lib/dist/resolution/frameworks/nestjs.d.ts +26 -0
  458. package/lib/dist/resolution/frameworks/nestjs.d.ts.map +1 -0
  459. package/lib/dist/resolution/frameworks/nestjs.js +698 -0
  460. package/lib/dist/resolution/frameworks/nestjs.js.map +1 -0
  461. package/lib/dist/resolution/frameworks/play.d.ts +19 -0
  462. package/lib/dist/resolution/frameworks/play.d.ts.map +1 -0
  463. package/lib/dist/resolution/frameworks/play.js +111 -0
  464. package/lib/dist/resolution/frameworks/play.js.map +1 -0
  465. package/lib/dist/resolution/frameworks/python.d.ts +10 -0
  466. package/lib/dist/resolution/frameworks/python.d.ts.map +1 -0
  467. package/lib/dist/resolution/frameworks/python.js +400 -0
  468. package/lib/dist/resolution/frameworks/python.js.map +1 -0
  469. package/lib/dist/resolution/frameworks/react-native.d.ts +3 -0
  470. package/lib/dist/resolution/frameworks/react-native.d.ts.map +1 -0
  471. package/lib/dist/resolution/frameworks/react-native.js +410 -0
  472. package/lib/dist/resolution/frameworks/react-native.js.map +1 -0
  473. package/lib/dist/resolution/frameworks/react.d.ts +8 -0
  474. package/lib/dist/resolution/frameworks/react.d.ts.map +1 -0
  475. package/lib/dist/resolution/frameworks/react.js +334 -0
  476. package/lib/dist/resolution/frameworks/react.js.map +1 -0
  477. package/lib/dist/resolution/frameworks/ruby.d.ts +8 -0
  478. package/lib/dist/resolution/frameworks/ruby.d.ts.map +1 -0
  479. package/lib/dist/resolution/frameworks/ruby.js +302 -0
  480. package/lib/dist/resolution/frameworks/ruby.js.map +1 -0
  481. package/lib/dist/resolution/frameworks/rust.d.ts +8 -0
  482. package/lib/dist/resolution/frameworks/rust.d.ts.map +1 -0
  483. package/lib/dist/resolution/frameworks/rust.js +304 -0
  484. package/lib/dist/resolution/frameworks/rust.js.map +1 -0
  485. package/lib/dist/resolution/frameworks/svelte.d.ts +9 -0
  486. package/lib/dist/resolution/frameworks/svelte.d.ts.map +1 -0
  487. package/lib/dist/resolution/frameworks/svelte.js +253 -0
  488. package/lib/dist/resolution/frameworks/svelte.js.map +1 -0
  489. package/lib/dist/resolution/frameworks/swift-objc.d.ts +37 -0
  490. package/lib/dist/resolution/frameworks/swift-objc.d.ts.map +1 -0
  491. package/lib/dist/resolution/frameworks/swift-objc.js +252 -0
  492. package/lib/dist/resolution/frameworks/swift-objc.js.map +1 -0
  493. package/lib/dist/resolution/frameworks/swift.d.ts +10 -0
  494. package/lib/dist/resolution/frameworks/swift.d.ts.map +1 -0
  495. package/lib/dist/resolution/frameworks/swift.js +400 -0
  496. package/lib/dist/resolution/frameworks/swift.js.map +1 -0
  497. package/lib/dist/resolution/frameworks/vue.d.ts +9 -0
  498. package/lib/dist/resolution/frameworks/vue.d.ts.map +1 -0
  499. package/lib/dist/resolution/frameworks/vue.js +303 -0
  500. package/lib/dist/resolution/frameworks/vue.js.map +1 -0
  501. package/lib/dist/resolution/go-module.d.ts +26 -0
  502. package/lib/dist/resolution/go-module.d.ts.map +1 -0
  503. package/lib/dist/resolution/go-module.js +78 -0
  504. package/lib/dist/resolution/go-module.js.map +1 -0
  505. package/lib/dist/resolution/goframe-synthesizer.d.ts +28 -0
  506. package/lib/dist/resolution/goframe-synthesizer.d.ts.map +1 -0
  507. package/lib/dist/resolution/goframe-synthesizer.js +158 -0
  508. package/lib/dist/resolution/goframe-synthesizer.js.map +1 -0
  509. package/lib/dist/resolution/import-resolver.d.ts +78 -0
  510. package/lib/dist/resolution/import-resolver.d.ts.map +1 -0
  511. package/lib/dist/resolution/import-resolver.js +1849 -0
  512. package/lib/dist/resolution/import-resolver.js.map +1 -0
  513. package/lib/dist/resolution/index.d.ts +196 -0
  514. package/lib/dist/resolution/index.d.ts.map +1 -0
  515. package/lib/dist/resolution/index.js +1328 -0
  516. package/lib/dist/resolution/index.js.map +1 -0
  517. package/lib/dist/resolution/lru-cache.d.ts +24 -0
  518. package/lib/dist/resolution/lru-cache.d.ts.map +1 -0
  519. package/lib/dist/resolution/lru-cache.js +62 -0
  520. package/lib/dist/resolution/lru-cache.js.map +1 -0
  521. package/lib/dist/resolution/name-matcher.d.ts +93 -0
  522. package/lib/dist/resolution/name-matcher.d.ts.map +1 -0
  523. package/lib/dist/resolution/name-matcher.js +1256 -0
  524. package/lib/dist/resolution/name-matcher.js.map +1 -0
  525. package/lib/dist/resolution/path-aliases.d.ts +68 -0
  526. package/lib/dist/resolution/path-aliases.d.ts.map +1 -0
  527. package/lib/dist/resolution/path-aliases.js +238 -0
  528. package/lib/dist/resolution/path-aliases.js.map +1 -0
  529. package/lib/dist/resolution/strip-comments.d.ts +27 -0
  530. package/lib/dist/resolution/strip-comments.d.ts.map +1 -0
  531. package/lib/dist/resolution/strip-comments.js +443 -0
  532. package/lib/dist/resolution/strip-comments.js.map +1 -0
  533. package/lib/dist/resolution/swift-objc-bridge.d.ts +134 -0
  534. package/lib/dist/resolution/swift-objc-bridge.d.ts.map +1 -0
  535. package/lib/dist/resolution/swift-objc-bridge.js +256 -0
  536. package/lib/dist/resolution/swift-objc-bridge.js.map +1 -0
  537. package/lib/dist/resolution/types.d.ts +233 -0
  538. package/lib/dist/resolution/types.d.ts.map +1 -0
  539. package/lib/dist/resolution/types.js +8 -0
  540. package/lib/dist/resolution/types.js.map +1 -0
  541. package/lib/dist/resolution/workspace-packages.d.ts +48 -0
  542. package/lib/dist/resolution/workspace-packages.d.ts.map +1 -0
  543. package/lib/dist/resolution/workspace-packages.js +208 -0
  544. package/lib/dist/resolution/workspace-packages.js.map +1 -0
  545. package/lib/dist/search/query-parser.d.ts +57 -0
  546. package/lib/dist/search/query-parser.d.ts.map +1 -0
  547. package/lib/dist/search/query-parser.js +177 -0
  548. package/lib/dist/search/query-parser.js.map +1 -0
  549. package/lib/dist/search/query-utils.d.ts +87 -0
  550. package/lib/dist/search/query-utils.d.ts.map +1 -0
  551. package/lib/dist/search/query-utils.js +449 -0
  552. package/lib/dist/search/query-utils.js.map +1 -0
  553. package/lib/dist/sync/git-hooks.d.ts +45 -0
  554. package/lib/dist/sync/git-hooks.d.ts.map +1 -0
  555. package/lib/dist/sync/git-hooks.js +225 -0
  556. package/lib/dist/sync/git-hooks.js.map +1 -0
  557. package/lib/dist/sync/index.d.ts +19 -0
  558. package/lib/dist/sync/index.d.ts.map +1 -0
  559. package/lib/dist/sync/index.js +35 -0
  560. package/lib/dist/sync/index.js.map +1 -0
  561. package/lib/dist/sync/watch-policy.d.ts +48 -0
  562. package/lib/dist/sync/watch-policy.d.ts.map +1 -0
  563. package/lib/dist/sync/watch-policy.js +124 -0
  564. package/lib/dist/sync/watch-policy.js.map +1 -0
  565. package/lib/dist/sync/watcher.d.ts +358 -0
  566. package/lib/dist/sync/watcher.d.ts.map +1 -0
  567. package/lib/dist/sync/watcher.js +829 -0
  568. package/lib/dist/sync/watcher.js.map +1 -0
  569. package/lib/dist/sync/worktree.d.ts +54 -0
  570. package/lib/dist/sync/worktree.d.ts.map +1 -0
  571. package/lib/dist/sync/worktree.js +145 -0
  572. package/lib/dist/sync/worktree.js.map +1 -0
  573. package/lib/dist/telemetry/index.d.ts +143 -0
  574. package/lib/dist/telemetry/index.d.ts.map +1 -0
  575. package/lib/dist/telemetry/index.js +541 -0
  576. package/lib/dist/telemetry/index.js.map +1 -0
  577. package/lib/dist/types.d.ts +409 -0
  578. package/lib/dist/types.d.ts.map +1 -0
  579. package/lib/dist/types.js +101 -0
  580. package/lib/dist/types.js.map +1 -0
  581. package/lib/dist/ui/glyphs.d.ts +42 -0
  582. package/lib/dist/ui/glyphs.d.ts.map +1 -0
  583. package/lib/dist/ui/glyphs.js +78 -0
  584. package/lib/dist/ui/glyphs.js.map +1 -0
  585. package/lib/dist/ui/shimmer-progress.d.ts +11 -0
  586. package/lib/dist/ui/shimmer-progress.d.ts.map +1 -0
  587. package/lib/dist/ui/shimmer-progress.js +90 -0
  588. package/lib/dist/ui/shimmer-progress.js.map +1 -0
  589. package/lib/dist/ui/shimmer-worker.d.ts +2 -0
  590. package/lib/dist/ui/shimmer-worker.d.ts.map +1 -0
  591. package/lib/dist/ui/shimmer-worker.js +118 -0
  592. package/lib/dist/ui/shimmer-worker.js.map +1 -0
  593. package/lib/dist/ui/types.d.ts +17 -0
  594. package/lib/dist/ui/types.d.ts.map +1 -0
  595. package/lib/dist/ui/types.js +3 -0
  596. package/lib/dist/ui/types.js.map +1 -0
  597. package/lib/dist/upgrade/index.d.ts +132 -0
  598. package/lib/dist/upgrade/index.d.ts.map +1 -0
  599. package/lib/dist/upgrade/index.js +576 -0
  600. package/lib/dist/upgrade/index.js.map +1 -0
  601. package/lib/dist/utils.d.ts +224 -0
  602. package/lib/dist/utils.d.ts.map +1 -0
  603. package/lib/dist/utils.js +583 -0
  604. package/lib/dist/utils.js.map +1 -0
  605. package/lib/node_modules/.modules.yaml +45 -0
  606. package/lib/node_modules/.pnpm/lock.yaml +126 -0
  607. package/lib/node_modules/.pnpm-workspace-state-v1.json +25 -0
  608. package/lib/node_modules/@clack/core/CHANGELOG.md +397 -0
  609. package/lib/node_modules/@clack/core/LICENSE +9 -0
  610. package/lib/node_modules/@clack/core/README.md +22 -0
  611. package/lib/node_modules/@clack/core/dist/index.d.mts +469 -0
  612. package/lib/node_modules/@clack/core/dist/index.mjs +981 -0
  613. package/lib/node_modules/@clack/core/package.json +64 -0
  614. package/lib/node_modules/@clack/prompts/CHANGELOG.md +672 -0
  615. package/lib/node_modules/@clack/prompts/LICENSE +9 -0
  616. package/lib/node_modules/@clack/prompts/README.md +396 -0
  617. package/lib/node_modules/@clack/prompts/dist/index.d.mts +928 -0
  618. package/lib/node_modules/@clack/prompts/dist/index.mjs +1398 -0
  619. package/lib/node_modules/@clack/prompts/package.json +68 -0
  620. package/lib/node_modules/commander/LICENSE +22 -0
  621. package/lib/node_modules/commander/Readme.md +1176 -0
  622. package/lib/node_modules/commander/esm.mjs +16 -0
  623. package/lib/node_modules/commander/index.js +24 -0
  624. package/lib/node_modules/commander/lib/argument.js +150 -0
  625. package/lib/node_modules/commander/lib/command.js +2777 -0
  626. package/lib/node_modules/commander/lib/error.js +39 -0
  627. package/lib/node_modules/commander/lib/help.js +747 -0
  628. package/lib/node_modules/commander/lib/option.js +380 -0
  629. package/lib/node_modules/commander/lib/suggestSimilar.js +101 -0
  630. package/lib/node_modules/commander/package-support.json +19 -0
  631. package/lib/node_modules/commander/package.json +82 -0
  632. package/lib/node_modules/commander/typings/esm.d.mts +3 -0
  633. package/lib/node_modules/commander/typings/index.d.ts +1113 -0
  634. package/lib/node_modules/fast-string-truncated-width/dist/index.d.ts +4 -0
  635. package/lib/node_modules/fast-string-truncated-width/dist/index.js +111 -0
  636. package/lib/node_modules/fast-string-truncated-width/dist/types.d.ts +19 -0
  637. package/lib/node_modules/fast-string-truncated-width/dist/types.js +2 -0
  638. package/lib/node_modules/fast-string-truncated-width/dist/utils.d.ts +4 -0
  639. package/lib/node_modules/fast-string-truncated-width/dist/utils.js +20 -0
  640. package/lib/node_modules/fast-string-truncated-width/license +21 -0
  641. package/lib/node_modules/fast-string-truncated-width/package.json +35 -0
  642. package/lib/node_modules/fast-string-truncated-width/readme.md +59 -0
  643. package/lib/node_modules/fast-string-width/dist/index.d.ts +4 -0
  644. package/lib/node_modules/fast-string-width/dist/index.js +14 -0
  645. package/lib/node_modules/fast-string-width/license +21 -0
  646. package/lib/node_modules/fast-string-width/package.json +34 -0
  647. package/lib/node_modules/fast-string-width/readme.md +42 -0
  648. package/lib/node_modules/fast-wrap-ansi/LICENSE +23 -0
  649. package/lib/node_modules/fast-wrap-ansi/README.md +26 -0
  650. package/lib/node_modules/fast-wrap-ansi/lib/main.d.ts +6 -0
  651. package/lib/node_modules/fast-wrap-ansi/lib/main.js +218 -0
  652. package/lib/node_modules/fast-wrap-ansi/package.json +51 -0
  653. package/lib/node_modules/ignore/LICENSE-MIT +21 -0
  654. package/lib/node_modules/ignore/README.md +452 -0
  655. package/lib/node_modules/ignore/index.d.ts +81 -0
  656. package/lib/node_modules/ignore/index.js +784 -0
  657. package/lib/node_modules/ignore/legacy.js +681 -0
  658. package/lib/node_modules/ignore/package.json +87 -0
  659. package/lib/node_modules/jsonc-parser/CHANGELOG.md +76 -0
  660. package/lib/node_modules/jsonc-parser/LICENSE.md +21 -0
  661. package/lib/node_modules/jsonc-parser/README.md +364 -0
  662. package/lib/node_modules/jsonc-parser/SECURITY.md +41 -0
  663. package/lib/node_modules/jsonc-parser/lib/esm/impl/edit.js +185 -0
  664. package/lib/node_modules/jsonc-parser/lib/esm/impl/format.js +261 -0
  665. package/lib/node_modules/jsonc-parser/lib/esm/impl/parser.js +659 -0
  666. package/lib/node_modules/jsonc-parser/lib/esm/impl/scanner.js +443 -0
  667. package/lib/node_modules/jsonc-parser/lib/esm/impl/string-intern.js +29 -0
  668. package/lib/node_modules/jsonc-parser/lib/esm/main.d.ts +351 -0
  669. package/lib/node_modules/jsonc-parser/lib/esm/main.js +178 -0
  670. package/lib/node_modules/jsonc-parser/lib/umd/impl/edit.js +201 -0
  671. package/lib/node_modules/jsonc-parser/lib/umd/impl/format.js +275 -0
  672. package/lib/node_modules/jsonc-parser/lib/umd/impl/parser.js +682 -0
  673. package/lib/node_modules/jsonc-parser/lib/umd/impl/scanner.js +456 -0
  674. package/lib/node_modules/jsonc-parser/lib/umd/impl/string-intern.js +42 -0
  675. package/lib/node_modules/jsonc-parser/lib/umd/main.d.ts +351 -0
  676. package/lib/node_modules/jsonc-parser/lib/umd/main.js +194 -0
  677. package/lib/node_modules/jsonc-parser/package.json +37 -0
  678. package/lib/node_modules/picomatch/LICENSE +21 -0
  679. package/lib/node_modules/picomatch/README.md +749 -0
  680. package/lib/node_modules/picomatch/index.js +17 -0
  681. package/lib/node_modules/picomatch/lib/constants.js +184 -0
  682. package/lib/node_modules/picomatch/lib/parse.js +1386 -0
  683. package/lib/node_modules/picomatch/lib/picomatch.js +349 -0
  684. package/lib/node_modules/picomatch/lib/scan.js +391 -0
  685. package/lib/node_modules/picomatch/lib/utils.js +72 -0
  686. package/lib/node_modules/picomatch/package.json +82 -0
  687. package/lib/node_modules/picomatch/posix.js +3 -0
  688. package/lib/node_modules/sisteransi/license +21 -0
  689. package/lib/node_modules/sisteransi/package.json +34 -0
  690. package/lib/node_modules/sisteransi/readme.md +113 -0
  691. package/lib/node_modules/sisteransi/src/index.js +58 -0
  692. package/lib/node_modules/sisteransi/src/sisteransi.d.ts +35 -0
  693. package/lib/node_modules/tree-sitter-wasms/LICENSE +24 -0
  694. package/lib/node_modules/tree-sitter-wasms/README.md +23 -0
  695. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-bash.wasm +0 -0
  696. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-c.wasm +0 -0
  697. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-c_sharp.wasm +0 -0
  698. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-cpp.wasm +0 -0
  699. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-css.wasm +0 -0
  700. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-dart.wasm +0 -0
  701. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-elisp.wasm +0 -0
  702. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-elixir.wasm +0 -0
  703. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-elm.wasm +0 -0
  704. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-embedded_template.wasm +0 -0
  705. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-go.wasm +0 -0
  706. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-html.wasm +0 -0
  707. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-java.wasm +0 -0
  708. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-javascript.wasm +0 -0
  709. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-json.wasm +0 -0
  710. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-kotlin.wasm +0 -0
  711. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-lua.wasm +0 -0
  712. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-objc.wasm +0 -0
  713. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-ocaml.wasm +0 -0
  714. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-php.wasm +0 -0
  715. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-python.wasm +0 -0
  716. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-ql.wasm +0 -0
  717. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-rescript.wasm +0 -0
  718. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-ruby.wasm +0 -0
  719. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-rust.wasm +0 -0
  720. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-scala.wasm +0 -0
  721. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-solidity.wasm +0 -0
  722. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-swift.wasm +0 -0
  723. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-systemrdl.wasm +0 -0
  724. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-tlaplus.wasm +0 -0
  725. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-toml.wasm +0 -0
  726. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-tsx.wasm +0 -0
  727. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-typescript.wasm +0 -0
  728. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-vue.wasm +0 -0
  729. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-yaml.wasm +0 -0
  730. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-zig.wasm +0 -0
  731. package/lib/node_modules/tree-sitter-wasms/package.json +64 -0
  732. package/lib/node_modules/web-tree-sitter/LICENSE +21 -0
  733. package/lib/node_modules/web-tree-sitter/README.md +269 -0
  734. package/lib/node_modules/web-tree-sitter/debug/tree-sitter.cjs +4558 -0
  735. package/lib/node_modules/web-tree-sitter/debug/tree-sitter.cjs.map +7 -0
  736. package/lib/node_modules/web-tree-sitter/debug/tree-sitter.js +4516 -0
  737. package/lib/node_modules/web-tree-sitter/debug/tree-sitter.js.map +7 -0
  738. package/lib/node_modules/web-tree-sitter/debug/tree-sitter.wasm +0 -0
  739. package/lib/node_modules/web-tree-sitter/debug/tree-sitter.wasm.map +31 -0
  740. package/lib/node_modules/web-tree-sitter/lib/alloc.c +48 -0
  741. package/lib/node_modules/web-tree-sitter/lib/alloc.h +41 -0
  742. package/lib/node_modules/web-tree-sitter/lib/array.h +291 -0
  743. package/lib/node_modules/web-tree-sitter/lib/atomic.h +68 -0
  744. package/lib/node_modules/web-tree-sitter/lib/clock.h +146 -0
  745. package/lib/node_modules/web-tree-sitter/lib/error_costs.h +11 -0
  746. package/lib/node_modules/web-tree-sitter/lib/get_changed_ranges.c +523 -0
  747. package/lib/node_modules/web-tree-sitter/lib/get_changed_ranges.h +36 -0
  748. package/lib/node_modules/web-tree-sitter/lib/host.h +21 -0
  749. package/lib/node_modules/web-tree-sitter/lib/language.c +293 -0
  750. package/lib/node_modules/web-tree-sitter/lib/language.h +293 -0
  751. package/lib/node_modules/web-tree-sitter/lib/length.h +52 -0
  752. package/lib/node_modules/web-tree-sitter/lib/lexer.c +483 -0
  753. package/lib/node_modules/web-tree-sitter/lib/lexer.h +54 -0
  754. package/lib/node_modules/web-tree-sitter/lib/lib.c +12 -0
  755. package/lib/node_modules/web-tree-sitter/lib/node.c +875 -0
  756. package/lib/node_modules/web-tree-sitter/lib/parser.c +2297 -0
  757. package/lib/node_modules/web-tree-sitter/lib/parser.h +286 -0
  758. package/lib/node_modules/web-tree-sitter/lib/point.h +48 -0
  759. package/lib/node_modules/web-tree-sitter/lib/query.c +4347 -0
  760. package/lib/node_modules/web-tree-sitter/lib/reduce_action.h +34 -0
  761. package/lib/node_modules/web-tree-sitter/lib/reusable_node.h +95 -0
  762. package/lib/node_modules/web-tree-sitter/lib/stack.c +912 -0
  763. package/lib/node_modules/web-tree-sitter/lib/stack.h +133 -0
  764. package/lib/node_modules/web-tree-sitter/lib/subtree.c +1034 -0
  765. package/lib/node_modules/web-tree-sitter/lib/subtree.h +399 -0
  766. package/lib/node_modules/web-tree-sitter/lib/tree-sitter.c +987 -0
  767. package/lib/node_modules/web-tree-sitter/lib/tree-sitter.cjs +2988 -0
  768. package/lib/node_modules/web-tree-sitter/lib/tree-sitter.wasm +0 -0
  769. package/lib/node_modules/web-tree-sitter/lib/tree-sitter.wasm.map +1 -0
  770. package/lib/node_modules/web-tree-sitter/lib/tree.c +170 -0
  771. package/lib/node_modules/web-tree-sitter/lib/tree.h +31 -0
  772. package/lib/node_modules/web-tree-sitter/lib/tree_cursor.c +716 -0
  773. package/lib/node_modules/web-tree-sitter/lib/tree_cursor.h +48 -0
  774. package/lib/node_modules/web-tree-sitter/lib/ts_assert.h +11 -0
  775. package/lib/node_modules/web-tree-sitter/lib/unicode.h +75 -0
  776. package/lib/node_modules/web-tree-sitter/lib/wasm_store.c +1937 -0
  777. package/lib/node_modules/web-tree-sitter/lib/wasm_store.h +31 -0
  778. package/lib/node_modules/web-tree-sitter/package.json +98 -0
  779. package/lib/node_modules/web-tree-sitter/src/bindings.ts +26 -0
  780. package/lib/node_modules/web-tree-sitter/src/constants.ts +133 -0
  781. package/lib/node_modules/web-tree-sitter/src/index.ts +31 -0
  782. package/lib/node_modules/web-tree-sitter/src/language.ts +291 -0
  783. package/lib/node_modules/web-tree-sitter/src/lookahead_iterator.ts +75 -0
  784. package/lib/node_modules/web-tree-sitter/src/marshal.ts +176 -0
  785. package/lib/node_modules/web-tree-sitter/src/node.ts +646 -0
  786. package/lib/node_modules/web-tree-sitter/src/parser.ts +325 -0
  787. package/lib/node_modules/web-tree-sitter/src/query.ts +973 -0
  788. package/lib/node_modules/web-tree-sitter/src/tree.ts +145 -0
  789. package/lib/node_modules/web-tree-sitter/src/tree_cursor.ts +318 -0
  790. package/lib/node_modules/web-tree-sitter/tree-sitter.cjs +4031 -0
  791. package/lib/node_modules/web-tree-sitter/tree-sitter.cjs.map +7 -0
  792. package/lib/node_modules/web-tree-sitter/tree-sitter.js +3980 -0
  793. package/lib/node_modules/web-tree-sitter/tree-sitter.js.map +7 -0
  794. package/lib/node_modules/web-tree-sitter/tree-sitter.wasm +0 -0
  795. package/lib/node_modules/web-tree-sitter/tree-sitter.wasm.map +30 -0
  796. package/lib/node_modules/web-tree-sitter/web-tree-sitter.d.ts +1030 -0
  797. package/lib/node_modules/web-tree-sitter/web-tree-sitter.d.ts.map +56 -0
  798. package/lib/package.json +57 -0
  799. package/node +0 -0
  800. package/package.json +17 -0
@@ -0,0 +1,1951 @@
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.scanDirectory = scanDirectory;
50
+ exports.scanDirectoryAsync = scanDirectoryAsync;
51
+ const fs = __importStar(require("fs"));
52
+ const fsp = __importStar(require("fs/promises"));
53
+ const path = __importStar(require("path"));
54
+ const os = __importStar(require("os"));
55
+ const crypto = __importStar(require("crypto"));
56
+ const child_process_1 = require("child_process");
57
+ const tree_sitter_1 = require("./tree-sitter");
58
+ const parse_pool_1 = require("./parse-pool");
59
+ const grammars_1 = require("./grammars");
60
+ const project_config_1 = require("../project-config");
61
+ const directory_1 = require("../directory");
62
+ const errors_1 = require("../errors");
63
+ const utils_1 = require("../utils");
64
+ const ignore_1 = __importDefault(require("ignore"));
65
+ const frameworks_1 = require("../resolution/frameworks");
66
+ /**
67
+ * Number of files to read in parallel during indexing.
68
+ * File reads are I/O-bound; batching overlaps I/O wait with CPU parse work.
69
+ */
70
+ const FILE_IO_BATCH_SIZE = 10;
71
+ /**
72
+ * How many files the `sync()` reconcile processes between cooperative yields to
73
+ * the event loop. The reconcile runs two O(files) loops of synchronous `fs`
74
+ * calls (existsSync for removals, statSync for adds/mods); on a very large repo
75
+ * (~100k files) an un-yielded run wedges the main thread for minutes, which both
76
+ * trips the liveness watchdog (it SIGKILLs a process whose loop stops turning)
77
+ * and blocks the first MCP tool call behind the catch-up gate (issue #905).
78
+ * Yielding every N files keeps the socket, the watchdog heartbeat, and any
79
+ * concurrent read query responsive while the reconcile runs.
80
+ */
81
+ const SYNC_RECONCILE_YIELD_INTERVAL = 1000;
82
+ // PARSER_RESET_INTERVAL moved to parse-worker.ts (runs in worker thread)
83
+ /**
84
+ * Maximum time (ms) to wait for a single file to parse in the worker thread.
85
+ * If tree-sitter hangs or WASM runs out of memory, this prevents the entire
86
+ * indexing run from freezing. The worker is restarted after a timeout.
87
+ */
88
+ const PARSE_TIMEOUT_MS = 10_000;
89
+ /**
90
+ * Number of files to parse before recycling the worker thread.
91
+ * WASM linear memory can grow but NEVER shrink (WebAssembly spec limitation).
92
+ * The only way to reclaim tree-sitter's WASM heap is to destroy the entire
93
+ * V8 isolate by terminating the worker thread and spawning a fresh one.
94
+ * This interval balances memory usage against the cost of reloading grammars.
95
+ */
96
+ const WORKER_RECYCLE_INTERVAL = 250;
97
+ /**
98
+ * Calculate SHA256 hash of file contents
99
+ */
100
+ function hashContent(content) {
101
+ return crypto.createHash('sha256').update(content).digest('hex');
102
+ }
103
+ /**
104
+ * Skip files larger than this (bytes). Generated bundles, minified JS, and
105
+ * vendored blobs blow the WASM heap and the worker-recycle budget for no useful
106
+ * symbols. 1 MB covers essentially all hand-written source.
107
+ */
108
+ const MAX_FILE_SIZE = 1024 * 1024;
109
+ /**
110
+ * Directory names that are dependency, build, cache, or tooling output across the
111
+ * languages/frameworks CodeGraph supports — curated from the canonical
112
+ * github/gitignore templates. Excluded by default so the graph reflects your code,
113
+ * not third-party noise, without requiring a `.gitignore` (issue #407). The
114
+ * exclusion applies uniformly (git or not, tracked or not); the only opt-in is an
115
+ * explicit `.gitignore` negation (e.g. `!vendor/`). First-party-prone or generic
116
+ * names (`packages`, `lib`, `app`, `bin`, `src`, `deps`, `env`, `tmp`, `storage`,
117
+ * `Library`) are deliberately NOT listed, to avoid ever hiding real source.
118
+ *
119
+ * Only dirs that actually contain *indexable source* (or are enormous) earn a slot
120
+ * — IDE/state dirs like `.idea`/`.vs` are omitted because CodeGraph indexes only
121
+ * recognized source extensions, so they produce no symbols regardless.
122
+ */
123
+ const DEFAULT_IGNORE_DIRS = new Set([
124
+ // JS / TS — dependency directories
125
+ 'node_modules', 'bower_components', 'jspm_packages', 'web_modules',
126
+ '.yarn', '.pnpm-store',
127
+ // JS / TS — framework & bundler build / cache / deploy output
128
+ '.next', '.nuxt', '.svelte-kit', '.turbo', '.vite', '.parcel-cache', '.angular',
129
+ '.docusaurus', 'storybook-static', '.vinxi', '.nitro', 'out-tsc',
130
+ '.vercel', '.netlify', '.wrangler',
131
+ // Build output (common across ecosystems)
132
+ 'dist', 'build', 'out', '.output',
133
+ // Test / coverage
134
+ 'coverage', '.nyc_output',
135
+ // Python
136
+ '__pycache__', '__pypackages__', '.venv', 'venv', '.pixi', '.pdm-build',
137
+ '.mypy_cache', '.pytest_cache', '.ruff_cache', '.tox', '.nox', '.hypothesis',
138
+ '.ipynb_checkpoints', '.eggs',
139
+ // Rust / JVM (Maven, Gradle, Scala)
140
+ 'target', '.gradle',
141
+ // .NET
142
+ 'obj',
143
+ // Vendored deps (Go, PHP/Composer, Ruby/Bundler)
144
+ 'vendor',
145
+ // Swift / iOS
146
+ '.build', 'Pods', 'Carthage', 'DerivedData', '.swiftpm',
147
+ // Dart / Flutter
148
+ '.dart_tool', '.pub-cache',
149
+ // Native (Android NDK, C/C++ deps)
150
+ '.cxx', '.externalNativeBuild', 'vcpkg_installed',
151
+ // Scala tooling
152
+ '.bloop', '.metals',
153
+ // Lua / Luau (LuaRocks)
154
+ 'lua_modules', '.luarocks',
155
+ // Delphi / RAD Studio IDE backups (duplicate .pas source — would double-count)
156
+ '__history', '__recovery',
157
+ // Generic cache
158
+ '.cache',
159
+ ]);
160
+ /** Gitignore-style patterns for the `ignore` matcher: the dirs above plus a few globs. */
161
+ const DEFAULT_IGNORE_PATTERNS = [
162
+ ...Array.from(DEFAULT_IGNORE_DIRS, (d) => `${d}/`),
163
+ '*.egg-info/', // Python packaging metadata
164
+ 'cmake-build-*/', // CLion / CMake build trees
165
+ 'bazel-*/', // Bazel output symlink trees
166
+ ];
167
+ /** True if `buf` decodes as strict UTF-8 (no invalid byte sequences). */
168
+ function isValidUtf8(buf) {
169
+ try {
170
+ new TextDecoder('utf-8', { fatal: true }).decode(buf);
171
+ return true;
172
+ }
173
+ catch {
174
+ return false;
175
+ }
176
+ }
177
+ /**
178
+ * Read a `.gitignore` and return patterns safe to hand to the `ignore` matcher —
179
+ * never throwing, even when the file isn't real gitignore text. Two failure
180
+ * modes, both seen in the wild (issue #682):
181
+ *
182
+ * - The file isn't valid UTF-8 — e.g. transparently encrypted in place by
183
+ * corporate DLP / endpoint-security software, leaving a UTF-16 header plus
184
+ * ciphertext. None of it is meaningful patterns, so the whole file is skipped.
185
+ * - The file is text but a single line can't be compiled to a regex by the
186
+ * `ignore` library — `\\[` and friends throw "Unterminated character class".
187
+ * Crucially the throw is LAZY (at match time, not `.add()`), so it would
188
+ * otherwise escape mid-scan. That one pattern is dropped; the rest are kept.
189
+ *
190
+ * Either way a warning that NAMES the file is logged (the reporter couldn't tell
191
+ * which `.gitignore` was at fault) and indexing continues instead of aborting.
192
+ * Returns '' when there's nothing usable.
193
+ */
194
+ function readGitignorePatterns(giPath) {
195
+ let buf;
196
+ try {
197
+ buf = fs.readFileSync(giPath);
198
+ }
199
+ catch {
200
+ return ''; // unreadable (permissions / race) — treat as absent
201
+ }
202
+ // A NUL byte never appears in real gitignore text, and a fatal UTF-8 decode
203
+ // catches the rest. Such a file isn't ignore patterns at all.
204
+ if (buf.includes(0) || !isValidUtf8(buf)) {
205
+ (0, errors_1.logWarn)('Ignoring a .gitignore that is not valid UTF-8 text — it may have been encrypted ' +
206
+ 'in place by endpoint-security software. Indexing continues without it.', { file: giPath });
207
+ return '';
208
+ }
209
+ const content = buf.toString('utf-8');
210
+ // Fast path: one `.ignores()` call forces the library to compile EVERY rule,
211
+ // so if it doesn't throw, the whole file is safe to use verbatim.
212
+ try {
213
+ (0, ignore_1.default)().add(content).ignores('.codegraph-probe');
214
+ return content;
215
+ }
216
+ catch {
217
+ // Fall through: a line is uncompilable — keep the good ones, drop the bad.
218
+ }
219
+ const kept = [];
220
+ let dropped = 0;
221
+ for (const line of content.split(/\r?\n/)) {
222
+ try {
223
+ (0, ignore_1.default)().add(line).ignores('.codegraph-probe');
224
+ kept.push(line);
225
+ }
226
+ catch {
227
+ dropped++;
228
+ }
229
+ }
230
+ if (dropped > 0) {
231
+ (0, errors_1.logWarn)(`Skipped ${dropped} unparseable pattern(s) in a .gitignore; the rest are applied.`, { file: giPath });
232
+ }
233
+ return kept.join('\n');
234
+ }
235
+ /**
236
+ * An `ignore` matcher seeded with the built-in defaults, merged with the project's
237
+ * root .gitignore so a negation there (e.g. `!vendor/`) overrides a default. Shared
238
+ * by both enumeration paths so behavior is identical with or without git — and so
239
+ * the defaults apply to tracked files too (committing a dependency dir doesn't make
240
+ * it project code; the explicit `.gitignore` negation is the only opt-in).
241
+ */
242
+ function buildDefaultIgnore(rootDir) {
243
+ const ig = (0, ignore_1.default)().add(DEFAULT_IGNORE_PATTERNS);
244
+ const rootGitignore = path.join(rootDir, '.gitignore');
245
+ if (fs.existsSync(rootGitignore))
246
+ ig.add(readGitignorePatterns(rootGitignore));
247
+ return ig;
248
+ }
249
+ /**
250
+ * Defaults-only ignore matcher (no root `.gitignore` merged). Used wherever the
251
+ * parent repo's own ignore rules must NOT apply — inside embedded child repos,
252
+ * whose gitignore semantics their own `git ls-files` already enforced (#514).
253
+ */
254
+ function defaultsOnlyIgnore() {
255
+ return (0, ignore_1.default)().add(DEFAULT_IGNORE_PATTERNS);
256
+ }
257
+ /**
258
+ * Matcher for the project's `codegraph.json` `includeIgnored` patterns — the
259
+ * explicit opt-in to index embedded git repos living inside gitignored
260
+ * directories (#622, #699). Returns `null` when the project opted in nothing,
261
+ * which is the zero-config DEFAULT: `.gitignore` is then fully respected and a
262
+ * gitignored directory (even one holding nested repos) is never walked or
263
+ * indexed (#970, #976). Built once per scan/sync/scope operation from the scan
264
+ * root and threaded down — never global, so multi-project daemons stay isolated.
265
+ */
266
+ function loadIncludeIgnoredMatcher(rootDir) {
267
+ const patterns = (0, project_config_1.loadIncludeIgnoredPatterns)(rootDir);
268
+ return patterns.length > 0 ? (0, ignore_1.default)().add(patterns) : null;
269
+ }
270
+ /**
271
+ * Matcher for the project's `codegraph.json` `exclude` patterns — paths to keep
272
+ * OUT of the index even when git-tracked, which `.gitignore` cannot do (#999).
273
+ * The escape hatch for a committed vendor/theme/SDK directory. Returns `null`
274
+ * when nothing is excluded (the zero-config default → no overhead). Matched
275
+ * against project-root-relative paths, so it applies uniformly across the whole
276
+ * workspace, including inside embedded repos (excluding `static/` means gone
277
+ * everywhere). Built once per scan/sync/scope operation from the scan root.
278
+ */
279
+ function loadExcludeMatcher(rootDir) {
280
+ const patterns = (0, project_config_1.loadExcludePatterns)(rootDir);
281
+ return patterns.length > 0 ? (0, ignore_1.default)().add(patterns) : null;
282
+ }
283
+ /**
284
+ * `git ls-files --directory` collapses a wholly-untracked/ignored directory into
285
+ * one entry — and when the command's own cwd is such a directory (the indexed
286
+ * root is itself a git-ignored subdir of an enclosing repo), git emits the
287
+ * literal `./` meaning "this entire directory". That sentinel is not a real
288
+ * nested path: feeding it to the `ignore` matcher throws ("path should be a
289
+ * `path.relative()`d string, but got "./""), which used to abort `buildScopeIgnore`
290
+ * and so break the MCP daemon's watcher/auto-sync on connect; and joining it back
291
+ * onto `repoDir` would just re-point at the cwd. Drop it wherever we consume
292
+ * `--directory` output. (#936)
293
+ */
294
+ function isWholeCwdEntry(entry) {
295
+ return entry === './' || entry === '.' || entry === '';
296
+ }
297
+ /**
298
+ * List the gitignored DIRECTORIES of a repo (collapsed, trailing-slash form),
299
+ * relative to `repoDir`. These are invisible to every other `git ls-files` /
300
+ * `git status` mode — and in a multi-repo workspace they are exactly where the
301
+ * nested project repos live (a super-repo `.gitignore`s its child repos to keep
302
+ * `git status` quiet; that does not make them third-party code). (#514)
303
+ */
304
+ function listIgnoredDirs(repoDir) {
305
+ try {
306
+ 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 });
307
+ return out.split('\0').filter((e) => e.endsWith('/') && !isWholeCwdEntry(e));
308
+ }
309
+ catch {
310
+ return [];
311
+ }
312
+ }
313
+ /** Max directory depth searched below an ignored dir for nested `.git` roots. */
314
+ const EMBEDDED_REPO_SEARCH_DEPTH = 4;
315
+ /** Max directories examined per search — a huge ignored data dir must never stall a scan/sync. */
316
+ const EMBEDDED_REPO_SEARCH_ENTRIES = 2000;
317
+ /**
318
+ * Classify a directory's `.git` entry for embedded-repo discovery.
319
+ *
320
+ * - A `.git` **directory** is an embedded clone — distinct first-party code a
321
+ * super-repo merely hides from git; index it (#193, #514).
322
+ * - A `.git` **file** is a pointer (`gitdir: …`). A git **worktree** points into
323
+ * the host repo's own `.git/worktrees/<name>`, so it is a second working view
324
+ * of a repo CodeGraph already indexes — indexing it just duplicates the whole
325
+ * graph N times; skip it (#848). A **submodule worktree** points into
326
+ * `.git/modules/<module>/worktrees/<name>` — same duplication, so skip it too
327
+ * (#945). A **submodule** checkout points into `.git/modules/<module>` (no
328
+ * `worktrees/` segment) and is distinct code, so index it as before.
329
+ *
330
+ * Returns `'none'` when there is no `.git` entry here.
331
+ */
332
+ function classifyGitDir(absDir) {
333
+ let st;
334
+ try {
335
+ st = fs.statSync(path.join(absDir, '.git'));
336
+ }
337
+ catch {
338
+ return 'none';
339
+ }
340
+ if (st.isDirectory())
341
+ return 'embedded';
342
+ if (!st.isFile())
343
+ return 'none';
344
+ try {
345
+ const gitdir = fs.readFileSync(path.join(absDir, '.git'), 'utf8').match(/^gitdir:\s*(.+)$/m)?.[1]?.trim();
346
+ // A worktree's gitdir lives under some repo's `.git/worktrees/<name>` —
347
+ // either the top-level repo's (`.git/worktrees/`) or, for a worktree of a
348
+ // submodule, that submodule's gitdir (`.git/modules/<module>/worktrees/`).
349
+ // The optional `modules/<module>` segment covers the submodule case (#945).
350
+ // Match both separators so a Windows-style pointer is recognized too.
351
+ if (gitdir && /(^|[\\/])\.git[\\/](modules[\\/][^\\/]+[\\/])?worktrees[\\/]/.test(gitdir))
352
+ return 'worktree';
353
+ }
354
+ catch {
355
+ // Unreadable `.git` pointer — fall back to the prior "index it" behavior.
356
+ }
357
+ return 'embedded';
358
+ }
359
+ /**
360
+ * Find git repositories nested under `absDir` (inclusive), shallow bounded BFS.
361
+ * Stops descending at each repo root found — contents belong to that repo's own
362
+ * enumeration. Skips default-ignored dirs (`node_modules` can contain `.git`
363
+ * from npm git-dependencies — that never makes it project code) and CodeGraph
364
+ * data dirs. Depth- and entry-capped so a huge ignored tree can't stall the scan.
365
+ */
366
+ function findNestedGitRepos(absDir, relPrefix) {
367
+ const found = [];
368
+ const defaults = defaultsOnlyIgnore();
369
+ const queue = [
370
+ { abs: absDir, rel: relPrefix, depth: 0 },
371
+ ];
372
+ let examined = 0;
373
+ while (queue.length > 0) {
374
+ const { abs, rel, depth } = queue.shift();
375
+ if (++examined > EMBEDDED_REPO_SEARCH_ENTRIES) {
376
+ (0, errors_1.logDebug)('Embedded-repo search entry cap hit — deeper repos (if any) not discovered', { under: relPrefix });
377
+ break;
378
+ }
379
+ const cls = classifyGitDir(abs);
380
+ if (cls === 'worktree') {
381
+ continue; // a git worktree duplicates an already-indexed repo (#848) — skip
382
+ }
383
+ if (cls === 'embedded') {
384
+ found.push(rel);
385
+ continue; // its own git handles everything below
386
+ }
387
+ if (depth >= EMBEDDED_REPO_SEARCH_DEPTH)
388
+ continue;
389
+ let entries;
390
+ try {
391
+ entries = fs.readdirSync(abs, { withFileTypes: true });
392
+ }
393
+ catch {
394
+ continue;
395
+ }
396
+ for (const entry of entries) {
397
+ if (!entry.isDirectory())
398
+ continue;
399
+ if (entry.name === '.git' || (0, directory_1.isCodeGraphDataDir)(entry.name))
400
+ continue;
401
+ const childRel = rel + entry.name + '/';
402
+ if (defaults.ignores(childRel))
403
+ continue;
404
+ queue.push({ abs: path.join(abs, entry.name), rel: childRel, depth: depth + 1 });
405
+ }
406
+ }
407
+ return found;
408
+ }
409
+ /**
410
+ * Workspace-scope ignore matcher. Ordinary paths get the root's matcher
411
+ * (built-in defaults + root `.gitignore`); paths inside an EMBEDDED repo get
412
+ * that repo's own matcher (defaults + its root `.gitignore`) — the parent's
413
+ * `.gitignore` hides a child repo from git, not from the index (#514). A
414
+ * directory path (trailing slash) that is an ANCESTOR of an embedded root is
415
+ * never ignored, so directory-pruning callers (the Linux per-directory
416
+ * watcher) still descend to reach the embedded repos.
417
+ *
418
+ * Single source of truth for indexer and watcher scope — they must not diverge.
419
+ */
420
+ class ScopeIgnore {
421
+ rootMatcher;
422
+ exclude;
423
+ embedded;
424
+ defaults = defaultsOnlyIgnore();
425
+ constructor(rootMatcher, embedded,
426
+ /**
427
+ * Project `codegraph.json` `exclude` patterns (#999), matched against the
428
+ * full root-relative path. Wins over everything else — an explicit user
429
+ * exclude applies even to tracked files and even inside embedded repos.
430
+ */
431
+ exclude = null) {
432
+ this.rootMatcher = rootMatcher;
433
+ this.exclude = exclude;
434
+ // Longest root first so paths in nested embedded repos hit the innermost matcher.
435
+ this.embedded = [...embedded].sort((a, b) => b.root.length - a.root.length);
436
+ }
437
+ ignores(rel) {
438
+ // User `exclude` (#999) is checked first and against the full root-relative
439
+ // path: it must drop git-TRACKED paths (which `.gitignore` can't) and apply
440
+ // everywhere, including ancestors of embedded repos.
441
+ if (this.exclude && this.exclude.ignores(rel))
442
+ return true;
443
+ for (const { root, matcher } of this.embedded) {
444
+ if (rel.startsWith(root)) {
445
+ const inner = rel.slice(root.length);
446
+ if (inner === '')
447
+ return false;
448
+ // Built-in defaults apply to the FULL path uniformly (#407) — an
449
+ // embedded repo inside node_modules (an npm git-dependency) must stay
450
+ // excluded even though its own rules wouldn't ignore its files.
451
+ return this.defaults.ignores(rel) || matcher.ignores(inner);
452
+ }
453
+ }
454
+ // Never prune a directory that leads to an embedded repo.
455
+ if (rel.endsWith('/') && this.embedded.some(({ root }) => root.startsWith(rel))) {
456
+ return false;
457
+ }
458
+ return this.rootMatcher.ignores(rel);
459
+ }
460
+ }
461
+ exports.ScopeIgnore = ScopeIgnore;
462
+ /**
463
+ * Build the workspace-scope matcher. When the caller already knows the
464
+ * embedded roots (the scanner discovers them during collection), pass them to
465
+ * skip rediscovery; otherwise they're discovered here (the watcher path).
466
+ */
467
+ function buildScopeIgnore(rootDir, embeddedRoots) {
468
+ const roots = embeddedRoots ? [...embeddedRoots] : discoverEmbeddedRepoRoots(rootDir);
469
+ return new ScopeIgnore(buildDefaultIgnore(rootDir), roots.map((root) => ({ root, matcher: buildDefaultIgnore(path.join(rootDir, root)) })), loadExcludeMatcher(rootDir));
470
+ }
471
+ /**
472
+ * Standalone discovery of every embedded repo root under `rootDir` (relative,
473
+ * trailing-slashed) — the untracked kind (#193) always, and the gitignored kind
474
+ * (#514) only for directories the project opted in via `codegraph.json`
475
+ * `includeIgnored` (#622, #699); otherwise `.gitignore` is respected and they
476
+ * are not discovered (#970, #976). Recursive (an embedded repo can embed further
477
+ * repos). Returns [] for non-git roots: the filesystem walk handles nested repos
478
+ * there already.
479
+ */
480
+ function discoverEmbeddedRepoRoots(rootDir) {
481
+ try {
482
+ (0, child_process_1.execFileSync)('git', ['rev-parse', '--git-dir'], { cwd: rootDir, encoding: 'utf-8', timeout: 5000, stdio: ['pipe', 'pipe', 'pipe'], windowsHide: true });
483
+ }
484
+ catch {
485
+ return [];
486
+ }
487
+ const out = [];
488
+ const defaults = defaultsOnlyIgnore();
489
+ const includeIgnored = loadIncludeIgnoredMatcher(rootDir);
490
+ const visit = (repoAbs, prefix) => {
491
+ const candidates = [];
492
+ try {
493
+ 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 });
494
+ for (const e of o.split('\0')) {
495
+ if (e.endsWith('/') && !isWholeCwdEntry(e) && !defaults.ignores(e)) {
496
+ candidates.push(...findNestedGitRepos(path.join(repoAbs, e), e));
497
+ }
498
+ }
499
+ }
500
+ catch { /* untracked listing failed — ignored-side discovery still runs */ }
501
+ candidates.push(...findIgnoredEmbeddedRepos(repoAbs, includeIgnored, prefix));
502
+ for (const rel of candidates) {
503
+ const full = (0, utils_1.normalizePath)(prefix + rel);
504
+ out.push(full);
505
+ visit(path.join(repoAbs, rel), full);
506
+ }
507
+ };
508
+ visit(rootDir, '');
509
+ return out;
510
+ }
511
+ /**
512
+ * Discover embedded repos hidden by `repoDir`'s OWN gitignore rules: for each
513
+ * gitignored directory, search for nested `.git` roots. Returns repo paths
514
+ * relative to `repoDir`, trailing-slashed.
515
+ *
516
+ * OPT-IN ONLY. Walking into a gitignored directory contradicts what every other
517
+ * tool (and CodeGraph's own `git ls-files` foundation) does — `.gitignore`
518
+ * excludes. So this returns `[]` unless the project opted the directory in via
519
+ * `codegraph.json` `includeIgnored`; without that, a gitignored dir — including
520
+ * a huge reference/data dir full of nested clones — is left untouched (#970,
521
+ * #976). When opted in, it restores the super-repo-of-clones behavior (#622,
522
+ * #699). `prefix` is the scan-root-relative path of `repoDir`, so a pattern like
523
+ * `services/` opts that whole subtree in at any recursion depth. Built-in
524
+ * default excludes (`node_modules`, …) are always skipped.
525
+ */
526
+ function findIgnoredEmbeddedRepos(repoDir, includeIgnored, prefix) {
527
+ if (!includeIgnored)
528
+ return [];
529
+ const defaults = defaultsOnlyIgnore();
530
+ const repos = [];
531
+ for (const dir of listIgnoredDirs(repoDir)) {
532
+ if (defaults.ignores(dir))
533
+ continue;
534
+ if (!includeIgnored.ignores((0, utils_1.normalizePath)(prefix + dir)))
535
+ continue;
536
+ repos.push(...findNestedGitRepos(path.join(repoDir, dir), dir));
537
+ }
538
+ return repos;
539
+ }
540
+ /**
541
+ * Collect git-visible files (tracked + untracked, .gitignore-respected) from the
542
+ * git repository rooted at `repoDir`, adding each to `files` with `prefix`
543
+ * prepended so paths stay relative to the original scan root.
544
+ *
545
+ * Recurses into embedded git repositories — nested repos that are NOT submodules
546
+ * (independent clones living inside the workspace, common in CMake "super-repo"
547
+ * layouts). The parent repo's `git ls-files` cannot see into them: tracked output
548
+ * skips them entirely, and untracked output reports them only as an opaque
549
+ * "subdir/" entry (trailing slash) rather than expanding their files. Each
550
+ * embedded repo is its own git boundary, so we re-run `git ls-files` inside it.
551
+ * (See issue #193.) GITIGNORED embedded repos are invisible even to that; they
552
+ * are discovered separately via `findIgnoredEmbeddedRepos` (#514) but ONLY for
553
+ * directories the project opted in through `codegraph.json` `includeIgnored`
554
+ * (`includeIgnored` here, threaded from the scan root) — by default `.gitignore`
555
+ * is respected and they stay out (#970, #976). Every embedded repo root (however
556
+ * found) is recorded in `embeddedRoots` so callers can exempt its files from the
557
+ * parent's own gitignore rules.
558
+ */
559
+ function collectGitFiles(repoDir, prefix, files, embeddedRoots, includeIgnored = null) {
560
+ const gitOpts = { cwd: repoDir, encoding: 'utf-8', timeout: 30000, maxBuffer: 50 * 1024 * 1024, stdio: ['pipe', 'pipe', 'pipe'], windowsHide: true };
561
+ // Tracked files. --recurse-submodules pulls in files from active submodules,
562
+ // which the index would otherwise represent only as a commit pointer.
563
+ // Without this, monorepos using submodules index 0 files. (See issue #147.)
564
+ // Note: --recurse-submodules only supports -c/--cached and --stage modes — it
565
+ // can't be combined with -o, so untracked files are gathered separately below.
566
+ // -z gives NUL-separated, unquoted output so non-ASCII (e.g. CJK) paths
567
+ // survive verbatim. Without it git octal-escapes and double-quotes such paths
568
+ // (the core.quotepath default), and the quoted form never matches a real file
569
+ // on disk → those files are silently dropped from the index. (#541)
570
+ const tracked = (0, child_process_1.execFileSync)('git', ['ls-files', '-z', '-c', '--recurse-submodules'], gitOpts);
571
+ for (const rel of tracked.split('\0')) {
572
+ if (rel)
573
+ files.add((0, utils_1.normalizePath)(prefix + rel));
574
+ }
575
+ // Untracked files (submodules manage their own untracked state). Embedded git
576
+ // repos surface here as a single "subdir/" entry that git refuses to descend
577
+ // into — recurse into those as their own repos so their source gets indexed.
578
+ const untracked = (0, child_process_1.execFileSync)('git', ['ls-files', '-z', '-o', '--exclude-standard'], gitOpts);
579
+ for (const rel of untracked.split('\0')) {
580
+ if (!rel)
581
+ continue;
582
+ if (rel.endsWith('/')) {
583
+ // git only emits a trailing-slash directory entry for an embedded repo.
584
+ // Guard with a .git check anyway, and skip anything else exactly as git
585
+ // itself skips it (we never descend into a non-repo opaque dir). Never
586
+ // descend into default-ignored locations — an embedded repo inside
587
+ // node_modules is an npm git-dependency, not project code.
588
+ const childDir = path.join(repoDir, rel);
589
+ // A git worktree surfaces here as an opaque untracked dir too — skip it,
590
+ // it's a duplicate working view of an already-indexed repo (#848).
591
+ if (classifyGitDir(childDir) === 'embedded' && !defaultsOnlyIgnore().ignores(rel)) {
592
+ embeddedRoots?.add((0, utils_1.normalizePath)(prefix + rel));
593
+ collectGitFiles(childDir, prefix + rel, files, embeddedRoots, includeIgnored);
594
+ }
595
+ continue;
596
+ }
597
+ files.add((0, utils_1.normalizePath)(prefix + rel));
598
+ }
599
+ // Embedded repos hidden by THIS repo's ignore rules (`/packages/` in a
600
+ // super-repo .gitignore) never appear in any listing above. By default they
601
+ // stay hidden — `.gitignore` is respected (#970, #976). They are recursed into
602
+ // only when the project opted the directory in via `codegraph.json`
603
+ // `includeIgnored` (#622, #699), which `findIgnoredEmbeddedRepos` enforces.
604
+ for (const rel of findIgnoredEmbeddedRepos(repoDir, includeIgnored, prefix)) {
605
+ embeddedRoots?.add((0, utils_1.normalizePath)(prefix + rel));
606
+ collectGitFiles(path.join(repoDir, rel), prefix + rel, files, embeddedRoots, includeIgnored);
607
+ }
608
+ }
609
+ /**
610
+ * Get all files visible to git (tracked + untracked but not ignored).
611
+ * Respects .gitignore at all levels (root, subdirectories) and descends into
612
+ * embedded (nested, non-submodule) git repos. Returns null on failure
613
+ * (non-git project) so callers can fall back to a filesystem walk.
614
+ */
615
+ function getGitVisibleFiles(rootDir) {
616
+ try {
617
+ // Check if the project directory is gitignored by a parent repo.
618
+ // When rootDir lives inside a parent git repo that ignores it,
619
+ // `git ls-files` returns nothing — fall back to filesystem walk.
620
+ 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();
621
+ if (path.resolve(gitRoot) !== path.resolve(rootDir)) {
622
+ try {
623
+ // git check-ignore exits 0 if the path IS ignored, 1 if not
624
+ (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 });
625
+ // Directory is gitignored by parent repo — fall back to filesystem walk
626
+ return null;
627
+ }
628
+ catch {
629
+ // Not ignored — safe to use git ls-files
630
+ }
631
+ }
632
+ const files = new Set();
633
+ const embeddedRoots = new Set();
634
+ collectGitFiles(rootDir, '', files, embeddedRoots, loadIncludeIgnoredMatcher(rootDir));
635
+ // Apply built-in default ignores uniformly — to tracked files too, since
636
+ // committing a dependency/build dir doesn't make it project code. A
637
+ // `.gitignore` negation (e.g. `!vendor/`) is the explicit opt-in. (issue #407)
638
+ // Files inside an EMBEDDED repo are matched against that repo's own rules,
639
+ // not the parent's: the parent's .gitignore hides the child repo from git,
640
+ // not from the index. (#514)
641
+ const ig = buildScopeIgnore(rootDir, embeddedRoots);
642
+ return new Set([...files].filter((f) => !ig.ignores(f)));
643
+ }
644
+ catch {
645
+ return null;
646
+ }
647
+ }
648
+ /**
649
+ * Use `git status` to detect changed files instead of scanning every file.
650
+ * Returns null on failure so callers fall back to full scan.
651
+ *
652
+ * Recurses into embedded repos — the untracked kind (#193: the parent's status
653
+ * collapses them to an opaque `?? subdir/` entry) always, and the gitignored
654
+ * kind (#514: they never appear in the parent's status at all) only for
655
+ * directories opted in via `codegraph.json` `includeIgnored` (#622, #699) —
656
+ * running `git status` inside each, so changes in a multi-repo workspace sync
657
+ * without a full rescan. By default a gitignored dir is left alone, matching the
658
+ * full-index scan (#970, #976). Deleting an ENTIRE embedded repo dir is the one
659
+ * case this cannot see (the child status that would report the deletions is gone
660
+ * with it); a full `codegraph index` reconciles that.
661
+ */
662
+ function getGitChangedFiles(rootDir) {
663
+ try {
664
+ const changes = { modified: [], added: [], deleted: [] };
665
+ // Custom extension → language overrides from the project's codegraph.json,
666
+ // so change detection sees the same custom-extension files the full index does.
667
+ const overrides = (0, project_config_1.loadExtensionOverrides)(rootDir);
668
+ collectGitStatus(rootDir, '', changes, overrides, loadIncludeIgnoredMatcher(rootDir), loadExcludeMatcher(rootDir));
669
+ return changes;
670
+ }
671
+ catch {
672
+ return null;
673
+ }
674
+ }
675
+ function collectGitStatus(repoDir, prefix, out, overrides, includeIgnored = null, exclude = null) {
676
+ 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 });
677
+ // This repo's own ignore rules — built-in defaults (#407) plus its .gitignore.
678
+ // Change detection must exclude the SAME files the full index does, but git
679
+ // status hides neither: it ignores nothing for *tracked* paths, and the
680
+ // built-in defaults aren't gitignore at all. Without this filter a committed
681
+ // vendor/ dir, or a tracked file under a .gitignored dir, surfaces here as a
682
+ // change — so `codegraph status` (which reads getChangedFiles) reports a
683
+ // pending edit the full index never tracks and `sync` never clears. Matching
684
+ // repo-relative `rel` at each recursion level mirrors getGitVisibleFiles'
685
+ // ScopeIgnore: every embedded repo is judged by ITS OWN rules, never the
686
+ // parent's. (#766)
687
+ const ig = buildDefaultIgnore(repoDir);
688
+ const untrackedDirs = [];
689
+ for (const line of output.split('\n')) {
690
+ if (line.length < 4)
691
+ continue; // Minimum: "XY file"
692
+ const statusCode = line.substring(0, 2);
693
+ const rel = (0, utils_1.normalizePath)(line.substring(3));
694
+ // Untracked directory entries (trailing slash) may hide an embedded repo —
695
+ // collect for the recursion below instead of treating as a file.
696
+ if (statusCode === '??' && rel.endsWith('/')) {
697
+ untrackedDirs.push(rel);
698
+ continue;
699
+ }
700
+ const filePath = (0, utils_1.normalizePath)(prefix + rel);
701
+ if (!(0, grammars_1.isSourceFile)(filePath, overrides) && !isQuerySqlOnDisk(repoDir, rel))
702
+ continue;
703
+ if (statusCode.includes('D')) {
704
+ // Deletions stay unfiltered: getChangedFiles acts on one only when the
705
+ // path is already tracked in the DB, where removal is always correct — and
706
+ // that lets a newly-excluded dir's stale rows clean themselves up. (#766)
707
+ out.deleted.push(filePath);
708
+ continue;
709
+ }
710
+ // Added (`??`) / modified files inside an excluded dir must not enter the
711
+ // index — match against the repo-relative path, same as the full scan. (#766)
712
+ if (ig.ignores(rel))
713
+ continue;
714
+ // User `codegraph.json` `exclude` (#999) is project-root-relative, so it's
715
+ // matched against the full path — sync must not re-add a tracked file the
716
+ // full index now keeps out. Deletions above stay unfiltered so a file that
717
+ // WAS indexed before an exclude was added still cleans itself out.
718
+ if (exclude && exclude.ignores(filePath))
719
+ continue;
720
+ if (statusCode === '??') {
721
+ out.added.push(filePath);
722
+ }
723
+ else {
724
+ // M, MM, AM, A (staged), etc. — treat as modified
725
+ out.modified.push(filePath);
726
+ }
727
+ }
728
+ // Recurse embedded repos found under untracked dirs (at the dir itself or
729
+ // nested deeper). Gitignored dirs are walked only for the directories the
730
+ // project opted in via `includeIgnored`; by default `.gitignore` is respected
731
+ // and they are left alone (#970, #976), mirroring the full-index scan.
732
+ for (const rel of untrackedDirs) {
733
+ for (const repoRel of findNestedGitRepos(path.join(repoDir, rel), rel)) {
734
+ collectGitStatus(path.join(repoDir, repoRel), prefix + repoRel, out, overrides, includeIgnored, exclude);
735
+ }
736
+ }
737
+ for (const rel of findIgnoredEmbeddedRepos(repoDir, includeIgnored, prefix)) {
738
+ collectGitStatus(path.join(repoDir, rel), prefix + rel, out, overrides, includeIgnored, exclude);
739
+ }
740
+ }
741
+ /**
742
+ * Whether `rel` (repo-relative, under `repoDir`) is a Dysflow saved-query
743
+ * `.sql` — a `.sql` whose on-disk directory also holds a `queries.json`
744
+ * manifest. Used on the incremental-sync path where only one path is known at
745
+ * a time (no full file list to derive the manifest set from).
746
+ */
747
+ function isQuerySqlOnDisk(repoDir, rel) {
748
+ if (!rel.toLowerCase().endsWith('.sql'))
749
+ return false;
750
+ try {
751
+ return fs.existsSync(path.join(repoDir, path.dirname(rel), 'queries.json'));
752
+ }
753
+ catch {
754
+ return false;
755
+ }
756
+ }
757
+ /**
758
+ * POSIX dirname for a normalized repo-relative path. Returns '' for a
759
+ * top-level file (no slash).
760
+ */
761
+ function posixDirOf(p) {
762
+ const i = p.lastIndexOf('/');
763
+ return i < 0 ? '' : p.slice(0, i);
764
+ }
765
+ /**
766
+ * Set of directories (repo-relative POSIX) that contain a `queries.json`
767
+ * manifest, derived from a flat file list. Dysflow writes this manifest
768
+ * beside its exported `<Name>.sql` saved queries; a `.sql` is only treated as
769
+ * an Access query when its directory is in this set, so ordinary `.sql` files
770
+ * in non-Access repos stay ignored.
771
+ */
772
+ function buildQueryDirSet(files) {
773
+ const dirs = new Set();
774
+ for (const f of files) {
775
+ const lower = f.toLowerCase();
776
+ if (lower === 'queries.json' || lower.endsWith('/queries.json')) {
777
+ dirs.add(posixDirOf(f));
778
+ }
779
+ }
780
+ return dirs;
781
+ }
782
+ /**
783
+ * Whether a file should be indexed: a normal source file, OR a Dysflow saved
784
+ * query `.sql` whose directory carries a `queries.json` manifest.
785
+ */
786
+ function isIndexableFile(filePath, overrides, queryDirs) {
787
+ if ((0, grammars_1.isSourceFile)(filePath, overrides))
788
+ return true;
789
+ return (filePath.toLowerCase().endsWith('.sql') &&
790
+ queryDirs.has(posixDirOf(filePath)));
791
+ }
792
+ /**
793
+ * Recursively scan a directory for source files.
794
+ *
795
+ * In git repos, uses `git ls-files` (inherently respects .gitignore at all
796
+ * levels), then keeps files with a supported source extension. For non-git
797
+ * projects, falls back to a filesystem walk that parses .gitignore itself.
798
+ */
799
+ function scanDirectory(rootDir, onProgress) {
800
+ // Custom extension → language overrides from the project's codegraph.json.
801
+ const overrides = (0, project_config_1.loadExtensionOverrides)(rootDir);
802
+ // Fast path: use git to get all visible files (respects .gitignore everywhere)
803
+ const gitFiles = getGitVisibleFiles(rootDir);
804
+ if (gitFiles) {
805
+ const queryDirs = buildQueryDirSet(gitFiles);
806
+ const files = [];
807
+ let count = 0;
808
+ for (const filePath of gitFiles) {
809
+ if (isIndexableFile(filePath, overrides, queryDirs)) {
810
+ files.push(filePath);
811
+ count++;
812
+ onProgress?.(count, filePath);
813
+ }
814
+ }
815
+ return files;
816
+ }
817
+ // Fallback: walk filesystem for non-git projects
818
+ return scanDirectoryWalk(rootDir, onProgress);
819
+ }
820
+ /**
821
+ * Async variant of scanDirectory that yields to the event loop periodically,
822
+ * allowing worker threads to receive and render progress messages.
823
+ */
824
+ async function scanDirectoryAsync(rootDir, onProgress) {
825
+ // Custom extension → language overrides from the project's codegraph.json.
826
+ const overrides = (0, project_config_1.loadExtensionOverrides)(rootDir);
827
+ const gitFiles = getGitVisibleFiles(rootDir);
828
+ if (gitFiles) {
829
+ const queryDirs = buildQueryDirSet(gitFiles);
830
+ const files = [];
831
+ let count = 0;
832
+ for (const filePath of gitFiles) {
833
+ if (isIndexableFile(filePath, overrides, queryDirs)) {
834
+ files.push(filePath);
835
+ count++;
836
+ onProgress?.(count, filePath);
837
+ // Yield every 100 files so worker threads can render progress
838
+ if (count % 100 === 0) {
839
+ await new Promise(r => setImmediate(r));
840
+ }
841
+ }
842
+ }
843
+ return files;
844
+ }
845
+ return scanDirectoryWalk(rootDir, onProgress);
846
+ }
847
+ /**
848
+ * Filesystem walk fallback for non-git projects.
849
+ */
850
+ function scanDirectoryWalk(rootDir, onProgress) {
851
+ const files = [];
852
+ let count = 0;
853
+ const visitedDirs = new Set();
854
+ // Custom extension → language overrides from the project's codegraph.json.
855
+ const overrides = (0, project_config_1.loadExtensionOverrides)(rootDir);
856
+ const loadIgnore = (dir) => {
857
+ const giPath = path.join(dir, '.gitignore');
858
+ if (!fs.existsSync(giPath))
859
+ return null;
860
+ // readGitignorePatterns is defensive: a non-UTF-8 (DLP-encrypted) or
861
+ // uncompilable .gitignore is skipped/filtered with a warning, never thrown
862
+ // (issue #682) — so the per-file `.ignores()` calls below can't crash.
863
+ const patterns = readGitignorePatterns(giPath);
864
+ return patterns ? { dir, ig: (0, ignore_1.default)().add(patterns) } : null;
865
+ };
866
+ const isIgnored = (fullPath, isDir, matchers) => {
867
+ for (const { dir, ig } of matchers) {
868
+ let rel = (0, utils_1.normalizePath)(path.relative(dir, fullPath));
869
+ if (!rel || rel.startsWith('..'))
870
+ continue; // not under this matcher's dir
871
+ if (isDir)
872
+ rel += '/'; // dir-only rules (e.g. `build/`) only match with the slash
873
+ if (ig.ignores(rel))
874
+ return true;
875
+ }
876
+ return false;
877
+ };
878
+ function walk(dir, matchers) {
879
+ let realDir;
880
+ try {
881
+ realDir = fs.realpathSync(dir);
882
+ }
883
+ catch {
884
+ (0, errors_1.logDebug)('Skipping unresolvable directory', { dir });
885
+ return;
886
+ }
887
+ if (visitedDirs.has(realDir)) {
888
+ (0, errors_1.logDebug)('Skipping already-visited directory (symlink cycle)', { dir, realDir });
889
+ return;
890
+ }
891
+ visitedDirs.add(realDir);
892
+ // This directory's own .gitignore (if present) applies to everything below it.
893
+ // The root's .gitignore is already merged into the seeded base matcher (so a
894
+ // negation there can override a built-in default), so skip it here.
895
+ const own = dir === rootDir ? null : loadIgnore(dir);
896
+ const active = own ? [...matchers, own] : matchers;
897
+ let entries;
898
+ try {
899
+ entries = fs.readdirSync(dir, { withFileTypes: true });
900
+ }
901
+ catch (error) {
902
+ (0, errors_1.logDebug)('Skipping unreadable directory', { dir, error: String(error) });
903
+ return;
904
+ }
905
+ // Dysflow exports saved Access queries as `<Name>.sql` alongside a
906
+ // `queries.json` manifest. `.sql` is deliberately not a globally-indexed
907
+ // extension (it would mislabel SQL in non-Access repos), so a `.sql` file
908
+ // counts as a source file only when this directory carries that manifest.
909
+ const hasQueriesManifest = entries.some((e) => e.isFile() && e.name.toLowerCase() === 'queries.json');
910
+ const isIndexable = (rel) => (0, grammars_1.isSourceFile)(rel, overrides) ||
911
+ (hasQueriesManifest && rel.toLowerCase().endsWith('.sql'));
912
+ for (const entry of entries) {
913
+ // Never descend into git internals or any CodeGraph data directory
914
+ // (the active one or a sibling another environment created — #636).
915
+ if (entry.name === '.git' || (0, directory_1.isCodeGraphDataDir)(entry.name))
916
+ continue;
917
+ const fullPath = path.join(dir, entry.name);
918
+ const relativePath = (0, utils_1.normalizePath)(path.relative(rootDir, fullPath));
919
+ if (entry.isSymbolicLink()) {
920
+ try {
921
+ const realTarget = fs.realpathSync(fullPath);
922
+ const stat = fs.statSync(realTarget);
923
+ if (stat.isDirectory()) {
924
+ if (!isIgnored(fullPath, true, active)) {
925
+ walk(fullPath, active);
926
+ }
927
+ }
928
+ else if (stat.isFile()) {
929
+ if (!isIgnored(fullPath, false, active) && isIndexable(relativePath)) {
930
+ files.push(relativePath);
931
+ count++;
932
+ onProgress?.(count, relativePath);
933
+ }
934
+ }
935
+ }
936
+ catch {
937
+ (0, errors_1.logDebug)('Skipping broken symlink', { path: fullPath });
938
+ }
939
+ continue;
940
+ }
941
+ if (entry.isDirectory()) {
942
+ if (!isIgnored(fullPath, true, active)) {
943
+ walk(fullPath, active);
944
+ }
945
+ }
946
+ else if (entry.isFile()) {
947
+ if (!isIgnored(fullPath, false, active) && isIndexable(relativePath)) {
948
+ files.push(relativePath);
949
+ count++;
950
+ onProgress?.(count, relativePath);
951
+ }
952
+ }
953
+ }
954
+ }
955
+ // Seed a base matcher with the built-in default ignores (merged with the root
956
+ // .gitignore so a negation can override). Nested .gitignores still layer per-dir.
957
+ const baseMatchers = [{ dir: rootDir, ig: buildDefaultIgnore(rootDir) }];
958
+ // Project `codegraph.json` `exclude` patterns (#999), rooted at the project so
959
+ // `isIgnored` matches them against root-relative paths — same coverage the
960
+ // git path gets via ScopeIgnore, for non-git projects.
961
+ const exclude = loadExcludeMatcher(rootDir);
962
+ if (exclude)
963
+ baseMatchers.push({ dir: rootDir, ig: exclude });
964
+ walk(rootDir, baseMatchers);
965
+ return files;
966
+ }
967
+ /**
968
+ * Extraction orchestrator
969
+ */
970
+ class ExtractionOrchestrator {
971
+ rootDir;
972
+ queries;
973
+ /**
974
+ * Names of frameworks detected for this project, populated by indexAll().
975
+ * Passed to extractFromSource so framework-specific extractors (route nodes,
976
+ * middleware, etc.) run after the tree-sitter pass. Cleared if detection
977
+ * hasn't run yet so single-file re-index paths can detect on the spot.
978
+ */
979
+ detectedFrameworkNames = null;
980
+ constructor(rootDir, queries) {
981
+ this.rootDir = rootDir;
982
+ this.queries = queries;
983
+ }
984
+ /**
985
+ * Build a filesystem-backed ResolutionContext sufficient for framework
986
+ * detection. Graph-query methods (getNodesByName etc.) return empty because
987
+ * the DB hasn't been populated yet, but detect() only uses readFile,
988
+ * fileExists, and getAllFiles, so that's fine.
989
+ */
990
+ buildDetectionContext(files) {
991
+ const rootDir = this.rootDir;
992
+ return {
993
+ getNodesInFile: () => [],
994
+ getNodesByName: () => [],
995
+ getNodesByQualifiedName: () => [],
996
+ getNodesByKind: () => [],
997
+ getNodesByLowerName: () => [],
998
+ getImportMappings: () => [],
999
+ getAllFiles: () => files,
1000
+ getProjectRoot: () => rootDir,
1001
+ fileExists: (relativePath) => {
1002
+ const full = (0, utils_1.validatePathWithinRoot)(rootDir, relativePath);
1003
+ if (!full)
1004
+ return false;
1005
+ try {
1006
+ return fs.existsSync(full);
1007
+ }
1008
+ catch {
1009
+ return false;
1010
+ }
1011
+ },
1012
+ readFile: (relativePath) => {
1013
+ const full = (0, utils_1.validatePathWithinRoot)(rootDir, relativePath);
1014
+ if (!full)
1015
+ return null;
1016
+ try {
1017
+ return fs.readFileSync(full, 'utf-8');
1018
+ }
1019
+ catch {
1020
+ return null;
1021
+ }
1022
+ },
1023
+ // Monorepo support — needed by framework detect()s that probe
1024
+ // subpackage manifests (e.g. fabric-view looking at
1025
+ // packages/<sub>/package.json when the root manifest is just a
1026
+ // workspace declaration). Matches the resolver-context shape.
1027
+ listDirectories: (relativePath) => {
1028
+ const target = relativePath === '.' || relativePath === ''
1029
+ ? rootDir
1030
+ : path.join(rootDir, relativePath);
1031
+ try {
1032
+ return fs
1033
+ .readdirSync(target, { withFileTypes: true })
1034
+ .filter((entry) => entry.isDirectory())
1035
+ .map((entry) => entry.name);
1036
+ }
1037
+ catch {
1038
+ return [];
1039
+ }
1040
+ },
1041
+ };
1042
+ }
1043
+ /**
1044
+ * Detect frameworks on demand using the current scanned files (or a fresh
1045
+ * scan if none are provided). Cached on the orchestrator so repeat calls
1046
+ * inside a single run don't re-scan.
1047
+ */
1048
+ ensureDetectedFrameworks(files) {
1049
+ if (this.detectedFrameworkNames !== null)
1050
+ return this.detectedFrameworkNames;
1051
+ const fileList = files ?? scanDirectory(this.rootDir);
1052
+ const context = this.buildDetectionContext(fileList);
1053
+ this.detectedFrameworkNames = (0, frameworks_1.detectFrameworks)(context).map((r) => r.name);
1054
+ return this.detectedFrameworkNames;
1055
+ }
1056
+ /**
1057
+ * Index all files in the project
1058
+ */
1059
+ async indexAll(onProgress, signal, verbose) {
1060
+ await (0, grammars_1.initGrammars)();
1061
+ const startTime = Date.now();
1062
+ const errors = [];
1063
+ let filesIndexed = 0;
1064
+ let filesSkipped = 0;
1065
+ let filesErrored = 0;
1066
+ let totalNodes = 0;
1067
+ let totalEdges = 0;
1068
+ // Custom extension → language overrides from the project's codegraph.json.
1069
+ // Threaded into language detection so custom-extension files load the right
1070
+ // grammar and store under the mapped language.
1071
+ const overrides = (0, project_config_1.loadExtensionOverrides)(this.rootDir);
1072
+ const log = verbose
1073
+ ? (msg) => { console.log(`[worker] ${msg}`); }
1074
+ : (_msg) => { };
1075
+ // Phase 1: Scan for files
1076
+ onProgress?.({
1077
+ phase: 'scanning',
1078
+ current: 0,
1079
+ total: 0,
1080
+ });
1081
+ const files = await scanDirectoryAsync(this.rootDir, (current, file) => {
1082
+ onProgress?.({
1083
+ phase: 'scanning',
1084
+ current,
1085
+ total: 0,
1086
+ currentFile: file,
1087
+ });
1088
+ });
1089
+ // Detect frameworks once per indexAll run using the scanned file list.
1090
+ // Names are passed to each parse call so framework-specific extractors
1091
+ // (route nodes, middleware, etc.) run after the tree-sitter pass.
1092
+ // Framework detection is reset each run so adding e.g. requirements.txt
1093
+ // between runs is picked up without restarting the process.
1094
+ this.detectedFrameworkNames = null;
1095
+ const frameworkNames = this.ensureDetectedFrameworks(files);
1096
+ if (signal?.aborted) {
1097
+ return {
1098
+ success: false,
1099
+ filesIndexed: 0,
1100
+ filesSkipped: 0,
1101
+ filesErrored: 0,
1102
+ nodesCreated: 0,
1103
+ edgesCreated: 0,
1104
+ errors: [{ message: 'Aborted', severity: 'error' }],
1105
+ durationMs: Date.now() - startTime,
1106
+ };
1107
+ }
1108
+ // Phase 2: Parse files in a worker thread (keeps main thread unblocked for UI)
1109
+ const total = files.length;
1110
+ let processed = 0;
1111
+ // Emit parsing phase immediately so the progress bar appears during worker setup.
1112
+ // The yield lets the shimmer worker flush the phase transition to stdout before
1113
+ // the main thread starts synchronous grammar detection work.
1114
+ onProgress?.({
1115
+ phase: 'parsing',
1116
+ current: 0,
1117
+ total,
1118
+ });
1119
+ await new Promise(resolve => setImmediate(resolve));
1120
+ // Detect needed languages and load grammars in the parse worker
1121
+ const neededLanguages = [...new Set(files.map((f) => (0, grammars_1.detectLanguage)(f, undefined, overrides)))];
1122
+ // .h files default to 'c' but may be C++ — ensure cpp grammar is loaded when c is needed
1123
+ if (neededLanguages.includes('c') && !neededLanguages.includes('cpp')) {
1124
+ neededLanguages.push('cpp');
1125
+ }
1126
+ // Parse files on a pool of worker threads (keeps the main thread free for UI
1127
+ // and uses every core). Falls back to in-process parsing when the compiled
1128
+ // worker is unavailable (e.g. running from source in tests).
1129
+ const parseWorkerPath = path.join(__dirname, 'parse-worker.js');
1130
+ const useWorker = fs.existsSync(parseWorkerPath);
1131
+ let pool = null;
1132
+ if (useWorker) {
1133
+ // CODEGRAPH_PARSE_WORKERS: explicit worker count; 1 = the old single-worker
1134
+ // behaviour (the conservative rollback). Unset → clamp(cores-1, 1, 8).
1135
+ const poolSize = (0, parse_pool_1.resolveParsePoolSize)(process.env.CODEGRAPH_PARSE_WORKERS, os.cpus().length);
1136
+ pool = new parse_pool_1.ParseWorkerPool({
1137
+ languages: neededLanguages,
1138
+ size: poolSize,
1139
+ workerScriptPath: parseWorkerPath,
1140
+ recycleInterval: WORKER_RECYCLE_INTERVAL,
1141
+ parseTimeoutMs: PARSE_TIMEOUT_MS,
1142
+ log,
1143
+ });
1144
+ log(`Parse worker pool: ${poolSize} worker(s)`);
1145
+ }
1146
+ else {
1147
+ // In-process fallback: load grammars locally and parse on the main thread.
1148
+ await (0, grammars_1.loadGrammarsForLanguages)(neededLanguages);
1149
+ }
1150
+ /**
1151
+ * Parse one file: on the pool when available (the promise REJECTS on a worker
1152
+ * crash/timeout — the caller records it and the retry pass re-attempts), or
1153
+ * in-process synchronously as the no-worker fallback. The language is resolved
1154
+ * here on the main thread, where the codegraph.json overrides are loaded.
1155
+ */
1156
+ const parseFile = (filePath, content) => {
1157
+ const language = (0, grammars_1.detectLanguage)(filePath, content, overrides);
1158
+ if (!pool)
1159
+ return Promise.resolve((0, tree_sitter_1.extractFromSource)(filePath, content, language, frameworkNames));
1160
+ return pool.requestParse({ filePath, content, language, frameworkNames });
1161
+ };
1162
+ // --- Bounded rolling-window dispatch, ordered commit ---
1163
+ // Reads stay batched/parallel; parses run concurrently across the pool; the
1164
+ // SQLite store stays on the main thread (it isn't thread-safe). Crucially we
1165
+ // COMMIT results in original file order, not parse-completion order: the
1166
+ // resolution phase (run after indexing) resolves an ambiguous reference to one
1167
+ // of several same-named candidates by the nodes' DB insertion order, so a
1168
+ // stable commit order keeps the resulting graph deterministic — byte-identical
1169
+ // to the single-worker path — instead of drifting with parse timing. The
1170
+ // `completed` buffer holds at most ~windowSize out-of-order results, so memory
1171
+ // stays bounded.
1172
+ const windowSize = pool ? Math.max(4, pool.size * 2) : 1;
1173
+ const inFlight = new Set();
1174
+ const completed = new Map();
1175
+ let nextSeq = 0; // file-order sequence assigned at dispatch
1176
+ let nextToStore = 0; // cursor: next sequence to commit
1177
+ let aborted = false;
1178
+ const storeResult = (filePath, content, stats, result) => {
1179
+ processed++;
1180
+ // Store in database on main thread (SQLite is not thread-safe)
1181
+ if (result.nodes.length > 0 || result.errors.length === 0) {
1182
+ const language = (0, grammars_1.detectLanguage)(filePath, content, overrides);
1183
+ this.storeExtractionResult(filePath, content, language, stats, result);
1184
+ }
1185
+ if (result.errors.length > 0) {
1186
+ for (const err of result.errors) {
1187
+ if (!err.filePath)
1188
+ err.filePath = filePath;
1189
+ }
1190
+ errors.push(...result.errors);
1191
+ }
1192
+ if (result.nodes.length > 0) {
1193
+ filesIndexed++;
1194
+ totalNodes += result.nodes.length;
1195
+ totalEdges += result.edges.length;
1196
+ }
1197
+ else if (result.errors.some((e) => e.severity === 'error')) {
1198
+ filesErrored++;
1199
+ }
1200
+ else {
1201
+ // Files with no symbols but no errors (yaml, twig, properties) are
1202
+ // tracked at the file level — count them as indexed so the CLI doesn't
1203
+ // misleadingly report "No files found to index".
1204
+ const lang = (0, grammars_1.detectLanguage)(filePath, content, overrides);
1205
+ if ((0, grammars_1.isFileLevelOnlyLanguage)(lang)) {
1206
+ filesIndexed++;
1207
+ }
1208
+ else {
1209
+ filesSkipped++;
1210
+ }
1211
+ }
1212
+ onProgress?.({ phase: 'parsing', current: processed, total, currentFile: filePath });
1213
+ };
1214
+ const recordParseFailure = (filePath, err) => {
1215
+ processed++;
1216
+ filesErrored++;
1217
+ errors.push({
1218
+ message: err instanceof Error ? err.message : String(err),
1219
+ filePath,
1220
+ severity: 'error',
1221
+ code: 'parse_error',
1222
+ });
1223
+ onProgress?.({ phase: 'parsing', current: processed, total });
1224
+ };
1225
+ // Commit buffered parses to the DB in file order, advancing the cursor over
1226
+ // contiguous completed results. Runs after each parse settles (and once more
1227
+ // after the drain). storeResult / recordParseFailure run here single-threaded,
1228
+ // so shared counters and SQLite writes never race despite parallel parsing.
1229
+ const flushOrdered = () => {
1230
+ if (aborted)
1231
+ return;
1232
+ while (completed.has(nextToStore)) {
1233
+ const item = completed.get(nextToStore);
1234
+ completed.delete(nextToStore);
1235
+ nextToStore++;
1236
+ if (item.ok)
1237
+ storeResult(item.filePath, item.content, item.stats, item.result);
1238
+ else
1239
+ recordParseFailure(item.filePath, item.err);
1240
+ }
1241
+ };
1242
+ // Dispatch one file's parse (parses run concurrently across the pool), tagged
1243
+ // with its file-order sequence so flushOrdered commits results in order. The
1244
+ // backpressure below bounds how far parsing runs ahead of the in-order commit.
1245
+ const feed = async (filePath, content, stats) => {
1246
+ const seq = nextSeq++;
1247
+ const p = (async () => {
1248
+ try {
1249
+ const result = await parseFile(filePath, content);
1250
+ completed.set(seq, { ok: true, filePath, content, stats, result });
1251
+ }
1252
+ catch (parseErr) {
1253
+ completed.set(seq, { ok: false, filePath, err: parseErr });
1254
+ }
1255
+ flushOrdered();
1256
+ })();
1257
+ const tracked = p.finally(() => { inFlight.delete(tracked); });
1258
+ inFlight.add(tracked);
1259
+ // Backpressure on the dispatched-but-not-yet-committed count (in-flight +
1260
+ // buffered), not just in-flight: a slow file sitting at the commit cursor
1261
+ // lets later parses finish and buffer, which would otherwise grow without
1262
+ // bound. Wait for parses to settle (each may advance the cursor) until the
1263
+ // window has room. `inFlight.size > 0` guards against an empty race — the
1264
+ // cursor file is always still in flight when the window is full.
1265
+ while (nextSeq - nextToStore >= windowSize && inFlight.size > 0) {
1266
+ await Promise.race(inFlight);
1267
+ }
1268
+ };
1269
+ for (let i = 0; i < files.length; i += FILE_IO_BATCH_SIZE) {
1270
+ if (signal?.aborted) {
1271
+ aborted = true;
1272
+ break;
1273
+ }
1274
+ const batch = files.slice(i, i + FILE_IO_BATCH_SIZE);
1275
+ // Read files in parallel (with path validation before any I/O)
1276
+ const fileContents = await Promise.all(batch.map(async (fp) => {
1277
+ try {
1278
+ // Indexing read: follow in-root symlinks the directory walk already
1279
+ // descended into (the `../` guard still applies) so files reached
1280
+ // via an in-root symlink-to-outside still index (#935).
1281
+ const fullPath = (0, utils_1.validatePathWithinRoot)(this.rootDir, fp, { allowSymlinkEscape: true });
1282
+ if (!fullPath) {
1283
+ (0, errors_1.logWarn)('Path traversal blocked in batch reader', { filePath: fp });
1284
+ return { filePath: fp, content: null, stats: null, error: new Error('Path traversal blocked') };
1285
+ }
1286
+ const content = await fsp.readFile(fullPath, 'utf-8');
1287
+ const stats = await fsp.stat(fullPath);
1288
+ return { filePath: fp, content, stats, error: null };
1289
+ }
1290
+ catch (err) {
1291
+ return { filePath: fp, content: null, stats: null, error: err };
1292
+ }
1293
+ }));
1294
+ // Dispatch each readable file into the bounded parse window; the window
1295
+ // stores results on the main thread as they arrive.
1296
+ for (const { filePath, content, stats, error } of fileContents) {
1297
+ if (signal?.aborted) {
1298
+ aborted = true;
1299
+ break;
1300
+ }
1301
+ if (error || content === null || stats === null) {
1302
+ processed++;
1303
+ filesErrored++;
1304
+ errors.push({
1305
+ message: `Failed to read file: ${error instanceof Error ? error.message : String(error)}`,
1306
+ filePath,
1307
+ severity: 'error',
1308
+ code: 'read_error',
1309
+ });
1310
+ onProgress?.({ phase: 'parsing', current: processed, total });
1311
+ continue;
1312
+ }
1313
+ // Honour MAX_FILE_SIZE. Without this check, vendored generated
1314
+ // headers, minified bundles, and other multi-MB files get indexed,
1315
+ // wasting WASM heap and the worker recycle budget on inputs with no
1316
+ // useful symbols. The single-file extractFile path already enforces
1317
+ // this; the bulk path used to silently skip the check.
1318
+ if (stats.size > MAX_FILE_SIZE) {
1319
+ processed++;
1320
+ filesSkipped++;
1321
+ errors.push({
1322
+ message: `File exceeds max size (${stats.size} > ${MAX_FILE_SIZE})`,
1323
+ filePath,
1324
+ severity: 'warning',
1325
+ code: 'size_exceeded',
1326
+ });
1327
+ onProgress?.({ phase: 'parsing', current: processed, total });
1328
+ continue;
1329
+ }
1330
+ // Parse on the pool (main thread stays unblocked). Errors/timeouts are
1331
+ // handled inside feed() → recordParseFailure, feeding the retry pass.
1332
+ await feed(filePath, content, stats);
1333
+ }
1334
+ if (aborted)
1335
+ break;
1336
+ }
1337
+ // Drain parses still in flight (skip on abort — we tear down below instead),
1338
+ // then commit any results the cursor hasn't reached yet.
1339
+ if (!aborted) {
1340
+ await Promise.all(inFlight);
1341
+ flushOrdered();
1342
+ }
1343
+ if (signal?.aborted || aborted) {
1344
+ if (pool)
1345
+ await pool.destroy();
1346
+ return {
1347
+ success: false,
1348
+ filesIndexed,
1349
+ filesSkipped,
1350
+ filesErrored,
1351
+ nodesCreated: totalNodes,
1352
+ edgesCreated: totalEdges,
1353
+ errors: [{ message: 'Aborted', severity: 'error' }, ...errors],
1354
+ durationMs: Date.now() - startTime,
1355
+ };
1356
+ }
1357
+ // Report 100% so the progress bar doesn't hang at 99%
1358
+ onProgress?.({
1359
+ phase: 'parsing',
1360
+ current: total,
1361
+ total,
1362
+ });
1363
+ // Yield so the shimmer worker's buffered stdout writes can flush.
1364
+ // Worker thread stdout is proxied through the main thread's event loop,
1365
+ // so synchronous work here blocks the animation from rendering.
1366
+ await new Promise(resolve => setImmediate(resolve));
1367
+ // Retry pass: files that failed due to WASM memory corruption may succeed
1368
+ // on a fresh worker with a clean heap. Recycle before each attempt so
1369
+ // every file gets the absolute cleanest WASM state possible.
1370
+ const retryableErrors = errors.filter((e) => e.code === 'parse_error' && e.filePath &&
1371
+ (e.message.includes('Worker exited') || e.message.includes('memory access out of bounds')));
1372
+ if (retryableErrors.length > 0 && pool) {
1373
+ log(`Retrying ${retryableErrors.length} files that failed due to WASM memory errors...`);
1374
+ // Fresh WASM heaps for the retry phase. A retry that still crashes its
1375
+ // worker makes the pool respawn it, so later retries keep landing on clean
1376
+ // workers too.
1377
+ pool.recycleAll();
1378
+ const stillFailing = [];
1379
+ for (const errEntry of retryableErrors) {
1380
+ const filePath = errEntry.filePath;
1381
+ if (signal?.aborted)
1382
+ break;
1383
+ let content;
1384
+ try {
1385
+ const fullPath = (0, utils_1.validatePathWithinRoot)(this.rootDir, filePath);
1386
+ if (!fullPath)
1387
+ continue;
1388
+ content = await fsp.readFile(fullPath, 'utf-8');
1389
+ }
1390
+ catch {
1391
+ continue;
1392
+ }
1393
+ let result;
1394
+ try {
1395
+ result = await parseFile(filePath, content);
1396
+ }
1397
+ catch {
1398
+ stillFailing.push(errEntry);
1399
+ continue;
1400
+ }
1401
+ if (result.nodes.length > 0 || result.errors.length === 0) {
1402
+ const language = (0, grammars_1.detectLanguage)(filePath, content, overrides);
1403
+ const stats = await fsp.stat(path.join(this.rootDir, filePath));
1404
+ this.storeExtractionResult(filePath, content, language, stats, result);
1405
+ const idx = errors.indexOf(errEntry);
1406
+ if (idx >= 0)
1407
+ errors.splice(idx, 1);
1408
+ filesErrored--;
1409
+ filesIndexed++;
1410
+ totalNodes += result.nodes.length;
1411
+ totalEdges += result.edges.length;
1412
+ log(`Retry OK: ${filePath} (${result.nodes.length} nodes)`);
1413
+ }
1414
+ }
1415
+ // Last resort: for files that still crash on a clean worker, strip
1416
+ // comment-only lines to reduce WASM memory pressure. Many compiler
1417
+ // test files are 90%+ comments (CHECK directives) that don't contribute
1418
+ // code nodes but consume parser memory.
1419
+ if (stillFailing.length > 0) {
1420
+ log(`${stillFailing.length} files still failing — retrying with comments stripped...`);
1421
+ pool.recycleAll();
1422
+ for (const errEntry of stillFailing) {
1423
+ const filePath = errEntry.filePath;
1424
+ if (signal?.aborted)
1425
+ break;
1426
+ let fullContent;
1427
+ try {
1428
+ const fullPath = (0, utils_1.validatePathWithinRoot)(this.rootDir, filePath);
1429
+ if (!fullPath)
1430
+ continue;
1431
+ fullContent = await fsp.readFile(fullPath, 'utf-8');
1432
+ }
1433
+ catch {
1434
+ continue;
1435
+ }
1436
+ // Strip lines that are entirely comments (preserving line numbers
1437
+ // by replacing with empty lines so node positions stay correct)
1438
+ const stripped = fullContent
1439
+ .split('\n')
1440
+ .map(line => /^\s*\/\//.test(line) ? '' : line)
1441
+ .join('\n');
1442
+ let result;
1443
+ try {
1444
+ result = await parseFile(filePath, stripped);
1445
+ }
1446
+ catch {
1447
+ continue;
1448
+ }
1449
+ if (result.nodes.length > 0 || result.errors.length === 0) {
1450
+ const language = (0, grammars_1.detectLanguage)(filePath, fullContent, overrides);
1451
+ const stats = await fsp.stat(path.join(this.rootDir, filePath));
1452
+ this.storeExtractionResult(filePath, fullContent, language, stats, result);
1453
+ const idx = errors.indexOf(errEntry);
1454
+ if (idx >= 0)
1455
+ errors.splice(idx, 1);
1456
+ filesErrored--;
1457
+ filesIndexed++;
1458
+ totalNodes += result.nodes.length;
1459
+ totalEdges += result.edges.length;
1460
+ log(`Retry (stripped) OK: ${filePath} (${result.nodes.length} nodes)`);
1461
+ }
1462
+ }
1463
+ }
1464
+ }
1465
+ // Shut down the parse worker pool.
1466
+ if (pool)
1467
+ await pool.destroy();
1468
+ return {
1469
+ success: filesIndexed > 0 || errors.filter((e) => e.severity === 'error').length === 0,
1470
+ filesIndexed,
1471
+ filesSkipped,
1472
+ filesErrored,
1473
+ nodesCreated: totalNodes,
1474
+ edgesCreated: totalEdges,
1475
+ errors,
1476
+ durationMs: Date.now() - startTime,
1477
+ };
1478
+ }
1479
+ /**
1480
+ * Index specific files
1481
+ */
1482
+ async indexFiles(filePaths) {
1483
+ const startTime = Date.now();
1484
+ const errors = [];
1485
+ let filesIndexed = 0;
1486
+ let filesSkipped = 0;
1487
+ let filesErrored = 0;
1488
+ let totalNodes = 0;
1489
+ let totalEdges = 0;
1490
+ for (const filePath of filePaths) {
1491
+ const result = await this.indexFile(filePath);
1492
+ if (result.errors.length > 0) {
1493
+ errors.push(...result.errors);
1494
+ }
1495
+ if (result.nodes.length > 0) {
1496
+ filesIndexed++;
1497
+ totalNodes += result.nodes.length;
1498
+ totalEdges += result.edges.length;
1499
+ }
1500
+ else if (result.errors.some((e) => e.severity === 'error')) {
1501
+ filesErrored++;
1502
+ }
1503
+ else {
1504
+ const tracked = this.queries.getFileByPath(filePath);
1505
+ if (tracked && (0, grammars_1.isFileLevelOnlyLanguage)(tracked.language)) {
1506
+ filesIndexed++;
1507
+ }
1508
+ else {
1509
+ filesSkipped++;
1510
+ }
1511
+ }
1512
+ }
1513
+ return {
1514
+ success: filesIndexed > 0 || errors.filter((e) => e.severity === 'error').length === 0,
1515
+ filesIndexed,
1516
+ filesSkipped,
1517
+ filesErrored,
1518
+ nodesCreated: totalNodes,
1519
+ edgesCreated: totalEdges,
1520
+ errors,
1521
+ durationMs: Date.now() - startTime,
1522
+ };
1523
+ }
1524
+ /**
1525
+ * Index a single file
1526
+ */
1527
+ async indexFile(relativePath) {
1528
+ // Indexing read: follow in-root symlinks (the `../` guard still applies), #935.
1529
+ const fullPath = (0, utils_1.validatePathWithinRoot)(this.rootDir, relativePath, { allowSymlinkEscape: true });
1530
+ if (!fullPath) {
1531
+ return {
1532
+ nodes: [],
1533
+ edges: [],
1534
+ unresolvedReferences: [],
1535
+ errors: [{ message: `Path traversal blocked: ${relativePath}`, filePath: relativePath, severity: 'error', code: 'path_traversal' }],
1536
+ durationMs: 0,
1537
+ };
1538
+ }
1539
+ // Read file content and stats
1540
+ let content;
1541
+ let stats;
1542
+ try {
1543
+ stats = await fsp.stat(fullPath);
1544
+ content = await fsp.readFile(fullPath, 'utf-8');
1545
+ }
1546
+ catch (error) {
1547
+ return {
1548
+ nodes: [],
1549
+ edges: [],
1550
+ unresolvedReferences: [],
1551
+ errors: [
1552
+ {
1553
+ message: `Failed to read file: ${error instanceof Error ? error.message : String(error)}`,
1554
+ filePath: relativePath,
1555
+ severity: 'error',
1556
+ code: 'read_error',
1557
+ },
1558
+ ],
1559
+ durationMs: 0,
1560
+ };
1561
+ }
1562
+ return this.indexFileWithContent(relativePath, content, stats);
1563
+ }
1564
+ /**
1565
+ * Index a single file with pre-read content and stats.
1566
+ * Used by the parallel batch reader to avoid redundant file I/O.
1567
+ */
1568
+ async indexFileWithContent(relativePath, content, stats) {
1569
+ // Prevent `../` traversal; follow in-root symlinks like the directory walk (#935).
1570
+ const fullPath = (0, utils_1.validatePathWithinRoot)(this.rootDir, relativePath, { allowSymlinkEscape: true });
1571
+ if (!fullPath) {
1572
+ (0, errors_1.logWarn)('Path traversal blocked in indexFileWithContent', { relativePath });
1573
+ return {
1574
+ nodes: [],
1575
+ edges: [],
1576
+ unresolvedReferences: [],
1577
+ errors: [{ message: 'Path traversal blocked', filePath: relativePath, severity: 'error', code: 'path_traversal' }],
1578
+ durationMs: 0,
1579
+ };
1580
+ }
1581
+ // Check file size
1582
+ if (stats.size > MAX_FILE_SIZE) {
1583
+ return {
1584
+ nodes: [],
1585
+ edges: [],
1586
+ unresolvedReferences: [],
1587
+ errors: [
1588
+ {
1589
+ message: `File exceeds max size (${stats.size} > ${MAX_FILE_SIZE})`,
1590
+ filePath: relativePath,
1591
+ severity: 'warning',
1592
+ code: 'size_exceeded',
1593
+ },
1594
+ ],
1595
+ durationMs: 0,
1596
+ };
1597
+ }
1598
+ // Detect language (honoring the project's codegraph.json extension overrides)
1599
+ const language = (0, grammars_1.detectLanguage)(relativePath, content, (0, project_config_1.loadExtensionOverrides)(this.rootDir));
1600
+ if (!(0, grammars_1.isLanguageSupported)(language)) {
1601
+ return {
1602
+ nodes: [],
1603
+ edges: [],
1604
+ unresolvedReferences: [],
1605
+ errors: [],
1606
+ durationMs: 0,
1607
+ };
1608
+ }
1609
+ // Extract from source. Use cached framework names if indexAll has run,
1610
+ // otherwise detect on the spot so single-file re-index paths still emit
1611
+ // route nodes / middleware / etc.
1612
+ const frameworkNames = this.ensureDetectedFrameworks();
1613
+ const result = (0, tree_sitter_1.extractFromSource)(relativePath, content, language, frameworkNames);
1614
+ // Store in database
1615
+ if (result.nodes.length > 0 || result.errors.length === 0) {
1616
+ this.storeExtractionResult(relativePath, content, language, stats, result);
1617
+ }
1618
+ return result;
1619
+ }
1620
+ /**
1621
+ * Store extraction result in database
1622
+ */
1623
+ storeExtractionResult(filePath, content, language, stats, result) {
1624
+ const contentHash = hashContent(content);
1625
+ // Check if file already exists and hasn't changed
1626
+ const existingFile = this.queries.getFileByPath(filePath);
1627
+ if (existingFile && existingFile.contentHash === contentHash) {
1628
+ return; // No changes
1629
+ }
1630
+ // Snapshot incoming cross-file edges BEFORE deleting this file's nodes.
1631
+ // `deleteFile` cascades to delete every edge whose source OR target is a
1632
+ // node in this file (edges.FK ... ON DELETE CASCADE). Edges whose SOURCE is
1633
+ // in this file are re-emitted by the extractor below, but edges whose SOURCE
1634
+ // is in a *different* (unchanged) file are not — they would be silently
1635
+ // dropped, which is issue #899: re-indexing a callee file severs `calls`/
1636
+ // `references` edges from callers that import it via module-attribute
1637
+ // access (`pkg.mod.fn(...)`).
1638
+ //
1639
+ // We snapshot the edge plus the target node's (name, kind) so we can
1640
+ // re-resolve to the re-indexed target's NEW id. Node ids are
1641
+ // `sha256(filePath:kind:name:line)`, so any line shift in the callee file
1642
+ // (e.g. a docstring-only edit above the symbol) changes every target id and
1643
+ // a naive re-insert by old id would silently drop every edge. Matching by
1644
+ // (filePath, kind, name) is stable across line shifts; if the symbol was
1645
+ // renamed/removed, no match is found and the edge stays dropped (correct).
1646
+ const crossFileIncomingEdges = this.queries.getCrossFileIncomingEdgesWithTarget(filePath);
1647
+ // Delete existing data for this file
1648
+ if (existingFile) {
1649
+ this.queries.deleteFile(filePath);
1650
+ }
1651
+ // Filter out nodes with missing required fields before insertion.
1652
+ // This prevents FK violations when edges reference nodes that would
1653
+ // be silently skipped by insertNode() (see issue #42).
1654
+ const validNodes = result.nodes.filter((n) => n.id && n.kind && n.name && n.filePath && n.language);
1655
+ // Insert nodes
1656
+ if (validNodes.length > 0) {
1657
+ this.queries.insertNodes(validNodes);
1658
+ }
1659
+ // Filter edges to only reference nodes that were actually inserted
1660
+ if (result.edges.length > 0) {
1661
+ const insertedIds = new Set(validNodes.map((n) => n.id));
1662
+ const validEdges = result.edges.filter((e) => insertedIds.has(e.source) && insertedIds.has(e.target));
1663
+ if (validEdges.length > 0) {
1664
+ this.queries.insertEdges(validEdges);
1665
+ }
1666
+ }
1667
+ // Re-insert cross-file incoming edges snapshotted before the delete,
1668
+ // re-resolving each edge's target to the re-indexed node's new id by
1669
+ // (filePath, kind, name). Node ids include the source line, so any line
1670
+ // shift in the callee file (e.g. a docstring-only edit above the symbol)
1671
+ // changes every target id and a naive re-insert by old id would drop them
1672
+ // all. `insertEdges` still filters to endpoints that exist, so edges whose
1673
+ // caller (source) was deleted, or whose callee (target) was renamed/removed
1674
+ // during the re-index (no match in `newTargetIds`), are dropped. This
1675
+ // closes the #899 edge-drop on `sync`.
1676
+ if (crossFileIncomingEdges.length > 0) {
1677
+ const newNodesByKindName = new Map();
1678
+ for (const n of validNodes) {
1679
+ newNodesByKindName.set(`${n.kind}\0${n.name}`, n.id);
1680
+ }
1681
+ const reinserted = [];
1682
+ for (const e of crossFileIncomingEdges) {
1683
+ const newTargetId = newNodesByKindName.get(`${e.targetKind}\0${e.targetName}`);
1684
+ if (newTargetId) {
1685
+ reinserted.push({ source: e.source, target: newTargetId, kind: e.kind, metadata: e.metadata, line: e.line, column: e.column, provenance: e.provenance });
1686
+ }
1687
+ }
1688
+ if (reinserted.length > 0) {
1689
+ this.queries.insertEdges(reinserted);
1690
+ }
1691
+ }
1692
+ // Insert unresolved references in batch with denormalized filePath/language
1693
+ if (result.unresolvedReferences.length > 0) {
1694
+ const insertedIds = new Set(validNodes.map((n) => n.id));
1695
+ const refsWithContext = result.unresolvedReferences
1696
+ .filter((ref) => insertedIds.has(ref.fromNodeId))
1697
+ .map((ref) => ({
1698
+ ...ref,
1699
+ filePath: ref.filePath ?? filePath,
1700
+ language: ref.language ?? language,
1701
+ }));
1702
+ if (refsWithContext.length > 0) {
1703
+ this.queries.insertUnresolvedRefsBatch(refsWithContext);
1704
+ }
1705
+ }
1706
+ // Insert file record
1707
+ const fileRecord = {
1708
+ path: filePath,
1709
+ contentHash,
1710
+ language,
1711
+ size: stats.size,
1712
+ modifiedAt: stats.mtimeMs,
1713
+ indexedAt: Date.now(),
1714
+ nodeCount: result.nodes.length,
1715
+ errors: result.errors.length > 0 ? result.errors : undefined,
1716
+ };
1717
+ this.queries.upsertFile(fileRecord);
1718
+ }
1719
+ /**
1720
+ * Sync the index with the current file state.
1721
+ *
1722
+ * Change detection is filesystem-based, never git: a (size, mtime) stat
1723
+ * pre-filter skips unchanged files, then a content-hash compare confirms real
1724
+ * changes. This works in non-git projects and catches committed changes from
1725
+ * `git pull`/`checkout`/`merge`/`rebase` that `git status` cannot see.
1726
+ */
1727
+ async sync(onProgress) {
1728
+ await (0, grammars_1.initGrammars)(); // Initialize WASM runtime (grammars loaded lazily below)
1729
+ const startTime = Date.now();
1730
+ let filesChecked = 0;
1731
+ let filesAdded = 0;
1732
+ let filesModified = 0;
1733
+ let filesRemoved = 0;
1734
+ let nodesUpdated = 0;
1735
+ const changedFilePaths = [];
1736
+ onProgress?.({
1737
+ phase: 'scanning',
1738
+ current: 0,
1739
+ total: 0,
1740
+ });
1741
+ const filesToIndex = [];
1742
+ // === Filesystem reconcile (git-independent) ===
1743
+ // The source of truth for "what changed" is the filesystem vs the indexed
1744
+ // state — never git. We enumerate the current source files and reconcile
1745
+ // each against the DB. A cheap (size, mtime) stat pre-filter skips unchanged
1746
+ // files without reading or hashing them, so the expensive read+hash+parse
1747
+ // only runs for files that actually changed. This catches edits/adds/deletes
1748
+ // whether or not the project uses git, and crucially also catches committed
1749
+ // changes from `git pull`/`checkout`/`merge`/`rebase` — which `git status`
1750
+ // cannot see, because the working tree is clean afterward.
1751
+ const currentFiles = await scanDirectoryAsync(this.rootDir);
1752
+ filesChecked = currentFiles.length;
1753
+ const currentSet = new Set(currentFiles);
1754
+ const trackedFiles = this.queries.getAllFiles();
1755
+ const trackedMap = new Map();
1756
+ for (const f of trackedFiles) {
1757
+ trackedMap.set(f.path, f);
1758
+ }
1759
+ // Removals: tracked in the DB but no longer a present source file. Check the
1760
+ // filesystem directly — `scanDirectory` (via `git ls-files`) still lists a
1761
+ // file deleted from disk but not yet staged, so set membership alone misses it.
1762
+ // `reconcileChecks` drives the cooperative yield shared with the adds/mods loop
1763
+ // below (see SYNC_RECONCILE_YIELD_INTERVAL / issue #905).
1764
+ let reconcileChecks = 0;
1765
+ for (const tracked of trackedFiles) {
1766
+ if (!currentSet.has(tracked.path) || !fs.existsSync(path.join(this.rootDir, tracked.path))) {
1767
+ this.queries.deleteFile(tracked.path);
1768
+ filesRemoved++;
1769
+ }
1770
+ if (++reconcileChecks % SYNC_RECONCILE_YIELD_INTERVAL === 0) {
1771
+ await new Promise((resolve) => setImmediate(resolve));
1772
+ }
1773
+ }
1774
+ // Adds / modifications.
1775
+ for (const filePath of currentFiles) {
1776
+ // Same cooperative yield as the removals loop — this is the other O(files)
1777
+ // synchronous-stat loop that wedges the main thread on a large repo (#905).
1778
+ // Yield at the top of the body so the `continue` fast-paths below still hit it.
1779
+ if (++reconcileChecks % SYNC_RECONCILE_YIELD_INTERVAL === 0) {
1780
+ await new Promise((resolve) => setImmediate(resolve));
1781
+ }
1782
+ const fullPath = path.join(this.rootDir, filePath);
1783
+ const tracked = trackedMap.get(filePath);
1784
+ // Cheap pre-filter: an already-indexed file whose size AND mtime both match
1785
+ // the DB is unchanged — skip it without reading or hashing. (A content
1786
+ // change that preserves both exactly is the blind spot every mtime-based
1787
+ // incremental tool accepts; `index --force` is the escape hatch. Git bumps
1788
+ // mtime on every file it writes during checkout/merge, so pulls are caught.)
1789
+ if (tracked) {
1790
+ try {
1791
+ const stat = fs.statSync(fullPath);
1792
+ if (stat.size === tracked.size && Math.floor(stat.mtimeMs) === Math.floor(tracked.modifiedAt)) {
1793
+ continue;
1794
+ }
1795
+ }
1796
+ catch (error) {
1797
+ (0, errors_1.logDebug)('Skipping unstattable file during sync', { filePath, error: String(error) });
1798
+ continue;
1799
+ }
1800
+ }
1801
+ // New, or size/mtime changed — read + hash to confirm a real content change.
1802
+ let content;
1803
+ try {
1804
+ content = fs.readFileSync(fullPath, 'utf-8');
1805
+ }
1806
+ catch (error) {
1807
+ (0, errors_1.logDebug)('Skipping unreadable file during sync', { filePath, error: String(error) });
1808
+ continue;
1809
+ }
1810
+ const contentHash = hashContent(content);
1811
+ if (!tracked) {
1812
+ filesToIndex.push(filePath);
1813
+ changedFilePaths.push(filePath);
1814
+ filesAdded++;
1815
+ }
1816
+ else if (tracked.contentHash !== contentHash) {
1817
+ filesToIndex.push(filePath);
1818
+ changedFilePaths.push(filePath);
1819
+ filesModified++;
1820
+ }
1821
+ }
1822
+ // Load only grammars needed for changed files
1823
+ if (filesToIndex.length > 0) {
1824
+ const overrides = (0, project_config_1.loadExtensionOverrides)(this.rootDir);
1825
+ const neededLanguages = [...new Set(filesToIndex.map((f) => (0, grammars_1.detectLanguage)(f, undefined, overrides)))];
1826
+ // .h files default to 'c' but may be C++ — ensure cpp grammar is loaded
1827
+ if (neededLanguages.includes('c') && !neededLanguages.includes('cpp')) {
1828
+ neededLanguages.push('cpp');
1829
+ }
1830
+ await (0, grammars_1.loadGrammarsForLanguages)(neededLanguages);
1831
+ }
1832
+ // Index changed files
1833
+ const total = filesToIndex.length;
1834
+ for (let i = 0; i < filesToIndex.length; i++) {
1835
+ const filePath = filesToIndex[i];
1836
+ onProgress?.({
1837
+ phase: 'parsing',
1838
+ current: i + 1,
1839
+ total,
1840
+ currentFile: filePath,
1841
+ });
1842
+ const result = await this.indexFile(filePath);
1843
+ nodesUpdated += result.nodes.length;
1844
+ }
1845
+ return {
1846
+ filesChecked,
1847
+ filesAdded,
1848
+ filesModified,
1849
+ filesRemoved,
1850
+ nodesUpdated,
1851
+ durationMs: Date.now() - startTime,
1852
+ changedFilePaths: changedFilePaths.length > 0 ? changedFilePaths : undefined,
1853
+ };
1854
+ }
1855
+ /**
1856
+ * Get files that have changed since last index.
1857
+ * Uses git status as a fast path when available, falling back to full scan.
1858
+ */
1859
+ getChangedFiles() {
1860
+ const gitChanges = getGitChangedFiles(this.rootDir);
1861
+ if (gitChanges) {
1862
+ // === Git fast path ===
1863
+ const added = [];
1864
+ const modified = [];
1865
+ const removed = [];
1866
+ // Deleted files — only report if tracked in DB
1867
+ for (const filePath of gitChanges.deleted) {
1868
+ const tracked = this.queries.getFileByPath(filePath);
1869
+ if (tracked) {
1870
+ removed.push(filePath);
1871
+ }
1872
+ }
1873
+ // Modified + added files — read + hash, compare with DB. Untracked (`??`)
1874
+ // files stay untracked in git even after indexing, so they must be
1875
+ // hash-compared like modified files instead of always counting as added —
1876
+ // otherwise status reports them as pending forever. (See issue #206.)
1877
+ for (const filePath of [...gitChanges.modified, ...gitChanges.added]) {
1878
+ const fullPath = path.join(this.rootDir, filePath);
1879
+ let content;
1880
+ try {
1881
+ content = fs.readFileSync(fullPath, 'utf-8');
1882
+ }
1883
+ catch (error) {
1884
+ (0, errors_1.logDebug)('Skipping unreadable file while detecting changes', { filePath, error: String(error) });
1885
+ continue;
1886
+ }
1887
+ const contentHash = hashContent(content);
1888
+ const tracked = this.queries.getFileByPath(filePath);
1889
+ if (!tracked) {
1890
+ added.push(filePath);
1891
+ }
1892
+ else if (tracked.contentHash !== contentHash) {
1893
+ modified.push(filePath);
1894
+ }
1895
+ }
1896
+ return { added, modified, removed };
1897
+ }
1898
+ // === Fallback: full scan (non-git project or git failure) ===
1899
+ const currentFiles = new Set(scanDirectory(this.rootDir));
1900
+ const trackedFiles = this.queries.getAllFiles();
1901
+ // Build Map for O(1) lookups
1902
+ const trackedMap = new Map();
1903
+ for (const f of trackedFiles) {
1904
+ trackedMap.set(f.path, f);
1905
+ }
1906
+ const added = [];
1907
+ const modified = [];
1908
+ const removed = [];
1909
+ // Find removed files
1910
+ for (const tracked of trackedFiles) {
1911
+ if (!currentFiles.has(tracked.path)) {
1912
+ removed.push(tracked.path);
1913
+ }
1914
+ }
1915
+ // Find added and modified files
1916
+ for (const filePath of currentFiles) {
1917
+ const fullPath = path.join(this.rootDir, filePath);
1918
+ let content;
1919
+ try {
1920
+ content = fs.readFileSync(fullPath, 'utf-8');
1921
+ }
1922
+ catch (error) {
1923
+ (0, errors_1.logDebug)('Skipping unreadable file while detecting changes', { filePath, error: String(error) });
1924
+ continue;
1925
+ }
1926
+ const contentHash = hashContent(content);
1927
+ const tracked = trackedMap.get(filePath);
1928
+ if (!tracked) {
1929
+ added.push(filePath);
1930
+ }
1931
+ else if (tracked.contentHash !== contentHash) {
1932
+ modified.push(filePath);
1933
+ }
1934
+ }
1935
+ return { added, modified, removed };
1936
+ }
1937
+ }
1938
+ exports.ExtractionOrchestrator = ExtractionOrchestrator;
1939
+ // Re-export useful types and functions
1940
+ var tree_sitter_2 = require("./tree-sitter");
1941
+ Object.defineProperty(exports, "extractFromSource", { enumerable: true, get: function () { return tree_sitter_2.extractFromSource; } });
1942
+ var grammars_2 = require("./grammars");
1943
+ Object.defineProperty(exports, "detectLanguage", { enumerable: true, get: function () { return grammars_2.detectLanguage; } });
1944
+ Object.defineProperty(exports, "isSourceFile", { enumerable: true, get: function () { return grammars_2.isSourceFile; } });
1945
+ Object.defineProperty(exports, "isLanguageSupported", { enumerable: true, get: function () { return grammars_2.isLanguageSupported; } });
1946
+ Object.defineProperty(exports, "isGrammarLoaded", { enumerable: true, get: function () { return grammars_2.isGrammarLoaded; } });
1947
+ Object.defineProperty(exports, "getSupportedLanguages", { enumerable: true, get: function () { return grammars_2.getSupportedLanguages; } });
1948
+ Object.defineProperty(exports, "initGrammars", { enumerable: true, get: function () { return grammars_2.initGrammars; } });
1949
+ Object.defineProperty(exports, "loadGrammarsForLanguages", { enumerable: true, get: function () { return grammars_2.loadGrammarsForLanguages; } });
1950
+ Object.defineProperty(exports, "loadAllGrammars", { enumerable: true, get: function () { return grammars_2.loadAllGrammars; } });
1951
+ //# sourceMappingURL=index.js.map