@colbymchenry/codegraph-win32-arm64 1.6.1 → 1.6.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 (1094) hide show
  1. package/bin/codegraph +1 -1
  2. package/bin/codegraph.cmd +1 -1
  3. package/lib/dist/.test-build-engine.json +1 -1
  4. package/lib/dist/.test-build-viewer.json +1 -1
  5. package/lib/dist/bin/codegraph.d.ts +3 -0
  6. package/lib/dist/bin/codegraph.d.ts.map +1 -1
  7. package/lib/dist/bin/codegraph.js +427 -684
  8. package/lib/dist/bin/codegraph.js.map +1 -1
  9. package/lib/dist/bin/command-supervision.d.ts +7 -0
  10. package/lib/dist/bin/command-supervision.d.ts.map +1 -1
  11. package/lib/dist/bin/command-supervision.js +30 -74
  12. package/lib/dist/bin/command-supervision.js.map +1 -1
  13. package/lib/dist/bin/fatal-handler.js +0 -46
  14. package/lib/dist/bin/fatal-handler.js.map +1 -1
  15. package/lib/dist/bin/node-version-check.js +0 -33
  16. package/lib/dist/bin/node-version-check.js.map +1 -1
  17. package/lib/dist/bin/uninstall.js +0 -19
  18. package/lib/dist/bin/uninstall.js.map +1 -1
  19. package/lib/dist/bin/viewer-gate.js +0 -14
  20. package/lib/dist/bin/viewer-gate.js.map +1 -1
  21. package/lib/dist/compile-cache.d.ts +2 -0
  22. package/lib/dist/compile-cache.d.ts.map +1 -0
  23. package/lib/dist/compile-cache.js +45 -0
  24. package/lib/dist/compile-cache.js.map +1 -0
  25. package/lib/dist/context/formatter.js +3 -66
  26. package/lib/dist/context/formatter.js.map +1 -1
  27. package/lib/dist/context/index.d.ts +44 -1
  28. package/lib/dist/context/index.d.ts.map +1 -1
  29. package/lib/dist/context/index.js +123 -430
  30. package/lib/dist/context/index.js.map +1 -1
  31. package/lib/dist/context/markers.js +0 -17
  32. package/lib/dist/context/markers.js.map +1 -1
  33. package/lib/dist/db/index.d.ts +44 -1
  34. package/lib/dist/db/index.d.ts.map +1 -1
  35. package/lib/dist/db/index.js +123 -395
  36. package/lib/dist/db/index.js.map +1 -1
  37. package/lib/dist/db/migrations.d.ts +11 -1
  38. package/lib/dist/db/migrations.d.ts.map +1 -1
  39. package/lib/dist/db/migrations.js +71 -79
  40. package/lib/dist/db/migrations.js.map +1 -1
  41. package/lib/dist/db/name-substring-index.d.ts +63 -0
  42. package/lib/dist/db/name-substring-index.d.ts.map +1 -0
  43. package/lib/dist/db/name-substring-index.js +151 -0
  44. package/lib/dist/db/name-substring-index.js.map +1 -0
  45. package/lib/dist/db/node-sqlite.d.ts +19 -0
  46. package/lib/dist/db/node-sqlite.d.ts.map +1 -0
  47. package/lib/dist/db/node-sqlite.js +23 -0
  48. package/lib/dist/db/node-sqlite.js.map +1 -0
  49. package/lib/dist/db/open-error.d.ts +36 -0
  50. package/lib/dist/db/open-error.d.ts.map +1 -0
  51. package/lib/dist/db/open-error.js +63 -0
  52. package/lib/dist/db/open-error.js.map +1 -0
  53. package/lib/dist/db/parameter-flow-queries.d.ts +120 -0
  54. package/lib/dist/db/parameter-flow-queries.d.ts.map +1 -0
  55. package/lib/dist/db/parameter-flow-queries.js +168 -0
  56. package/lib/dist/db/parameter-flow-queries.js.map +1 -0
  57. package/lib/dist/db/queries.d.ts +641 -40
  58. package/lib/dist/db/queries.d.ts.map +1 -1
  59. package/lib/dist/db/queries.js +1370 -1398
  60. package/lib/dist/db/queries.js.map +1 -1
  61. package/lib/dist/db/reference-tail.d.ts +83 -0
  62. package/lib/dist/db/reference-tail.d.ts.map +1 -0
  63. package/lib/dist/db/reference-tail.js +68 -0
  64. package/lib/dist/db/reference-tail.js.map +1 -0
  65. package/lib/dist/db/schema.sql +18 -2
  66. package/lib/dist/db/sqlite-adapter.d.ts +18 -1
  67. package/lib/dist/db/sqlite-adapter.d.ts.map +1 -1
  68. package/lib/dist/db/sqlite-adapter.js +12 -62
  69. package/lib/dist/db/sqlite-adapter.js.map +1 -1
  70. package/lib/dist/db/synthesis-stage.d.ts.map +1 -1
  71. package/lib/dist/db/synthesis-stage.js +2 -6
  72. package/lib/dist/db/synthesis-stage.js.map +1 -1
  73. package/lib/dist/db/wal-valve.js +1 -153
  74. package/lib/dist/db/wal-valve.js.map +1 -1
  75. package/lib/dist/db/wsl-shared-index.js +0 -37
  76. package/lib/dist/db/wsl-shared-index.js.map +1 -1
  77. package/lib/dist/directory.d.ts +81 -0
  78. package/lib/dist/directory.d.ts.map +1 -1
  79. package/lib/dist/directory.js +91 -500
  80. package/lib/dist/directory.js.map +1 -1
  81. package/lib/dist/engine.d.ts +15 -0
  82. package/lib/dist/engine.d.ts.map +1 -0
  83. package/lib/dist/engine.js +34 -0
  84. package/lib/dist/engine.js.map +1 -0
  85. package/lib/dist/errors.d.ts +10 -0
  86. package/lib/dist/errors.d.ts.map +1 -1
  87. package/lib/dist/errors.js +8 -101
  88. package/lib/dist/errors.js.map +1 -1
  89. package/lib/dist/extraction/astro-extractor.d.ts.map +1 -1
  90. package/lib/dist/extraction/astro-extractor.js +15 -133
  91. package/lib/dist/extraction/astro-extractor.js.map +1 -1
  92. package/lib/dist/extraction/cfml-extractor.d.ts +102 -10
  93. package/lib/dist/extraction/cfml-extractor.d.ts.map +1 -1
  94. package/lib/dist/extraction/cfml-extractor.js +260 -179
  95. package/lib/dist/extraction/cfml-extractor.js.map +1 -1
  96. package/lib/dist/extraction/commonjs-requires.d.ts +23 -0
  97. package/lib/dist/extraction/commonjs-requires.d.ts.map +1 -0
  98. package/lib/dist/extraction/commonjs-requires.js +37 -0
  99. package/lib/dist/extraction/commonjs-requires.js.map +1 -0
  100. package/lib/dist/extraction/dfm-extractor.js +0 -21
  101. package/lib/dist/extraction/dfm-extractor.js.map +1 -1
  102. package/lib/dist/extraction/extraction-version.d.ts +1 -1
  103. package/lib/dist/extraction/extraction-version.js +1 -24
  104. package/lib/dist/extraction/extraction-version.js.map +1 -1
  105. package/lib/dist/extraction/function-ref.d.ts +40 -0
  106. package/lib/dist/extraction/function-ref.d.ts.map +1 -1
  107. package/lib/dist/extraction/function-ref.js +145 -206
  108. package/lib/dist/extraction/function-ref.js.map +1 -1
  109. package/lib/dist/extraction/generated-detection.d.ts +9 -0
  110. package/lib/dist/extraction/generated-detection.d.ts.map +1 -1
  111. package/lib/dist/extraction/generated-detection.js +29 -154
  112. package/lib/dist/extraction/generated-detection.js.map +1 -1
  113. package/lib/dist/extraction/grammars.d.ts +47 -4
  114. package/lib/dist/extraction/grammars.d.ts.map +1 -1
  115. package/lib/dist/extraction/grammars.js +91 -374
  116. package/lib/dist/extraction/grammars.js.map +1 -1
  117. package/lib/dist/extraction/index.d.ts +216 -11
  118. package/lib/dist/extraction/index.d.ts.map +1 -1
  119. package/lib/dist/extraction/index.js +703 -1368
  120. package/lib/dist/extraction/index.js.map +1 -1
  121. package/lib/dist/extraction/kernel/decode.js +0 -16
  122. package/lib/dist/extraction/kernel/decode.js.map +1 -1
  123. package/lib/dist/extraction/kernel/index.d.ts +3 -1
  124. package/lib/dist/extraction/kernel/index.d.ts.map +1 -1
  125. package/lib/dist/extraction/kernel/index.js +29 -131
  126. package/lib/dist/extraction/kernel/index.js.map +1 -1
  127. package/lib/dist/extraction/kernel/layout.js +42 -76
  128. package/lib/dist/extraction/kernel/layout.js.map +1 -1
  129. package/lib/dist/extraction/kernel/loader.js +0 -37
  130. package/lib/dist/extraction/kernel/loader.js.map +1 -1
  131. package/lib/dist/extraction/languages/arkts.js +0 -59
  132. package/lib/dist/extraction/languages/arkts.js.map +1 -1
  133. package/lib/dist/extraction/languages/c-cpp.d.ts +140 -28
  134. package/lib/dist/extraction/languages/c-cpp.d.ts.map +1 -1
  135. package/lib/dist/extraction/languages/c-cpp.js +876 -823
  136. package/lib/dist/extraction/languages/c-cpp.js.map +1 -1
  137. package/lib/dist/extraction/languages/cfquery.js +0 -9
  138. package/lib/dist/extraction/languages/cfquery.js.map +1 -1
  139. package/lib/dist/extraction/languages/cfscript.d.ts +20 -0
  140. package/lib/dist/extraction/languages/cfscript.d.ts.map +1 -1
  141. package/lib/dist/extraction/languages/cfscript.js +80 -9
  142. package/lib/dist/extraction/languages/cfscript.js.map +1 -1
  143. package/lib/dist/extraction/languages/cobol.js +0 -114
  144. package/lib/dist/extraction/languages/cobol.js.map +1 -1
  145. package/lib/dist/extraction/languages/cpp-brace-scopes.d.ts +66 -0
  146. package/lib/dist/extraction/languages/cpp-brace-scopes.d.ts.map +1 -0
  147. package/lib/dist/extraction/languages/cpp-brace-scopes.js +343 -0
  148. package/lib/dist/extraction/languages/cpp-brace-scopes.js.map +1 -0
  149. package/lib/dist/extraction/languages/cpp-macro-methods.d.ts +41 -0
  150. package/lib/dist/extraction/languages/cpp-macro-methods.d.ts.map +1 -0
  151. package/lib/dist/extraction/languages/cpp-macro-methods.js +487 -0
  152. package/lib/dist/extraction/languages/cpp-macro-methods.js.map +1 -0
  153. package/lib/dist/extraction/languages/csharp.d.ts.map +1 -1
  154. package/lib/dist/extraction/languages/csharp.js +11 -54
  155. package/lib/dist/extraction/languages/csharp.js.map +1 -1
  156. package/lib/dist/extraction/languages/dart.d.ts +84 -0
  157. package/lib/dist/extraction/languages/dart.d.ts.map +1 -1
  158. package/lib/dist/extraction/languages/dart.js +335 -159
  159. package/lib/dist/extraction/languages/dart.js.map +1 -1
  160. package/lib/dist/extraction/languages/erlang.d.ts.map +1 -1
  161. package/lib/dist/extraction/languages/erlang.js +15 -102
  162. package/lib/dist/extraction/languages/erlang.js.map +1 -1
  163. package/lib/dist/extraction/languages/go.d.ts +48 -0
  164. package/lib/dist/extraction/languages/go.d.ts.map +1 -1
  165. package/lib/dist/extraction/languages/go.js +102 -31
  166. package/lib/dist/extraction/languages/go.js.map +1 -1
  167. package/lib/dist/extraction/languages/index.js +0 -6
  168. package/lib/dist/extraction/languages/index.js.map +1 -1
  169. package/lib/dist/extraction/languages/java.d.ts.map +1 -1
  170. package/lib/dist/extraction/languages/java.js +67 -78
  171. package/lib/dist/extraction/languages/java.js.map +1 -1
  172. package/lib/dist/extraction/languages/javascript.d.ts.map +1 -1
  173. package/lib/dist/extraction/languages/javascript.js +2 -12
  174. package/lib/dist/extraction/languages/javascript.js.map +1 -1
  175. package/lib/dist/extraction/languages/kotlin.d.ts +15 -0
  176. package/lib/dist/extraction/languages/kotlin.d.ts.map +1 -1
  177. package/lib/dist/extraction/languages/kotlin.js +69 -150
  178. package/lib/dist/extraction/languages/kotlin.js.map +1 -1
  179. package/lib/dist/extraction/languages/lua.js +2 -39
  180. package/lib/dist/extraction/languages/lua.js.map +1 -1
  181. package/lib/dist/extraction/languages/luau.js +0 -14
  182. package/lib/dist/extraction/languages/luau.js.map +1 -1
  183. package/lib/dist/extraction/languages/nix.js +0 -16
  184. package/lib/dist/extraction/languages/nix.js.map +1 -1
  185. package/lib/dist/extraction/languages/objc.d.ts.map +1 -1
  186. package/lib/dist/extraction/languages/objc.js +5 -16
  187. package/lib/dist/extraction/languages/objc.js.map +1 -1
  188. package/lib/dist/extraction/languages/pascal-preparse.d.ts +66 -0
  189. package/lib/dist/extraction/languages/pascal-preparse.d.ts.map +1 -0
  190. package/lib/dist/extraction/languages/pascal-preparse.js +958 -0
  191. package/lib/dist/extraction/languages/pascal-preparse.js.map +1 -0
  192. package/lib/dist/extraction/languages/pascal-system.d.ts +11 -0
  193. package/lib/dist/extraction/languages/pascal-system.d.ts.map +1 -0
  194. package/lib/dist/extraction/languages/pascal-system.js +23 -0
  195. package/lib/dist/extraction/languages/pascal-system.js.map +1 -0
  196. package/lib/dist/extraction/languages/pascal.d.ts.map +1 -1
  197. package/lib/dist/extraction/languages/pascal.js +3 -4
  198. package/lib/dist/extraction/languages/pascal.js.map +1 -1
  199. package/lib/dist/extraction/languages/php.js +5 -42
  200. package/lib/dist/extraction/languages/php.js.map +1 -1
  201. package/lib/dist/extraction/languages/python.js +2 -20
  202. package/lib/dist/extraction/languages/python.js.map +1 -1
  203. package/lib/dist/extraction/languages/r.js +8 -78
  204. package/lib/dist/extraction/languages/r.js.map +1 -1
  205. package/lib/dist/extraction/languages/ruby.d.ts.map +1 -1
  206. package/lib/dist/extraction/languages/ruby.js +17 -25
  207. package/lib/dist/extraction/languages/ruby.js.map +1 -1
  208. package/lib/dist/extraction/languages/rust.d.ts +10 -0
  209. package/lib/dist/extraction/languages/rust.d.ts.map +1 -1
  210. package/lib/dist/extraction/languages/rust.js +15 -47
  211. package/lib/dist/extraction/languages/rust.js.map +1 -1
  212. package/lib/dist/extraction/languages/scala.js +5 -41
  213. package/lib/dist/extraction/languages/scala.js.map +1 -1
  214. package/lib/dist/extraction/languages/solidity.js +1 -82
  215. package/lib/dist/extraction/languages/solidity.js.map +1 -1
  216. package/lib/dist/extraction/languages/swift.d.ts +15 -0
  217. package/lib/dist/extraction/languages/swift.d.ts.map +1 -1
  218. package/lib/dist/extraction/languages/swift.js +33 -27
  219. package/lib/dist/extraction/languages/swift.js.map +1 -1
  220. package/lib/dist/extraction/languages/terraform.js +6 -152
  221. package/lib/dist/extraction/languages/terraform.js.map +1 -1
  222. package/lib/dist/extraction/languages/typescript.d.ts +71 -0
  223. package/lib/dist/extraction/languages/typescript.d.ts.map +1 -1
  224. package/lib/dist/extraction/languages/typescript.js +86 -41
  225. package/lib/dist/extraction/languages/typescript.js.map +1 -1
  226. package/lib/dist/extraction/languages/vbnet.d.ts.map +1 -1
  227. package/lib/dist/extraction/languages/vbnet.js +9 -42
  228. package/lib/dist/extraction/languages/vbnet.js.map +1 -1
  229. package/lib/dist/extraction/lazy-frameworks.d.ts +15 -0
  230. package/lib/dist/extraction/lazy-frameworks.d.ts.map +1 -0
  231. package/lib/dist/extraction/lazy-frameworks.js +8 -0
  232. package/lib/dist/extraction/lazy-frameworks.js.map +1 -0
  233. package/lib/dist/extraction/liquid-extractor.d.ts +29 -3
  234. package/lib/dist/extraction/liquid-extractor.d.ts.map +1 -1
  235. package/lib/dist/extraction/liquid-extractor.js +89 -148
  236. package/lib/dist/extraction/liquid-extractor.js.map +1 -1
  237. package/lib/dist/extraction/mybatis-extractor.js +0 -78
  238. package/lib/dist/extraction/mybatis-extractor.js.map +1 -1
  239. package/lib/dist/extraction/parse-budget.d.ts +16 -0
  240. package/lib/dist/extraction/parse-budget.d.ts.map +1 -0
  241. package/lib/dist/extraction/parse-budget.js +11 -0
  242. package/lib/dist/extraction/parse-budget.js.map +1 -0
  243. package/lib/dist/extraction/parse-pool.d.ts +41 -5
  244. package/lib/dist/extraction/parse-pool.d.ts.map +1 -1
  245. package/lib/dist/extraction/parse-pool.js +74 -158
  246. package/lib/dist/extraction/parse-pool.js.map +1 -1
  247. package/lib/dist/extraction/parse-worker.d.ts +1 -1
  248. package/lib/dist/extraction/parse-worker.d.ts.map +1 -1
  249. package/lib/dist/extraction/parse-worker.js +7 -58
  250. package/lib/dist/extraction/parse-worker.js.map +1 -1
  251. package/lib/dist/extraction/razor-extractor.d.ts +9 -0
  252. package/lib/dist/extraction/razor-extractor.d.ts.map +1 -1
  253. package/lib/dist/extraction/razor-extractor.js +45 -69
  254. package/lib/dist/extraction/razor-extractor.js.map +1 -1
  255. package/lib/dist/extraction/razor-script.d.ts +23 -0
  256. package/lib/dist/extraction/razor-script.d.ts.map +1 -0
  257. package/lib/dist/extraction/razor-script.js +244 -0
  258. package/lib/dist/extraction/razor-script.js.map +1 -0
  259. package/lib/dist/extraction/sfc-script.d.ts +85 -0
  260. package/lib/dist/extraction/sfc-script.d.ts.map +1 -0
  261. package/lib/dist/extraction/sfc-script.js +136 -0
  262. package/lib/dist/extraction/sfc-script.js.map +1 -0
  263. package/lib/dist/extraction/store-worker.d.ts +1 -1
  264. package/lib/dist/extraction/store-worker.d.ts.map +1 -1
  265. package/lib/dist/extraction/store-worker.js +5 -37
  266. package/lib/dist/extraction/store-worker.js.map +1 -1
  267. package/lib/dist/extraction/store-writer.d.ts +10 -2
  268. package/lib/dist/extraction/store-writer.d.ts.map +1 -1
  269. package/lib/dist/extraction/store-writer.js +8 -32
  270. package/lib/dist/extraction/store-writer.js.map +1 -1
  271. package/lib/dist/extraction/svelte-extractor.d.ts.map +1 -1
  272. package/lib/dist/extraction/svelte-extractor.js +16 -122
  273. package/lib/dist/extraction/svelte-extractor.js.map +1 -1
  274. package/lib/dist/extraction/syntax-tokens.d.ts +6 -5
  275. package/lib/dist/extraction/syntax-tokens.d.ts.map +1 -1
  276. package/lib/dist/extraction/syntax-tokens.js +6 -153
  277. package/lib/dist/extraction/syntax-tokens.js.map +1 -1
  278. package/lib/dist/extraction/tree-sitter-helpers.d.ts +37 -1
  279. package/lib/dist/extraction/tree-sitter-helpers.d.ts.map +1 -1
  280. package/lib/dist/extraction/tree-sitter-helpers.js +76 -68
  281. package/lib/dist/extraction/tree-sitter-helpers.js.map +1 -1
  282. package/lib/dist/extraction/tree-sitter-types.d.ts +102 -22
  283. package/lib/dist/extraction/tree-sitter-types.d.ts.map +1 -1
  284. package/lib/dist/extraction/tree-sitter-types.js +0 -7
  285. package/lib/dist/extraction/tree-sitter-types.js.map +1 -1
  286. package/lib/dist/extraction/tree-sitter.d.ts +455 -9
  287. package/lib/dist/extraction/tree-sitter.d.ts.map +1 -1
  288. package/lib/dist/extraction/tree-sitter.js +1998 -2517
  289. package/lib/dist/extraction/tree-sitter.js.map +1 -1
  290. package/lib/dist/extraction/vue-extractor.d.ts +20 -0
  291. package/lib/dist/extraction/vue-extractor.d.ts.map +1 -1
  292. package/lib/dist/extraction/vue-extractor.js +113 -115
  293. package/lib/dist/extraction/vue-extractor.js.map +1 -1
  294. package/lib/dist/extraction/vue-options-api.d.ts +28 -0
  295. package/lib/dist/extraction/vue-options-api.d.ts.map +1 -0
  296. package/lib/dist/extraction/vue-options-api.js +164 -0
  297. package/lib/dist/extraction/vue-options-api.js.map +1 -0
  298. package/lib/dist/extraction/vue-template-calls.d.ts +37 -0
  299. package/lib/dist/extraction/vue-template-calls.d.ts.map +1 -0
  300. package/lib/dist/extraction/vue-template-calls.js +497 -0
  301. package/lib/dist/extraction/vue-template-calls.js.map +1 -0
  302. package/lib/dist/extraction/wasm/tree-sitter-cobol.wasm +0 -0
  303. package/lib/dist/extraction/wasm/tree-sitter-kotlin.wasm +0 -0
  304. package/lib/dist/extraction/wasm/tree-sitter-vbnet.wasm +0 -0
  305. package/lib/dist/extraction/wasm-runtime-flags.d.ts +6 -0
  306. package/lib/dist/extraction/wasm-runtime-flags.d.ts.map +1 -1
  307. package/lib/dist/extraction/wasm-runtime-flags.js +1 -88
  308. package/lib/dist/extraction/wasm-runtime-flags.js.map +1 -1
  309. package/lib/dist/file-limits.d.ts +8 -0
  310. package/lib/dist/file-limits.d.ts.map +1 -1
  311. package/lib/dist/file-limits.js +13 -28
  312. package/lib/dist/file-limits.js.map +1 -1
  313. package/lib/dist/graph/branch-guards.d.ts +17 -0
  314. package/lib/dist/graph/branch-guards.d.ts.map +1 -1
  315. package/lib/dist/graph/branch-guards.js +98 -250
  316. package/lib/dist/graph/branch-guards.js.map +1 -1
  317. package/lib/dist/graph/call-sites.d.ts +12 -0
  318. package/lib/dist/graph/call-sites.d.ts.map +1 -0
  319. package/lib/dist/graph/call-sites.js +17 -0
  320. package/lib/dist/graph/call-sites.js.map +1 -0
  321. package/lib/dist/graph/cobol-copybooks.d.ts +75 -0
  322. package/lib/dist/graph/cobol-copybooks.d.ts.map +1 -0
  323. package/lib/dist/graph/cobol-copybooks.js +45 -0
  324. package/lib/dist/graph/cobol-copybooks.js.map +1 -0
  325. package/lib/dist/graph/dead-code.d.ts +26 -4
  326. package/lib/dist/graph/dead-code.d.ts.map +1 -1
  327. package/lib/dist/graph/dead-code.js +157 -311
  328. package/lib/dist/graph/dead-code.js.map +1 -1
  329. package/lib/dist/graph/dynamic-boundary-report.js +1 -88
  330. package/lib/dist/graph/dynamic-boundary-report.js.map +1 -1
  331. package/lib/dist/graph/file-cycles.d.ts +20 -0
  332. package/lib/dist/graph/file-cycles.d.ts.map +1 -0
  333. package/lib/dist/graph/file-cycles.js +79 -0
  334. package/lib/dist/graph/file-cycles.js.map +1 -0
  335. package/lib/dist/graph/go-package.d.ts +27 -0
  336. package/lib/dist/graph/go-package.d.ts.map +1 -0
  337. package/lib/dist/graph/go-package.js +49 -0
  338. package/lib/dist/graph/go-package.js.map +1 -0
  339. package/lib/dist/graph/index.d.ts +2 -0
  340. package/lib/dist/graph/index.d.ts.map +1 -1
  341. package/lib/dist/graph/index.js +4 -6
  342. package/lib/dist/graph/index.js.map +1 -1
  343. package/lib/dist/graph/named-symbol-flow.d.ts +5 -1
  344. package/lib/dist/graph/named-symbol-flow.d.ts.map +1 -1
  345. package/lib/dist/graph/named-symbol-flow.js +85 -219
  346. package/lib/dist/graph/named-symbol-flow.js.map +1 -1
  347. package/lib/dist/graph/owning-package.d.ts +59 -0
  348. package/lib/dist/graph/owning-package.d.ts.map +1 -0
  349. package/lib/dist/graph/owning-package.js +120 -0
  350. package/lib/dist/graph/owning-package.js.map +1 -0
  351. package/lib/dist/graph/queries.d.ts +2 -2
  352. package/lib/dist/graph/queries.d.ts.map +1 -1
  353. package/lib/dist/graph/queries.js +2 -135
  354. package/lib/dist/graph/queries.js.map +1 -1
  355. package/lib/dist/graph/symbol-lookup.d.ts +15 -3
  356. package/lib/dist/graph/symbol-lookup.d.ts.map +1 -1
  357. package/lib/dist/graph/symbol-lookup.js +47 -89
  358. package/lib/dist/graph/symbol-lookup.js.map +1 -1
  359. package/lib/dist/graph/synthesized-hop.d.ts +37 -0
  360. package/lib/dist/graph/synthesized-hop.d.ts.map +1 -0
  361. package/lib/dist/graph/synthesized-hop.js +62 -0
  362. package/lib/dist/graph/synthesized-hop.js.map +1 -0
  363. package/lib/dist/graph/test-code.d.ts +21 -0
  364. package/lib/dist/graph/test-code.d.ts.map +1 -0
  365. package/lib/dist/graph/test-code.js +50 -0
  366. package/lib/dist/graph/test-code.js.map +1 -0
  367. package/lib/dist/graph/traversal.d.ts +31 -2
  368. package/lib/dist/graph/traversal.d.ts.map +1 -1
  369. package/lib/dist/graph/traversal.js +98 -226
  370. package/lib/dist/graph/traversal.js.map +1 -1
  371. package/lib/dist/graph/type-hierarchy.js +0 -138
  372. package/lib/dist/graph/type-hierarchy.js.map +1 -1
  373. package/lib/dist/index.d.ts +195 -25
  374. package/lib/dist/index.d.ts.map +1 -1
  375. package/lib/dist/index.js +697 -1105
  376. package/lib/dist/index.js.map +1 -1
  377. package/lib/dist/installer/beta-signup.js +0 -39
  378. package/lib/dist/installer/beta-signup.js.map +1 -1
  379. package/lib/dist/installer/config-writer.js +0 -24
  380. package/lib/dist/installer/config-writer.js.map +1 -1
  381. package/lib/dist/installer/index.d.ts +9 -5
  382. package/lib/dist/installer/index.d.ts.map +1 -1
  383. package/lib/dist/installer/index.js +25 -159
  384. package/lib/dist/installer/index.js.map +1 -1
  385. package/lib/dist/installer/instructions-template.d.ts +1 -1
  386. package/lib/dist/installer/instructions-template.js +0 -37
  387. package/lib/dist/installer/instructions-template.js.map +1 -1
  388. package/lib/dist/installer/targets/antigravity.js +0 -113
  389. package/lib/dist/installer/targets/antigravity.js.map +1 -1
  390. package/lib/dist/installer/targets/bob.d.ts +20 -0
  391. package/lib/dist/installer/targets/bob.d.ts.map +1 -0
  392. package/lib/dist/installer/targets/bob.js +83 -0
  393. package/lib/dist/installer/targets/bob.js.map +1 -0
  394. package/lib/dist/installer/targets/claude.d.ts.map +1 -1
  395. package/lib/dist/installer/targets/claude.js +1 -185
  396. package/lib/dist/installer/targets/claude.js.map +1 -1
  397. package/lib/dist/installer/targets/codex.d.ts.map +1 -1
  398. package/lib/dist/installer/targets/codex.js +17 -109
  399. package/lib/dist/installer/targets/codex.js.map +1 -1
  400. package/lib/dist/installer/targets/copilot-cli.d.ts.map +1 -1
  401. package/lib/dist/installer/targets/copilot-cli.js +2 -54
  402. package/lib/dist/installer/targets/copilot-cli.js.map +1 -1
  403. package/lib/dist/installer/targets/copilot-jetbrains.js +0 -57
  404. package/lib/dist/installer/targets/copilot-jetbrains.js.map +1 -1
  405. package/lib/dist/installer/targets/copilot-vscode.js +0 -58
  406. package/lib/dist/installer/targets/copilot-vscode.js.map +1 -1
  407. package/lib/dist/installer/targets/cursor.js +7 -88
  408. package/lib/dist/installer/targets/cursor.js.map +1 -1
  409. package/lib/dist/installer/targets/droid.d.ts +18 -0
  410. package/lib/dist/installer/targets/droid.d.ts.map +1 -0
  411. package/lib/dist/installer/targets/droid.js +92 -0
  412. package/lib/dist/installer/targets/droid.js.map +1 -0
  413. package/lib/dist/installer/targets/dsh.d.ts +35 -0
  414. package/lib/dist/installer/targets/dsh.d.ts.map +1 -0
  415. package/lib/dist/installer/targets/dsh.js +267 -0
  416. package/lib/dist/installer/targets/dsh.js.map +1 -0
  417. package/lib/dist/installer/targets/gemini.js +0 -37
  418. package/lib/dist/installer/targets/gemini.js.map +1 -1
  419. package/lib/dist/installer/targets/grok.d.ts +25 -0
  420. package/lib/dist/installer/targets/grok.d.ts.map +1 -0
  421. package/lib/dist/installer/targets/grok.js +96 -0
  422. package/lib/dist/installer/targets/grok.js.map +1 -0
  423. package/lib/dist/installer/targets/hermes.d.ts +19 -7
  424. package/lib/dist/installer/targets/hermes.d.ts.map +1 -1
  425. package/lib/dist/installer/targets/hermes.js +218 -214
  426. package/lib/dist/installer/targets/hermes.js.map +1 -1
  427. package/lib/dist/installer/targets/json-config.d.ts +45 -0
  428. package/lib/dist/installer/targets/json-config.d.ts.map +1 -0
  429. package/lib/dist/installer/targets/json-config.js +128 -0
  430. package/lib/dist/installer/targets/json-config.js.map +1 -0
  431. package/lib/dist/installer/targets/kimi.d.ts +21 -0
  432. package/lib/dist/installer/targets/kimi.d.ts.map +1 -0
  433. package/lib/dist/installer/targets/kimi.js +97 -0
  434. package/lib/dist/installer/targets/kimi.js.map +1 -0
  435. package/lib/dist/installer/targets/kiro.js +1 -41
  436. package/lib/dist/installer/targets/kiro.js.map +1 -1
  437. package/lib/dist/installer/targets/opencode.js +0 -102
  438. package/lib/dist/installer/targets/opencode.js.map +1 -1
  439. package/lib/dist/installer/targets/pi.d.ts +24 -0
  440. package/lib/dist/installer/targets/pi.d.ts.map +1 -0
  441. package/lib/dist/installer/targets/pi.js +100 -0
  442. package/lib/dist/installer/targets/pi.js.map +1 -0
  443. package/lib/dist/installer/targets/qoder.d.ts +23 -0
  444. package/lib/dist/installer/targets/qoder.d.ts.map +1 -0
  445. package/lib/dist/installer/targets/qoder.js +83 -0
  446. package/lib/dist/installer/targets/qoder.js.map +1 -0
  447. package/lib/dist/installer/targets/qwen.d.ts +21 -0
  448. package/lib/dist/installer/targets/qwen.d.ts.map +1 -0
  449. package/lib/dist/installer/targets/qwen.js +115 -0
  450. package/lib/dist/installer/targets/qwen.js.map +1 -0
  451. package/lib/dist/installer/targets/registry.d.ts.map +1 -1
  452. package/lib/dist/installer/targets/registry.js +18 -25
  453. package/lib/dist/installer/targets/registry.js.map +1 -1
  454. package/lib/dist/installer/targets/shared.d.ts +81 -11
  455. package/lib/dist/installer/targets/shared.d.ts.map +1 -1
  456. package/lib/dist/installer/targets/shared.js +183 -129
  457. package/lib/dist/installer/targets/shared.js.map +1 -1
  458. package/lib/dist/installer/targets/toml.d.ts +82 -6
  459. package/lib/dist/installer/targets/toml.d.ts.map +1 -1
  460. package/lib/dist/installer/targets/toml.js +318 -112
  461. package/lib/dist/installer/targets/toml.js.map +1 -1
  462. package/lib/dist/installer/targets/types.d.ts +1 -1
  463. package/lib/dist/installer/targets/types.d.ts.map +1 -1
  464. package/lib/dist/installer/targets/types.js +0 -13
  465. package/lib/dist/installer/targets/types.js.map +1 -1
  466. package/lib/dist/installer/targets/windsurf.d.ts +22 -0
  467. package/lib/dist/installer/targets/windsurf.d.ts.map +1 -0
  468. package/lib/dist/installer/targets/windsurf.js +90 -0
  469. package/lib/dist/installer/targets/windsurf.js.map +1 -0
  470. package/lib/dist/lazy-engine.d.ts +22 -0
  471. package/lib/dist/lazy-engine.d.ts.map +1 -0
  472. package/lib/dist/lazy-engine.js +16 -0
  473. package/lib/dist/lazy-engine.js.map +1 -0
  474. package/lib/dist/mcp/answer-freshness.js +0 -6
  475. package/lib/dist/mcp/answer-freshness.js.map +1 -1
  476. package/lib/dist/mcp/daemon-manager.js +2 -23
  477. package/lib/dist/mcp/daemon-manager.js.map +1 -1
  478. package/lib/dist/mcp/daemon-paths.d.ts.map +1 -1
  479. package/lib/dist/mcp/daemon-paths.js +2 -79
  480. package/lib/dist/mcp/daemon-paths.js.map +1 -1
  481. package/lib/dist/mcp/daemon-registry.d.ts +44 -0
  482. package/lib/dist/mcp/daemon-registry.d.ts.map +1 -1
  483. package/lib/dist/mcp/daemon-registry.js +189 -118
  484. package/lib/dist/mcp/daemon-registry.js.map +1 -1
  485. package/lib/dist/mcp/daemon.d.ts +23 -0
  486. package/lib/dist/mcp/daemon.d.ts.map +1 -1
  487. package/lib/dist/mcp/daemon.js +89 -373
  488. package/lib/dist/mcp/daemon.js.map +1 -1
  489. package/lib/dist/mcp/dynamic-boundaries.js +4 -78
  490. package/lib/dist/mcp/dynamic-boundaries.js.map +1 -1
  491. package/lib/dist/mcp/early-ppid.js +0 -24
  492. package/lib/dist/mcp/early-ppid.js.map +1 -1
  493. package/lib/dist/mcp/engine.d.ts +10 -0
  494. package/lib/dist/mcp/engine.d.ts.map +1 -1
  495. package/lib/dist/mcp/engine.js +41 -152
  496. package/lib/dist/mcp/engine.js.map +1 -1
  497. package/lib/dist/mcp/explore-dedup.js +0 -108
  498. package/lib/dist/mcp/explore-dedup.js.map +1 -1
  499. package/lib/dist/mcp/explore-diagnostics.js +0 -116
  500. package/lib/dist/mcp/explore-diagnostics.js.map +1 -1
  501. package/lib/dist/mcp/explore-session-state.js +0 -129
  502. package/lib/dist/mcp/explore-session-state.js.map +1 -1
  503. package/lib/dist/mcp/index-freshness-worker.js +5 -4
  504. package/lib/dist/mcp/index-freshness-worker.js.map +1 -1
  505. package/lib/dist/mcp/index-freshness.d.ts +7 -1
  506. package/lib/dist/mcp/index-freshness.d.ts.map +1 -1
  507. package/lib/dist/mcp/index-freshness.js +20 -12
  508. package/lib/dist/mcp/index-freshness.js.map +1 -1
  509. package/lib/dist/mcp/index-version-warning.d.ts +21 -0
  510. package/lib/dist/mcp/index-version-warning.d.ts.map +1 -0
  511. package/lib/dist/mcp/index-version-warning.js +38 -0
  512. package/lib/dist/mcp/index-version-warning.js.map +1 -0
  513. package/lib/dist/mcp/index.d.ts +19 -1
  514. package/lib/dist/mcp/index.d.ts.map +1 -1
  515. package/lib/dist/mcp/index.js +118 -293
  516. package/lib/dist/mcp/index.js.map +1 -1
  517. package/lib/dist/mcp/liveness-watchdog.d.ts +13 -3
  518. package/lib/dist/mcp/liveness-watchdog.d.ts.map +1 -1
  519. package/lib/dist/mcp/liveness-watchdog.js +106 -121
  520. package/lib/dist/mcp/liveness-watchdog.js.map +1 -1
  521. package/lib/dist/mcp/ppid-watchdog.js +0 -24
  522. package/lib/dist/mcp/ppid-watchdog.js.map +1 -1
  523. package/lib/dist/mcp/process-identity.d.ts +42 -0
  524. package/lib/dist/mcp/process-identity.d.ts.map +1 -0
  525. package/lib/dist/mcp/process-identity.js +130 -0
  526. package/lib/dist/mcp/process-identity.js.map +1 -0
  527. package/lib/dist/mcp/project-lifecycle.d.ts.map +1 -1
  528. package/lib/dist/mcp/project-lifecycle.js +55 -21
  529. package/lib/dist/mcp/project-lifecycle.js.map +1 -1
  530. package/lib/dist/mcp/proxy.d.ts +26 -8
  531. package/lib/dist/mcp/proxy.d.ts.map +1 -1
  532. package/lib/dist/mcp/proxy.js +209 -223
  533. package/lib/dist/mcp/proxy.js.map +1 -1
  534. package/lib/dist/mcp/query-pool.d.ts +58 -3
  535. package/lib/dist/mcp/query-pool.d.ts.map +1 -1
  536. package/lib/dist/mcp/query-pool.js +140 -100
  537. package/lib/dist/mcp/query-pool.js.map +1 -1
  538. package/lib/dist/mcp/query-worker.js +24 -36
  539. package/lib/dist/mcp/query-worker.js.map +1 -1
  540. package/lib/dist/mcp/server-instructions.js +0 -31
  541. package/lib/dist/mcp/server-instructions.js.map +1 -1
  542. package/lib/dist/mcp/session.d.ts +27 -0
  543. package/lib/dist/mcp/session.d.ts.map +1 -1
  544. package/lib/dist/mcp/session.js +29 -130
  545. package/lib/dist/mcp/session.js.map +1 -1
  546. package/lib/dist/mcp/startup-handshake.js +1 -48
  547. package/lib/dist/mcp/startup-handshake.js.map +1 -1
  548. package/lib/dist/mcp/stdin-teardown.js +0 -28
  549. package/lib/dist/mcp/stdin-teardown.js.map +1 -1
  550. package/lib/dist/mcp/stdout-teardown.d.ts +26 -0
  551. package/lib/dist/mcp/stdout-teardown.d.ts.map +1 -0
  552. package/lib/dist/mcp/stdout-teardown.js +20 -0
  553. package/lib/dist/mcp/stdout-teardown.js.map +1 -0
  554. package/lib/dist/mcp/tools.d.ts +159 -20
  555. package/lib/dist/mcp/tools.d.ts.map +1 -1
  556. package/lib/dist/mcp/tools.js +730 -3545
  557. package/lib/dist/mcp/tools.js.map +1 -1
  558. package/lib/dist/mcp/transport.d.ts.map +1 -1
  559. package/lib/dist/mcp/transport.js +4 -96
  560. package/lib/dist/mcp/transport.js.map +1 -1
  561. package/lib/dist/mcp/version.d.ts +13 -1
  562. package/lib/dist/mcp/version.d.ts.map +1 -1
  563. package/lib/dist/mcp/version.js +19 -21
  564. package/lib/dist/mcp/version.js.map +1 -1
  565. package/lib/dist/mcp/writer-lock.d.ts +11 -0
  566. package/lib/dist/mcp/writer-lock.d.ts.map +1 -1
  567. package/lib/dist/mcp/writer-lock.js +49 -46
  568. package/lib/dist/mcp/writer-lock.js.map +1 -1
  569. package/lib/dist/project-config.js +1 -138
  570. package/lib/dist/project-config.js.map +1 -1
  571. package/lib/dist/resolution/alias-binding.d.ts +7 -0
  572. package/lib/dist/resolution/alias-binding.d.ts.map +1 -1
  573. package/lib/dist/resolution/alias-binding.js +19 -52
  574. package/lib/dist/resolution/alias-binding.js.map +1 -1
  575. package/lib/dist/resolution/ambient-modules.d.ts +185 -0
  576. package/lib/dist/resolution/ambient-modules.d.ts.map +1 -0
  577. package/lib/dist/resolution/ambient-modules.js +732 -0
  578. package/lib/dist/resolution/ambient-modules.js.map +1 -0
  579. package/lib/dist/resolution/angular-template-synthesizer.d.ts +96 -0
  580. package/lib/dist/resolution/angular-template-synthesizer.d.ts.map +1 -0
  581. package/lib/dist/resolution/angular-template-synthesizer.js +695 -0
  582. package/lib/dist/resolution/angular-template-synthesizer.js.map +1 -0
  583. package/lib/dist/resolution/c-feature-variants.d.ts +40 -0
  584. package/lib/dist/resolution/c-feature-variants.d.ts.map +1 -0
  585. package/lib/dist/resolution/c-feature-variants.js +249 -0
  586. package/lib/dist/resolution/c-feature-variants.js.map +1 -0
  587. package/lib/dist/resolution/c-fnptr-synthesizer.d.ts.map +1 -1
  588. package/lib/dist/resolution/c-fnptr-synthesizer.js +23 -391
  589. package/lib/dist/resolution/c-fnptr-synthesizer.js.map +1 -1
  590. package/lib/dist/resolution/c-macro-renames.d.ts +25 -0
  591. package/lib/dist/resolution/c-macro-renames.d.ts.map +1 -0
  592. package/lib/dist/resolution/c-macro-renames.js +95 -0
  593. package/lib/dist/resolution/c-macro-renames.js.map +1 -0
  594. package/lib/dist/resolution/callback-synthesizer.d.ts +15 -1
  595. package/lib/dist/resolution/callback-synthesizer.d.ts.map +1 -1
  596. package/lib/dist/resolution/callback-synthesizer.js +1487 -1234
  597. package/lib/dist/resolution/callback-synthesizer.js.map +1 -1
  598. package/lib/dist/resolution/const-alias-synthesizer.d.ts +48 -0
  599. package/lib/dist/resolution/const-alias-synthesizer.d.ts.map +1 -0
  600. package/lib/dist/resolution/const-alias-synthesizer.js +234 -0
  601. package/lib/dist/resolution/const-alias-synthesizer.js.map +1 -0
  602. package/lib/dist/resolution/cooperative-yield.js +0 -27
  603. package/lib/dist/resolution/cooperative-yield.js.map +1 -1
  604. package/lib/dist/resolution/cpp-constructor.d.ts.map +1 -1
  605. package/lib/dist/resolution/cpp-constructor.js +15 -17
  606. package/lib/dist/resolution/cpp-constructor.js.map +1 -1
  607. package/lib/dist/resolution/cpp-includers.d.ts +46 -0
  608. package/lib/dist/resolution/cpp-includers.d.ts.map +1 -0
  609. package/lib/dist/resolution/cpp-includers.js +153 -0
  610. package/lib/dist/resolution/cpp-includers.js.map +1 -0
  611. package/lib/dist/resolution/cpp-macro-visibility.d.ts +16 -0
  612. package/lib/dist/resolution/cpp-macro-visibility.d.ts.map +1 -1
  613. package/lib/dist/resolution/cpp-macro-visibility.js +60 -61
  614. package/lib/dist/resolution/cpp-macro-visibility.js.map +1 -1
  615. package/lib/dist/resolution/cpp-namespaces.d.ts +54 -0
  616. package/lib/dist/resolution/cpp-namespaces.d.ts.map +1 -0
  617. package/lib/dist/resolution/cpp-namespaces.js +151 -0
  618. package/lib/dist/resolution/cpp-namespaces.js.map +1 -0
  619. package/lib/dist/resolution/cpp-raw-strings.d.ts +33 -0
  620. package/lib/dist/resolution/cpp-raw-strings.d.ts.map +1 -0
  621. package/lib/dist/resolution/cpp-raw-strings.js +167 -0
  622. package/lib/dist/resolution/cpp-raw-strings.js.map +1 -0
  623. package/lib/dist/resolution/cpp-supertypes.d.ts +118 -0
  624. package/lib/dist/resolution/cpp-supertypes.d.ts.map +1 -0
  625. package/lib/dist/resolution/cpp-supertypes.js +322 -0
  626. package/lib/dist/resolution/cpp-supertypes.js.map +1 -0
  627. package/lib/dist/resolution/cpp-template-instantiations.d.ts +83 -0
  628. package/lib/dist/resolution/cpp-template-instantiations.d.ts.map +1 -0
  629. package/lib/dist/resolution/cpp-template-instantiations.js +983 -0
  630. package/lib/dist/resolution/cpp-template-instantiations.js.map +1 -0
  631. package/lib/dist/resolution/cpp-type-aliases.d.ts +194 -0
  632. package/lib/dist/resolution/cpp-type-aliases.d.ts.map +1 -0
  633. package/lib/dist/resolution/cpp-type-aliases.js +648 -0
  634. package/lib/dist/resolution/cpp-type-aliases.js.map +1 -0
  635. package/lib/dist/resolution/dart-libraries.d.ts +75 -0
  636. package/lib/dist/resolution/dart-libraries.d.ts.map +1 -0
  637. package/lib/dist/resolution/dart-libraries.js +721 -0
  638. package/lib/dist/resolution/dart-libraries.js.map +1 -0
  639. package/lib/dist/resolution/dart-local-scope.d.ts +41 -0
  640. package/lib/dist/resolution/dart-local-scope.d.ts.map +1 -0
  641. package/lib/dist/resolution/dart-local-scope.js +565 -0
  642. package/lib/dist/resolution/dart-local-scope.js.map +1 -0
  643. package/lib/dist/resolution/expo-router-synthesizer.js +0 -52
  644. package/lib/dist/resolution/expo-router-synthesizer.js.map +1 -1
  645. package/lib/dist/resolution/frameworks/angular-router.d.ts +142 -0
  646. package/lib/dist/resolution/frameworks/angular-router.d.ts.map +1 -0
  647. package/lib/dist/resolution/frameworks/angular-router.js +959 -0
  648. package/lib/dist/resolution/frameworks/angular-router.js.map +1 -0
  649. package/lib/dist/resolution/frameworks/astro.d.ts.map +1 -1
  650. package/lib/dist/resolution/frameworks/astro.js +30 -60
  651. package/lib/dist/resolution/frameworks/astro.js.map +1 -1
  652. package/lib/dist/resolution/frameworks/cargo-workspace.d.ts +18 -1
  653. package/lib/dist/resolution/frameworks/cargo-workspace.d.ts.map +1 -1
  654. package/lib/dist/resolution/frameworks/cargo-workspace.js +65 -15
  655. package/lib/dist/resolution/frameworks/cargo-workspace.js.map +1 -1
  656. package/lib/dist/resolution/frameworks/cics.d.ts.map +1 -1
  657. package/lib/dist/resolution/frameworks/cics.js +7 -33
  658. package/lib/dist/resolution/frameworks/cics.js.map +1 -1
  659. package/lib/dist/resolution/frameworks/codeigniter.d.ts +23 -0
  660. package/lib/dist/resolution/frameworks/codeigniter.d.ts.map +1 -0
  661. package/lib/dist/resolution/frameworks/codeigniter.js +271 -0
  662. package/lib/dist/resolution/frameworks/codeigniter.js.map +1 -0
  663. package/lib/dist/resolution/frameworks/component-folder.d.ts +17 -0
  664. package/lib/dist/resolution/frameworks/component-folder.d.ts.map +1 -0
  665. package/lib/dist/resolution/frameworks/component-folder.js +11 -0
  666. package/lib/dist/resolution/frameworks/component-folder.js.map +1 -0
  667. package/lib/dist/resolution/frameworks/csharp.d.ts.map +1 -1
  668. package/lib/dist/resolution/frameworks/csharp.js +106 -101
  669. package/lib/dist/resolution/frameworks/csharp.js.map +1 -1
  670. package/lib/dist/resolution/frameworks/drupal.d.ts +17 -8
  671. package/lib/dist/resolution/frameworks/drupal.d.ts.map +1 -1
  672. package/lib/dist/resolution/frameworks/drupal.js +377 -142
  673. package/lib/dist/resolution/frameworks/drupal.js.map +1 -1
  674. package/lib/dist/resolution/frameworks/expo-modules.d.ts +10 -0
  675. package/lib/dist/resolution/frameworks/expo-modules.d.ts.map +1 -1
  676. package/lib/dist/resolution/frameworks/expo-modules.js +79 -65
  677. package/lib/dist/resolution/frameworks/expo-modules.js.map +1 -1
  678. package/lib/dist/resolution/frameworks/expo-router.d.ts +6 -0
  679. package/lib/dist/resolution/frameworks/expo-router.d.ts.map +1 -1
  680. package/lib/dist/resolution/frameworks/expo-router.js +64 -183
  681. package/lib/dist/resolution/frameworks/expo-router.js.map +1 -1
  682. package/lib/dist/resolution/frameworks/express.d.ts.map +1 -1
  683. package/lib/dist/resolution/frameworks/express.js +215 -173
  684. package/lib/dist/resolution/frameworks/express.js.map +1 -1
  685. package/lib/dist/resolution/frameworks/fabric.d.ts.map +1 -1
  686. package/lib/dist/resolution/frameworks/fabric.js +11 -112
  687. package/lib/dist/resolution/frameworks/fabric.js.map +1 -1
  688. package/lib/dist/resolution/frameworks/go.d.ts.map +1 -1
  689. package/lib/dist/resolution/frameworks/go.js +15 -61
  690. package/lib/dist/resolution/frameworks/go.js.map +1 -1
  691. package/lib/dist/resolution/frameworks/goframe.js +1 -55
  692. package/lib/dist/resolution/frameworks/goframe.js.map +1 -1
  693. package/lib/dist/resolution/frameworks/index.d.ts +16 -2
  694. package/lib/dist/resolution/frameworks/index.d.ts.map +1 -1
  695. package/lib/dist/resolution/frameworks/index.js +20 -48
  696. package/lib/dist/resolution/frameworks/index.js.map +1 -1
  697. package/lib/dist/resolution/frameworks/java.d.ts.map +1 -1
  698. package/lib/dist/resolution/frameworks/java.js +209 -147
  699. package/lib/dist/resolution/frameworks/java.js.map +1 -1
  700. package/lib/dist/resolution/frameworks/laravel.d.ts.map +1 -1
  701. package/lib/dist/resolution/frameworks/laravel.js +291 -71
  702. package/lib/dist/resolution/frameworks/laravel.js.map +1 -1
  703. package/lib/dist/resolution/frameworks/name-heuristic.d.ts +35 -0
  704. package/lib/dist/resolution/frameworks/name-heuristic.d.ts.map +1 -0
  705. package/lib/dist/resolution/frameworks/name-heuristic.js +33 -0
  706. package/lib/dist/resolution/frameworks/name-heuristic.js.map +1 -0
  707. package/lib/dist/resolution/frameworks/nestjs.d.ts.map +1 -1
  708. package/lib/dist/resolution/frameworks/nestjs.js +236 -192
  709. package/lib/dist/resolution/frameworks/nestjs.js.map +1 -1
  710. package/lib/dist/resolution/frameworks/next-proxy.d.ts +67 -0
  711. package/lib/dist/resolution/frameworks/next-proxy.d.ts.map +1 -0
  712. package/lib/dist/resolution/frameworks/next-proxy.js +239 -0
  713. package/lib/dist/resolution/frameworks/next-proxy.js.map +1 -0
  714. package/lib/dist/resolution/frameworks/nextjs.d.ts.map +1 -1
  715. package/lib/dist/resolution/frameworks/nextjs.js +11 -66
  716. package/lib/dist/resolution/frameworks/nextjs.js.map +1 -1
  717. package/lib/dist/resolution/frameworks/object-literal.js +0 -21
  718. package/lib/dist/resolution/frameworks/object-literal.js.map +1 -1
  719. package/lib/dist/resolution/frameworks/package-deps.d.ts +11 -7
  720. package/lib/dist/resolution/frameworks/package-deps.d.ts.map +1 -1
  721. package/lib/dist/resolution/frameworks/package-deps.js +35 -26
  722. package/lib/dist/resolution/frameworks/package-deps.js.map +1 -1
  723. package/lib/dist/resolution/frameworks/page-component.d.ts +20 -0
  724. package/lib/dist/resolution/frameworks/page-component.d.ts.map +1 -0
  725. package/lib/dist/resolution/frameworks/page-component.js +31 -0
  726. package/lib/dist/resolution/frameworks/page-component.js.map +1 -0
  727. package/lib/dist/resolution/frameworks/play.d.ts.map +1 -1
  728. package/lib/dist/resolution/frameworks/play.js +27 -33
  729. package/lib/dist/resolution/frameworks/play.js.map +1 -1
  730. package/lib/dist/resolution/frameworks/python.d.ts.map +1 -1
  731. package/lib/dist/resolution/frameworks/python.js +106 -116
  732. package/lib/dist/resolution/frameworks/python.js.map +1 -1
  733. package/lib/dist/resolution/frameworks/react-native.d.ts.map +1 -1
  734. package/lib/dist/resolution/frameworks/react-native.js +1 -166
  735. package/lib/dist/resolution/frameworks/react-native.js.map +1 -1
  736. package/lib/dist/resolution/frameworks/react-router.d.ts +17 -7
  737. package/lib/dist/resolution/frameworks/react-router.d.ts.map +1 -1
  738. package/lib/dist/resolution/frameworks/react-router.js +21 -79
  739. package/lib/dist/resolution/frameworks/react-router.js.map +1 -1
  740. package/lib/dist/resolution/frameworks/react.d.ts +68 -1
  741. package/lib/dist/resolution/frameworks/react.d.ts.map +1 -1
  742. package/lib/dist/resolution/frameworks/react.js +1721 -114
  743. package/lib/dist/resolution/frameworks/react.js.map +1 -1
  744. package/lib/dist/resolution/frameworks/ruby.d.ts.map +1 -1
  745. package/lib/dist/resolution/frameworks/ruby.js +152 -52
  746. package/lib/dist/resolution/frameworks/ruby.js.map +1 -1
  747. package/lib/dist/resolution/frameworks/rust.d.ts.map +1 -1
  748. package/lib/dist/resolution/frameworks/rust.js +51 -70
  749. package/lib/dist/resolution/frameworks/rust.js.map +1 -1
  750. package/lib/dist/resolution/frameworks/svelte.d.ts.map +1 -1
  751. package/lib/dist/resolution/frameworks/svelte.js +9 -74
  752. package/lib/dist/resolution/frameworks/svelte.js.map +1 -1
  753. package/lib/dist/resolution/frameworks/sveltekit-router.d.ts.map +1 -1
  754. package/lib/dist/resolution/frameworks/sveltekit-router.js +8 -46
  755. package/lib/dist/resolution/frameworks/sveltekit-router.js.map +1 -1
  756. package/lib/dist/resolution/frameworks/swift-objc.js +0 -97
  757. package/lib/dist/resolution/frameworks/swift-objc.js.map +1 -1
  758. package/lib/dist/resolution/frameworks/swift.d.ts.map +1 -1
  759. package/lib/dist/resolution/frameworks/swift.js +199 -167
  760. package/lib/dist/resolution/frameworks/swift.js.map +1 -1
  761. package/lib/dist/resolution/frameworks/tanstack-router.d.ts.map +1 -1
  762. package/lib/dist/resolution/frameworks/tanstack-router.js +9 -130
  763. package/lib/dist/resolution/frameworks/tanstack-router.js.map +1 -1
  764. package/lib/dist/resolution/frameworks/terraform.js +1 -85
  765. package/lib/dist/resolution/frameworks/terraform.js.map +1 -1
  766. package/lib/dist/resolution/frameworks/vue-router.d.ts +26 -10
  767. package/lib/dist/resolution/frameworks/vue-router.d.ts.map +1 -1
  768. package/lib/dist/resolution/frameworks/vue-router.js +147 -147
  769. package/lib/dist/resolution/frameworks/vue-router.js.map +1 -1
  770. package/lib/dist/resolution/frameworks/vue.d.ts +9 -2
  771. package/lib/dist/resolution/frameworks/vue.d.ts.map +1 -1
  772. package/lib/dist/resolution/frameworks/vue.js +69 -107
  773. package/lib/dist/resolution/frameworks/vue.js.map +1 -1
  774. package/lib/dist/resolution/go-func-field-synthesizer.d.ts +58 -0
  775. package/lib/dist/resolution/go-func-field-synthesizer.d.ts.map +1 -0
  776. package/lib/dist/resolution/go-func-field-synthesizer.js +696 -0
  777. package/lib/dist/resolution/go-func-field-synthesizer.js.map +1 -0
  778. package/lib/dist/resolution/go-module.d.ts +23 -7
  779. package/lib/dist/resolution/go-module.d.ts.map +1 -1
  780. package/lib/dist/resolution/go-module.js +21 -24
  781. package/lib/dist/resolution/go-module.js.map +1 -1
  782. package/lib/dist/resolution/go-stdlib-methods.d.ts +9 -0
  783. package/lib/dist/resolution/go-stdlib-methods.d.ts.map +1 -0
  784. package/lib/dist/resolution/go-stdlib-methods.js +224 -0
  785. package/lib/dist/resolution/go-stdlib-methods.js.map +1 -0
  786. package/lib/dist/resolution/goframe-synthesizer.js +2 -53
  787. package/lib/dist/resolution/goframe-synthesizer.js.map +1 -1
  788. package/lib/dist/resolution/import-resolver.d.ts +298 -23
  789. package/lib/dist/resolution/import-resolver.d.ts.map +1 -1
  790. package/lib/dist/resolution/import-resolver.js +1802 -1280
  791. package/lib/dist/resolution/import-resolver.js.map +1 -1
  792. package/lib/dist/resolution/index.d.ts +449 -5
  793. package/lib/dist/resolution/index.d.ts.map +1 -1
  794. package/lib/dist/resolution/index.js +1477 -981
  795. package/lib/dist/resolution/index.js.map +1 -1
  796. package/lib/dist/resolution/js-builtins.d.ts +14 -0
  797. package/lib/dist/resolution/js-builtins.d.ts.map +1 -1
  798. package/lib/dist/resolution/js-builtins.js +15 -13
  799. package/lib/dist/resolution/js-builtins.js.map +1 -1
  800. package/lib/dist/resolution/js-class-expressions.d.ts +48 -0
  801. package/lib/dist/resolution/js-class-expressions.d.ts.map +1 -0
  802. package/lib/dist/resolution/js-class-expressions.js +25 -0
  803. package/lib/dist/resolution/js-class-expressions.js.map +1 -0
  804. package/lib/dist/resolution/js-super-calls.d.ts +18 -0
  805. package/lib/dist/resolution/js-super-calls.d.ts.map +1 -0
  806. package/lib/dist/resolution/js-super-calls.js +94 -0
  807. package/lib/dist/resolution/js-super-calls.js.map +1 -0
  808. package/lib/dist/resolution/jsx-code.d.ts +28 -0
  809. package/lib/dist/resolution/jsx-code.d.ts.map +1 -0
  810. package/lib/dist/resolution/jsx-code.js +459 -0
  811. package/lib/dist/resolution/jsx-code.js.map +1 -0
  812. package/lib/dist/resolution/lru-cache.d.ts +5 -13
  813. package/lib/dist/resolution/lru-cache.d.ts.map +1 -1
  814. package/lib/dist/resolution/lru-cache.js +43 -32
  815. package/lib/dist/resolution/lru-cache.js.map +1 -1
  816. package/lib/dist/resolution/memory-budget.js +0 -52
  817. package/lib/dist/resolution/memory-budget.js.map +1 -1
  818. package/lib/dist/resolution/module-importers.d.ts +185 -0
  819. package/lib/dist/resolution/module-importers.d.ts.map +1 -0
  820. package/lib/dist/resolution/module-importers.js +588 -0
  821. package/lib/dist/resolution/module-importers.js.map +1 -0
  822. package/lib/dist/resolution/name-matcher.d.ts +891 -8
  823. package/lib/dist/resolution/name-matcher.d.ts.map +1 -1
  824. package/lib/dist/resolution/name-matcher.js +25013 -2928
  825. package/lib/dist/resolution/name-matcher.js.map +1 -1
  826. package/lib/dist/resolution/next-router-synthesizer.d.ts +19 -0
  827. package/lib/dist/resolution/next-router-synthesizer.d.ts.map +1 -1
  828. package/lib/dist/resolution/next-router-synthesizer.js +46 -28
  829. package/lib/dist/resolution/next-router-synthesizer.js.map +1 -1
  830. package/lib/dist/resolution/override-parameters.d.ts +40 -0
  831. package/lib/dist/resolution/override-parameters.d.ts.map +1 -0
  832. package/lib/dist/resolution/override-parameters.js +339 -0
  833. package/lib/dist/resolution/override-parameters.js.map +1 -0
  834. package/lib/dist/resolution/parameter-flow.d.ts +218 -0
  835. package/lib/dist/resolution/parameter-flow.d.ts.map +1 -0
  836. package/lib/dist/resolution/parameter-flow.js +474 -0
  837. package/lib/dist/resolution/parameter-flow.js.map +1 -0
  838. package/lib/dist/resolution/pascal-scope.d.ts +91 -0
  839. package/lib/dist/resolution/pascal-scope.d.ts.map +1 -0
  840. package/lib/dist/resolution/pascal-scope.js +961 -0
  841. package/lib/dist/resolution/pascal-scope.js.map +1 -0
  842. package/lib/dist/resolution/path-aliases.d.ts +32 -4
  843. package/lib/dist/resolution/path-aliases.d.ts.map +1 -1
  844. package/lib/dist/resolution/path-aliases.js +43 -110
  845. package/lib/dist/resolution/path-aliases.js.map +1 -1
  846. package/lib/dist/resolution/project-scans.d.ts +38 -0
  847. package/lib/dist/resolution/project-scans.d.ts.map +1 -0
  848. package/lib/dist/resolution/project-scans.js +30 -0
  849. package/lib/dist/resolution/project-scans.js.map +1 -0
  850. package/lib/dist/resolution/react-router-synthesizer.d.ts +2 -0
  851. package/lib/dist/resolution/react-router-synthesizer.d.ts.map +1 -1
  852. package/lib/dist/resolution/react-router-synthesizer.js +67 -48
  853. package/lib/dist/resolution/react-router-synthesizer.js.map +1 -1
  854. package/lib/dist/resolution/resolver-pool.d.ts +43 -3
  855. package/lib/dist/resolution/resolver-pool.d.ts.map +1 -1
  856. package/lib/dist/resolution/resolver-pool.js +55 -97
  857. package/lib/dist/resolution/resolver-pool.js.map +1 -1
  858. package/lib/dist/resolution/resolver-worker.d.ts +1 -1
  859. package/lib/dist/resolution/resolver-worker.d.ts.map +1 -1
  860. package/lib/dist/resolution/resolver-worker.js +10 -36
  861. package/lib/dist/resolution/resolver-worker.js.map +1 -1
  862. package/lib/dist/resolution/resurrect-ref.d.ts +25 -0
  863. package/lib/dist/resolution/resurrect-ref.d.ts.map +1 -0
  864. package/lib/dist/resolution/resurrect-ref.js +19 -0
  865. package/lib/dist/resolution/resurrect-ref.js.map +1 -0
  866. package/lib/dist/resolution/ruby-constant-paths.d.ts +56 -0
  867. package/lib/dist/resolution/ruby-constant-paths.d.ts.map +1 -0
  868. package/lib/dist/resolution/ruby-constant-paths.js +255 -0
  869. package/lib/dist/resolution/ruby-constant-paths.js.map +1 -0
  870. package/lib/dist/resolution/ruby-parameter-flow.d.ts +10 -0
  871. package/lib/dist/resolution/ruby-parameter-flow.d.ts.map +1 -0
  872. package/lib/dist/resolution/ruby-parameter-flow.js +801 -0
  873. package/lib/dist/resolution/ruby-parameter-flow.js.map +1 -0
  874. package/lib/dist/resolution/rust-scopes.d.ts +120 -0
  875. package/lib/dist/resolution/rust-scopes.d.ts.map +1 -0
  876. package/lib/dist/resolution/rust-scopes.js +730 -0
  877. package/lib/dist/resolution/rust-scopes.js.map +1 -0
  878. package/lib/dist/resolution/shopify-themes.d.ts +10 -0
  879. package/lib/dist/resolution/shopify-themes.d.ts.map +1 -0
  880. package/lib/dist/resolution/shopify-themes.js +19 -0
  881. package/lib/dist/resolution/shopify-themes.js.map +1 -0
  882. package/lib/dist/resolution/strip-comments.d.ts +20 -1
  883. package/lib/dist/resolution/strip-comments.d.ts.map +1 -1
  884. package/lib/dist/resolution/strip-comments.js +164 -119
  885. package/lib/dist/resolution/strip-comments.js.map +1 -1
  886. package/lib/dist/resolution/sveltekit-synthesizer.js +0 -64
  887. package/lib/dist/resolution/sveltekit-synthesizer.js.map +1 -1
  888. package/lib/dist/resolution/swift-objc-bridge.js +0 -160
  889. package/lib/dist/resolution/swift-objc-bridge.js.map +1 -1
  890. package/lib/dist/resolution/swift-type-visibility.d.ts +68 -0
  891. package/lib/dist/resolution/swift-type-visibility.d.ts.map +1 -0
  892. package/lib/dist/resolution/swift-type-visibility.js +355 -0
  893. package/lib/dist/resolution/swift-type-visibility.js.map +1 -0
  894. package/lib/dist/resolution/synth-utils.js +1 -22
  895. package/lib/dist/resolution/synth-utils.js.map +1 -1
  896. package/lib/dist/resolution/tanstack-router-synthesizer.js +0 -32
  897. package/lib/dist/resolution/tanstack-router-synthesizer.js.map +1 -1
  898. package/lib/dist/resolution/tauri-synthesizer.d.ts +37 -0
  899. package/lib/dist/resolution/tauri-synthesizer.d.ts.map +1 -0
  900. package/lib/dist/resolution/tauri-synthesizer.js +1038 -0
  901. package/lib/dist/resolution/tauri-synthesizer.js.map +1 -0
  902. package/lib/dist/resolution/tier-synthesizer.d.ts +7 -2
  903. package/lib/dist/resolution/tier-synthesizer.d.ts.map +1 -1
  904. package/lib/dist/resolution/tier-synthesizer.js +318 -121
  905. package/lib/dist/resolution/tier-synthesizer.js.map +1 -1
  906. package/lib/dist/resolution/type-parameters.d.ts +34 -0
  907. package/lib/dist/resolution/type-parameters.d.ts.map +1 -0
  908. package/lib/dist/resolution/type-parameters.js +285 -0
  909. package/lib/dist/resolution/type-parameters.js.map +1 -0
  910. package/lib/dist/resolution/types.d.ts +209 -10
  911. package/lib/dist/resolution/types.d.ts.map +1 -1
  912. package/lib/dist/resolution/types.js +0 -47
  913. package/lib/dist/resolution/types.js.map +1 -1
  914. package/lib/dist/resolution/vbnet-receivers.d.ts +92 -0
  915. package/lib/dist/resolution/vbnet-receivers.d.ts.map +1 -0
  916. package/lib/dist/resolution/vbnet-receivers.js +1482 -0
  917. package/lib/dist/resolution/vbnet-receivers.js.map +1 -0
  918. package/lib/dist/resolution/vue-router-synthesizer.js +0 -31
  919. package/lib/dist/resolution/vue-router-synthesizer.js.map +1 -1
  920. package/lib/dist/resolution/workspace-packages.d.ts +206 -15
  921. package/lib/dist/resolution/workspace-packages.d.ts.map +1 -1
  922. package/lib/dist/resolution/workspace-packages.js +570 -152
  923. package/lib/dist/resolution/workspace-packages.js.map +1 -1
  924. package/lib/dist/search/identifier-segments.js +2 -93
  925. package/lib/dist/search/identifier-segments.js.map +1 -1
  926. package/lib/dist/search/query-parser.js +0 -54
  927. package/lib/dist/search/query-parser.js.map +1 -1
  928. package/lib/dist/search/query-paths.js +0 -167
  929. package/lib/dist/search/query-paths.js.map +1 -1
  930. package/lib/dist/search/query-utils.d.ts +44 -0
  931. package/lib/dist/search/query-utils.d.ts.map +1 -1
  932. package/lib/dist/search/query-utils.js +120 -198
  933. package/lib/dist/search/query-utils.js.map +1 -1
  934. package/lib/dist/sync/git-hooks.d.ts +14 -5
  935. package/lib/dist/sync/git-hooks.d.ts.map +1 -1
  936. package/lib/dist/sync/git-hooks.js +118 -65
  937. package/lib/dist/sync/git-hooks.js.map +1 -1
  938. package/lib/dist/sync/index.js +0 -14
  939. package/lib/dist/sync/index.js.map +1 -1
  940. package/lib/dist/sync/watch-policy.js +0 -45
  941. package/lib/dist/sync/watch-policy.js.map +1 -1
  942. package/lib/dist/sync/watcher.d.ts +29 -11
  943. package/lib/dist/sync/watcher.d.ts.map +1 -1
  944. package/lib/dist/sync/watcher.js +83 -487
  945. package/lib/dist/sync/watcher.js.map +1 -1
  946. package/lib/dist/sync/worktree.d.ts +29 -2
  947. package/lib/dist/sync/worktree.d.ts.map +1 -1
  948. package/lib/dist/sync/worktree.js +59 -78
  949. package/lib/dist/sync/worktree.js.map +1 -1
  950. package/lib/dist/telemetry/index.d.ts.map +1 -1
  951. package/lib/dist/telemetry/index.js +68 -146
  952. package/lib/dist/telemetry/index.js.map +1 -1
  953. package/lib/dist/types.d.ts +46 -0
  954. package/lib/dist/types.d.ts.map +1 -1
  955. package/lib/dist/types.js +15 -44
  956. package/lib/dist/types.js.map +1 -1
  957. package/lib/dist/ui/color.js +0 -19
  958. package/lib/dist/ui/color.js.map +1 -1
  959. package/lib/dist/ui/glyphs.js +2 -45
  960. package/lib/dist/ui/glyphs.js.map +1 -1
  961. package/lib/dist/ui/shimmer-progress.js +0 -21
  962. package/lib/dist/ui/shimmer-progress.js.map +1 -1
  963. package/lib/dist/ui/shimmer-worker.js +0 -22
  964. package/lib/dist/ui/shimmer-worker.js.map +1 -1
  965. package/lib/dist/ui-server/api/deadcode.d.ts.map +1 -1
  966. package/lib/dist/ui-server/api/deadcode.js +2 -31
  967. package/lib/dist/ui-server/api/deadcode.js.map +1 -1
  968. package/lib/dist/ui-server/api/effects.d.ts +7 -0
  969. package/lib/dist/ui-server/api/effects.d.ts.map +1 -1
  970. package/lib/dist/ui-server/api/effects.js +20 -103
  971. package/lib/dist/ui-server/api/effects.js.map +1 -1
  972. package/lib/dist/ui-server/api/entrypoints.d.ts +6 -0
  973. package/lib/dist/ui-server/api/entrypoints.d.ts.map +1 -1
  974. package/lib/dist/ui-server/api/entrypoints.js +73 -130
  975. package/lib/dist/ui-server/api/entrypoints.js.map +1 -1
  976. package/lib/dist/ui-server/api/events.js +0 -145
  977. package/lib/dist/ui-server/api/events.js.map +1 -1
  978. package/lib/dist/ui-server/api/file.js +0 -80
  979. package/lib/dist/ui-server/api/file.js.map +1 -1
  980. package/lib/dist/ui-server/api/filecode.js +0 -95
  981. package/lib/dist/ui-server/api/filecode.js.map +1 -1
  982. package/lib/dist/ui-server/api/flow.js +0 -149
  983. package/lib/dist/ui-server/api/flow.js.map +1 -1
  984. package/lib/dist/ui-server/api/hierarchy.js +0 -28
  985. package/lib/dist/ui-server/api/hierarchy.js.map +1 -1
  986. package/lib/dist/ui-server/api/index.js +0 -88
  987. package/lib/dist/ui-server/api/index.js.map +1 -1
  988. package/lib/dist/ui-server/api/map.d.ts +41 -6
  989. package/lib/dist/ui-server/api/map.d.ts.map +1 -1
  990. package/lib/dist/ui-server/api/map.js +95 -308
  991. package/lib/dist/ui-server/api/map.js.map +1 -1
  992. package/lib/dist/ui-server/api/node.d.ts.map +1 -1
  993. package/lib/dist/ui-server/api/node.js +4 -109
  994. package/lib/dist/ui-server/api/node.js.map +1 -1
  995. package/lib/dist/ui-server/api/nodes.js +0 -16
  996. package/lib/dist/ui-server/api/nodes.js.map +1 -1
  997. package/lib/dist/ui-server/api/program.js +0 -90
  998. package/lib/dist/ui-server/api/program.js.map +1 -1
  999. package/lib/dist/ui-server/api/respond.js +0 -60
  1000. package/lib/dist/ui-server/api/respond.js.map +1 -1
  1001. package/lib/dist/ui-server/api/route-roots.d.ts +6 -0
  1002. package/lib/dist/ui-server/api/route-roots.d.ts.map +1 -1
  1003. package/lib/dist/ui-server/api/route-roots.js +18 -39
  1004. package/lib/dist/ui-server/api/route-roots.js.map +1 -1
  1005. package/lib/dist/ui-server/api/routes.d.ts +2 -0
  1006. package/lib/dist/ui-server/api/routes.d.ts.map +1 -1
  1007. package/lib/dist/ui-server/api/routes.js +47 -47
  1008. package/lib/dist/ui-server/api/routes.js.map +1 -1
  1009. package/lib/dist/ui-server/api/screens.d.ts.map +1 -1
  1010. package/lib/dist/ui-server/api/screens.js +16 -171
  1011. package/lib/dist/ui-server/api/screens.js.map +1 -1
  1012. package/lib/dist/ui-server/api/search.js +0 -62
  1013. package/lib/dist/ui-server/api/search.js.map +1 -1
  1014. package/lib/dist/ui-server/api/session.js +0 -58
  1015. package/lib/dist/ui-server/api/session.js.map +1 -1
  1016. package/lib/dist/ui-server/api/source.d.ts.map +1 -1
  1017. package/lib/dist/ui-server/api/source.js +0 -161
  1018. package/lib/dist/ui-server/api/source.js.map +1 -1
  1019. package/lib/dist/ui-server/api/stats.js +0 -58
  1020. package/lib/dist/ui-server/api/stats.js.map +1 -1
  1021. package/lib/dist/ui-server/api/steps.d.ts.map +1 -1
  1022. package/lib/dist/ui-server/api/steps.js +105 -373
  1023. package/lib/dist/ui-server/api/steps.js.map +1 -1
  1024. package/lib/dist/ui-server/api/trail-store.d.ts +3 -3
  1025. package/lib/dist/ui-server/api/trail-store.d.ts.map +1 -1
  1026. package/lib/dist/ui-server/api/trail-store.js +24 -106
  1027. package/lib/dist/ui-server/api/trail-store.js.map +1 -1
  1028. package/lib/dist/ui-server/api/trails.d.ts.map +1 -1
  1029. package/lib/dist/ui-server/api/trails.js +20 -94
  1030. package/lib/dist/ui-server/api/trails.js.map +1 -1
  1031. package/lib/dist/ui-server/api/when.d.ts +10 -2
  1032. package/lib/dist/ui-server/api/when.d.ts.map +1 -1
  1033. package/lib/dist/ui-server/api/when.js +32 -44
  1034. package/lib/dist/ui-server/api/when.js.map +1 -1
  1035. package/lib/dist/ui-server/api/wire.js +0 -58
  1036. package/lib/dist/ui-server/api/wire.js.map +1 -1
  1037. package/lib/dist/ui-server/assets.js +0 -35
  1038. package/lib/dist/ui-server/assets.js.map +1 -1
  1039. package/lib/dist/ui-server/constants.js +0 -26
  1040. package/lib/dist/ui-server/constants.js.map +1 -1
  1041. package/lib/dist/ui-server/highlight/bounded-tokenize.d.ts +28 -0
  1042. package/lib/dist/ui-server/highlight/bounded-tokenize.d.ts.map +1 -0
  1043. package/lib/dist/ui-server/highlight/bounded-tokenize.js +114 -0
  1044. package/lib/dist/ui-server/highlight/bounded-tokenize.js.map +1 -0
  1045. package/lib/dist/ui-server/highlight/index.d.ts.map +1 -1
  1046. package/lib/dist/ui-server/highlight/index.js +7 -133
  1047. package/lib/dist/ui-server/highlight/index.js.map +1 -1
  1048. package/lib/dist/ui-server/highlight/languages.d.ts +3 -3
  1049. package/lib/dist/ui-server/highlight/languages.js +0 -31
  1050. package/lib/dist/ui-server/highlight/languages.js.map +1 -1
  1051. package/lib/dist/ui-server/highlight/tokenize-worker.d.ts +7 -0
  1052. package/lib/dist/ui-server/highlight/tokenize-worker.d.ts.map +1 -0
  1053. package/lib/dist/ui-server/highlight/tokenize-worker.js +15 -0
  1054. package/lib/dist/ui-server/highlight/tokenize-worker.js.map +1 -0
  1055. package/lib/dist/ui-server/index.d.ts +25 -0
  1056. package/lib/dist/ui-server/index.d.ts.map +1 -1
  1057. package/lib/dist/ui-server/index.js +35 -103
  1058. package/lib/dist/ui-server/index.js.map +1 -1
  1059. package/lib/dist/ui-server/open-browser.js +0 -34
  1060. package/lib/dist/ui-server/open-browser.js.map +1 -1
  1061. package/lib/dist/ui-server/security.d.ts +5 -0
  1062. package/lib/dist/ui-server/security.d.ts.map +1 -1
  1063. package/lib/dist/ui-server/security.js +11 -147
  1064. package/lib/dist/ui-server/security.js.map +1 -1
  1065. package/lib/dist/ui-server/static.js +0 -41
  1066. package/lib/dist/ui-server/static.js.map +1 -1
  1067. package/lib/dist/upgrade/index.d.ts +61 -10
  1068. package/lib/dist/upgrade/index.d.ts.map +1 -1
  1069. package/lib/dist/upgrade/index.js +191 -225
  1070. package/lib/dist/upgrade/index.js.map +1 -1
  1071. package/lib/dist/upgrade/remove-binary.js +2 -67
  1072. package/lib/dist/upgrade/remove-binary.js.map +1 -1
  1073. package/lib/dist/upgrade/update-check.js +1 -81
  1074. package/lib/dist/upgrade/update-check.js.map +1 -1
  1075. package/lib/dist/utils.d.ts +69 -1
  1076. package/lib/dist/utils.d.ts.map +1 -1
  1077. package/lib/dist/utils.js +224 -266
  1078. package/lib/dist/utils.js.map +1 -1
  1079. package/lib/dist/viewer/assets/{index-D4S7YUPf.js → index-BSGpxBr9.js} +60 -58
  1080. package/lib/dist/viewer/index.html +1 -1
  1081. package/lib/dist/worker-teardown.d.ts +48 -0
  1082. package/lib/dist/worker-teardown.d.ts.map +1 -0
  1083. package/lib/dist/worker-teardown.js +53 -0
  1084. package/lib/dist/worker-teardown.js.map +1 -0
  1085. package/lib/kernel/codegraph-kernel.node +2 -2
  1086. package/lib/node_modules/.package-lock.json +4 -4
  1087. package/lib/node_modules/ignore/README.md +138 -8
  1088. package/lib/node_modules/ignore/index.d.ts +56 -20
  1089. package/lib/node_modules/ignore/index.js +1033 -221
  1090. package/lib/node_modules/ignore/legacy.js +871 -178
  1091. package/lib/node_modules/ignore/package.json +10 -4
  1092. package/lib/package.json +14 -8
  1093. package/node.exe +2 -2
  1094. package/package.json +1 -1
