gitnexus 1.4.1 → 1.4.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 (169) hide show
  1. package/README.md +215 -194
  2. package/dist/cli/ai-context.d.ts +2 -1
  3. package/dist/cli/ai-context.js +117 -90
  4. package/dist/cli/analyze.d.ts +2 -0
  5. package/dist/cli/analyze.js +57 -30
  6. package/dist/cli/augment.js +1 -1
  7. package/dist/cli/eval-server.d.ts +1 -1
  8. package/dist/cli/eval-server.js +14 -6
  9. package/dist/cli/index.js +18 -25
  10. package/dist/cli/lazy-action.d.ts +6 -0
  11. package/dist/cli/lazy-action.js +18 -0
  12. package/dist/cli/mcp.js +1 -1
  13. package/dist/cli/setup.js +42 -32
  14. package/dist/cli/skill-gen.d.ts +26 -0
  15. package/dist/cli/skill-gen.js +549 -0
  16. package/dist/cli/status.js +13 -4
  17. package/dist/cli/tool.d.ts +3 -2
  18. package/dist/cli/tool.js +48 -13
  19. package/dist/cli/wiki.js +2 -2
  20. package/dist/config/ignore-service.d.ts +25 -0
  21. package/dist/config/ignore-service.js +76 -0
  22. package/dist/config/supported-languages.d.ts +1 -0
  23. package/dist/config/supported-languages.js +1 -1
  24. package/dist/core/augmentation/engine.js +99 -72
  25. package/dist/core/embeddings/embedder.d.ts +1 -1
  26. package/dist/core/embeddings/embedder.js +1 -1
  27. package/dist/core/embeddings/embedding-pipeline.d.ts +3 -3
  28. package/dist/core/embeddings/embedding-pipeline.js +74 -47
  29. package/dist/core/embeddings/types.d.ts +1 -1
  30. package/dist/core/graph/types.d.ts +5 -2
  31. package/dist/core/ingestion/ast-cache.js +3 -2
  32. package/dist/core/ingestion/call-processor.d.ts +5 -7
  33. package/dist/core/ingestion/call-processor.js +430 -283
  34. package/dist/core/ingestion/call-routing.d.ts +53 -0
  35. package/dist/core/ingestion/call-routing.js +108 -0
  36. package/dist/core/ingestion/cluster-enricher.js +16 -16
  37. package/dist/core/ingestion/constants.d.ts +16 -0
  38. package/dist/core/ingestion/constants.js +16 -0
  39. package/dist/core/ingestion/entry-point-scoring.d.ts +2 -1
  40. package/dist/core/ingestion/entry-point-scoring.js +94 -24
  41. package/dist/core/ingestion/export-detection.d.ts +18 -0
  42. package/dist/core/ingestion/export-detection.js +231 -0
  43. package/dist/core/ingestion/filesystem-walker.js +4 -3
  44. package/dist/core/ingestion/framework-detection.d.ts +5 -1
  45. package/dist/core/ingestion/framework-detection.js +48 -8
  46. package/dist/core/ingestion/heritage-processor.d.ts +13 -5
  47. package/dist/core/ingestion/heritage-processor.js +109 -55
  48. package/dist/core/ingestion/import-processor.d.ts +16 -20
  49. package/dist/core/ingestion/import-processor.js +202 -696
  50. package/dist/core/ingestion/language-config.d.ts +46 -0
  51. package/dist/core/ingestion/language-config.js +167 -0
  52. package/dist/core/ingestion/mro-processor.d.ts +45 -0
  53. package/dist/core/ingestion/mro-processor.js +369 -0
  54. package/dist/core/ingestion/named-binding-extraction.d.ts +61 -0
  55. package/dist/core/ingestion/named-binding-extraction.js +363 -0
  56. package/dist/core/ingestion/parsing-processor.d.ts +3 -11
  57. package/dist/core/ingestion/parsing-processor.js +85 -181
  58. package/dist/core/ingestion/pipeline.d.ts +5 -1
  59. package/dist/core/ingestion/pipeline.js +192 -116
  60. package/dist/core/ingestion/process-processor.js +2 -1
  61. package/dist/core/ingestion/resolution-context.d.ts +53 -0
  62. package/dist/core/ingestion/resolution-context.js +132 -0
  63. package/dist/core/ingestion/resolvers/csharp.d.ts +22 -0
  64. package/dist/core/ingestion/resolvers/csharp.js +109 -0
  65. package/dist/core/ingestion/resolvers/go.d.ts +19 -0
  66. package/dist/core/ingestion/resolvers/go.js +42 -0
  67. package/dist/core/ingestion/resolvers/index.d.ts +18 -0
  68. package/dist/core/ingestion/resolvers/index.js +13 -0
  69. package/dist/core/ingestion/resolvers/jvm.d.ts +23 -0
  70. package/dist/core/ingestion/resolvers/jvm.js +87 -0
  71. package/dist/core/ingestion/resolvers/php.d.ts +15 -0
  72. package/dist/core/ingestion/resolvers/php.js +35 -0
  73. package/dist/core/ingestion/resolvers/python.d.ts +19 -0
  74. package/dist/core/ingestion/resolvers/python.js +52 -0
  75. package/dist/core/ingestion/resolvers/ruby.d.ts +12 -0
  76. package/dist/core/ingestion/resolvers/ruby.js +15 -0
  77. package/dist/core/ingestion/resolvers/rust.d.ts +15 -0
  78. package/dist/core/ingestion/resolvers/rust.js +73 -0
  79. package/dist/core/ingestion/resolvers/standard.d.ts +28 -0
  80. package/dist/core/ingestion/resolvers/standard.js +123 -0
  81. package/dist/core/ingestion/resolvers/utils.d.ts +33 -0
  82. package/dist/core/ingestion/resolvers/utils.js +122 -0
  83. package/dist/core/ingestion/symbol-table.d.ts +21 -1
  84. package/dist/core/ingestion/symbol-table.js +40 -12
  85. package/dist/core/ingestion/tree-sitter-queries.d.ts +12 -11
  86. package/dist/core/ingestion/tree-sitter-queries.js +642 -485
  87. package/dist/core/ingestion/type-env.d.ts +49 -0
  88. package/dist/core/ingestion/type-env.js +611 -0
  89. package/dist/core/ingestion/type-extractors/c-cpp.d.ts +2 -0
  90. package/dist/core/ingestion/type-extractors/c-cpp.js +385 -0
  91. package/dist/core/ingestion/type-extractors/csharp.d.ts +2 -0
  92. package/dist/core/ingestion/type-extractors/csharp.js +383 -0
  93. package/dist/core/ingestion/type-extractors/go.d.ts +2 -0
  94. package/dist/core/ingestion/type-extractors/go.js +467 -0
  95. package/dist/core/ingestion/type-extractors/index.d.ts +22 -0
  96. package/dist/core/ingestion/type-extractors/index.js +31 -0
  97. package/dist/core/ingestion/type-extractors/jvm.d.ts +3 -0
  98. package/dist/core/ingestion/type-extractors/jvm.js +681 -0
  99. package/dist/core/ingestion/type-extractors/php.d.ts +2 -0
  100. package/dist/core/ingestion/type-extractors/php.js +549 -0
  101. package/dist/core/ingestion/type-extractors/python.d.ts +2 -0
  102. package/dist/core/ingestion/type-extractors/python.js +406 -0
  103. package/dist/core/ingestion/type-extractors/ruby.d.ts +2 -0
  104. package/dist/core/ingestion/type-extractors/ruby.js +389 -0
  105. package/dist/core/ingestion/type-extractors/rust.d.ts +2 -0
  106. package/dist/core/ingestion/type-extractors/rust.js +449 -0
  107. package/dist/core/ingestion/type-extractors/shared.d.ts +133 -0
  108. package/dist/core/ingestion/type-extractors/shared.js +703 -0
  109. package/dist/core/ingestion/type-extractors/swift.d.ts +2 -0
  110. package/dist/core/ingestion/type-extractors/swift.js +137 -0
  111. package/dist/core/ingestion/type-extractors/types.d.ts +127 -0
  112. package/dist/core/ingestion/type-extractors/types.js +1 -0
  113. package/dist/core/ingestion/type-extractors/typescript.d.ts +2 -0
  114. package/dist/core/ingestion/type-extractors/typescript.js +494 -0
  115. package/dist/core/ingestion/utils.d.ts +98 -0
  116. package/dist/core/ingestion/utils.js +1064 -9
  117. package/dist/core/ingestion/workers/parse-worker.d.ts +38 -4
  118. package/dist/core/ingestion/workers/parse-worker.js +251 -359
  119. package/dist/core/ingestion/workers/worker-pool.js +8 -0
  120. package/dist/core/{kuzu → lbug}/csv-generator.d.ts +1 -1
  121. package/dist/core/{kuzu → lbug}/csv-generator.js +20 -4
  122. package/dist/core/{kuzu/kuzu-adapter.d.ts → lbug/lbug-adapter.d.ts} +19 -19
  123. package/dist/core/{kuzu/kuzu-adapter.js → lbug/lbug-adapter.js} +82 -82
  124. package/dist/core/{kuzu → lbug}/schema.d.ts +4 -4
  125. package/dist/core/{kuzu → lbug}/schema.js +304 -289
  126. package/dist/core/search/bm25-index.d.ts +4 -4
  127. package/dist/core/search/bm25-index.js +17 -16
  128. package/dist/core/search/hybrid-search.d.ts +2 -2
  129. package/dist/core/search/hybrid-search.js +9 -9
  130. package/dist/core/tree-sitter/parser-loader.js +9 -2
  131. package/dist/core/wiki/generator.d.ts +4 -52
  132. package/dist/core/wiki/generator.js +53 -552
  133. package/dist/core/wiki/graph-queries.d.ts +4 -46
  134. package/dist/core/wiki/graph-queries.js +103 -282
  135. package/dist/core/wiki/html-viewer.js +192 -192
  136. package/dist/core/wiki/llm-client.js +11 -73
  137. package/dist/core/wiki/prompts.d.ts +8 -52
  138. package/dist/core/wiki/prompts.js +86 -200
  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} +7 -9
  142. package/dist/mcp/core/{kuzu-adapter.js → lbug-adapter.js} +77 -79
  143. package/dist/mcp/local/local-backend.d.ts +7 -6
  144. package/dist/mcp/local/local-backend.js +176 -147
  145. package/dist/mcp/resources.js +42 -42
  146. package/dist/mcp/server.js +18 -19
  147. package/dist/mcp/tools.js +103 -104
  148. package/dist/server/api.js +12 -12
  149. package/dist/server/mcp-http.d.ts +1 -1
  150. package/dist/server/mcp-http.js +1 -1
  151. package/dist/storage/repo-manager.d.ts +20 -2
  152. package/dist/storage/repo-manager.js +55 -1
  153. package/dist/types/pipeline.d.ts +1 -1
  154. package/hooks/claude/gitnexus-hook.cjs +238 -155
  155. package/hooks/claude/pre-tool-use.sh +79 -79
  156. package/hooks/claude/session-start.sh +42 -42
  157. package/package.json +99 -96
  158. package/scripts/patch-tree-sitter-swift.cjs +74 -74
  159. package/skills/gitnexus-cli.md +82 -82
  160. package/skills/gitnexus-debugging.md +89 -89
  161. package/skills/gitnexus-exploring.md +78 -78
  162. package/skills/gitnexus-guide.md +64 -64
  163. package/skills/gitnexus-impact-analysis.md +97 -97
  164. package/skills/gitnexus-pr-review.md +163 -163
  165. package/skills/gitnexus-refactoring.md +121 -121
  166. package/vendor/leiden/index.cjs +355 -355
  167. package/vendor/leiden/utils.cjs +392 -392
  168. package/dist/core/wiki/diagrams.d.ts +0 -27
  169. package/dist/core/wiki/diagrams.js +0 -163
