gitnexus 1.6.6-rc.98 → 1.6.6

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 (541) hide show
  1. package/README.md +122 -68
  2. package/dist/_shared/graph/types.d.ts +17 -1
  3. package/dist/_shared/graph/types.d.ts.map +1 -1
  4. package/dist/_shared/index.d.ts +3 -5
  5. package/dist/_shared/index.d.ts.map +1 -1
  6. package/dist/_shared/index.js +2 -4
  7. package/dist/_shared/index.js.map +1 -1
  8. package/dist/_shared/scope-resolution/module-scope-index.d.ts +1 -2
  9. package/dist/_shared/scope-resolution/module-scope-index.d.ts.map +1 -1
  10. package/dist/_shared/scope-resolution/module-scope-index.js +1 -2
  11. package/dist/_shared/scope-resolution/module-scope-index.js.map +1 -1
  12. package/dist/_shared/scope-resolution/parsed-file.d.ts +24 -0
  13. package/dist/_shared/scope-resolution/parsed-file.d.ts.map +1 -1
  14. package/dist/_shared/scope-resolution/reference-site.d.ts +13 -1
  15. package/dist/_shared/scope-resolution/reference-site.d.ts.map +1 -1
  16. package/dist/_shared/scope-resolution/registries/context.d.ts +1 -0
  17. package/dist/_shared/scope-resolution/registries/context.d.ts.map +1 -1
  18. package/dist/_shared/scope-resolution/registries/context.js +6 -0
  19. package/dist/_shared/scope-resolution/registries/context.js.map +1 -1
  20. package/dist/_shared/scope-resolution/registries/evidence.d.ts +2 -3
  21. package/dist/_shared/scope-resolution/registries/evidence.d.ts.map +1 -1
  22. package/dist/_shared/scope-resolution/registries/evidence.js +2 -3
  23. package/dist/_shared/scope-resolution/registries/evidence.js.map +1 -1
  24. package/dist/_shared/scope-resolution/registries/macro-registry.d.ts +29 -0
  25. package/dist/_shared/scope-resolution/registries/macro-registry.d.ts.map +1 -0
  26. package/dist/_shared/scope-resolution/registries/macro-registry.js +32 -0
  27. package/dist/_shared/scope-resolution/registries/macro-registry.js.map +1 -0
  28. package/dist/_shared/scope-resolution/symbol-definition.d.ts +9 -0
  29. package/dist/_shared/scope-resolution/symbol-definition.d.ts.map +1 -1
  30. package/dist/_shared/scope-resolution/types.d.ts +1 -1
  31. package/dist/_shared/scope-resolution/types.d.ts.map +1 -1
  32. package/dist/cli/ai-context.d.ts +35 -1
  33. package/dist/cli/ai-context.js +111 -12
  34. package/dist/cli/analyze-config.d.ts +92 -0
  35. package/dist/cli/analyze-config.js +364 -0
  36. package/dist/cli/analyze.d.ts +17 -1
  37. package/dist/cli/analyze.js +224 -71
  38. package/dist/cli/cli-message.d.ts +1 -1
  39. package/dist/cli/doctor.d.ts +18 -0
  40. package/dist/cli/doctor.js +32 -0
  41. package/dist/cli/i18n/en.d.ts +2 -2
  42. package/dist/cli/i18n/en.js +2 -2
  43. package/dist/cli/i18n/resources.d.ts +2 -2
  44. package/dist/cli/i18n/zh-CN.js +2 -2
  45. package/dist/cli/index.js +4 -2
  46. package/dist/cli/resolve-invocation.d.ts +21 -0
  47. package/dist/cli/resolve-invocation.js +68 -0
  48. package/dist/cli/setup.d.ts +33 -0
  49. package/dist/cli/setup.js +96 -35
  50. package/dist/cli/skill-gen.js +2 -2
  51. package/dist/cli/wiki.js +20 -4
  52. package/dist/core/embeddings/embedder.d.ts +1 -1
  53. package/dist/core/embeddings/embedder.js +14 -1
  54. package/dist/core/embeddings/runtime-support.d.ts +41 -0
  55. package/dist/core/embeddings/runtime-support.js +65 -0
  56. package/dist/core/group/extractors/grpc-patterns/proto.js +2 -1
  57. package/dist/core/group/extractors/http-patterns/java.js +15 -1
  58. package/dist/core/ingestion/call-processor.d.ts +57 -227
  59. package/dist/core/ingestion/call-processor.js +172 -2595
  60. package/dist/core/ingestion/call-routing.d.ts +6 -5
  61. package/dist/core/ingestion/call-routing.js +6 -6
  62. package/dist/core/ingestion/call-types.d.ts +0 -75
  63. package/dist/core/ingestion/class-extractors/configs/c-cpp.js +26 -1
  64. package/dist/core/ingestion/class-extractors/configs/ruby.js +3 -0
  65. package/dist/core/ingestion/class-extractors/generic.js +9 -11
  66. package/dist/core/ingestion/class-types.d.ts +23 -0
  67. package/dist/core/ingestion/cobol/cobol-preprocessor.d.ts +11 -0
  68. package/dist/core/ingestion/cobol/cobol-preprocessor.js +227 -73
  69. package/dist/core/ingestion/cobol-processor.d.ts +1 -0
  70. package/dist/core/ingestion/cobol-processor.js +51 -2
  71. package/dist/core/ingestion/emit-references.js +8 -2
  72. package/dist/core/ingestion/export-detection.d.ts +2 -1
  73. package/dist/core/ingestion/export-detection.js +2 -6
  74. package/dist/core/ingestion/field-extractors/configs/dart.d.ts +0 -6
  75. package/dist/core/ingestion/field-extractors/configs/dart.js +62 -44
  76. package/dist/core/ingestion/field-extractors/configs/go.d.ts +0 -9
  77. package/dist/core/ingestion/field-extractors/configs/go.js +40 -1
  78. package/dist/core/ingestion/field-extractors/configs/jvm.js +43 -4
  79. package/dist/core/ingestion/field-extractors/configs/php.js +1 -2
  80. package/dist/core/ingestion/field-extractors/configs/swift.d.ts +12 -1
  81. package/dist/core/ingestion/field-extractors/configs/swift.js +31 -6
  82. package/dist/core/ingestion/field-extractors/generic.d.ts +6 -0
  83. package/dist/core/ingestion/field-extractors/generic.js +5 -4
  84. package/dist/core/ingestion/field-extractors/typescript.js +0 -29
  85. package/dist/core/ingestion/filesystem-walker.d.ts +0 -9
  86. package/dist/core/ingestion/filesystem-walker.js +0 -11
  87. package/dist/core/ingestion/finalize-orchestrator.js +14 -2
  88. package/dist/core/ingestion/import-resolvers/configs/swift.d.ts +21 -0
  89. package/dist/core/ingestion/import-resolvers/configs/swift.js +72 -11
  90. package/dist/core/ingestion/import-resolvers/python.d.ts +1 -1
  91. package/dist/core/ingestion/import-resolvers/standard.d.ts +2 -2
  92. package/dist/core/ingestion/import-resolvers/standard.js +6 -5
  93. package/dist/core/ingestion/import-resolvers/utils.d.ts +2 -5
  94. package/dist/core/ingestion/import-resolvers/utils.js +1 -9
  95. package/dist/core/ingestion/language-provider.d.ts +39 -119
  96. package/dist/core/ingestion/language-provider.js +0 -2
  97. package/dist/core/ingestion/languages/c/capture-side-channel.d.ts +62 -0
  98. package/dist/core/ingestion/languages/c/capture-side-channel.js +65 -0
  99. package/dist/core/ingestion/languages/c/captures.js +41 -23
  100. package/dist/core/ingestion/languages/c/import-decomposer.d.ts +9 -0
  101. package/dist/core/ingestion/languages/c/import-decomposer.js +15 -0
  102. package/dist/core/ingestion/languages/c/import-target.js +52 -9
  103. package/dist/core/ingestion/languages/c/index.d.ts +2 -1
  104. package/dist/core/ingestion/languages/c/index.js +2 -1
  105. package/dist/core/ingestion/languages/c/query.js +15 -0
  106. package/dist/core/ingestion/languages/c/scope-resolver.js +47 -4
  107. package/dist/core/ingestion/languages/c/static-linkage.d.ts +8 -0
  108. package/dist/core/ingestion/languages/c/static-linkage.js +46 -1
  109. package/dist/core/ingestion/languages/c-cpp.js +16 -7
  110. package/dist/core/ingestion/languages/cobol/captures.js +25 -2
  111. package/dist/core/ingestion/languages/cpp/adl.d.ts +88 -4
  112. package/dist/core/ingestion/languages/cpp/adl.js +380 -160
  113. package/dist/core/ingestion/languages/cpp/arity-metadata.js +2 -8
  114. package/dist/core/ingestion/languages/cpp/capture-side-channel.d.ts +65 -0
  115. package/dist/core/ingestion/languages/cpp/capture-side-channel.js +78 -0
  116. package/dist/core/ingestion/languages/cpp/captures.js +162 -54
  117. package/dist/core/ingestion/languages/cpp/file-local-linkage.d.ts +18 -52
  118. package/dist/core/ingestion/languages/cpp/file-local-linkage.js +49 -1
  119. package/dist/core/ingestion/languages/cpp/import-decomposer.d.ts +7 -0
  120. package/dist/core/ingestion/languages/cpp/import-decomposer.js +12 -0
  121. package/dist/core/ingestion/languages/cpp/index.d.ts +1 -0
  122. package/dist/core/ingestion/languages/cpp/index.js +1 -0
  123. package/dist/core/ingestion/languages/cpp/inline-namespaces.d.ts +8 -0
  124. package/dist/core/ingestion/languages/cpp/inline-namespaces.js +21 -0
  125. package/dist/core/ingestion/languages/cpp/query.js +21 -0
  126. package/dist/core/ingestion/languages/cpp/range-bindings.js +20 -5
  127. package/dist/core/ingestion/languages/cpp/scope-resolver.js +52 -5
  128. package/dist/core/ingestion/languages/cpp/two-phase-lookup.d.ts +20 -0
  129. package/dist/core/ingestion/languages/cpp/two-phase-lookup.js +83 -3
  130. package/dist/core/ingestion/languages/csharp/captures.js +205 -41
  131. package/dist/core/ingestion/languages/csharp/index.d.ts +3 -4
  132. package/dist/core/ingestion/languages/csharp/index.js +3 -4
  133. package/dist/core/ingestion/languages/csharp/interpret.js +17 -3
  134. package/dist/core/ingestion/languages/csharp/namespace-siblings.d.ts +17 -7
  135. package/dist/core/ingestion/languages/csharp/namespace-siblings.js +129 -124
  136. package/dist/core/ingestion/languages/csharp/qualified-type-names.d.ts +14 -0
  137. package/dist/core/ingestion/languages/csharp/qualified-type-names.js +59 -0
  138. package/dist/core/ingestion/languages/csharp/query.js +13 -0
  139. package/dist/core/ingestion/languages/csharp/receiver-binding.js +10 -6
  140. package/dist/core/ingestion/languages/csharp/scope-resolver.js +8 -1
  141. package/dist/core/ingestion/languages/csharp.js +0 -5
  142. package/dist/core/ingestion/languages/dart/arity-metadata.d.ts +25 -0
  143. package/dist/core/ingestion/languages/dart/arity-metadata.js +35 -0
  144. package/dist/core/ingestion/languages/dart/arity.d.ts +19 -0
  145. package/dist/core/ingestion/languages/dart/arity.js +31 -0
  146. package/dist/core/ingestion/languages/dart/built-ins.d.ts +11 -0
  147. package/dist/core/ingestion/languages/dart/built-ins.js +34 -0
  148. package/dist/core/ingestion/languages/dart/cache-stats.d.ts +13 -0
  149. package/dist/core/ingestion/languages/dart/cache-stats.js +24 -0
  150. package/dist/core/ingestion/languages/dart/captures.d.ts +29 -0
  151. package/dist/core/ingestion/languages/dart/captures.js +445 -0
  152. package/dist/core/ingestion/languages/dart/expand-wildcards.d.ts +13 -0
  153. package/dist/core/ingestion/languages/dart/expand-wildcards.js +31 -0
  154. package/dist/core/ingestion/languages/dart/import-target.d.ts +15 -0
  155. package/dist/core/ingestion/languages/dart/import-target.js +65 -0
  156. package/dist/core/ingestion/languages/dart/index.d.ts +28 -0
  157. package/dist/core/ingestion/languages/dart/index.js +28 -0
  158. package/dist/core/ingestion/languages/dart/interpret.d.ts +24 -0
  159. package/dist/core/ingestion/languages/dart/interpret.js +95 -0
  160. package/dist/core/ingestion/languages/dart/merge-bindings.d.ts +10 -0
  161. package/dist/core/ingestion/languages/dart/merge-bindings.js +39 -0
  162. package/dist/core/ingestion/languages/dart/query.d.ts +26 -0
  163. package/dist/core/ingestion/languages/dart/query.js +142 -0
  164. package/dist/core/ingestion/languages/dart/receiver-binding.d.ts +24 -0
  165. package/dist/core/ingestion/languages/dart/receiver-binding.js +87 -0
  166. package/dist/core/ingestion/languages/dart/scope-resolver.d.ts +29 -0
  167. package/dist/core/ingestion/languages/dart/scope-resolver.js +194 -0
  168. package/dist/core/ingestion/languages/dart/signature-bindings.d.ts +23 -0
  169. package/dist/core/ingestion/languages/dart/signature-bindings.js +51 -0
  170. package/dist/core/ingestion/languages/dart/simple-hooks.d.ts +20 -0
  171. package/dist/core/ingestion/languages/dart/simple-hooks.js +47 -0
  172. package/dist/core/ingestion/languages/dart.d.ts +0 -1
  173. package/dist/core/ingestion/languages/dart.js +15 -29
  174. package/dist/core/ingestion/languages/go/arity-metadata.d.ts +1 -0
  175. package/dist/core/ingestion/languages/go/arity-metadata.js +31 -1
  176. package/dist/core/ingestion/languages/go/captures.js +247 -26
  177. package/dist/core/ingestion/languages/go/interface-impls.js +476 -50
  178. package/dist/core/ingestion/languages/go/interpret.js +21 -11
  179. package/dist/core/ingestion/languages/go/method-owners.js +20 -8
  180. package/dist/core/ingestion/languages/go/query.js +15 -7
  181. package/dist/core/ingestion/languages/go/range-binding.js +24 -9
  182. package/dist/core/ingestion/languages/go/receiver-binding.js +1 -1
  183. package/dist/core/ingestion/languages/go/scope-resolver.js +2 -2
  184. package/dist/core/ingestion/languages/go/simple-hooks.js +10 -5
  185. package/dist/core/ingestion/languages/go/type-binding.d.ts +1 -0
  186. package/dist/core/ingestion/languages/go/type-binding.js +40 -2
  187. package/dist/core/ingestion/languages/go.d.ts +0 -1
  188. package/dist/core/ingestion/languages/go.js +0 -5
  189. package/dist/core/ingestion/languages/index.d.ts +0 -5
  190. package/dist/core/ingestion/languages/index.js +0 -3
  191. package/dist/core/ingestion/languages/java/captures.js +252 -23
  192. package/dist/core/ingestion/languages/java/interpret.js +12 -6
  193. package/dist/core/ingestion/languages/java/package-siblings.js +18 -5
  194. package/dist/core/ingestion/languages/java/query.js +16 -1
  195. package/dist/core/ingestion/languages/java/scope-resolver.d.ts +2 -8
  196. package/dist/core/ingestion/languages/java/scope-resolver.js +2 -8
  197. package/dist/core/ingestion/languages/java.js +0 -5
  198. package/dist/core/ingestion/languages/javascript/captures.js +185 -11
  199. package/dist/core/ingestion/languages/javascript/query.js +107 -1
  200. package/dist/core/ingestion/languages/kotlin/capture-side-channel.d.ts +57 -0
  201. package/dist/core/ingestion/languages/kotlin/capture-side-channel.js +60 -0
  202. package/dist/core/ingestion/languages/kotlin/captures.js +213 -22
  203. package/dist/core/ingestion/languages/kotlin/companion-scopes.d.ts +7 -0
  204. package/dist/core/ingestion/languages/kotlin/companion-scopes.js +10 -0
  205. package/dist/core/ingestion/languages/kotlin/index.d.ts +1 -0
  206. package/dist/core/ingestion/languages/kotlin/index.js +1 -0
  207. package/dist/core/ingestion/languages/kotlin/query.js +30 -0
  208. package/dist/core/ingestion/languages/kotlin/scope-resolver.d.ts +5 -7
  209. package/dist/core/ingestion/languages/kotlin/scope-resolver.js +22 -7
  210. package/dist/core/ingestion/languages/kotlin.js +8 -5
  211. package/dist/core/ingestion/languages/php/captures.js +135 -19
  212. package/dist/core/ingestion/languages/php/import-decomposer.js +21 -63
  213. package/dist/core/ingestion/languages/php/index.d.ts +3 -4
  214. package/dist/core/ingestion/languages/php/index.js +3 -4
  215. package/dist/core/ingestion/languages/php/query.js +5 -0
  216. package/dist/core/ingestion/languages/php/receiver-binding.js +8 -4
  217. package/dist/core/ingestion/languages/php.js +0 -4
  218. package/dist/core/ingestion/languages/python/captures.js +128 -13
  219. package/dist/core/ingestion/languages/python/depends-references.js +1 -1
  220. package/dist/core/ingestion/languages/python/import-target.d.ts +4 -5
  221. package/dist/core/ingestion/languages/python/import-target.js +108 -16
  222. package/dist/core/ingestion/languages/python/index-stats.d.ts +18 -0
  223. package/dist/core/ingestion/languages/python/index-stats.js +25 -0
  224. package/dist/core/ingestion/languages/python/index.d.ts +3 -4
  225. package/dist/core/ingestion/languages/python/index.js +3 -4
  226. package/dist/core/ingestion/languages/python/query.js +17 -0
  227. package/dist/core/ingestion/languages/python/scope-resolver.js +7 -6
  228. package/dist/core/ingestion/languages/python.d.ts +0 -2
  229. package/dist/core/ingestion/languages/python.js +0 -7
  230. package/dist/core/ingestion/languages/ruby/captures.js +174 -31
  231. package/dist/core/ingestion/languages/ruby/import-target.js +2 -1
  232. package/dist/core/ingestion/languages/ruby/interpret.js +2 -1
  233. package/dist/core/ingestion/languages/ruby/query.js +10 -0
  234. package/dist/core/ingestion/languages/ruby/scope-resolver.js +61 -11
  235. package/dist/core/ingestion/languages/ruby.js +4 -53
  236. package/dist/core/ingestion/languages/rust/captures.js +95 -13
  237. package/dist/core/ingestion/languages/rust/query.js +64 -1
  238. package/dist/core/ingestion/languages/rust/range-binding.js +40 -12
  239. package/dist/core/ingestion/languages/rust/receiver-binding.js +9 -0
  240. package/dist/core/ingestion/languages/rust/scope-resolver.js +75 -1
  241. package/dist/core/ingestion/languages/rust.d.ts +0 -2
  242. package/dist/core/ingestion/languages/rust.js +0 -6
  243. package/dist/core/ingestion/languages/swift/arity-metadata.d.ts +24 -0
  244. package/dist/core/ingestion/languages/swift/arity-metadata.js +41 -0
  245. package/dist/core/ingestion/languages/swift/arity.d.ts +29 -0
  246. package/dist/core/ingestion/languages/swift/arity.js +42 -0
  247. package/dist/core/ingestion/languages/swift/base-type.d.ts +20 -0
  248. package/dist/core/ingestion/languages/swift/base-type.js +27 -0
  249. package/dist/core/ingestion/languages/swift/cache-stats.d.ts +15 -0
  250. package/dist/core/ingestion/languages/swift/cache-stats.js +26 -0
  251. package/dist/core/ingestion/languages/swift/captures.d.ts +35 -0
  252. package/dist/core/ingestion/languages/swift/captures.js +495 -0
  253. package/dist/core/ingestion/languages/swift/implicit-imports.d.ts +34 -0
  254. package/dist/core/ingestion/languages/swift/implicit-imports.js +57 -0
  255. package/dist/core/ingestion/languages/swift/import-decomposer.d.ts +24 -0
  256. package/dist/core/ingestion/languages/swift/import-decomposer.js +84 -0
  257. package/dist/core/ingestion/languages/swift/import-target.d.ts +33 -0
  258. package/dist/core/ingestion/languages/swift/import-target.js +81 -0
  259. package/dist/core/ingestion/languages/swift/index.d.ts +37 -0
  260. package/dist/core/ingestion/languages/swift/index.js +37 -0
  261. package/dist/core/ingestion/languages/swift/interpret.d.ts +15 -0
  262. package/dist/core/ingestion/languages/swift/interpret.js +89 -0
  263. package/dist/core/ingestion/languages/swift/merge-bindings.d.ts +20 -0
  264. package/dist/core/ingestion/languages/swift/merge-bindings.js +48 -0
  265. package/dist/core/ingestion/languages/swift/query.d.ts +46 -0
  266. package/dist/core/ingestion/languages/swift/query.js +194 -0
  267. package/dist/core/ingestion/languages/swift/receiver-binding.d.ts +40 -0
  268. package/dist/core/ingestion/languages/swift/receiver-binding.js +161 -0
  269. package/dist/core/ingestion/languages/swift/scope-resolver.d.ts +50 -0
  270. package/dist/core/ingestion/languages/swift/scope-resolver.js +189 -0
  271. package/dist/core/ingestion/languages/swift/sibling-type-bindings.d.ts +34 -0
  272. package/dist/core/ingestion/languages/swift/sibling-type-bindings.js +65 -0
  273. package/dist/core/ingestion/languages/swift/signature-bindings.d.ts +25 -0
  274. package/dist/core/ingestion/languages/swift/signature-bindings.js +66 -0
  275. package/dist/core/ingestion/languages/swift/simple-hooks.d.ts +37 -0
  276. package/dist/core/ingestion/languages/swift/simple-hooks.js +60 -0
  277. package/dist/core/ingestion/languages/swift/target-grouping.d.ts +51 -0
  278. package/dist/core/ingestion/languages/swift/target-grouping.js +93 -0
  279. package/dist/core/ingestion/languages/swift/target-siblings.d.ts +30 -0
  280. package/dist/core/ingestion/languages/swift/target-siblings.js +71 -0
  281. package/dist/core/ingestion/languages/swift.d.ts +0 -5
  282. package/dist/core/ingestion/languages/swift.js +11 -87
  283. package/dist/core/ingestion/languages/typescript/array-callback.d.ts +3 -29
  284. package/dist/core/ingestion/languages/typescript/array-callback.js +4 -43
  285. package/dist/core/ingestion/languages/typescript/captures.js +147 -17
  286. package/dist/core/ingestion/languages/typescript/index.d.ts +3 -4
  287. package/dist/core/ingestion/languages/typescript/index.js +3 -4
  288. package/dist/core/ingestion/languages/typescript/query.d.ts +2 -3
  289. package/dist/core/ingestion/languages/typescript/query.js +125 -4
  290. package/dist/core/ingestion/languages/typescript/receiver-binding.js +0 -1
  291. package/dist/core/ingestion/languages/typescript.d.ts +2 -3
  292. package/dist/core/ingestion/languages/typescript.js +46 -23
  293. package/dist/core/ingestion/languages/vue/captures.d.ts +46 -0
  294. package/dist/core/ingestion/languages/vue/captures.js +67 -0
  295. package/dist/core/ingestion/languages/vue/import-target.d.ts +27 -0
  296. package/dist/core/ingestion/languages/vue/import-target.js +58 -0
  297. package/dist/core/ingestion/languages/vue/index.d.ts +49 -0
  298. package/dist/core/ingestion/languages/vue/index.js +49 -0
  299. package/dist/core/ingestion/languages/vue/scope-resolver.d.ts +55 -0
  300. package/dist/core/ingestion/languages/vue/scope-resolver.js +292 -0
  301. package/dist/core/ingestion/languages/vue.js +12 -4
  302. package/dist/core/ingestion/local-symbol-pruner.d.ts +11 -0
  303. package/dist/core/ingestion/local-symbol-pruner.js +63 -0
  304. package/dist/core/ingestion/method-extractors/configs/dart.js +14 -1
  305. package/dist/core/ingestion/method-extractors/configs/jvm.js +37 -20
  306. package/dist/core/ingestion/method-extractors/configs/php.js +0 -1
  307. package/dist/core/ingestion/method-extractors/configs/swift.js +11 -4
  308. package/dist/core/ingestion/method-types.d.ts +2 -2
  309. package/dist/core/ingestion/model/index.d.ts +0 -3
  310. package/dist/core/ingestion/model/index.js +0 -8
  311. package/dist/core/ingestion/model/resolve.d.ts +7 -43
  312. package/dist/core/ingestion/model/resolve.js +7 -226
  313. package/dist/core/ingestion/model/scope-resolution-indexes.d.ts +46 -1
  314. package/dist/core/ingestion/model/semantic-model.d.ts +4 -6
  315. package/dist/core/ingestion/model/semantic-model.js +1 -1
  316. package/dist/core/ingestion/model/symbol-table.d.ts +3 -4
  317. package/dist/core/ingestion/model/symbol-table.js +3 -4
  318. package/dist/core/ingestion/parsing-processor.d.ts +30 -24
  319. package/dist/core/ingestion/parsing-processor.js +76 -640
  320. package/dist/core/ingestion/pipeline-phases/communities.d.ts +1 -1
  321. package/dist/core/ingestion/pipeline-phases/communities.js +5 -2
  322. package/dist/core/ingestion/pipeline-phases/cross-file.d.ts +9 -8
  323. package/dist/core/ingestion/pipeline-phases/cross-file.js +16 -12
  324. package/dist/core/ingestion/pipeline-phases/index.d.ts +1 -0
  325. package/dist/core/ingestion/pipeline-phases/index.js +1 -0
  326. package/dist/core/ingestion/pipeline-phases/mro.d.ts +1 -1
  327. package/dist/core/ingestion/pipeline-phases/mro.js +2 -2
  328. package/dist/core/ingestion/pipeline-phases/parse-impl.d.ts +44 -22
  329. package/dist/core/ingestion/pipeline-phases/parse-impl.js +426 -565
  330. package/dist/core/ingestion/pipeline-phases/parse.d.ts +13 -33
  331. package/dist/core/ingestion/pipeline-phases/parse.js +2 -2
  332. package/dist/core/ingestion/pipeline-phases/processes.d.ts +1 -1
  333. package/dist/core/ingestion/pipeline-phases/processes.js +5 -3
  334. package/dist/core/ingestion/pipeline-phases/prune-local-symbols.d.ts +14 -0
  335. package/dist/core/ingestion/pipeline-phases/prune-local-symbols.js +26 -0
  336. package/dist/core/ingestion/pipeline.d.ts +27 -19
  337. package/dist/core/ingestion/pipeline.js +4 -2
  338. package/dist/core/ingestion/resolve-references.js +15 -3
  339. package/dist/core/ingestion/route-extractors/laravel.d.ts +10 -0
  340. package/dist/core/ingestion/route-extractors/laravel.js +88 -9
  341. package/dist/core/ingestion/scope-extractor-bridge.d.ts +2 -1
  342. package/dist/core/ingestion/scope-extractor-bridge.js +2 -2
  343. package/dist/core/ingestion/scope-extractor.js +13 -0
  344. package/dist/core/ingestion/scope-resolution/contract/scope-resolver.d.ts +181 -15
  345. package/dist/core/ingestion/scope-resolution/contract/scope-resolver.js +21 -10
  346. package/dist/core/ingestion/scope-resolution/graph-bridge/edges.js +10 -2
  347. package/dist/core/ingestion/scope-resolution/graph-bridge/ids.d.ts +7 -1
  348. package/dist/core/ingestion/scope-resolution/graph-bridge/ids.js +58 -6
  349. package/dist/core/ingestion/scope-resolution/graph-bridge/node-lookup.js +24 -5
  350. package/dist/core/ingestion/scope-resolution/passes/free-call-fallback.d.ts +68 -1
  351. package/dist/core/ingestion/scope-resolution/passes/free-call-fallback.js +189 -29
  352. package/dist/core/ingestion/scope-resolution/passes/imported-return-types.js +21 -1
  353. package/dist/core/ingestion/scope-resolution/passes/receiver-bound-calls.js +1 -1
  354. package/dist/core/ingestion/scope-resolution/pipeline/phase.d.ts +8 -11
  355. package/dist/core/ingestion/scope-resolution/pipeline/phase.js +171 -50
  356. package/dist/core/ingestion/scope-resolution/pipeline/registry.d.ts +3 -4
  357. package/dist/core/ingestion/scope-resolution/pipeline/registry.js +9 -4
  358. package/dist/core/ingestion/scope-resolution/pipeline/run.d.ts +28 -5
  359. package/dist/core/ingestion/scope-resolution/pipeline/run.js +191 -24
  360. package/dist/core/ingestion/scope-resolution/pipeline/validate-bindings-immutability.js +31 -0
  361. package/dist/core/ingestion/scope-resolution/scope/walkers.d.ts +72 -0
  362. package/dist/core/ingestion/scope-resolution/scope/walkers.js +440 -39
  363. package/dist/core/ingestion/scope-resolution/workspace-index.d.ts +18 -2
  364. package/dist/core/ingestion/scope-resolution/workspace-index.js +94 -7
  365. package/dist/core/ingestion/tree-sitter-queries.d.ts +14 -14
  366. package/dist/core/ingestion/tree-sitter-queries.js +380 -158
  367. package/dist/core/ingestion/ts-js-hoc-utils.d.ts +12 -0
  368. package/dist/core/ingestion/ts-js-hoc-utils.js +105 -0
  369. package/dist/core/ingestion/type-env.d.ts +2 -1
  370. package/dist/core/ingestion/type-env.js +6 -8
  371. package/dist/core/ingestion/type-extractors/c-cpp.js +8 -10
  372. package/dist/core/ingestion/type-extractors/csharp.js +18 -34
  373. package/dist/core/ingestion/type-extractors/go.js +2 -10
  374. package/dist/core/ingestion/type-extractors/jvm.js +6 -5
  375. package/dist/core/ingestion/type-extractors/php.js +1 -1
  376. package/dist/core/ingestion/type-extractors/python.js +1 -1
  377. package/dist/core/ingestion/type-extractors/ruby.js +2 -2
  378. package/dist/core/ingestion/type-extractors/rust.js +0 -16
  379. package/dist/core/ingestion/type-extractors/shared.d.ts +2 -2
  380. package/dist/core/ingestion/type-extractors/shared.js +25 -11
  381. package/dist/core/ingestion/type-extractors/swift.js +5 -5
  382. package/dist/core/ingestion/type-extractors/types.d.ts +1 -1
  383. package/dist/core/ingestion/type-extractors/typescript.js +1 -1
  384. package/dist/core/ingestion/utils/ast-helpers.d.ts +119 -1
  385. package/dist/core/ingestion/utils/ast-helpers.js +260 -13
  386. package/dist/core/ingestion/utils/callable-labels.d.ts +13 -0
  387. package/dist/core/ingestion/utils/callable-labels.js +14 -0
  388. package/dist/core/ingestion/utils/deferred-resolution-profile.d.ts +10 -0
  389. package/dist/core/ingestion/utils/deferred-resolution-profile.js +30 -0
  390. package/dist/core/ingestion/utils/heap-probe.d.ts +20 -0
  391. package/dist/core/ingestion/utils/heap-probe.js +39 -0
  392. package/dist/core/ingestion/utils/heritage-marker.d.ts +33 -0
  393. package/dist/core/ingestion/utils/heritage-marker.js +41 -0
  394. package/dist/core/ingestion/utils/qualified-name.d.ts +37 -0
  395. package/dist/core/ingestion/utils/qualified-name.js +67 -0
  396. package/dist/core/ingestion/variable-extractors/configs/c-cpp.js +49 -0
  397. package/dist/core/ingestion/variable-extractors/configs/dart.js +76 -62
  398. package/dist/core/ingestion/variable-extractors/configs/go.js +74 -7
  399. package/dist/core/ingestion/variable-extractors/configs/jvm.js +35 -8
  400. package/dist/core/ingestion/variable-extractors/generic.js +40 -12
  401. package/dist/core/ingestion/variable-types.d.ts +9 -0
  402. package/dist/core/ingestion/vue-sfc-extractor.d.ts +97 -7
  403. package/dist/core/ingestion/vue-sfc-extractor.js +433 -11
  404. package/dist/core/ingestion/workers/parse-worker.d.ts +0 -11
  405. package/dist/core/ingestion/workers/parse-worker.js +358 -187
  406. package/dist/core/ingestion/workers/worker-pool.d.ts +78 -9
  407. package/dist/core/ingestion/workers/worker-pool.js +346 -49
  408. package/dist/core/lbug/csv-generator.js +20 -2
  409. package/dist/core/lbug/lbug-adapter.js +29 -10
  410. package/dist/core/lbug/native-check.js +17 -5
  411. package/dist/core/lbug/pool-adapter.d.ts +0 -19
  412. package/dist/core/lbug/pool-adapter.js +40 -77
  413. package/dist/core/lbug/query-result-utils.d.ts +19 -0
  414. package/dist/core/lbug/query-result-utils.js +28 -0
  415. package/dist/core/run-analyze.d.ts +9 -2
  416. package/dist/core/run-analyze.js +24 -3
  417. package/dist/core/tree-sitter/parser-loader.d.ts +13 -0
  418. package/dist/core/tree-sitter/parser-loader.js +4 -0
  419. package/dist/core/tree-sitter/safe-parse.d.ts +70 -3
  420. package/dist/core/tree-sitter/safe-parse.js +214 -11
  421. package/dist/core/wiki/generator.js +13 -5
  422. package/dist/core/wiki/graph-queries.d.ts +3 -0
  423. package/dist/core/wiki/graph-queries.js +9 -1
  424. package/dist/core/wiki/llm-client.d.ts +1 -1
  425. package/dist/core/wiki/llm-client.js +7 -2
  426. package/dist/core/wiki/local-cli-client.d.ts +2 -1
  427. package/dist/core/wiki/local-cli-client.js +62 -4
  428. package/dist/mcp/compatible-stdio-transport.d.ts +3 -0
  429. package/dist/mcp/compatible-stdio-transport.js +22 -0
  430. package/dist/mcp/core/embedder.d.ts +1 -1
  431. package/dist/mcp/core/embedder.js +13 -1
  432. package/dist/mcp/local/local-backend.d.ts +37 -5
  433. package/dist/mcp/local/local-backend.js +227 -129
  434. package/dist/mcp/resources.js +3 -3
  435. package/dist/mcp/server.js +9 -1
  436. package/dist/storage/git.d.ts +11 -0
  437. package/dist/storage/git.js +30 -0
  438. package/dist/storage/parse-cache.d.ts +23 -1
  439. package/dist/storage/parse-cache.js +138 -32
  440. package/dist/storage/parsedfile-store.d.ts +142 -0
  441. package/dist/storage/parsedfile-store.js +367 -0
  442. package/dist/storage/repo-manager.d.ts +2 -1
  443. package/dist/storage/scope-index-store.d.ts +114 -0
  444. package/dist/storage/scope-index-store.js +236 -0
  445. package/dist/types/pipeline.d.ts +6 -3
  446. package/hooks/antigravity/gitnexus-antigravity-hook.cjs +2 -1
  447. package/hooks/claude/gitnexus-hook.cjs +2 -1
  448. package/hooks/claude/resolve-analyze-cmd.cjs +323 -0
  449. package/package.json +4 -5
  450. package/scripts/bench-scope-resolution.ts +1 -3
  451. package/scripts/cross-platform-tests.ts +4 -1
  452. package/skills/gitnexus-cli.md +8 -6
  453. package/skills/gitnexus-debugging.md +15 -15
  454. package/skills/gitnexus-exploring.md +11 -11
  455. package/skills/gitnexus-guide.md +1 -1
  456. package/skills/gitnexus-impact-analysis.md +10 -10
  457. package/skills/gitnexus-pr-review.md +19 -19
  458. package/skills/gitnexus-refactoring.md +25 -25
  459. package/web/assets/{agent-BRX-afm3.js → agent-EkX7webX.js} +156 -131
  460. package/web/assets/{architectureDiagram-UL44E2DR-B1oYB8-c.js → architectureDiagram-UL44E2DR-BoczH8cv.js} +1 -1
  461. package/web/assets/{chunk-LCXTWHL2-SPC6pgWI.js → chunk-LCXTWHL2-By5HB3b-.js} +1 -1
  462. package/web/assets/{chunk-RG4AUYOV-DZXr4Yv3.js → chunk-RG4AUYOV-BQE_DkpL.js} +1 -1
  463. package/web/assets/{classDiagram-KGZ6W3CR-BqpOj8L9.js → classDiagram-KGZ6W3CR-Dj_02GUH.js} +1 -1
  464. package/web/assets/{classDiagram-v2-72OJOZXJ-FmElywK2.js → classDiagram-v2-72OJOZXJ-D-NArMpf.js} +1 -1
  465. package/web/assets/{diagram-3NCE3AQN-BWtJXMDq.js → diagram-3NCE3AQN-VXtXDO95.js} +1 -1
  466. package/web/assets/{diagram-GF46GFSD-Hh-fChxU.js → diagram-GF46GFSD-B1qab2Ah.js} +1 -1
  467. package/web/assets/{diagram-QXG6HAR7-DYeQHxGU.js → diagram-QXG6HAR7-BSCHGzzT.js} +1 -1
  468. package/web/assets/{diagram-WEQXMOUZ-DYGU4T0y.js → diagram-WEQXMOUZ-DHtknmNT.js} +1 -1
  469. package/web/assets/{erDiagram-L5TCEMPS-bN3wlP2A.js → erDiagram-L5TCEMPS-Db-IYTmm.js} +1 -1
  470. package/web/assets/{flowDiagram-H6V6AXG4-YACVtF3-.js → flowDiagram-H6V6AXG4-BHDoyVoW.js} +1 -1
  471. package/web/assets/{index-BhnAdWTt.js → index-BR0IhgbR.js} +10 -10
  472. package/web/assets/{infoDiagram-3YFTVSEB-BWBzD28-.js → infoDiagram-3YFTVSEB-6h8wbWEe.js} +1 -1
  473. package/web/assets/{ishikawaDiagram-BNXS4ZKH-B8qYT-j9.js → ishikawaDiagram-BNXS4ZKH-Dx2OkPk1.js} +1 -1
  474. package/web/assets/{kanban-definition-75IXJCU3-BeoPr5Tl.js → kanban-definition-75IXJCU3-CIIEZfqV.js} +1 -1
  475. package/web/assets/{mindmap-definition-2TDM6QVE-CdLLN_so.js → mindmap-definition-2TDM6QVE-DUAqydRq.js} +1 -1
  476. package/web/assets/{pieDiagram-CU6KROY3-DEd2a_k_.js → pieDiagram-CU6KROY3-BntYuYZa.js} +1 -1
  477. package/web/assets/{requirementDiagram-JXO7QTGE-QNeTo5C_.js → requirementDiagram-JXO7QTGE-QCD6I29n.js} +1 -1
  478. package/web/assets/{sequenceDiagram-VS2MUI6T-BHC7q7yJ.js → sequenceDiagram-VS2MUI6T-DScFwLz2.js} +1 -1
  479. package/web/assets/{stateDiagram-7D4R322I-KONnc2Px.js → stateDiagram-7D4R322I-AkRAm6Hl.js} +1 -1
  480. package/web/assets/{stateDiagram-v2-36443NZ5-C2QfuMlu.js → stateDiagram-v2-36443NZ5-BCK1vigR.js} +1 -1
  481. package/web/assets/{timeline-definition-O6YCAMPW-D4t4NJx1.js → timeline-definition-O6YCAMPW-BvpIVXjX.js} +1 -1
  482. package/web/assets/{vennDiagram-MWXL3ELB-6bctC9Yg.js → vennDiagram-MWXL3ELB-BYGWk6dK.js} +1 -1
  483. package/web/assets/{wardleyDiagram-CUQ6CDDI-BPZYNTvC.js → wardleyDiagram-CUQ6CDDI-Dk1z7H2T.js} +1 -1
  484. package/web/assets/{xychartDiagram-N2JHSOCM-lBI9O6DW.js → xychartDiagram-N2JHSOCM-2N6NCSWN.js} +1 -1
  485. package/web/index.html +1 -1
  486. package/dist/_shared/scope-resolution/shadow/aggregate.d.ts +0 -63
  487. package/dist/_shared/scope-resolution/shadow/aggregate.d.ts.map +0 -1
  488. package/dist/_shared/scope-resolution/shadow/aggregate.js +0 -122
  489. package/dist/_shared/scope-resolution/shadow/aggregate.js.map +0 -1
  490. package/dist/_shared/scope-resolution/shadow/diff.d.ts +0 -59
  491. package/dist/_shared/scope-resolution/shadow/diff.d.ts.map +0 -1
  492. package/dist/_shared/scope-resolution/shadow/diff.js +0 -79
  493. package/dist/_shared/scope-resolution/shadow/diff.js.map +0 -1
  494. package/dist/core/ingestion/ast-cache.d.ts +0 -26
  495. package/dist/core/ingestion/ast-cache.js +0 -48
  496. package/dist/core/ingestion/heritage-extractors/configs/go.d.ts +0 -13
  497. package/dist/core/ingestion/heritage-extractors/configs/go.js +0 -20
  498. package/dist/core/ingestion/heritage-extractors/configs/ruby.d.ts +0 -18
  499. package/dist/core/ingestion/heritage-extractors/configs/ruby.js +0 -65
  500. package/dist/core/ingestion/heritage-extractors/generic.d.ts +0 -23
  501. package/dist/core/ingestion/heritage-extractors/generic.js +0 -47
  502. package/dist/core/ingestion/heritage-processor.d.ts +0 -54
  503. package/dist/core/ingestion/heritage-processor.js +0 -367
  504. package/dist/core/ingestion/heritage-types.d.ts +0 -73
  505. package/dist/core/ingestion/heritage-types.js +0 -2
  506. package/dist/core/ingestion/import-processor.d.ts +0 -23
  507. package/dist/core/ingestion/import-processor.js +0 -377
  508. package/dist/core/ingestion/model/heritage-map.d.ts +0 -105
  509. package/dist/core/ingestion/model/heritage-map.js +0 -294
  510. package/dist/core/ingestion/model/resolution-context.d.ts +0 -93
  511. package/dist/core/ingestion/model/resolution-context.js +0 -337
  512. package/dist/core/ingestion/named-bindings/csharp.d.ts +0 -3
  513. package/dist/core/ingestion/named-bindings/csharp.js +0 -37
  514. package/dist/core/ingestion/named-bindings/java.d.ts +0 -3
  515. package/dist/core/ingestion/named-bindings/java.js +0 -29
  516. package/dist/core/ingestion/named-bindings/kotlin.d.ts +0 -3
  517. package/dist/core/ingestion/named-bindings/kotlin.js +0 -36
  518. package/dist/core/ingestion/named-bindings/php.d.ts +0 -3
  519. package/dist/core/ingestion/named-bindings/php.js +0 -61
  520. package/dist/core/ingestion/named-bindings/python.d.ts +0 -3
  521. package/dist/core/ingestion/named-bindings/python.js +0 -49
  522. package/dist/core/ingestion/named-bindings/rust.d.ts +0 -3
  523. package/dist/core/ingestion/named-bindings/rust.js +0 -66
  524. package/dist/core/ingestion/named-bindings/types.d.ts +0 -16
  525. package/dist/core/ingestion/named-bindings/types.js +0 -6
  526. package/dist/core/ingestion/named-bindings/typescript.d.ts +0 -3
  527. package/dist/core/ingestion/named-bindings/typescript.js +0 -58
  528. package/dist/core/ingestion/pipeline-phases/cross-file-impl.d.ts +0 -17
  529. package/dist/core/ingestion/pipeline-phases/cross-file-impl.js +0 -209
  530. package/dist/core/ingestion/pipeline-phases/orm-extraction.d.ts +0 -22
  531. package/dist/core/ingestion/pipeline-phases/orm-extraction.js +0 -92
  532. package/dist/core/ingestion/pipeline-phases/wildcard-synthesis.d.ts +0 -70
  533. package/dist/core/ingestion/pipeline-phases/wildcard-synthesis.js +0 -312
  534. package/dist/core/ingestion/registry-primary-flag.d.ts +0 -89
  535. package/dist/core/ingestion/registry-primary-flag.js +0 -122
  536. package/dist/core/ingestion/shadow-harness.d.ts +0 -113
  537. package/dist/core/ingestion/shadow-harness.js +0 -148
  538. package/dist/core/ingestion/utils/ruby-self-call.d.ts +0 -52
  539. package/dist/core/ingestion/utils/ruby-self-call.js +0 -59
  540. package/scripts/ci-list-migrated-languages.ts +0 -24
  541. package/scripts/run-parity.ts +0 -128
