gitnexus 1.6.2-rc.2 → 1.6.2-rc.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_shared/lbug/schema-constants.d.ts +1 -1
- package/dist/_shared/lbug/schema-constants.d.ts.map +1 -1
- package/dist/_shared/lbug/schema-constants.js +1 -0
- package/dist/_shared/lbug/schema-constants.js.map +1 -1
- package/dist/cli/analyze.js +3 -0
- package/dist/core/embeddings/ast-utils.d.ts +22 -0
- package/dist/core/embeddings/ast-utils.js +105 -0
- package/dist/core/embeddings/character-chunk.d.ts +12 -0
- package/dist/core/embeddings/character-chunk.js +43 -0
- package/dist/core/embeddings/chunker.d.ts +14 -0
- package/dist/core/embeddings/chunker.js +234 -0
- package/dist/core/embeddings/embedder.js +5 -0
- package/dist/core/embeddings/embedding-pipeline.d.ts +29 -24
- package/dist/core/embeddings/embedding-pipeline.js +244 -125
- package/dist/core/embeddings/line-index.d.ts +7 -0
- package/dist/core/embeddings/line-index.js +42 -0
- package/dist/core/embeddings/server-mapping.d.ts +15 -0
- package/dist/core/embeddings/server-mapping.js +33 -0
- package/dist/core/embeddings/structural-extractor.d.ts +15 -0
- package/dist/core/embeddings/structural-extractor.js +58 -0
- package/dist/core/embeddings/text-generator.d.ts +20 -13
- package/dist/core/embeddings/text-generator.js +151 -119
- package/dist/core/embeddings/types.d.ts +81 -3
- package/dist/core/embeddings/types.js +105 -3
- package/dist/core/group/extractors/http-patterns/node.js +130 -0
- package/dist/core/group/extractors/manifest-extractor.js +20 -5
- package/dist/core/group/sync.js +49 -1
- package/dist/core/ingestion/call-extractors/configs/c-cpp.d.ts +3 -0
- package/dist/core/ingestion/call-extractors/configs/c-cpp.js +8 -0
- package/dist/core/ingestion/call-extractors/configs/csharp.d.ts +2 -0
- package/dist/core/ingestion/call-extractors/configs/csharp.js +6 -0
- package/dist/core/ingestion/call-extractors/configs/dart.d.ts +2 -0
- package/dist/core/ingestion/call-extractors/configs/dart.js +5 -0
- package/dist/core/ingestion/call-extractors/configs/go.d.ts +2 -0
- package/dist/core/ingestion/call-extractors/configs/go.js +5 -0
- package/dist/core/ingestion/call-extractors/configs/jvm.d.ts +3 -0
- package/dist/core/ingestion/call-extractors/configs/jvm.js +51 -0
- package/dist/core/ingestion/call-extractors/configs/php.d.ts +2 -0
- package/dist/core/ingestion/call-extractors/configs/php.js +5 -0
- package/dist/core/ingestion/call-extractors/configs/python.d.ts +2 -0
- package/dist/core/ingestion/call-extractors/configs/python.js +5 -0
- package/dist/core/ingestion/call-extractors/configs/ruby.d.ts +2 -0
- package/dist/core/ingestion/call-extractors/configs/ruby.js +5 -0
- package/dist/core/ingestion/call-extractors/configs/rust.d.ts +2 -0
- package/dist/core/ingestion/call-extractors/configs/rust.js +5 -0
- package/dist/core/ingestion/call-extractors/configs/swift.d.ts +2 -0
- package/dist/core/ingestion/call-extractors/configs/swift.js +5 -0
- package/dist/core/ingestion/call-extractors/configs/typescript-javascript.d.ts +3 -0
- package/dist/core/ingestion/call-extractors/configs/typescript-javascript.js +8 -0
- package/dist/core/ingestion/call-extractors/generic.d.ts +5 -0
- package/dist/core/ingestion/call-extractors/generic.js +59 -0
- package/dist/core/ingestion/call-processor.d.ts +1 -3
- package/dist/core/ingestion/call-processor.js +49 -47
- package/dist/core/ingestion/call-types.d.ts +60 -0
- package/dist/core/ingestion/call-types.js +2 -0
- package/dist/core/ingestion/class-extractors/configs/c-cpp.d.ts +3 -0
- package/dist/core/ingestion/class-extractors/configs/c-cpp.js +11 -0
- package/dist/core/ingestion/class-extractors/configs/csharp.d.ts +2 -0
- package/dist/core/ingestion/class-extractors/configs/csharp.js +21 -0
- package/dist/core/ingestion/class-extractors/configs/dart.d.ts +2 -0
- package/dist/core/ingestion/class-extractors/configs/dart.js +7 -0
- package/dist/core/ingestion/class-extractors/configs/go.d.ts +2 -0
- package/dist/core/ingestion/class-extractors/configs/go.js +20 -0
- package/dist/core/ingestion/class-extractors/configs/jvm.d.ts +3 -0
- package/dist/core/ingestion/class-extractors/configs/jvm.js +35 -0
- package/dist/core/ingestion/class-extractors/configs/php.d.ts +2 -0
- package/dist/core/ingestion/class-extractors/configs/php.js +7 -0
- package/dist/core/ingestion/class-extractors/configs/python.d.ts +2 -0
- package/dist/core/ingestion/class-extractors/configs/python.js +7 -0
- package/dist/core/ingestion/class-extractors/configs/ruby.d.ts +2 -0
- package/dist/core/ingestion/class-extractors/configs/ruby.js +7 -0
- package/dist/core/ingestion/class-extractors/configs/rust.d.ts +2 -0
- package/dist/core/ingestion/class-extractors/configs/rust.js +7 -0
- package/dist/core/ingestion/class-extractors/configs/swift.d.ts +2 -0
- package/dist/core/ingestion/class-extractors/configs/swift.js +18 -0
- package/dist/core/ingestion/class-extractors/configs/typescript-javascript.d.ts +4 -0
- package/dist/core/ingestion/class-extractors/configs/typescript-javascript.js +28 -0
- package/dist/core/ingestion/field-types.d.ts +1 -1
- package/dist/core/ingestion/import-resolvers/configs/c-cpp.d.ts +7 -0
- package/dist/core/ingestion/import-resolvers/configs/c-cpp.js +14 -0
- package/dist/core/ingestion/import-resolvers/configs/csharp.d.ts +8 -0
- package/dist/core/ingestion/import-resolvers/configs/csharp.js +27 -0
- package/dist/core/ingestion/import-resolvers/configs/dart.d.ts +17 -0
- package/dist/core/ingestion/import-resolvers/{dart.js → configs/dart.js} +26 -16
- package/dist/core/ingestion/import-resolvers/configs/go.d.ts +8 -0
- package/dist/core/ingestion/import-resolvers/configs/go.js +26 -0
- package/dist/core/ingestion/import-resolvers/configs/jvm.d.ts +13 -0
- package/dist/core/ingestion/import-resolvers/configs/jvm.js +68 -0
- package/dist/core/ingestion/import-resolvers/configs/php.d.ts +8 -0
- package/dist/core/ingestion/import-resolvers/configs/php.js +15 -0
- package/dist/core/ingestion/import-resolvers/configs/python.d.ts +12 -0
- package/dist/core/ingestion/import-resolvers/configs/python.js +41 -0
- package/dist/core/ingestion/import-resolvers/configs/ruby.d.ts +8 -0
- package/dist/core/ingestion/import-resolvers/configs/ruby.js +16 -0
- package/dist/core/ingestion/import-resolvers/configs/rust.d.ts +8 -0
- package/dist/core/ingestion/import-resolvers/configs/rust.js +54 -0
- package/dist/core/ingestion/import-resolvers/configs/swift.d.ts +8 -0
- package/dist/core/ingestion/import-resolvers/{swift.js → configs/swift.js} +10 -5
- package/dist/core/ingestion/import-resolvers/configs/typescript-javascript.d.ts +9 -0
- package/dist/core/ingestion/import-resolvers/configs/typescript-javascript.js +23 -0
- package/dist/core/ingestion/import-resolvers/csharp.d.ts +4 -5
- package/dist/core/ingestion/import-resolvers/csharp.js +4 -20
- package/dist/core/ingestion/import-resolvers/go.d.ts +4 -5
- package/dist/core/ingestion/import-resolvers/go.js +4 -19
- package/dist/core/ingestion/import-resolvers/jvm.d.ts +5 -10
- package/dist/core/ingestion/import-resolvers/jvm.js +5 -58
- package/dist/core/ingestion/import-resolvers/php.d.ts +4 -5
- package/dist/core/ingestion/import-resolvers/php.js +4 -7
- package/dist/core/ingestion/import-resolvers/python.d.ts +3 -6
- package/dist/core/ingestion/import-resolvers/python.js +3 -18
- package/dist/core/ingestion/import-resolvers/resolver-factory.d.ts +24 -0
- package/dist/core/ingestion/import-resolvers/resolver-factory.js +33 -0
- package/dist/core/ingestion/import-resolvers/ruby.d.ts +4 -5
- package/dist/core/ingestion/import-resolvers/ruby.js +4 -7
- package/dist/core/ingestion/import-resolvers/rust.d.ts +4 -5
- package/dist/core/ingestion/import-resolvers/rust.js +4 -47
- package/dist/core/ingestion/import-resolvers/standard.d.ts +3 -9
- package/dist/core/ingestion/import-resolvers/standard.js +7 -8
- package/dist/core/ingestion/import-resolvers/types.d.ts +24 -0
- package/dist/core/ingestion/language-provider.d.ts +12 -0
- package/dist/core/ingestion/languages/c-cpp.js +15 -12
- package/dist/core/ingestion/languages/csharp.js +11 -21
- package/dist/core/ingestion/languages/dart.js +11 -7
- package/dist/core/ingestion/languages/go.js +11 -20
- package/dist/core/ingestion/languages/java.js +11 -18
- package/dist/core/ingestion/languages/kotlin.js +11 -13
- package/dist/core/ingestion/languages/php.js +11 -7
- package/dist/core/ingestion/languages/python.js +11 -7
- package/dist/core/ingestion/languages/ruby.js +11 -7
- package/dist/core/ingestion/languages/rust.js +11 -7
- package/dist/core/ingestion/languages/swift.js +11 -18
- package/dist/core/ingestion/languages/typescript.js +15 -23
- package/dist/core/ingestion/languages/vue.js +11 -17
- package/dist/core/ingestion/model/index.d.ts +2 -2
- package/dist/core/ingestion/model/index.js +1 -1
- package/dist/core/ingestion/model/resolve.d.ts +3 -0
- package/dist/core/ingestion/model/resolve.js +6 -2
- package/dist/core/ingestion/parsing-processor.d.ts +1 -2
- package/dist/core/ingestion/tree-sitter-queries.d.ts +11 -11
- package/dist/core/ingestion/tree-sitter-queries.js +81 -0
- package/dist/core/ingestion/type-env.d.ts +1 -1
- package/dist/core/ingestion/utils/ast-helpers.d.ts +1 -1
- package/dist/core/ingestion/utils/ast-helpers.js +3 -0
- package/dist/core/ingestion/variable-extractors/configs/c-cpp.d.ts +3 -0
- package/dist/core/ingestion/variable-extractors/configs/c-cpp.js +81 -0
- package/dist/core/ingestion/variable-extractors/configs/csharp.d.ts +9 -0
- package/dist/core/ingestion/variable-extractors/configs/csharp.js +63 -0
- package/dist/core/ingestion/variable-extractors/configs/dart.d.ts +2 -0
- package/dist/core/ingestion/variable-extractors/configs/dart.js +94 -0
- package/dist/core/ingestion/variable-extractors/configs/go.d.ts +2 -0
- package/dist/core/ingestion/variable-extractors/configs/go.js +83 -0
- package/dist/core/ingestion/variable-extractors/configs/jvm.d.ts +18 -0
- package/dist/core/ingestion/variable-extractors/configs/jvm.js +115 -0
- package/dist/core/ingestion/variable-extractors/configs/php.d.ts +14 -0
- package/dist/core/ingestion/variable-extractors/configs/php.js +58 -0
- package/dist/core/ingestion/variable-extractors/configs/python.d.ts +2 -0
- package/dist/core/ingestion/variable-extractors/configs/python.js +101 -0
- package/dist/core/ingestion/variable-extractors/configs/ruby.d.ts +11 -0
- package/dist/core/ingestion/variable-extractors/configs/ruby.js +52 -0
- package/dist/core/ingestion/variable-extractors/configs/rust.d.ts +2 -0
- package/dist/core/ingestion/variable-extractors/configs/rust.js +76 -0
- package/dist/core/ingestion/variable-extractors/configs/swift.d.ts +2 -0
- package/dist/core/ingestion/variable-extractors/configs/swift.js +88 -0
- package/dist/core/ingestion/variable-extractors/configs/typescript-javascript.d.ts +3 -0
- package/dist/core/ingestion/variable-extractors/configs/typescript-javascript.js +83 -0
- package/dist/core/ingestion/variable-extractors/generic.d.ts +5 -0
- package/dist/core/ingestion/variable-extractors/generic.js +80 -0
- package/dist/core/ingestion/variable-types.d.ts +82 -0
- package/dist/core/ingestion/variable-types.js +2 -0
- package/dist/core/ingestion/workers/parse-worker.js +196 -166
- package/dist/core/ingestion/workers/worker-pool.js +3 -0
- package/dist/core/lbug/csv-generator.js +1 -0
- package/dist/core/lbug/lbug-adapter.d.ts +13 -4
- package/dist/core/lbug/lbug-adapter.js +166 -81
- package/dist/core/lbug/schema.d.ts +9 -1
- package/dist/core/lbug/schema.js +19 -2
- package/dist/core/run-analyze.js +17 -4
- package/dist/core/tree-sitter/parser-loader.d.ts +3 -0
- package/dist/core/tree-sitter/parser-loader.js +17 -8
- package/dist/mcp/core/embedder.js +5 -0
- package/dist/mcp/local/local-backend.js +29 -19
- package/dist/server/api.js +10 -21
- package/package.json +5 -3
- package/scripts/build-tree-sitter-proto.cjs +82 -0
- package/vendor/node_modules/node-addon-api/node_addon_api.Makefile +6 -0
- package/vendor/node_modules/node-addon-api/node_addon_api.target.mk +104 -0
- package/vendor/node_modules/node-addon-api/node_addon_api_except.target.mk +108 -0
- package/vendor/node_modules/node-addon-api/node_addon_api_except_all.target.mk +104 -0
- package/vendor/node_modules/node-addon-api/node_addon_api_maybe.target.mk +104 -0
- package/vendor/tree-sitter-proto/package.json +1 -7
- package/dist/core/ingestion/call-sites/extract-language-call-site.d.ts +0 -10
- package/dist/core/ingestion/call-sites/extract-language-call-site.js +0 -22
- package/dist/core/ingestion/call-sites/java.d.ts +0 -9
- package/dist/core/ingestion/call-sites/java.js +0 -30
- package/dist/core/ingestion/import-resolvers/dart.d.ts +0 -7
- package/dist/core/ingestion/import-resolvers/swift.d.ts +0 -7
- package/dist/core/ingestion/import-resolvers/vue.d.ts +0 -8
- package/dist/core/ingestion/import-resolvers/vue.js +0 -9
|
@@ -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,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,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,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;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// gitnexus/src/core/ingestion/variable-extractors/configs/ruby.ts
|
|
2
|
+
import { SupportedLanguages } from '../../../../_shared/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* Ruby variable extraction config.
|
|
5
|
+
*
|
|
6
|
+
* Ruby module-level constants use UPPER_CASE identifiers or start with
|
|
7
|
+
* an uppercase letter. Ruby uses:
|
|
8
|
+
* - assignment for variable declarations at module scope
|
|
9
|
+
* - Constants: `MAX_SIZE = 100` or `Config = ...`
|
|
10
|
+
* - Global variables: `$global = ...`
|
|
11
|
+
*/
|
|
12
|
+
export const rubyVariableConfig = {
|
|
13
|
+
language: SupportedLanguages.Ruby,
|
|
14
|
+
constNodeTypes: [],
|
|
15
|
+
staticNodeTypes: [],
|
|
16
|
+
variableNodeTypes: ['assignment'],
|
|
17
|
+
extractName(node) {
|
|
18
|
+
const left = node.childForFieldName('left');
|
|
19
|
+
if (!left)
|
|
20
|
+
return undefined;
|
|
21
|
+
if (left.type === 'identifier' || left.type === 'constant')
|
|
22
|
+
return left.text;
|
|
23
|
+
if (left.type === 'global_variable')
|
|
24
|
+
return left.text;
|
|
25
|
+
return undefined;
|
|
26
|
+
},
|
|
27
|
+
extractType(_node) {
|
|
28
|
+
// Ruby is dynamically typed — no type annotations at module level
|
|
29
|
+
return undefined;
|
|
30
|
+
},
|
|
31
|
+
extractVisibility(_node) {
|
|
32
|
+
const left = _node.childForFieldName('left');
|
|
33
|
+
if (!left)
|
|
34
|
+
return 'public';
|
|
35
|
+
// Constants (uppercase start) and global variables are effectively public
|
|
36
|
+
if (left.type === 'constant' || left.type === 'global_variable')
|
|
37
|
+
return 'public';
|
|
38
|
+
return 'private';
|
|
39
|
+
},
|
|
40
|
+
isConst(node) {
|
|
41
|
+
const left = node.childForFieldName('left');
|
|
42
|
+
return left?.type === 'constant';
|
|
43
|
+
},
|
|
44
|
+
isStatic(_node) {
|
|
45
|
+
return false;
|
|
46
|
+
},
|
|
47
|
+
isMutable(node) {
|
|
48
|
+
const left = node.childForFieldName('left');
|
|
49
|
+
// Constants are immutable by convention
|
|
50
|
+
return left?.type !== 'constant';
|
|
51
|
+
},
|
|
52
|
+
};
|