@@ -1,9 +1,4 @@
1
1
  "use strict";
2
- /**
3
- * Extraction Orchestrator
4
- *
5
- * Coordinates file scanning, parsing, and database storage.
6
- */
7
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
8
3
  if (k2 === undefined) k2 = k;
9
4
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -48,6 +43,7 @@ exports.preloadLanguagesForFiles = preloadLanguagesForFiles;
48
43
  exports.buildScopeIgnore = buildScopeIgnore;
49
44
  exports.discoverEmbeddedRepoRoots = discoverEmbeddedRepoRoots;
50
45
  exports.findUnindexedIgnoredRepos = findUnindexedIgnoredRepos;
46
+ exports.includeIgnoredPatternFor = includeIgnoredPatternFor;
51
47
  exports.getGitChangedFiles = getGitChangedFiles;
52
48
  exports.getGitHeadSha = getGitHeadSha;
53
49
  exports.canTrustGitFastPath = canTrustGitFastPath;
@@ -71,156 +67,136 @@ const errors_1 = require("../errors");
71
67
  const utils_1 = require("../utils");
72
68
  const ignore_1 = __importDefault(require("ignore"));
73
69
  const frameworks_1 = require("../resolution/frameworks");
70
+ const package_deps_1 = require("../resolution/frameworks/package-deps");
74
71
  const cooperative_yield_1 = require("../resolution/cooperative-yield");