@@ -7,513 +7,669 @@ import { SupportedLanguages } from '../../config/supported-languages.js';
7
7
  * compatible with the standard tree-sitter grammars.
8
8
  */
9
9
  // TypeScript queries - works with tree-sitter-typescript
10
- export const TYPESCRIPT_QUERIES = `
11
- (class_declaration
12
- name: (type_identifier) @name) @definition.class
13
-
14
- (interface_declaration
15
- name: (type_identifier) @name) @definition.interface
16
-
17
- (function_declaration
18
- name: (identifier) @name) @definition.function
19
-
20
- (method_definition
21
- name: (property_identifier) @name) @definition.method
22
-
23
- (lexical_declaration
24
- (variable_declarator
25
- name: (identifier) @name
26
- value: (arrow_function))) @definition.function
27
-
28
- (lexical_declaration
29
- (variable_declarator
30
- name: (identifier) @name
31
- value: (function_expression))) @definition.function
32
-
33
- (export_statement
34
- declaration: (lexical_declaration
35
- (variable_declarator
36
- name: (identifier) @name
37
- value: (arrow_function)))) @definition.function
38
-
39
- (export_statement
40
- declaration: (lexical_declaration
41
- (variable_declarator
42
- name: (identifier) @name
43
- value: (function_expression)))) @definition.function
44
-
45
- (import_statement
46
- source: (string) @import.source) @import
47
-
48
- (call_expression
49
- function: (identifier) @call.name) @call
50
-
51
- (call_expression
52
- function: (member_expression
53
- property: (property_identifier) @call.name)) @call
54
-
55
- ; Heritage queries - class extends
56
- (class_declaration
57
- name: (type_identifier) @heritage.class
58
- (class_heritage
59
- (extends_clause
60
- value: (identifier) @heritage.extends))) @heritage
61
-
62
- ; Heritage queries - class implements interface
63
- (class_declaration
64
- name: (type_identifier) @heritage.class
65
- (class_heritage
66
- (implements_clause
67
- (type_identifier) @heritage.implements))) @heritage.impl
10
+ export const TYPESCRIPT_QUERIES = `
11
+ (class_declaration
12
+ name: (type_identifier) @name) @definition.class
13
+
14
+ (interface_declaration
15
+ name: (type_identifier) @name) @definition.interface
16
+
17
+ (function_declaration
18
+ name: (identifier) @name) @definition.function
19
+
20
+ (method_definition
21
+ name: (property_identifier) @name) @definition.method
22
+
23
+ (lexical_declaration
24
+ (variable_declarator
25
+ name: (identifier) @name
26
+ value: (arrow_function))) @definition.function
27
+
28
+ (lexical_declaration
29
+ (variable_declarator
30
+ name: (identifier) @name
31
+ value: (function_expression))) @definition.function
32
+
33
+ (export_statement
34
+ declaration: (lexical_declaration
35
+ (variable_declarator
36
+ name: (identifier) @name
37
+ value: (arrow_function)))) @definition.function
38
+
39
+ (export_statement
40
+ declaration: (lexical_declaration
41
+ (variable_declarator
42
+ name: (identifier) @name
43
+ value: (function_expression)))) @definition.function
44
+
45
+ (import_statement
46
+ source: (string) @import.source) @import
47
+
48
+ ; Re-export statements: export { X } from './y'
49
+ (export_statement
50
+ source: (string) @import.source) @import
51
+
52
+ (call_expression
53
+ function: (identifier) @call.name) @call
54
+
55
+ (call_expression
56
+ function: (member_expression
57
+ property: (property_identifier) @call.name)) @call
58
+
59
+ ; Constructor calls: new Foo()
60
+ (new_expression
61
+ constructor: (identifier) @call.name) @call
62
+
63
+ ; Heritage queries - class extends
64
+ (class_declaration
65
+ name: (type_identifier) @heritage.class
66
+ (class_heritage
67
+ (extends_clause
68
+ value: (identifier) @heritage.extends))) @heritage
69
+
70
+ ; Heritage queries - class implements interface
71
+ (class_declaration
72
+ name: (type_identifier) @heritage.class
73
+ (class_heritage
74
+ (implements_clause
75
+ (type_identifier) @heritage.implements))) @heritage.impl
68
76
  `;
69
- // JavaScript queries - works with tree-sitter-javascript
70
- export const JAVASCRIPT_QUERIES = `
71
- (class_declaration
72
- name: (identifier) @name) @definition.class
73
-
74
- (function_declaration
75
- name: (identifier) @name) @definition.function
76
-
77
- (method_definition
78
- name: (property_identifier) @name) @definition.method
79
-
80
- (lexical_declaration
81
- (variable_declarator
82
- name: (identifier) @name
83
- value: (arrow_function))) @definition.function
84
-
85
- (lexical_declaration
86
- (variable_declarator
87
- name: (identifier) @name
88
- value: (function_expression))) @definition.function
89
-
90
- (export_statement
91
- declaration: (lexical_declaration
92
- (variable_declarator
93
- name: (identifier) @name
94
- value: (arrow_function)))) @definition.function
95
-
96
- (export_statement
97
- declaration: (lexical_declaration
98
- (variable_declarator
99
- name: (identifier) @name
100
- value: (function_expression)))) @definition.function
101
-
102
- (import_statement
103
- source: (string) @import.source) @import
104
-
105
- (call_expression
106
- function: (identifier) @call.name) @call
107
-
108
- (call_expression
109
- function: (member_expression
110
- property: (property_identifier) @call.name)) @call
111
-
112
- ; Heritage queries - class extends (JavaScript uses different AST than TypeScript)
113
- ; In tree-sitter-javascript, class_heritage directly contains the parent identifier
114
- (class_declaration
115
- name: (identifier) @heritage.class
116
- (class_heritage
117
- (identifier) @heritage.extends)) @heritage
77
+ // JavaScript queries - works with tree-sitter-javascript
78
+ export const JAVASCRIPT_QUERIES = `
79
+ (class_declaration
80
+ name: (identifier) @name) @definition.class
81
+
82
+ (function_declaration
83
+ name: (identifier) @name) @definition.function
84
+
85
+ (method_definition
86
+ name: (property_identifier) @name) @definition.method
87
+
88
+ (lexical_declaration
89
+ (variable_declarator
90
+ name: (identifier) @name
91
+ value: (arrow_function))) @definition.function
92
+
93
+ (lexical_declaration
94
+ (variable_declarator
95
+ name: (identifier) @name
96
+ value: (function_expression))) @definition.function
97
+
98
+ (export_statement
99
+ declaration: (lexical_declaration
100
+ (variable_declarator
101
+ name: (identifier) @name
102
+ value: (arrow_function)))) @definition.function
103
+
104
+ (export_statement
105
+ declaration: (lexical_declaration
106
+ (variable_declarator
107
+ name: (identifier) @name
108
+ value: (function_expression)))) @definition.function
109
+
110
+ (import_statement
111
+ source: (string) @import.source) @import
112
+
113
+ ; Re-export statements: export { X } from './y'
114
+ (export_statement
115
+ source: (string) @import.source) @import
116
+
117
+ (call_expression
118
+ function: (identifier) @call.name) @call
119
+
120
+ (call_expression
121
+ function: (member_expression
122
+ property: (property_identifier) @call.name)) @call
123
+
124
+ ; Constructor calls: new Foo()
125
+ (new_expression
126
+ constructor: (identifier) @call.name) @call
127
+
128
+ ; Heritage queries - class extends (JavaScript uses different AST than TypeScript)
129
+ ; In tree-sitter-javascript, class_heritage directly contains the parent identifier
130
+ (class_declaration
131
+ name: (identifier) @heritage.class
132
+ (class_heritage
133
+ (identifier) @heritage.extends)) @heritage
118
134
  `;