@@ -7,6 +7,7 @@ import path from 'path';
7
7
  import os from 'os';
8
8
  import crypto from 'crypto';
9
9
  import lbug from '@ladybugdb/core';
10
+ import { closeQueryResults } from './query-result-utils.js';
10
11
  import { NODE_TABLES, REL_TABLE_NAME, SCHEMA_QUERIES, EMBEDDING_TABLE_NAME, STALE_HASH_SENTINEL, } from './schema.js';
11
12
  import { streamAllCSVsToDisk } from './csv-generator.js';
12
13
  import { extensionManager } from './extension-loader.js';
@@ -153,8 +154,19 @@ const DB_LOCK_RETRY_DELAY_MS = 500;
153
154
  * analyze` and either already happened or will happen on the next run.
154
155
  */
155
156
  export const isReadOnlyDbError = (err) => {
156
- const msg = err instanceof Error ? err.message : String(err);
157
- return /read-only database/i.test(msg);
157
+ // Walk the `cause` chain (bounded) so a wrapped read-only error — e.g. the
158
+ // pool adapter's `new Error('…read-only.', { cause: nativeReadOnlyErr })` —
159
+ // is still detected by callers that only see the wrapper (#2068 follow-up).
160
+ // The same strict regex is re-applied at each level, so a non-read-only
161
+ // chain stays false; the depth bound guards a cyclic `cause`.
162
+ let cur = err;
163
+ for (let depth = 0; depth < 5 && cur != null; depth++) {
164
+ const msg = cur instanceof Error ? cur.message : String(cur);
165
+ if (/read-only database/i.test(msg))
166
+ return true;
167
+ cur = cur instanceof Error ? cur.cause : undefined;
168
+ }
169
+ return false;
158
170
  };
159
171
  const isMissingFileError = (err) => {
160
172
  const errno = err;
@@ -301,13 +313,10 @@ const runWithSessionLock = async (operation) => {
301
313
  }
302
314
  };
303
315
  const normalizeCopyPath = (filePath) => toNativeSafePath(filePath).replace(/\\/g, '/');
316
+ // Single-result convenience wrapper over the shared best-effort closer
317
+ // (drainQueryResult / readQueryRows close one cursor at a time).
304
318
  const closeQueryResult = async (result) => {
305
- try {
306
- await result.close();
307
- }
308
- catch {
309
- // Best-effort cleanup only.
310
- }
319
+ await closeQueryResults(result);
311
320
  };
312
321
  const drainQueryResult = async (queryResult) => {
313
322
  const results = Array.isArray(queryResult) ? queryResult : [queryResult];
@@ -1544,8 +1553,9 @@ export const queryImporters = async (targetFilePath) => {
1544
1553
  WHERE r.type = 'IMPORTS' AND b.filePath = '${escaped}'
1545
1554
  RETURN DISTINCT a.filePath AS importer
1546
1555
  `;
