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