gitnexus 1.6.2-rc.8 → 1.6.2

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 (222) hide show
  1. package/dist/_shared/lbug/schema-constants.d.ts +1 -1
  2. package/dist/_shared/lbug/schema-constants.d.ts.map +1 -1
  3. package/dist/_shared/lbug/schema-constants.js +1 -0
  4. package/dist/_shared/lbug/schema-constants.js.map +1 -1
  5. package/dist/_shared/mro-strategy.d.ts +38 -16
  6. package/dist/_shared/mro-strategy.d.ts.map +1 -1
  7. package/dist/cli/ai-context.js +0 -58
  8. package/dist/cli/analyze.js +3 -0
  9. package/dist/core/embeddings/ast-utils.d.ts +22 -0
  10. package/dist/core/embeddings/ast-utils.js +105 -0
  11. package/dist/core/embeddings/character-chunk.d.ts +12 -0
  12. package/dist/core/embeddings/character-chunk.js +43 -0
  13. package/dist/core/embeddings/chunker.d.ts +14 -0
  14. package/dist/core/embeddings/chunker.js +234 -0
  15. package/dist/core/embeddings/embedder.js +5 -0
  16. package/dist/core/embeddings/embedding-pipeline.d.ts +20 -24
  17. package/dist/core/embeddings/embedding-pipeline.js +176 -107
  18. package/dist/core/embeddings/line-index.d.ts +7 -0
  19. package/dist/core/embeddings/line-index.js +42 -0
  20. package/dist/core/embeddings/server-mapping.d.ts +15 -0
  21. package/dist/core/embeddings/server-mapping.js +33 -0
  22. package/dist/core/embeddings/structural-extractor.d.ts +15 -0
  23. package/dist/core/embeddings/structural-extractor.js +58 -0
  24. package/dist/core/embeddings/text-generator.d.ts +20 -13
  25. package/dist/core/embeddings/text-generator.js +151 -119
  26. package/dist/core/embeddings/types.d.ts +81 -3
  27. package/dist/core/embeddings/types.js +105 -3
  28. package/dist/core/group/extractors/http-patterns/node.js +130 -0
  29. package/dist/core/ingestion/call-extractors/configs/c-cpp.d.ts +3 -0
  30. package/dist/core/ingestion/call-extractors/configs/c-cpp.js +8 -0
  31. package/dist/core/ingestion/call-extractors/configs/csharp.d.ts +2 -0
  32. package/dist/core/ingestion/call-extractors/configs/csharp.js +6 -0
  33. package/dist/core/ingestion/call-extractors/configs/dart.d.ts +2 -0
  34. package/dist/core/ingestion/call-extractors/configs/dart.js +5 -0
  35. package/dist/core/ingestion/call-extractors/configs/go.d.ts +2 -0
  36. package/dist/core/ingestion/call-extractors/configs/go.js +5 -0
  37. package/dist/core/ingestion/call-extractors/configs/jvm.d.ts +3 -0
  38. package/dist/core/ingestion/call-extractors/configs/jvm.js +51 -0
  39. package/dist/core/ingestion/call-extractors/configs/php.d.ts +2 -0
  40. package/dist/core/ingestion/call-extractors/configs/php.js +5 -0
  41. package/dist/core/ingestion/call-extractors/configs/python.d.ts +2 -0
  42. package/dist/core/ingestion/call-extractors/configs/python.js +5 -0
  43. package/dist/core/ingestion/call-extractors/configs/ruby.d.ts +2 -0
  44. package/dist/core/ingestion/call-extractors/configs/ruby.js +5 -0
  45. package/dist/core/ingestion/call-extractors/configs/rust.d.ts +2 -0
  46. package/dist/core/ingestion/call-extractors/configs/rust.js +5 -0
  47. package/dist/core/ingestion/call-extractors/configs/swift.d.ts +2 -0
  48. package/dist/core/ingestion/call-extractors/configs/swift.js +5 -0
  49. package/dist/core/ingestion/call-extractors/configs/typescript-javascript.d.ts +3 -0
  50. package/dist/core/ingestion/call-extractors/configs/typescript-javascript.js +8 -0
  51. package/dist/core/ingestion/call-extractors/generic.d.ts +5 -0
  52. package/dist/core/ingestion/call-extractors/generic.js +59 -0
  53. package/dist/core/ingestion/call-processor.d.ts +2 -4
  54. package/dist/core/ingestion/call-processor.js +221 -89
  55. package/dist/core/ingestion/call-routing.d.ts +8 -12
  56. package/dist/core/ingestion/call-routing.js +13 -34
  57. package/dist/core/ingestion/call-types.d.ts +135 -0
  58. package/dist/core/ingestion/call-types.js +2 -0
  59. package/dist/core/ingestion/class-extractors/configs/c-cpp.d.ts +3 -0
  60. package/dist/core/ingestion/class-extractors/configs/c-cpp.js +11 -0
  61. package/dist/core/ingestion/class-extractors/configs/csharp.d.ts +2 -0
  62. package/dist/core/ingestion/class-extractors/configs/csharp.js +21 -0
  63. package/dist/core/ingestion/class-extractors/configs/dart.d.ts +2 -0
  64. package/dist/core/ingestion/class-extractors/configs/dart.js +7 -0
  65. package/dist/core/ingestion/class-extractors/configs/go.d.ts +2 -0
  66. package/dist/core/ingestion/class-extractors/configs/go.js +20 -0
  67. package/dist/core/ingestion/class-extractors/configs/jvm.d.ts +3 -0
  68. package/dist/core/ingestion/class-extractors/configs/jvm.js +35 -0
  69. package/dist/core/ingestion/class-extractors/configs/php.d.ts +2 -0
  70. package/dist/core/ingestion/class-extractors/configs/php.js +7 -0
  71. package/dist/core/ingestion/class-extractors/configs/python.d.ts +2 -0
  72. package/dist/core/ingestion/class-extractors/configs/python.js +7 -0
  73. package/dist/core/ingestion/class-extractors/configs/ruby.d.ts +2 -0
  74. package/dist/core/ingestion/class-extractors/configs/ruby.js +7 -0
  75. package/dist/core/ingestion/class-extractors/configs/rust.d.ts +2 -0
  76. package/dist/core/ingestion/class-extractors/configs/rust.js +7 -0
  77. package/dist/core/ingestion/class-extractors/configs/swift.d.ts +2 -0
  78. package/dist/core/ingestion/class-extractors/configs/swift.js +18 -0
  79. package/dist/core/ingestion/class-extractors/configs/typescript-javascript.d.ts +4 -0
  80. package/dist/core/ingestion/class-extractors/configs/typescript-javascript.js +28 -0
  81. package/dist/core/ingestion/field-types.d.ts +1 -1
  82. package/dist/core/ingestion/heritage-extractors/configs/go.d.ts +13 -0
  83. package/dist/core/ingestion/heritage-extractors/configs/go.js +20 -0
  84. package/dist/core/ingestion/heritage-extractors/configs/ruby.d.ts +18 -0
  85. package/dist/core/ingestion/heritage-extractors/configs/ruby.js +65 -0
  86. package/dist/core/ingestion/heritage-extractors/generic.d.ts +23 -0
  87. package/dist/core/ingestion/heritage-extractors/generic.js +47 -0
  88. package/dist/core/ingestion/heritage-processor.d.ts +9 -0
  89. package/dist/core/ingestion/heritage-processor.js +120 -85
  90. package/dist/core/ingestion/heritage-types.d.ts +73 -0
  91. package/dist/core/ingestion/heritage-types.js +2 -0
  92. package/dist/core/ingestion/import-resolvers/configs/c-cpp.d.ts +7 -0
  93. package/dist/core/ingestion/import-resolvers/configs/c-cpp.js +14 -0
  94. package/dist/core/ingestion/import-resolvers/configs/csharp.d.ts +8 -0
  95. package/dist/core/ingestion/import-resolvers/configs/csharp.js +27 -0
  96. package/dist/core/ingestion/import-resolvers/configs/dart.d.ts +17 -0
  97. package/dist/core/ingestion/import-resolvers/{dart.js → configs/dart.js} +26 -16
  98. package/dist/core/ingestion/import-resolvers/configs/go.d.ts +8 -0
  99. package/dist/core/ingestion/import-resolvers/configs/go.js +26 -0
  100. package/dist/core/ingestion/import-resolvers/configs/jvm.d.ts +13 -0
  101. package/dist/core/ingestion/import-resolvers/configs/jvm.js +68 -0
  102. package/dist/core/ingestion/import-resolvers/configs/php.d.ts +8 -0
  103. package/dist/core/ingestion/import-resolvers/configs/php.js +15 -0
  104. package/dist/core/ingestion/import-resolvers/configs/python.d.ts +12 -0
  105. package/dist/core/ingestion/import-resolvers/configs/python.js +41 -0
  106. package/dist/core/ingestion/import-resolvers/configs/ruby.d.ts +8 -0
  107. package/dist/core/ingestion/import-resolvers/configs/ruby.js +16 -0
  108. package/dist/core/ingestion/import-resolvers/configs/rust.d.ts +8 -0
  109. package/dist/core/ingestion/import-resolvers/configs/rust.js +54 -0
  110. package/dist/core/ingestion/import-resolvers/configs/swift.d.ts +8 -0
  111. package/dist/core/ingestion/import-resolvers/{swift.js → configs/swift.js} +10 -5
  112. package/dist/core/ingestion/import-resolvers/configs/typescript-javascript.d.ts +9 -0
  113. package/dist/core/ingestion/import-resolvers/configs/typescript-javascript.js +23 -0
  114. package/dist/core/ingestion/import-resolvers/csharp.d.ts +4 -5
  115. package/dist/core/ingestion/import-resolvers/csharp.js +4 -20
  116. package/dist/core/ingestion/import-resolvers/go.d.ts +4 -5
  117. package/dist/core/ingestion/import-resolvers/go.js +4 -19
  118. package/dist/core/ingestion/import-resolvers/jvm.d.ts +5 -10
  119. package/dist/core/ingestion/import-resolvers/jvm.js +5 -58
  120. package/dist/core/ingestion/import-resolvers/php.d.ts +4 -5
  121. package/dist/core/ingestion/import-resolvers/php.js +4 -7
  122. package/dist/core/ingestion/import-resolvers/python.d.ts +3 -6
  123. package/dist/core/ingestion/import-resolvers/python.js +3 -18
  124. package/dist/core/ingestion/import-resolvers/resolver-factory.d.ts +24 -0
  125. package/dist/core/ingestion/import-resolvers/resolver-factory.js +33 -0
  126. package/dist/core/ingestion/import-resolvers/ruby.d.ts +4 -5
  127. package/dist/core/ingestion/import-resolvers/ruby.js +4 -7
  128. package/dist/core/ingestion/import-resolvers/rust.d.ts +4 -5
  129. package/dist/core/ingestion/import-resolvers/rust.js +4 -47
  130. package/dist/core/ingestion/import-resolvers/standard.d.ts +3 -9
  131. package/dist/core/ingestion/import-resolvers/standard.js +7 -8
  132. package/dist/core/ingestion/import-resolvers/types.d.ts +24 -0
  133. package/dist/core/ingestion/language-provider.d.ts +80 -0
  134. package/dist/core/ingestion/languages/c-cpp.js +18 -12
  135. package/dist/core/ingestion/languages/csharp.js +13 -21
  136. package/dist/core/ingestion/languages/dart.js +13 -7
  137. package/dist/core/ingestion/languages/go.js +14 -20
  138. package/dist/core/ingestion/languages/java.js +13 -18
  139. package/dist/core/ingestion/languages/kotlin.js +13 -13
  140. package/dist/core/ingestion/languages/php.js +13 -7
  141. package/dist/core/ingestion/languages/python.js +13 -7
  142. package/dist/core/ingestion/languages/ruby.js +103 -22
  143. package/dist/core/ingestion/languages/rust.js +13 -7
  144. package/dist/core/ingestion/languages/swift.js +13 -18
  145. package/dist/core/ingestion/languages/typescript.js +18 -23
  146. package/dist/core/ingestion/languages/vue.js +13 -17
  147. package/dist/core/ingestion/model/heritage-map.d.ts +35 -0
  148. package/dist/core/ingestion/model/heritage-map.js +110 -9
  149. package/dist/core/ingestion/model/index.d.ts +2 -2
  150. package/dist/core/ingestion/model/index.js +1 -1
  151. package/dist/core/ingestion/model/resolve.d.ts +33 -28
  152. package/dist/core/ingestion/model/resolve.js +111 -27
  153. package/dist/core/ingestion/parsing-processor.d.ts +1 -2
  154. package/dist/core/ingestion/pipeline-phases/parse-impl.d.ts +1 -0
  155. package/dist/core/ingestion/pipeline-phases/parse-impl.js +9 -3
  156. package/dist/core/ingestion/pipeline-phases/parse.d.ts +7 -0
  157. package/dist/core/ingestion/pipeline.d.ts +11 -0
  158. package/dist/core/ingestion/pipeline.js +9 -2
  159. package/dist/core/ingestion/tree-sitter-queries.d.ts +11 -11
  160. package/dist/core/ingestion/tree-sitter-queries.js +81 -0
  161. package/dist/core/ingestion/type-env.d.ts +1 -1
  162. package/dist/core/ingestion/utils/ast-helpers.d.ts +1 -1
  163. package/dist/core/ingestion/utils/ast-helpers.js +22 -2
  164. package/dist/core/ingestion/utils/ruby-self-call.d.ts +52 -0
  165. package/dist/core/ingestion/utils/ruby-self-call.js +59 -0
  166. package/dist/core/ingestion/variable-extractors/configs/c-cpp.d.ts +3 -0
  167. package/dist/core/ingestion/variable-extractors/configs/c-cpp.js +81 -0
  168. package/dist/core/ingestion/variable-extractors/configs/csharp.d.ts +9 -0
  169. package/dist/core/ingestion/variable-extractors/configs/csharp.js +63 -0
  170. package/dist/core/ingestion/variable-extractors/configs/dart.d.ts +2 -0
  171. package/dist/core/ingestion/variable-extractors/configs/dart.js +94 -0
  172. package/dist/core/ingestion/variable-extractors/configs/go.d.ts +2 -0
  173. package/dist/core/ingestion/variable-extractors/configs/go.js +83 -0
  174. package/dist/core/ingestion/variable-extractors/configs/jvm.d.ts +18 -0
  175. package/dist/core/ingestion/variable-extractors/configs/jvm.js +115 -0
  176. package/dist/core/ingestion/variable-extractors/configs/php.d.ts +14 -0
  177. package/dist/core/ingestion/variable-extractors/configs/php.js +58 -0
  178. package/dist/core/ingestion/variable-extractors/configs/python.d.ts +2 -0
  179. package/dist/core/ingestion/variable-extractors/configs/python.js +101 -0
  180. package/dist/core/ingestion/variable-extractors/configs/ruby.d.ts +11 -0
  181. package/dist/core/ingestion/variable-extractors/configs/ruby.js +52 -0
  182. package/dist/core/ingestion/variable-extractors/configs/rust.d.ts +2 -0
  183. package/dist/core/ingestion/variable-extractors/configs/rust.js +76 -0
  184. package/dist/core/ingestion/variable-extractors/configs/swift.d.ts +2 -0
  185. package/dist/core/ingestion/variable-extractors/configs/swift.js +88 -0
  186. package/dist/core/ingestion/variable-extractors/configs/typescript-javascript.d.ts +3 -0
  187. package/dist/core/ingestion/variable-extractors/configs/typescript-javascript.js +83 -0
  188. package/dist/core/ingestion/variable-extractors/generic.d.ts +5 -0
  189. package/dist/core/ingestion/variable-extractors/generic.js +80 -0
  190. package/dist/core/ingestion/variable-types.d.ts +82 -0
  191. package/dist/core/ingestion/variable-types.js +2 -0
  192. package/dist/core/ingestion/workers/parse-worker.js +244 -217
  193. package/dist/core/ingestion/workers/worker-pool.js +3 -0
  194. package/dist/core/lbug/csv-generator.js +1 -0
  195. package/dist/core/lbug/lbug-adapter.d.ts +4 -5
  196. package/dist/core/lbug/lbug-adapter.js +38 -14
  197. package/dist/core/lbug/schema.d.ts +2 -1
  198. package/dist/core/lbug/schema.js +10 -1
  199. package/dist/core/run-analyze.js +6 -7
  200. package/dist/core/tree-sitter/parser-loader.d.ts +3 -0
  201. package/dist/core/tree-sitter/parser-loader.js +17 -8
  202. package/dist/mcp/core/embedder.js +5 -0
  203. package/dist/mcp/local/local-backend.js +29 -19
  204. package/dist/server/api.js +2 -0
  205. package/dist/types/pipeline.d.ts +6 -0
  206. package/package.json +8 -7
  207. package/scripts/build-tree-sitter-proto.cjs +82 -0
  208. package/vendor/node_modules/node-addon-api/node_addon_api.Makefile +6 -0
  209. package/vendor/node_modules/node-addon-api/node_addon_api.target.mk +104 -0
  210. package/vendor/node_modules/node-addon-api/node_addon_api_except.target.mk +108 -0
  211. package/vendor/node_modules/node-addon-api/node_addon_api_except_all.target.mk +104 -0
  212. package/vendor/node_modules/node-addon-api/node_addon_api_maybe.target.mk +104 -0
  213. package/vendor/tree-sitter-proto/package.json +1 -7
  214. package/dist/core/ingestion/call-sites/extract-language-call-site.d.ts +0 -10
  215. package/dist/core/ingestion/call-sites/extract-language-call-site.js +0 -22
  216. package/dist/core/ingestion/call-sites/java.d.ts +0 -9
  217. package/dist/core/ingestion/call-sites/java.js +0 -30
  218. package/dist/core/ingestion/import-resolvers/dart.d.ts +0 -7
  219. package/dist/core/ingestion/import-resolvers/swift.d.ts +0 -7
  220. package/dist/core/ingestion/import-resolvers/vue.d.ts +0 -8
  221. package/dist/core/ingestion/import-resolvers/vue.js +0 -9
  222. package/scripts/preinstall-cleanup.cjs +0 -34
