gitnexus 1.6.4-rc.2 → 1.6.4-rc.21

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 (243) hide show
  1. package/README.md +35 -0
  2. package/dist/_shared/index.d.ts +1 -1
  3. package/dist/_shared/index.d.ts.map +1 -1
  4. package/dist/_shared/index.js +1 -1
  5. package/dist/_shared/index.js.map +1 -1
  6. package/dist/_shared/scope-resolution/finalize-algorithm.d.ts +22 -14
  7. package/dist/_shared/scope-resolution/finalize-algorithm.d.ts.map +1 -1
  8. package/dist/_shared/scope-resolution/finalize-algorithm.js +298 -37
  9. package/dist/_shared/scope-resolution/finalize-algorithm.js.map +1 -1
  10. package/dist/_shared/scope-resolution/scope-tree.d.ts +23 -1
  11. package/dist/_shared/scope-resolution/scope-tree.d.ts.map +1 -1
  12. package/dist/_shared/scope-resolution/scope-tree.js +36 -2
  13. package/dist/_shared/scope-resolution/scope-tree.js.map +1 -1
  14. package/dist/_shared/scope-resolution/types.d.ts +47 -3
  15. package/dist/_shared/scope-resolution/types.d.ts.map +1 -1
  16. package/dist/_shared/scope-resolution/types.js +10 -2
  17. package/dist/_shared/scope-resolution/types.js.map +1 -1
  18. package/dist/cli/analyze.d.ts +6 -0
  19. package/dist/cli/analyze.js +35 -0
  20. package/dist/cli/doctor.d.ts +1 -0
  21. package/dist/cli/doctor.js +31 -0
  22. package/dist/cli/index.js +13 -0
  23. package/dist/cli/setup.js +2 -2
  24. package/dist/core/embeddings/config.d.ts +2 -0
  25. package/dist/core/embeddings/config.js +36 -0
  26. package/dist/core/embeddings/embedder.js +11 -6
  27. package/dist/core/embeddings/embedding-pipeline.d.ts +7 -1
  28. package/dist/core/embeddings/embedding-pipeline.js +93 -29
  29. package/dist/core/embeddings/exact-search.d.ts +15 -0
  30. package/dist/core/embeddings/exact-search.js +27 -0
  31. package/dist/core/embeddings/types.d.ts +4 -0
  32. package/dist/core/embeddings/types.js +2 -0
  33. package/dist/core/group/config-parser.js +2 -0
  34. package/dist/core/group/matching.d.ts +3 -3
  35. package/dist/core/group/matching.js +46 -6
  36. package/dist/core/group/storage.js +2 -0
  37. package/dist/core/group/sync.js +1 -1
  38. package/dist/core/group/types.d.ts +18 -0
  39. package/dist/core/ingestion/call-processor.d.ts +3 -3
  40. package/dist/core/ingestion/call-processor.js +58 -65
  41. package/dist/core/ingestion/constants.d.ts +4 -3
  42. package/dist/core/ingestion/constants.js +8 -3
  43. package/dist/core/ingestion/finalize-orchestrator.js +6 -3
  44. package/dist/core/ingestion/heritage-processor.js +2 -2
  45. package/dist/core/ingestion/import-processor.js +1 -1
  46. package/dist/core/ingestion/language-provider.d.ts +8 -0
  47. package/dist/core/ingestion/languages/csharp/captures.js +4 -1
  48. package/dist/core/ingestion/languages/csharp/namespace-siblings.d.ts +14 -13
  49. package/dist/core/ingestion/languages/csharp/namespace-siblings.js +62 -50
  50. package/dist/core/ingestion/languages/python/captures.js +9 -1
  51. package/dist/core/ingestion/languages/python/index.d.ts +1 -1
  52. package/dist/core/ingestion/languages/python/index.js +1 -1
  53. package/dist/core/ingestion/languages/python/simple-hooks.d.ts +3 -1
  54. package/dist/core/ingestion/languages/python/simple-hooks.js +8 -0
  55. package/dist/core/ingestion/languages/python.js +28 -1
  56. package/dist/core/ingestion/languages/swift.js +14 -0
  57. package/dist/core/ingestion/languages/typescript/arity-metadata.d.ts +59 -0
  58. package/dist/core/ingestion/languages/typescript/arity-metadata.js +103 -0
  59. package/dist/core/ingestion/languages/typescript/arity.d.ts +37 -0
  60. package/dist/core/ingestion/languages/typescript/arity.js +54 -0
  61. package/dist/core/ingestion/languages/typescript/cache-stats.d.ts +17 -0
  62. package/dist/core/ingestion/languages/typescript/cache-stats.js +28 -0
  63. package/dist/core/ingestion/languages/typescript/captures.d.ts +28 -0
  64. package/dist/core/ingestion/languages/typescript/captures.js +451 -0
  65. package/dist/core/ingestion/languages/typescript/import-decomposer.d.ts +49 -0
  66. package/dist/core/ingestion/languages/typescript/import-decomposer.js +371 -0
  67. package/dist/core/ingestion/languages/typescript/import-target.d.ts +50 -0
  68. package/dist/core/ingestion/languages/typescript/import-target.js +61 -0
  69. package/dist/core/ingestion/languages/typescript/index.d.ts +94 -0
  70. package/dist/core/ingestion/languages/typescript/index.js +94 -0
  71. package/dist/core/ingestion/languages/typescript/interpret.d.ts +35 -0
  72. package/dist/core/ingestion/languages/typescript/interpret.js +317 -0
  73. package/dist/core/ingestion/languages/typescript/merge-bindings.d.ts +62 -0
  74. package/dist/core/ingestion/languages/typescript/merge-bindings.js +158 -0
  75. package/dist/core/ingestion/languages/typescript/query.d.ts +77 -0
  76. package/dist/core/ingestion/languages/typescript/query.js +778 -0
  77. package/dist/core/ingestion/languages/typescript/receiver-binding.d.ts +59 -0
  78. package/dist/core/ingestion/languages/typescript/receiver-binding.js +171 -0
  79. package/dist/core/ingestion/languages/typescript/scope-resolver.d.ts +16 -0
  80. package/dist/core/ingestion/languages/typescript/scope-resolver.js +113 -0
  81. package/dist/core/ingestion/languages/typescript/simple-hooks.d.ts +71 -0
  82. package/dist/core/ingestion/languages/typescript/simple-hooks.js +131 -0
  83. package/dist/core/ingestion/languages/typescript.js +19 -0
  84. package/dist/core/ingestion/method-extractors/configs/swift.js +3 -4
  85. package/dist/core/ingestion/model/scope-resolution-indexes.d.ts +14 -1
  86. package/dist/core/ingestion/parsing-processor.js +20 -9
  87. package/dist/core/ingestion/pipeline-phases/processes.js +9 -4
  88. package/dist/core/ingestion/pipeline-phases/tools.d.ts +1 -0
  89. package/dist/core/ingestion/pipeline-phases/tools.js +10 -4
  90. package/dist/core/ingestion/registry-primary-flag.d.ts +3 -1
  91. package/dist/core/ingestion/registry-primary-flag.js +4 -1
  92. package/dist/core/ingestion/scope-extractor-bridge.d.ts +5 -2
  93. package/dist/core/ingestion/scope-extractor-bridge.js +7 -2
  94. package/dist/core/ingestion/scope-extractor.js +19 -18
  95. package/dist/core/ingestion/scope-resolution/contract/scope-resolver.d.ts +73 -11
  96. package/dist/core/ingestion/scope-resolution/contract/scope-resolver.js +48 -10
  97. package/dist/core/ingestion/scope-resolution/passes/compound-receiver.js +283 -14
  98. package/dist/core/ingestion/scope-resolution/passes/imported-return-types.d.ts +23 -2
  99. package/dist/core/ingestion/scope-resolution/passes/imported-return-types.js +109 -37
  100. package/dist/core/ingestion/scope-resolution/passes/mro.js +3 -1
  101. package/dist/core/ingestion/scope-resolution/passes/receiver-bound-calls.js +13 -5
  102. package/dist/core/ingestion/scope-resolution/pipeline/phase.js +11 -2
  103. package/dist/core/ingestion/scope-resolution/pipeline/registry.js +2 -0
  104. package/dist/core/ingestion/scope-resolution/pipeline/run.d.ts +8 -0
  105. package/dist/core/ingestion/scope-resolution/pipeline/run.js +21 -5
  106. package/dist/core/ingestion/scope-resolution/pipeline/validate-bindings-immutability.d.ts +39 -0
  107. package/dist/core/ingestion/scope-resolution/pipeline/validate-bindings-immutability.js +65 -0
  108. package/dist/core/ingestion/scope-resolution/scope/walkers.d.ts +54 -11
  109. package/dist/core/ingestion/scope-resolution/scope/walkers.js +105 -30
  110. package/dist/core/ingestion/type-extractors/swift.js +7 -4
  111. package/dist/core/ingestion/utils/ast-helpers.d.ts +2 -0
  112. package/dist/core/ingestion/utils/ast-helpers.js +12 -0
  113. package/dist/core/ingestion/utils/env.d.ts +10 -0
  114. package/dist/core/ingestion/utils/env.js +14 -0
  115. package/dist/core/ingestion/workers/parse-worker.d.ts +1 -0
  116. package/dist/core/ingestion/workers/parse-worker.js +15 -9
  117. package/dist/core/ingestion/workers/worker-pool.d.ts +11 -4
  118. package/dist/core/ingestion/workers/worker-pool.js +244 -48
  119. package/dist/core/lbug/extension-loader.d.ts +86 -0
  120. package/dist/core/lbug/extension-loader.js +184 -0
  121. package/dist/core/lbug/lbug-adapter.d.ts +18 -17
  122. package/dist/core/lbug/lbug-adapter.js +45 -73
  123. package/dist/core/lbug/pool-adapter.js +10 -28
  124. package/dist/core/platform/capabilities.d.ts +24 -0
  125. package/dist/core/platform/capabilities.js +54 -0
  126. package/dist/core/run-analyze.js +36 -9
  127. package/dist/core/search/bm25-index.d.ts +0 -17
  128. package/dist/core/search/bm25-index.js +10 -118
  129. package/dist/core/search/fts-indexes.d.ts +1 -0
  130. package/dist/core/search/fts-indexes.js +7 -0
  131. package/dist/core/search/fts-schema.d.ts +6 -0
  132. package/dist/core/search/fts-schema.js +7 -0
  133. package/dist/mcp/core/embedder.js +11 -4
  134. package/dist/mcp/local/local-backend.js +50 -15
  135. package/dist/server/api.d.ts +5 -0
  136. package/dist/server/api.js +113 -0
  137. package/hooks/claude/gitnexus-hook.cjs +11 -1
  138. package/package.json +6 -5
  139. package/scripts/build-tree-sitter-dart.cjs +42 -0
  140. package/scripts/build-tree-sitter-proto.cjs +1 -1
  141. package/scripts/build.js +22 -2
  142. package/scripts/install-duckdb-extension.mjs +37 -0
  143. package/vendor/tree-sitter-dart/README.md +18 -0
  144. package/vendor/tree-sitter-dart/binding.gyp +31 -0
  145. package/vendor/tree-sitter-dart/bindings/node/binding.cc +20 -0
  146. package/vendor/tree-sitter-dart/bindings/node/index.d.ts +28 -0
  147. package/vendor/tree-sitter-dart/bindings/node/index.js +7 -0
  148. package/vendor/tree-sitter-dart/grammar.js +2895 -0
  149. package/vendor/tree-sitter-dart/package.json +18 -0
  150. package/vendor/tree-sitter-dart/queries/highlights.scm +246 -0
  151. package/vendor/tree-sitter-dart/queries/tags.scm +92 -0
  152. package/vendor/tree-sitter-dart/queries/test.scm +1 -0
  153. package/vendor/tree-sitter-dart/src/grammar.json +12459 -0
  154. package/vendor/tree-sitter-dart/src/node-types.json +15055 -0
  155. package/vendor/tree-sitter-dart/src/parser.c +196127 -0
  156. package/vendor/tree-sitter-dart/src/scanner.c +130 -0
  157. package/vendor/tree-sitter-dart/src/tree_sitter/alloc.h +54 -0
  158. package/vendor/tree-sitter-dart/src/tree_sitter/array.h +290 -0
  159. package/vendor/tree-sitter-dart/src/tree_sitter/parser.h +265 -0
  160. package/vendor/tree-sitter-swift/LICENSE +21 -0
  161. package/vendor/tree-sitter-swift/README.md +139 -0
  162. package/vendor/tree-sitter-swift/bindings/node/index.d.ts +28 -0
  163. package/vendor/tree-sitter-swift/bindings/node/index.js +7 -0
  164. package/vendor/tree-sitter-swift/package.json +28 -0
  165. package/vendor/tree-sitter-swift/prebuilds/darwin-arm64/tree-sitter-swift.node +0 -0
  166. package/vendor/tree-sitter-swift/prebuilds/darwin-x64/tree-sitter-swift.node +0 -0
  167. package/vendor/tree-sitter-swift/prebuilds/linux-arm64/tree-sitter-swift.node +0 -0
  168. package/vendor/tree-sitter-swift/prebuilds/linux-x64/tree-sitter-swift.node +0 -0
  169. package/vendor/tree-sitter-swift/prebuilds/win32-arm64/tree-sitter-swift.node +0 -0
  170. package/vendor/tree-sitter-swift/prebuilds/win32-x64/tree-sitter-swift.node +0 -0
  171. package/vendor/tree-sitter-swift/src/node-types.json +30694 -0
  172. package/web/assets/agent-DaprsFSX.js +597 -0
  173. package/web/assets/architecture-YZFGNWBL-S5CXDPWN-DEdGaPg2.js +1 -0
  174. package/web/assets/architectureDiagram-EMZXCZ2Q-Domyk_gO.js +36 -0
  175. package/web/assets/blockDiagram-IGV67L2C-B_2kD7tM.js +132 -0
  176. package/web/assets/c4Diagram-DFAF54RM-BhJJW8Gg.js +10 -0
  177. package/web/assets/chunk-3GS5O3IE-jlWIjPsl.js +231 -0
  178. package/web/assets/chunk-3YCYZ6SJ-Blq_IzZs.js +1 -0
  179. package/web/assets/chunk-6NTNNK5N-DyPc58pp.js +1 -0
  180. package/web/assets/chunk-7RZVMHOQ-BdIU-RGO.js +321 -0
  181. package/web/assets/chunk-A34GCYZU-BI2i_LdU.js +1 -0
  182. package/web/assets/chunk-AEOMTBSW-D7qjBMHW.js +1 -0
  183. package/web/assets/chunk-CilyBKbf.js +1 -0
  184. package/web/assets/chunk-DJ7UZH7F-i11ywiBl.js +1 -0
  185. package/web/assets/chunk-DKKBVRCY-1SffGI1N.js +4 -0
  186. package/web/assets/chunk-DU5LTGQ6-DaPeiwD5.js +1 -0
  187. package/web/assets/chunk-FXACKDTF-uhhi2PC2.js +159 -0
  188. package/web/assets/chunk-H3VCZNTA-IchcISDt.js +1 -0
  189. package/web/assets/chunk-HN6EAY2L-D7ZFMNrB.js +1 -0
  190. package/web/assets/chunk-KSICW3F5-C2tZmXwv.js +15 -0
  191. package/web/assets/chunk-O5ABG6QK-Bt-Km84H.js +1 -0
  192. package/web/assets/chunk-PK6DOVAG-ChlWY0BQ.js +206 -0
  193. package/web/assets/chunk-RNJOYNJ4-B724K7cW.js +1 -0
  194. package/web/assets/chunk-RWUO3TPN-DYn1XriD.js +1 -0
  195. package/web/assets/chunk-TBF5ZNIQ-DKtDz6ae.js +1 -0
  196. package/web/assets/chunk-TU3PZOEN-DE5Qhc0N.js +1 -0
  197. package/web/assets/chunk-TYMNRAUI-g1h33cq-.js +1 -0
  198. package/web/assets/chunk-VELTKBKT-C9dVN39o.js +1 -0
  199. package/web/assets/chunk-W7ZLLLMY-Du-Hb9yb.js +1 -0
  200. package/web/assets/chunk-WSB5WSVC-B123clsZ.js +1 -0
  201. package/web/assets/chunk-XGPFEOL4-BR7Eue38.js +1 -0
  202. package/web/assets/classDiagram-PPOCWD7C-BglfKSs_.js +1 -0
  203. package/web/assets/classDiagram-v2-23LJLIIU-BSzTM28O.js +1 -0
  204. package/web/assets/context-builder-CqQNhRj1.js +15 -0
  205. package/web/assets/cose-bilkent-PNC4W37J-DCfErU-A.js +1 -0
  206. package/web/assets/dagre-E77IOHMT-tDRRhDoN.js +4 -0
  207. package/web/assets/diagram-H7BISOXX-CUVHlmAh.js +43 -0
  208. package/web/assets/diagram-JC5VWROH-BoyOxulB.js +24 -0
  209. package/web/assets/diagram-LXUTUG65-osr9hb7N.js +10 -0
  210. package/web/assets/diagram-WEHSV5V5-d8nUqS39.js +24 -0
  211. package/web/assets/erDiagram-GCSMX5X6-b-IwOhPS.js +85 -0
  212. package/web/assets/flowDiagram-OTCZ4VVT-Ott2Q0AP.js +162 -0
  213. package/web/assets/ganttDiagram-MUNLMDZQ-BYtgN_5s.js +292 -0
  214. package/web/assets/gitGraph-7Q5UKJZL-54BCDZD5-CFyBIGZq.js +1 -0
  215. package/web/assets/gitGraphDiagram-3HKGZ4G3-CsVD2gn4.js +106 -0
  216. package/web/assets/index-BleGLU8S.css +2 -0
  217. package/web/assets/index-C_xK08EW.js +885 -0
  218. package/web/assets/info-OMHHGYJF-BF2H5H6G-yjAxKEzh.js +1 -0
  219. package/web/assets/infoDiagram-MN7RKWGX-DXK0Unn5.js +2 -0
  220. package/web/assets/ishikawaDiagram-YMYX4NHK-CXsnC2FA.js +70 -0
  221. package/web/assets/journeyDiagram-SO5T7YLQ-BzZ07B-X.js +139 -0
  222. package/web/assets/kanban-definition-LJHFXRCJ-C6_EpAd9.js +89 -0
  223. package/web/assets/katex-GD7MH7QM-CJiOjBBJ.js +261 -0
  224. package/web/assets/mindmap-definition-2EUWGEK5-CCYGWZ1m.js +96 -0
  225. package/web/assets/packet-4T2RLAQJ-EV4IVRXR-B8k4E3IT.js +1 -0
  226. package/web/assets/pie-ZZUOXDRM-N23DN5KN-DdvfY118.js +1 -0
  227. package/web/assets/pieDiagram-3IATQBI2-RyvRlQb4.js +30 -0
  228. package/web/assets/quadrantDiagram-E256RVCF-Bfb6sxCx.js +7 -0
  229. package/web/assets/radar-PYXPWWZC-P6TP7ZYP-1EEDC_yU.js +1 -0
  230. package/web/assets/requirementDiagram-M5DCFWZL-DjvHDyvN.js +84 -0
  231. package/web/assets/sankeyDiagram-L3NBLAOT-CBCbbl8s.js +10 -0
  232. package/web/assets/sequenceDiagram-ZOUHS735-BscU8TUR.js +157 -0
  233. package/web/assets/stateDiagram-MLPALWAM-CJusEK2D.js +1 -0
  234. package/web/assets/stateDiagram-v2-B5LQ5ZB2-DImJ3PXD.js +1 -0
  235. package/web/assets/timeline-definition-5SPVSISX-DigPA1X8.js +120 -0
  236. package/web/assets/treeView-SZITEDCU-5DXDK3XO-CzPDt3aG.js +1 -0
  237. package/web/assets/treemap-W4RFUUIX-WYLRDWKO-B9Iqiorr.js +1 -0
  238. package/web/assets/vennDiagram-IE5QUKF5-C91UkZIf.js +34 -0
  239. package/web/assets/wardley-RL74JXVD-BCRCBASE-x42Qw7hp.js +1 -0
  240. package/web/assets/wardleyDiagram-XU3VSMPF-DloBhI0U.js +20 -0
  241. package/web/assets/xychartDiagram-ZHJ5623Y-BGWJvgwI.js +7 -0
  242. package/web/index.html +21 -0
  243. package/scripts/patch-tree-sitter-swift.cjs +0 -78