1556
+ let queryResult;
1547
1557
  try {
1548
- const queryResult = await conn.query(cypher);
1558
+ queryResult = await conn.query(cypher);
1549
1559
  const result = Array.isArray(queryResult) ? queryResult[0] : queryResult;
1550
1560
  const rows = await result.getAll();
1551
1561
  const out = [];
@@ -1559,6 +1569,10 @@ export const queryImporters = async (targetFilePath) => {
1559
1569
  catch {
1560
1570
  return [];
1561
1571
  }
1572
+ finally {
1573
+ if (queryResult)
1574
+ await closeQueryResults(queryResult);
1575
+ }
1562
1576
  };
1563
1577
  /**
1564
1578
  * Drop every Community and Process node (and their MEMBER_OF /
@@ -1573,8 +1587,9 @@ export const deleteAllCommunitiesAndProcesses = async () => {
1573
1587
  }
1574
1588
  let nodesDeleted = 0;
1575
1589
  for (const label of ['Community', 'Process']) {
1590
+ let countResult;
1576
1591
  try {
1577
- const countResult = await conn.query(`MATCH (n:${label}) RETURN count(n) AS cnt`);
1592
+ countResult = await conn.query(`MATCH (n:${label}) RETURN count(n) AS cnt`);
1578
1593
  const result = Array.isArray(countResult) ? countResult[0] : countResult;
1579
1594
  const rows = await result.getAll();
1580
1595
  const count = Number(rows[0]?.cnt ?? rows[0]?.[0] ?? 0);
@@ -1586,6 +1601,10 @@ export const deleteAllCommunitiesAndProcesses = async () => {
1586
1601
  catch {
1587
1602
  // Table may not exist yet on a freshly-initialized DB — fine.
1588
1603
  }
1604
+ finally {
1605
+ if (countResult)
1606
+ await closeQueryResults(countResult);
1607
+ }
1589
1608
  }
1590
1609
  return { nodesDeleted };
1591
1610
  };
@@ -36,11 +36,18 @@ export function checkLbugNative(overridePkgDir) {
36
36
  'To repair:',
37
37
  ` node ${path.join(pkgDir, 'install.js')}`,
38
38
  '',
39
- 'If using bun, add to package.json and reinstall:',
40
- ' "trustedDependencies": ["@ladybugdb/core"]',
41
- '',
42
- 'Also check that npm is not configured with ignore-scripts=true',
43
- '(in .npmrc or via --ignore-scripts).',
39
+ 'Common causes:',
40
+ ' - pnpm dlx / pnpx skip build scripts by default (security model). Options:',
41
+ ' # Keep pnpm dlx — explicitly allow the required builds:',
42
+ ' pnpm --allow-build=@ladybugdb/core --allow-build=gitnexus --allow-build=tree-sitter \\',
43
+ ' dlx gitnexus@latest serve',
44
+ ' # Or install globally with build scripts allowed (pnpm 10.2+):',
45
+ ' pnpm add -g --allow-build=@ladybugdb/core --allow-build=gitnexus --allow-build=tree-sitter gitnexus',
46
+ ' # Or npm i -g gitnexus@latest (bare npx on npm 11 may crash before gitnexus runs).',
47
+ ' - bun: add to package.json and reinstall:',
48
+ ' "trustedDependencies": ["@ladybugdb/core"]',
49
+ ' - npm configured with ignore-scripts=true',
50
+ ' (in .npmrc or via --ignore-scripts).',
44
51
  ].join('\n'),
45
52
  };
46
53
  }
@@ -62,6 +69,11 @@ export function checkLbugNative(overridePkgDir) {
62
69
  'To repair:',
63
70
  ` node ${path.join(pkgDir, 'install.js')}`,
64
71
  '',
72
+ 'If install scripts were skipped (pnpm dlx / pnpx / ignore-scripts):',
73
+ ' pnpm --allow-build=@ladybugdb/core --allow-build=gitnexus --allow-build=tree-sitter \\',
74
+ ' dlx gitnexus@latest serve',
75
+ ' pnpm add -g --allow-build=@ladybugdb/core --allow-build=gitnexus --allow-build=tree-sitter gitnexus',
76
+ '',
65
77
  'If using bun, add to package.json and reinstall:',
66
78
  ' "trustedDependencies": ["@ladybugdb/core"]',
67
79
  ].join('\n'),
@@ -15,25 +15,6 @@
15
15
  * from the same Database is the officially supported concurrency pattern.
16
16
  */
17
17
  import lbug from '@ladybugdb/core';
18
- /**
19
- * Probe whether a Windows FTS extension binary is locally installed under
20
- * ~/.lbdb/extension/<any-version>/win_amd64/fts/. Returns true on the first
21
- * version dir whose libfts.lbug_extension exists on disk; false if the
22
- * extension root is missing or contains no FTS binary.
23
- *
24
- * Gates the Windows skip-FTS-load guard below so we only skip the load
25
- * when no extension binary is present. When at least one binary exists,
26
- * loadFTSExtension is called with policy: 'load-only' — LadybugDB resolves
27
- * LOAD EXTENSION fts to its version-specific path internally, and the
28
- * ExtensionManager's tryLoad try/catch handles version-mismatch errors
29
- * cleanly without ever attempting dlopen of a stale binary. The install
30
- * path that the #1199/#1217 SIGSEGV documented is never exercised at
31
- * query time.
32
- *
33
- * Exported so unit tests can exercise the probe directly against a
34
- * temp-dir plus spied `os.homedir()` — see lbug-pool-win-fts-probe.test.ts.
35
- */
36
- export declare function hasLocalWinFtsExtension(): Promise<boolean>;
37
18
  /**
38
19
  * Listeners notified when a pool entry is torn down (LRU eviction, idle
39
20
  * timeout, explicit close). Used by upper layers (e.g. the BM25 search
@@ -15,49 +15,11 @@
15
15
  * from the same Database is the officially supported concurrency pattern.
16
16
  */
17
17
  import fs from 'fs/promises';
18
- import os from 'os';
19
- import path from 'path';
20
18
  import lbug from '@ladybugdb/core';
21
19
  import { isReadOnlyDbError, loadFTSExtension } from './lbug-adapter.js';
20
+ import { closeQueryResults } from './query-result-utils.js';
22
21
  import { createLbugDatabase, isWalCorruptionError, toNativeSafePath, WAL_RECOVERY_SUGGESTION, } from './lbug-config.js';
23
22
  import { isMissingFsError, isMissingShadowSidecarError, isReadOnlyShadowReplayError, preflightLbugSidecars, quarantineWalForMissingShadow, renameFailureMessage, statIfExists, } from './sidecar-recovery.js';
24
- /**
25
- * Probe whether a Windows FTS extension binary is locally installed under
26
- * ~/.lbdb/extension/<any-version>/win_amd64/fts/. Returns true on the first
27
- * version dir whose libfts.lbug_extension exists on disk; false if the
28
- * extension root is missing or contains no FTS binary.
29
- *
30
- * Gates the Windows skip-FTS-load guard below so we only skip the load
31
- * when no extension binary is present. When at least one binary exists,
32
- * loadFTSExtension is called with policy: 'load-only' — LadybugDB resolves
33
- * LOAD EXTENSION fts to its version-specific path internally, and the
34
- * ExtensionManager's tryLoad try/catch handles version-mismatch errors
35
- * cleanly without ever attempting dlopen of a stale binary. The install
36
- * path that the #1199/#1217 SIGSEGV documented is never exercised at
37
- * query time.
38
- *
39
- * Exported so unit tests can exercise the probe directly against a
40
- * temp-dir plus spied `os.homedir()` — see lbug-pool-win-fts-probe.test.ts.
41
- */
42
- export async function hasLocalWinFtsExtension() {
43
- try {
44
- const extRoot = path.join(os.homedir(), '.lbdb', 'extension');
45
- const versions = await fs.readdir(extRoot);
46
- for (const v of versions) {
47
- try {
48
- await fs.stat(path.join(extRoot, v, 'win_amd64', 'fts', 'libfts.lbug_extension'));
49
- return true;
50
- }
51
- catch {
52
- /* missing for this version, keep looking */
53
- }
54
- }
55
- }
56
- catch {
57
- /* no .lbdb/extension dir */
58
- }
59
- return false;
60
- }
61
23
  const pool = new Map();
62
24
  const poolCloseListeners = new Set();
63
25
  /**
@@ -151,6 +113,18 @@ function closeOne(repoId) {
151
113
  if (!entry)
152
114
  return;
153
115
  entry.closed = true;
116
+ // Reject any callers still queued for a connection: the pool is going away
117
+ // (re-init / teardown / LRU eviction), so they must fail fast with an
118
+ // actionable error instead of hanging until WAITER_TIMEOUT_MS and then
119
+ // surfacing a misleading "pool exhausted" (#2068 follow-up). Draining the
120
+ // queue also guarantees checkin() below finds no waiter expecting a
121
+ // connection, so a connection returned after close is simply closed.
122
+ if (entry.waiters.length > 0) {
123
+ const closedErr = new Error(`LadybugDB connection pool closed for repo "${repoId}" (re-init/teardown); retry the query.`);
124
+ for (const waiter of entry.waiters)
125
+ waiter.reject(closedErr);
126
+ entry.waiters.length = 0;
127
+ }
154
128
  // Close available connections — fire-and-forget with .catch() to prevent
155
129
  // unhandled rejections. Native close() returns Promise<void> but can crash
156
130
  // the N-API destructor on macOS/Windows; deferring to process exit lets
@@ -522,28 +496,7 @@ async function doInitLbug(repoId, dbPath) {
522
496
  // install; analyze owns extension installation. If LOAD fails, search
523
497
  // features degrade gracefully and the user-facing query path proceeds.
524
498
  if (!shared.ftsLoaded) {
525
- // Windows guard: LOAD EXTENSION fts crashes with SIGSEGV on Windows during
526
- // *install* — the @ladybugdb/core out-of-process installer hits an unhandled
527
- // error path that signals SIGSEGV instead of throwing (see #1199, #1217).
528
- // The previous unconditional skip was over-broad: it also disabled FTS on
529
- // hosts where the binary was already on disk and only needed LOAD, leaving
530
- // BM25 silently degraded with no error path (see #1690).
531
- //
532
- // Probe ~/.lbdb/extension/*/win_amd64/fts/ first. If any binary is on disk
533
- // we run loadFTSExtension(..., 'load-only'); the install path is never
534
- // exercised, and LadybugDB's version-specific resolution + ExtensionManager
535
- // try/catch handle stale/zero-byte siblings cleanly (verified empirically
536
- // on Win10 + Node 22.19 + gitnexus 1.6.5 + @ladybugdb/core 0.16.1). With
537
- // no binary at all, we fall back to the upstream skip so install-time
538
- // SIGSEGV continues to be avoided.
539
- if (process.platform === 'win32') {
540
- shared.ftsLoaded = (await hasLocalWinFtsExtension())
541
- ? await loadFTSExtension(available[0], { policy: 'load-only' })
542
- : true;
543
- }
544
- else {
545
- shared.ftsLoaded = await loadFTSExtension(available[0], { policy: 'load-only' });
546
- }
499
+ shared.ftsLoaded = await loadFTSExtension(available[0], { policy: 'load-only' });
547
500
  }