@@ -0,0 +1,81 @@
1
+ // gitnexus/src/core/ingestion/variable-extractors/configs/c-cpp.ts
2
+ import { SupportedLanguages } from '../../../../_shared/index.js';
3
+ import { hasKeyword } from '../../field-extractors/configs/helpers.js';
4
+ import { extractSimpleTypeName } from '../../type-extractors/shared.js';
5
+ /**
6
+ * C/C++ variable extraction config.
7
+ *
8
+ * Handles global/namespace-scoped variable declarations:
9
+ * - `int x = 5;`
10
+ * - `const int MAX = 100;`
11
+ * - `static int counter = 0;`
12
+ * - `constexpr int SIZE = 10;` (C++)
13
+ * - `extern int shared;`
14
+ *
15
+ * tree-sitter-c/cpp uses declaration for variable declarations.
16
+ */
17
+ function extractCVarName(node) {
18
+ // declaration → declarator (init_declarator or identifier)
19
+ for (let i = 0; i < node.namedChildCount; i++) {
20
+ const child = node.namedChild(i);
21
+ if (child?.type === 'init_declarator') {
22
+ const declarator = child.childForFieldName('declarator');
23
+ if (declarator?.type === 'identifier')
24
+ return declarator.text;
25
+ if (declarator?.type === 'pointer_declarator') {
26
+ const inner = declarator.namedChildren.find((c) => c.type === 'identifier');
27
+ return inner?.text;
28
+ }
29
+ }
30
+ if (child?.type === 'identifier')
31
+ return child.text;
32
+ }
33
+ return undefined;
34
+ }
35
+ function extractCVarType(node) {
36
+ const typeNode = node.childForFieldName('type');
37
+ if (typeNode)
38
+ return extractSimpleTypeName(typeNode) ?? typeNode.text?.trim();
39
+ // Fallback: first primitive_type or type_identifier child
40
+ for (let i = 0; i < node.namedChildCount; i++) {
41
+ const child = node.namedChild(i);
42
+ if (child?.type === 'primitive_type' ||
43
+ child?.type === 'type_identifier' ||
44
+ child?.type === 'sized_type_specifier') {
45
+ return child.text?.trim();
46
+ }
47
+ }
48
+ return undefined;
49
+ }
50
+ const shared = {
51
+ constNodeTypes: [],
52
+ staticNodeTypes: [],
53
+ variableNodeTypes: ['declaration'],
54
+ extractName: extractCVarName,
55
+ extractType: extractCVarType,
56
+ extractVisibility(node) {
57
+ // C/C++ visibility is file-scoped by default (static = file-private)
58
+ if (hasKeyword(node, 'static'))
59
+ return 'private';
60
+ if (hasKeyword(node, 'extern'))
61
+ return 'public';
62
+ return 'public';
63
+ },
64
+ isConst(node) {
65
+ return hasKeyword(node, 'const') || hasKeyword(node, 'constexpr');
66
+ },
67
+ isStatic(node) {
68
+ return hasKeyword(node, 'static');
69
+ },
70
+ isMutable(node) {
71
+ return !hasKeyword(node, 'const') && !hasKeyword(node, 'constexpr');
72
+ },
73
+ };
74
+ export const cVariableConfig = {
75
+ ...shared,
76
+ language: SupportedLanguages.C,
77
+ };
78
+ export const cppVariableConfig = {
79
+ ...shared,
80
+ language: SupportedLanguages.CPlusPlus,
81
+ };
@@ -0,0 +1,9 @@
1
+ import type { VariableExtractionConfig } from '../../variable-types.js';
2
+ /**
3
+ * C# variable extraction config.
4
+ *
5
+ * C# does not have true top-level variables (pre-C# 9). In C# 9+ top-level
6
+ * statements, local_declaration_statement can appear at program scope.
7
+ * Class-scoped fields are handled by the field extractor.
8
+ */
9
+ export declare const csharpVariableConfig: VariableExtractionConfig;
@@ -0,0 +1,63 @@
1
+ // gitnexus/src/core/ingestion/variable-extractors/configs/csharp.ts
2
+ import { SupportedLanguages } from '../../../../_shared/index.js';
3
+ import { collectModifierTexts } from '../../field-extractors/configs/helpers.js';
4
+ import { extractSimpleTypeName } from '../../type-extractors/shared.js';
5
+ /**
6
+ * C# variable extraction config.
7
+ *
8
+ * C# does not have true top-level variables (pre-C# 9). In C# 9+ top-level
9
+ * statements, local_declaration_statement can appear at program scope.
10
+ * Class-scoped fields are handled by the field extractor.
11
+ */
12
+ export const csharpVariableConfig = {
13
+ language: SupportedLanguages.CSharp,
14
+ constNodeTypes: [],
15
+ staticNodeTypes: [],
16
+ variableNodeTypes: ['local_declaration_statement'],
17
+ extractName(node) {
18
+ // local_declaration_statement → variable_declaration → variable_declarator → identifier
19
+ const varDecl = node.namedChildren.find((c) => c.type === 'variable_declaration');
20
+ if (!varDecl)
21
+ return undefined;
22
+ const declarator = varDecl.namedChildren.find((c) => c.type === 'variable_declarator');
23
+ const name = declarator?.childForFieldName('name');
24
+ return name?.type === 'identifier' ? name.text : undefined;
25
+ },
26
+ extractType(node) {
27
+ const varDecl = node.namedChildren.find((c) => c.type === 'variable_declaration');
28
+ if (!varDecl)
29
+ return undefined;
30
+ const typeNode = varDecl.childForFieldName('type');
31
+ if (typeNode)
32
+ return extractSimpleTypeName(typeNode) ?? typeNode.text?.trim();
33
+ return undefined;
34
+ },
35
+ extractVisibility(node) {
36
+ const mods = collectModifierTexts(node);
37
+ if (mods.has('public'))
38
+ return 'public';
39
+ if (mods.has('private'))
40
+ return 'private';
41
+ if (mods.has('protected') && mods.has('internal'))
42
+ return 'protected internal';
43
+ if (mods.has('private') && mods.has('protected'))
44
+ return 'private protected';
45
+ if (mods.has('protected'))
46
+ return 'protected';
47
+ if (mods.has('internal'))
48
+ return 'internal';
49
+ return 'private';
50
+ },
51
+ isConst(node) {
52
+ const mods = collectModifierTexts(node);
53
+ return mods.has('const');
54
+ },
55
+ isStatic(node) {
56
+ const mods = collectModifierTexts(node);
57
+ return mods.has('static');
58
+ },
59
+ isMutable(node) {
60
+ const mods = collectModifierTexts(node);
61
+ return !mods.has('const') && !mods.has('readonly');
62
+ },
63
+ };
@@ -0,0 +1,2 @@
1
+ import type { VariableExtractionConfig } from '../../variable-types.js';
2
+ export declare const dartVariableConfig: VariableExtractionConfig;
@@ -0,0 +1,94 @@
1
+ // gitnexus/src/core/ingestion/variable-extractors/configs/dart.ts
2
+ import { SupportedLanguages } from '../../../../_shared/index.js';
3
+ import { extractSimpleTypeName } from '../../type-extractors/shared.js';
4
+ /**
5
+ * Dart variable extraction config.
6
+ *
7
+ * Dart has top-level variable and constant declarations:
8
+ * - `const maxSize = 100;`
9
+ * - `final String name = "dart";`
10
+ * - `var counter = 0;`
11
+ * - `int x = 5;`
12
+ *
13
+ * tree-sitter-dart uses:
14
+ * - declaration (with initialized_identifier_list) for file-scope variables
15
+ */
16
+ function extractDartVarName(node) {
17
+ // declaration → initialized_variable_definition → identifier
18
+ for (let i = 0; i < node.namedChildCount; i++) {
19
+ const child = node.namedChild(i);
20
+ if (child?.type === 'initialized_variable_definition') {
21
+ const name = child.childForFieldName('name');
22
+ if (name)
23
+ return name.text;
24
+ // Fallback: first identifier
25
+ for (let j = 0; j < child.namedChildCount; j++) {
26
+ const gc = child.namedChild(j);
27
+ if (gc?.type === 'identifier')
28
+ return gc.text;
29
+ }
30
+ }
31
+ // declaration → initialized_identifier_list → initialized_identifier → identifier
32
+ if (child?.type === 'initialized_identifier_list') {
33
+ for (let j = 0; j < child.namedChildCount; j++) {
34
+ const gc = child.namedChild(j);
35
+ if (gc?.type === 'initialized_identifier') {
36
+ const ident = gc.namedChildren.find((c) => c.type === 'identifier');
37
+ if (ident)
38
+ return ident.text;
39
+ }
40
+ }
41
+ }
42
+ }
43
+ return undefined;
44
+ }
45
+ function extractDartVarType(node) {
46
+ for (let i = 0; i < node.namedChildCount; i++) {
47
+ const child = node.namedChild(i);
48
+ if (child?.type === 'initialized_variable_definition') {
49
+ const typeNode = child.childForFieldName('type');
50
+ if (typeNode)
51
+ return extractSimpleTypeName(typeNode) ?? typeNode.text?.trim();
52
+ }
53
+ }
54
+ // Look for type_identifier directly on the node
55
+ for (let i = 0; i < node.namedChildCount; i++) {
56
+ const child = node.namedChild(i);
57
+ if (child?.type === 'type_identifier')
58
+ return child.text;
59
+ }
60
+ return undefined;
61
+ }
62
+ function hasDartKeyword(node, keyword) {
63
+ for (let i = 0; i < node.childCount; i++) {
64
+ const child = node.child(i);
65
+ if (child?.text === keyword)
66
+ return true;
67
+ }
68
+ return false;
69
+ }
70
+ export const dartVariableConfig = {
71
+ language: SupportedLanguages.Dart,
72
+ constNodeTypes: [],
73
+ staticNodeTypes: [],
74
+ variableNodeTypes: ['declaration'],
75
+ extractName: extractDartVarName,
76
+ extractType: extractDartVarType,
77
+ extractVisibility(node) {
78
+ const name = extractDartVarName(node);
79
+ if (!name)
80
+ return 'public';
81
+ // Dart convention: underscore prefix = library-private
82
+ return name.startsWith('_') ? 'private' : 'public';
83
+ },
84
+ isConst(node) {
85
+ return hasDartKeyword(node, 'const') || hasDartKeyword(node, 'final');
86
+ },
87
+ isStatic(_node) {
88
+ // Top-level Dart variables are not static
89
+ return false;
90
+ },
91
+ isMutable(node) {
92
+ return !hasDartKeyword(node, 'const') && !hasDartKeyword(node, 'final');
93
+ },
94
+ };
@@ -0,0 +1,2 @@
1
+ import type { VariableExtractionConfig } from '../../variable-types.js';
2
+ export declare const goVariableConfig: VariableExtractionConfig;
@@ -0,0 +1,83 @@
1
+ // gitnexus/src/core/ingestion/variable-extractors/configs/go.ts
2
+ import { SupportedLanguages } from '../../../../_shared/index.js';
3
+ import { extractSimpleTypeName } from '../../type-extractors/shared.js';
4
+ /**
5
+ * Go variable extraction config.
6
+ *
7
+ * Go has package-scoped var and const declarations:
8
+ * - `var x int = 5`
9
+ * - `const MaxSize = 100`
10
+ * - `var ( ... )` grouped declarations
11
+ *
12
+ * tree-sitter-go uses:
13
+ * - var_declaration → var_spec → identifier, type
14
+ * - const_declaration → const_spec → identifier, type
15
+ *
16
+ * Visibility: uppercase first letter = exported (public), lowercase = unexported (package).
17
+ */
18
+ function extractGoVarName(node) {
19
+ // var_declaration/const_declaration → var_spec/const_spec → identifier
20
+ for (let i = 0; i < node.namedChildCount; i++) {
21
+ const child = node.namedChild(i);
22
+ if (child?.type === 'var_spec' || child?.type === 'const_spec') {
23
+ const name = child.childForFieldName('name');
24
+ if (name)
25
+ return name.text;
26
+ // Fallback: first identifier child
27
+ for (let j = 0; j < child.namedChildCount; j++) {
28
+ const gc = child.namedChild(j);
29
+ if (gc?.type === 'identifier')
30
+ return gc.text;
31
+ }
32
+ }
33
+ }
34
+ // short_var_declaration: x := 5 → expression_list → identifier
35
+ if (node.type === 'short_var_declaration') {
36
+ const left = node.childForFieldName('left');
37
+ if (left?.type === 'expression_list') {
38
+ const firstIdent = left.namedChildren.find((c) => c.type === 'identifier');
39
+ if (firstIdent)
40
+ return firstIdent.text;
41
+ }
42
+ }
43
+ return undefined;
44
+ }
45
+ function extractGoVarType(node) {
46
+ for (let i = 0; i < node.namedChildCount; i++) {
47
+ const child = node.namedChild(i);
48
+ if (child?.type === 'var_spec' || child?.type === 'const_spec') {
49
+ const typeNode = child.childForFieldName('type');
50
+ if (typeNode)
51
+ return extractSimpleTypeName(typeNode) ?? typeNode.text?.trim();
52
+ }
53
+ }
54
+ return undefined;
55
+ }
56
+ export const goVariableConfig = {
57
+ language: SupportedLanguages.Go,
58
+ constNodeTypes: ['const_declaration'],
59
+ staticNodeTypes: [],
60
+ variableNodeTypes: ['var_declaration', 'short_var_declaration'],
61
+ extractName: extractGoVarName,
62
+ extractType: extractGoVarType,
63
+ extractVisibility(node) {
64
+ const name = extractGoVarName(node);
65
+ if (!name)
66
+ return 'package';
67
+ // Go visibility: uppercase first letter = exported
68
+ const firstChar = name.charAt(0);
69
+ return firstChar === firstChar.toUpperCase() && firstChar !== firstChar.toLowerCase()
70
+ ? 'public'
71
+ : 'package';
72
+ },
73
+ isConst(node) {
74
+ return node.type === 'const_declaration';
75
+ },
76
+ isStatic(_node) {
77
+ // Go does not have static declarations
78
+ return false;
79
+ },
80
+ isMutable(node) {
81
+ return node.type !== 'const_declaration';
82
+ },
83
+ };
@@ -0,0 +1,18 @@
1
+ import type { VariableExtractionConfig } from '../../variable-types.js';
2
+ /**
3
+ * Java variable extraction config.
4
+ *
5
+ * Java does not have true module-level variables — all declarations are
6
+ * class-scoped. However, `static final` fields at class scope act like
7
+ * constants. These are already handled by the field extractor. This config
8
+ * covers any rare local_variable_declaration captures at file scope
9
+ * (e.g., in scripts or top-level code blocks in JShell).
10
+ */
11
+ export declare const javaVariableConfig: VariableExtractionConfig;
12
+ /**
13
+ * Kotlin variable extraction config.
14
+ *
15
+ * Kotlin has true top-level val/var declarations outside classes.
16
+ * tree-sitter-kotlin uses 'property_declaration' for both.
17
+ */
18
+ export declare const kotlinVariableConfig: VariableExtractionConfig;
@@ -0,0 +1,115 @@
1
+ // gitnexus/src/core/ingestion/variable-extractors/configs/jvm.ts
2
+ import { SupportedLanguages } from '../../../../_shared/index.js';
3
+ import { hasModifier } from '../../field-extractors/configs/helpers.js';
4
+ import { extractSimpleTypeName } from '../../type-extractors/shared.js';
5
+ /**
6
+ * Java variable extraction config.
7
+ *
8
+ * Java does not have true module-level variables — all declarations are
9
+ * class-scoped. However, `static final` fields at class scope act like
10
+ * constants. These are already handled by the field extractor. This config
11
+ * covers any rare local_variable_declaration captures at file scope
12
+ * (e.g., in scripts or top-level code blocks in JShell).
13
+ */
14
+ export const javaVariableConfig = {
15
+ language: SupportedLanguages.Java,
16
+ constNodeTypes: [],
17
+ staticNodeTypes: [],
18
+ variableNodeTypes: ['local_variable_declaration'],
19
+ extractName(node) {
20
+ const declarator = node.namedChildren.find((c) => c.type === 'variable_declarator');
21
+ const name = declarator?.childForFieldName('name');
22
+ return name?.type === 'identifier' ? name.text : undefined;
23
+ },
24
+ extractType(node) {
25
+ const typeNode = node.childForFieldName('type');
26
+ if (typeNode)
27
+ return extractSimpleTypeName(typeNode) ?? typeNode.text?.trim();
28
+ return undefined;
29
+ },
30
+ extractVisibility(node) {
31
+ if (hasModifier(node, 'modifiers', 'public'))
32
+ return 'public';
33
+ if (hasModifier(node, 'modifiers', 'private'))
34
+ return 'private';
35
+ if (hasModifier(node, 'modifiers', 'protected'))
36
+ return 'protected';
37
+ return 'package';
38
+ },
39
+ isConst(node) {
40
+ return hasModifier(node, 'modifiers', 'final');
41
+ },
42
+ isStatic(node) {
43
+ return hasModifier(node, 'modifiers', 'static');
44
+ },
45
+ isMutable(node) {
46
+ return !hasModifier(node, 'modifiers', 'final');
47
+ },
48
+ };
49
+ /**
50
+ * Kotlin variable extraction config.
51
+ *
52
+ * Kotlin has true top-level val/var declarations outside classes.
53
+ * tree-sitter-kotlin uses 'property_declaration' for both.
54
+ */
55
+ export const kotlinVariableConfig = {
56
+ language: SupportedLanguages.Kotlin,
57
+ constNodeTypes: [],
58
+ staticNodeTypes: [],
59
+ variableNodeTypes: ['property_declaration'],
60
+ extractName(node) {
61
+ // property_declaration → variable_declaration → simple_identifier
62
+ for (let i = 0; i < node.namedChildCount; i++) {
63
+ const child = node.namedChild(i);
64
+ if (child?.type === 'variable_declaration') {
65
+ const ident = child.namedChildren.find((c) => c.type === 'simple_identifier');
66
+ return ident?.text;
67
+ }
68
+ }
69
+ return undefined;
70
+ },
71
+ extractType(node) {
72
+ // Look for type annotation in variable_declaration child
73
+ for (let i = 0; i < node.namedChildCount; i++) {
74
+ const child = node.namedChild(i);
75
+ if (child?.type === 'variable_declaration') {
76
+ const typeNode = child.namedChildren.find((c) => c.type === 'user_type' || c.type === 'nullable_type');
77
+ if (typeNode)
78
+ return extractSimpleTypeName(typeNode) ?? typeNode.text?.trim();
79
+ }
80
+ }
81
+ return undefined;
82
+ },
83
+ extractVisibility(node) {
84
+ if (hasModifier(node, 'modifiers', 'public'))
85
+ return 'public';
86
+ if (hasModifier(node, 'modifiers', 'private'))
87
+ return 'private';
88
+ if (hasModifier(node, 'modifiers', 'protected'))
89
+ return 'protected';
90
+ if (hasModifier(node, 'modifiers', 'internal'))
91
+ return 'internal';
92
+ return 'public'; // Kotlin default is public
93
+ },
94
+ isConst(node) {
95
+ // val is immutable; also check for `const` modifier
96
+ for (let i = 0; i < node.childCount; i++) {
97
+ const child = node.child(i);
98
+ if (child?.text === 'val')
99
+ return true;
100
+ }
101
+ return hasModifier(node, 'modifiers', 'const');
102
+ },
103
+ isStatic(_node) {
104
+ // Top-level Kotlin properties are not static in the Java sense
105
+ return false;
106
+ },
107
+ isMutable(node) {
108
+ for (let i = 0; i < node.childCount; i++) {
109
+ const child = node.child(i);
110
+ if (child?.text === 'var')
111
+ return true;
112
+ }
113
+ return false;
114
+ },
115
+ };
@@ -0,0 +1,14 @@
1
+ import type { VariableExtractionConfig } from '../../variable-types.js';
2
+ /**
3
+ * PHP variable extraction config.
4
+ *
5
+ * PHP has const declarations at namespace/file scope and global variables:
6
+ * - `const MAX_SIZE = 100;`
7
+ * - `define('MAX_SIZE', 100);`
8
+ * - `$variable = value;`
9
+ *
10
+ * tree-sitter-php uses:
11
+ * - const_declaration at namespace/program scope
12
+ * - expression_statement containing assignment_expression for variables
13
+ */
14
+ export declare const phpVariableConfig: VariableExtractionConfig;
@@ -0,0 +1,58 @@
1
+ // gitnexus/src/core/ingestion/variable-extractors/configs/php.ts
2
+ import { SupportedLanguages } from '../../../../_shared/index.js';
3
+ import { hasKeyword } from '../../field-extractors/configs/helpers.js';
4
+ /**
5
+ * PHP variable extraction config.
6
+ *
7
+ * PHP has const declarations at namespace/file scope and global variables:
8
+ * - `const MAX_SIZE = 100;`
9
+ * - `define('MAX_SIZE', 100);`
10
+ * - `$variable = value;`
11
+ *
12
+ * tree-sitter-php uses:
13
+ * - const_declaration at namespace/program scope
14
+ * - expression_statement containing assignment_expression for variables
15
+ */
16
+ export const phpVariableConfig = {
17
+ language: SupportedLanguages.PHP,
18
+ constNodeTypes: ['const_declaration'],
19
+ staticNodeTypes: [],
20
+ variableNodeTypes: ['expression_statement'],
21
+ extractName(node) {
22
+ if (node.type === 'const_declaration') {
23
+ // const_declaration → const_element → name (identifier)
24
+ for (let i = 0; i < node.namedChildCount; i++) {
25
+ const child = node.namedChild(i);
26
+ if (child?.type === 'const_element') {
27
+ const name = child.childForFieldName('name');
28
+ return name?.text;
29
+ }
30
+ }
31
+ return undefined;
32
+ }
33
+ // expression_statement → assignment_expression → variable_name
34
+ const inner = node.firstNamedChild;
35
+ if (inner?.type === 'assignment_expression') {
36
+ const left = inner.childForFieldName('left');
37
+ if (left?.type === 'variable_name')
38
+ return left.text;
39
+ }
40
+ return undefined;
41
+ },
42
+ extractType(_node) {
43
+ // PHP is dynamically typed — no inline type annotations for variables
44
+ return undefined;
45
+ },
46
+ extractVisibility(_node) {
47
+ return 'public';
48
+ },
49
+ isConst(node) {
50
+ return node.type === 'const_declaration';
51
+ },
52
+ isStatic(node) {
53
+ return hasKeyword(node, 'static');
54
+ },
55
+ isMutable(node) {
56
+ return node.type !== 'const_declaration';
57
+ },
58
+ };
@@ -0,0 +1,2 @@
1
+ import type { VariableExtractionConfig } from '../../variable-types.js';
2
+ export declare const pythonVariableConfig: VariableExtractionConfig;
@@ -0,0 +1,101 @@
1
+ // gitnexus/src/core/ingestion/variable-extractors/configs/python.ts
2
+ import { SupportedLanguages } from '../../../../_shared/index.js';
3
+ import { extractSimpleTypeName } from '../../type-extractors/shared.js';
4
+ /**
5
+ * Python variable extraction config.
6
+ *
7
+ * Handles module-level assignments and annotated assignments:
8
+ * - `MAX_SIZE = 100` → const by UPPER_CASE convention
9
+ * - `name: str = "default"` → annotated assignment with type
10
+ * - `_private_var = 42` → protected by convention
11
+ * - `__private_var = 42` → private by convention
12
+ *
13
+ * tree-sitter-python uses:
14
+ * - expression_statement containing assignment or type nodes
15
+ */
16
+ function extractNameFromPython(node) {
17
+ const inner = node.firstNamedChild;
18
+ if (!inner)
19
+ return undefined;
20
+ // Annotated assignment: name: str = "default"
21
+ // AST: expression_statement > type > identifier
22
+ if (inner.type === 'type') {
23
+ const ident = inner.childForFieldName('name') ?? inner.firstNamedChild;
24
+ return ident?.type === 'identifier' ? ident.text : undefined;
25
+ }
26
+ // Plain assignment: x = 5
27
+ if (inner.type === 'assignment') {
28
+ const left = inner.childForFieldName('left');
29
+ if (left?.type === 'identifier')
30
+ return left.text;
31
+ }
32
+ return undefined;
33
+ }
34
+ function extractTypeFromPython(node) {
35
+ const inner = node.firstNamedChild;
36
+ if (!inner)
37
+ return undefined;
38
+ // Standalone annotated type without assignment: `name: str`
39
+ if (inner.type === 'type') {
40
+ const typeNode = inner.childForFieldName('type') ?? inner.namedChild(1);
41
+ if (typeNode)
42
+ return extractSimpleTypeName(typeNode) ?? typeNode.text?.trim();
43
+ }
44
+ // Annotated assignment: `name: str = "hello"`
45
+ // AST: expression_statement > assignment > [identifier, type > identifier, ...]
46
+ if (inner.type === 'assignment') {
47
+ for (let i = 0; i < inner.childCount; i++) {
48
+ const child = inner.child(i);
49
+ if (child?.type === 'type') {
50
+ const typeId = child.firstNamedChild;
51
+ if (typeId)
52
+ return extractSimpleTypeName(typeId) ?? typeId.text?.trim();
53
+ }
54
+ }
55
+ }
56
+ return undefined;
57
+ }
58
+ function extractVisFromPython(node) {
59
+ const name = extractNameFromPython(node);
60
+ if (!name)
61
+ return 'public';
62
+ // Dunder names (__name__, __all__) are public Python conventions
63
+ if (name.startsWith('__') && name.endsWith('__'))
64
+ return 'public';
65
+ // Double underscore prefix (name mangled) = private
66
+ if (name.startsWith('__'))
67
+ return 'private';
68
+ // Single underscore prefix = protected by convention
69
+ if (name.startsWith('_'))
70
+ return 'protected';
71
+ return 'public';
72
+ }
73
+ export const pythonVariableConfig = {
74
+ language: SupportedLanguages.Python,
75
+ constNodeTypes: [],
76
+ staticNodeTypes: [],
77
+ // expression_statement is broad — isVariableDeclaration returns true for
78
+ // all expression_statement nodes, but extract() safely filters non-assignments
79
+ // by returning null when extractNameFromPython finds no assignment target.
80
+ variableNodeTypes: ['expression_statement'],
81
+ extractName: extractNameFromPython,
82
+ extractType: extractTypeFromPython,
83
+ extractVisibility: extractVisFromPython,
84
+ isConst(node) {
85
+ // Python convention: UPPER_CASE names are constants
86
+ const name = extractNameFromPython(node);
87
+ if (!name)
88
+ return false;
89
+ return name === name.toUpperCase() && /^[A-Z][A-Z0-9_]*$/.test(name);
90
+ },
91
+ isStatic(_node) {
92
+ return false;
93
+ },
94
+ isMutable(node) {
95
+ const name = extractNameFromPython(node);
96
+ if (!name)
97
+ return true;
98
+ // By convention, UPPER_CASE names are immutable constants
99
+ return !(name === name.toUpperCase() && /^[A-Z][A-Z0-9_]*$/.test(name));
100
+ },
101
+ };
@@ -0,0 +1,11 @@
1
+ import type { VariableExtractionConfig } from '../../variable-types.js';
2
+ /**
3
+ * Ruby variable extraction config.
4
+ *
5
+ * Ruby module-level constants use UPPER_CASE identifiers or start with
6
+ * an uppercase letter. Ruby uses:
7
+ * - assignment for variable declarations at module scope
8
+ * - Constants: `MAX_SIZE = 100` or `Config = ...`
9
+ * - Global variables: `$global = ...`
10
+ */
11
+ export declare const rubyVariableConfig: VariableExtractionConfig;