@@ -0,0 +1,103 @@
1
+ /**
2
+ * Extract TypeScript arity metadata from a method-like tree-sitter node —
3
+ * `method_definition`, `method_signature`, `abstract_method_signature`,
4
+ * `function_declaration`, `generator_function_declaration`, or
5
+ * `function_signature` (overload signature).
6
+ *
7
+ * Reuses `typescriptMethodConfig.extractParameters` so scope-extracted defs
8
+ * carry the same arity semantics as the legacy parse-worker path:
9
+ * - Rest parameters (`...args: T[]`) collapse `parameterCount` to
10
+ * `undefined`, which `typescriptArityCompatibility` treats as
11
+ * "max unknown" — the candidate stays eligible at
12
+ * `argCount >= required` (mirrors Python `*args` / C# `params`).
13
+ * - Optional (`p?: T`) and defaulted (`p: T = …`) parameters both
14
+ * contribute to `optionalCount`;
15
+ * `requiredParameterCount = total − optionalCount`.
16
+ * - `parameterTypes` collects declared type-annotation text for
17
+ * overload narrowing; TypeScript supports function overloading
18
+ * (`function f(x: string); function f(x: number); function f(x) {}`),
19
+ * so populated types let the registry disambiguate same-arity
20
+ * siblings by declared types.
21
+ * - A literal `'params'` marker is appended for variadic methods so
22
+ * `typescriptArityCompatibility` can detect rest params without
23
+ * re-reading the AST.
24
+ *
25
+ * ## Generics stripping
26
+ *
27
+ * TypeScript parameter types frequently contain generic instantiations
28
+ * (`User<string>`, `Array<User>`, `Promise<User[]>`). For overload
29
+ * narrowing by declared type, we want the "head" name — `User`,
30
+ * `Array`, `Promise` — so `arity-metadata` applies a light strip to
31
+ * each `parameterTypes[i]`:
32
+ *
33
+ * - `Foo<Bar>` → `Foo`
34
+ * - `Foo<Bar, Baz>` → `Foo`
35
+ * - `Foo[]` → `Foo`
36
+ * - `Foo<Bar>[]` → `Foo`
37
+ * - `Foo<Bar<Baz>>` → `Foo` (greedy — strip the outermost once)
38
+ * - plain `Foo` → `Foo`
39
+ *
40
+ * We do NOT strip unions / intersections at this layer — those stay
41
+ * intact because the registry's overload narrowing is a string
42
+ * equality check; union types shouldn't match anything and we prefer
43
+ * "unknown" to "accidental match". `undefined` / `null` in unions
44
+ * (TS strict mode) is handled by `interpret.ts`'s `stripNullableUnion`
45
+ * when the name would be consumed as a receiver type — that path is
46
+ * separate from this arity-metadata path.
47
+ *
48
+ * Generic type parameters on the function itself (`function f<T>(x: T)`)
49
+ * do NOT enter here — the method extractor reads the `parameters`
50
+ * field only, which contains value parameters, not type parameters.
51
+ */
52
+ import { typescriptMethodConfig } from '../../method-extractors/configs/typescript-javascript.js';
53
+ export function computeTsArityMetadata(fnNode) {
54
+ const params = typescriptMethodConfig.extractParameters?.(fnNode) ?? [];
55
+ let hasRest = false;
56
+ let optionalCount = 0;
57
+ const types = [];
58
+ for (const p of params) {
59
+ if (p.isVariadic)
60
+ hasRest = true;
61
+ else if (p.isOptional)
62
+ optionalCount++;
63
+ const t = p.type !== null && p.type !== undefined ? stripGenericsAndArraySuffix(p.type) : '';
64
+ types.push(t);
65
+ }
66
+ if (hasRest)
67
+ types.push('params');
68
+ const total = params.length;
69
+ const parameterCount = hasRest ? undefined : total;
70
+ const requiredParameterCount = hasRest ? undefined : total - optionalCount;
71
+ // Only emit parameterTypes when at least one param carries a non-
72
+ // empty type name. An array of all empty strings adds noise to the
73
+ // registry without aiding narrowing — callers treat absence as
74
+ // "types unknown".
75
+ const hasAnyType = types.some((t) => t !== '' && t !== 'params');
76
+ const parameterTypes = hasAnyType || hasRest ? (types.length > 0 ? types : undefined) : undefined;
77
+ return {
78
+ parameterCount,
79
+ requiredParameterCount,
80
+ parameterTypes,
81
+ };
82
+ }
83
+ /**
84
+ * Light generic + array-suffix strip used only for registry overload
85
+ * narrowing. See file-level JSDoc for the exact transformation table.
86
+ *
87
+ * Handles nesting greedily at the outermost level:
88
+ * `Foo<Bar<Baz>>[]` — strip `[]` → `Foo<Bar<Baz>>`, then strip
89
+ * outermost `<>` → `Foo`.
90
+ */
91
+ function stripGenericsAndArraySuffix(raw) {
92
+ let t = raw.trim();
93
+ // Repeatedly peel trailing `[]` pairs, then peel the outermost `<…>`
94
+ // block once. We don't loop the `<>` peel since nesting is rare and
95
+ // the head name is already reached after one peel.
96
+ while (t.endsWith('[]'))
97
+ t = t.slice(0, -2).trim();
98
+ const lt = t.indexOf('<');
99
+ if (lt > 0 && t.endsWith('>')) {
100
+ t = t.slice(0, lt).trim();
101
+ }
102
+ return t;
103
+ }
@@ -0,0 +1,37 @@
1
+ /**
2
+ * TypeScript arity check, accommodating rest parameters and optional
3
+ * (`p?: T`) / defaulted (`p: T = …`) parameters.
4
+ *
5
+ * TypeScript-specific semantics vs C#:
6
+ *
7
+ * - **Optional** — `p?: T` collapses to `isOptional` in the extractor
8
+ * and contributes to `optionalCount`, so `requiredParameterCount`
9
+ * excludes it. Same wire shape as a default-valued parameter.
10
+ * - **Rest** — `...args: T[]` makes `parameterCount` undefined (max
11
+ * unknown) and `parameterTypes` carries a literal `'params'` marker
12
+ * so this hook can detect variadic calls without re-reading the AST
13
+ * (mirrors the C# convention for cross-language consistency).
14
+ * - **Generics** — function-level generic type parameters (`<T, U>`)
15
+ * do NOT count toward arity; the method-extractor reads the
16
+ * `parameters` field and ignores `type_parameters`, so generic
17
+ * count never enters the metadata.
18
+ *
19
+ * The metadata shape (`parameterCount`, `requiredParameterCount`,
20
+ * `parameterTypes`) is synthesized by `arity-metadata.ts` and stored
21
+ * on `SymbolDefinition`. This file consumes that metadata.
22
+ *
23
+ * Verdicts:
24
+ * - `'compatible'` — `requiredParameterCount <= argCount <=
25
+ * parameterCount`, OR the def has rest params
26
+ * (any `argCount >= required`).
27
+ * - `'incompatible'` — argCount is below required, OR above max with
28
+ * no rest params.
29
+ * - `'unknown'` — metadata is absent / incomplete (treated as
30
+ * neutral by the registry).
31
+ *
32
+ * `'incompatible'` is a soft signal in `Registry.lookup` (penalized
33
+ * but still considered when no compatible candidate exists), per
34
+ * RFC §4.
35
+ */
36
+ import type { Callsite, SymbolDefinition } from '../../../../_shared/index.js';
37
+ export declare function typescriptArityCompatibility(def: SymbolDefinition, callsite: Callsite): 'compatible' | 'unknown' | 'incompatible';
@@ -0,0 +1,54 @@
1
+ /**
2
+ * TypeScript arity check, accommodating rest parameters and optional
3
+ * (`p?: T`) / defaulted (`p: T = …`) parameters.
4
+ *
5
+ * TypeScript-specific semantics vs C#:
6
+ *
7
+ * - **Optional** — `p?: T` collapses to `isOptional` in the extractor
8
+ * and contributes to `optionalCount`, so `requiredParameterCount`
9
+ * excludes it. Same wire shape as a default-valued parameter.
10
+ * - **Rest** — `...args: T[]` makes `parameterCount` undefined (max
11
+ * unknown) and `parameterTypes` carries a literal `'params'` marker
12
+ * so this hook can detect variadic calls without re-reading the AST
13
+ * (mirrors the C# convention for cross-language consistency).
14
+ * - **Generics** — function-level generic type parameters (`<T, U>`)
15
+ * do NOT count toward arity; the method-extractor reads the
16
+ * `parameters` field and ignores `type_parameters`, so generic
17
+ * count never enters the metadata.
18
+ *
19
+ * The metadata shape (`parameterCount`, `requiredParameterCount`,
20
+ * `parameterTypes`) is synthesized by `arity-metadata.ts` and stored
21
+ * on `SymbolDefinition`. This file consumes that metadata.
22
+ *
23
+ * Verdicts:
24
+ * - `'compatible'` — `requiredParameterCount <= argCount <=
25
+ * parameterCount`, OR the def has rest params
26
+ * (any `argCount >= required`).
27
+ * - `'incompatible'` — argCount is below required, OR above max with
28
+ * no rest params.
29
+ * - `'unknown'` — metadata is absent / incomplete (treated as
30
+ * neutral by the registry).
31
+ *
32
+ * `'incompatible'` is a soft signal in `Registry.lookup` (penalized
33
+ * but still considered when no compatible candidate exists), per
34
+ * RFC §4.
35
+ */
36
+ export function typescriptArityCompatibility(def, callsite) {
37
+ const max = def.parameterCount;
38
+ const min = def.requiredParameterCount;
39
+ if (max === undefined && min === undefined)
40
+ return 'unknown';
41
+ const argCount = callsite.arity;
42
+ if (!Number.isFinite(argCount) || argCount < 0)
43
+ return 'unknown';
44
+ // Variadic detection: the `arity-metadata` synthesizer appends the
45
+ // literal `'params'` marker to `parameterTypes` when the def has a
46
+ // rest parameter, to avoid re-parsing the AST here.
47
+ const hasRest = def.parameterTypes !== undefined &&
48
+ def.parameterTypes.some((t) => t === 'params' || t.startsWith('params '));
49
+ if (min !== undefined && argCount < min)
50
+ return 'incompatible';
51
+ if (max !== undefined && argCount > max && !hasRest)
52
+ return 'incompatible';
53
+ return 'compatible';
54
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Dev-mode counters for the TypeScript cross-phase scope-captures parse cache.
3
+ *
4
+ * Gated by `PROF_SCOPE_RESOLUTION=1`. In production the module-level `PROF`
5
+ * constant is `false` and V8 folds every increment site into dead code, so the
6
+ * hot path in `captures.ts` stays branch-free.
7
+ *
8
+ * Extracted from `captures.ts` so the production hot-path module doesn't carry
9
+ * a module-global counter and its reset/export surface.
10
+ */
11
+ export declare function recordCacheHit(): void;
12
+ export declare function recordCacheMiss(): void;
13
+ export declare function getTypescriptCaptureCacheStats(): {
14
+ hits: number;
15
+ misses: number;
16
+ };
17
+ export declare function resetTypescriptCaptureCacheStats(): void;
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Dev-mode counters for the TypeScript cross-phase scope-captures parse cache.
3
+ *
4
+ * Gated by `PROF_SCOPE_RESOLUTION=1`. In production the module-level `PROF`
5
+ * constant is `false` and V8 folds every increment site into dead code, so the
6
+ * hot path in `captures.ts` stays branch-free.
7
+ *
8
+ * Extracted from `captures.ts` so the production hot-path module doesn't carry
9
+ * a module-global counter and its reset/export surface.
10
+ */
11
+ const PROF = process.env.PROF_SCOPE_RESOLUTION === '1';
12
+ let CACHE_HITS = 0;
13
+ let CACHE_MISSES = 0;
14
+ export function recordCacheHit() {
15
+ if (PROF)
16
+ CACHE_HITS++;
17
+ }
18
+ export function recordCacheMiss() {
19
+ if (PROF)
20
+ CACHE_MISSES++;
21
+ }
22
+ export function getTypescriptCaptureCacheStats() {
23
+ return { hits: CACHE_HITS, misses: CACHE_MISSES };
24
+ }
25
+ export function resetTypescriptCaptureCacheStats() {
26
+ CACHE_HITS = 0;
27
+ CACHE_MISSES = 0;
28
+ }
@@ -0,0 +1,28 @@
1
+ /**
2
+ * `emitScopeCaptures` for TypeScript.
3
+ *
4
+ * Drives the TypeScript scope query against tree-sitter-typescript and groups
5
+ * raw matches into `CaptureMatch[]` for the central extractor. Layers
6
+ * synthesized streams on top:
7
+ *
8
+ * 1. **Import decomposition** — each `import_statement` / re-export is
9
+ * re-emitted with `@import.kind/source/name/alias/typeOnly` markers so
10
+ * `interpretTsImport` can recover the `ParsedImport` shape without
11
+ * re-parsing raw text (see `import-decomposer.ts`). Unit 2 adds this;
12
+ * until then, raw `@import.statement` matches flow through as-is.
13
+ * 2. **Dynamic imports** — `import('./m')` is re-emitted as a
14
+ * decomposed `@import.statement` with `@import.kind=dynamic` so the
15
+ * central extractor treats it uniformly with static imports.
16
+ * 3. **Function-decl arity metadata** (Unit 5) — `@declaration.parameter-count`
17
+ * / `@declaration.required-parameter-count` / `@declaration.parameter-types`
18
+ * synthesized onto function-like declarations so the registry can narrow
19
+ * overloads.
20
+ * 4. **Callsite arity metadata** (Unit 5) — `@reference.arity` /
21
+ * `@reference.parameter-types` on every callsite.
22
+ * 5. **Receiver-binding synthesis** (Unit 3) — `this` type anchors on
23
+ * instance methods, with arrow-function lexical-this walk-up.
24
+ *
25
+ * Pure given the input source text. No I/O, no globals consulted.
26
+ */
27
+ import type { CaptureMatch } from '../../../../_shared/index.js';
28
+ export declare function emitTsScopeCaptures(sourceText: string, filePath: string, cachedTree?: unknown): readonly CaptureMatch[];