548
501
  // Register pool entry only after all connections are pre-warmed and FTS is
549
502
  // loaded. Concurrent executeQuery calls see either "not initialized"
@@ -599,16 +552,8 @@ export async function initLbugWithDb(repoId, existingDb, dbPath) {
599
552
  // Load FTS extension if not already loaded on this Database.
600
553
  // policy: 'load-only' — same contract as initLbug above; the read pool
601
554
  // must not block on a network install during query execution.
602
- // Windows guard: same probe-then-load policy as doInitLbug above.
603
555
  if (!shared.ftsLoaded) {
604
- if (process.platform === 'win32') {
605
- shared.ftsLoaded = (await hasLocalWinFtsExtension())
606
- ? await loadFTSExtension(available[0], { policy: 'load-only' })
607
- : true;
608
- }
609
- else {
610
- shared.ftsLoaded = await loadFTSExtension(available[0], { policy: 'load-only' });
611
- }
556
+ shared.ftsLoaded = await loadFTSExtension(available[0], { policy: 'load-only' });
612
557
  }
613
558
  pool.set(repoId, {
614
559
  db: existingDb,
@@ -643,15 +588,21 @@ function checkout(entry) {
643
588
  }
644
589
  // At capacity — queue the caller with a timeout.
645
590
  return new Promise((resolve, reject) => {
646
- const waiter = (conn) => {
647
- clearTimeout(timer);
648
- resolve(conn);
591
+ const waiter = {
592
+ resolve: (conn) => {
593
+ clearTimeout(timer);
594
+ resolve(conn);
595
+ },
596
+ reject: (err) => {
597
+ clearTimeout(timer);
598
+ reject(err);
599
+ },
649
600
  };
650
601
  const timer = setTimeout(() => {
651
602
  const idx = entry.waiters.indexOf(waiter);
652
603
  if (idx !== -1)
653
604
  entry.waiters.splice(idx, 1);
654
- reject(new Error(`Connection pool exhausted: timed out after ${WAITER_TIMEOUT_MS}ms waiting for a free connection`));
605
+ waiter.reject(new Error(`Connection pool exhausted: timed out after ${WAITER_TIMEOUT_MS}ms waiting for a free connection`));
655
606
  }, WAITER_TIMEOUT_MS);
656
607
  entry.waiters.push(waiter);
657
608
  });
@@ -672,7 +623,7 @@ function checkin(entry, conn) {
672
623
  if (entry.waiters.length > 0) {
673
624
  // Hand directly to the next waiter — no intermediate available state
674
625
  const waiter = entry.waiters.shift();
675
- waiter(conn);
626
+ waiter.resolve(conn);
676
627
  }
677
628
  else {
678
629
  entry.checkedOut--;
@@ -707,24 +658,36 @@ export const executeParameterized = async (repoId, cypher, params) => {
707
658
  const conn = await checkout(entry);
708
659
  silenceStdout();
709
660
  activeQueryCount++;
661
+ let queryResult;
710
662
  try {
711
663
  const stmt = await withTimeout(conn.prepare(cypher), QUERY_TIMEOUT_MS, 'Prepare');
712
664
  if (!stmt.isSuccess()) {
713
665
  const errMsg = await stmt.getErrorMessage();
714
666
  throw new Error(`Prepare failed: ${errMsg}`);
715
667
  }
716
- const queryResult = await withTimeout(conn.execute(stmt, params), QUERY_TIMEOUT_MS, 'Execute');
668
+ queryResult = await withTimeout(conn.execute(stmt, params), QUERY_TIMEOUT_MS, 'Execute');
717
669
  const result = Array.isArray(queryResult) ? queryResult[0] : queryResult;
718
670
  const rows = await result.getAll();
719
671
  return rows;
720
672
  }
721
673
  catch (err) {
722
674
  if (isReadOnlyDbError(err)) {
723
- throw new Error('Write operations are not allowed. The pool adapter is read-only.');
675
+ // Preserve the native error as `cause` so the original frame/message is
676
+ // not lost behind the friendly read-only message (#2068 follow-up).
677
+ throw new Error('Write operations are not allowed. The pool adapter is read-only.', {
678
+ cause: err,
679
+ });
724
680
  }
725
681
  throw err;
726
682
  }
727
683
  finally {
684
+ // Close the native QueryResult cursor(s) before returning the connection —
685
+ // getAll() drains rows but does not release the native cursor, so without
686
+ // this the cursor leaks for the connection's lifetime (#2068 follow-up).
687
+ // Best-effort via the shared helper; never masks the query result or a real
688
+ // error.
689
+ if (queryResult)
690
+ await closeQueryResults(queryResult);
728
691
  activeQueryCount--;
729
692
  restoreStdout();
730
693
  checkin(entry, conn);
@@ -0,0 +1,19 @@
1
+ import lbug from '@ladybugdb/core';
2
+ /**
3
+ * Best-effort close of one or more native `QueryResult` cursors.
4
+ *
5
+ * `result.getAll()` materializes rows into a JS array but does not release the
6
+ * native cursor — leaving it open holds native resources for the connection's
7
+ * lifetime. Both the pooled adapter (`pool-adapter.ts`) and the direct adapter
8
+ * (`lbug-adapter.ts`) must release cursors after reading; this is the single
9
+ * shared implementation so neither re-rolls the array-normalize + swallow loop
10
+ * (a #2068 follow-up de-dup). Lives in its own leaf module so the two adapters
11
+ * depend on it rather than on each other.
12
+ *
13
+ * `conn.execute()` can return either a single `QueryResult` or an array
14
+ * (multi-statement); this normalizes both. Each close is independent and
15
+ * best-effort: a failing or absent `close()` on one cursor never throws and
16
+ * never prevents the others from closing — a cleanup failure must not mask the
17
+ * query result or a real error at the call site.
18
+ */
19
+ export declare function closeQueryResults(queryResult: lbug.QueryResult | lbug.QueryResult[]): Promise<void>;
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Best-effort close of one or more native `QueryResult` cursors.
3
+ *
4
+ * `result.getAll()` materializes rows into a JS array but does not release the
5
+ * native cursor — leaving it open holds native resources for the connection's
6
+ * lifetime. Both the pooled adapter (`pool-adapter.ts`) and the direct adapter
7
+ * (`lbug-adapter.ts`) must release cursors after reading; this is the single
8
+ * shared implementation so neither re-rolls the array-normalize + swallow loop
9
+ * (a #2068 follow-up de-dup). Lives in its own leaf module so the two adapters
10
+ * depend on it rather than on each other.
11
+ *
12
+ * `conn.execute()` can return either a single `QueryResult` or an array
13
+ * (multi-statement); this normalizes both. Each close is independent and
14
+ * best-effort: a failing or absent `close()` on one cursor never throws and
15
+ * never prevents the others from closing — a cleanup failure must not mask the
16
+ * query result or a real error at the call site.
17
+ */
18
+ export async function closeQueryResults(queryResult) {
19
+ const results = Array.isArray(queryResult) ? queryResult : [queryResult];
20
+ for (const r of results) {
21
+ try {
22
+ await r?.close();
23
+ }
24
+ catch {
25
+ // Best-effort cleanup only.
26
+ }
27
+ }
28
+ }
@@ -48,6 +48,13 @@ export interface AnalyzeOptions {
48
48
  noStats?: boolean;
49
49
  /** Skip installing standard GitNexus skill files to .claude/skills/gitnexus/. */
50
50
  skipSkills?: boolean;
51
+ /**
52
+ * Default branch threaded into generated AGENTS.md / CLAUDE.md so the
53
+ * regression-compare example uses the configured branch instead of a
54
+ * hardcoded "main" (#243). Resolved by the CLI; `undefined` here keeps the
55
+ * "main" fallback for non-CLI callers (e.g. the server analyze worker).
56
+ */
57
+ defaultBranch?: string;
51
58
  /**
52
59
  * User-provided alias for the registry `name` (#829). When set,
53
60
  * forwarded to `registerRepo` so the indexed repo is stored under
@@ -67,8 +74,8 @@ export interface AnalyzeOptions {
67
74
  * Worker pool size override, threaded from the CLI `--workers` flag.
68
75
  * Forwarded to `PipelineOptions.workerPoolSize` so the parse phase
69
76
  * sizes the pool without `analyzeCommand` mutating `process.env`.
70
- * `0` disables the pool (sequential fallback); positive integer sets
71
- * the count; `undefined` defers to the env / auto-formula fallback.
77
+ * Must be a positive integer — `0` hard-errors (sequential parsing was
78
+ * removed); `undefined` defers to the env / auto-formula fallback.
72
79
  */
73
80
  workerPoolSize?: number;
74
81
  }
@@ -12,6 +12,7 @@ import path from 'path';
12
12
  import fs from 'fs/promises';
13
13
  import { execFileSync } from 'child_process';
14
14
  import { runPipelineFromRepo } from './ingestion/pipeline.js';
15
+ import { resetDegradedParseCounter } from './tree-sitter/safe-parse.js';
15
16
  import { initLbug, loadGraphToLbug, getLbugStats, executeQuery, executeWithReusedStatement, closeLbug, loadCachedEmbeddings, deleteNodesForFile, deleteAllCommunitiesAndProcesses, queryImporters, loadFTSExtension, } from './lbug/lbug-adapter.js';
16
17
  import { createSearchFTSIndexes, verifySearchFTSIndexes } from './search/fts-indexes.js';
17
18
  import { resolveAnalyzeInstallPolicy } from './lbug/extension-loader.js';
@@ -20,7 +21,8 @@ import { getStoragePaths, saveMeta, loadMeta, ensureGitNexusIgnored, registerRep
20
21
  import { computeFileHashes, diffFileHashes } from '../storage/file-hash.js';
21
22
  import { extractChangedSubgraph, computeEffectiveWriteSet, } from './incremental/subgraph-extract.js';
22
23
  import { shadowCandidatesFor } from './incremental/shadow-candidates.js';
23
- import { loadParseCache, saveParseCache, pruneCache } from '../storage/parse-cache.js';
24
+ import { loadParseCache, saveParseCache, pruneCache, PARSE_CACHE_VERSION, } from '../storage/parse-cache.js';
25
+ import { getDurableParsedFileDir, pruneAndSaveDurableParsedFileStore, } from '../storage/parsedfile-store.js';
24
26
  import { getCurrentCommit, getRemoteUrl, hasGitDir, getInferredRepoName, resolveRepoIdentityRoot, } from '../storage/git.js';
25
27
  import { generateAIContextFiles } from '../cli/ai-context.js';
26
28
  import { EMBEDDING_TABLE_NAME } from './lbug/schema.js';
@@ -71,6 +73,13 @@ export const PHASE_LABELS = {
71
73
  export async function runFullAnalysis(repoPath, options, callbacks) {
72
74
  const log = (msg) => callbacks.onLog?.(msg);
73
75
  const progress = (phase, percent, message) => callbacks.onProgress(phase, percent, message);
76
+ // Scope the degraded-parse log throttle to this run. On a reused process
77
+ // (e.g. tests, or any host that calls runFullAnalysis more than once) the
78
+ // module-level counter would otherwise stay saturated and suppress every
79
+ // degraded-parse log after the first run. The per-parse worker holds its own
80
+ // counter in its own module instance and is process-scoped, so no separate
81
+ // worker-side reset is needed (see safe-parse.ts ParseTimeoutError contract).
82
+ resetDegradedParseCounter();
74
83
  const { storagePath, lbugPath } = getStoragePaths(repoPath);
75
84
  // Clean up stale KuzuDB files from before the LadybugDB migration.
76
85
  const kuzuResult = await cleanupOldKuzuFiles(storagePath);
@@ -296,7 +305,10 @@ export async function runFullAnalysis(repoPath, options, callbacks) {
296
305
  ? `${p.message || phaseLabel} (${p.detail})`
297
306
  : p.message || phaseLabel;
298
307
  progress(p.phase, scaled, message);
299
- }, { parseCache, workerPoolSize: options.workerPoolSize });
308
+ }, {
309
+ parseCache,
310
+ workerPoolSize: options.workerPoolSize,
311
+ });
300
312
  // ── Phase 2: LadybugDB (60–85%) ──────────────────────────────────
301
313
  progress('lbug', 60, 'Loading into LadybugDB...');
302
314
  // Compute current per-file content hashes from the pipeline's File nodes.
@@ -726,7 +738,15 @@ export async function runFullAnalysis(repoPath, options, callbacks) {
726
738
  if (pruned > 0) {
727
739
  log(`Parse cache: pruned ${pruned} stale chunk entries`);
728
740
  }
729
- await saveParseCache(storagePath, parseCache);
741
+ const savedKeys = await saveParseCache(storagePath, parseCache);
742
+ // Prune the durable ParsedFile store to EXACTLY the parse cache's
743
+ // surviving keys (#2038 warm-cache coverage), so the two content-addressed
744
+ // stores stay coherent: a chunk is "cached" iff both its parse-cache shard
745
+ // and its durable shards exist. A quarantined chunk (in usedKeys but with
746
+ // no parse-cache shard) drops its durable subdir here and re-dispatches
747
+ // next run. Same try/catch — a durable-store write failure must never
748
+ // break an otherwise successful run (next run treats it as a miss).
749
+ await pruneAndSaveDurableParsedFileStore(getDurableParsedFileDir(storagePath), PARSE_CACHE_VERSION, new Set(savedKeys));
730
750
  }
731
751
  catch (e) {
732
752
  log(`Warning: could not save parse cache (${e.message}); continuing.`);
@@ -768,6 +788,7 @@ export async function runFullAnalysis(repoPath, options, callbacks) {
768
788
  skipAgentsMd: options.skipAgentsMd,
769
789
  skipSkills: options.skipSkills,
770
790
  noStats: options.noStats,
791
+ defaultBranch: options.defaultBranch,
771
792
  });
772
793
  }
773
794
  catch {
@@ -1,5 +1,18 @@
1
1
  import Parser from 'tree-sitter';
2
2
  import { SupportedLanguages } from '../../_shared/index.js';
3
+ /**
4
+ * Introspection over the grammar registry for the ABI load-smoke test
5
+ * (`test/unit/parser-loader-abi.test.ts`, #1922). Returns one descriptor per
6
+ * `SOURCES` row — including the `:tsx` variant — so the smoke can assert that
7
+ * EVERY registered grammar loads (required) or "loads OR cleanly reports
8
+ * unavailable" (optional/vendored). Derived from `SOURCES` so adding a grammar
9
+ * automatically widens the smoke's coverage with no second list to maintain.
10
+ */
11
+ export interface GrammarSourceDescriptor {
12
+ key: string;
13
+ optional: boolean;
14
+ }
15
+ export declare const listGrammarSources: () => GrammarSourceDescriptor[];
3
16
  export declare const resolveLanguageKey: (language: SupportedLanguages, filePath?: string) => string;
4
17
  export declare const isLanguageAvailable: (language: SupportedLanguages, filePath?: string) => boolean;
5
18
  export declare const getLanguageGrammar: (language: SupportedLanguages, filePath?: string) => unknown;
@@ -106,6 +106,10 @@ const SOURCES = {
106
106
  'and is not installed (or its native binding failed to build).',
107
107
  },
108
108
  };
109
+ export const listGrammarSources = () => Object.entries(SOURCES).map(([key, source]) => ({
110
+ key,
111
+ optional: source.optional === true,
112
+ }));
109
113
  const loadCache = new Map();
110
114
  const logged = new Set();
111
115
  const logFailure = (key, result) => {
@@ -1,6 +1,73 @@
1
1
  import type Parser from 'tree-sitter';
2
2
  /**
3
- * Parse `sourceText` safely on every platform. See {@link SAFE_PARSE_CHUNK_CHARS}
4
- * for the underlying tree-sitter binding bug this works around.
3
+ * Thrown when a parse exceeds its wall-clock budget (see
4
+ * {@link DEFAULT_PARSE_TIMEOUT_MS}). The parser has already been `reset()` and
5
+ * its budget cleared by the time this propagates, so callers may safely reuse
6
+ * the same parser for the next file.
7
+ *
8
+ * Hard-skip contract: a timeout is fatal for the offending file but MUST NOT
9
+ * abort the run. Every caller is responsible for catching this specific error
10
+ * (`instanceof ParseTimeoutError`), skipping that one file (degrade-and-
11
+ * continue), and re-throwing anything else. Catching it generically and
12
+ * swallowing all errors would mask real bugs, so callers match on the type.
5
13
  */
6
- export declare function parseSourceSafe(parser: Parser, sourceText: string, oldTree?: Parser.Tree, options?: Parser.Options): Parser.Tree;
14
+ export declare class ParseTimeoutError extends Error {
15
+ readonly budgetMs: number;
16
+ readonly label?: string;
17
+ constructor(budgetMs: number, label?: string);
18
+ }
19
+ /**
20
+ * Reset the per-run degraded-parse log throttle. Called at the start of every
21
+ * analysis run (`runFullAnalysis`) so the first-N-then-suppress budget is
22
+ * scoped to a single run rather than to the lifetime of the module (which, on
23
+ * a reused process, would suppress all degraded-parse logs after the first
24
+ * run). Safe to call at any time.
25
+ */
26
+ export declare function resetDegradedParseCounter(): void;
27
+ /**
28
+ * @internal Test-only alias for {@link resetDegradedParseCounter}, kept so the
29
+ * existing `safe-parse.test.ts` import keeps working. Prefer the public name.
30
+ */
31
+ export declare function _resetDegradedParseCounter(): void;
32
+ /**
33
+ * True when the parsed tree contains any ERROR or MISSING node — i.e. the
34
+ * source did not parse cleanly and tree-sitter applied error recovery.
35
+ * `parse` never throws on bad syntax (it recovers into ERROR/MISSING nodes),
36
+ * so this is the only signal callers have that a tree is degraded.
37
+ */
38
+ export declare function parseHadErrors(tree: Parser.Tree): boolean;
39
+ /**
40
+ * Structured diagnostics for a parsed tree. Cheap (reads boolean node
41
+ * properties only); callers that just want a yes/no use {@link parseHadErrors}.
42
+ */
43
+ export declare function getParseDiagnostics(tree: Parser.Tree): {
44
+ hasError: boolean;
45
+ isMissing: boolean;
46
+ };
47
+ /**
48
+ * Parse `sourceText` safely on every platform.
49
+ *
50
+ * This is the single "parse safely" entry point and its contract covers three
51
+ * concerns:
52
+ *
53
+ * 1. **Windows crash workaround.** Inputs longer than 32 767 chars are fed
54
+ * through the chunked `Parser.Input` callback overload to dodge the
55
+ * 0.21.x string-to-buffer SIGSEGV. See {@link SAFE_PARSE_CHUNK_CHARS}.
56
+ *
57
+ * 2. **Runaway-parse timeout.** A per-parse budget (default 15 s, env
58
+ * `GITNEXUS_PARSE_TIMEOUT_MS`, `0` disables) is armed before parsing on
59
+ * both the direct and chunked paths. On timeout the runtime returns
60
+ * `null`; this function `reset()`s the parser, clears the budget, and
61
+ * throws {@link ParseTimeoutError}. The budget is always cleared in a
62
+ * `finally` so it never leaks to the next parse on a reused/singleton
63
+ * parser (`loadParser()` and the worker both reuse one `Parser`).
64
+ *
65
+ * 3. **Intrinsic error detection.** On a successful parse, a degraded tree
66
+ * (`rootNode.hasError`) is logged at `debug` level with throttling, then
67
+ * the tree is **returned anyway** — error recovery is a downgrade, never a
68
+ * drop. Callers wanting the boolean use {@link parseHadErrors}.
69
+ *
70
+ * @param label optional context (e.g. file path) attached to timeout errors
71
+ * and degraded-parse logs. Non-breaking trailing param.
72
+ */
73
+ export declare function parseSourceSafe(parser: Parser, sourceText: string, oldTree?: Parser.Tree, options?: Parser.Options, label?: string): Parser.Tree;