@veewo/gitnexus 1.3.11 → 1.4.6-rc

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 (181) hide show
  1. package/README.md +37 -80
  2. package/dist/benchmark/agent-context/tool-runner.js +2 -2
  3. package/dist/benchmark/neonspark-candidates.js +3 -3
  4. package/dist/benchmark/tool-runner.js +2 -2
  5. package/dist/cli/ai-context.d.ts +2 -1
  6. package/dist/cli/ai-context.js +16 -12
  7. package/dist/cli/analyze.d.ts +2 -0
  8. package/dist/cli/analyze.js +68 -48
  9. package/dist/cli/augment.js +1 -1
  10. package/dist/cli/eval-server.d.ts +8 -1
  11. package/dist/cli/eval-server.js +30 -13
  12. package/dist/cli/index.js +28 -82
  13. package/dist/cli/lazy-action.d.ts +6 -0
  14. package/dist/cli/lazy-action.js +18 -0
  15. package/dist/cli/mcp.js +3 -1
  16. package/dist/cli/setup.js +87 -48
  17. package/dist/cli/setup.test.js +18 -13
  18. package/dist/cli/skill-gen.d.ts +26 -0
  19. package/dist/cli/skill-gen.js +549 -0
  20. package/dist/cli/status.js +13 -4
  21. package/dist/cli/tool.d.ts +3 -2
  22. package/dist/cli/tool.js +50 -16
  23. package/dist/cli/wiki.js +8 -4
  24. package/dist/config/ignore-service.d.ts +25 -0
  25. package/dist/config/ignore-service.js +76 -0
  26. package/dist/config/supported-languages.d.ts +4 -1
  27. package/dist/config/supported-languages.js +3 -2
  28. package/dist/core/augmentation/engine.js +94 -67
  29. package/dist/core/embeddings/embedder.d.ts +1 -1
  30. package/dist/core/embeddings/embedder.js +1 -1
  31. package/dist/core/embeddings/embedding-pipeline.d.ts +3 -3
  32. package/dist/core/embeddings/embedding-pipeline.js +52 -25
  33. package/dist/core/embeddings/types.d.ts +1 -1
  34. package/dist/core/graph/types.d.ts +7 -2
  35. package/dist/core/ingestion/ast-cache.js +3 -2
  36. package/dist/core/ingestion/call-processor.d.ts +8 -6
  37. package/dist/core/ingestion/call-processor.js +468 -206
  38. package/dist/core/ingestion/call-routing.d.ts +53 -0
  39. package/dist/core/ingestion/call-routing.js +108 -0
  40. package/dist/core/ingestion/constants.d.ts +16 -0
  41. package/dist/core/ingestion/constants.js +16 -0
  42. package/dist/core/ingestion/entry-point-scoring.d.ts +2 -1
  43. package/dist/core/ingestion/entry-point-scoring.js +116 -23
  44. package/dist/core/ingestion/export-detection.d.ts +18 -0
  45. package/dist/core/ingestion/export-detection.js +231 -0
  46. package/dist/core/ingestion/filesystem-walker.js +4 -3
  47. package/dist/core/ingestion/framework-detection.d.ts +19 -4
  48. package/dist/core/ingestion/framework-detection.js +182 -6
  49. package/dist/core/ingestion/heritage-processor.d.ts +13 -5
  50. package/dist/core/ingestion/heritage-processor.js +109 -55
  51. package/dist/core/ingestion/import-processor.d.ts +16 -20
  52. package/dist/core/ingestion/import-processor.js +199 -579
  53. package/dist/core/ingestion/language-config.d.ts +46 -0
  54. package/dist/core/ingestion/language-config.js +167 -0
  55. package/dist/core/ingestion/mro-processor.d.ts +45 -0
  56. package/dist/core/ingestion/mro-processor.js +369 -0
  57. package/dist/core/ingestion/named-binding-extraction.d.ts +61 -0
  58. package/dist/core/ingestion/named-binding-extraction.js +363 -0
  59. package/dist/core/ingestion/parsing-processor.d.ts +4 -1
  60. package/dist/core/ingestion/parsing-processor.js +107 -109
  61. package/dist/core/ingestion/pipeline.d.ts +6 -3
  62. package/dist/core/ingestion/pipeline.js +208 -114
  63. package/dist/core/ingestion/process-processor.js +8 -2
  64. package/dist/core/ingestion/resolution-context.d.ts +53 -0
  65. package/dist/core/ingestion/resolution-context.js +132 -0
  66. package/dist/core/ingestion/resolvers/csharp.d.ts +22 -0
  67. package/dist/core/ingestion/resolvers/csharp.js +109 -0
  68. package/dist/core/ingestion/resolvers/go.d.ts +19 -0
  69. package/dist/core/ingestion/resolvers/go.js +42 -0
  70. package/dist/core/ingestion/resolvers/index.d.ts +18 -0
  71. package/dist/core/ingestion/resolvers/index.js +13 -0
  72. package/dist/core/ingestion/resolvers/jvm.d.ts +23 -0
  73. package/dist/core/ingestion/resolvers/jvm.js +87 -0
  74. package/dist/core/ingestion/resolvers/php.d.ts +15 -0
  75. package/dist/core/ingestion/resolvers/php.js +35 -0
  76. package/dist/core/ingestion/resolvers/python.d.ts +19 -0
  77. package/dist/core/ingestion/resolvers/python.js +52 -0
  78. package/dist/core/ingestion/resolvers/ruby.d.ts +12 -0
  79. package/dist/core/ingestion/resolvers/ruby.js +15 -0
  80. package/dist/core/ingestion/resolvers/rust.d.ts +15 -0
  81. package/dist/core/ingestion/resolvers/rust.js +73 -0
  82. package/dist/core/ingestion/resolvers/standard.d.ts +28 -0
  83. package/dist/core/ingestion/resolvers/standard.js +123 -0
  84. package/dist/core/ingestion/resolvers/utils.d.ts +33 -0
  85. package/dist/core/ingestion/resolvers/utils.js +122 -0
  86. package/dist/core/ingestion/symbol-table.d.ts +21 -1
  87. package/dist/core/ingestion/symbol-table.js +40 -12
  88. package/dist/core/ingestion/tree-sitter-queries.d.ts +13 -10
  89. package/dist/core/ingestion/tree-sitter-queries.js +297 -7
  90. package/dist/core/ingestion/type-env.d.ts +49 -0
  91. package/dist/core/ingestion/type-env.js +611 -0
  92. package/dist/core/ingestion/type-extractors/c-cpp.d.ts +2 -0
  93. package/dist/core/ingestion/type-extractors/c-cpp.js +385 -0
  94. package/dist/core/ingestion/type-extractors/csharp.d.ts +2 -0
  95. package/dist/core/ingestion/type-extractors/csharp.js +383 -0
  96. package/dist/core/ingestion/type-extractors/go.d.ts +2 -0
  97. package/dist/core/ingestion/type-extractors/go.js +467 -0
  98. package/dist/core/ingestion/type-extractors/index.d.ts +22 -0
  99. package/dist/core/ingestion/type-extractors/index.js +31 -0
  100. package/dist/core/ingestion/type-extractors/jvm.d.ts +3 -0
  101. package/dist/core/ingestion/type-extractors/jvm.js +681 -0
  102. package/dist/core/ingestion/type-extractors/php.d.ts +2 -0
  103. package/dist/core/ingestion/type-extractors/php.js +549 -0
  104. package/dist/core/ingestion/type-extractors/python.d.ts +2 -0
  105. package/dist/core/ingestion/type-extractors/python.js +406 -0
  106. package/dist/core/ingestion/type-extractors/ruby.d.ts +2 -0
  107. package/dist/core/ingestion/type-extractors/ruby.js +389 -0
  108. package/dist/core/ingestion/type-extractors/rust.d.ts +2 -0
  109. package/dist/core/ingestion/type-extractors/rust.js +449 -0
  110. package/dist/core/ingestion/type-extractors/shared.d.ts +133 -0
  111. package/dist/core/ingestion/type-extractors/shared.js +703 -0
  112. package/dist/core/ingestion/type-extractors/swift.d.ts +2 -0
  113. package/dist/core/ingestion/type-extractors/swift.js +137 -0
  114. package/dist/core/ingestion/type-extractors/types.d.ts +127 -0
  115. package/dist/core/ingestion/type-extractors/typescript.d.ts +2 -0
  116. package/dist/core/ingestion/type-extractors/typescript.js +494 -0
  117. package/dist/core/ingestion/utils.d.ts +103 -0
  118. package/dist/core/ingestion/utils.js +1085 -4
  119. package/dist/core/ingestion/workers/parse-worker.d.ts +51 -4
  120. package/dist/core/ingestion/workers/parse-worker.js +634 -222
  121. package/dist/core/ingestion/workers/worker-pool.js +8 -0
  122. package/dist/core/{kuzu → lbug}/csv-generator.d.ts +12 -10
  123. package/dist/core/{kuzu → lbug}/csv-generator.js +82 -101
  124. package/dist/core/{kuzu/kuzu-adapter.d.ts → lbug/lbug-adapter.d.ts} +20 -25
  125. package/dist/core/{kuzu/kuzu-adapter.js → lbug/lbug-adapter.js} +150 -122
  126. package/dist/core/{kuzu → lbug}/schema.d.ts +4 -4
  127. package/dist/core/{kuzu → lbug}/schema.js +23 -22
  128. package/dist/core/lbug/schema.test.d.ts +1 -0
  129. package/dist/core/search/bm25-index.d.ts +4 -4
  130. package/dist/core/search/bm25-index.js +12 -11
  131. package/dist/core/search/hybrid-search.d.ts +2 -2
  132. package/dist/core/search/hybrid-search.js +6 -6
  133. package/dist/core/tree-sitter/parser-loader.d.ts +1 -0
  134. package/dist/core/tree-sitter/parser-loader.js +19 -0
  135. package/dist/core/wiki/generator.d.ts +2 -2
  136. package/dist/core/wiki/generator.js +6 -6
  137. package/dist/core/wiki/graph-queries.d.ts +4 -4
  138. package/dist/core/wiki/graph-queries.js +7 -7
  139. package/dist/mcp/compatible-stdio-transport.d.ts +25 -0
  140. package/dist/mcp/compatible-stdio-transport.js +200 -0
  141. package/dist/mcp/core/{kuzu-adapter.d.ts → lbug-adapter.d.ts} +11 -10
  142. package/dist/mcp/core/lbug-adapter.js +327 -0
  143. package/dist/mcp/local/local-backend.d.ts +21 -16
  144. package/dist/mcp/local/local-backend.js +306 -706
  145. package/dist/mcp/local/unity-parity-seed-loader.d.ts +6 -1
  146. package/dist/mcp/local/unity-parity-seed-loader.js +119 -9
  147. package/dist/mcp/local/unity-parity-seed-loader.test.js +95 -7
  148. package/dist/mcp/resources.js +2 -2
  149. package/dist/mcp/server.js +28 -13
  150. package/dist/mcp/staleness.js +2 -2
  151. package/dist/mcp/tools.js +12 -3
  152. package/dist/server/api.js +12 -12
  153. package/dist/server/mcp-http.d.ts +1 -1
  154. package/dist/server/mcp-http.js +1 -1
  155. package/dist/storage/git.js +4 -1
  156. package/dist/storage/repo-manager.d.ts +20 -2
  157. package/dist/storage/repo-manager.js +74 -4
  158. package/dist/types/pipeline.d.ts +1 -1
  159. package/hooks/claude/gitnexus-hook.cjs +149 -46
  160. package/hooks/claude/pre-tool-use.sh +2 -1
  161. package/hooks/claude/session-start.sh +0 -0
  162. package/package.json +20 -4
  163. package/scripts/patch-tree-sitter-swift.cjs +74 -0
  164. package/skills/gitnexus-cli.md +8 -8
  165. package/skills/gitnexus-debugging.md +1 -1
  166. package/skills/gitnexus-exploring.md +1 -1
  167. package/skills/gitnexus-guide.md +1 -1
  168. package/skills/gitnexus-impact-analysis.md +1 -1
  169. package/skills/gitnexus-pr-review.md +163 -0
  170. package/skills/gitnexus-refactoring.md +1 -1
  171. package/dist/cli/claude-hooks.d.ts +0 -22
  172. package/dist/cli/claude-hooks.js +0 -97
  173. package/dist/mcp/core/kuzu-adapter.js +0 -231
  174. /package/dist/core/{kuzu/csv-generator.test.d.ts → ingestion/type-extractors/types.js} +0 -0
  175. /package/dist/core/{kuzu/relationship-pair-buckets.test.d.ts → lbug/csv-generator.test.d.ts} +0 -0
  176. /package/dist/core/{kuzu → lbug}/csv-generator.test.js +0 -0
  177. /package/dist/core/{kuzu → lbug}/relationship-pair-buckets.d.ts +0 -0
  178. /package/dist/core/{kuzu → lbug}/relationship-pair-buckets.js +0 -0
  179. /package/dist/core/{kuzu/schema.test.d.ts → lbug/relationship-pair-buckets.test.d.ts} +0 -0
  180. /package/dist/core/{kuzu → lbug}/relationship-pair-buckets.test.js +0 -0
  181. /package/dist/core/{kuzu → lbug}/schema.test.js +0 -0