119
135
  // Python queries - works with tree-sitter-python
120
- export const PYTHON_QUERIES = `
121
- (class_definition
122
- name: (identifier) @name) @definition.class
123
-
124
- (function_definition
125
- name: (identifier) @name) @definition.function
126
-
127
- (import_statement
128
- name: (dotted_name) @import.source) @import
129
-
130
- (import_from_statement
131
- module_name: (dotted_name) @import.source) @import
132
-
133
- (call
134
- function: (identifier) @call.name) @call
135
-
136
- (call
137
- function: (attribute
138
- attribute: (identifier) @call.name)) @call
139
-
140
- ; Heritage queries - Python class inheritance
141
- (class_definition
142
- name: (identifier) @heritage.class
143
- superclasses: (argument_list
144
- (identifier) @heritage.extends)) @heritage
136
+ export const PYTHON_QUERIES = `
137
+ (class_definition
138
+ name: (identifier) @name) @definition.class
139
+
140
+ (function_definition
141
+ name: (identifier) @name) @definition.function
142
+
143
+ (import_statement
144
+ name: (dotted_name) @import.source) @import
145
+
146
+ (import_from_statement
147
+ module_name: (dotted_name) @import.source) @import
148
+
149
+ (import_from_statement
150
+ module_name: (relative_import) @import.source) @import
151
+
152
+ (call
153
+ function: (identifier) @call.name) @call
154
+
155
+ (call
156
+ function: (attribute
157
+ attribute: (identifier) @call.name)) @call
158
+
159
+ ; Heritage queries - Python class inheritance
160
+ (class_definition
161
+ name: (identifier) @heritage.class
162
+ superclasses: (argument_list
163
+ (identifier) @heritage.extends)) @heritage
145
164
  `;
146
165
  // Java queries - works with tree-sitter-java
147
- export const JAVA_QUERIES = `
148
- ; Classes, Interfaces, Enums, Annotations
149
- (class_declaration name: (identifier) @name) @definition.class
150
- (interface_declaration name: (identifier) @name) @definition.interface
151
- (enum_declaration name: (identifier) @name) @definition.enum
152
- (annotation_type_declaration name: (identifier) @name) @definition.annotation
153
-
154
- ; Methods & Constructors
155
- (method_declaration name: (identifier) @name) @definition.method
156
- (constructor_declaration name: (identifier) @name) @definition.constructor
157
-
158
- ; Imports - capture any import declaration child as source
159
- (import_declaration (_) @import.source) @import
160
-
161
- ; Calls
162
- (method_invocation name: (identifier) @call.name) @call
163
- (method_invocation object: (_) name: (identifier) @call.name) @call
164
-
165
- ; Heritage - extends class
166
- (class_declaration name: (identifier) @heritage.class
167
- (superclass (type_identifier) @heritage.extends)) @heritage
168
-
169
- ; Heritage - implements interfaces
170
- (class_declaration name: (identifier) @heritage.class
171
- (super_interfaces (type_list (type_identifier) @heritage.implements))) @heritage.impl
166
+ export const JAVA_QUERIES = `
167
+ ; Classes, Interfaces, Enums, Annotations
168
+ (class_declaration name: (identifier) @name) @definition.class
169
+ (interface_declaration name: (identifier) @name) @definition.interface
170
+ (enum_declaration name: (identifier) @name) @definition.enum
171
+ (annotation_type_declaration name: (identifier) @name) @definition.annotation
172
+
173
+ ; Methods & Constructors
174
+ (method_declaration name: (identifier) @name) @definition.method
175
+ (constructor_declaration name: (identifier) @name) @definition.constructor
176
+
177
+ ; Imports - capture any import declaration child as source
178
+ (import_declaration (_) @import.source) @import
179
+
180
+ ; Calls
181
+ (method_invocation name: (identifier) @call.name) @call
182
+ (method_invocation object: (_) name: (identifier) @call.name) @call
183
+
184
+ ; Constructor calls: new Foo()
185
+ (object_creation_expression type: (type_identifier) @call.name) @call
186
+
187
+ ; Heritage - extends class
188
+ (class_declaration name: (identifier) @heritage.class
189
+ (superclass (type_identifier) @heritage.extends)) @heritage
190
+
191
+ ; Heritage - implements interfaces
192
+ (class_declaration name: (identifier) @heritage.class
193
+ (super_interfaces (type_list (type_identifier) @heritage.implements))) @heritage.impl
172
194
  `;