72
+ const resurrect_ref_1 = require("../resolution/resurrect-ref");
73
+ const module_importers_1 = require("../resolution/module-importers");
74
+ const workspace_packages_1 = require("../resolution/workspace-packages");
75
75
  const file_limits_1 = require("../file-limits");
76
76
  Object.defineProperty(exports, "oversizeStamp", { enumerable: true, get: function () { return file_limits_1.oversizeStamp; } });
77
- /**
78
- * Number of files to read in parallel during indexing.
79
- * File reads are I/O-bound; batching overlaps I/O wait with CPU parse work.
80
- */
81
77
  const FILE_IO_BATCH_SIZE = 10;
82
- /**
83
- * How many files the `sync()` reconcile processes between cooperative yields to
84
- * the event loop. The reconcile runs two O(files) loops of synchronous `fs`
85
- * calls (existsSync for removals, statSync for adds/mods); on a very large repo
86
- * (~100k files) an un-yielded run wedges the main thread for minutes, which both
87
- * trips the liveness watchdog (it SIGKILLs a process whose loop stops turning)
88
- * and blocks the first MCP tool call behind the catch-up gate (issue #905).
89
- * Yielding every N files keeps the socket, the watchdog heartbeat, and any
90
- * concurrent read query responsive while the reconcile runs.
91
- */
92
78
  const SYNC_RECONCILE_YIELD_INTERVAL = 1000;
93
- // PARSER_RESET_INTERVAL moved to parse-worker.ts (runs in worker thread)
94
- /**
95
- * Maximum time (ms) to wait for a single file to parse in the worker thread.
96
- * If tree-sitter hangs or WASM runs out of memory, this prevents the entire
97
- * indexing run from freezing. The worker is restarted after a (hard) timeout.
98
- * Env-overridable via CODEGRAPH_PARSE_TIMEOUT_MS for slow storage (#1231).
99
- */
100
79
  const PARSE_TIMEOUT_MS = (0, parse_pool_1.resolveParseTimeoutMs)(process.env.CODEGRAPH_PARSE_TIMEOUT_MS);
101
- /**
102
- * Number of files to parse before recycling the worker thread.
103
- * WASM linear memory can grow but NEVER shrink (WebAssembly spec limitation).
104
- * The only way to reclaim tree-sitter's WASM heap is to destroy the entire
105
- * V8 isolate by terminating the worker thread and spawning a fresh one.
106
- * This interval balances memory usage against the cost of reloading grammars.
107
- */
108
80
  const WORKER_RECYCLE_INTERVAL = 250;
109
- /**
110
- * Calculate SHA256 hash of file contents
111
- */
81
+ const RE_EXPORTING_LANGUAGES = new Set(['typescript', 'tsx', 'javascript', 'jsx']);
82
+ const TYPE_FROM_FILE = /\.(?:pyi?|[mc]?[jt]sx?)$/;
112
83
  function hashContent(content) {
113
84
  return crypto.createHash('sha256').update(content).digest('hex');
114
85
  }
115
- /**
116
- * What change detection hashes for a file: its text when it is under the size
117
- * limit, the size stamp when it is over — an oversize file is never decoded.
118
- * `null` when the bytes show a `.ts` file is an MPEG transport stream, not
119
- * TypeScript (#1910): decided from the bytes already read, so it costs no I/O
120
- * and runs only for a file that is new or changed — never once per `.ts` file
121
- * at discovery, which on a slow disk is a random read per file per scan.
122
- */
123
86
  function readSourceOrStamp(fullPath) {
124
87
  const { stats, bytes } = (0, file_limits_1.readBoundedSourceSync)(fullPath);
125
88
  if (bytes === null)
126
89
  return (0, file_limits_1.oversizeStamp)(stats.size);
127
90
  return isMpegTsBytes(fullPath, bytes) ? null : bytes.toString('utf8');
128
91
  }
129
- /** Whether these bytes, read from `filePath`, are a `.ts` MPEG transport stream (#1910). */
92
+ function diskSignature(fullPath, isFolder = false) {
93
+ try {
94
+ if (isFolder) {
95
+ return fs.readdirSync(fullPath, { withFileTypes: true })
96
+ .filter((entry) => entry.isDirectory())
97
+ .map((entry) => entry.name)
98
+ .sort()
99
+ .join('/');
100
+ }
101
+ const stats = fs.statSync(fullPath, { throwIfNoEntry: false });
102
+ return stats ? `${stats.size}:${stats.mtimeMs}` : '-';
103
+ }
104
+ catch {
105
+ return '-';
106
+ }
107
+ }
130
108
  function isMpegTsBytes(filePath, bytes) {
131
109
  if (!(0, grammars_1.hasMpegTsExtension)(filePath) || !(0, grammars_1.isMpegTransportStream)(bytes.subarray(0, grammars_1.MPEG_TS_SNIFF_BYTES)))
132
110
  return false;
133
111
  (0, errors_1.logDebug)('Skipping MPEG transport stream named .ts — not TypeScript', { filePath });
134
112
  return true;
135
113
  }
136
- /**
137
- * Directory names that are dependency, build, cache, or tooling output across the
138
- * languages/frameworks CodeGraph supports — curated from the canonical
139
- * github/gitignore templates. Excluded by default so the graph reflects your code,
140
- * not third-party noise, without requiring a `.gitignore` (issue #407). The
141
- * exclusion applies uniformly (git or not, tracked or not); the only opt-in is an
142
- * explicit `.gitignore` negation (e.g. `!vendor/`). First-party-prone or generic
143
- * names (`packages`, `lib`, `app`, `bin`, `src`, `deps`, `env`, `tmp`, `storage`,
144
- * `Library`) are deliberately NOT listed, to avoid ever hiding real source.
145
- *
146
- * Only dirs that actually contain *indexable source* (or are enormous) earn a slot
147
- * — IDE/state dirs like `.idea`/`.vs` are omitted because CodeGraph indexes only
148
- * recognized source extensions, so they produce no symbols regardless.
149
- */
150
114
  const DEFAULT_IGNORE_DIRS = new Set([
151
- // JS / TS — dependency directories
152
115
  'node_modules', 'bower_components', 'jspm_packages', 'web_modules',
153
116
  '.yarn', '.pnpm-store',
154
- // JS / TS — framework & bundler build / cache / deploy output
155
117
  '.next', '.nuxt', '.svelte-kit', '.turbo', '.vite', '.parcel-cache', '.angular',
156
118
  '.docusaurus', 'storybook-static', '.vinxi', '.nitro', 'out-tsc',
157
119
  '.vercel', '.netlify', '.wrangler',
158
- // Build output (common across ecosystems)
159
120
  'dist', 'build', 'out', '.output',
160
- // Test / coverage
161
121
  'coverage', '.nyc_output',
162
- // Python
163
122
  '__pycache__', '__pypackages__', '.venv', 'venv', '.pixi', '.pdm-build',
164
123
  '.mypy_cache', '.pytest_cache', '.ruff_cache', '.tox', '.nox', '.hypothesis',
165
124
  '.ipynb_checkpoints', '.eggs',
166
- // Rust / JVM (Maven, Gradle, Scala)
167
125
  'target', '.gradle',
168
- // .NET
169
126
  'obj',
170
- // Vendored deps (Go, PHP/Composer, Ruby/Bundler)
171
127
  'vendor',
172
- // Swift / iOS
173
128
  '.build', 'Pods', 'Carthage', 'DerivedData', '.swiftpm',
174
- // Dart / Flutter
175
129
  '.dart_tool', '.pub-cache',
176
- // Native (Android NDK, C/C++ deps)
177
130
  '.cxx', '.externalNativeBuild', 'vcpkg_installed',
178
- // Scala tooling
179
131
  '.bloop', '.metals',
180
- // Lua / Luau (LuaRocks)
181
132
  'lua_modules', '.luarocks',
182
- // Delphi / RAD Studio IDE backups (duplicate .pas source — would double-count)
183
133
  '__history', '__recovery',
184
- // Generic cache
185
134
  '.cache',
186
135
  ]);
187
- /**
188
- * Android resource directory types. A `res/` tree holds ONLY non-code resources —
189
- * layouts, drawables, value bags (strings/colors/styles), menus, navigation
190
- * graphs — split into one typed subdirectory per kind, optionally density/locale/
191
- * version-qualified (`values-es`, `drawable-hdpi`, `layout-v21`, …). None of it
192
- * yields an extractable code symbol, yet on an Android app it DOMINATES the tree
193
- * (one report: 26k XML files = 97% of the project, 0 symbols), bloating the DB,
194
- * slowing indexing, and skewing both the file count and `codegraph_explore`
195
- * results (#1047). So these are excluded by default. The structure is
196
- * self-identifying — a non-Android project has no `res/layout/` etc., so it's
197
- * untouched — and the only XML that DOES produce symbols (MyBatis mappers) lives
198
- * under `src/main/resources/`, never `res/`, so nothing useful is dropped.
199
- * `res/raw/` is deliberately NOT here: it holds arbitrary bundled assets that can
200
- * be code-ish (a `.sql` schema, a `.js`), so we leave it indexed. Override any of
201
- * these with a `.gitignore` negation (e.g. `!res/values/`).
202
- */
203
136
  const ANDROID_RES_TYPES = [
204
137
  'anim', 'animator', 'color', 'drawable', 'font', 'layout',
205
138
  'menu', 'mipmap', 'navigation', 'transition', 'values', 'xml',
206
139
  ];
207
- /** Gitignore-style patterns for the `ignore` matcher: the dirs above plus a few globs. */
140
+ const JVM_BUILD_PACKAGE_DIRS = [
141
+ '**/src/*/java/**/build/',
142
+ '**/src/*/kotlin/**/build/',
143
+ '**/src/*/scala/**/build/',
144
+ ];
208
145
  const DEFAULT_IGNORE_PATTERNS = [
209
146
  ...Array.from(DEFAULT_IGNORE_DIRS, (d) => `${d}/`),
210
- '*.egg-info/', // Python packaging metadata
211
- 'cmake-build-*/', // CLion / CMake build trees
212
- 'bazel-*/', // Bazel output symlink trees
213
- // Android resource dirs at any depth, with their qualifier variants (#1047).
147
+ '*.egg-info/',
148
+ 'cmake-build-*/',
149
+ 'bazel-*/',
214
150
  ...ANDROID_RES_TYPES.map((t) => `**/res/${t}*/`),
215
- // `build` is also a legal JVM package segment. Keep it under conventional
216
- // source roots (any source set: main, test, androidTest, ...) while continuing
217
- // to exclude module/build output (#1642). Unignore only the directory, not its
218
- // subtree: other defaults still apply.
219
- '!**/src/*/java/**/build/',
220
- '!**/src/*/kotlin/**/build/',
221
- '!**/src/*/scala/**/build/',
151
+ ...JVM_BUILD_PACKAGE_DIRS.map((d) => `!${d}`),
152
+ '!**/src/**/build/',
222
153
  ];