@@ -45,6 +45,10 @@ export const TYPESCRIPT_QUERIES = `
45
45
  (import_statement
46
46
  source: (string) @import.source) @import
47
47
 
48
+ ; Re-export statements: export { X } from './y'
49
+ (export_statement
50
+ source: (string) @import.source) @import
51
+
48
52
  (call_expression
49
53
  function: (identifier) @call.name) @call
50
54
 
@@ -52,6 +56,10 @@ export const TYPESCRIPT_QUERIES = `
52
56
  function: (member_expression
53
57
  property: (property_identifier) @call.name)) @call
54
58
 
59
+ ; Constructor calls: new Foo()
60
+ (new_expression
61
+ constructor: (identifier) @call.name) @call
62
+
55
63
  ; Heritage queries - class extends
56
64
  (class_declaration
57
65
  name: (type_identifier) @heritage.class
@@ -66,7 +74,7 @@ export const TYPESCRIPT_QUERIES = `
66
74
  (implements_clause
67
75
  (type_identifier) @heritage.implements))) @heritage.impl
68
76
  `;
69
- // JavaScript queries - works with tree-sitter-javascript
77
+ // JavaScript queries - works with tree-sitter-javascript
70
78
  export const JAVASCRIPT_QUERIES = `
71
79
  (class_declaration
72
80
  name: (identifier) @name) @definition.class
@@ -102,6 +110,10 @@ export const JAVASCRIPT_QUERIES = `
102
110
  (import_statement
103
111
  source: (string) @import.source) @import
104
112
 
113
+ ; Re-export statements: export { X } from './y'
114
+ (export_statement
115
+ source: (string) @import.source) @import
116
+
105
117
  (call_expression
106
118
  function: (identifier) @call.name) @call
107
119
 
@@ -109,6 +121,10 @@ export const JAVASCRIPT_QUERIES = `
109
121
  function: (member_expression
110
122
  property: (property_identifier) @call.name)) @call
111
123
 
124
+ ; Constructor calls: new Foo()
125
+ (new_expression
126
+ constructor: (identifier) @call.name) @call
127
+
112
128
  ; Heritage queries - class extends (JavaScript uses different AST than TypeScript)
113
129
  ; In tree-sitter-javascript, class_heritage directly contains the parent identifier
114
130
  (class_declaration
@@ -130,6 +146,9 @@ export const PYTHON_QUERIES = `
130
146
  (import_from_statement
131
147
  module_name: (dotted_name) @import.source) @import
132
148
 
149
+ (import_from_statement
150
+ module_name: (relative_import) @import.source) @import
151
+
133
152
  (call
134
153
  function: (identifier) @call.name) @call
135
154
 
@@ -162,6 +181,9 @@ export const JAVA_QUERIES = `
162
181
  (method_invocation name: (identifier) @call.name) @call
163
182
  (method_invocation object: (_) name: (identifier) @call.name) @call
164
183
 
184
+ ; Constructor calls: new Foo()
185
+ (object_creation_expression type: (type_identifier) @call.name) @call
186
+
165
187
  ; Heritage - extends class
166
188
  (class_declaration name: (identifier) @heritage.class
167
189
  (superclass (type_identifier) @heritage.extends)) @heritage
@@ -172,10 +194,17 @@ export const JAVA_QUERIES = `
172
194
  `;
173
195
  // C queries - works with tree-sitter-c
174
196
  export const C_QUERIES = `
175
- ; Functions
197
+ ; Functions (direct declarator)
176
198
  (function_definition declarator: (function_declarator declarator: (identifier) @name)) @definition.function
177
199
  (declaration declarator: (function_declarator declarator: (identifier) @name)) @definition.function
178
200
 
201
+ ; Functions returning pointers (pointer_declarator wraps function_declarator)
202
+ (function_definition declarator: (pointer_declarator declarator: (function_declarator declarator: (identifier) @name))) @definition.function
203
+ (declaration declarator: (pointer_declarator declarator: (function_declarator declarator: (identifier) @name))) @definition.function
204
+
205
+ ; Functions returning double pointers (nested pointer_declarator)
206
+ (function_definition declarator: (pointer_declarator declarator: (pointer_declarator declarator: (function_declarator declarator: (identifier) @name)))) @definition.function
207
+
179
208
  ; Structs, Unions, Enums, Typedefs
180
209
  (struct_specifier name: (type_identifier) @name) @definition.struct
181
210
  (union_specifier name: (type_identifier) @name) @definition.union
@@ -202,15 +231,26 @@ export const GO_QUERIES = `
202
231
  ; Types
203
232
  (type_declaration (type_spec name: (type_identifier) @name type: (struct_type))) @definition.struct
204
233
  (type_declaration (type_spec name: (type_identifier) @name type: (interface_type))) @definition.interface
205
- (type_declaration (type_spec name: (type_identifier) @name)) @definition.type
206
234
 
207
235
  ; Imports
208
236
  (import_declaration (import_spec path: (interpreted_string_literal) @import.source)) @import
209
237
  (import_declaration (import_spec_list (import_spec path: (interpreted_string_literal) @import.source))) @import
210
238
 
239
+ ; Struct embedding (anonymous fields = inheritance)
240
+ (type_declaration
241
+ (type_spec
242
+ name: (type_identifier) @heritage.class
243
+ type: (struct_type
244
+ (field_declaration_list
245
+ (field_declaration
246
+ type: (type_identifier) @heritage.extends))))) @definition.struct
247
+
211
248
  ; Calls
212
249
  (call_expression function: (identifier) @call.name) @call
213
250
  (call_expression function: (selector_expression field: (field_identifier) @call.name)) @call
251
+
252
+ ; Struct literal construction: User{Name: "Alice"}
253
+ (composite_literal type: (type_identifier) @call.name) @call
214
254
  `;
215
255
  // C++ queries - works with tree-sitter-cpp
216
256
  export const CPP_QUERIES = `
@@ -220,10 +260,46 @@ export const CPP_QUERIES = `
220
260
  (namespace_definition name: (namespace_identifier) @name) @definition.namespace
221
261
  (enum_specifier name: (type_identifier) @name) @definition.enum
222
262
 
223
- ; Functions & Methods
263
+ ; Typedefs and unions (common in C-style headers and mixed C/C++ code)
264
+ (type_definition declarator: (type_identifier) @name) @definition.typedef
265
+ (union_specifier name: (type_identifier) @name) @definition.union
266
+
267
+ ; Macros
268
+ (preproc_function_def name: (identifier) @name) @definition.macro
269
+ (preproc_def name: (identifier) @name) @definition.macro
270
+
271
+ ; Functions & Methods (direct declarator)
224
272
  (function_definition declarator: (function_declarator declarator: (identifier) @name)) @definition.function
225
273
  (function_definition declarator: (function_declarator declarator: (qualified_identifier name: (identifier) @name))) @definition.method
226
274
 
275
+ ; Functions/methods returning pointers (pointer_declarator wraps function_declarator)
276
+ (function_definition declarator: (pointer_declarator declarator: (function_declarator declarator: (identifier) @name))) @definition.function
277
+ (function_definition declarator: (pointer_declarator declarator: (function_declarator declarator: (qualified_identifier name: (identifier) @name)))) @definition.method
278
+
279
+ ; Functions/methods returning double pointers (nested pointer_declarator)
280
+ (function_definition declarator: (pointer_declarator declarator: (pointer_declarator declarator: (function_declarator declarator: (identifier) @name)))) @definition.function
281
+ (function_definition declarator: (pointer_declarator declarator: (pointer_declarator declarator: (function_declarator declarator: (qualified_identifier name: (identifier) @name))))) @definition.method
282
+
283
+ ; Functions/methods returning references (reference_declarator wraps function_declarator)
284
+ (function_definition declarator: (reference_declarator (function_declarator declarator: (identifier) @name))) @definition.function
285
+ (function_definition declarator: (reference_declarator (function_declarator declarator: (qualified_identifier name: (identifier) @name)))) @definition.method
286
+
287
+ ; Destructors (destructor_name is distinct from identifier in tree-sitter-cpp)
288
+ (function_definition declarator: (function_declarator declarator: (qualified_identifier name: (destructor_name) @name))) @definition.method
289
+
290
+ ; Function declarations / prototypes (common in headers)
291
+ (declaration declarator: (function_declarator declarator: (identifier) @name)) @definition.function
292
+ (declaration declarator: (pointer_declarator declarator: (function_declarator declarator: (identifier) @name))) @definition.function
293
+
294
+ ; Inline class method declarations (inside class body, no body: void Foo();)
295
+ (field_declaration declarator: (function_declarator declarator: (identifier) @name)) @definition.method
296
+
297
+ ; Inline class method definitions (inside class body, with body: void Foo() { ... })
298
+ (field_declaration_list
299
+ (function_definition
300
+ declarator: (function_declarator
301
+ declarator: [(field_identifier) (identifier) (operator_name) (destructor_name)] @name)) @definition.method)
302
+
227
303
  ; Templates
228
304
  (template_declaration (class_specifier name: (type_identifier) @name)) @definition.template
229
305
  (template_declaration (function_definition declarator: (function_declarator declarator: (identifier) @name))) @definition.template
@@ -237,6 +313,9 @@ export const CPP_QUERIES = `
237
313
  (call_expression function: (qualified_identifier name: (identifier) @call.name)) @call
238
314
  (call_expression function: (template_function name: (identifier) @call.name)) @call
239
315
 
316
+ ; Constructor calls: new User()
317
+ (new_expression type: (type_identifier) @call.name) @call
318
+
240
319
  ; Heritage
241
320
  (class_specifier name: (type_identifier) @heritage.class
242
321
  (base_class_clause (type_identifier) @heritage.extends)) @heritage
@@ -253,9 +332,11 @@ export const CSHARP_QUERIES = `
253
332
  (record_declaration name: (identifier) @name) @definition.record
254
333
  (delegate_declaration name: (identifier) @name) @definition.delegate
255
334
 
256
- ; Namespaces
335
+ ; Namespaces (block form and C# 10+ file-scoped form)
257
336
  (namespace_declaration name: (identifier) @name) @definition.namespace
258
337
  (namespace_declaration name: (qualified_name) @name) @definition.namespace
338
+ (file_scoped_namespace_declaration name: (identifier) @name) @definition.namespace
339
+ (file_scoped_namespace_declaration name: (qualified_name) @name) @definition.namespace
259
340
 
260
341
  ; Methods & Properties
261
342
  (method_declaration name: (identifier) @name) @definition.method
@@ -263,6 +344,10 @@ export const CSHARP_QUERIES = `
263
344
  (constructor_declaration name: (identifier) @name) @definition.constructor
264
345
  (property_declaration name: (identifier) @name) @definition.property
265
346
 
347
+ ; Primary constructors (C# 12): class User(string name, int age) { }
348
+ (class_declaration name: (identifier) @name (parameter_list) @definition.constructor)
349
+ (record_declaration name: (identifier) @name (parameter_list) @definition.constructor)
350
+
266
351
  ; Using
267
352
  (using_directive (qualified_name) @import.source) @import
268
353
  (using_directive (identifier) @import.source) @import
@@ -271,6 +356,19 @@ export const CSHARP_QUERIES = `
271
356
  (invocation_expression function: (identifier) @call.name) @call
272
357
  (invocation_expression function: (member_access_expression name: (identifier) @call.name)) @call
273
358
 
359
+ ; Null-conditional method calls: user?.Save()
360
+ ; Parses as: invocation_expression → conditional_access_expression → member_binding_expression → identifier
361
+ (invocation_expression
362
+ function: (conditional_access_expression
363
+ (member_binding_expression
364
+ (identifier) @call.name))) @call
365
+
366
+ ; Constructor calls: new Foo() and new Foo { Props }
367
+ (object_creation_expression type: (identifier) @call.name) @call
368
+
369
+ ; Target-typed new (C# 9): User u = new("x", 5)
370
+ (variable_declaration type: (identifier) @call.name (variable_declarator (implicit_object_creation_expression) @call))
371
+
274
372
  ; Heritage
275
373
  (class_declaration name: (identifier) @heritage.class
276
374
  (base_list (identifier) @heritage.extends)) @heritage
@@ -284,7 +382,8 @@ export const RUST_QUERIES = `
284
382
  (struct_item name: (type_identifier) @name) @definition.struct
285
383
  (enum_item name: (type_identifier) @name) @definition.enum
286
384
  (trait_item name: (type_identifier) @name) @definition.trait
287
- (impl_item type: (type_identifier) @name) @definition.impl
385
+ (impl_item type: (type_identifier) @name !trait) @definition.impl
386
+ (impl_item type: (generic_type type: (type_identifier) @name) !trait) @definition.impl
288
387
  (mod_item name: (identifier) @name) @definition.module
289
388
 
290
389
  ; Type aliases, const, static, macros
@@ -302,9 +401,14 @@ export const RUST_QUERIES = `
302
401
  (call_expression function: (scoped_identifier name: (identifier) @call.name)) @call
303
402
  (call_expression function: (generic_function function: (identifier) @call.name)) @call
304
403
 
305
- ; Heritage (trait implementation)
404
+ ; Struct literal construction: User { name: value }
405
+ (struct_expression name: (type_identifier) @call.name) @call
406
+
407
+ ; Heritage (trait implementation) — all combinations of concrete/generic trait × concrete/generic type
306
408
  (impl_item trait: (type_identifier) @heritage.trait type: (type_identifier) @heritage.class) @heritage
307
409
  (impl_item trait: (generic_type type: (type_identifier) @heritage.trait) type: (type_identifier) @heritage.class) @heritage
410
+ (impl_item trait: (type_identifier) @heritage.trait type: (generic_type type: (type_identifier) @heritage.class)) @heritage
411
+ (impl_item trait: (generic_type type: (type_identifier) @heritage.trait) type: (generic_type type: (type_identifier) @heritage.class)) @heritage
308
412
  `;
309
413
  // PHP queries - works with tree-sitter-php (php_only grammar)
310
414
  export const PHP_QUERIES = `
@@ -365,6 +469,9 @@ export const PHP_QUERIES = `
365
469
  (scoped_call_expression
366
470
  name: (name) @call.name) @call
367
471
 
472
+ ; Constructor call: new User()
473
+ (object_creation_expression (name) @call.name) @call
474
+
368
475
  ; ── Heritage: extends ────────────────────────────────────────────────────────
369
476
  (class_declaration
370
477
  name: (name) @heritage.class
@@ -384,6 +491,186 @@ export const PHP_QUERIES = `
384
491
  (use_declaration
385
492
  [(name) (qualified_name)] @heritage.trait))) @heritage
386
493
  `;
494
+ // Ruby queries - works with tree-sitter-ruby
495
+ // NOTE: Ruby uses `call` for require, include, extend, prepend, attr_* etc.
496
+ // These are all captured as @call and routed in JS post-processing:
497
+ // - require/require_relative → import extraction
498
+ // - include/extend/prepend → heritage (mixin) extraction
499
+ // - attr_accessor/attr_reader/attr_writer → property definition extraction
500
+ // - everything else → regular call extraction
501
+ export const RUBY_QUERIES = `
502
+ ; ── Modules ──────────────────────────────────────────────────────────────────
503
+ (module
504
+ name: (constant) @name) @definition.module
505
+
506
+ ; ── Classes ──────────────────────────────────────────────────────────────────
507
+ (class
508
+ name: (constant) @name) @definition.class
509
+
510
+ ; ── Instance methods ─────────────────────────────────────────────────────────
511
+ (method
512
+ name: (identifier) @name) @definition.method
513
+
514
+ ; ── Singleton (class-level) methods ──────────────────────────────────────────
515
+ (singleton_method
516
+ name: (identifier) @name) @definition.method
517
+
518
+ ; ── All calls (require, include, attr_*, and regular calls routed in JS) ─────
519
+ (call
520
+ method: (identifier) @call.name) @call
521
+
522
+ ; ── Bare calls without parens (identifiers at statement level are method calls) ─
523
+ ; NOTE: This may over-capture variable reads as calls (e.g. 'result' at
524
+ ; statement level). Ruby's grammar makes bare identifiers ambiguous — they
525
+ ; could be local variables or zero-arity method calls. Post-processing via
526
+ ; isBuiltInOrNoise and symbol resolution filtering suppresses most false
527
+ ; positives, but a variable name that coincidentally matches a method name
528
+ ; elsewhere may produce a false CALLS edge.
529
+ (body_statement
530
+ (identifier) @call.name @call)
531
+
532
+ ; ── Heritage: class < SuperClass ─────────────────────────────────────────────
533
+ (class
534
+ name: (constant) @heritage.class
535
+ superclass: (superclass
536
+ (constant) @heritage.extends)) @heritage
537
+ `;
538
+ // Kotlin queries - works with tree-sitter-kotlin (fwcd/tree-sitter-kotlin)
539
+ // Based on official tags.scm; functions use simple_identifier, classes use type_identifier
540
+ export const KOTLIN_QUERIES = `
541
+ ; ── Interfaces ─────────────────────────────────────────────────────────────
542
+ ; tree-sitter-kotlin (fwcd) has no interface_declaration node type.
543
+ ; Interfaces are class_declaration nodes with an anonymous "interface" keyword child.
544
+ (class_declaration
545
+ "interface"
546
+ (type_identifier) @name) @definition.interface
547
+
548
+ ; ── Classes (regular, data, sealed, enum) ────────────────────────────────
549
+ ; All have the anonymous "class" keyword child. enum class has both
550
+ ; "enum" and "class" children — the "class" child still matches.
551
+ (class_declaration
552
+ "class"
553
+ (type_identifier) @name) @definition.class
554
+
555
+ ; ── Object declarations (Kotlin singletons) ──────────────────────────────
556
+ (object_declaration
557
+ (type_identifier) @name) @definition.class
558
+
559
+ ; ── Companion objects (named only) ───────────────────────────────────────
560
+ (companion_object
561
+ (type_identifier) @name) @definition.class
562
+
563
+ ; ── Functions (top-level, member, extension) ──────────────────────────────
564
+ (function_declaration
565
+ (simple_identifier) @name) @definition.function
566
+
567
+ ; ── Properties ───────────────────────────────────────────────────────────
568
+ (property_declaration
569
+ (variable_declaration
570
+ (simple_identifier) @name)) @definition.property
571
+
572
+ ; ── Enum entries ─────────────────────────────────────────────────────────
573
+ (enum_entry
574
+ (simple_identifier) @name) @definition.enum
575
+
576
+ ; ── Type aliases ─────────────────────────────────────────────────────────
577
+ (type_alias
578
+ (type_identifier) @name) @definition.type
579
+
580
+ ; ── Imports ──────────────────────────────────────────────────────────────
581
+ (import_header
582
+ (identifier) @import.source) @import
583
+
584
+ ; ── Function calls (direct) ──────────────────────────────────────────────
585
+ (call_expression
586
+ (simple_identifier) @call.name) @call
587
+
588
+ ; ── Method calls (via navigation: obj.method()) ──────────────────────────
589
+ (call_expression
590
+ (navigation_expression
591
+ (navigation_suffix
592
+ (simple_identifier) @call.name))) @call
593
+
594
+ ; ── Constructor invocations ──────────────────────────────────────────────
595
+ (constructor_invocation
596
+ (user_type
597
+ (type_identifier) @call.name)) @call
598
+
599
+ ; ── Infix function calls (e.g., a to b, x until y) ──────────────────────
600
+ (infix_expression
601
+ (simple_identifier) @call.name) @call
602
+
603
+ ; ── Heritage: extends / implements via delegation_specifier ──────────────
604
+ ; Interface implementation (bare user_type): class Foo : Bar
605
+ (class_declaration
606
+ (type_identifier) @heritage.class
607
+ (delegation_specifier
608
+ (user_type (type_identifier) @heritage.extends))) @heritage
609
+
610
+ ; Class extension (constructor_invocation): class Foo : Bar()
611
+ (class_declaration
612
+ (type_identifier) @heritage.class
613
+ (delegation_specifier
614
+ (constructor_invocation
615
+ (user_type (type_identifier) @heritage.extends)))) @heritage
616
+ `;
617
+ // Swift queries - works with tree-sitter-swift
618
+ export const SWIFT_QUERIES = `
619
+ ; Classes
620
+ (class_declaration "class" name: (type_identifier) @name) @definition.class
621
+
622
+ ; Structs
623
+ (class_declaration "struct" name: (type_identifier) @name) @definition.struct
624
+
625
+ ; Enums
626
+ (class_declaration "enum" name: (type_identifier) @name) @definition.enum
627
+
628
+ ; Extensions (mapped to class — no dedicated label in schema)
629
+ (class_declaration "extension" name: (user_type (type_identifier) @name)) @definition.class
630
+
631
+ ; Actors
632
+ (class_declaration "actor" name: (type_identifier) @name) @definition.class
633
+
634
+ ; Protocols (mapped to interface)
635
+ (protocol_declaration name: (type_identifier) @name) @definition.interface
636
+
637
+ ; Type aliases
638
+ (typealias_declaration name: (type_identifier) @name) @definition.type
639
+
640
+ ; Functions (top-level and methods)
641
+ (function_declaration name: (simple_identifier) @name) @definition.function
642
+
643
+ ; Protocol method declarations
644
+ (protocol_function_declaration name: (simple_identifier) @name) @definition.method
645
+
646
+ ; Initializers
647
+ (init_declaration) @definition.constructor
648
+
649
+ ; Properties (stored and computed)
650
+ (property_declaration (pattern (simple_identifier) @name)) @definition.property
651
+
652
+ ; Imports
653
+ (import_declaration (identifier (simple_identifier) @import.source)) @import
654
+
655
+ ; Calls - direct function calls
656
+ (call_expression (simple_identifier) @call.name) @call
657
+
658
+ ; Calls - member/navigation calls (obj.method())
659
+ (call_expression (navigation_expression (navigation_suffix (simple_identifier) @call.name))) @call
660
+
661
+ ; Heritage - class/struct/enum inheritance and protocol conformance
662
+ (class_declaration name: (type_identifier) @heritage.class
663
+ (inheritance_specifier inherits_from: (user_type (type_identifier) @heritage.extends))) @heritage
664
+
665
+ ; Heritage - protocol inheritance
666
+ (protocol_declaration name: (type_identifier) @heritage.class
667
+ (inheritance_specifier inherits_from: (user_type (type_identifier) @heritage.extends))) @heritage
668
+
669
+ ; Heritage - extension protocol conformance (e.g. extension Foo: SomeProtocol)
670
+ ; Extensions wrap the name in user_type unlike class/struct/enum declarations
671
+ (class_declaration "extension" name: (user_type (type_identifier) @heritage.class)
672
+ (inheritance_specifier inherits_from: (user_type (type_identifier) @heritage.extends))) @heritage
673
+ `;
387
674
  export const LANGUAGE_QUERIES = {
388
675
  [SupportedLanguages.TypeScript]: TYPESCRIPT_QUERIES,
389
676
  [SupportedLanguages.JavaScript]: JAVASCRIPT_QUERIES,
@@ -393,6 +680,9 @@ export const LANGUAGE_QUERIES = {
393
680
  [SupportedLanguages.Go]: GO_QUERIES,
394
681
  [SupportedLanguages.CPlusPlus]: CPP_QUERIES,
395
682
  [SupportedLanguages.CSharp]: CSHARP_QUERIES,
683
+ [SupportedLanguages.Ruby]: RUBY_QUERIES,
396
684
  [SupportedLanguages.Rust]: RUST_QUERIES,
397
685
  [SupportedLanguages.PHP]: PHP_QUERIES,
686
+ [SupportedLanguages.Kotlin]: KOTLIN_QUERIES,
687
+ [SupportedLanguages.Swift]: SWIFT_QUERIES,
398
688
  };
@@ -0,0 +1,49 @@
1
+ import type { SyntaxNode } from './utils.js';
2
+ import { SupportedLanguages } from '../../config/supported-languages.js';
3
+ import type { SymbolTable } from './symbol-table.js';
4
+ /**
5
+ * Per-file scoped type environment: maps (scope, variableName) → typeName.
6
+ * Scope-aware: variables inside functions are keyed by function name,
7
+ * file-level variables use the '' (empty string) scope.
8
+ *
9
+ * Design constraints:
10
+ * - Explicit-only: Tier 0 uses type annotations; Tier 1 infers from constructors
11
+ * - Tier 2: single-pass assignment chain propagation in source order — resolves
12
+ * `const b = a` when `a` already has a type from Tier 0/1
13
+ * - Scope-aware: function-local variables don't collide across functions
14
+ * - Conservative: complex/generic types extract the base name only
15
+ * - Per-file: built once, used for receiver resolution, then discarded
16
+ */
17
+ export type TypeEnv = Map<string, Map<string, string>>;
18
+ /**
19
+ * Per-file type environment with receiver resolution.
20
+ * Built once per file via `buildTypeEnv`, used for receiver-type filtering,
21
+ * then discarded. Encapsulates scope-aware type lookup and self/this/super
22
+ * AST resolution behind a single `.lookup()` method.
23
+ */
24
+ export interface TypeEnvironment {
25
+ /** Look up a variable's resolved type, with self/this/super AST resolution. */
26
+ lookup(varName: string, callNode: SyntaxNode): string | undefined;
27
+ /** Unverified cross-file constructor bindings for SymbolTable verification. */
28
+ readonly constructorBindings: readonly ConstructorBinding[];
29
+ /** Raw per-scope type bindings — for testing and debugging. */
30
+ readonly env: TypeEnv;
31
+ }
32
+ export declare const buildTypeEnv: (tree: {
33
+ rootNode: SyntaxNode;
34
+ }, language: SupportedLanguages, symbolTable?: SymbolTable) => TypeEnvironment;
35
+ /**
36
+ * Unverified constructor binding: a `val x = Callee()` pattern where we
37
+ * couldn't confirm the callee is a class (because it's defined in another file).
38
+ * The caller must verify `calleeName` against the SymbolTable before trusting.
39
+ */
40
+ export interface ConstructorBinding {
41
+ /** Function scope key (matches TypeEnv scope keys) */
42
+ scope: string;
43
+ /** Variable name that received the constructor result */
44
+ varName: string;
45
+ /** Name of the callee (potential class constructor) */
46
+ calleeName: string;
47
+ /** Enclosing class name when callee is a method on a known receiver (e.g. $this) */
48
+ receiverClassName?: string;
49
+ }