173
195
  // C queries - works with tree-sitter-c
174
- export const C_QUERIES = `
175
- ; Functions
176
- (function_definition declarator: (function_declarator declarator: (identifier) @name)) @definition.function
177
- (declaration declarator: (function_declarator declarator: (identifier) @name)) @definition.function
178
-
179
- ; Structs, Unions, Enums, Typedefs
180
- (struct_specifier name: (type_identifier) @name) @definition.struct
181
- (union_specifier name: (type_identifier) @name) @definition.union
182
- (enum_specifier name: (type_identifier) @name) @definition.enum
183
- (type_definition declarator: (type_identifier) @name) @definition.typedef
184
-
185
- ; Macros
186
- (preproc_function_def name: (identifier) @name) @definition.macro
187
- (preproc_def name: (identifier) @name) @definition.macro
188
-
189
- ; Includes
190
- (preproc_include path: (_) @import.source) @import
191
-
192
- ; Calls
193
- (call_expression function: (identifier) @call.name) @call
194
- (call_expression function: (field_expression field: (field_identifier) @call.name)) @call
196
+ export const C_QUERIES = `
197
+ ; Functions (direct declarator)
198
+ (function_definition declarator: (function_declarator declarator: (identifier) @name)) @definition.function
199
+ (declaration declarator: (function_declarator declarator: (identifier) @name)) @definition.function
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
+
208
+ ; Structs, Unions, Enums, Typedefs
209
+ (struct_specifier name: (type_identifier) @name) @definition.struct
210
+ (union_specifier name: (type_identifier) @name) @definition.union
211
+ (enum_specifier name: (type_identifier) @name) @definition.enum
212
+ (type_definition declarator: (type_identifier) @name) @definition.typedef
213
+
214
+ ; Macros
215
+ (preproc_function_def name: (identifier) @name) @definition.macro
216
+ (preproc_def name: (identifier) @name) @definition.macro
217
+
218
+ ; Includes
219
+ (preproc_include path: (_) @import.source) @import
220
+
221
+ ; Calls
222
+ (call_expression function: (identifier) @call.name) @call
223
+ (call_expression function: (field_expression field: (field_identifier) @call.name)) @call
195
224
  `;
196
225
  // Go queries - works with tree-sitter-go
197
- export const GO_QUERIES = `
198
- ; Functions & Methods
199
- (function_declaration name: (identifier) @name) @definition.function
200
- (method_declaration name: (field_identifier) @name) @definition.method
201
-
202
- ; Types
203
- (type_declaration (type_spec name: (type_identifier) @name type: (struct_type))) @definition.struct
204
- (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
-
207
- ; Imports
208
- (import_declaration (import_spec path: (interpreted_string_literal) @import.source)) @import
209
- (import_declaration (import_spec_list (import_spec path: (interpreted_string_literal) @import.source))) @import
210
-
211
- ; Calls
212
- (call_expression function: (identifier) @call.name) @call
213
- (call_expression function: (selector_expression field: (field_identifier) @call.name)) @call
226
+ export const GO_QUERIES = `
227
+ ; Functions & Methods
228
+ (function_declaration name: (identifier) @name) @definition.function
229
+ (method_declaration name: (field_identifier) @name) @definition.method
230
+
231
+ ; Types
232
+ (type_declaration (type_spec name: (type_identifier) @name type: (struct_type))) @definition.struct
233
+ (type_declaration (type_spec name: (type_identifier) @name type: (interface_type))) @definition.interface
234
+
235
+ ; Imports
236
+ (import_declaration (import_spec path: (interpreted_string_literal) @import.source)) @import
237
+ (import_declaration (import_spec_list (import_spec path: (interpreted_string_literal) @import.source))) @import
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
+
248
+ ; Calls
249
+ (call_expression function: (identifier) @call.name) @call
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
- export const CPP_QUERIES = `
217
- ; Classes, Structs, Namespaces
218
- (class_specifier name: (type_identifier) @name) @definition.class
219
- (struct_specifier name: (type_identifier) @name) @definition.struct
220
- (namespace_definition name: (namespace_identifier) @name) @definition.namespace
221
- (enum_specifier name: (type_identifier) @name) @definition.enum
222
-
223
- ; Functions & Methods
224
- (function_definition declarator: (function_declarator declarator: (identifier) @name)) @definition.function
225
- (function_definition declarator: (function_declarator declarator: (qualified_identifier name: (identifier) @name))) @definition.method
226
-
227
- ; Templates
228
- (template_declaration (class_specifier name: (type_identifier) @name)) @definition.template
229
- (template_declaration (function_definition declarator: (function_declarator declarator: (identifier) @name))) @definition.template
230
-
231
- ; Includes
232
- (preproc_include path: (_) @import.source) @import
233
-
234
- ; Calls
235
- (call_expression function: (identifier) @call.name) @call
236
- (call_expression function: (field_expression field: (field_identifier) @call.name)) @call
237
- (call_expression function: (qualified_identifier name: (identifier) @call.name)) @call
238
- (call_expression function: (template_function name: (identifier) @call.name)) @call
239
-
240
- ; Heritage
241
- (class_specifier name: (type_identifier) @heritage.class
242
- (base_class_clause (type_identifier) @heritage.extends)) @heritage
243
- (class_specifier name: (type_identifier) @heritage.class
244
- (base_class_clause (access_specifier) (type_identifier) @heritage.extends)) @heritage
256
+ export const CPP_QUERIES = `
257
+ ; Classes, Structs, Namespaces
258
+ (class_specifier name: (type_identifier) @name) @definition.class
259
+ (struct_specifier name: (type_identifier) @name) @definition.struct
260
+ (namespace_definition name: (namespace_identifier) @name) @definition.namespace
261
+ (enum_specifier name: (type_identifier) @name) @definition.enum
262
+
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)
272
+ (function_definition declarator: (function_declarator declarator: (identifier) @name)) @definition.function
273
+ (function_definition declarator: (function_declarator declarator: (qualified_identifier name: (identifier) @name))) @definition.method
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
+
303
+ ; Templates
304
+ (template_declaration (class_specifier name: (type_identifier) @name)) @definition.template
305
+ (template_declaration (function_definition declarator: (function_declarator declarator: (identifier) @name))) @definition.template
306
+
307
+ ; Includes
308
+ (preproc_include path: (_) @import.source) @import
309
+
310
+ ; Calls
311
+ (call_expression function: (identifier) @call.name) @call
312
+ (call_expression function: (field_expression field: (field_identifier) @call.name)) @call
313
+ (call_expression function: (qualified_identifier name: (identifier) @call.name)) @call
314
+ (call_expression function: (template_function name: (identifier) @call.name)) @call
315
+
316
+ ; Constructor calls: new User()
317
+ (new_expression type: (type_identifier) @call.name) @call
318
+
319
+ ; Heritage
320
+ (class_specifier name: (type_identifier) @heritage.class
321
+ (base_class_clause (type_identifier) @heritage.extends)) @heritage
322
+ (class_specifier name: (type_identifier) @heritage.class
323
+ (base_class_clause (access_specifier) (type_identifier) @heritage.extends)) @heritage
245
324
  `;
246
325
  // C# queries - works with tree-sitter-c-sharp
247
- export const CSHARP_QUERIES = `
248
- ; Types
249
- (class_declaration name: (identifier) @name) @definition.class
250
- (interface_declaration name: (identifier) @name) @definition.interface
251
- (struct_declaration name: (identifier) @name) @definition.struct
252
- (enum_declaration name: (identifier) @name) @definition.enum
253
- (record_declaration name: (identifier) @name) @definition.record
254
- (delegate_declaration name: (identifier) @name) @definition.delegate
255
-
256
- ; Namespaces
257
- (namespace_declaration name: (identifier) @name) @definition.namespace
258
- (namespace_declaration name: (qualified_name) @name) @definition.namespace
259
-
260
- ; Methods & Properties
261
- (method_declaration name: (identifier) @name) @definition.method
262
- (local_function_statement name: (identifier) @name) @definition.function
263
- (constructor_declaration name: (identifier) @name) @definition.constructor
264
- (property_declaration name: (identifier) @name) @definition.property
265
-
266
- ; Using
267
- (using_directive (qualified_name) @import.source) @import
268
- (using_directive (identifier) @import.source) @import
269
-
270
- ; Calls
271
- (invocation_expression function: (identifier) @call.name) @call
272
- (invocation_expression function: (member_access_expression name: (identifier) @call.name)) @call
273
-
274
- ; Heritage
275
- (class_declaration name: (identifier) @heritage.class
276
- (base_list (simple_base_type (identifier) @heritage.extends))) @heritage
277
- (class_declaration name: (identifier) @heritage.class
278
- (base_list (simple_base_type (generic_name (identifier) @heritage.extends)))) @heritage
326
+ export const CSHARP_QUERIES = `
327
+ ; Types
328
+ (class_declaration name: (identifier) @name) @definition.class
329
+ (interface_declaration name: (identifier) @name) @definition.interface
330
+ (struct_declaration name: (identifier) @name) @definition.struct
331
+ (enum_declaration name: (identifier) @name) @definition.enum
332
+ (record_declaration name: (identifier) @name) @definition.record
333
+ (delegate_declaration name: (identifier) @name) @definition.delegate
334
+
335
+ ; Namespaces (block form and C# 10+ file-scoped form)
336
+ (namespace_declaration name: (identifier) @name) @definition.namespace
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
340
+
341
+ ; Methods & Properties
342
+ (method_declaration name: (identifier) @name) @definition.method
343
+ (local_function_statement name: (identifier) @name) @definition.function
344
+ (constructor_declaration name: (identifier) @name) @definition.constructor
345
+ (property_declaration name: (identifier) @name) @definition.property
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
+
351
+ ; Using
352
+ (using_directive (qualified_name) @import.source) @import
353
+ (using_directive (identifier) @import.source) @import
354
+
355
+ ; Calls
356
+ (invocation_expression function: (identifier) @call.name) @call
357
+ (invocation_expression function: (member_access_expression name: (identifier) @call.name)) @call
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
+
372
+ ; Heritage
373
+ (class_declaration name: (identifier) @heritage.class
374
+ (base_list (identifier) @heritage.extends)) @heritage
375
+ (class_declaration name: (identifier) @heritage.class
376
+ (base_list (generic_name (identifier) @heritage.extends))) @heritage
279
377
  `;
280
378
  // Rust queries - works with tree-sitter-rust
281
- export const RUST_QUERIES = `
282
- ; Functions & Items
283
- (function_item name: (identifier) @name) @definition.function
284
- (struct_item name: (type_identifier) @name) @definition.struct
285
- (enum_item name: (type_identifier) @name) @definition.enum
286
- (trait_item name: (type_identifier) @name) @definition.trait
287
- (impl_item type: (type_identifier) @name) @definition.impl
288
- (mod_item name: (identifier) @name) @definition.module
289
-
290
- ; Type aliases, const, static, macros
291
- (type_item name: (type_identifier) @name) @definition.type
292
- (const_item name: (identifier) @name) @definition.const
293
- (static_item name: (identifier) @name) @definition.static
294
- (macro_definition name: (identifier) @name) @definition.macro
295
-
296
- ; Use statements
297
- (use_declaration argument: (_) @import.source) @import
298
-
299
- ; Calls
300
- (call_expression function: (identifier) @call.name) @call
301
- (call_expression function: (field_expression field: (field_identifier) @call.name)) @call
302
- (call_expression function: (scoped_identifier name: (identifier) @call.name)) @call
303
- (call_expression function: (generic_function function: (identifier) @call.name)) @call
304
-
305
- ; Heritage (trait implementation)
306
- (impl_item trait: (type_identifier) @heritage.trait type: (type_identifier) @heritage.class) @heritage
307
- (impl_item trait: (generic_type type: (type_identifier) @heritage.trait) type: (type_identifier) @heritage.class) @heritage
379
+ export const RUST_QUERIES = `
380
+ ; Functions & Items
381
+ (function_item name: (identifier) @name) @definition.function
382
+ (struct_item name: (type_identifier) @name) @definition.struct
383
+ (enum_item name: (type_identifier) @name) @definition.enum
384
+ (trait_item name: (type_identifier) @name) @definition.trait
385
+ (impl_item type: (type_identifier) @name !trait) @definition.impl
386
+ (impl_item type: (generic_type type: (type_identifier) @name) !trait) @definition.impl
387
+ (mod_item name: (identifier) @name) @definition.module
388
+
389
+ ; Type aliases, const, static, macros
390
+ (type_item name: (type_identifier) @name) @definition.type
391
+ (const_item name: (identifier) @name) @definition.const
392
+ (static_item name: (identifier) @name) @definition.static
393
+ (macro_definition name: (identifier) @name) @definition.macro
394
+
395
+ ; Use statements
396
+ (use_declaration argument: (_) @import.source) @import
397
+
398
+ ; Calls
399
+ (call_expression function: (identifier) @call.name) @call
400
+ (call_expression function: (field_expression field: (field_identifier) @call.name)) @call
401
+ (call_expression function: (scoped_identifier name: (identifier) @call.name)) @call
402
+ (call_expression function: (generic_function function: (identifier) @call.name)) @call
403
+
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
408
+ (impl_item trait: (type_identifier) @heritage.trait type: (type_identifier) @heritage.class) @heritage
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
- export const PHP_QUERIES = `
311
- ; ── Namespace ────────────────────────────────────────────────────────────────
312
- (namespace_definition
313
- name: (namespace_name) @name) @definition.namespace
314
-
315
- ; ── Classes ──────────────────────────────────────────────────────────────────
316
- (class_declaration
317
- name: (name) @name) @definition.class
318
-
319
- ; ── Interfaces ───────────────────────────────────────────────────────────────
320
- (interface_declaration
321
- name: (name) @name) @definition.interface
322
-
323
- ; ── Traits ───────────────────────────────────────────────────────────────────
324
- (trait_declaration
325
- name: (name) @name) @definition.trait
326
-
327
- ; ── Enums (PHP 8.1) ──────────────────────────────────────────────────────────
328
- (enum_declaration
329
- name: (name) @name) @definition.enum
330
-
331
- ; ── Top-level functions ───────────────────────────────────────────────────────
332
- (function_definition
333
- name: (name) @name) @definition.function
334
-
335
- ; ── Methods (including constructors) ─────────────────────────────────────────
336
- (method_declaration
337
- name: (name) @name) @definition.method
338
-
339
- ; ── Class properties (including Eloquent $fillable, $casts, etc.) ────────────
340
- (property_declaration
341
- (property_element
342
- (variable_name
343
- (name) @name))) @definition.property
344
-
345
- ; ── Imports: use statements ──────────────────────────────────────────────────
346
- ; Simple: use App\\Models\\User;
347
- (namespace_use_declaration
348
- (namespace_use_clause
349
- (qualified_name) @import.source)) @import
350
-
351
- ; ── Function/method calls ────────────────────────────────────────────────────
352
- ; Regular function call: foo()
353
- (function_call_expression
354
- function: (name) @call.name) @call
355
-
356
- ; Method call: $obj->method()
357
- (member_call_expression
358
- name: (name) @call.name) @call
359
-
360
- ; Nullsafe method call: $obj?->method()
361
- (nullsafe_member_call_expression
362
- name: (name) @call.name) @call
363
-
364
- ; Static call: Foo::bar() (php_only uses scoped_call_expression)
365
- (scoped_call_expression
366
- name: (name) @call.name) @call
367
-
368
- ; ── Heritage: extends ────────────────────────────────────────────────────────
369
- (class_declaration
370
- name: (name) @heritage.class
371
- (base_clause
372
- [(name) (qualified_name)] @heritage.extends)) @heritage
373
-
374
- ; ── Heritage: implements ─────────────────────────────────────────────────────
375
- (class_declaration
376
- name: (name) @heritage.class
377
- (class_interface_clause
378
- [(name) (qualified_name)] @heritage.implements)) @heritage.impl
379
-
380
- ; ── Heritage: use trait (must capture enclosing class name) ──────────────────
381
- (class_declaration
382
- name: (name) @heritage.class
383
- body: (declaration_list
384
- (use_declaration
385
- [(name) (qualified_name)] @heritage.trait))) @heritage
414
+ export const PHP_QUERIES = `
415
+ ; ── Namespace ────────────────────────────────────────────────────────────────
416
+ (namespace_definition
417
+ name: (namespace_name) @name) @definition.namespace
418
+
419
+ ; ── Classes ──────────────────────────────────────────────────────────────────
420
+ (class_declaration
421
+ name: (name) @name) @definition.class
422
+
423
+ ; ── Interfaces ───────────────────────────────────────────────────────────────
424
+ (interface_declaration
425
+ name: (name) @name) @definition.interface
426
+
427
+ ; ── Traits ───────────────────────────────────────────────────────────────────
428
+ (trait_declaration
429
+ name: (name) @name) @definition.trait
430
+
431
+ ; ── Enums (PHP 8.1) ──────────────────────────────────────────────────────────
432
+ (enum_declaration
433
+ name: (name) @name) @definition.enum
434
+
435
+ ; ── Top-level functions ───────────────────────────────────────────────────────
436
+ (function_definition
437
+ name: (name) @name) @definition.function
438
+
439
+ ; ── Methods (including constructors) ─────────────────────────────────────────
440
+ (method_declaration
441
+ name: (name) @name) @definition.method
442
+
443
+ ; ── Class properties (including Eloquent $fillable, $casts, etc.) ────────────
444
+ (property_declaration
445
+ (property_element
446
+ (variable_name
447
+ (name) @name))) @definition.property
448
+
449
+ ; ── Imports: use statements ──────────────────────────────────────────────────
450
+ ; Simple: use App\\Models\\User;
451
+ (namespace_use_declaration
452
+ (namespace_use_clause
453
+ (qualified_name) @import.source)) @import
454
+
455
+ ; ── Function/method calls ────────────────────────────────────────────────────
456
+ ; Regular function call: foo()
457
+ (function_call_expression
458
+ function: (name) @call.name) @call
459
+
460
+ ; Method call: $obj->method()
461
+ (member_call_expression
462
+ name: (name) @call.name) @call
463
+
464
+ ; Nullsafe method call: $obj?->method()
465
+ (nullsafe_member_call_expression
466
+ name: (name) @call.name) @call
467
+
468
+ ; Static call: Foo::bar() (php_only uses scoped_call_expression)
469
+ (scoped_call_expression
470
+ name: (name) @call.name) @call
471
+
472
+ ; Constructor call: new User()
473
+ (object_creation_expression (name) @call.name) @call
474
+
475
+ ; ── Heritage: extends ────────────────────────────────────────────────────────
476
+ (class_declaration
477
+ name: (name) @heritage.class
478
+ (base_clause
479
+ [(name) (qualified_name)] @heritage.extends)) @heritage
480
+
481
+ ; ── Heritage: implements ─────────────────────────────────────────────────────
482
+ (class_declaration
483
+ name: (name) @heritage.class
484
+ (class_interface_clause
485
+ [(name) (qualified_name)] @heritage.implements)) @heritage.impl
486
+
487
+ ; ── Heritage: use trait (must capture enclosing class name) ──────────────────
488
+ (class_declaration
489
+ name: (name) @heritage.class
490
+ body: (declaration_list
491
+ (use_declaration
492
+ [(name) (qualified_name)] @heritage.trait))) @heritage
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
386
537
  `;
387
538
  // Kotlin queries - works with tree-sitter-kotlin (fwcd/tree-sitter-kotlin)
388
539
  // Based on official tags.scm; functions use simple_identifier, classes use type_identifier
389
- export const KOTLIN_QUERIES = `
390
- ; ── Interfaces ─────────────────────────────────────────────────────────────
391
- ; tree-sitter-kotlin (fwcd) has no interface_declaration node type.
392
- ; Interfaces are class_declaration nodes with an anonymous "interface" keyword child.
393
- (class_declaration
394
- "interface"
395
- (type_identifier) @name) @definition.interface
396
-
397
- ; ── Classes (regular, data, sealed, enum) ────────────────────────────────
398
- ; All have the anonymous "class" keyword child. enum class has both
399
- ; "enum" and "class" children — the "class" child still matches.
400
- (class_declaration
401
- "class"
402
- (type_identifier) @name) @definition.class
403
-
404
- ; ── Object declarations (Kotlin singletons) ──────────────────────────────
405
- (object_declaration
406
- (type_identifier) @name) @definition.class
407
-
408
- ; ── Companion objects (named only) ───────────────────────────────────────
409
- (companion_object
410
- (type_identifier) @name) @definition.class
411
-
412
- ; ── Functions (top-level, member, extension) ──────────────────────────────
413
- (function_declaration
414
- (simple_identifier) @name) @definition.function
415
-
416
- ; ── Properties ───────────────────────────────────────────────────────────
417
- (property_declaration
418
- (variable_declaration
419
- (simple_identifier) @name)) @definition.property
420
-
421
- ; ── Enum entries ─────────────────────────────────────────────────────────
422
- (enum_entry
423
- (simple_identifier) @name) @definition.enum
424
-
425
- ; ── Type aliases ─────────────────────────────────────────────────────────
426
- (type_alias
427
- (type_identifier) @name) @definition.type
428
-
429
- ; ── Imports ──────────────────────────────────────────────────────────────
430
- (import_header
431
- (identifier) @import.source) @import
432
-
433
- ; ── Function calls (direct) ──────────────────────────────────────────────
434
- (call_expression
435
- (simple_identifier) @call.name) @call
436
-
437
- ; ── Method calls (via navigation: obj.method()) ──────────────────────────
438
- (call_expression
439
- (navigation_expression
440
- (navigation_suffix
441
- (simple_identifier) @call.name))) @call
442
-
443
- ; ── Constructor invocations ──────────────────────────────────────────────
444
- (constructor_invocation
445
- (user_type
446
- (type_identifier) @call.name)) @call
447
-
448
- ; ── Infix function calls (e.g., a to b, x until y) ──────────────────────
449
- (infix_expression
450
- (simple_identifier) @call.name) @call
451
-
452
- ; ── Heritage: extends / implements via delegation_specifier ──────────────
453
- ; Interface implementation (bare user_type): class Foo : Bar
454
- (class_declaration
455
- (type_identifier) @heritage.class
456
- (delegation_specifier
457
- (user_type (type_identifier) @heritage.extends))) @heritage
458
-
459
- ; Class extension (constructor_invocation): class Foo : Bar()
460
- (class_declaration
461
- (type_identifier) @heritage.class
462
- (delegation_specifier
463
- (constructor_invocation
464
- (user_type (type_identifier) @heritage.extends)))) @heritage
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
465
616
  `;
466
617
  // Swift queries - works with tree-sitter-swift
467
- export const SWIFT_QUERIES = `
468
- ; Classes
469
- (class_declaration "class" name: (type_identifier) @name) @definition.class
470
-
471
- ; Structs
472
- (class_declaration "struct" name: (type_identifier) @name) @definition.struct
473
-
474
- ; Enums
475
- (class_declaration "enum" name: (type_identifier) @name) @definition.enum
476
-
477
- ; Extensions (mapped to class — no dedicated label in schema)
478
- (class_declaration "extension" name: (user_type (type_identifier) @name)) @definition.class
479
-
480
- ; Actors
481
- (class_declaration "actor" name: (type_identifier) @name) @definition.class
482
-
483
- ; Protocols (mapped to interface)
484
- (protocol_declaration name: (type_identifier) @name) @definition.interface
485
-
486
- ; Type aliases
487
- (typealias_declaration name: (type_identifier) @name) @definition.type
488
-
489
- ; Functions (top-level and methods)
490
- (function_declaration name: (simple_identifier) @name) @definition.function
491
-
492
- ; Protocol method declarations
493
- (protocol_function_declaration name: (simple_identifier) @name) @definition.method
494
-
495
- ; Initializers
496
- (init_declaration) @definition.constructor
497
-
498
- ; Properties (stored and computed)
499
- (property_declaration (pattern (simple_identifier) @name)) @definition.property
500
-
501
- ; Imports
502
- (import_declaration (identifier (simple_identifier) @import.source)) @import
503
-
504
- ; Calls - direct function calls
505
- (call_expression (simple_identifier) @call.name) @call
506
-
507
- ; Calls - member/navigation calls (obj.method())
508
- (call_expression (navigation_expression (navigation_suffix (simple_identifier) @call.name))) @call
509
-
510
- ; Heritage - class/struct/enum inheritance and protocol conformance
511
- (class_declaration name: (type_identifier) @heritage.class
512
- (inheritance_specifier inherits_from: (user_type (type_identifier) @heritage.extends))) @heritage
513
-
514
- ; Heritage - protocol inheritance
515
- (protocol_declaration name: (type_identifier) @heritage.class
516
- (inheritance_specifier inherits_from: (user_type (type_identifier) @heritage.extends))) @heritage
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
517
673
  `;
518
674
  export const LANGUAGE_QUERIES = {
519
675
  [SupportedLanguages.TypeScript]: TYPESCRIPT_QUERIES,
@@ -524,6 +680,7 @@ export const LANGUAGE_QUERIES = {
524
680
  [SupportedLanguages.Go]: GO_QUERIES,
525
681
  [SupportedLanguages.CPlusPlus]: CPP_QUERIES,
526
682
  [SupportedLanguages.CSharp]: CSHARP_QUERIES,
683
+ [SupportedLanguages.Ruby]: RUBY_QUERIES,
527
684
  [SupportedLanguages.Rust]: RUST_QUERIES,
528
685
  [SupportedLanguages.PHP]: PHP_QUERIES,
529
686
  [SupportedLanguages.Kotlin]: KOTLIN_QUERIES,