223
- /** True if `buf` decodes as strict UTF-8 (no invalid byte sequences). */
154
+ const HAND_WRITTEN_SOURCE = /\.(?:[mc]?ts|tsx|ets|jsx|vue|svelte|astro|go|cs|rs)$/i;
155
+ const DECLARATION_FILE = /\.d\.(?:[mc]?ts|ets)$/i;
156
+ const jvmBuildPackages = (0, ignore_1.default)().add(JVM_BUILD_PACKAGE_DIRS);
157
+ function srcBuildFolderOf(rel) {
158
+ if (!/(?:^|\/)build\//i.test(rel))
159
+ return null;
160
+ const parts = rel.split('/');
161
+ let inSrc = false;
162
+ for (let i = 0; i < parts.length - 1; i++) {
163
+ const part = parts[i].toLowerCase();
164
+ if (part === 'src') {
165
+ inSrc = true;
166
+ }
167
+ else if (part === 'build' && inSrc) {
168
+ const folder = parts.slice(0, i + 1).join('/') + '/';
169
+ return jvmBuildPackages.ignores(folder) ? null : folder;
170
+ }
171
+ }
172
+ return null;
173
+ }
174
+ function buildOutputFolderUnderSrc(rel) {
175
+ const name = rel.slice(rel.lastIndexOf('/') + 1);
176
+ if (!name.includes('.'))
177
+ return null;
178
+ if (HAND_WRITTEN_SOURCE.test(name) && !DECLARATION_FILE.test(name))
179
+ return null;
180
+ return srcBuildFolderOf(rel);
181
+ }
182
+ function excludeBuildOutputUnderSrc(ig, projectRules) {
183
+ const ignoredByPatterns = ig.ignores.bind(ig);
184
+ ig.ignores = (rel) => {
185
+ if (ignoredByPatterns(rel))
186
+ return true;
187
+ const folder = buildOutputFolderUnderSrc(rel);
188
+ if (folder === null)
189
+ return false;
190
+ if (!projectRules)
191
+ return true;
192
+ for (let end = rel.length; end >= folder.length; end = rel.lastIndexOf('/', end - 2) + 1) {
193
+ if (projectRules.test(rel.slice(0, end)).unignored)
194
+ return false;
195
+ }
196
+ return true;
197
+ };
198
+ return ig;
199
+ }
224
200
  function isValidUtf8(buf) {
225
201
  try {
226
202
  new TextDecoder('utf-8', { fatal: true }).decode(buf);
@@ -230,47 +206,25 @@ function isValidUtf8(buf) {
230
206
  return false;
231
207
  }
232
208
  }
233
- /**
234
- * Read a `.gitignore` and return patterns safe to hand to the `ignore` matcher —
235
- * never throwing, even when the file isn't real gitignore text. Two failure
236
- * modes, both seen in the wild (issue #682):
237
- *
238
- * - The file isn't valid UTF-8 — e.g. transparently encrypted in place by
239
- * corporate DLP / endpoint-security software, leaving a UTF-16 header plus
240
- * ciphertext. None of it is meaningful patterns, so the whole file is skipped.
241
- * - The file is text but a single line can't be compiled to a regex by the
242
- * `ignore` library — `\\[` and friends throw "Unterminated character class".
243
- * Crucially the throw is LAZY (at match time, not `.add()`), so it would
244
- * otherwise escape mid-scan. That one pattern is dropped; the rest are kept.
245
- *
246
- * Either way a warning that NAMES the file is logged (the reporter couldn't tell
247
- * which `.gitignore` was at fault) and indexing continues instead of aborting.
248
- * Returns '' when there's nothing usable.
249
- */
250
209
  function readGitignorePatterns(giPath) {
251
210
  let buf;
252
211
  try {
253
212
  buf = fs.readFileSync(giPath);
254
213
  }
255
214
  catch {
256
- return ''; // unreadable (permissions / race) — treat as absent
215
+ return '';
257
216
  }
258
- // A NUL byte never appears in real gitignore text, and a fatal UTF-8 decode
259
- // catches the rest. Such a file isn't ignore patterns at all.
260
217
  if (buf.includes(0) || !isValidUtf8(buf)) {
261
218
  (0, errors_1.logWarn)('Ignoring a .gitignore that is not valid UTF-8 text — it may have been encrypted ' +
262
219
  'in place by endpoint-security software. Indexing continues without it.', { file: giPath });
263
220
  return '';
264
221
  }
265
222
  const content = buf.toString('utf-8');
266
- // Fast path: one `.ignores()` call forces the library to compile EVERY rule,
267
- // so if it doesn't throw, the whole file is safe to use verbatim.
268
223
  try {
269
224
  (0, ignore_1.default)().add(content).ignores('.codegraph-probe');
270
225
  return content;
271
226
  }
272
227
  catch {
273
- // Fall through: a line is uncompilable — keep the good ones, drop the bad.
274
228
  }
275
229
  const kept = [];
276
230
  let dropped = 0;
@@ -288,10 +242,6 @@ function readGitignorePatterns(giPath) {
288
242
  }
289
243
  return kept.join('\n');
290
244
  }
291
- /**
292
- * Resolve the repository GIT_DIR for `repoRoot` (a `.git` directory, or the
293
- * target of a `.git` file pointer). Null when this isn't a git checkout.
294
- */
295
245
  function resolveGitDir(repoRoot) {
296
246
  const gitPath = path.join(repoRoot, '.git');
297
247
  let st;
@@ -315,7 +265,34 @@ function resolveGitDir(repoRoot) {
315
265
  return null;
316
266
  }
317
267
  }
318
- /** Expand a leading `~/` the way git does for `core.excludesFile`. */
268
+ function sparseCheckoutStamp(dir) {
269
+ let repoRoot = path.resolve(dir);
270
+ while (!fs.existsSync(path.join(repoRoot, '.git'))) {
271
+ const parent = path.dirname(repoRoot);
272
+ if (parent === repoRoot)
273
+ return '';
274
+ repoRoot = parent;
275
+ }
276
+ const gitDir = resolveGitDir(repoRoot);
277
+ if (!gitDir)
278
+ return '';
279
+ let patterns;
280
+ try {
281
+ patterns = fs.readFileSync(path.join(gitDir, 'info', 'sparse-checkout'), 'utf8');
282
+ }
283
+ catch {
284
+ return '';
285
+ }
286
+ const switches = ['config', 'config.worktree'].flatMap((name) => {
287
+ try {
288
+ return fs.readFileSync(path.join(gitDir, name), 'utf8').split('\n').filter((line) => /sparsecheckout/i.test(line));
289
+ }
290
+ catch {
291
+ return [];
292
+ }
293
+ });
294
+ return hashContent(`${patterns}\0${switches.join('\n')}`);
295
+ }
319
296
  function expandUserPath(p) {
320
297
  if (p === '~')
321
298
  return os.homedir();
@@ -323,13 +300,6 @@ function expandUserPath(p) {
323
300
  return path.join(os.homedir(), p.slice(2));
324
301
  return p;
325
302
  }
326
- /**
327
- * Root-relative exclude patterns from git sources that are NOT the root
328
- * `.gitignore`: `.git/info/exclude` and `core.excludesFile`. Same semantics as
329
- * the root `.gitignore`, so they merge into {@link buildDefaultIgnore}. Without
330
- * these, the watcher / FS-walk scope silently diverged from
331
- * `git ls-files --exclude-standard` (#1728).
332
- */
333
303
  function readGitExcludeExtraPatterns(rootDir) {
334
304
  const chunks = [];
335
305
  const gitDir = resolveGitDir(rootDir);
@@ -342,7 +312,7 @@ function readGitExcludeExtraPatterns(rootDir) {
342
312
  }
343
313
  }
344
314
  try {
345
- const configured = (0, child_process_1.execFileSync)('git', ['-C', rootDir, 'config', '--get', 'core.excludesFile'], { encoding: 'utf8', timeout: 5_000, stdio: ['ignore', 'pipe', 'ignore'] }).trim();
315
+ const configured = (0, child_process_1.execFileSync)('git', ['-C', rootDir, 'config', '--get', 'core.excludesFile'], { encoding: 'utf8', timeout: 5_000, stdio: ['ignore', 'pipe', 'ignore'], windowsHide: true }).trim();
346
316
  if (configured) {
347
317
  const abs = expandUserPath(configured);
348
318
  if (fs.existsSync(abs)) {
@@ -353,29 +323,25 @@ function readGitExcludeExtraPatterns(rootDir) {
353
323
  }
354
324
  }
355
325
  catch {
356
- // No git, unset, or timeout — leave extras empty.
357
326
  }
358
327
  return chunks.join('\n');
359
328
  }
360
- /**
361
- * Directories `git ls-files -o -i --exclude-standard --directory` reports as
362
- * ignored-untracked. Seeded into {@link ScopeIgnore} so nested `.gitignore`
363
- * effects (and any exclude-standard rule the flat matcher might miss) prune the
364
- * watcher the same way the indexer skips them (#1728).
365
- */
366
- function listGitIgnoredDirectories(rootDir) {
329
+ function listGitIgnoredDirectories(rootDir, sink) {
367
330
  try {
368
331
  const out = (0, child_process_1.execFileSync)('git', ['-C', rootDir, 'ls-files', '-z', '-o', '-i', '--exclude-standard', '--directory'], {
369
332
  encoding: 'utf8',
370
333
  timeout: 60_000,
371
334
  maxBuffer: 50 * 1024 * 1024,
372
335
  stdio: ['ignore', 'pipe', 'ignore'],
336
+ windowsHide: true,
373
337
  });
374
338
  const dirs = [];
375
- for (const entry of out.split('\0')) {
376
- if (!entry)
339
+ for (const raw of out.split('\0')) {
340
+ if (isWholeCwdEntry(raw))
377
341
  continue;
342
+ const entry = (0, utils_1.normalizePath)(raw);
378
343
  dirs.push(entry.endsWith('/') ? entry : `${entry}/`);
344
+ sink?.push(entry);
379
345
  }
380
346
  return dirs;
381
347
  }
@@ -383,86 +349,38 @@ function listGitIgnoredDirectories(rootDir) {
383
349
  return [];
384
350
  }
385
351
  }
386
- /**
387
- * An `ignore` matcher seeded with the built-in defaults, merged with the project's
388
- * root .gitignore so a negation there (e.g. `!vendor/`) overrides a default, plus
389
- * git's other root-relative exclude files (`.git/info/exclude`, `core.excludesFile`)
390
- * so watcher / FS-walk scope matches `git ls-files --exclude-standard` (#1728).
391
- * Shared by both enumeration paths so behavior is identical with or without git —
392
- * and so the defaults apply to tracked files too (committing a dependency dir
393
- * doesn't make it project code; the explicit `.gitignore` negation is the only
394
- * opt-in).
395
- */
396
352
  function buildDefaultIgnore(rootDir) {
397
353
  const ig = (0, ignore_1.default)().add(DEFAULT_IGNORE_PATTERNS);
354
+ const projectRules = (0, ignore_1.default)();
398
355
  const rootGitignore = path.join(rootDir, '.gitignore');
399
- if (fs.existsSync(rootGitignore))
400
- ig.add(readGitignorePatterns(rootGitignore));
356
+ if (fs.existsSync(rootGitignore)) {
357
+ const patterns = readGitignorePatterns(rootGitignore);
358
+ ig.add(patterns);
359
+ projectRules.add(patterns);
360
+ }
401
361
  const extra = readGitExcludeExtraPatterns(rootDir);
402
- if (extra)
362
+ if (extra) {
403
363
  ig.add(extra);
404
- return ig;
364
+ projectRules.add(extra);
365
+ }
366
+ return excludeBuildOutputUnderSrc(ig, projectRules);
405
367
  }
406
- /**
407
- * Defaults-only ignore matcher (no root `.gitignore` merged). Used wherever the
408
- * parent repo's own ignore rules must NOT apply — inside embedded child repos,
409
- * whose gitignore semantics their own `git ls-files` already enforced (#514).
410
- */
411
368
  function defaultsOnlyIgnore() {
412
- return (0, ignore_1.default)().add(DEFAULT_IGNORE_PATTERNS);
369
+ return excludeBuildOutputUnderSrc((0, ignore_1.default)().add(DEFAULT_IGNORE_PATTERNS), null);
413
370
  }
414
- /**
415
- * Matcher for the project's `codegraph.json` `includeIgnored` patterns — the
416
- * explicit opt-in to index embedded git repos living inside gitignored
417
- * directories (#622, #699). Returns `null` when the project opted in nothing,
418
- * which is the zero-config DEFAULT: `.gitignore` is then fully respected and a
419
- * gitignored directory (even one holding nested repos) is never walked or
420
- * indexed (#970, #976). Built once per scan/sync/scope operation from the scan
421
- * root and threaded down — never global, so multi-project daemons stay isolated.
422
- */
423
371
  function loadIncludeIgnoredMatcher(rootDir) {
424
372
  const patterns = (0, project_config_1.loadIncludeIgnoredPatterns)(rootDir);
425
373
  return patterns.length > 0 ? (0, ignore_1.default)().add(patterns) : null;
426
374
  }
427
- /**
428
- * Matcher for the project's `codegraph.json` `exclude` patterns — paths to keep
429
- * OUT of the index even when git-tracked, which `.gitignore` cannot do (#999).
430
- * The escape hatch for a committed vendor/theme/SDK directory. Returns `null`
431
- * when nothing is excluded (the zero-config default → no overhead). Matched
432
- * against project-root-relative paths, so it applies uniformly across the whole
433
- * workspace, including inside embedded repos (excluding `static/` means gone
434
- * everywhere). Built once per scan/sync/scope operation from the scan root.
435
- */
436
375
  function loadExcludeMatcher(rootDir) {
437
376
  const patterns = (0, project_config_1.loadExcludePatterns)(rootDir);
438
377
  return patterns.length > 0 ? (0, ignore_1.default)().add(patterns) : null;
439
378
  }
440
- /**
441
- * Matcher for the project's `codegraph.json` `include` patterns — first-party
442
- * source to force INTO the index even when `.gitignore` drops it (the general
443
- * whitelist `includeIgnored` never was — that one only revives *embedded git
444
- * repos*). The case it exists for: a project under a second VCS (SVN/Perforce)
445
- * `.gitignore`s its own real source so it stays out of Git, yet we still want it
446
- * indexed. Returns `null` when nothing is force-included (the zero-config
447
- * default → no overhead, no extra walk). Built once per scan/sync/scope
448
- * operation from the scan root.
449
- */
450
379
  function loadIncludeMatcher(rootDir) {
451
380
  const patterns = (0, project_config_1.loadIncludePatterns)(rootDir);
452
381
  return patterns.length > 0 ? (0, ignore_1.default)().add(patterns) : null;
453
382
  }
454
- /** Glob metacharacters that end the static (literal) prefix of an `include` pattern. */
455
383
  const GLOB_META = /[*?[\]{}!]/;
456
- /**
457
- * The static directory prefix of each `include` pattern — the literal leading
458
- * path up to the first glob segment — trailing-slashed, used to (a) walk only
459
- * the opted-in subtrees in `collectIncludedFiles` and (b) let `ScopeIgnore` keep
460
- * the watcher descending toward them. `Tools/` stays `Tools/`; a recursive
461
- * `Tools/**` glob yields `Tools/`; `src/local/file.ts` yields `src/local/` (the
462
- * file's dir); a pattern that starts with a glob (like a leading `**`) yields
463
- * `''`, meaning "no static root — walk the whole tree". Duplicates and roots
464
- * nested under a broader root are collapsed so each subtree is walked once.
465
- */
466
384
  function includeStaticRoots(patterns) {
467
385
  const roots = new Set();
468
386
  for (const pattern of patterns) {
@@ -478,35 +396,18 @@ function includeStaticRoots(patterns) {
478
396
  lead.push(s);
479
397
  }
480
398
  const hadWildcard = lead.length < segs.length;
481
- // A wholly-literal pattern with no trailing slash names a file (or a dir we
482
- // can't tell apart) — drop its last segment so we walk the containing dir
483
- // and let the matcher pick the file. A trailing slash or a glob means the
484
- // remaining `lead` is already the directory to walk.
485
399
  if (!hadWildcard && !trailingSlash && lead.length > 0)
486
400
  lead.pop();
487
401
  if (lead.length === 0) {
488
402
  roots.clear();
489
403
  roots.add('');
490
- return ['']; // a top-level glob forces a whole-tree walk; nothing narrower matters
404
+ return [''];
491
405
  }
492
406
  roots.add(lead.join('/') + '/');
493
407
  }
494
- // Collapse roots nested under a broader one (e.g. drop `a/b/` if `a/` is present).
495
408
  const all = [...roots];
496
409
  return all.filter((r) => !all.some((other) => other !== r && r.startsWith(other)));
497
410
  }
498
- /**
499
- * Actively discover the source files an `include` whitelist forces in. `git
500
- * ls-files` never lists gitignored files, so a filtered filesystem walk of just
501
- * the opted-in subtrees (`includeStaticRoots`) is the only way to find them.
502
- * Returns project-root-relative, normalized source-file paths.
503
- *
504
- * A file is collected when it MATCHES `include`, is NOT hit by `exclude` (an
505
- * explicit exclude always wins), is a recognized source file, and does not live
506
- * under a built-in default-ignored dir (`node_modules`, `dist`, …), `.git`, or
507
- * CodeGraph's data dir — those are never resurfaced, mirroring `ScopeIgnore`.
508
- * `.gitignore` is deliberately NOT consulted: overriding it is the whole point.
509
- */
510
411
  function collectIncludedFiles(rootDir, include, exclude, roots, overrides) {
511
412
  const out = new Set();
512
413
  const defaults = defaultsOnlyIgnore();
@@ -514,11 +415,7 @@ function collectIncludedFiles(rootDir, include, exclude, roots, overrides) {
514
415
  const consider = (abs, rel, isDir) => {
515
416
  if (isDir) {
516
417
  if (defaults.ignores(rel + '/'))
517
- return; // never node_modules/dist/… via include
518
- // An explicit `exclude` always wins over `include`; prune the whole subtree
519
- // here so a large excluded dir (a committed frontend's own vendored deps,
520
- // build output, …) is never walked — the per-file guard below still catches
521
- // anything a directory pattern doesn't, so this is a pure efficiency win.
418
+ return;
522
419
  if (exclude && exclude.ignores(rel + '/'))
523
420
  return;
524
421
  walk(abs);
@@ -530,7 +427,7 @@ function collectIncludedFiles(rootDir, include, exclude, roots, overrides) {
530
427
  return;
531
428
  if (exclude && exclude.ignores(rel))
532
429
  return;
533
- if (!(0, grammars_1.isSourceFile)(rel, overrides))
430
+ if (!(0, grammars_1.isSourceFile)(rel, overrides, rootDir))
534
431
  return;
535
432
  out.add(rel);
536
433
  }
@@ -544,7 +441,7 @@ function collectIncludedFiles(rootDir, include, exclude, roots, overrides) {
544
441
  return;
545
442
  }
546
443
  if (visited.has(realDir))
547
- return; // symlink-cycle guard
444
+ return;
548
445
  visited.add(realDir);
549
446
  let entries;
550
447
  try {
@@ -558,7 +455,7 @@ function collectIncludedFiles(rootDir, include, exclude, roots, overrides) {
558
455
  continue;
559
456
  const abs = path.join(absDir, entry.name);
560
457
  const rel = (0, utils_1.normalizePath)(path.relative(rootDir, abs));
561
- if (!rel || rel.startsWith('..'))
458
+ if (!rel || (0, utils_1.escapesRoot)(rel))
562
459
  continue;
563
460
  if (entry.isSymbolicLink()) {
564
461
  try {
@@ -566,7 +463,6 @@ function collectIncludedFiles(rootDir, include, exclude, roots, overrides) {
566
463
  consider(abs, rel, st.isDirectory());
567
464
  }
568
465
  catch {
569
- // broken symlink — skip
570
466
  }
571
467
  continue;
572
468
  }
@@ -578,12 +474,6 @@ function collectIncludedFiles(rootDir, include, exclude, roots, overrides) {
578
474
  }
579
475
  return out;
580
476
  }
581
- /**
582
- * The included source files (`codegraph.json` `include`) for a scan root, or an
583
- * empty set when nothing is force-included. Centralizes loading the matcher,
584
- * roots, exclude, and overrides so both enumeration paths (git and filesystem
585
- * walk) add the same files.
586
- */
587
477
  function collectIncludedFilesForRoot(rootDir) {
588
478
  const include = loadIncludeMatcher(rootDir);
589
479
  if (!include)
@@ -591,27 +481,9 @@ function collectIncludedFilesForRoot(rootDir) {
591
481
  const roots = includeStaticRoots((0, project_config_1.loadIncludePatterns)(rootDir));
592
482
  return collectIncludedFiles(rootDir, include, loadExcludeMatcher(rootDir), roots, (0, project_config_1.loadExtensionOverrides)(rootDir));
593
483
  }
594
- /**
595
- * `git ls-files --directory` collapses a wholly-untracked/ignored directory into
596
- * one entry — and when the command's own cwd is such a directory (the indexed
597
- * root is itself a git-ignored subdir of an enclosing repo), git emits the
598
- * literal `./` meaning "this entire directory". That sentinel is not a real
599
- * nested path: feeding it to the `ignore` matcher throws ("path should be a
600
- * `path.relative()`d string, but got "./""), which used to abort `buildScopeIgnore`
601
- * and so break the MCP daemon's watcher/auto-sync on connect; and joining it back
602
- * onto `repoDir` would just re-point at the cwd. Drop it wherever we consume
603
- * `--directory` output. (#936)
604
- */
605
484
  function isWholeCwdEntry(entry) {
606
485
  return entry === './' || entry === '.' || entry === '';
607
486
  }
608
- /**
609
- * List the gitignored DIRECTORIES of a repo (collapsed, trailing-slash form),
610
- * relative to `repoDir`. These are invisible to every other `git ls-files` /
611
- * `git status` mode — and in a multi-repo workspace they are exactly where the
612
- * nested project repos live (a super-repo `.gitignore`s its child repos to keep
613
- * `git status` quiet; that does not make them third-party code). (#514)
614
- */
615
487
  function listIgnoredDirs(repoDir) {
616
488
  try {
617
489
  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 });
@@ -621,25 +493,8 @@ function listIgnoredDirs(repoDir) {
621
493
  return [];
622
494
  }
623
495
  }
624
- /** Max directory depth searched below an ignored dir for nested `.git` roots. */
625
496
  const EMBEDDED_REPO_SEARCH_DEPTH = 4;
626
- /** Max directories examined per search — a huge ignored data dir must never stall a scan/sync. */
627
497
  const EMBEDDED_REPO_SEARCH_ENTRIES = 2000;
628
- /**
629
- * Classify a directory's `.git` entry for embedded-repo discovery.
630
- *
631
- * - A `.git` **directory** is an embedded clone — distinct first-party code a
632
- * super-repo merely hides from git; index it (#193, #514).
633
- * - A `.git` **file** is a pointer (`gitdir: …`). A git **worktree** points into
634
- * the host repo's own `.git/worktrees/<name>`, so it is a second working view
635
- * of a repo CodeGraph already indexes — indexing it just duplicates the whole
636
- * graph N times; skip it (#848). A **submodule worktree** points into
637
- * `.git/modules/<module>/worktrees/<name>` — same duplication, so skip it too
638
- * (#945). A **submodule** checkout points into `.git/modules/<module>` (no
639
- * `worktrees/` segment) and is distinct code, so index it as before.
640
- *
641
- * Returns `'none'` when there is no `.git` entry here.
642
- */
643
498
  function classifyGitDir(absDir) {
644
499
  let st;
645
500
  try {
@@ -654,26 +509,13 @@ function classifyGitDir(absDir) {
654
509
  return 'none';
655
510
  try {
656
511
  const gitdir = fs.readFileSync(path.join(absDir, '.git'), 'utf8').match(/^gitdir:\s*(.+)$/m)?.[1]?.trim();
657
- // A worktree's gitdir lives under some repo's `.git/worktrees/<name>` —
658
- // either the top-level repo's (`.git/worktrees/`) or, for a worktree of a
659
- // submodule, that submodule's gitdir (`.git/modules/<module>/worktrees/`).
660
- // The optional `modules/<module>` segment covers the submodule case (#945).
661
- // Match both separators so a Windows-style pointer is recognized too.
662
512
  if (gitdir && /(^|[\\/])\.git[\\/](modules[\\/][^\\/]+[\\/])?worktrees[\\/]/.test(gitdir))
663
513
  return 'worktree';
664
514
  }
665
515
  catch {
666
- // Unreadable `.git` pointer — fall back to the prior "index it" behavior.
667
516
  }
668
517
  return 'embedded';
669
518
  }
670
- /**
671
- * Find git repositories nested under `absDir` (inclusive), shallow bounded BFS.
672
- * Stops descending at each repo root found — contents belong to that repo's own
673
- * enumeration. Skips default-ignored dirs (`node_modules` can contain `.git`
674
- * from npm git-dependencies — that never makes it project code) and CodeGraph
675
- * data dirs. Depth- and entry-capped so a huge ignored tree can't stall the scan.
676
- */
677
519
  function findNestedGitRepos(absDir, relPrefix) {
678
520
  const found = [];
679
521
  const defaults = defaultsOnlyIgnore();
@@ -689,11 +531,11 @@ function findNestedGitRepos(absDir, relPrefix) {
689
531
  }
690
532
  const cls = classifyGitDir(abs);
691
533
  if (cls === 'worktree') {
692
- continue; // a git worktree duplicates an already-indexed repo (#848) — skip
534
+ continue;
693
535
  }
694
536
  if (cls === 'embedded') {
695
537
  found.push(rel);
696
- continue; // its own git handles everything below
538
+ continue;
697
539
  }
698
540
  if (depth >= EMBEDDED_REPO_SEARCH_DEPTH)
699
541
  continue;
@@ -717,38 +559,21 @@ function findNestedGitRepos(absDir, relPrefix) {
717
559
  }
718
560
  return found;
719
561
  }
720
- /**
721
- * Workspace-scope ignore matcher. Ordinary paths get the root's matcher
722
- * (built-in defaults + root `.gitignore` + `.git/info/exclude` +
723
- * `core.excludesFile`, plus directories `git ls-files --exclude-standard`
724
- * reports as ignored); paths inside an EMBEDDED repo get that repo's own
725
- * matcher — the parent's `.gitignore` hides a child repo from git, not from
726
- * the index (#514). A directory path (trailing slash) that is an ANCESTOR of
727
- * an embedded root is never ignored, so directory-pruning callers (the Linux
728
- * per-directory watcher) still descend to reach the embedded repos.
729
- *
730
- * Shared by the indexer (scoped sync / skip checks) and the watcher so their
731
- * scope cannot diverge from each other or from `git ls-files --exclude-standard`
732
- * (#1728).
733
- */
734
- /**
735
- * The grammars to preload for a file set.
736
- *
737
- * Path-only detection calls every `.h` file C, but parse-time detection reads
738
- * the source and can reclassify it as C++ or Objective-C (`detectLanguage`
739
- * with a `source` argument). Workers only ever get the grammars named here, so
740
- * a header that turns out to be Objective-C in a project with no `.m` file
741
- * found no parser and failed with `Failed to get parser for language: objc`
742
- * (#1628). C++ was already covered; Objective-C was not.
743
- */
744
- function preloadLanguagesForFiles(files, overrides) {
745
- const languages = [...new Set(files.map((f) => (0, grammars_1.detectLanguage)(f, undefined, overrides)))];
562
+ function preloadLanguagesForFiles(files, overrides, rootDir) {
563
+ const languages = [...new Set(files.map((f) => (0, grammars_1.detectLanguage)(f, undefined, overrides, rootDir)))];
564
+ if ((languages.includes('javascript') || languages.includes('jsx')) && !languages.includes('tsx'))
565
+ languages.push('tsx');
746
566
  if (languages.includes('c')) {
747
567
  for (const ambiguous of ['cpp', 'objc']) {
748
568
  if (!languages.includes(ambiguous))
749
569
  languages.push(ambiguous);
750
570
  }
751
571
  }
572
+ if (!languages.includes('pascal') &&
573
+ !(overrides && overrides['.inc']) &&
574
+ files.some((f) => f.toLowerCase().endsWith('.inc'))) {
575
+ languages.push('pascal');
576
+ }
752
577
  return languages;
753
578
  }
754
579
  class ScopeIgnore {
@@ -756,45 +581,31 @@ class ScopeIgnore {
756
581
  exclude;
757
582
  include;
758
583
  includeRoots;
584
+ gitIgnoredDirs;
759
585
  embedded;
760
586
  defaults = defaultsOnlyIgnore();
761
- constructor(rootMatcher, embedded,
762
- /**
763
- * Project `codegraph.json` `exclude` patterns (#999), matched against the
764
- * full root-relative path. Wins over everything else — an explicit user
765
- * exclude applies even to tracked files and even inside embedded repos.
766
- */
767
- exclude = null,
768
- /**
769
- * Project `codegraph.json` `include` patterns — first-party source forced
770
- * INTO the index despite `.gitignore`. When a path matches, it is NOT
771
- * ignored (so the watcher watches it), overriding `.gitignore`/`rootMatcher`
772
- * — but never `exclude` (checked first) and never a built-in default-ignored
773
- * dir. `includeRoots` are the static prefixes so a gitignored ANCESTOR
774
- * directory of an included subtree still isn't pruned by the directory
775
- * walker/watcher.
776
- */
777
- include = null, includeRoots = []) {
587
+ constructor(rootMatcher, embedded, exclude = null, include = null, includeRoots = [], gitIgnoredDirs = new Set()) {
778
588
  this.rootMatcher = rootMatcher;
779
589
  this.exclude = exclude;
780
590
  this.include = include;
781
591
  this.includeRoots = includeRoots;
782
- // Longest root first so paths in nested embedded repos hit the innermost matcher.
592
+ this.gitIgnoredDirs = gitIgnoredDirs;
783
593
  this.embedded = [...embedded].sort((a, b) => b.root.length - a.root.length);
784
594
  }
595
+ inGitIgnoredDir(rel) {
596
+ if (this.gitIgnoredDirs.size === 0)
597
+ return false;
598
+ for (let slash = rel.indexOf('/'); slash !== -1; slash = rel.indexOf('/', slash + 1)) {
599
+ if (this.gitIgnoredDirs.has(rel.slice(0, slash + 1)))
600
+ return true;
601
+ }
602
+ return false;
603
+ }
785
604
  ignores(rel) {
786
- // User `exclude` (#999) is checked first and against the full root-relative
787
- // path: it must drop git-TRACKED paths (which `.gitignore` can't) and apply
788
- // everywhere, including ancestors of embedded repos.
789
605
  if (this.exclude && this.exclude.ignores(rel))
790
606
  return true;
791
- // User `include`: force first-party source in despite `.gitignore`. Never
792
- // resurfaces a built-in default-ignored dir (node_modules/dist/…), so an
793
- // include pattern can't accidentally pull in dependency/build trees.
794
607
  if (this.include && !this.defaults.ignores(rel)) {
795
608
  if (rel.endsWith('/')) {
796
- // A directory on (or leading to) an included subtree must stay walkable
797
- // so the watcher/walker descends to reach the forced-in files.
798
609
  if (this.includeRoots.some((r) => r.startsWith(rel) || rel.startsWith(r)))
799
610
  return false;
800
611
  }
@@ -807,75 +618,28 @@ class ScopeIgnore {
807
618
  const inner = rel.slice(root.length);
808
619
  if (inner === '')
809
620
  return false;
810
- // Built-in defaults apply to the FULL path uniformly (#407) — an
811
- // embedded repo inside node_modules (an npm git-dependency) must stay
812
- // excluded even though its own rules wouldn't ignore its files.
813
621
  return this.defaults.ignores(rel) || matcher.ignores(inner);
814
622
  }
815
623
  }
816
- // Never prune a directory that leads to an embedded repo.
817
624
  if (rel.endsWith('/') && this.embedded.some(({ root }) => root.startsWith(rel))) {
818
625
  return false;
819
626
  }
820
- return this.rootMatcher.ignores(rel);
627
+ return this.rootMatcher.ignores(rel) || this.inGitIgnoredDir(rel);
821
628
  }
822
629
  }
823
630
  exports.ScopeIgnore = ScopeIgnore;
824
- /**
825
- * Build the workspace-scope matcher. When the caller already knows the
826
- * embedded roots (the scanner discovers them during collection), pass them to
827
- * skip rediscovery; otherwise they're discovered here (the watcher path).
828
- */
829
- function buildScopeIgnore(rootDir, embeddedRoots) {
631
+ function buildScopeIgnore(rootDir, embeddedRoots, ignoredEntries) {
830
632
  const roots = embeddedRoots ? [...embeddedRoots] : discoverEmbeddedRepoRoots(rootDir);
831
633
  const include = loadIncludeMatcher(rootDir);
832
- // Root matcher already has defaults + root `.gitignore` + info/exclude +
833
- // core.excludesFile. Seed ignored-untracked directories from git so nested
834
- // `.gitignore` effects prune the watcher identically to the indexer (#1728).
835
- const rootMatcher = buildDefaultIgnore(rootDir);
836
- for (const dir of listGitIgnoredDirectories(rootDir)) {
837
- rootMatcher.add(dir);
838
- }
839
- return new ScopeIgnore(rootMatcher, roots.map((root) => ({ root, matcher: buildDefaultIgnore(path.join(rootDir, root)) })), loadExcludeMatcher(rootDir), include, include ? includeStaticRoots((0, project_config_1.loadIncludePatterns)(rootDir)) : []);
634
+ return new ScopeIgnore(buildDefaultIgnore(rootDir), roots.map((root) => ({ root, matcher: buildDefaultIgnore(path.join(rootDir, root)) })), loadExcludeMatcher(rootDir), include, include ? includeStaticRoots((0, project_config_1.loadIncludePatterns)(rootDir)) : [], new Set(listGitIgnoredDirectories(rootDir, ignoredEntries)));
840
635
  }
841
- /**
842
- * Whether an embedded repo found as a tracked gitlink (mode 160000, #1031/#1033)
843
- * must be SKIPPED rather than indexed. A gitlink is tracked, so `.gitignore`
844
- * can't untrack it — but the discovery passes for it must still honor the same
845
- * scope rules as every other path, or a gitignored reference/data dir full of
846
- * `git add`ed clones gets pulled into the index against the user's stated intent
847
- * (#1065). Two reasons to skip:
848
- * 1. It sits in a built-in default-ignored location — an npm git-dependency
849
- * under `node_modules` is never project code; not even an explicit opt-in
850
- * revives it (matches `findIgnoredEmbeddedRepos`).
851
- * 2. The parent repo's own `.gitignore` covers its path and the project did
852
- * NOT opt that path in via `codegraph.json` `includeIgnored`. The gitignore
853
- * rule is the user's stated intent to keep that path out of scope, exactly
854
- * as for an UNtracked embedded repo — respect it by default, opt back in
855
- * with `includeIgnored` (#514, #970, #976).
856
- * `relDir` is repoDir-relative (trailing-slashed); `prefix` is repoDir's
857
- * scan-root-relative path so the `includeIgnored` pattern is matched on the full
858
- * scan-root-relative path. `defaults` is `defaultsOnlyIgnore()` and `repoIgnore`
859
- * is `buildDefaultIgnore(repoDir)` (defaults + the repo's own `.gitignore`),
860
- * both passed in so they're built once per repo level rather than per gitlink.
861
- */
862
636
  function gitlinkEmbeddedRepoSkipped(relDir, prefix, defaults, repoIgnore, includeIgnored) {
863
637
  if (defaults.ignores(relDir))
864
- return true; // default-ignored — never index, opt-in can't revive
638
+ return true;
865
639
  if (!repoIgnore.ignores(relDir))
866
- return false; // not ignored at all — index as before (#1031/#1033)
867
- // Gitignored by the repo's own rules — skip unless the project opted it in.
640
+ return false;
868
641
  return !includeIgnored?.ignores((0, utils_1.normalizePath)(prefix + relDir));
869
642
  }
870
- /**
871
- * Standalone discovery of every embedded repo root under `rootDir` (relative,
872
- * trailing-slashed) — the untracked kind (#193) always, and the gitignored kind
873
- * (#514) only for directories the project opted in via `codegraph.json`
874
- * `includeIgnored` (#622, #699); otherwise `.gitignore` is respected and they
875
- * are not discovered (#970, #976). Recursive (an embedded repo can embed further
876
- * repos). Returns [] for non-git roots: the filesystem walk handles nested repos
877
- * there already.
878
- */
879
643
  function discoverEmbeddedRepoRoots(rootDir) {
880
644
  try {
881
645
  (0, child_process_1.execFileSync)('git', ['rev-parse', '--git-dir'], { cwd: rootDir, encoding: 'utf-8', timeout: 5000, stdio: ['pipe', 'pipe', 'pipe'], windowsHide: true });
@@ -896,32 +660,25 @@ function discoverEmbeddedRepoRoots(rootDir) {
896
660
  }
897
661
  }
898
662
  }
899
- catch { /* untracked listing failed — ignored-side discovery still runs */ }
900
- // Unexpanded gitlinks (mode 160000) with a real checkout on disk — embedded
901
- // repos `git add`ed without `.gitmodules`, or submodules not active here. The
902
- // untracked listing above can't see them (they're tracked), so find them the
903
- // same way collectGitFiles does, keeping watcher scope == indexer scope.
904
- // (#1031, #1033)
663
+ catch { }
905
664
  try {
906
665
  const staged = lsFilesStaged({ cwd: repoAbs, encoding: 'utf-8', timeout: 30000, maxBuffer: 50 * 1024 * 1024, stdio: ['pipe', 'pipe', 'pipe'], windowsHide: true });
907
666
  const repoIgnore = buildDefaultIgnore(repoAbs);
908
667
  for (const entry of staged.split('\0')) {
909
- if (!entry || entry.slice(0, 6) !== '160000')
668
+ if (!entry || !isGitlinkEntry(entry))
910
669
  continue;
911
670
  const tab = entry.indexOf('\t');
912
671
  if (tab === -1)
913
672
  continue;
914
673
  const rel = entry.slice(tab + 1);
915
674
  const relDir = rel.endsWith('/') ? rel : rel + '/';
916
- // A gitlink under a gitignored path is respected (not indexed) unless the
917
- // project opted it in — same rule as the untracked-ignored kind (#1065).
918
675
  if (gitlinkEmbeddedRepoSkipped(relDir, prefix, defaults, repoIgnore, includeIgnored))
919
676
  continue;
920
677
  if (classifyGitDir(path.join(repoAbs, rel)) === 'embedded')
921
678
  candidates.push(relDir);
922
679
  }
923
680
  }
924
- catch { /* staged listing failed — other discovery still runs */ }
681
+ catch { }
925
682
  candidates.push(...findIgnoredEmbeddedRepos(repoAbs, includeIgnored, prefix));
926
683
  for (const rel of candidates) {
927
684
  const full = (0, utils_1.normalizePath)(prefix + rel);
@@ -932,27 +689,7 @@ function discoverEmbeddedRepoRoots(rootDir) {
932
689
  visit(rootDir, '');
933
690
  return out;
934
691
  }
935
- /**
936
- * Cap on how many skipped gitignored repos the CLI hint enumerates — a huge
937
- * gitignored data dir full of clones must never turn the hint scan into a long
938
- * walk. Enough to make the point; the caller says "+N more" past this.
939
- */
940
692
  const UNINDEXED_IGNORED_REPO_HINT_CAP = 100;
941
- /**
942
- * The INVERSE of the gitignored side of {@link discoverEmbeddedRepoRoots}:
943
- * nested git repositories under a gitignored directory that the project has NOT
944
- * opted into via `codegraph.json` `includeIgnored`. These are real repos the
945
- * default `init`/`index` deliberately skips because `.gitignore` excludes them
946
- * (#970, #976) — most visibly the "super-repo `.gitignore`s its child repos"
947
- * layout (#1156), where `init` at the parent correctly indexes ~nothing while
948
- * `init` inside each child works. The CLI uses this to turn that silent empty
949
- * index into an actionable hint: it names the skipped repos and offers to opt
950
- * them in. Paths are `rootDir`-relative and trailing-slashed (valid
951
- * `includeIgnored` patterns as-is). Returns `[]` for a non-git root (a
952
- * filesystem walk already descends into nested repos there), skips built-in
953
- * default-ignored dirs (`node_modules`, …), and is bounded so it never stalls
954
- * on a giant ignored tree.
955
- */
956
693
  function findUnindexedIgnoredRepos(rootDir) {
957
694
  try {
958
695
  (0, child_process_1.execFileSync)('git', ['rev-parse', '--git-dir'], { cwd: rootDir, encoding: 'utf-8', timeout: 5000, stdio: ['pipe', 'pipe', 'pipe'], windowsHide: true });
@@ -965,13 +702,10 @@ function findUnindexedIgnoredRepos(rootDir) {
965
702
  const repos = [];
966
703
  for (const dir of listIgnoredDirs(rootDir)) {
967
704
  if (defaults.ignores(dir))
968
- continue; // node_modules etc. — never project code
705
+ continue;
969
706
  if (includeIgnored?.ignores((0, utils_1.normalizePath)(dir)))
970
- continue; // already opted in — nothing to nag about
707
+ continue;
971
708
  for (const repo of findNestedGitRepos(path.join(rootDir, dir), dir)) {
972
- // Per-repo opt-in check, mirroring findIgnoredEmbeddedRepos: a child
973
- // pattern (`repos/a/`) doesn't match the parent dir above but DOES
974
- // cover this repo — it's indexed, so don't nag about it (#1295).
975
709
  if (includeIgnored?.ignores((0, utils_1.normalizePath)(repo)))
976
710
  continue;
977
711
  repos.push(repo);
@@ -981,21 +715,9 @@ function findUnindexedIgnoredRepos(rootDir) {
981
715
  }
982
716
  return repos;
983
717
  }
984
- /**
985
- * Discover embedded repos hidden by `repoDir`'s OWN gitignore rules: for each
986
- * gitignored directory, search for nested `.git` roots. Returns repo paths
987
- * relative to `repoDir`, trailing-slashed.
988
- *
989
- * OPT-IN ONLY. Walking into a gitignored directory contradicts what every other
990
- * tool (and CodeGraph's own `git ls-files` foundation) does — `.gitignore`
991
- * excludes. So this returns `[]` unless the project opted the directory in via
992
- * `codegraph.json` `includeIgnored`; without that, a gitignored dir — including
993
- * a huge reference/data dir full of nested clones — is left untouched (#970,
994
- * #976). When opted in, it restores the super-repo-of-clones behavior (#622,
995
- * #699). `prefix` is the scan-root-relative path of `repoDir`, so a pattern like
996
- * `services/` opts that whole subtree in at any recursion depth. Built-in
997
- * default excludes (`node_modules`, …) are always skipped.
998
- */
718
+ function includeIgnoredPatternFor(repoDir) {
719
+ return '/' + repoDir.replace(/[*[]/g, '\\$&');
720
+ }
999
721
  function findIgnoredEmbeddedRepos(repoDir, includeIgnored, prefix) {
1000
722
  if (!includeIgnored)
1001
723
  return [];
@@ -1006,90 +728,27 @@ function findIgnoredEmbeddedRepos(repoDir, includeIgnored, prefix) {
1006
728
  continue;
1007
729
  const nested = findNestedGitRepos(path.join(repoDir, dir), dir);
1008
730
  if (includeIgnored.ignores((0, utils_1.normalizePath)(prefix + dir))) {
1009
- // The whole ignored dir is opted in — every nested repo under it counts.
1010
731
  repos.push(...nested);
1011
732
  }
1012
733
  else {
1013
- // A single gitignore rule often covers the PARENT of the opted-in
1014
- // repos: `.gitignore: /repos/` lists `repos/` as ONE ignored entry,
1015
- // while `includeIgnored: ["repos/a/"]` (the CLI hint's own suggested
1016
- // spelling) names the child — which never matches the parent path, so
1017
- // the opt-in silently did nothing (#1295). Match each nested repo
1018
- // root individually so both spellings work. The walk is bounded
1019
- // (depth/entry caps in findNestedGitRepos) and only runs when
1020
- // includeIgnored is configured at all.
1021
734
  repos.push(...nested.filter((r) => includeIgnored.ignores((0, utils_1.normalizePath)(prefix + r))));
1022
735
  }
1023
736
  }
1024
737
  return repos;
1025
738
  }
1026
- /**
1027
- * `git ls-files -z -s`, expanding submodules where git allows it.
1028
- *
1029
- * `--recurse-submodules` could not be combined with `-s` before git 2.36:
1030
- * `builtin/ls-files.c` listed `show_stage` among the modes that die, and the
1031
- * check is unconditional — it does not look at whether the repo actually has
1032
- * submodules, so every call fails on older git. Ubuntu 22.04 LTS (2.34.1) and
1033
- * Debian 11 (2.30.2) are both below that line.
1034
- *
1035
- * Letting the throw escape cost far more than submodule expansion: it unwound
1036
- * the whole git-visible pass, so `includeIgnored`, gitlink recursion and the
1037
- * `codegraph.json` include allowlist silently stopped applying and files went
1038
- * missing from the index with no error (#1549). Retry without the flag instead
1039
- * — `-s` is the part that matters here, since gitlink detection reads the mode
1040
- * bits, and embedded repos are reached through the gitlink recursion anyway.
1041
- */
1042
739
  function lsFilesStaged(gitOpts) {
1043
740
  try {
1044
- return (0, child_process_1.execFileSync)('git', ['ls-files', '-z', '-s', '--recurse-submodules'], gitOpts);
741
+ return (0, child_process_1.execFileSync)('git', ['ls-files', '-z', '-s', '-t', '--recurse-submodules'], gitOpts);
1045
742
  }
1046
743
  catch {
1047
- return (0, child_process_1.execFileSync)('git', ['ls-files', '-z', '-s'], gitOpts);
744
+ return (0, child_process_1.execFileSync)('git', ['ls-files', '-z', '-s', '-t'], gitOpts);
1048
745
  }
1049
746
  }
1050
- /**
1051
- * Collect git-visible files (tracked + untracked, .gitignore-respected) from the
1052
- * git repository rooted at `repoDir`, adding each to `files` with `prefix`
1053
- * prepended so paths stay relative to the original scan root.
1054
- *
1055
- * Recurses into embedded git repositories — nested repos that are NOT submodules
1056
- * (independent clones living inside the workspace, common in CMake "super-repo"
1057
- * layouts). The parent repo's `git ls-files` cannot see into them: tracked output
1058
- * skips them entirely, and untracked output reports them only as an opaque
1059
- * "subdir/" entry (trailing slash) rather than expanding their files. Each
1060
- * embedded repo is its own git boundary, so we re-run `git ls-files` inside it.
1061
- * (See issue #193.) GITIGNORED embedded repos are invisible even to that; they
1062
- * are discovered separately via `findIgnoredEmbeddedRepos` (#514) but ONLY for
1063
- * directories the project opted in through `codegraph.json` `includeIgnored`
1064
- * (`includeIgnored` here, threaded from the scan root) — by default `.gitignore`
1065
- * is respected and they stay out (#970, #976). Every embedded repo root (however
1066
- * found) is recorded in `embeddedRoots` so callers can exempt its files from the
1067
- * parent's own gitignore rules.
1068
- */
1069
- function collectGitFiles(repoDir, prefix, files, embeddedRoots, includeIgnored = null) {
747
+ function isGitlinkEntry(entry) {
748
+ return entry.slice(2, 8) === '160000';
749
+ }
750
+ function collectGitFiles(repoDir, prefix, files, embeddedRoots, includeIgnored = null, gitlinks) {
1070
751
  const gitOpts = { cwd: repoDir, encoding: 'utf-8', timeout: 30000, maxBuffer: 50 * 1024 * 1024, stdio: ['pipe', 'pipe', 'pipe'], windowsHide: true };
1071
- // Tracked files. --recurse-submodules pulls in files from active submodules,
1072
- // which the index would otherwise represent only as a commit pointer.
1073
- // Without this, monorepos using submodules index 0 files. (See issue #147.)
1074
- // Note: --recurse-submodules only supports -c/--cached and --stage modes — it
1075
- // can't be combined with -o, so untracked files are gathered separately below.
1076
- //
1077
- // We use --stage (-s) rather than -c so each entry carries its file mode. That
1078
- // lets us spot gitlink entries (mode 160000) that --recurse-submodules did NOT
1079
- // expand: a nested repo `git add`ed without a `.gitmodules` entry, or a
1080
- // submodule that isn't active/initialized in this checkout. Such a gitlink
1081
- // falls through every pass — it's tracked, so the untracked `-o` listing below
1082
- // never reports it, and --recurse-submodules only expands ACTIVE submodules —
1083
- // so its source would be silently skipped, leaving only the super-repo's own
1084
- // files indexed. We collect those gitlinks here and recurse into them below.
1085
- // (An active submodule is expanded inline by --recurse-submodules and so never
1086
- // surfaces as a 160000 entry — only the unhandled gitlinks do.) (#1031, #1033)
1087
- //
1088
- // -z gives NUL-separated, unquoted output so non-ASCII (e.g. CJK) paths
1089
- // survive verbatim. Without it git octal-escapes and double-quotes such paths
1090
- // (the core.quotepath default), and the quoted form never matches a real file
1091
- // on disk → those files are silently dropped from the index. (#541) With -s the
1092
- // path follows a TAB after the `<mode> <object> <stage>` prefix.
1093
752
  const gitlinkRels = [];
1094
753
  const tracked = lsFilesStaged(gitOpts);
1095
754
  for (const entry of tracked.split('\0')) {
@@ -1097,30 +756,23 @@ function collectGitFiles(repoDir, prefix, files, embeddedRoots, includeIgnored =
1097
756
  continue;
1098
757
  const tab = entry.indexOf('\t');
1099
758
  if (tab === -1)
1100
- continue; // --stage always emits "<mode> <object> <stage>\t<path>"
759
+ continue;
1101
760
  const rel = entry.slice(tab + 1);
1102
- if (entry.slice(0, 6) === '160000') {
1103
- gitlinkRels.push(rel); // an unexpanded gitlink — recursed into below, not a source file itself
761
+ if (isGitlinkEntry(entry)) {
762
+ gitlinkRels.push(rel);
763
+ gitlinks?.push((0, utils_1.normalizePath)(prefix + rel));
1104
764
  continue;
1105
765
  }
766
+ if (entry[0] === 'S' && !fs.existsSync(path.join(repoDir, rel)))
767
+ continue;
1106
768
  files.add((0, utils_1.normalizePath)(prefix + rel));
1107
769
  }
1108
- // Untracked files (submodules manage their own untracked state). Embedded git
1109
- // repos surface here as a single "subdir/" entry that git refuses to descend
1110
- // into — recurse into those as their own repos so their source gets indexed.
1111
770
  const untracked = (0, child_process_1.execFileSync)('git', ['ls-files', '-z', '-o', '--exclude-standard'], gitOpts);
1112
771
  for (const rel of untracked.split('\0')) {
1113
772
  if (!rel)
1114
773
  continue;
1115
774
  if (rel.endsWith('/')) {
1116
- // git only emits a trailing-slash directory entry for an embedded repo.
1117
- // Guard with a .git check anyway, and skip anything else exactly as git
1118
- // itself skips it (we never descend into a non-repo opaque dir). Never
1119
- // descend into default-ignored locations — an embedded repo inside
1120
- // node_modules is an npm git-dependency, not project code.
1121
775
  const childDir = path.join(repoDir, rel);
1122
- // A git worktree surfaces here as an opaque untracked dir too — skip it,
1123
- // it's a duplicate working view of an already-indexed repo (#848).
1124
776
  if (classifyGitDir(childDir) === 'embedded' && !defaultsOnlyIgnore().ignores(rel)) {
1125
777
  embeddedRoots?.add((0, utils_1.normalizePath)(prefix + rel));
1126
778
  collectGitFiles(childDir, prefix + rel, files, embeddedRoots, includeIgnored);
@@ -1129,99 +781,71 @@ function collectGitFiles(repoDir, prefix, files, embeddedRoots, includeIgnored =
1129
781
  }
1130
782
  files.add((0, utils_1.normalizePath)(prefix + rel));
1131
783
  }
1132
- // Gitlink entries (mode 160000) that --recurse-submodules left unexpanded —
1133
- // an embedded repo `git add`ed without `.gitmodules`, or a submodule not
1134
- // active/initialized in this checkout. When such a gitlink has a real working
1135
- // tree on disk it is distinct first-party code we must index as its own
1136
- // embedded repo: the tracked pass skipped its contents and the untracked pass
1137
- // never sees it (it's tracked, not "other"). A gitlink with no checkout on disk
1138
- // (an uninitialized submodule — empty dir, no `.git`) has nothing to index and
1139
- // is left alone, as is a submodule worktree (a duplicate view, #945). (#1031, #1033)
1140
784
  if (gitlinkRels.length > 0) {
1141
785
  const defaults = defaultsOnlyIgnore();
1142
786
  const repoIgnore = buildDefaultIgnore(repoDir);
1143
787
  for (const rel of gitlinkRels) {
1144
788
  const relDir = rel.endsWith('/') ? rel : rel + '/';
1145
- // A gitlink under a gitignored path is respected (not indexed) unless the
1146
- // project opted it in via `includeIgnored` — keep tracked gitlinks under
1147
- // the same scope rule as the untracked-ignored kind below (#1065).
1148
789
  if (gitlinkEmbeddedRepoSkipped(relDir, prefix, defaults, repoIgnore, includeIgnored))
1149
790
  continue;
1150
791
  const childDir = path.join(repoDir, rel);
1151
- // 'embedded' = a real .git checkout on disk; 'worktree' and 'none' are skipped.
1152
792
  if (classifyGitDir(childDir) !== 'embedded')
1153
793
  continue;
1154
794
  embeddedRoots?.add((0, utils_1.normalizePath)(prefix + relDir));
1155
795
  collectGitFiles(childDir, prefix + relDir, files, embeddedRoots, includeIgnored);
1156
796
  }
1157
797
  }
1158
- // Embedded repos hidden by THIS repo's ignore rules (`/packages/` in a
1159
- // super-repo .gitignore) never appear in any listing above. By default they
1160
- // stay hidden — `.gitignore` is respected (#970, #976). They are recursed into
1161
- // only when the project opted the directory in via `codegraph.json`
1162
- // `includeIgnored` (#622, #699), which `findIgnoredEmbeddedRepos` enforces.
1163
798
  for (const rel of findIgnoredEmbeddedRepos(repoDir, includeIgnored, prefix)) {
1164
799
  embeddedRoots?.add((0, utils_1.normalizePath)(prefix + rel));
1165
800
  collectGitFiles(path.join(repoDir, rel), prefix + rel, files, embeddedRoots, includeIgnored);
1166
801
  }
1167
802
  }
1168
- /**
1169
- * Get all files visible to git (tracked + untracked but not ignored).
1170
- * Respects .gitignore at all levels (root, subdirectories) and descends into
1171
- * embedded (nested, non-submodule) git repos. Returns null on failure
1172
- * (non-git project) so callers can fall back to a filesystem walk.
1173
- */
1174
- function getGitVisibleFiles(rootDir) {
803
+ function isIgnoredByEnclosingRepo(rootDir) {
804
+ try {
805
+ (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 });
806
+ return true;
807
+ }
808
+ catch {
809
+ return false;
810
+ }
811
+ }
812
+ const gitRepoPrefixes = new Map();
813
+ function gitRepoPrefix(dir) {
814
+ if (fs.existsSync(path.join(dir, '.git')))
815
+ return '';
816
+ const key = path.resolve(dir);
817
+ let prefix = gitRepoPrefixes.get(key);
818
+ if (prefix === undefined) {
819
+ prefix = (0, utils_1.normalizePath)((0, child_process_1.execFileSync)('git', ['rev-parse', '--show-prefix'], { cwd: dir, encoding: 'utf-8', timeout: 5000, stdio: ['pipe', 'pipe', 'pipe'], windowsHide: true }).trim());
820
+ gitRepoPrefixes.set(key, prefix);
821
+ }
822
+ return prefix;
823
+ }
824
+ function getGitVisibleFiles(rootDir, onManifestEvidence) {
1175
825
  try {
1176
- // Check if the project directory is gitignored by a parent repo.
1177
- // When rootDir lives inside a parent git repo that ignores it,
1178
- // `git ls-files` returns nothing — fall back to filesystem walk.
1179
826
  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();
1180
- if (path.resolve(gitRoot) !== path.resolve(rootDir)) {
1181
- try {
1182
- // git check-ignore exits 0 if the path IS ignored, 1 if not
1183
- (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 });
1184
- // Directory is gitignored by parent repo — fall back to filesystem walk
1185
- (0, errors_1.logDebug)('project root is gitignored by a parent repo — falling back to filesystem walk', {
1186
- rootDir,
1187
- gitRoot,
1188
- });
1189
- return null;
1190
- }
1191
- catch {
1192
- // Not ignored — safe to use git ls-files
1193
- }
827
+ if (path.resolve(gitRoot) !== path.resolve(rootDir) && isIgnoredByEnclosingRepo(rootDir)) {
828
+ (0, errors_1.logDebug)('project root is gitignored by a parent repo — falling back to filesystem walk', {
829
+ rootDir,
830
+ gitRoot,
831
+ });
832
+ return null;
1194
833
  }
1195
834
  const files = new Set();
1196
835
  const embeddedRoots = new Set();
1197
- collectGitFiles(rootDir, '', files, embeddedRoots, loadIncludeIgnoredMatcher(rootDir));
1198
- // Apply built-in default ignores uniformly — to tracked files too, since
1199
- // committing a dependency/build dir doesn't make it project code. A
1200
- // `.gitignore` negation (e.g. `!vendor/`) is the explicit opt-in. (issue #407)
1201
- // Files inside an EMBEDDED repo are matched against that repo's own rules,
1202
- // not the parent's: the parent's .gitignore hides the child repo from git,
1203
- // not from the index. (#514)
1204
- const ig = buildScopeIgnore(rootDir, embeddedRoots);
836
+ const gitlinks = [];
837
+ collectGitFiles(rootDir, '', files, embeddedRoots, loadIncludeIgnoredMatcher(rootDir), gitlinks);
838
+ const ignoredEntries = onManifestEvidence ? [] : undefined;
839
+ const ig = buildScopeIgnore(rootDir, embeddedRoots, ignoredEntries);
840
+ if (onManifestEvidence) {
841
+ onManifestEvidence((0, workspace_packages_1.manifestEvidence)(rootDir, files, ignoredEntries, embeddedRoots.size === 0 && gitlinks.length === 0 && !fs.existsSync(path.join(gitRoot, '.gitmodules'))));
842
+ }
1205
843
  const visible = new Set([...files].filter((f) => !ig.ignores(f)));
1206
- // Force-include first-party source the project whitelisted in
1207
- // `codegraph.json` `include`. These are gitignored, so `git ls-files` never
1208
- // listed them above — discover them directly off disk and add them. (The
1209
- // common SVN+Git dual-VCS case: source committed to SVN, gitignored out of
1210
- // Git, but still wanted in the graph.)
1211
844
  for (const f of collectIncludedFilesForRoot(rootDir))
1212
845
  visible.add(f);
1213
846
  return visible;
1214
847
  }
1215
848
  catch (error) {
1216
- // Any failure here (git missing, a `git rev-parse`/`ls-files` timeout or
1217
- // buffer overrun under load, an unreadable repo, unsupported flag combo on
1218
- // older git, etc.) silently sent every caller to `scanDirectoryWalk` with
1219
- // zero signal that the fast git-delegated path was skipped — making reports
1220
- // like #1567 (nested-`.gitignore`-excluded `node_modules` walked into)
1221
- // hard to triage, since both ignore implementations look correct in
1222
- // isolation but there was no way to tell which one ran. Log it under the
1223
- // existing CODEGRAPH_DEBUG gate so a future report can confirm or rule out
1224
- // the fallback in one step.
1225
849
  (0, errors_1.logDebug)('git-based file listing unavailable — falling back to filesystem walk', {
1226
850
  rootDir,
1227
851
  error: error instanceof Error ? error.message : String(error),
@@ -1229,49 +853,23 @@ function getGitVisibleFiles(rootDir) {
1229
853
  return null;
1230
854
  }
1231
855
  }
1232
- /**
1233
- * Use `git status` to detect changed files instead of scanning every file.
1234
- * Returns null on failure so callers fall back to full scan.
1235
- *
1236
- * Recurses into embedded repos — the untracked kind (#193: the parent's status
1237
- * collapses them to an opaque `?? subdir/` entry) always, and the gitignored
1238
- * kind (#514: they never appear in the parent's status at all) only for
1239
- * directories opted in via `codegraph.json` `includeIgnored` (#622, #699) —
1240
- * running `git status` inside each, so changes in a multi-repo workspace sync
1241
- * without a full rescan. By default a gitignored dir is left alone, matching the
1242
- * full-index scan (#970, #976). Deleting an ENTIRE embedded repo dir is the one
1243
- * case this cannot see (the child status that would report the deletions is gone
1244
- * with it); a full `codegraph index` reconciles that.
1245
- */
1246
856
  function getGitChangedFiles(rootDir, sinceCommit) {
1247
857
  try {
1248
- // `git status` only ever describes the WORKING TREE, so a change that has
1249
- // been committed leaves no entry and never enters the candidate set — the
1250
- // hash comparison in getChangedFiles is correct but is never reached for
1251
- // it, and `pendingChanges` reads 0 while the index is genuinely behind
1252
- // (#1829). `sinceCommit` — the commit the index was last brought up to
1253
- // date at — adds the other half: what has been committed since. Callers
1254
- // that hold no such stamp still get exactly what they always did, the
1255
- // working-tree changes.
1256
858
  const changes = { modified: [], added: [], deleted: [] };
1257
- // Custom extension → language overrides from the project's codegraph.json,
1258
- // so change detection sees the same custom-extension files the full index does.
1259
859
  const overrides = (0, project_config_1.loadExtensionOverrides)(rootDir);
1260
- collectGitStatus(rootDir, '', changes, overrides, loadIncludeIgnoredMatcher(rootDir), loadExcludeMatcher(rootDir), sinceCommit ?? undefined);
860
+ const isSource = (filePath) => (0, grammars_1.isSourceFile)(filePath, overrides, rootDir);
861
+ const repoPrefix = gitRepoPrefix(rootDir);
862
+ if (repoPrefix && isIgnoredByEnclosingRepo(rootDir))
863
+ return null;
864
+ collectGitStatus(rootDir, '', changes, isSource, loadIncludeIgnoredMatcher(rootDir), loadExcludeMatcher(rootDir), sinceCommit ?? undefined, repoPrefix);
1261
865
  return changes;
1262
866
  }
1263
867
  catch {
1264
868
  return null;
1265
869
  }
1266
870
  }
1267
- /**
1268
- * Metadata key: the commit the index was last brought up to date at. Written by
1269
- * a full index AND by every successful sync — unlike the extraction stamp, which
1270
- * a sync must not advance because it only touches a subset of files. This one is
1271
- * about the tree; failed file paths remain explicit retry candidates. (#1829)
1272
- */
1273
871
  exports.INDEXED_AT_COMMIT_KEY = 'indexed_at_commit';
1274
- /** HEAD's commit sha, or null in a non-git repo or one with no commits yet. */
872
+ const INDEXED_SPARSE_CHECKOUT_KEY = 'indexed_sparse_checkout';
1275
873
  function getGitHeadSha(rootDir) {
1276
874
  try {
1277
875
  return (0, child_process_1.execFileSync)('git', ['rev-parse', 'HEAD'], {
@@ -1282,40 +880,16 @@ function getGitHeadSha(rootDir) {
1282
880
  return null;
1283
881
  }
1284
882
  }
1285
- /**
1286
- * NUL-delimited status/path pairs for every path committed
1287
- * between `sinceCommit` and HEAD. Empty when the stamp IS HEAD, which is the
1288
- * common case — one cheap git call on the hot path.
1289
- */
1290
883
  function gitCommittedChangesSince(repoDir, sinceCommit) {
1291
- // NUL framing preserves Unicode, quotes, tabs and newlines in Git paths.
1292
- // Let command failures reach getGitChangedFiles: [] would falsely mean clean.
1293
884
  const out = (0, child_process_1.execFileSync)('git', ['diff', '--relative', '--name-status', '--no-renames', '-z', sinceCommit, 'HEAD', '--', '.'], {
1294
885
  cwd: repoDir, encoding: 'utf-8', timeout: 10000, maxBuffer: 50 * 1024 * 1024, stdio: ['pipe', 'pipe', 'pipe'], windowsHide: true,
1295
886
  });
1296
887
  return out.split('\0');
1297
888
  }
1298
- /**
1299
- * Can an INDEX trust the git fast path, given the commit it was built at?
1300
- *
1301
- * False means "fall back to the full scan" — the expensive path that compares
1302
- * every file on disk against the DB, and the only correct read when git cannot
1303
- * say what happened between the stamp and now:
1304
- *
1305
- * - stamp present but unknown to this repo (rebase, gc, shallow clone, a stamp
1306
- * from a different checkout) — history moved under the index.
1307
- * - stamp absent while the repo HAS commits — an index built before stamping
1308
- * existed. One full scan; the next sync stamps it and the fast path returns.
1309
- *
1310
- * A repo with NO commits keeps the fast path with or without a stamp: every
1311
- * file is untracked, so `git status` already sees all of them. Callers with no
1312
- * index behind them (the exported `getGitChangedFiles`) never ask this — a
1313
- * working-tree diff is the whole of what they wanted. (#1829)
1314
- */
1315
889
  function canTrustGitFastPath(rootDir, sinceCommit) {
1316
890
  const head = getGitHeadSha(rootDir);
1317
891
  if (head == null)
1318
- return true; // no commits (or not a git repo — caller handles that)
892
+ return true;
1319
893
  if (!sinceCommit)
1320
894
  return false;
1321
895
  if (sinceCommit === head)
@@ -1330,114 +904,70 @@ function canTrustGitFastPath(rootDir, sinceCommit) {
1330
904
  return false;
1331
905
  }
1332
906
  }
1333
- function collectGitStatus(repoDir, prefix, out, overrides, includeIgnored = null, exclude = null, sinceCommit) {
1334
- const output = (0, child_process_1.execFileSync)('git',
1335
- // `-uall` lists individual untracked files instead of collapsing an
1336
- // entirely-untracked directory into one `?? dir/` entry, which would
1337
- // otherwise be dropped here (only embedded git repos are recursed into
1338
- // below). Nested untracked git repos still collapse to `?? repo/` even
1339
- // with `-uall` — git never crosses a repo boundary — so the recursion
1340
- // still handles them. (#1213)
1341
- ['status', '--porcelain', '--no-renames', '-z', '-uall'], { cwd: repoDir, encoding: 'utf-8', timeout: 10000, maxBuffer: 50 * 1024 * 1024, stdio: ['pipe', 'pipe', 'pipe'], windowsHide: true });
1342
- // This repo's own ignore rules — built-in defaults (#407) plus its .gitignore.
1343
- // Change detection must exclude the SAME files the full index does, but git
1344
- // status hides neither: it ignores nothing for *tracked* paths, and the
1345
- // built-in defaults aren't gitignore at all. Without this filter a committed
1346
- // vendor/ dir, or a tracked file under a .gitignored dir, surfaces here as a
1347
- // change — so `codegraph status` (which reads getChangedFiles) reports a
1348
- // pending edit the full index never tracks and `sync` never clears. Matching
1349
- // repo-relative `rel` at each recursion level mirrors getGitVisibleFiles'
1350
- // ScopeIgnore: every embedded repo is judged by ITS OWN rules, never the
1351
- // parent's. (#766)
907
+ function collectGitStatus(repoDir, prefix, out, isSource, includeIgnored = null, exclude = null, sinceCommit, repoPrefix = '') {
908
+ const output = (0, child_process_1.execFileSync)('git', repoPrefix
909
+ ? ['status', '--porcelain', '--no-renames', '-z', '-uall', '--', '.']
910
+ : ['status', '--porcelain', '--no-renames', '-z', '-uall'], { cwd: repoDir, encoding: 'utf-8', timeout: 10000, maxBuffer: 50 * 1024 * 1024, stdio: ['pipe', 'pipe', 'pipe'], windowsHide: true });
1352
911
  const ig = buildDefaultIgnore(repoDir);
1353
- // One classifier for both candidate sources below, so a committed change is
1354
- // filtered by exactly the rules a working-tree change is (#766, #999, #1829).
1355
912
  const classify = (statusCode, rel) => {
1356
913
  const filePath = (0, utils_1.normalizePath)(prefix + rel);
1357
- if (!(0, grammars_1.isSourceFile)(filePath, overrides))
914
+ if (!isSource(filePath))
1358
915
  return;
1359
916
  if (statusCode.includes('D')) {
1360
- // Deletions stay unfiltered: getChangedFiles acts on one only when the
1361
- // path is already tracked in the DB, where removal is always correct — and
1362
- // that lets a newly-excluded dir's stale rows clean themselves up. (#766)
1363
917
  out.deleted.push(filePath);
1364
918
  return;
1365
919
  }
1366
- // Added (`??`) / modified files inside an excluded dir must not enter the
1367
- // index — match against the repo-relative path, same as the full scan. (#766)
1368
920
  if (ig.ignores(rel))
1369
921
  return;
1370
- // User `codegraph.json` `exclude` (#999) is project-root-relative, so it's
1371
- // matched against the full path — sync must not re-add a tracked file the
1372
- // full index now keeps out. Deletions above stay unfiltered so a file that
1373
- // WAS indexed before an exclude was added still cleans itself out.
1374
922
  if (exclude && exclude.ignores(filePath))
1375
923
  return;
1376
924
  if (statusCode === '??') {
1377
925
  out.added.push(filePath);
1378
926
  }
1379
927
  else {
1380
- // M, MM, AM, A (staged), etc. — treat as modified. getChangedFiles
1381
- // re-decides added-vs-modified from the DB, so a committed `A` that the
1382
- // index never saw still lands in `added`.
1383
928
  out.modified.push(filePath);
1384
929
  }
1385
930
  };
1386
931
  const untrackedDirs = [];
1387
932
  for (const line of output.split('\0')) {
1388
933
  if (line.length < 4)
1389
- continue; // Minimum: "XY file"
934
+ continue;
1390
935
  const statusCode = line.substring(0, 2);
1391
- const rel = (0, utils_1.normalizePath)(line.substring(3));
1392
- // Untracked directory entries (trailing slash) may hide an embedded repo —
1393
- // collect for the recursion below instead of treating as a file.
936
+ let rel = (0, utils_1.normalizePath)(line.substring(3));
937
+ if (repoPrefix) {
938
+ if (!rel.startsWith(repoPrefix) || rel.length === repoPrefix.length)
939
+ continue;
940
+ rel = rel.slice(repoPrefix.length);
941
+ }
1394
942
  if (statusCode === '??' && rel.endsWith('/')) {
1395
943
  untrackedDirs.push(rel);
1396
944
  continue;
1397
945
  }
1398
946
  classify(statusCode, rel);
1399
947
  }
1400
- // Committed but unindexed: everything between the commit this index was last
1401
- // brought up to date at and HEAD. `git status` cannot see these — committing
1402
- // is precisely what removes a file from its output — so without this pass a
1403
- // `git commit` makes a real pending change read as zero (#1829). The stamp
1404
- // belongs to the ROOT repo, so the embedded-repo recursion below passes none.
1405
948
  if (sinceCommit) {
1406
949
  const fields = gitCommittedChangesSince(repoDir, sinceCommit);
1407
950
  for (let i = 0; i + 1 < fields.length; i += 2) {
1408
951
  classify(`${fields[i].charAt(0)} `, (0, utils_1.normalizePath)(fields[i + 1]));
1409
952
  }
1410
953
  }
1411
- // Recurse embedded repos found under untracked dirs (at the dir itself or
1412
- // nested deeper). Gitignored dirs are walked only for the directories the
1413
- // project opted in via `includeIgnored`; by default `.gitignore` is respected
1414
- // and they are left alone (#970, #976), mirroring the full-index scan.
1415
954
  for (const rel of untrackedDirs) {
1416
955
  for (const repoRel of findNestedGitRepos(path.join(repoDir, rel), rel)) {
1417
- collectGitStatus(path.join(repoDir, repoRel), prefix + repoRel, out, overrides, includeIgnored, exclude);
956
+ collectGitStatus(path.join(repoDir, repoRel), prefix + repoRel, out, isSource, includeIgnored, exclude);
1418
957
  }
1419
958
  }
1420
959
  for (const rel of findIgnoredEmbeddedRepos(repoDir, includeIgnored, prefix)) {
1421
- collectGitStatus(path.join(repoDir, rel), prefix + rel, out, overrides, includeIgnored, exclude);
960
+ collectGitStatus(path.join(repoDir, rel), prefix + rel, out, isSource, includeIgnored, exclude);
1422
961
  }
1423
962
  }
1424
- /**
1425
- * Recursively scan a directory for source files.
1426
- *
1427
- * In git repos, uses `git ls-files` (inherently respects .gitignore at all
1428
- * levels), then keeps files with a supported source extension. For non-git
1429
- * projects, falls back to a filesystem walk that parses .gitignore itself.
1430
- */
1431
963
  function scanDirectory(rootDir, onProgress) {
1432
- // Custom extension → language overrides from the project's codegraph.json.
1433
964
  const overrides = (0, project_config_1.loadExtensionOverrides)(rootDir);
1434
- // Fast path: use git to get all visible files (respects .gitignore everywhere)
1435
965
  const gitFiles = getGitVisibleFiles(rootDir);
1436
966
  if (gitFiles) {
1437
967
  const files = [];
1438
968
  let count = 0;
1439
969
  for (const filePath of gitFiles) {
1440
- if ((0, grammars_1.isSourceFile)(filePath, overrides)) {
970
+ if ((0, grammars_1.isSourceFile)(filePath, overrides, rootDir)) {
1441
971
  files.push(filePath);
1442
972
  count++;
1443
973
  onProgress?.(count, filePath);
@@ -1445,10 +975,8 @@ function scanDirectory(rootDir, onProgress) {
1445
975
  }
1446
976
  return files;
1447
977
  }
1448
- // Fallback: walk filesystem for non-git projects
1449
978
  return scanDirectoryWalk(rootDir, onProgress);
1450
979
  }
1451
- /** Record one file the scan declined to index. */
1452
980
  function tallySkip(stats, rel) {
1453
981
  if (!stats)
1454
982
  return;
@@ -1457,19 +985,17 @@ function tallySkip(stats, rel) {
1457
985
  return;
1458
986
  stats.unsupportedByExtension.set(ext, (stats.unsupportedByExtension.get(ext) ?? 0) + 1);
1459
987
  }
1460
- async function scanDirectoryAsync(rootDir, onProgress, stats) {
1461
- // Custom extension → language overrides from the project's codegraph.json.
988
+ async function scanDirectoryAsync(rootDir, onProgress, stats, onManifestEvidence) {
1462
989
  const overrides = (0, project_config_1.loadExtensionOverrides)(rootDir);
1463
- const gitFiles = getGitVisibleFiles(rootDir);
990
+ const gitFiles = getGitVisibleFiles(rootDir, onManifestEvidence);
1464
991
  if (gitFiles) {
1465
992
  const files = [];
1466
993
  let count = 0;
1467
994
  for (const filePath of gitFiles) {
1468
- if ((0, grammars_1.isSourceFile)(filePath, overrides)) {
995
+ if ((0, grammars_1.isSourceFile)(filePath, overrides, rootDir)) {
1469
996
  files.push(filePath);
1470
997
  count++;
1471
998
  onProgress?.(count, filePath);
1472
- // Yield every 100 files so worker threads can render progress
1473
999
  if (count % 100 === 0) {
1474
1000
  await new Promise(r => setImmediate(r));
1475
1001
  }
@@ -1482,32 +1008,25 @@ async function scanDirectoryAsync(rootDir, onProgress, stats) {
1482
1008
  }
1483
1009
  return scanDirectoryWalk(rootDir, onProgress, stats);
1484
1010
  }
1485
- /**
1486
- * Filesystem walk fallback for non-git projects.
1487
- */
1488
1011
  function scanDirectoryWalk(rootDir, onProgress, stats) {
1489
1012
  const files = [];
1490
1013
  let count = 0;
1491
1014
  const visitedDirs = new Set();
1492
- // Custom extension → language overrides from the project's codegraph.json.
1493
1015
  const overrides = (0, project_config_1.loadExtensionOverrides)(rootDir);
1494
1016
  const loadIgnore = (dir) => {
1495
1017
  const giPath = path.join(dir, '.gitignore');
1496
1018
  if (!fs.existsSync(giPath))
1497
1019
  return null;
1498
- // readGitignorePatterns is defensive: a non-UTF-8 (DLP-encrypted) or
1499
- // uncompilable .gitignore is skipped/filtered with a warning, never thrown
1500
- // (issue #682) — so the per-file `.ignores()` calls below can't crash.
1501
1020
  const patterns = readGitignorePatterns(giPath);
1502
1021
  return patterns ? { dir, ig: (0, ignore_1.default)().add(patterns) } : null;
1503
1022
  };
1504
1023
  const isIgnored = (fullPath, isDir, matchers) => {
1505
1024
  for (const { dir, ig } of matchers) {
1506
1025
  let rel = (0, utils_1.normalizePath)(path.relative(dir, fullPath));
1507
- if (!rel || rel.startsWith('..'))
1508
- continue; // not under this matcher's dir
1026
+ if (!rel || (0, utils_1.escapesRoot)(rel))
1027
+ continue;
1509
1028
  if (isDir)
1510
- rel += '/'; // dir-only rules (e.g. `build/`) only match with the slash
1029
+ rel += '/';
1511
1030
  if (ig.ignores(rel))
1512
1031
  return true;
1513
1032
  }
@@ -1527,9 +1046,6 @@ function scanDirectoryWalk(rootDir, onProgress, stats) {
1527
1046
  return;
1528
1047
  }
1529
1048
  visitedDirs.add(realDir);
1530
- // This directory's own .gitignore (if present) applies to everything below it.
1531
- // The root's .gitignore is already merged into the seeded base matcher (so a
1532
- // negation there can override a built-in default), so skip it here.
1533
1049
  const own = dir === rootDir ? null : loadIgnore(dir);
1534
1050
  const active = own ? [...matchers, own] : matchers;
1535
1051
  let entries;
@@ -1541,8 +1057,6 @@ function scanDirectoryWalk(rootDir, onProgress, stats) {
1541
1057
  return;
1542
1058
  }
1543
1059
  for (const entry of entries) {
1544
- // Never descend into git internals or any CodeGraph data directory
1545
- // (the active one or a sibling another environment created — #636).
1546
1060
  if (entry.name === '.git' || (0, directory_1.isCodeGraphDataDir)(entry.name))
1547
1061
  continue;
1548
1062
  const fullPath = path.join(dir, entry.name);
@@ -1558,7 +1072,7 @@ function scanDirectoryWalk(rootDir, onProgress, stats) {
1558
1072
  }
1559
1073
  else if (stat.isFile()) {
1560
1074
  if (!isIgnored(fullPath, false, active)) {
1561
- if ((0, grammars_1.isSourceFile)(relativePath, overrides)) {
1075
+ if ((0, grammars_1.isSourceFile)(relativePath, overrides, rootDir)) {
1562
1076
  files.push(relativePath);
1563
1077
  count++;
1564
1078
  onProgress?.(count, relativePath);
@@ -1581,7 +1095,7 @@ function scanDirectoryWalk(rootDir, onProgress, stats) {
1581
1095
  }
1582
1096
  else if (entry.isFile()) {
1583
1097
  if (!isIgnored(fullPath, false, active)) {
1584
- if ((0, grammars_1.isSourceFile)(relativePath, overrides)) {
1098
+ if ((0, grammars_1.isSourceFile)(relativePath, overrides, rootDir)) {
1585
1099
  files.push(relativePath);
1586
1100
  count++;
1587
1101
  onProgress?.(count, relativePath);
@@ -1593,19 +1107,11 @@ function scanDirectoryWalk(rootDir, onProgress, stats) {
1593
1107
  }
1594
1108
  }
1595
1109
  }
1596
- // Seed a base matcher with the built-in default ignores (merged with the root
1597
- // .gitignore so a negation can override). Nested .gitignores still layer per-dir.
1598
1110
  const baseMatchers = [{ dir: rootDir, ig: buildDefaultIgnore(rootDir) }];
1599
- // Project `codegraph.json` `exclude` patterns (#999), rooted at the project so
1600
- // `isIgnored` matches them against root-relative paths — same coverage the
1601
- // git path gets via ScopeIgnore, for non-git projects.
1602
1111
  const exclude = loadExcludeMatcher(rootDir);
1603
1112
  if (exclude)
1604
1113
  baseMatchers.push({ dir: rootDir, ig: exclude });
1605
1114
  walk(rootDir, baseMatchers);
1606
- // Force-include first-party source whitelisted in `codegraph.json` `include`
1607
- // — the walk above honours `.gitignore`, so anything gitignored was dropped;
1608
- // add it back here (deduped). Mirrors the git path's union.
1609
1115
  const included = collectIncludedFilesForRoot(rootDir);
1610
1116
  if (included.size > 0) {
1611
1117
  const seen = new Set(files);
@@ -1618,77 +1124,65 @@ function scanDirectoryWalk(rootDir, onProgress, stats) {
1618
1124
  }
1619
1125
  return files;
1620
1126
  }
1621
- /**
1622
- * Resurrect a resolution edge that is about to be dropped (its target symbol
1623
- * was removed, renamed, or its whole file deleted) as the ORIGINAL unresolved
1624
- * reference that created it, read from the refName/refKind stamp
1625
- * `createEdges` writes into edge metadata. Inserted as status='pending', the
1626
- * ref is consumed by the same sync's resolution sweep: it rebinds to an
1627
- * alternative definition if one exists, or parks as status='failed' where the
1628
- * #1240 retry finds it if the symbol later reappears.
1629
- *
1630
- * Returns null — drop silently, the pre-#1240 behavior — for edges without a
1631
- * refName stamp (created before the stamp existed, or synthesized): rebuilding
1632
- * a ref from the target's plain node name would strip the receiver/qualifier
1633
- * context the original text carried (`h.greet` → `greet`) and could rebind
1634
- * somewhere a full re-index never would. Silent beats wrong.
1635
- */
1636
- function resurrectRefFromDroppedEdge(e) {
1637
- const refName = e.metadata?.refName;
1638
- if (typeof refName !== 'string' || refName.length === 0)
1639
- return null;
1640
- const refKind = typeof e.metadata?.refKind === 'string' ? e.metadata.refKind : e.kind;
1641
- return {
1642
- fromNodeId: e.source,
1643
- referenceName: refName,
1644
- referenceKind: refKind,
1645
- line: e.line ?? 0,
1646
- column: e.column ?? 0,
1647
- filePath: e.sourceFilePath,
1648
- language: e.sourceLanguage,
1127
+ const REINDEX_IDENTITY_TIERS = [
1128
+ (n) => `${n.kind}\0${n.name}`,
1129
+ (n) => n.qualifiedName,
1130
+ (n) => n.signature ?? '',
1131
+ ];
1132
+ function groupNodeIdentities(nodes, key) {
1133
+ const groups = new Map();
1134
+ for (const n of nodes) {
1135
+ const k = key(n);
1136
+ const group = groups.get(k);
1137
+ if (group)
1138
+ group.push(n);
1139
+ else
1140
+ groups.set(k, [n]);
1141
+ }
1142
+ return groups;
1143
+ }
1144
+ function pairReindexedNodes(prior, next) {
1145
+ const pairs = new Map();
1146
+ const byPosition = (a, b) => a.startLine - b.startLine || a.startColumn - b.startColumn;
1147
+ const pairGroups = (before, after, tier) => {
1148
+ const key = REINDEX_IDENTITY_TIERS[tier];
1149
+ const afterGroups = groupNodeIdentities(after, key);
1150
+ for (const [k, group] of groupNodeIdentities(before, key)) {
1151
+ const match = afterGroups.get(k);
1152
+ if (!match)
1153
+ continue;
1154
+ if (group.length === 1 && match.length === 1) {
1155
+ pairs.set(group[0].id, match[0].id);
1156
+ }
1157
+ else if (tier + 1 < REINDEX_IDENTITY_TIERS.length) {
1158
+ pairGroups(group, match, tier + 1);
1159
+ }
1160
+ else if (group.length === match.length) {
1161
+ const a = [...group].sort(byPosition);
1162
+ const b = [...match].sort(byPosition);
1163
+ for (let i = 0; i < a.length; i++)
1164
+ pairs.set(a[i].id, b[i].id);
1165
+ }
1166
+ }
1649
1167
  };
1168
+ pairGroups(prior, next, 0);
1169
+ return pairs;
1650
1170
  }
1651
- /**
1652
- * Extraction orchestrator
1653
- */
1654
1171
  class ExtractionOrchestrator {
1655
1172
  rootDir;
1656
1173
  queries;
1657
- /**
1658
- * Names of frameworks detected for this project, populated by indexAll().
1659
- * Passed to extractFromSource so framework-specific extractors (route nodes,
1660
- * middleware, etc.) run after the tree-sitter pass. Cleared if detection
1661
- * hasn't run yet so single-file re-index paths can detect on the spot.
1662
- */
1663
1174
  detectedFrameworkNames = null;
1664
- /**
1665
- * Scope matcher for SCOPED syncs, memoized on the mtimes of the two root
1666
- * files it is derived from (`codegraph.json`, `.gitignore`). See
1667
- * {@link scopedSyncMatcher}.
1668
- */
1175
+ detectionInputs = null;
1176
+ detectionFileListChanged = false;
1177
+ manifestEvidence = null;
1178
+ detectionReads = new Map();
1179
+ keepDetectionContents = false;
1669
1180
  scopedMatcher = null;
1670
1181
  constructor(rootDir, queries) {
1671
1182
  this.rootDir = rootDir;
1672
1183
  this.queries = queries;
1673
1184
  }
1674
- /**
1675
- * The scope matcher a scoped sync applies to the paths it was handed — the
1676
- * same `buildScopeIgnore` the full scan uses, so an explicitly-passed path
1677
- * that is OUT of scope (a user `exclude` in `codegraph.json`, a `.gitignore`
1678
- * rule, a built-in default) is treated exactly as the full walk would treat
1679
- * it: absent, hence removed if tracked, never parsed (#1590).
1680
- *
1681
- * Memoized on the root config + root `.gitignore` mtimes: building the
1682
- * matcher runs embedded-repo discovery (`git ls-files`), which would defeat
1683
- * the scoped path's whole point (skipping O(repo) work) if paid per sync.
1684
- * Two `stat`s per sync while nothing changed. An embedded repo created
1685
- * between config edits joins the scoped matcher on the next full sync, the
1686
- * same lifecycle the watcher's own matcher already has.
1687
- */
1688
1185
  scopedSyncMatcher() {
1689
- // Bust when any root-level exclude source the matcher reads may have
1690
- // changed. Nested `.gitignore` edits force a full watcher sync, which
1691
- // clears this cache (see the full-reconcile branch in sync()).
1692
1186
  const gitDir = resolveGitDir(this.rootDir);
1693
1187
  const key = [
1694
1188
  project_config_1.PROJECT_CONFIG_FILENAME,
@@ -1712,14 +1206,28 @@ class ExtractionOrchestrator {
1712
1206
  this.scopedMatcher = { key, matcher };
1713
1207
  return matcher;
1714
1208
  }
1715
- /**
1716
- * Build a filesystem-backed ResolutionContext sufficient for framework
1717
- * detection. Graph-query methods (getNodesByName etc.) return empty because
1718
- * the DB hasn't been populated yet, but detect() only uses readFile,
1719
- * fileExists, and getAllFiles, so that's fine.
1720
- */
1721
- buildDetectionContext(files) {
1209
+ buildDetectionContext(files, inputs) {
1722
1210
  const rootDir = this.rootDir;
1211
+ const listed = inputs ? new Set(files) : null;
1212
+ const reads = inputs ? this.detectionReads : null;
1213
+ const probe = (relativePath) => {
1214
+ const rel = (0, utils_1.normalizePath)(relativePath);
1215
+ let known = reads?.get(rel);
1216
+ if (!known) {
1217
+ const full = (0, utils_1.validatePathWithinRoot)(rootDir, relativePath, { readOnly: true });
1218
+ if (!full)
1219
+ return null;
1220
+ known = { full, signature: diskSignature(full) };
1221
+ reads?.set(rel, known);
1222
+ }
1223
+ if (inputs) {
1224
+ if (listed.has(rel))
1225
+ inputs.sourceFiles.add(rel);
1226
+ else if (!inputs.diskPaths.has(rel))
1227
+ inputs.diskPaths.set(rel, known.signature);
1228
+ }
1229
+ return known;
1230
+ };
1723
1231
  return {
1724
1232
  getNodesInFile: () => [],
1725
1233
  getNodesByName: () => [],
@@ -1730,37 +1238,32 @@ class ExtractionOrchestrator {
1730
1238
  getAllFiles: () => files,
1731
1239
  getProjectRoot: () => rootDir,
1732
1240
  fileExists: (relativePath) => {
1733
- const full = (0, utils_1.validatePathWithinRoot)(rootDir, relativePath);
1734
- if (!full)
1735
- return false;
1736
- try {
1737
- return fs.existsSync(full);
1738
- }
1739
- catch {
1740
- return false;
1741
- }
1241
+ const known = probe(relativePath);
1242
+ return known !== null && known.signature !== '-';
1742
1243
  },
1743
1244
  readFile: (relativePath) => {
1744
- const full = (0, utils_1.validatePathWithinRoot)(rootDir, relativePath);
1745
- if (!full)
1746
- return null;
1747
- try {
1748
- // Framework detectors scan source by name; a file over the size
1749
- // limit was never indexed and must not be decoded here either (#1910).
1750
- return (0, file_limits_1.readBoundedSourceSync)(full).bytes?.toString('utf8') ?? null;
1751
- }
1752
- catch {
1245
+ const known = probe(relativePath);
1246
+ if (!known)
1753
1247
  return null;
1248
+ if (known.content === undefined) {
1249
+ try {
1250
+ known.content = (0, file_limits_1.readBoundedSourceSync)(known.full).bytes?.toString('utf8') ?? null;
1251
+ }
1252
+ catch {
1253
+ known.content = null;
1254
+ }
1754
1255
  }
1256
+ return known.content;
1755
1257
  },
1756
- // Monorepo support — needed by framework detect()s that probe
1757
- // subpackage manifests (e.g. fabric-view looking at
1758
- // packages/<sub>/package.json when the root manifest is just a
1759
- // workspace declaration). Matches the resolver-context shape.
1760
1258
  listDirectories: (relativePath) => {
1761
1259
  const target = relativePath === '.' || relativePath === ''
1762
1260
  ? rootDir
1763
1261
  : path.join(rootDir, relativePath);
1262
+ if (inputs) {
1263
+ const key = (0, utils_1.normalizePath)(path.relative(rootDir, target)) + '/';
1264
+ if (!inputs.diskPaths.has(key))
1265
+ inputs.diskPaths.set(key, diskSignature(target, true));
1266
+ }
1764
1267
  try {
1765
1268
  return fs
1766
1269
  .readdirSync(target, { withFileTypes: true })
@@ -1773,34 +1276,117 @@ class ExtractionOrchestrator {
1773
1276
  },
1774
1277
  };
1775
1278
  }
1776
- /**
1777
- * Detect frameworks on demand using the current scanned files (or a fresh
1778
- * scan if none are provided). Cached on the orchestrator so repeat calls
1779
- * inside a single run don't re-scan.
1780
- */
1781
1279
  ensureDetectedFrameworks(files) {
1782
1280
  if (this.detectedFrameworkNames !== null)
1783
1281
  return this.detectedFrameworkNames;
1784
1282
  const fileList = files ?? scanDirectory(this.rootDir);
1785
- const context = this.buildDetectionContext(fileList);
1283
+ const inputs = { sourceFiles: new Set(), diskPaths: new Map() };
1284
+ const context = this.buildDetectionContext(fileList, inputs);
1285
+ this.detectionInputs = inputs;
1286
+ this.detectionFileListChanged = false;
1786
1287
  this.detectedFrameworkNames = (0, frameworks_1.detectFrameworks)(context).map((r) => r.name);
1288
+ const declared = (0, package_deps_1.declaredDependencies)(context);
1289
+ for (const [rel, known] of this.detectionReads) {
1290
+ if (!inputs.sourceFiles.has(rel) && !inputs.diskPaths.has(rel))
1291
+ this.detectionReads.delete(rel);
1292
+ else if (!this.keepDetectionContents)
1293
+ known.content = undefined;
1294
+ }
1295
+ this.gatedFrameworks = new Map();
1296
+ for (const name of this.detectedFrameworkNames) {
1297
+ const deps = (0, frameworks_1.getFrameworkResolver)(name)?.appDependencies;
1298
+ if (deps && deps.some((d) => declared.has(d)))
1299
+ this.gatedFrameworks.set(name, deps);
1300
+ }
1301
+ this.appFrameworkMemo.clear();
1302
+ this.manifestDependencies.clear();
1787
1303
  return this.detectedFrameworkNames;
1788
1304
  }
1789
- /**
1790
- * Index all files in the project
1791
- */
1792
- async indexAll(onProgress, signal, verbose,
1793
- // Writer-side backstop for deferred WAL checkpointing (#1231): returns
1794
- // null in the normal case, or a promise to await (at this safe,
1795
- // between-transactions boundary) when the WAL has outrun the off-thread
1796
- // checkpointer past its hard cap. See db/wal-valve.ts.
1797
- walBackpressure,
1798
- // Fresh-DB store offload (perf): when set, per-file store bundles are
1799
- // applied by a dedicated writer thread instead of the main thread. Only
1800
- // passed for a COMPLETELY fresh database, where the main thread performs
1801
- // no reads/writes during the parse loop, so one writer applying bundles
1802
- // in file order preserves the #1015 determinism exactly.
1803
- storeWriterOpts) {
1305
+ gatedFrameworks = new Map();
1306
+ appFrameworkMemo = new Map();
1307
+ manifestDependencies = new Map();
1308
+ frameworksForFile(filePath, names) {
1309
+ if (this.gatedFrameworks.size === 0)
1310
+ return names;
1311
+ const slash = filePath.lastIndexOf('/');
1312
+ const dir = slash < 0 ? '' : filePath.slice(0, slash);
1313
+ const kept = names.filter((name) => this.frameworkAppliesIn(dir, name));
1314
+ return kept.length === names.length ? names : kept;
1315
+ }
1316
+ frameworkAppliesIn(dir, name) {
1317
+ const deps = this.gatedFrameworks.get(name);
1318
+ if (!deps)
1319
+ return true;
1320
+ const key = `${dir}|${name}`;
1321
+ const memo = this.appFrameworkMemo.get(key);
1322
+ if (memo !== undefined)
1323
+ return memo;
1324
+ let applies = false;
1325
+ for (let d = dir; d !== null; d = d === '' ? null : d.includes('/') ? d.slice(0, d.lastIndexOf('/')) : '') {
1326
+ const declared = this.dependenciesDeclaredIn(d);
1327
+ if (!declared)
1328
+ continue;
1329
+ if (deps.some((dep) => declared.has(dep))) {
1330
+ applies = true;
1331
+ break;
1332
+ }
1333
+ if ([...this.gatedFrameworks].some(([other, otherDeps]) => other !== name && otherDeps.some((dep) => declared.has(dep))))
1334
+ break;
1335
+ }
1336
+ this.appFrameworkMemo.set(key, applies);
1337
+ return applies;
1338
+ }
1339
+ dependenciesDeclaredIn(dir) {
1340
+ if (this.manifestDependencies.has(dir))
1341
+ return this.manifestDependencies.get(dir);
1342
+ let declared = null;
1343
+ const manifest = path.join(this.rootDir, dir, 'package.json');
1344
+ const rel = dir ? `${dir}/package.json` : 'package.json';
1345
+ if (this.detectionInputs && !this.detectionInputs.diskPaths.has(rel))
1346
+ this.detectionInputs.diskPaths.set(rel, diskSignature(manifest));
1347
+ try {
1348
+ const pkg = JSON.parse(fs.readFileSync(manifest, 'utf8'));
1349
+ declared = new Set();
1350
+ for (const field of ['dependencies', 'devDependencies', 'peerDependencies']) {
1351
+ const group = pkg[field];
1352
+ if (group && typeof group === 'object')
1353
+ for (const name of Object.keys(group))
1354
+ declared.add(name);
1355
+ }
1356
+ }
1357
+ catch { }
1358
+ this.manifestDependencies.set(dir, declared);
1359
+ return declared;
1360
+ }
1361
+ setKeepDetectionContents(keep) {
1362
+ this.keepDetectionContents = keep;
1363
+ if (!keep)
1364
+ for (const known of this.detectionReads.values())
1365
+ known.content = undefined;
1366
+ }
1367
+ getDetectedFrameworkNames() {
1368
+ return this.detectedFrameworkNames;
1369
+ }
1370
+ refreshFrameworkDetection(scannedFiles, filesToIndex, addedFiles, removedFiles) {
1371
+ for (const file of filesToIndex)
1372
+ this.detectionReads.delete(file);
1373
+ for (const file of removedFiles)
1374
+ this.detectionReads.delete(file);
1375
+ const inputs = this.detectionInputs;
1376
+ let stale = this.detectedFrameworkNames === null || inputs === null || this.detectionFileListChanged ||
1377
+ filesToIndex.some((f) => inputs.sourceFiles.has(f));
1378
+ for (const [rel, signature] of inputs?.diskPaths ?? []) {
1379
+ if (diskSignature(path.join(this.rootDir, rel), rel.endsWith('/')) === signature)
1380
+ continue;
1381
+ stale = true;
1382
+ this.detectionReads.delete(rel);
1383
+ }
1384
+ if (!stale)
1385
+ return undefined;
1386
+ this.detectedFrameworkNames = null;
1387
+ return this.ensureDetectedFrameworks(scannedFiles ?? [...this.queries.getAllFilePaths(), ...addedFiles]);
1388
+ }
1389
+ async indexAll(onProgress, signal, verbose, walBackpressure, storeWriterOpts) {
1804
1390
  const tGrammar = Date.now();
1805
1391
  await (0, grammars_1.initGrammars)();
1806
1392
  if (process.env.CODEGRAPH_SYNTH_TIMINGS)
@@ -1812,24 +1398,18 @@ class ExtractionOrchestrator {
1812
1398
  let filesErrored = 0;
1813
1399
  let totalNodes = 0;
1814
1400
  let totalEdges = 0;
1815
- // Custom extension → language overrides from the project's codegraph.json.
1816
- // Threaded into language detection so custom-extension files load the right
1817
- // grammar and store under the mapped language.
1818
1401
  const overrides = (0, project_config_1.loadExtensionOverrides)(this.rootDir);
1819
1402
  const log = verbose
1820
1403
  ? (msg) => { console.log(`[worker] ${msg}`); }
1821
1404
  : (_msg) => { };
1822
- // Phase 1: Scan for files
1823
1405
  onProgress?.({
1824
1406
  phase: 'scanning',
1825
1407
  current: 0,
1826
1408
  total: 0,
1827
1409
  });
1828
- // Phase attribution to stderr (same opt-in as the synthesis timings):
1829
- // early-run 5-10s single stalls were observed on 95k-file repos but never
1830
- // attributed — these labels settle scan vs framework-detect vs grammars.
1831
1410
  const tScan = Date.now();
1832
1411
  const skipStats = { unsupportedByExtension: new Map() };
1412
+ this.manifestEvidence = null;
1833
1413
  const files = await scanDirectoryAsync(this.rootDir, (current, file) => {
1834
1414
  onProgress?.({
1835
1415
  phase: 'scanning',
@@ -1837,10 +1417,9 @@ class ExtractionOrchestrator {
1837
1417
  total: 0,
1838
1418
  currentFile: file,
1839
1419
  });
1840
- }, skipStats);
1420
+ }, skipStats, (evidence) => { this.manifestEvidence = evidence; });
1841
1421
  if (process.env.CODEGRAPH_SYNTH_TIMINGS)
1842
1422
  console.error(`[phase-timing] scan: ${Date.now() - tScan}ms (${files.length} files)`);
1843
- /** Only meaningful when nothing was indexable — see IndexResult (#1502). */
1844
1423
  const skipSummary = () => {
1845
1424
  let total = 0;
1846
1425
  for (const n of skipStats.unsupportedByExtension.values())
@@ -1853,16 +1432,9 @@ class ExtractionOrchestrator {
1853
1432
  .slice(0, 5);
1854
1433
  return { filesSkippedUnsupported: total, topUnsupportedExtensions: top };
1855
1434
  };
1856
- // A re-index over an existing DB skips unchanged-hash files at the store,
1857
- // which would preserve wiped zero-node rows (#1541) — drop them first so
1858
- // this run stores their files fresh. No-op on a fresh DB.
1859
1435
  this.healZeroNodeRows();
1860
- // Detect frameworks once per indexAll run using the scanned file list.
1861
- // Names are passed to each parse call so framework-specific extractors
1862
- // (route nodes, middleware, etc.) run after the tree-sitter pass.
1863
- // Framework detection is reset each run so adding e.g. requirements.txt
1864
- // between runs is picked up without restarting the process.
1865
1436
  this.detectedFrameworkNames = null;
1437
+ this.detectionReads.clear();
1866
1438
  const tFw = Date.now();
1867
1439
  const frameworkNames = this.ensureDetectedFrameworks(files);
1868
1440
  if (process.env.CODEGRAPH_SYNTH_TIMINGS)
@@ -1879,137 +1451,80 @@ class ExtractionOrchestrator {
1879
1451
  durationMs: Date.now() - startTime,
1880
1452
  };
1881
1453
  }
1882
- // Phase 2: Parse files in a worker thread (keeps main thread unblocked for UI)
1883
1454
  const total = files.length;
1884
1455
  let processed = 0;
1885
- // Emit parsing phase immediately so the progress bar appears during worker setup.
1886
- // The yield lets the shimmer worker flush the phase transition to stdout before
1887
- // the main thread starts synchronous grammar detection work.
1888
1456
  onProgress?.({
1889
1457
  phase: 'parsing',
1890
1458
  current: 0,
1891
1459
  total,
1892
1460
  });
1893
1461
  await new Promise(resolve => setImmediate(resolve));
1894
- // Detect needed languages and load grammars in the parse worker
1895
- const neededLanguages = preloadLanguagesForFiles(files, overrides);
1896
- // Parse files on a pool of worker threads (keeps the main thread free for UI
1897
- // and uses every core). Falls back to in-process parsing when the compiled
1898
- // worker is unavailable (e.g. running from source in tests).
1462
+ const neededLanguages = preloadLanguagesForFiles(files, overrides, this.rootDir);
1899
1463
  const parseWorkerPath = path.join(__dirname, 'parse-worker.js');
1900
1464
  const useWorker = fs.existsSync(parseWorkerPath);
1901
1465
  let pool = null;
1902
1466
  if (useWorker) {
1903
- // CODEGRAPH_PARSE_WORKERS: explicit worker count; 1 = the old single-worker
1904
- // behaviour (the conservative rollback). Unset → clamp(cores-1, 1, 8),
1905
- // with cores from availableParallelism — cpuset/affinity-honest, where
1906
- // os.cpus() enumerates the host's CPUs and spawned 8 wasm workers (and
1907
- // their grammar heaps) inside a 2-CPU container for zero extra
1908
- // throughput (§7a.1). Floored so a 2-core box still gets 2 workers:
1909
- // parse is worker-side CPU, and 1 worker measured 34% slower than the
1910
- // old oversubscribed pool on the kernel-scale 2-cpuset envelope
1911
- // (493s vs 369s) — main + store-worker don't fill the second core.
1912
1467
  const poolSize = (0, parse_pool_1.resolveParsePoolSize)(process.env.CODEGRAPH_PARSE_WORKERS, Math.max(3, os.availableParallelism()));
1913
- // Read each needed grammar's WASM ONCE here and hand the bytes to every
1914
- // worker, so spawns/respawns load grammars from memory instead of
1915
- // re-reading them from disk (#1231: on an HDD, respawn re-reads amplify
1916
- // the very I/O contention that caused the respawn).
1917
1468
  const grammarBuffers = await (0, grammars_1.readGrammarWasmBytes)(neededLanguages);
1918
1469
  pool = new parse_pool_1.ParseWorkerPool({
1919
1470
  languages: neededLanguages,
1920
1471
  size: poolSize,
1472
+ expectedParses: process.env.CODEGRAPH_PARSE_WORKERS ? undefined : files.length,
1921
1473
  workerScriptPath: parseWorkerPath,
1922
1474
  recycleInterval: WORKER_RECYCLE_INTERVAL,
1923
1475
  parseTimeoutMs: PARSE_TIMEOUT_MS,
1924
1476
  log,
1925
1477
  grammarBuffers,
1926
1478
  });
1927
- log(`Parse worker pool: ${poolSize} worker(s)`);
1928
- // Bulk index: every core will be needed — spawn the whole pool now so
1929
- // worker boot overlaps the first read batches instead of trickling in
1930
- // behind queue-pressure growth.
1479
+ log(`Parse worker pool: up to ${poolSize} worker(s)`);
1931
1480
  pool.prewarm();
1932
1481
  }
1933
1482
  else {
1934
- // In-process fallback: load grammars locally and parse on the main thread.
1935
1483
  await (0, grammars_1.loadGrammarsForLanguages)(neededLanguages);
1936
1484
  }
1937
- // Dedicated store writer thread (fresh DB only — see the parameter doc).
1938
- // Same availability rule as the parse pool: needs the compiled worker
1939
- // (absent when running from source in tests → main-thread fallback).
1940
1485
  const storeWorkerPath = path.join(__dirname, 'store-worker.js');
1941
1486
  let storeWriter = null;
1942
1487
  if (storeWriterOpts &&
1943
1488
  process.env.CODEGRAPH_NO_STORE_WORKER !== '1' &&
1944
1489
  fs.existsSync(storeWorkerPath)) {
1945
- // Deliberately NOT awaiting ready(): worker_threads delivers messages in
1946
- // order, so bundles posted while the worker is still booting queue
1947
- // behind 'open'. A boot failure surfaces at the first drain() — same
1948
- // propagation point as a store error.
1949
1490
  storeWriter = new store_writer_1.StoreWriter(storeWorkerPath, storeWriterOpts.dbPath, storeWriterOpts.fastInit);
1950
1491
  log('Store writer thread active');
1951
1492
  }
1952
- /** Queue-depth bound for un-acked bundles (bundles hold whole node/edge arrays). */
1953
1493
  const STORE_WRITER_WINDOW = 64;
1954
- /**
1955
- * Parse one file: on the pool when available (the promise REJECTS on a worker
1956
- * crash/timeout — the caller records it and the retry pass re-attempts), or
1957
- * in-process synchronously as the no-worker fallback. The language is resolved
1958
- * here on the main thread, where the codegraph.json overrides are loaded.
1959
- */
1960
1494
  const parseFile = (filePath, content) => {
1961
- const language = (0, grammars_1.detectLanguage)(filePath, content, overrides);
1495
+ const language = (0, grammars_1.detectLanguage)(filePath, content, overrides, this.rootDir);
1496
+ const names = this.frameworksForFile(filePath, frameworkNames);
1962
1497
  if (!pool)
1963
- return Promise.resolve((0, tree_sitter_1.extractFromSource)(filePath, content, language, frameworkNames));
1964
- return pool.requestParse({ filePath, content, language, frameworkNames });
1498
+ return Promise.resolve((0, tree_sitter_1.extractFromSource)(filePath, content, language, names));
1499
+ return pool.requestParse({ filePath, content, language, frameworkNames: names });
1965
1500
  };
1966
- // --- Bounded rolling-window dispatch, ordered commit ---
1967
- // Reads stay batched/parallel; parses run concurrently across the pool; the
1968
- // SQLite store stays on the main thread (it isn't thread-safe). Crucially we
1969
- // COMMIT results in original file order, not parse-completion order: the
1970
- // resolution phase (run after indexing) resolves an ambiguous reference to one
1971
- // of several same-named candidates by the nodes' DB insertion order, so a
1972
- // stable commit order keeps the resulting graph deterministic — byte-identical
1973
- // to the single-worker path — instead of drifting with parse timing. The
1974
- // `completed` buffer holds at most ~windowSize out-of-order results, so memory
1975
- // stays bounded.
1976
- const windowSize = pool ? Math.max(4, pool.size * 2) : 1;
1501
+ const windowSize = pool ? (0, parse_pool_1.parseWindowSize)(pool.size) : 1;
1977
1502
  const inFlight = new Set();
1978
1503
  const completed = new Map();
1979
- let nextSeq = 0; // file-order sequence assigned at dispatch
1980
- let nextToStore = 0; // cursor: next sequence to commit
1504
+ let nextSeq = 0;
1505
+ let nextToStore = 0;
1981
1506
  let aborted = false;
1982
- // Yielder for the in-order commit path: a single giant generated file's
1983
- // store is otherwise one unyielding multi-second transaction span on the
1984
- // main thread (5–14s single stalls measured on llvm-project), starving
1985
- // the #850 watchdog heartbeat on slow hardware.
1986
1507
  const commitYield = (0, cooperative_yield_1.createYielder)();
1987
1508
  const storeResult = async (filePath, content, stats, result) => {
1988
1509
  processed++;
1989
- // WAL hard-cap backstop: between files (never mid-transaction), pause
1990
- // the store until the off-thread checkpoint catches up. Resolves to
1991
- // null in the normal case — a single size check, no cost.
1992
1510
  const bp = walBackpressure?.();
1993
1511
  if (bp)
1994
1512
  await bp;
1995
- // Kernel deferred-decode results carry table sizes in kernelCounts
1996
- // (their object arrays are empty — decode happens at the store).
1997
1513
  const nodeCount = result.kernelCounts?.nodes ?? result.nodes.length;
1998
1514
  const edgeCount = result.kernelCounts?.edges ?? result.edges.length;
1999
- // Store: on the writer thread when active (fresh DB — bundles applied
2000
- // in the same file order this chain dispatches them), else on the main
2001
- // thread (SQLite connections are per-thread).
2002
- const language = (0, grammars_1.detectLanguage)(filePath, content, overrides);
2003
- if (storeWriter) {
1515
+ const grammarUnavailable = (0, grammars_1.hasGrammarLoadFailure)(result.errors);
1516
+ const language = (0, grammars_1.detectLanguage)(filePath, content, overrides, this.rootDir);
1517
+ if (grammarUnavailable) {
1518
+ }
1519
+ else if (storeWriter) {
2004
1520
  if (result.kernelBuffers) {
2005
- // Buffers go to the writer as-is; the worker decodes + finalizes.
2006
- // The main thread's only per-file work stays O(1) + the content hash.
2007
1521
  storeWriter.send({
2008
1522
  kernel: true,
2009
1523
  filePath,
2010
1524
  language,
2011
1525
  buffers: result.kernelBuffers,
2012
1526
  file: this.buildFileRecord(filePath, content, language, stats, nodeCount, result.errors),
1527
+ ...(result.unresolvedReferences.length > 0 ? { extraRefs: result.unresolvedReferences } : {}),
2013
1528
  });
2014
1529
  }
2015
1530
  else {
@@ -2028,7 +1543,10 @@ class ExtractionOrchestrator {
2028
1543
  }
2029
1544
  errors.push(...result.errors);
2030
1545
  }
2031
- if (nodeCount > 0) {
1546
+ if (grammarUnavailable) {
1547
+ filesErrored++;
1548
+ }
1549
+ else if (nodeCount > 0) {
2032
1550
  filesIndexed++;
2033
1551
  totalNodes += nodeCount;
2034
1552
  totalEdges += edgeCount;
@@ -2037,10 +1555,7 @@ class ExtractionOrchestrator {
2037
1555
  filesErrored++;
2038
1556
  }
2039
1557
  else {
2040
- // Files with no symbols but no errors (yaml, twig, properties) are
2041
- // tracked at the file level — count them as indexed so the CLI doesn't
2042
- // misleadingly report "No files found to index".
2043
- const lang = (0, grammars_1.detectLanguage)(filePath, content, overrides);
1558
+ const lang = (0, grammars_1.detectLanguage)(filePath, content, overrides, this.rootDir);
2044
1559
  if ((0, grammars_1.isFileLevelOnlyLanguage)(lang)) {
2045
1560
  filesIndexed++;
2046
1561
  }
@@ -2064,15 +1579,6 @@ class ExtractionOrchestrator {
2064
1579
  durationMs: 0,
2065
1580
  });
2066
1581
  };
2067
- // Commit buffered parses to the DB in file order, advancing the cursor over
2068
- // contiguous completed results. Runs after each parse settles (and once more
2069
- // after the drain). storeResult is now async (it yields between chunked
2070
- // inserts), so commits are SERIALIZED on a promise chain — concurrent parse
2071
- // completions append to the chain instead of interleaving mid-store, which
2072
- // preserves both the file-order commit invariant (#1015: resolution
2073
- // disambiguates same-named candidates by insertion order) and the
2074
- // single-writer discipline for SQLite. Errors are recorded and re-thrown
2075
- // at the drain, matching the old synchronous propagation.
2076
1582
  let flushChain = Promise.resolve();
2077
1583
  let flushError = null;
2078
1584
  const flushOrdered = () => {
@@ -2096,9 +1602,6 @@ class ExtractionOrchestrator {
2096
1602
  });
2097
1603
  return flushChain;
2098
1604
  };
2099
- // Dispatch one file's parse (parses run concurrently across the pool), tagged
2100
- // with its file-order sequence so flushOrdered commits results in order. The
2101
- // backpressure below bounds how far parsing runs ahead of the in-order commit.
2102
1605
  const feed = async (filePath, content, stats) => {
2103
1606
  const seq = nextSeq++;
2104
1607
  const p = (async () => {
@@ -2113,17 +1616,6 @@ class ExtractionOrchestrator {
2113
1616
  })();
2114
1617
  const tracked = p.finally(() => { inFlight.delete(tracked); });
2115
1618
  inFlight.add(tracked);
2116
- // Backpressure on the dispatched-but-not-yet-committed count (in-flight +
2117
- // buffered), not just in-flight: a slow file sitting at the commit cursor
2118
- // lets later parses finish and buffer, which would otherwise grow without
2119
- // bound. Wait for parses to settle (each may advance the cursor) until the
2120
- // window has room. When nothing is in flight but the window is still full,
2121
- // the async commit chain is what's behind — await it so the cursor
2122
- // advances (buffered items hold whole file contents, so this bound is
2123
- // load-bearing for memory). Once a store has failed the cursor never
2124
- // moves again — flushOrdered returns at once — so stop waiting and let
2125
- // the drain below rethrow; waiting would spin on microtasks forever,
2126
- // pinning a core and starving every timer in the process.
2127
1619
  while (nextSeq - nextToStore >= windowSize && !flushError && !aborted) {
2128
1620
  if (inFlight.size > 0)
2129
1621
  await Promise.race(inFlight);
@@ -2138,27 +1630,17 @@ class ExtractionOrchestrator {
2138
1630
  break;
2139
1631
  }
2140
1632
  const batch = files.slice(i, i + FILE_IO_BATCH_SIZE);
2141
- // Read files in parallel (with path validation before any I/O)
2142
1633
  const fileContents = await Promise.all(batch.map(async (fp) => {
2143
1634
  try {
2144
- // Indexing read: follow in-root symlinks the directory walk already
2145
- // descended into (the `../` guard still applies) so files reached
2146
- // via an in-root symlink-to-outside still index (#935).
2147
1635
  const fullPath = (0, utils_1.validatePathWithinRoot)(this.rootDir, fp, { allowSymlinkEscape: true });
2148
1636
  if (!fullPath) {
2149
1637
  (0, errors_1.logWarn)('Path traversal blocked in batch reader', { filePath: fp });
2150
1638
  return { filePath: fp, content: null, stats: null, error: new Error('Path traversal blocked') };
2151
1639
  }
2152
- // Stat first: a file over the size limit is stored as skipped
2153
- // without ever being read or decoded (#1910), so ten oversize
2154
- // fixtures in one I/O batch no longer cost their size in RSS.
2155
1640
  const { stats, bytes } = await (0, file_limits_1.readBoundedSource)(fullPath);
2156
1641
  if (bytes === null) {
2157
1642
  return { filePath: fp, content: (0, file_limits_1.oversizeStamp)(stats.size), stats, error: null };
2158
1643
  }
2159
- // Read bytes, not text: a `.ts` that is really an MPEG transport
2160
- // stream (#1910) is recognised from its head here, at no extra I/O,
2161
- // and never decoded or parsed.
2162
1644
  if (isMpegTsBytes(fp, bytes)) {
2163
1645
  return { filePath: fp, content: null, stats: null, error: null, skipped: true };
2164
1646
  }
@@ -2166,19 +1648,26 @@ class ExtractionOrchestrator {
2166
1648
  return { filePath: fp, content, stats, error: null };
2167
1649
  }
2168
1650
  catch (err) {
1651
+ if ((0, utils_1.isMissingPathError)(err)) {
1652
+ return { filePath: fp, content: null, stats: null, error: null, gone: true };
1653
+ }
2169
1654
  return { filePath: fp, content: null, stats: null, error: err };
2170
1655
  }
2171
1656
  }));
2172
- // Dispatch each readable file into the bounded parse window; the window
2173
- // stores results on the main thread as they arrive.
2174
- for (const { filePath, content, stats, error, skipped } of fileContents) {
1657
+ for (const { filePath, content, stats, error, skipped, gone } of fileContents) {
2175
1658
  if (signal?.aborted) {
2176
1659
  aborted = true;
2177
1660
  break;
2178
1661
  }
2179
1662
  if (skipped) {
2180
- // Not a source file after all — counted as done, stored as nothing.
2181
1663
  processed++;
1664
+ filesSkipped++;
1665
+ onProgress?.({ phase: 'parsing', current: processed, total });
1666
+ continue;
1667
+ }
1668
+ if (gone) {
1669
+ processed++;
1670
+ filesSkipped++;
2182
1671
  onProgress?.({ phase: 'parsing', current: processed, total });
2183
1672
  continue;
2184
1673
  }
@@ -2194,11 +1683,6 @@ class ExtractionOrchestrator {
2194
1683
  onProgress?.({ phase: 'parsing', current: processed, total });
2195
1684
  continue;
2196
1685
  }
2197
- // Honour MAX_SOURCE_FILE_SIZE_BYTES. Without this check, vendored generated
2198
- // headers, minified bundles, and other multi-MB files get indexed,
2199
- // wasting WASM heap and the worker recycle budget on inputs with no
2200
- // useful symbols. The single-file extractFile path already enforces
2201
- // this; the bulk path used to silently skip the check.
2202
1686
  if (stats.size > file_limits_1.MAX_SOURCE_FILE_SIZE_BYTES) {
2203
1687
  await storeResult(filePath, content, stats, {
2204
1688
  nodes: [],
@@ -2214,29 +1698,21 @@ class ExtractionOrchestrator {
2214
1698
  });
2215
1699
  continue;
2216
1700
  }
2217
- // Parse on the pool (main thread stays unblocked). Errors/timeouts are
2218
- // handled inside feed() → recordParseFailure, feeding the retry pass.
2219
1701
  await feed(filePath, content, stats);
2220
1702
  }
2221
1703
  if (aborted)
2222
1704
  break;
2223
1705
  }
2224
- // Drain parses still in flight (skip on abort — we tear down below instead),
2225
- // then commit any results the cursor hasn't reached yet.
2226
1706
  if (!aborted) {
2227
1707
  await Promise.all(inFlight);
2228
1708
  await flushOrdered();
2229
1709
  if (flushError) {
2230
1710
  if (storeWriter)
2231
1711
  await storeWriter.close();
2232
- // Its worker threads would otherwise outlive the failed index.
2233
1712
  if (pool)
2234
1713
  await pool.destroy();
2235
1714
  throw flushError;
2236
1715
  }
2237
- // All bundles are posted; wait for the writer to apply them, then close
2238
- // its connection BEFORE any main-thread DB work below (retry pass,
2239
- // resolution) so exactly one connection writes at a time.
2240
1716
  if (storeWriter) {
2241
1717
  try {
2242
1718
  await storeWriter.drain();
@@ -2267,31 +1743,18 @@ class ExtractionOrchestrator {
2267
1743
  durationMs: Date.now() - startTime,
2268
1744
  };
2269
1745
  }
2270
- // Report 100% so the progress bar doesn't hang at 99%
2271
1746
  onProgress?.({
2272
1747
  phase: 'parsing',
2273
1748
  current: total,
2274
1749
  total,
2275
1750
  });
2276
- // Yield so the shimmer worker's buffered stdout writes can flush.
2277
- // Worker thread stdout is proxied through the main thread's event loop,
2278
- // so synchronous work here blocks the animation from rendering.
2279
1751
  await new Promise(resolve => setImmediate(resolve));
2280
- // Retry pass: files that failed due to WASM memory corruption may succeed
2281
- // on a fresh worker with a clean heap. Recycle before each attempt so
2282
- // every file gets the absolute cleanest WASM state possible. Timeouts are
2283
- // retried too (#1231): most are main-thread-stall artifacts, not slow
2284
- // parses, and this pass parses one file at a time with the store strictly
2285
- // after each parse resolves, so the stall window can't recur here.
2286
1752
  const retryableErrors = errors.filter((e) => e.code === 'parse_error' && e.filePath &&
2287
1753
  (e.message.includes('Worker exited') ||
2288
1754
  e.message.includes('memory access out of bounds') ||
2289
1755
  e.message.includes('timed out')));
2290
1756
  if (retryableErrors.length > 0 && pool) {
2291
1757
  log(`Retrying ${retryableErrors.length} files that failed due to WASM memory errors or timeouts...`);
2292
- // Fresh WASM heaps for the retry phase. A retry that still crashes its
2293
- // worker makes the pool respawn it, so later retries keep landing on clean
2294
- // workers too.
2295
1758
  pool.recycleAll();
2296
1759
  const stillFailing = [];
2297
1760
  for (const errEntry of retryableErrors) {
@@ -2303,7 +1766,6 @@ class ExtractionOrchestrator {
2303
1766
  const fullPath = (0, utils_1.validatePathWithinRoot)(this.rootDir, filePath);
2304
1767
  if (!fullPath)
2305
1768
  continue;
2306
- // Bounded like the first read: the file may have grown since (#1910).
2307
1769
  const bytes = (await (0, file_limits_1.readBoundedSource)(fullPath)).bytes;
2308
1770
  if (bytes === null)
2309
1771
  continue;
@@ -2320,13 +1782,7 @@ class ExtractionOrchestrator {
2320
1782
  stillFailing.push(errEntry);
2321
1783
  continue;
2322
1784
  }
2323
- // The pool hands kernel results back as an undecoded buffer transport
2324
- // (`nodes`/`edges` EMPTY, tables in kernelBuffers). The main loop
2325
- // decodes or forwards to the store worker; this path stores directly,
2326
- // so decode here — otherwise a kernel-language retry passes the gate
2327
- // below via `errors.length === 0`, stores nothing, and the file is
2328
- // permanently recorded as "(0 symbols)" with the error erased (#1541).
2329
- const language = (0, grammars_1.detectLanguage)(filePath, content, overrides);
1785
+ const language = (0, grammars_1.detectLanguage)(filePath, content, overrides, this.rootDir);
2330
1786
  result = (0, kernel_1.materializeKernelResult)(result, filePath, language);
2331
1787
  if (result.nodes.length > 0 || result.errors.length === 0) {
2332
1788
  const stats = await fsp.stat(path.join(this.rootDir, filePath));
@@ -2341,10 +1797,6 @@ class ExtractionOrchestrator {
2341
1797
  log(`Retry OK: ${filePath} (${result.nodes.length} nodes)`);
2342
1798
  }
2343
1799
  }
2344
- // Last resort: for files that still crash on a clean worker, strip
2345
- // comment-only lines to reduce WASM memory pressure. Many compiler
2346
- // test files are 90%+ comments (CHECK directives) that don't contribute
2347
- // code nodes but consume parser memory.
2348
1800
  if (stillFailing.length > 0) {
2349
1801
  log(`${stillFailing.length} files still failing — retrying with comments stripped...`);
2350
1802
  pool.recycleAll();
@@ -2365,8 +1817,6 @@ class ExtractionOrchestrator {
2365
1817
  catch {
2366
1818
  continue;
2367
1819
  }
2368
- // Strip lines that are entirely comments (preserving line numbers
2369
- // by replacing with empty lines so node positions stay correct)
2370
1820
  const stripped = fullContent
2371
1821
  .split('\n')
2372
1822
  .map(line => /^\s*\/\//.test(line) ? '' : line)
@@ -2378,17 +1828,11 @@ class ExtractionOrchestrator {
2378
1828
  catch {
2379
1829
  continue;
2380
1830
  }
2381
- // Same undecoded-transport hazard as the first retry pass (#1541).
2382
- const language = (0, grammars_1.detectLanguage)(filePath, fullContent, overrides);
1831
+ const language = (0, grammars_1.detectLanguage)(filePath, fullContent, overrides, this.rootDir);
2383
1832
  result = (0, kernel_1.materializeKernelResult)(result, filePath, language);
2384
1833
  if (result.nodes.length > 0 || result.errors.length === 0) {
2385
1834
  const stats = await fsp.stat(path.join(this.rootDir, filePath));
2386
1835
  await this.storeExtractionResult(filePath, fullContent, language, stats, result, commitYield);
2387
- // Salvaged from comment-stripped source: keep a visible trace in
2388
- // the summary instead of erasing the failure outright — the
2389
- // stored result may be missing whatever the failing parse choked
2390
- // on, and a silently "clean" file here is how an index quietly
2391
- // disagrees with a later per-file sync of the same bytes (#1565).
2392
1836
  errEntry.severity = 'warning';
2393
1837
  errEntry.code = 'salvaged_stripped';
2394
1838
  errEntry.message = `Indexed from comment-stripped source after repeated parse failures (symbols may be incomplete until the file is re-indexed): ${errEntry.message}`;
@@ -2401,7 +1845,6 @@ class ExtractionOrchestrator {
2401
1845
  }
2402
1846
  }
2403
1847
  }
2404
- // Shut down the parse worker pool.
2405
1848
  if (pool)
2406
1849
  await pool.destroy();
2407
1850
  return {
@@ -2417,9 +1860,6 @@ class ExtractionOrchestrator {
2417
1860
  durationMs: Date.now() - startTime,
2418
1861
  };
2419
1862
  }
2420
- /**
2421
- * Index specific files
2422
- */
2423
1863
  async indexFiles(filePaths) {
2424
1864
  const startTime = Date.now();
2425
1865
  const errors = [];
@@ -2433,7 +1873,10 @@ class ExtractionOrchestrator {
2433
1873
  if (result.errors.length > 0) {
2434
1874
  errors.push(...result.errors);
2435
1875
  }
2436
- if (result.nodes.length > 0) {
1876
+ if ((0, grammars_1.hasGrammarLoadFailure)(result.errors)) {
1877
+ filesErrored++;
1878
+ }
1879
+ else if (result.nodes.length > 0) {
2437
1880
  filesIndexed++;
2438
1881
  totalNodes += result.nodes.length;
2439
1882
  totalEdges += result.edges.length;
@@ -2462,11 +1905,7 @@ class ExtractionOrchestrator {
2462
1905
  durationMs: Date.now() - startTime,
2463
1906
  };
2464
1907
  }
2465
- /**
2466
- * Index a single file
2467
- */
2468
1908
  async indexFile(relativePath) {
2469
- // Indexing read: follow in-root symlinks (the `../` guard still applies), #935.
2470
1909
  const fullPath = (0, utils_1.validatePathWithinRoot)(this.rootDir, relativePath, { allowSymlinkEscape: true });
2471
1910
  if (!fullPath) {
2472
1911
  return {
@@ -2477,20 +1916,20 @@ class ExtractionOrchestrator {
2477
1916
  durationMs: 0,
2478
1917
  };
2479
1918
  }
2480
- // Read file content and stats
2481
1919
  let content;
2482
1920
  let stats;
2483
1921
  try {
2484
- // An oversize file is stored as skipped; its bytes are never needed (#1910).
2485
1922
  const read = await (0, file_limits_1.readBoundedSource)(fullPath);
2486
1923
  stats = read.stats;
2487
- // An MPEG transport stream named `.ts` is not TypeScript (#1910).
2488
1924
  if (read.bytes !== null && isMpegTsBytes(relativePath, read.bytes)) {
2489
1925
  return { nodes: [], edges: [], unresolvedReferences: [], errors: [], durationMs: 0 };
2490
1926
  }
2491
1927
  content = read.bytes === null ? (0, file_limits_1.oversizeStamp)(stats.size) : read.bytes.toString('utf8');
2492
1928
  }
2493
1929
  catch (error) {
1930
+ if ((0, utils_1.isMissingPathError)(error)) {
1931
+ return { nodes: [], edges: [], unresolvedReferences: [], errors: [], durationMs: 0 };
1932
+ }
2494
1933
  return {
2495
1934
  nodes: [],
2496
1935
  edges: [],
@@ -2508,12 +1947,7 @@ class ExtractionOrchestrator {
2508
1947
  }
2509
1948
  return this.indexFileWithContent(relativePath, content, stats);
2510
1949
  }
2511
- /**
2512
- * Index a single file with pre-read content and stats.
2513
- * Used by the parallel batch reader to avoid redundant file I/O.
2514
- */
2515
1950
  async indexFileWithContent(relativePath, content, stats) {
2516
- // Prevent `../` traversal; follow in-root symlinks like the directory walk (#935).
2517
1951
  const fullPath = (0, utils_1.validatePathWithinRoot)(this.rootDir, relativePath, { allowSymlinkEscape: true });
2518
1952
  if (!fullPath) {
2519
1953
  (0, errors_1.logWarn)('Path traversal blocked in indexFileWithContent', { relativePath });
@@ -2525,8 +1959,7 @@ class ExtractionOrchestrator {
2525
1959
  durationMs: 0,
2526
1960
  };
2527
1961
  }
2528
- const language = (0, grammars_1.detectLanguage)(relativePath, content, (0, project_config_1.loadExtensionOverrides)(this.rootDir));
2529
- // Check file size
1962
+ const language = (0, grammars_1.detectLanguage)(relativePath, content, (0, project_config_1.loadExtensionOverrides)(this.rootDir), this.rootDir);
2530
1963
  if (stats.size > file_limits_1.MAX_SOURCE_FILE_SIZE_BYTES) {
2531
1964
  const result = {
2532
1965
  nodes: [],
@@ -2545,7 +1978,6 @@ class ExtractionOrchestrator {
2545
1978
  await this.storeExtractionResult(relativePath, content, language, stats, result, (0, cooperative_yield_1.createYielder)());
2546
1979
  return result;
2547
1980
  }
2548
- // Detect language (honoring the project's codegraph.json extension overrides)
2549
1981
  if (!(0, grammars_1.isLanguageSupported)(language)) {
2550
1982
  return {
2551
1983
  nodes: [],
@@ -2555,36 +1987,13 @@ class ExtractionOrchestrator {
2555
1987
  durationMs: 0,
2556
1988
  };
2557
1989
  }
2558
- // Extract from source. Use cached framework names if indexAll has run,
2559
- // otherwise detect on the spot so single-file re-index paths still emit
2560
- // route nodes / middleware / etc.
2561
- const frameworkNames = this.ensureDetectedFrameworks();
1990
+ const frameworkNames = this.frameworksForFile(relativePath, this.ensureDetectedFrameworks());
2562
1991
  const result = (0, tree_sitter_1.extractFromSource)(relativePath, content, language, frameworkNames);
2563
- // Store in database
2564
1992
  await this.storeExtractionResult(relativePath, content, language, stats, result, (0, cooperative_yield_1.createYielder)());
2565
1993
  return result;
2566
1994
  }
2567
- /**
2568
- * Store extraction result in database
2569
- */
2570
- /**
2571
- * Delete file rows recorded with ZERO nodes so their files re-index.
2572
- *
2573
- * No extraction path stores an empty, error-free result for a
2574
- * symbol-bearing language — even an empty file keeps its file node — so a
2575
- * zero-node row is a wiped one (#1541: an interrupted parse's retry stored
2576
- * an undecoded kernel transport). The wiped row's content hash matches the
2577
- * on-disk bytes, so every hash-based reconcile skips the file forever;
2578
- * deleting the row lets the normal add path repair it. File-level-only
2579
- * languages (yaml, twig, properties) are left alone. Deleting a zero-node
2580
- * row cascades nothing: it has no nodes, so no edges or refs either.
2581
- */
2582
1995
  healZeroNodeRows() {
2583
1996
  for (const f of this.queries.getAllFiles()) {
2584
- // A zero-node row WITH recorded errors is a deliberate skip marker
2585
- // (#1557: oversized / repeatedly-unparseable files are persisted with
2586
- // their reason so syncs stop retrying them) — leave those alone. The
2587
- // #1541 wipe rows are the error-FREE zero-node rows.
2588
1997
  if (f.nodeCount === 0 &&
2589
1998
  !(0, grammars_1.isFileLevelOnlyLanguage)(f.language) &&
2590
1999
  (f.errors === undefined || f.errors.length === 0)) {
@@ -2593,63 +2002,27 @@ class ExtractionOrchestrator {
2593
2002
  }
2594
2003
  }
2595
2004
  async storeExtractionResult(filePath, content, language, stats, result, onYield) {
2596
- // A kernel result can arrive as an undecoded buffer transport (empty
2597
- // node/edge arrays, tables riding in kernelBuffers). Decode it before
2598
- // storing — persisting the transport as-is records the file as having no
2599
- // symbols at all (#1541). No-op for already-decoded results.
2005
+ if ((0, grammars_1.hasGrammarLoadFailure)(result.errors))
2006
+ return;
2600
2007
  result = (0, kernel_1.materializeKernelResult)(result, filePath, language);
2601
- // Bulk inserts run in bounded sub-transactions with a yield between, so a
2602
- // giant generated file (tens of thousands of symbols) can't block the
2603
- // event loop — and the #850 watchdog heartbeat — for the whole store.
2604
- // The file was NEVER one atomic transaction (each insert call has its
2605
- // own), and the files-table record still lands last, so crash recovery
2606
- // is unchanged: a partially-stored file has no record and re-indexes.
2607
2008
  const STORE_CHUNK = 2000;
2608
2009
  const contentHash = hashContent(content);
2609
- // Check if file already exists and hasn't changed. A skip/failure MARKER
2610
- // row (zero nodes + recorded errors, #1557) never blocks a store carrying
2611
- // real content: markers are written BEFORE the retry pass under the same
2612
- // content hash, so treating them as "no changes" would silently discard a
2613
- // successful retry's symbols — a permanent empty file presented as
2614
- // recovered (the #1541 wipe, reintroduced through the marker path).
2615
2010
  const existingFile = this.queries.getFileByPath(filePath);
2616
2011
  if (existingFile && existingFile.contentHash === contentHash) {
2617
2012
  const existingIsMarker = existingFile.nodeCount === 0 && (existingFile.errors?.length ?? 0) > 0;
2618
2013
  const incomingHasContent = result.nodes.length > 0;
2619
- if (!existingIsMarker || !incomingHasContent) {
2620
- return; // No changes
2014
+ const existingNeverParsed = (0, grammars_1.hasGrammarLoadFailure)(existingFile.errors);
2015
+ if (!existingNeverParsed && (!existingIsMarker || !incomingHasContent)) {
2016
+ return;
2621
2017
  }
2622
2018
  }
2623
- // Re-decided on every re-index of a changed file, so a banner added (or
2624
- // removed) by an edit is reflected on the next sync (#1500). Computed after
2625
- // the unchanged-file early return so untouched files pay nothing.
2626
2019
  const generated = (0, generated_detection_1.detectGeneratedFile)(filePath, content);
2627
- // Snapshot incoming cross-file edges BEFORE deleting this file's nodes.
2628
- // `deleteFile` cascades to delete every edge whose source OR target is a
2629
- // node in this file (edges.FK ... ON DELETE CASCADE). Edges whose SOURCE is
2630
- // in this file are re-emitted by the extractor below, but edges whose SOURCE
2631
- // is in a *different* (unchanged) file are not — they would be silently
2632
- // dropped, which is issue #899: re-indexing a callee file severs `calls`/
2633
- // `references` edges from callers that import it via module-attribute
2634
- // access (`pkg.mod.fn(...)`).
2635
- //
2636
- // We snapshot the edge plus the target node's (name, kind) so we can
2637
- // re-resolve to the re-indexed target's NEW id. Node ids are
2638
- // `sha256(filePath:kind:name:line)`, so any line shift in the callee file
2639
- // (e.g. a docstring-only edit above the symbol) changes every target id and
2640
- // a naive re-insert by old id would silently drop every edge. Matching by
2641
- // (filePath, kind, name) is stable across line shifts; if the symbol was
2642
- // renamed/removed, no match is found and the edge stays dropped (correct).
2643
2020
  const crossFileIncomingEdges = existingFile
2644
2021
  ? this.queries.getCrossFileIncomingEdgesWithTarget(filePath)
2645
2022
  : [];
2646
- // Delete existing data for this file
2647
- if (existingFile) {
2648
- this.queries.deleteFile(filePath);
2649
- }
2650
- // Filter out nodes with missing required fields before insertion.
2651
- // This prevents FK violations when edges reference nodes that would
2652
- // be silently skipped by insertNode() (see issue #42).
2023
+ const priorNodes = crossFileIncomingEdges.length > 0
2024
+ ? this.queries.getNodeIdentitiesByFile(filePath)
2025
+ : [];
2653
2026
  const validNodes = result.nodes.filter((n) => n.id && n.kind && n.name && n.filePath && n.language);
2654
2027
  const insertedIds = new Set(validNodes.map((n) => n.id));
2655
2028
  const validEdges = result.edges.filter((e) => insertedIds.has(e.source) && insertedIds.has(e.target));
@@ -2660,76 +2033,56 @@ class ExtractionOrchestrator {
2660
2033
  filePath: ref.filePath ?? filePath,
2661
2034
  language: ref.language ?? language,
2662
2035
  }));
2663
- // Fast path for the common case (everything fits one chunk): the whole
2664
- // file — nodes, edges, refs, file record — lands in ONE transaction with
2665
- // no event-loop yields in between. Giant generated files keep the chunked
2666
- // + yielding path below so the #850 watchdog heartbeat stays serviced.
2667
2036
  const fitsOneChunk = validNodes.length <= STORE_CHUNK &&
2668
2037
  validEdges.length <= STORE_CHUNK &&
2669
2038
  validRefs.length <= STORE_CHUNK;
2670
2039
  if (fitsOneChunk) {
2671
- // Snapshot/re-resolution of cross-file incoming edges (below) still runs
2672
- // for the sync path; on a fresh bulk index crossFileIncomingEdges is [].
2673
- this.queries.storeFileBundle({
2674
- nodes: validNodes,
2675
- edges: validEdges,
2676
- refs: validRefs,
2677
- file: {
2678
- path: filePath,
2679
- contentHash,
2680
- language,
2681
- size: stats.size,
2682
- modifiedAt: stats.mtimeMs,
2683
- indexedAt: Date.now(),
2684
- nodeCount: result.nodes.length,
2685
- errors: result.errors.length > 0 ? result.errors : undefined,
2686
- generated,
2687
- },
2040
+ this.queries.runInTransaction(() => {
2041
+ if (existingFile) {
2042
+ this.queries.deleteFile(filePath);
2043
+ }
2044
+ this.queries.storeFileBundle({
2045
+ nodes: validNodes,
2046
+ edges: validEdges,
2047
+ refs: validRefs,
2048
+ file: {
2049
+ path: filePath,
2050
+ contentHash,
2051
+ language,
2052
+ size: stats.size,
2053
+ modifiedAt: stats.mtimeMs,
2054
+ indexedAt: Date.now(),
2055
+ nodeCount: result.nodes.length,
2056
+ errors: result.errors.length > 0 ? result.errors : undefined,
2057
+ generated,
2058
+ },
2059
+ });
2060
+ if (crossFileIncomingEdges.length > 0) {
2061
+ this.reattachCrossFileEdges(crossFileIncomingEdges, priorNodes, validNodes);
2062
+ }
2688
2063
  });
2689
- if (crossFileIncomingEdges.length > 0) {
2690
- this.reattachCrossFileEdges(crossFileIncomingEdges, validNodes);
2691
- }
2692
2064
  return;
2693
2065
  }
2694
- // Insert nodes (chunked — see STORE_CHUNK above)
2066
+ if (existingFile) {
2067
+ this.queries.deleteFile(filePath);
2068
+ }
2695
2069
  for (let i = 0; i < validNodes.length; i += STORE_CHUNK) {
2696
2070
  this.queries.insertNodes(validNodes.slice(i, i + STORE_CHUNK));
2697
2071
  await onYield?.();
2698
2072
  }
2699
- // Filter edges to only reference nodes that were actually inserted
2700
2073
  if (validEdges.length > 0) {
2701
2074
  for (let i = 0; i < validEdges.length; i += STORE_CHUNK) {
2702
2075
  this.queries.insertEdges(validEdges.slice(i, i + STORE_CHUNK));
2703
2076
  await onYield?.();
2704
2077
  }
2705
2078
  }
2706
- // Re-insert cross-file incoming edges snapshotted before the delete,
2707
- // re-resolving each edge's target to the re-indexed node's new id by
2708
- // (filePath, kind, name). Node ids include the source line, so any line
2709
- // shift in the callee file (e.g. a docstring-only edit above the symbol)
2710
- // changes every target id and a naive re-insert by old id would drop them
2711
- // all. `insertEdges` still filters to endpoints that exist. This closes
2712
- // the #899 edge-drop on `sync`.
2713
- //
2714
- // Edges whose callee (target) was renamed/removed during the re-index (no
2715
- // match in `newNodesByKindName`) are not silently dropped anymore: each is
2716
- // resurrected as its ORIGINAL unresolved ref (stamped on the edge as
2717
- // metadata.refName/refKind at creation) so the same sync's resolution
2718
- // sweep can rebind it to an alternative definition elsewhere, or park it
2719
- // as status='failed' to be retried when the symbol reappears — the
2720
- // removal-side counterpart of #1240. Edges without refName (built before
2721
- // the stamp existed, or synthesized) still drop silently: reconstructing
2722
- // a ref from the target's plain name would strip receiver/qualifier
2723
- // context and risk a rebind a full re-index would never make.
2724
2079
  if (crossFileIncomingEdges.length > 0) {
2725
- this.reattachCrossFileEdges(crossFileIncomingEdges, validNodes);
2080
+ this.reattachCrossFileEdges(crossFileIncomingEdges, priorNodes, validNodes);
2726
2081
  }
2727
- // Insert unresolved references in batch with denormalized filePath/language
2728
2082
  for (let i = 0; i < validRefs.length; i += STORE_CHUNK) {
2729
2083
  this.queries.insertUnresolvedRefsBatch(validRefs.slice(i, i + STORE_CHUNK));
2730
2084
  await onYield?.();
2731
2085
  }
2732
- // Insert file record
2733
2086
  const fileRecord = {
2734
2087
  path: filePath,
2735
2088
  contentHash,
@@ -2743,12 +2096,6 @@ class ExtractionOrchestrator {
2743
2096
  };
2744
2097
  this.queries.upsertFile(fileRecord);
2745
2098
  }
2746
- /**
2747
- * Build one file's store bundle for the FRESH-DB path: no existing-file
2748
- * check, no cross-file edge snapshot (both are re-index concerns — a fresh
2749
- * database has neither). Filters mirror storeExtractionResult exactly.
2750
- */
2751
- /** The FileRecord for a fresh-index store (nodeCount is the PRE-filter count). */
2752
2099
  buildFileRecord(filePath, content, language, stats, nodeCount, resultErrors) {
2753
2100
  return {
2754
2101
  path: filePath,
@@ -2759,36 +2106,23 @@ class ExtractionOrchestrator {
2759
2106
  indexedAt: Date.now(),
2760
2107
  nodeCount,
2761
2108
  errors: resultErrors.length > 0 ? resultErrors : undefined,
2762
- // Decided here, once, while the content is already in memory — never at
2763
- // query time (#1500). The header scan short-circuits on a single
2764
- // substring test for ~every hand-written file.
2765
2109
  generated: (0, generated_detection_1.detectGeneratedFile)(filePath, content),
2766
2110
  };
2767
2111
  }
2768
2112
  buildFreshStoreBundle(filePath, content, language, stats, result) {
2769
2113
  return (0, store_writer_1.finalizeStoreBundle)(result, filePath, language, this.buildFileRecord(filePath, content, language, stats, result.nodes.length, result.errors));
2770
2114
  }
2771
- /**
2772
- * Re-attach cross-file incoming edges snapshotted before a re-index delete
2773
- * (#899): re-resolve each edge's target to the re-indexed node's new id by
2774
- * (kind, name); targets that vanished are resurrected as their original
2775
- * unresolved ref (#1240's removal-side counterpart) when the edge carries
2776
- * its refName stamp.
2777
- */
2778
- reattachCrossFileEdges(crossFileIncomingEdges, validNodes) {
2779
- const newNodesByKindName = new Map();
2780
- for (const n of validNodes) {
2781
- newNodesByKindName.set(`${n.kind}\0${n.name}`, n.id);
2782
- }
2115
+ reattachCrossFileEdges(crossFileIncomingEdges, priorNodes, validNodes) {
2116
+ const replacementOf = pairReindexedNodes(priorNodes, validNodes);
2783
2117
  const reinserted = [];
2784
2118
  const resurrected = [];
2785
2119
  for (const e of crossFileIncomingEdges) {
2786
- const newTargetId = newNodesByKindName.get(`${e.targetKind}\0${e.targetName}`);
2120
+ const newTargetId = replacementOf.get(e.target);
2787
2121
  if (newTargetId) {
2788
2122
  reinserted.push({ source: e.source, target: newTargetId, kind: e.kind, metadata: e.metadata, line: e.line, column: e.column, provenance: e.provenance });
2789
2123
  }
2790
2124
  else {
2791
- const ref = resurrectRefFromDroppedEdge(e);
2125
+ const ref = (0, resurrect_ref_1.resurrectRefFromDroppedEdge)(e);
2792
2126
  if (ref)
2793
2127
  resurrected.push(ref);
2794
2128
  }
@@ -2800,92 +2134,116 @@ class ExtractionOrchestrator {
2800
2134
  this.queries.insertUnresolvedRefsBatch(resurrected);
2801
2135
  }
2802
2136
  }
2803
- /**
2804
- * Re-open, for re-resolution, every resolution edge whose answer this sync
2805
- * may have changed — the fix for index drift (CG-33).
2806
- *
2807
- * Incremental sync re-resolves only the references IN the changed files, but
2808
- * resolution's answer is a function of the WHOLE graph: a reference binds to
2809
- * one of the same-named definitions project-wide, so adding or removing a
2810
- * definition of `pct` can change which `pct` every other file's `pct(...)`
2811
- * should bind to. Those other files are never revisited, and their references
2812
- * resolved successfully once and were deleted from `unresolved_refs`, so
2813
- * nothing existed to revisit them with — the index kept an answer that was
2814
- * correct against an older graph. Measured on codegraph's own long-lived
2815
- * index: 4.3% of distinct edges differed from a clean rebuild, in BOTH
2816
- * directions, overwhelmingly `calls`. See docs/benchmarks/index-drift-cg33.md.
2817
- *
2818
- * This deletes each affected edge and re-inserts it as the reference that
2819
- * created it (the refName/refKind stamp), status='pending', for the sync's
2820
- * resolution sweep to bind against the post-sync graph — the same input a
2821
- * full rebuild resolves from, which is what makes the two converge.
2822
- *
2823
- * Deliberately conservative in three ways, because a wrong deletion is a
2824
- * permanent edge loss while a missed rebind is only residual drift:
2825
- * - an edge with no refName stamp (synthesized, or built by an engine older
2826
- * than the stamp) is left ALONE rather than reconstructed from the target's
2827
- * plain name, same rule as `resurrectRefFromDroppedEdge`;
2828
- * - edges whose source is in a file this sync already re-extracted are
2829
- * skipped — their references were re-resolved from scratch moments ago;
2830
- * - very common names are skipped by the per-name ceiling in
2831
- * `getResolutionEdgesByTargetName`.
2832
- *
2833
- * Returns the number of references resurrected.
2834
- */
2835
- resurrectStaleResolutionEdges(definitionDelta, changedFilePaths) {
2137
+ resurrectStaleResolutionEdges(definitionDelta, changedFilePaths, countedUpToEdgeId) {
2836
2138
  if (definitionDelta.length === 0)
2837
2139
  return 0;
2838
2140
  const alreadyFresh = new Set(changedFilePaths);
2839
- const candidates = this.queries.getResolutionEdgesByTargetName(definitionDelta);
2141
+ const candidates = this.queries.getResolutionEdgesByTargetName(definitionDelta, undefined, countedUpToEdgeId);
2840
2142
  const edgeIds = [];
2841
2143
  const refs = [];
2842
2144
  for (const e of candidates) {
2843
2145
  if (alreadyFresh.has(e.sourceFilePath))
2844
2146
  continue;
2845
- const ref = resurrectRefFromDroppedEdge(e);
2147
+ const ref = (0, resurrect_ref_1.resurrectRefFromDroppedEdge)(e);
2846
2148
  if (!ref)
2847
- continue; // no stamp — never delete what we cannot restore
2149
+ continue;
2848
2150
  edgeIds.push(e.edgeId);
2849
2151
  refs.push(ref);
2850
2152
  }
2851
2153
  if (refs.length === 0)
2852
2154
  return 0;
2853
- // Delete first. The sweep re-inserts whichever edge resolution now picks,
2854
- // and `insertEdges` is INSERT OR IGNORE against idx_edges_identity — so a
2855
- // rebind to the same target is a clean no-op, but leaving the old row in
2856
- // place for a rebind ELSEWHERE would keep both, turning drift into
2857
- // duplication.
2858
2155
  this.queries.replaceResolutionEdgesWithUnresolvedRefs(edgeIds, refs);
2859
2156
  return refs.length;
2860
2157
  }
2861
- /**
2862
- * Sync the index with the current file state.
2863
- *
2864
- * Change detection is filesystem-based, never git: a (size, mtime) stat
2865
- * pre-filter skips unchanged files, then a content-hash compare confirms real
2866
- * changes. This works in non-git projects and catches committed changes from
2867
- * `git pull`/`checkout`/`merge`/`rebase` that `git status` cannot see.
2868
- */
2869
- async sync(onProgress,
2870
- /**
2871
- * Watcher fast path: the exact project-relative paths the OS reported as
2872
- * changed. When provided, reconciliation runs over ONLY these paths —
2873
- * per-path logic identical to the full walk (stat pre-filter, hash
2874
- * confirm, the #1240 removal/resurrection flow) — skipping the O(repo)
2875
- * scan and tracked-load. Callers must pass undefined whenever the change
2876
- * set is not exactly known (directory removals, event overflow): the full
2877
- * scan-diff remains the ground truth those cases need (#1285).
2878
- */
2879
- scopedPaths,
2880
- /**
2881
- * Writer-side WAL pressure valve (#1539). Called after every changed file
2882
- * is stored, when no extraction transaction is open, so a checkpoint can
2883
- * safely catch up before the next file grows the WAL further.
2884
- */
2885
- backpressure,
2886
- /** Inspect changed inputs before deletion/re-extraction cascades their edges. */
2887
- onFileChange) {
2888
- await (0, grammars_1.initGrammars)(); // Initialize WASM runtime (grammars loaded lazily below)
2158
+ resurrectTypeDependentEdges(touchedPaths, changedFilePaths) {
2159
+ const touched = new Set(touchedPaths.filter((p) => TYPE_FROM_FILE.test(p)));
2160
+ if (touched.size === 0)
2161
+ return [];
2162
+ const alreadyFresh = new Set(changedFilePaths);
2163
+ const edgeIds = [];
2164
+ const refs = [];
2165
+ const files = new Set();
2166
+ for (const e of this.queries.getEdgesWithTypeFrom()) {
2167
+ if (alreadyFresh.has(e.sourceFilePath))
2168
+ continue;
2169
+ const from = e.metadata?.typeFrom;
2170
+ if (!Array.isArray(from) || !from.some((f) => typeof f === 'string' && touched.has(f)))
2171
+ continue;
2172
+ const ref = (0, resurrect_ref_1.resurrectRefFromDroppedEdge)(e);
2173
+ if (!ref)
2174
+ continue;
2175
+ edgeIds.push(e.edgeId);
2176
+ refs.push(ref);
2177
+ files.add(e.sourceFilePath);
2178
+ }
2179
+ if (refs.length === 0)
2180
+ return [];
2181
+ this.queries.replaceResolutionEdgesWithUnresolvedRefs(edgeIds, refs);
2182
+ return [...files];
2183
+ }
2184
+ resurrectResolutionEdgesForLanguage(language) {
2185
+ return (this.reopenEdges(this.queries.getResolutionEdgesBySourceLanguage(language)) +
2186
+ this.queries.requeueFailedReferencesByLanguage(language));
2187
+ }
2188
+ resurrectResolutionEdgesTouching(language, scope) {
2189
+ const files = new Set();
2190
+ const edges = this.queries.getResolutionEdgesTouchingFiles(language, scope.targetFiles, scope.sourceDirs, scope.moduleLeaves);
2191
+ for (const e of edges)
2192
+ files.add(e.sourceFilePath);
2193
+ this.reopenEdges(edges);
2194
+ this.queries.requeueFailedReferencesByLanguage(language, scope.moduleLeaves, files);
2195
+ return [...files];
2196
+ }
2197
+ resurrectPythonPackageImporters(bindings) {
2198
+ if (bindings.size === 0)
2199
+ return [];
2200
+ const edges = this.queries.getResolutionEdgesFromFiles('python', [...bindings.keys()]);
2201
+ const refHead = (e) => {
2202
+ const refName = e.metadata?.refName;
2203
+ return typeof refName === 'string' ? refName.split('.')[0] : null;
2204
+ };
2205
+ const bindsNow = new Map();
2206
+ for (const e of edges) {
2207
+ const refName = e.metadata?.refName;
2208
+ if (e.kind !== 'imports' || typeof refName !== 'string' || refName.includes('.'))
2209
+ continue;
2210
+ const target = this.queries.getNodeById(e.target);
2211
+ if (target)
2212
+ bindsNow.set(`${e.sourceFilePath}\0${refName}`, `${target.filePath}\0${target.kind === 'file' ? '' : target.name}`);
2213
+ }
2214
+ const moved = new Map();
2215
+ for (const [file, names] of bindings) {
2216
+ for (const [name, binding] of names) {
2217
+ if (binding !== null && bindsNow.get(`${file}\0${name}`) === binding)
2218
+ continue;
2219
+ let set = moved.get(file);
2220
+ if (!set)
2221
+ moved.set(file, (set = new Set()));
2222
+ set.add(name);
2223
+ }
2224
+ }
2225
+ if (moved.size === 0)
2226
+ return [];
2227
+ this.reopenEdges(edges.filter((e) => moved.get(e.sourceFilePath)?.has(refHead(e) ?? '') === true));
2228
+ this.queries.requeueFailedReferencesBinding('python', moved);
2229
+ return [...moved.keys()];
2230
+ }
2231
+ reopenEdges(edges) {
2232
+ const edgeIds = [];
2233
+ const refs = [];
2234
+ for (const e of edges) {
2235
+ const ref = (0, resurrect_ref_1.resurrectRefFromDroppedEdge)(e);
2236
+ if (!ref)
2237
+ continue;
2238
+ edgeIds.push(e.edgeId);
2239
+ refs.push(ref);
2240
+ }
2241
+ if (refs.length > 0)
2242
+ this.queries.replaceResolutionEdgesWithUnresolvedRefs(edgeIds, refs);
2243
+ return refs.length;
2244
+ }
2245
+ async sync(onProgress, scopedPaths, backpressure, onFileChange) {
2246
+ await (0, grammars_1.initGrammars)();
2889
2247
  const startTime = Date.now();
2890
2248
  let filesChecked = 0;
2891
2249
  let filesAdded = 0;
@@ -2893,10 +2251,11 @@ class ExtractionOrchestrator {
2893
2251
  let filesRemoved = 0;
2894
2252
  let nodesUpdated = 0;
2895
2253
  const changedFilePaths = [];
2896
- // `file\0name` definition pairs for the files this sync touches, sampled
2897
- // BEFORE their nodes are replaced/deleted. Compared against the post-store
2898
- // pairs below to derive `definitionDelta` (CG-33).
2254
+ const addedFilePaths = [];
2255
+ const indexedFromSkip = [];
2256
+ const removedFilePaths = [];
2899
2257
  const pairsBefore = new Set();
2258
+ const importReader = (0, module_importers_1.createImportReader)(this.rootDir);
2900
2259
  onProgress?.({
2901
2260
  phase: 'scanning',
2902
2261
  current: 0,
@@ -2904,37 +2263,14 @@ class ExtractionOrchestrator {
2904
2263
  });
2905
2264
  const filesToIndex = [];
2906
2265
  const failedFilePaths = [];
2907
- // === Filesystem reconcile (git-independent) ===
2908
- // The source of truth for "what changed" is the filesystem vs the indexed
2909
- // state — never git. We enumerate the current source files and reconcile
2910
- // each against the DB. A cheap (size, mtime) stat pre-filter skips unchanged
2911
- // files without reading or hashing them, so the expensive read+hash+parse
2912
- // only runs for files that actually changed. This catches edits/adds/deletes
2913
- // whether or not the project uses git, and crucially also catches committed
2914
- // changes from `git pull`/`checkout`/`merge`/`rebase` — which `git status`
2915
- // cannot see, because the working tree is clean afterward.
2916
2266
  const tSyncScan = Date.now();
2917
2267
  let currentFiles;
2918
2268
  let trackedFiles;
2919
2269
  if (scopedPaths && scopedPaths.length > 0) {
2920
- // Scoped reconcile: stat only the reported paths. filesChecked counts
2921
- // the PATHS examined (not the files found) — it must stay non-zero even
2922
- // when every scoped path was a deletion, because CodeGraph.watch()
2923
- // reads `filesChecked === 0 && durationMs === 0` as the
2924
- // lock-unavailable signature (#449).
2925
2270
  const unique = [...new Set(scopedPaths)];
2926
- // A scoped path is "present" only if it exists AND is in scope — the
2927
- // same two gates the full walk applies (source extension, scope
2928
- // matcher). Without the scope gate a caller's stale view of scope
2929
- // leaked straight into the index: the watcher re-parsed a file the
2930
- // user had just excluded in `codegraph.json` while `codegraph sync`
2931
- // removed it (#1590). Out-of-scope paths fall out of `currentFiles`,
2932
- // so a tracked one takes the removal branch below, exactly as a full
2933
- // sync would treat it. (`include`-forced paths pass: ScopeIgnore
2934
- // applies the include precedence itself.)
2935
2271
  const scope = this.scopedSyncMatcher();
2936
2272
  const overrides = (0, project_config_1.loadExtensionOverrides)(this.rootDir);
2937
- currentFiles = unique.filter((p) => (0, grammars_1.isSourceFile)(p, overrides) &&
2273
+ currentFiles = unique.filter((p) => (0, grammars_1.isSourceFile)(p, overrides, this.rootDir) &&
2938
2274
  !scope.ignores(p) &&
2939
2275
  fs.existsSync(path.join(this.rootDir, p)));
2940
2276
  trackedFiles = [];
@@ -2948,16 +2284,12 @@ class ExtractionOrchestrator {
2948
2284
  console.error(`[phase-timing] sync-scoped: ${Date.now() - tSyncScan}ms (${unique.length} paths, ${trackedFiles.length} tracked)`);
2949
2285
  }
2950
2286
  else {
2951
- // Full reconcile: drop the memoized scope matcher so a nested
2952
- // `.gitignore` / exclude-standard change that forced this full sync is
2953
- // visible to the next scoped sync (#1728).
2954
2287
  this.scopedMatcher = null;
2955
- currentFiles = await scanDirectoryAsync(this.rootDir);
2288
+ this.manifestEvidence = null;
2289
+ currentFiles = await scanDirectoryAsync(this.rootDir, undefined, undefined, (evidence) => { this.manifestEvidence = evidence; });
2956
2290
  if (process.env.CODEGRAPH_SYNTH_TIMINGS)
2957
2291
  console.error(`[phase-timing] sync-scan: ${Date.now() - tSyncScan}ms (${currentFiles.length} files)`);
2958
2292
  filesChecked = currentFiles.length;
2959
- // Full reconcile only (scoped syncs must not touch rows outside their
2960
- // scope): drop zero-node rows so the wiped files re-index as adds below.
2961
2293
  this.healZeroNodeRows();
2962
2294
  const tTracked = Date.now();
2963
2295
  trackedFiles = this.queries.getAllFiles();
@@ -2969,28 +2301,14 @@ class ExtractionOrchestrator {
2969
2301
  for (const f of trackedFiles) {
2970
2302
  trackedMap.set(f.path, f);
2971
2303
  }
2972
- // Removals: tracked in the DB but no longer a present source file. Check the
2973
- // filesystem directly — `scanDirectory` (via `git ls-files`) still lists a
2974
- // file deleted from disk but not yet staged, so set membership alone misses it.
2975
- // `reconcileChecks` drives the cooperative yield shared with the adds/mods loop
2976
- // below (see SYNC_RECONCILE_YIELD_INTERVAL / issue #905).
2977
2304
  let reconcileChecks = 0;
2978
2305
  const removeTracked = (tracked) => {
2979
- // Before the cascade deletes them, resurrect incoming cross-file
2980
- // resolution edges as their original refs (#1240 removal case): the
2981
- // callers live in files this sync will NOT revisit, so this is their
2982
- // only chance to rebind to an alternative definition — or to park as
2983
- // failed until the symbol reappears somewhere. (A deleted file whose
2984
- // CALLERS are also being deleted is fine: their nodes cascade later
2985
- // in this loop and take the resurrected rows with them.)
2986
- // Every name this file defined is about to stop existing here, which
2987
- // narrows the candidate set for that name repo-wide (CG-33).
2988
2306
  for (const pair of this.queries.getNodeNamePairsByFiles([tracked.path]))
2989
2307
  pairsBefore.add(pair);
2990
2308
  const incoming = this.queries.getCrossFileIncomingEdgesWithTarget(tracked.path);
2991
2309
  if (incoming.length > 0) {
2992
2310
  const resurrected = incoming
2993
- .map((e) => resurrectRefFromDroppedEdge(e))
2311
+ .map((e) => (0, resurrect_ref_1.resurrectRefFromDroppedEdge)(e))
2994
2312
  .filter((r) => r !== null);
2995
2313
  if (resurrected.length > 0) {
2996
2314
  this.queries.insertUnresolvedRefsBatch(resurrected);
@@ -2998,32 +2316,38 @@ class ExtractionOrchestrator {
2998
2316
  }
2999
2317
  onFileChange?.(tracked.path);
3000
2318
  this.queries.deleteFile(tracked.path);
2319
+ removedFilePaths.push(tracked.path);
3001
2320
  filesRemoved++;
3002
2321
  };
2322
+ const removed = [];
3003
2323
  for (const tracked of trackedFiles) {
3004
2324
  if (!currentSet.has(tracked.path) || !fs.existsSync(path.join(this.rootDir, tracked.path))) {
3005
- removeTracked(tracked);
2325
+ removed.push(tracked);
2326
+ }
2327
+ if (++reconcileChecks % SYNC_RECONCILE_YIELD_INTERVAL === 0) {
2328
+ await new Promise((resolve) => setImmediate(resolve));
3006
2329
  }
2330
+ }
2331
+ if (removed.length > 0) {
2332
+ const tImporters = Date.now();
2333
+ const reopened = (0, module_importers_1.reopenReferencesThroughRemovedFiles)(this.queries, importReader, removed);
2334
+ if (process.env.CODEGRAPH_SYNTH_TIMINGS)
2335
+ console.error(`[phase-timing] sync-removed-module-importers: ${Date.now() - tImporters}ms (${reopened} refs re-opened)`);
2336
+ }
2337
+ for (const tracked of removed) {
2338
+ removeTracked(tracked);
3007
2339
  if (++reconcileChecks % SYNC_RECONCILE_YIELD_INTERVAL === 0) {
3008
2340
  await new Promise((resolve) => setImmediate(resolve));
3009
2341
  }
3010
2342
  }
3011
- // Adds / modifications.
3012
2343
  for (const filePath of currentFiles) {
3013
- // Same cooperative yield as the removals loop — this is the other O(files)
3014
- // synchronous-stat loop that wedges the main thread on a large repo (#905).
3015
- // Yield at the top of the body so the `continue` fast-paths below still hit it.
3016
2344
  if (++reconcileChecks % SYNC_RECONCILE_YIELD_INTERVAL === 0) {
3017
2345
  await new Promise((resolve) => setImmediate(resolve));
3018
2346
  }
3019
2347
  const fullPath = path.join(this.rootDir, filePath);
3020
2348
  const tracked = trackedMap.get(filePath);
3021
- // Cheap pre-filter: an already-indexed file whose size AND mtime both match
3022
- // the DB is unchanged — skip it without reading or hashing. (A content
3023
- // change that preserves both exactly is the blind spot every mtime-based
3024
- // incremental tool accepts; `index --force` is the escape hatch. Git bumps
3025
- // mtime on every file it writes during checkout/merge, so pulls are caught.)
3026
- if (tracked) {
2349
+ const neverParsed = tracked !== undefined && (0, grammars_1.hasGrammarLoadFailure)(tracked.errors);
2350
+ if (tracked && !neverParsed) {
3027
2351
  try {
3028
2352
  const stat = fs.statSync(fullPath);
3029
2353
  if (stat.size === tracked.size && Math.floor(stat.mtimeMs) === Math.floor(tracked.modifiedAt)) {
@@ -3036,8 +2360,6 @@ class ExtractionOrchestrator {
3036
2360
  continue;
3037
2361
  }
3038
2362
  }
3039
- // New, or size/mtime changed — read + hash to confirm a real content change.
3040
- // (An oversize file hashes as its size stamp, unread — #1910.)
3041
2363
  let content;
3042
2364
  try {
3043
2365
  content = readSourceOrStamp(fullPath);
@@ -3047,11 +2369,11 @@ class ExtractionOrchestrator {
3047
2369
  failedFilePaths.push(filePath);
3048
2370
  continue;
3049
2371
  }
3050
- // Not source after all — an MPEG transport stream named `.ts` (#1910):
3051
- // a new one is ignored, a tracked file that became one is removed.
3052
2372
  if (content === null) {
3053
- if (tracked)
2373
+ if (tracked) {
2374
+ (0, module_importers_1.reopenReferencesThroughRemovedFiles)(this.queries, importReader, [tracked]);
3054
2375
  removeTracked(tracked);
2376
+ }
3055
2377
  continue;
3056
2378
  }
3057
2379
  const contentHash = hashContent(content);
@@ -3059,29 +2381,34 @@ class ExtractionOrchestrator {
3059
2381
  onFileChange?.(filePath, content);
3060
2382
  filesToIndex.push(filePath);
3061
2383
  changedFilePaths.push(filePath);
2384
+ addedFilePaths.push(filePath);
3062
2385
  filesAdded++;
3063
2386
  }
3064
- else if (tracked.contentHash !== contentHash) {
2387
+ else if (tracked.contentHash !== contentHash || neverParsed) {
3065
2388
  onFileChange?.(filePath, content);
3066
2389
  filesToIndex.push(filePath);
3067
2390
  changedFilePaths.push(filePath);
2391
+ if (tracked.nodeCount === 0 && (tracked.errors?.length ?? 0) > 0)
2392
+ indexedFromSkip.push(filePath);
3068
2393
  filesModified++;
3069
2394
  }
3070
2395
  }
3071
- // Sampled here — after the add/modify classification, before any file is
3072
- // re-extracted — because `storeExtractionResult` deletes a file's nodes
3073
- // before inserting the new ones, so this is the last point the pre-edit
3074
- // definition set is readable (CG-33).
3075
2396
  if (filesToIndex.length > 0) {
3076
2397
  for (const pair of this.queries.getNodeNamePairsByFiles(filesToIndex))
3077
2398
  pairsBefore.add(pair);
3078
2399
  }
3079
- // Load only grammars needed for changed files
2400
+ const reExportsBefore = filesToIndex.length > 0 ? this.queries.getReExportStatementsByFiles(filesToIndex) : new Set();
2401
+ if (addedFilePaths.length > 0 || removedFilePaths.length > 0)
2402
+ this.detectionFileListChanged = true;
2403
+ const tDetect = Date.now();
2404
+ const detectedFrameworks = filesToIndex.length === 0 ? undefined : this.refreshFrameworkDetection(scopedPaths && scopedPaths.length > 0 ? null : currentFiles, filesToIndex, addedFilePaths, removedFilePaths);
2405
+ if (process.env.CODEGRAPH_SYNTH_TIMINGS && filesToIndex.length > 0) {
2406
+ console.error(`[phase-timing] sync-framework-detect: ${Date.now() - tDetect}ms (${detectedFrameworks ? 'detected again' : 'unchanged'})`);
2407
+ }
3080
2408
  if (filesToIndex.length > 0) {
3081
2409
  const overrides = (0, project_config_1.loadExtensionOverrides)(this.rootDir);
3082
- await (0, grammars_1.loadGrammarsForLanguages)(preloadLanguagesForFiles(filesToIndex, overrides));
2410
+ await (0, grammars_1.loadGrammarsForLanguages)(preloadLanguagesForFiles(filesToIndex, overrides, this.rootDir));
3083
2411
  }
3084
- // Index changed files
3085
2412
  const total = filesToIndex.length;
3086
2413
  for (let i = 0; i < filesToIndex.length; i++) {
3087
2414
  const filePath = filesToIndex[i];
@@ -3094,23 +2421,16 @@ class ExtractionOrchestrator {
3094
2421
  const result = await this.indexFile(filePath);
3095
2422
  if (result.errors.some(e => e.severity === 'error'))
3096
2423
  failedFilePaths.push(filePath);
3097
- nodesUpdated += result.nodes.length;
2424
+ if (!(0, grammars_1.hasGrammarLoadFailure)(result.errors))
2425
+ nodesUpdated += result.nodes.length;
3098
2426
  const pause = backpressure?.();
3099
2427
  if (pause)
3100
2428
  await pause;
3101
2429
  }
3102
- // Names whose definition set this sync changed: a `file\0name` pair present
3103
- // before but not after (removed/renamed away) or after but not before
3104
- // (added). A pair on both sides is untouched as far as resolution's
3105
- // candidate set is concerned — only its node id moved, which
3106
- // reattachCrossFileEdges already follows — so an edit that only changes
3107
- // bodies yields an empty delta and no downstream rebind work (CG-33).
3108
- //
3109
- // Compared per FILE, not as one name set over the whole batch: a commit
3110
- // that adds `collect` to a new file while an unrelated changed file already
3111
- // defined `collect` must still flag the name, and a bare name set cancels
3112
- // exactly that case out. That miss left the largest residual class in the
3113
- // first measurement of this fix.
2430
+ for (const filePath of indexedFromSkip) {
2431
+ if ((this.queries.getFileByPath(filePath)?.nodeCount ?? 0) > 0)
2432
+ addedFilePaths.push(filePath);
2433
+ }
3114
2434
  const pairsAfter = this.queries.getNodeNamePairsByFiles(filesToIndex);
3115
2435
  const deltaNames = new Set();
3116
2436
  const nameOf = (pair) => pair.slice(pair.indexOf('\0') + 1);
@@ -3121,6 +2441,26 @@ class ExtractionOrchestrator {
3121
2441
  if (!pairsBefore.has(pair))
3122
2442
  deltaNames.add(nameOf(pair));
3123
2443
  const definitionDelta = [...deltaNames];
2444
+ const reExportsChanged = [];
2445
+ if (filesToIndex.length > 0) {
2446
+ const reExportsAfter = this.queries.getReExportStatementsByFiles(filesToIndex);
2447
+ const fileOf = (pair) => pair.slice(0, pair.indexOf('\0'));
2448
+ const changed = new Set();
2449
+ for (const pair of reExportsBefore)
2450
+ if (!reExportsAfter.has(pair))
2451
+ changed.add(fileOf(pair));
2452
+ for (const pair of reExportsAfter)
2453
+ if (!reExportsBefore.has(pair))
2454
+ changed.add(fileOf(pair));
2455
+ const added = new Set(addedFilePaths);
2456
+ for (const filePath of changed) {
2457
+ if (added.has(filePath))
2458
+ continue;
2459
+ const record = this.queries.getFileByPath(filePath);
2460
+ if (record && RE_EXPORTING_LANGUAGES.has(record.language))
2461
+ reExportsChanged.push(filePath);
2462
+ }
2463
+ }
3124
2464
  return {
3125
2465
  filesChecked,
3126
2466
  filesAdded,
@@ -3129,10 +2469,19 @@ class ExtractionOrchestrator {
3129
2469
  nodesUpdated,
3130
2470
  durationMs: Date.now() - startTime,
3131
2471
  changedFilePaths: changedFilePaths.length > 0 ? changedFilePaths : undefined,
2472
+ ...(addedFilePaths.length > 0 ? { addedFilePaths } : {}),
3132
2473
  ...(failedFilePaths.length > 0 ? { failedFilePaths } : {}),
3133
2474
  definitionDelta: definitionDelta.length > 0 ? definitionDelta : undefined,
2475
+ ...(reExportsChanged.length > 0 ? { reExportsChangedFilePaths: reExportsChanged } : {}),
2476
+ ...(removedFilePaths.length > 0 ? { removedFilePaths } : {}),
2477
+ ...(detectedFrameworks ? { detectedFrameworks } : {}),
3134
2478
  };
3135
2479
  }
2480
+ takeManifestEvidence() {
2481
+ const evidence = this.manifestEvidence;
2482
+ this.manifestEvidence = null;
2483
+ return evidence;
2484
+ }
3136
2485
  indexedDirtyPaths(stamp) {
3137
2486
  try {
3138
2487
  const state = JSON.parse(this.queries.getMetadata('indexed_dirty_paths') ?? 'null');
@@ -3147,7 +2496,6 @@ class ExtractionOrchestrator {
3147
2496
  return null;
3148
2497
  }
3149
2498
  }
3150
- /** Capture before file reads. In-flight/failed full writes must not claim freshness. */
3151
2499
  beginGitIndexState(full) {
3152
2500
  const head = getGitHeadSha(this.rootDir) ?? '';
3153
2501
  const stamp = this.queries.getMetadata(exports.INDEXED_AT_COMMIT_KEY) ?? '';
@@ -3161,11 +2509,9 @@ class ExtractionOrchestrator {
3161
2509
  this.queries.setMetadata('indexed_dirty_paths', '');
3162
2510
  }
3163
2511
  else {
3164
- // Scoped writes leave the commit alone and retain dirty paths before the
3165
- // first write, so a crash cannot forget an indexed uncommitted edit.
3166
2512
  this.queries.setMetadata('indexed_dirty_paths', JSON.stringify({ commit: stamp, paths: dirty }));
3167
2513
  }
3168
- return { head, stamp, dirty };
2514
+ return { head, stamp, dirty, sparse: full ? sparseCheckoutStamp(this.rootDir) : '' };
3169
2515
  }
3170
2516
  finishGitIndexState(snapshot, full, retries = []) {
3171
2517
  const after = getGitChangedFiles(this.rootDir);
@@ -3173,45 +2519,42 @@ class ExtractionOrchestrator {
3173
2519
  return;
3174
2520
  const commit = full ? snapshot.head : snapshot.stamp;
3175
2521
  const paths = [...new Set([...snapshot.dirty, ...after.added, ...after.modified, ...after.deleted, ...retries])].sort();
3176
- // The embedded commit makes a torn pair fail closed: readers reject a dirty
3177
- // set that doesn't match the separately stored commit. Write the set first.
3178
2522
  this.queries.setMetadata('indexed_dirty_paths', JSON.stringify({ commit, paths }));
3179
- if (full)
2523
+ if (full) {
3180
2524
  this.queries.setMetadata(exports.INDEXED_AT_COMMIT_KEY, commit);
2525
+ this.queries.setMetadata(INDEXED_SPARSE_CHECKOUT_KEY, snapshot.sparse);
2526
+ }
2527
+ }
2528
+ sparseCheckoutChanges() {
2529
+ const indexedAt = this.queries.getMetadata(INDEXED_SPARSE_CHECKOUT_KEY);
2530
+ if (indexedAt === null || indexedAt === sparseCheckoutStamp(this.rootDir))
2531
+ return [];
2532
+ const scanned = new Set(scanDirectory(this.rootDir));
2533
+ const indexed = this.queries.getAllFilePaths();
2534
+ const known = new Set(indexed);
2535
+ return [...[...scanned].filter((file) => !known.has(file)), ...indexed.filter((file) => !scanned.has(file))];
3181
2536
  }
3182
- /**
3183
- * Get files that have changed since last index.
3184
- * Uses git status as a fast path when available, falling back to full scan.
3185
- */
3186
2537
  getChangedFiles() {
3187
- // The commit this index was last brought up to date at. Absent on an index
3188
- // built before stamping existed — getGitChangedFiles then declines the fast
3189
- // path and the full scan below answers correctly, once, until a sync or a
3190
- // full index writes the stamp. (#1829)
3191
2538
  let sinceCommit = null;
3192
2539
  try {
3193
2540
  sinceCommit = this.queries.getMetadata(exports.INDEXED_AT_COMMIT_KEY) ?? null;
3194
2541
  }
3195
- catch { /* advisory */ }
2542
+ catch { }
3196
2543
  const dirtyPaths = this.indexedDirtyPaths(sinceCommit);
3197
2544
  const gitChanges = dirtyPaths !== null && canTrustGitFastPath(this.rootDir, sinceCommit)
3198
2545
  ? getGitChangedFiles(this.rootDir, sinceCommit)
3199
2546
  : null;
3200
2547
  if (gitChanges) {
3201
- // === Git fast path ===
3202
2548
  const added = [];
3203
2549
  const modified = [];
3204
2550
  const removed = [];
3205
- // Git supplies candidates, never the verdict. A committed deletion may
3206
- // have been recreated locally; a previously indexed dirty path may have
3207
- // vanished from git status after restore. Classify current disk vs DB once.
3208
- const candidates = new Set([...gitChanges.deleted, ...gitChanges.modified, ...gitChanges.added, ...dirtyPaths]);
2551
+ const candidates = new Set([...gitChanges.deleted, ...gitChanges.modified, ...gitChanges.added, ...dirtyPaths, ...this.sparseCheckoutChanges()]);
3209
2552
  const scope = this.scopedSyncMatcher();
3210
2553
  const overrides = (0, project_config_1.loadExtensionOverrides)(this.rootDir);
3211
2554
  for (const filePath of candidates) {
3212
2555
  const tracked = this.queries.getFileByPath(filePath);
3213
2556
  const fullPath = path.join(this.rootDir, filePath);
3214
- if (!(0, grammars_1.isSourceFile)(filePath, overrides) || scope.ignores(filePath) || !fs.existsSync(fullPath)) {
2557
+ if (!(0, grammars_1.isSourceFile)(filePath, overrides, this.rootDir) || scope.ignores(filePath) || !fs.existsSync(fullPath)) {
3215
2558
  if (tracked)
3216
2559
  removed.push(filePath);
3217
2560
  continue;
@@ -3224,8 +2567,6 @@ class ExtractionOrchestrator {
3224
2567
  (0, errors_1.logDebug)('Skipping unreadable file while detecting changes', { filePath, error: String(error) });
3225
2568
  continue;
3226
2569
  }
3227
- // A `.ts` that is an MPEG transport stream is not source (#1910), so an
3228
- // untracked clip is never pending and a tracked file that became one is gone.
3229
2570
  if (content === null) {
3230
2571
  if (tracked)
3231
2572
  removed.push(filePath);
@@ -3238,10 +2579,8 @@ class ExtractionOrchestrator {
3238
2579
  }
3239
2580
  return { added, modified, removed };
3240
2581
  }
3241
- // === Fallback: full scan (non-git project or git failure) ===
3242
2582
  const currentFiles = new Set(scanDirectory(this.rootDir));
3243
2583
  const trackedFiles = this.queries.getAllFiles();
3244
- // Build Map for O(1) lookups
3245
2584
  const trackedMap = new Map();
3246
2585
  for (const f of trackedFiles) {
3247
2586
  trackedMap.set(f.path, f);
@@ -3249,13 +2588,11 @@ class ExtractionOrchestrator {
3249
2588
  const added = [];
3250
2589
  const modified = [];
3251
2590
  const removed = [];
3252
- // Find removed files
3253
2591
  for (const tracked of trackedFiles) {
3254
2592
  if (!currentFiles.has(tracked.path)) {
3255
2593
  removed.push(tracked.path);
3256
2594
  }
3257
2595
  }
3258
- // Find added and modified files
3259
2596
  for (const filePath of currentFiles) {
3260
2597
  const fullPath = path.join(this.rootDir, filePath);
3261
2598
  let content;
@@ -3267,7 +2604,6 @@ class ExtractionOrchestrator {
3267
2604
  continue;
3268
2605
  }
3269
2606
  const tracked = trackedMap.get(filePath);
3270
- // An MPEG transport stream named `.ts` (#1910) is not source.
3271
2607
  if (content === null) {
3272
2608
  if (tracked)
3273
2609
  removed.push(filePath);
@@ -3285,7 +2621,6 @@ class ExtractionOrchestrator {
3285
2621
  }
3286
2622
  }
3287
2623
  exports.ExtractionOrchestrator = ExtractionOrchestrator;
3288
- // Re-export useful types and functions
3289
2624
  var tree_sitter_2 = require("./tree-sitter");
3290
2625
  Object.defineProperty(exports, "extractFromSource", { enumerable: true, get: function () { return tree_sitter_2.extractFromSource; } });
3291
2626
  var grammars_2 = require("./grammars");