orion-super-agent-dev 0.1.13 → 0.1.14
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/out/brains/darwin-arm64/orion-brain +0 -0
- package/out/brains/darwin-x64/orion-brain +0 -0
- package/out/brains/linux-arm64/orion-brain +0 -0
- package/out/brains/linux-x64/orion-brain +0 -0
- package/out/brains/win32-x64/orion-brain.exe +0 -0
- package/out/indexProcessWorker.cjs +454 -14
- package/out/main.js +8102 -4832
- package/out/treesitter/grammars/tree-sitter-c.wasm.gz +0 -0
- package/out/treesitter/grammars/tree-sitter-cpp.wasm.gz +0 -0
- package/out/treesitter/grammars/tree-sitter-csharp.wasm.gz +0 -0
- package/out/treesitter/grammars/tree-sitter-kotlin.wasm.gz +0 -0
- package/out/treesitter/grammars/tree-sitter-php.wasm.gz +0 -0
- package/out/treesitter/grammars/tree-sitter-scala.wasm.gz +0 -0
- package/out/worker.js +236 -12
- package/package.json +1 -1
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -4533,6 +4533,164 @@ var JAVA_QUERY = `
|
|
|
4533
4533
|
|
|
4534
4534
|
(method_invocation name: (identifier) @edge.call.target)
|
|
4535
4535
|
`;
|
|
4536
|
+
var C_QUERY = `
|
|
4537
|
+
(function_definition
|
|
4538
|
+
declarator: (function_declarator
|
|
4539
|
+
declarator: (identifier) @symbol.function.name)) @symbol.function.def
|
|
4540
|
+
|
|
4541
|
+
(struct_specifier
|
|
4542
|
+
name: (type_identifier) @symbol.class.name
|
|
4543
|
+
body: (field_declaration_list)) @symbol.class.def
|
|
4544
|
+
|
|
4545
|
+
(enum_specifier
|
|
4546
|
+
name: (type_identifier) @symbol.enum.name
|
|
4547
|
+
body: (enumerator_list)) @symbol.enum.def
|
|
4548
|
+
|
|
4549
|
+
(type_definition
|
|
4550
|
+
declarator: (type_identifier) @symbol.type.name) @symbol.type.def
|
|
4551
|
+
|
|
4552
|
+
(preproc_include path: (string_literal) @edge.import.source)
|
|
4553
|
+
|
|
4554
|
+
(call_expression
|
|
4555
|
+
function: (identifier) @edge.call.target)
|
|
4556
|
+
`;
|
|
4557
|
+
var CPP_QUERY = `
|
|
4558
|
+
(function_definition
|
|
4559
|
+
declarator: (function_declarator
|
|
4560
|
+
declarator: (identifier) @symbol.function.name)) @symbol.function.def
|
|
4561
|
+
|
|
4562
|
+
(function_definition
|
|
4563
|
+
declarator: (function_declarator
|
|
4564
|
+
declarator: (field_identifier) @symbol.method.name)) @symbol.method.def
|
|
4565
|
+
|
|
4566
|
+
(class_specifier
|
|
4567
|
+
name: (type_identifier) @symbol.class.name
|
|
4568
|
+
body: (field_declaration_list)) @symbol.class.def
|
|
4569
|
+
|
|
4570
|
+
(struct_specifier
|
|
4571
|
+
name: (type_identifier) @symbol.class.name
|
|
4572
|
+
body: (field_declaration_list)) @symbol.class.def
|
|
4573
|
+
|
|
4574
|
+
(enum_specifier
|
|
4575
|
+
name: (type_identifier) @symbol.enum.name
|
|
4576
|
+
body: (enumerator_list)) @symbol.enum.def
|
|
4577
|
+
|
|
4578
|
+
(type_definition
|
|
4579
|
+
declarator: (type_identifier) @symbol.type.name) @symbol.type.def
|
|
4580
|
+
|
|
4581
|
+
(preproc_include path: (string_literal) @edge.import.source)
|
|
4582
|
+
|
|
4583
|
+
(base_class_clause (type_identifier) @edge.extends.parent)
|
|
4584
|
+
|
|
4585
|
+
(call_expression
|
|
4586
|
+
function: (identifier) @edge.call.target)
|
|
4587
|
+
|
|
4588
|
+
(call_expression
|
|
4589
|
+
function: (field_expression field: (field_identifier) @edge.call.target))
|
|
4590
|
+
`;
|
|
4591
|
+
var CSHARP_QUERY = `
|
|
4592
|
+
(class_declaration
|
|
4593
|
+
name: (identifier) @symbol.class.name) @symbol.class.def
|
|
4594
|
+
|
|
4595
|
+
(struct_declaration
|
|
4596
|
+
name: (identifier) @symbol.class.name) @symbol.class.def
|
|
4597
|
+
|
|
4598
|
+
(interface_declaration
|
|
4599
|
+
name: (identifier) @symbol.interface.name) @symbol.interface.def
|
|
4600
|
+
|
|
4601
|
+
(enum_declaration
|
|
4602
|
+
name: (identifier) @symbol.enum.name) @symbol.enum.def
|
|
4603
|
+
|
|
4604
|
+
(method_declaration
|
|
4605
|
+
name: (identifier) @symbol.method.name) @symbol.method.def
|
|
4606
|
+
|
|
4607
|
+
(base_list (identifier) @edge.extends.parent)
|
|
4608
|
+
|
|
4609
|
+
(using_directive (identifier) @edge.import.target)
|
|
4610
|
+
|
|
4611
|
+
(using_directive (qualified_name) @edge.import.target)
|
|
4612
|
+
|
|
4613
|
+
(invocation_expression
|
|
4614
|
+
function: (identifier) @edge.call.target)
|
|
4615
|
+
|
|
4616
|
+
(invocation_expression
|
|
4617
|
+
function: (member_access_expression name: (identifier) @edge.call.target))
|
|
4618
|
+
`;
|
|
4619
|
+
var PHP_QUERY = `
|
|
4620
|
+
(function_definition
|
|
4621
|
+
name: (name) @symbol.function.name) @symbol.function.def
|
|
4622
|
+
|
|
4623
|
+
(method_declaration
|
|
4624
|
+
name: (name) @symbol.method.name) @symbol.method.def
|
|
4625
|
+
|
|
4626
|
+
(class_declaration
|
|
4627
|
+
name: (name) @symbol.class.name) @symbol.class.def
|
|
4628
|
+
|
|
4629
|
+
(trait_declaration
|
|
4630
|
+
name: (name) @symbol.class.name) @symbol.class.def
|
|
4631
|
+
|
|
4632
|
+
(interface_declaration
|
|
4633
|
+
name: (name) @symbol.interface.name) @symbol.interface.def
|
|
4634
|
+
|
|
4635
|
+
(base_clause (name) @edge.extends.parent)
|
|
4636
|
+
|
|
4637
|
+
(class_interface_clause (name) @edge.implements.parent)
|
|
4638
|
+
|
|
4639
|
+
(namespace_use_clause (qualified_name (name) @edge.import.target))
|
|
4640
|
+
|
|
4641
|
+
(function_call_expression
|
|
4642
|
+
function: (name) @edge.call.target)
|
|
4643
|
+
|
|
4644
|
+
(member_call_expression
|
|
4645
|
+
name: (name) @edge.call.target)
|
|
4646
|
+
`;
|
|
4647
|
+
var KOTLIN_QUERY = `
|
|
4648
|
+
(function_declaration
|
|
4649
|
+
(simple_identifier) @symbol.function.name) @symbol.function.def
|
|
4650
|
+
|
|
4651
|
+
(class_declaration
|
|
4652
|
+
(type_identifier) @symbol.class.name) @symbol.class.def
|
|
4653
|
+
|
|
4654
|
+
(object_declaration
|
|
4655
|
+
(type_identifier) @symbol.class.name) @symbol.class.def
|
|
4656
|
+
|
|
4657
|
+
(delegation_specifier
|
|
4658
|
+
(constructor_invocation (user_type (type_identifier) @edge.extends.parent)))
|
|
4659
|
+
|
|
4660
|
+
(delegation_specifier
|
|
4661
|
+
(user_type (type_identifier) @edge.implements.parent))
|
|
4662
|
+
|
|
4663
|
+
(import_header (identifier) @edge.import.target)
|
|
4664
|
+
|
|
4665
|
+
(call_expression (simple_identifier) @edge.call.target)
|
|
4666
|
+
`;
|
|
4667
|
+
var SCALA_QUERY = `
|
|
4668
|
+
(function_definition
|
|
4669
|
+
name: (identifier) @symbol.function.name) @symbol.function.def
|
|
4670
|
+
|
|
4671
|
+
(function_declaration
|
|
4672
|
+
name: (identifier) @symbol.function.name) @symbol.function.def
|
|
4673
|
+
|
|
4674
|
+
(class_definition
|
|
4675
|
+
name: (identifier) @symbol.class.name) @symbol.class.def
|
|
4676
|
+
|
|
4677
|
+
(object_definition
|
|
4678
|
+
name: (identifier) @symbol.class.name) @symbol.class.def
|
|
4679
|
+
|
|
4680
|
+
(trait_definition
|
|
4681
|
+
name: (identifier) @symbol.interface.name) @symbol.interface.def
|
|
4682
|
+
|
|
4683
|
+
(extends_clause type: (type_identifier) @edge.extends.parent)
|
|
4684
|
+
|
|
4685
|
+
(extends_clause type: (compound_type base: (type_identifier) @edge.extends.parent))
|
|
4686
|
+
|
|
4687
|
+
(extends_clause type: (compound_type extra: (type_identifier) @edge.implements.parent))
|
|
4688
|
+
|
|
4689
|
+
(import_declaration path: (stable_identifier) @edge.import.target)
|
|
4690
|
+
|
|
4691
|
+
(call_expression
|
|
4692
|
+
function: (identifier) @edge.call.target)
|
|
4693
|
+
`;
|
|
4536
4694
|
|
|
4537
4695
|
// ../packages/orion-client-core/src/treesitter/extractor.ts
|
|
4538
4696
|
function queryFor(lang) {
|
|
@@ -4550,6 +4708,18 @@ function queryFor(lang) {
|
|
|
4550
4708
|
return RUST_QUERY;
|
|
4551
4709
|
case "java":
|
|
4552
4710
|
return JAVA_QUERY;
|
|
4711
|
+
case "c":
|
|
4712
|
+
return C_QUERY;
|
|
4713
|
+
case "cpp":
|
|
4714
|
+
return CPP_QUERY;
|
|
4715
|
+
case "csharp":
|
|
4716
|
+
return CSHARP_QUERY;
|
|
4717
|
+
case "php":
|
|
4718
|
+
return PHP_QUERY;
|
|
4719
|
+
case "kotlin":
|
|
4720
|
+
return KOTLIN_QUERY;
|
|
4721
|
+
case "scala":
|
|
4722
|
+
return SCALA_QUERY;
|
|
4553
4723
|
// Ruby intentionally falls back to regex: tree-sitter `(call method: …)`
|
|
4554
4724
|
// can't distinguish `require "x"` (an import) from any other method
|
|
4555
4725
|
// call without a `#match?` predicate, and a tree-sitter pass that
|
|
@@ -4568,21 +4738,64 @@ function signatureOf(node, allLines) {
|
|
|
4568
4738
|
const line = (allLines[row] ?? "").trim();
|
|
4569
4739
|
return line.length > 160 ? line.slice(0, 160) + "\u2026" : line;
|
|
4570
4740
|
}
|
|
4741
|
+
var DEFINITION_NODE_TYPES = /* @__PURE__ */ new Set([
|
|
4742
|
+
// Python
|
|
4743
|
+
"function_definition",
|
|
4744
|
+
"class_definition",
|
|
4745
|
+
// JS/TS
|
|
4746
|
+
"method_definition",
|
|
4747
|
+
"function_declaration",
|
|
4748
|
+
"class_declaration",
|
|
4749
|
+
// Go / Java / C#
|
|
4750
|
+
"method_declaration",
|
|
4751
|
+
"interface_declaration",
|
|
4752
|
+
"enum_declaration",
|
|
4753
|
+
"struct_declaration",
|
|
4754
|
+
// Rust
|
|
4755
|
+
"function_item",
|
|
4756
|
+
// C / C++
|
|
4757
|
+
"class_specifier",
|
|
4758
|
+
"struct_specifier",
|
|
4759
|
+
"enum_specifier",
|
|
4760
|
+
"type_definition",
|
|
4761
|
+
// PHP
|
|
4762
|
+
"trait_declaration",
|
|
4763
|
+
// Kotlin
|
|
4764
|
+
"object_declaration",
|
|
4765
|
+
// Scala
|
|
4766
|
+
"class_definition",
|
|
4767
|
+
"object_definition",
|
|
4768
|
+
"trait_definition"
|
|
4769
|
+
]);
|
|
4770
|
+
var NAME_NODE_TYPES = /* @__PURE__ */ new Set([
|
|
4771
|
+
"identifier",
|
|
4772
|
+
"type_identifier",
|
|
4773
|
+
"simple_identifier",
|
|
4774
|
+
"field_identifier",
|
|
4775
|
+
"name"
|
|
4776
|
+
]);
|
|
4777
|
+
function definitionName(node) {
|
|
4778
|
+
const named = node.childForFieldName("name");
|
|
4779
|
+
if (named) return named.text;
|
|
4780
|
+
let decl = node.childForFieldName("declarator");
|
|
4781
|
+
for (let depth = 0; decl && depth < 8; depth += 1) {
|
|
4782
|
+
if (NAME_NODE_TYPES.has(decl.type)) return decl.text;
|
|
4783
|
+
decl = decl.childForFieldName("declarator");
|
|
4784
|
+
}
|
|
4785
|
+
for (const child of node.namedChildren) {
|
|
4786
|
+
if (NAME_NODE_TYPES.has(child.type)) return child.text;
|
|
4787
|
+
}
|
|
4788
|
+
return "";
|
|
4789
|
+
}
|
|
4571
4790
|
function enclosingSymbolName(node) {
|
|
4572
4791
|
let cur = node.parent;
|
|
4573
4792
|
while (cur) {
|
|
4574
4793
|
if (cur.type === "impl_item") {
|
|
4575
4794
|
const t = cur.childForFieldName("type");
|
|
4576
4795
|
if (t) return t.text;
|
|
4577
|
-
} else if (
|
|
4578
|
-
|
|
4579
|
-
|
|
4580
|
-
cur.type === "method_definition" || cur.type === "function_declaration" || cur.type === "class_declaration" || // Go / Java
|
|
4581
|
-
cur.type === "method_declaration" || cur.type === "interface_declaration" || cur.type === "enum_declaration" || // Rust
|
|
4582
|
-
cur.type === "function_item"
|
|
4583
|
-
) {
|
|
4584
|
-
const nameNode = cur.childForFieldName("name");
|
|
4585
|
-
if (nameNode) return nameNode.text;
|
|
4796
|
+
} else if (DEFINITION_NODE_TYPES.has(cur.type)) {
|
|
4797
|
+
const name2 = definitionName(cur);
|
|
4798
|
+
if (name2) return name2;
|
|
4586
4799
|
}
|
|
4587
4800
|
cur = cur.parent;
|
|
4588
4801
|
}
|
|
@@ -4904,6 +5117,7 @@ var TreeSitterWorkerPool = class {
|
|
|
4904
5117
|
|
|
4905
5118
|
// ../packages/orion-client-core/src/treesitter/loader.ts
|
|
4906
5119
|
var fs3 = __toESM(require("fs"));
|
|
5120
|
+
var zlib = __toESM(require("zlib"));
|
|
4907
5121
|
var GRAMMAR_FILE = {
|
|
4908
5122
|
python: "tree-sitter-python.wasm",
|
|
4909
5123
|
typescript: "tree-sitter-typescript.wasm",
|
|
@@ -4912,7 +5126,13 @@ var GRAMMAR_FILE = {
|
|
|
4912
5126
|
go: "tree-sitter-go.wasm",
|
|
4913
5127
|
rust: "tree-sitter-rust.wasm",
|
|
4914
5128
|
java: "tree-sitter-java.wasm",
|
|
4915
|
-
ruby: "tree-sitter-ruby.wasm"
|
|
5129
|
+
ruby: "tree-sitter-ruby.wasm",
|
|
5130
|
+
c: "tree-sitter-c.wasm",
|
|
5131
|
+
cpp: "tree-sitter-cpp.wasm",
|
|
5132
|
+
csharp: "tree-sitter-csharp.wasm",
|
|
5133
|
+
php: "tree-sitter-php.wasm",
|
|
5134
|
+
kotlin: "tree-sitter-kotlin.wasm",
|
|
5135
|
+
scala: "tree-sitter-scala.wasm"
|
|
4916
5136
|
};
|
|
4917
5137
|
var handle2 = null;
|
|
4918
5138
|
var initAttempted = false;
|
|
@@ -4937,6 +5157,21 @@ function langFromExt(ext) {
|
|
|
4937
5157
|
return "java";
|
|
4938
5158
|
case ".rb":
|
|
4939
5159
|
return "ruby";
|
|
5160
|
+
case ".c":
|
|
5161
|
+
return "c";
|
|
5162
|
+
case ".cpp":
|
|
5163
|
+
case ".cc":
|
|
5164
|
+
case ".h":
|
|
5165
|
+
case ".hpp":
|
|
5166
|
+
return "cpp";
|
|
5167
|
+
case ".cs":
|
|
5168
|
+
return "csharp";
|
|
5169
|
+
case ".php":
|
|
5170
|
+
return "php";
|
|
5171
|
+
case ".kt":
|
|
5172
|
+
return "kotlin";
|
|
5173
|
+
case ".scala":
|
|
5174
|
+
return "scala";
|
|
4940
5175
|
default:
|
|
4941
5176
|
return null;
|
|
4942
5177
|
}
|
|
@@ -4977,12 +5212,16 @@ async function tryLoad(grammarDir) {
|
|
|
4977
5212
|
const next = grammarQueue.then(async () => {
|
|
4978
5213
|
if (grammarCache.has(lang)) return grammarCache.get(lang) ?? null;
|
|
4979
5214
|
const wasmPath = `${grammarDir}/${GRAMMAR_FILE[lang]}`;
|
|
4980
|
-
|
|
5215
|
+
const gzPath = `${wasmPath}.gz`;
|
|
5216
|
+
const plainExists = fs3.existsSync(wasmPath);
|
|
5217
|
+
if (!plainExists && !fs3.existsSync(gzPath)) {
|
|
4981
5218
|
grammarCache.set(lang, null);
|
|
4982
5219
|
return null;
|
|
4983
5220
|
}
|
|
4984
5221
|
try {
|
|
4985
|
-
const langObj = await Parser2.Language.load(wasmPath)
|
|
5222
|
+
const langObj = plainExists ? await Parser2.Language.load(wasmPath) : await Parser2.Language.load(
|
|
5223
|
+
new Uint8Array(zlib.gunzipSync(fs3.readFileSync(gzPath)))
|
|
5224
|
+
);
|
|
4986
5225
|
grammarCache.set(lang, langObj);
|
|
4987
5226
|
return langObj;
|
|
4988
5227
|
} catch {
|
|
@@ -5895,6 +6134,46 @@ var RUBY_RULES = [
|
|
|
5895
6134
|
{ match: /^\s*class\s+(\w+)/, kind: "class", nameGroup: 1 },
|
|
5896
6135
|
{ match: /^\s*module\s+(\w+)/, kind: "type", nameGroup: 1 }
|
|
5897
6136
|
];
|
|
6137
|
+
var C_FAMILY_RULES = [
|
|
6138
|
+
{ match: /^\s*(?:template\s*<[^>]*>\s*)?class\s+(\w+)/, kind: "class", nameGroup: 1 },
|
|
6139
|
+
{ match: /^\s*(?:typedef\s+)?struct\s+(\w+)/, kind: "struct", nameGroup: 1 },
|
|
6140
|
+
{ match: /^\s*enum(?:\s+class)?\s+(\w+)/, kind: "enum", nameGroup: 1 },
|
|
6141
|
+
{ match: /^\s*namespace\s+(\w+)/, kind: "type", nameGroup: 1 },
|
|
6142
|
+
// A definition, not a declaration: the line must open a body, so `void go();` is correctly
|
|
6143
|
+
// skipped. Leading indentation IS allowed, because a class's methods are indented and they are
|
|
6144
|
+
// most of the content of the large C++ files this fallback exists to serve — anchoring at column
|
|
6145
|
+
// 0 found the class and none of its methods.
|
|
6146
|
+
//
|
|
6147
|
+
// Allowing indentation is what makes the negative lookahead load-bearing: without it, `if (x) {`,
|
|
6148
|
+
// `while (y) {` and `for (i) {` all parse as functions named after the keyword. `\b` in the
|
|
6149
|
+
// lookahead keeps a real function called `news()` or `deleter()` matchable.
|
|
6150
|
+
{
|
|
6151
|
+
match: /^\s*(?!(?:if|for|while|switch|catch|return|else|do|new|delete|sizeof|throw|co_return|co_await)\b)[\w~][\w\s:*&<>,~]*?\b(\w+)\s*\([^)]*\)\s*(?:(?:const|noexcept|override|final|mutable)\s+)*\{/,
|
|
6152
|
+
kind: "function",
|
|
6153
|
+
nameGroup: 1
|
|
6154
|
+
}
|
|
6155
|
+
];
|
|
6156
|
+
var CSHARP_RULES = [
|
|
6157
|
+
{ match: /^\s*(?:public|private|protected|internal|static|sealed|abstract|partial|\s)*class\s+(\w+)/, kind: "class", nameGroup: 1 },
|
|
6158
|
+
{ match: /^\s*(?:public|private|protected|internal|partial|\s)*interface\s+(\w+)/, kind: "interface", nameGroup: 1 },
|
|
6159
|
+
{ match: /^\s*(?:public|private|protected|internal|readonly|record|partial|\s)*struct\s+(\w+)/, kind: "struct", nameGroup: 1 },
|
|
6160
|
+
{ match: /^\s*(?:public|private|protected|internal|\s)*enum\s+(\w+)/, kind: "enum", nameGroup: 1 },
|
|
6161
|
+
{ match: /^\s*(?:public|private|protected|internal|static|virtual|override|async|sealed|abstract|extern|unsafe|new|\s)+[\w<>[\],.?]+\s+(\w+)\s*\([^)]*\)\s*[{=;]/, kind: "method", nameGroup: 1 }
|
|
6162
|
+
];
|
|
6163
|
+
var PHP_RULES = [
|
|
6164
|
+
{ match: /^\s*(?:abstract\s+|final\s+)*class\s+(\w+)/, kind: "class", nameGroup: 1 },
|
|
6165
|
+
{ match: /^\s*interface\s+(\w+)/, kind: "interface", nameGroup: 1 },
|
|
6166
|
+
{ match: /^\s*trait\s+(\w+)/, kind: "class", nameGroup: 1 },
|
|
6167
|
+
{ match: /^\s*(?:(?:public|private|protected|static|abstract|final)\s+)*function\s+&?(\w+)\s*\(/, kind: "function", nameGroup: 1 }
|
|
6168
|
+
];
|
|
6169
|
+
var SWIFT_RULES = [
|
|
6170
|
+
{ match: /^\s*(?:(?:public|private|internal|fileprivate|open|final)\s+)*class\s+(\w+)/, kind: "class", nameGroup: 1 },
|
|
6171
|
+
{ match: /^\s*(?:(?:public|private|internal|fileprivate|open)\s+)*struct\s+(\w+)/, kind: "struct", nameGroup: 1 },
|
|
6172
|
+
{ match: /^\s*(?:(?:public|private|internal|fileprivate|open|indirect)\s+)*enum\s+(\w+)/, kind: "enum", nameGroup: 1 },
|
|
6173
|
+
{ match: /^\s*(?:(?:public|private|internal|fileprivate|open)\s+)*protocol\s+(\w+)/, kind: "interface", nameGroup: 1 },
|
|
6174
|
+
{ match: /^\s*extension\s+(\w+)/, kind: "type", nameGroup: 1 },
|
|
6175
|
+
{ match: /^\s*(?:(?:public|private|internal|fileprivate|open|static|class|final|override|mutating)\s+)*func\s+(\w+)/, kind: "function", nameGroup: 1 }
|
|
6176
|
+
];
|
|
5898
6177
|
function languageFor(path5) {
|
|
5899
6178
|
const dot = path5.lastIndexOf(".");
|
|
5900
6179
|
const ext = dot >= 0 ? path5.slice(dot).toLowerCase() : "";
|
|
@@ -5921,6 +6200,20 @@ function languageFor(path5) {
|
|
|
5921
6200
|
return { family: "java", rules: JAVA_KOTLIN_RULES };
|
|
5922
6201
|
case ".rb":
|
|
5923
6202
|
return { family: "ruby", rules: RUBY_RULES };
|
|
6203
|
+
// `.h` follows the same C++-over-C choice the tree-sitter mapping makes (loader.ts
|
|
6204
|
+
// `langFromExt`) — the extension is ambiguous and C++ is the more forgiving superset.
|
|
6205
|
+
case ".c":
|
|
6206
|
+
case ".cpp":
|
|
6207
|
+
case ".cc":
|
|
6208
|
+
case ".h":
|
|
6209
|
+
case ".hpp":
|
|
6210
|
+
return { family: "cfamily", rules: C_FAMILY_RULES };
|
|
6211
|
+
case ".cs":
|
|
6212
|
+
return { family: "csharp", rules: CSHARP_RULES };
|
|
6213
|
+
case ".php":
|
|
6214
|
+
return { family: "php", rules: PHP_RULES };
|
|
6215
|
+
case ".swift":
|
|
6216
|
+
return { family: "swift", rules: SWIFT_RULES };
|
|
5924
6217
|
default:
|
|
5925
6218
|
return { family: "other", rules: [] };
|
|
5926
6219
|
}
|
|
@@ -6052,6 +6345,13 @@ function lastWord(s) {
|
|
|
6052
6345
|
const m = s.match(/(\w+)\s*$/);
|
|
6053
6346
|
return m ? m[1] : s;
|
|
6054
6347
|
}
|
|
6348
|
+
function pathBasename(s) {
|
|
6349
|
+
const parts2 = s.trim().split(/[\\/]/);
|
|
6350
|
+
return parts2[parts2.length - 1] || s;
|
|
6351
|
+
}
|
|
6352
|
+
function jsModuleTarget(spec) {
|
|
6353
|
+
return pathBasename(spec).replace(/\.(d\.)?ts$/, "").replace(/\.js$/, "");
|
|
6354
|
+
}
|
|
6055
6355
|
function extractEdgesPython(path5, lines) {
|
|
6056
6356
|
const edges = [];
|
|
6057
6357
|
const scope = [];
|
|
@@ -6161,7 +6461,7 @@ function extractEdgesJsTs(path5, lines) {
|
|
|
6161
6461
|
if (importMatch) {
|
|
6162
6462
|
const moduleSpec = importMatch[5];
|
|
6163
6463
|
if (moduleSpec) {
|
|
6164
|
-
const tgt =
|
|
6464
|
+
const tgt = jsModuleTarget(moduleSpec);
|
|
6165
6465
|
if (tgt) {
|
|
6166
6466
|
edges.push({
|
|
6167
6467
|
kind: "imports",
|
|
@@ -6386,7 +6686,7 @@ function extractEdgesRuby(path5, lines) {
|
|
|
6386
6686
|
const line = lines[i2];
|
|
6387
6687
|
const requireMatch = /^\s*require(?:_relative)?\s+['"]([^'"]+)['"]/.exec(line);
|
|
6388
6688
|
if (requireMatch) {
|
|
6389
|
-
const tgt =
|
|
6689
|
+
const tgt = pathBasename(requireMatch[1]).replace(/\.rb$/, "");
|
|
6390
6690
|
edges.push({
|
|
6391
6691
|
kind: "imports",
|
|
6392
6692
|
source_path: path5,
|
|
@@ -6408,6 +6708,122 @@ function extractEdgesRuby(path5, lines) {
|
|
|
6408
6708
|
}
|
|
6409
6709
|
return edges;
|
|
6410
6710
|
}
|
|
6711
|
+
function stripBracketGroups(s) {
|
|
6712
|
+
let out2 = s;
|
|
6713
|
+
for (let i2 = 0; i2 < 8; i2++) {
|
|
6714
|
+
const next = out2.replace(/<[^<>]*>/g, " ").replace(/\([^()]*\)/g, " ");
|
|
6715
|
+
if (next === out2) break;
|
|
6716
|
+
out2 = next;
|
|
6717
|
+
}
|
|
6718
|
+
return out2;
|
|
6719
|
+
}
|
|
6720
|
+
var declRegexCache = /* @__PURE__ */ new Map();
|
|
6721
|
+
function declRegexFor(keywords) {
|
|
6722
|
+
const key = keywords.join("|");
|
|
6723
|
+
let re = declRegexCache.get(key);
|
|
6724
|
+
if (!re) {
|
|
6725
|
+
re = new RegExp(`^\\s*(?:[\\w[\\]]+\\s+)*?(?:${key})\\s+(\\w+)\\s*:\\s*([^{;/]+)`);
|
|
6726
|
+
declRegexCache.set(key, re);
|
|
6727
|
+
}
|
|
6728
|
+
return re;
|
|
6729
|
+
}
|
|
6730
|
+
function extractEdgesColonInherit(path5, lines, opts) {
|
|
6731
|
+
const edges = [];
|
|
6732
|
+
const declRe = declRegexFor(opts.declKeywords);
|
|
6733
|
+
for (let i2 = 0; i2 < lines.length; i2++) {
|
|
6734
|
+
const line = lines[i2];
|
|
6735
|
+
const imp = opts.importRe.exec(line);
|
|
6736
|
+
if (imp && imp[1]) {
|
|
6737
|
+
const target = opts.importTarget(imp[1]);
|
|
6738
|
+
if (target) {
|
|
6739
|
+
edges.push({
|
|
6740
|
+
kind: "imports",
|
|
6741
|
+
source_path: path5,
|
|
6742
|
+
source_name: "",
|
|
6743
|
+
target: target.toLowerCase(),
|
|
6744
|
+
line: i2 + 1
|
|
6745
|
+
});
|
|
6746
|
+
}
|
|
6747
|
+
}
|
|
6748
|
+
const decl = declRe.exec(line);
|
|
6749
|
+
if (decl) {
|
|
6750
|
+
const child = decl[1];
|
|
6751
|
+
let list = decl[2];
|
|
6752
|
+
const whereAt = list.search(/\bwhere\b/);
|
|
6753
|
+
if (whereAt >= 0) list = list.slice(0, whereAt);
|
|
6754
|
+
for (const raw of stripBracketGroups(list).split(",")) {
|
|
6755
|
+
let base = raw;
|
|
6756
|
+
if (opts.baseNoise) base = base.replace(opts.baseNoise, " ");
|
|
6757
|
+
const first = base.trim().split(/\s+/)[0] ?? "";
|
|
6758
|
+
const name2 = first.includes(".") ? first.split(".").pop() ?? "" : first;
|
|
6759
|
+
if (/^\w+$/.test(name2) && name2 !== child) {
|
|
6760
|
+
edges.push({
|
|
6761
|
+
kind: "extends",
|
|
6762
|
+
source_path: path5,
|
|
6763
|
+
source_name: child,
|
|
6764
|
+
target: name2.toLowerCase(),
|
|
6765
|
+
line: i2 + 1
|
|
6766
|
+
});
|
|
6767
|
+
}
|
|
6768
|
+
}
|
|
6769
|
+
}
|
|
6770
|
+
}
|
|
6771
|
+
return edges;
|
|
6772
|
+
}
|
|
6773
|
+
function extractEdgesPhp(path5, lines) {
|
|
6774
|
+
const edges = [];
|
|
6775
|
+
for (let i2 = 0; i2 < lines.length; i2++) {
|
|
6776
|
+
const line = lines[i2];
|
|
6777
|
+
const use = /^\s*use\s+([\w\\]+)\s*(?:as\s+\w+\s*)?;/.exec(line);
|
|
6778
|
+
if (use) {
|
|
6779
|
+
edges.push({
|
|
6780
|
+
kind: "imports",
|
|
6781
|
+
source_path: path5,
|
|
6782
|
+
source_name: "",
|
|
6783
|
+
target: lastWord(use[1].replace(/\\/g, ".")).toLowerCase(),
|
|
6784
|
+
line: i2 + 1
|
|
6785
|
+
});
|
|
6786
|
+
}
|
|
6787
|
+
const req = /^\s*(?:require|include)(?:_once)?\s*\(?\s*['"]([^'"]+)['"]/.exec(line);
|
|
6788
|
+
if (req) {
|
|
6789
|
+
edges.push({
|
|
6790
|
+
kind: "imports",
|
|
6791
|
+
source_path: path5,
|
|
6792
|
+
source_name: "",
|
|
6793
|
+
target: pathBasename(req[1]).toLowerCase(),
|
|
6794
|
+
line: i2 + 1
|
|
6795
|
+
});
|
|
6796
|
+
}
|
|
6797
|
+
const decl = /^\s*(?:abstract\s+|final\s+)*class\s+(\w+)(?:\s+extends\s+([\w\\]+))?(?:\s+implements\s+([\w\\,\s]+))?/.exec(line);
|
|
6798
|
+
if (decl) {
|
|
6799
|
+
const child = decl[1];
|
|
6800
|
+
if (decl[2]) {
|
|
6801
|
+
edges.push({
|
|
6802
|
+
kind: "extends",
|
|
6803
|
+
source_path: path5,
|
|
6804
|
+
source_name: child,
|
|
6805
|
+
target: lastWord(decl[2].replace(/\\/g, ".")).toLowerCase(),
|
|
6806
|
+
line: i2 + 1
|
|
6807
|
+
});
|
|
6808
|
+
}
|
|
6809
|
+
if (decl[3]) {
|
|
6810
|
+
for (const raw of decl[3].split(",")) {
|
|
6811
|
+
const name2 = lastWord(raw.trim().replace(/\\/g, "."));
|
|
6812
|
+
if (name2) {
|
|
6813
|
+
edges.push({
|
|
6814
|
+
kind: "implements",
|
|
6815
|
+
source_path: path5,
|
|
6816
|
+
source_name: child,
|
|
6817
|
+
target: name2.toLowerCase(),
|
|
6818
|
+
line: i2 + 1
|
|
6819
|
+
});
|
|
6820
|
+
}
|
|
6821
|
+
}
|
|
6822
|
+
}
|
|
6823
|
+
}
|
|
6824
|
+
}
|
|
6825
|
+
return edges;
|
|
6826
|
+
}
|
|
6411
6827
|
function extractEdges(path5, content) {
|
|
6412
6828
|
const { family } = languageFor(path5);
|
|
6413
6829
|
const lines = content.split("\n");
|
|
@@ -6424,6 +6840,30 @@ function extractEdges(path5, content) {
|
|
|
6424
6840
|
return extractEdgesJava(path5, lines);
|
|
6425
6841
|
case "ruby":
|
|
6426
6842
|
return extractEdgesRuby(path5, lines);
|
|
6843
|
+
case "cfamily":
|
|
6844
|
+
return extractEdgesColonInherit(path5, lines, {
|
|
6845
|
+
importRe: /^\s*#\s*include\s+"([^"]+)"/,
|
|
6846
|
+
importTarget: pathBasename,
|
|
6847
|
+
// C++ `enum class Foo : int` names a storage type, not a base — excluded (see declKeywords).
|
|
6848
|
+
declKeywords: ["class", "struct"],
|
|
6849
|
+
baseNoise: /\b(?:public|private|protected|virtual)\b/g
|
|
6850
|
+
});
|
|
6851
|
+
case "csharp":
|
|
6852
|
+
return extractEdgesColonInherit(path5, lines, {
|
|
6853
|
+
importRe: /^\s*(?:global\s+)?using\s+(?:static\s+)?([\w.]+)\s*;/,
|
|
6854
|
+
importTarget: lastWord,
|
|
6855
|
+
// `enum Color : byte` is a storage type, not a base — excluded (see declKeywords).
|
|
6856
|
+
declKeywords: ["class", "struct", "interface"]
|
|
6857
|
+
});
|
|
6858
|
+
case "swift":
|
|
6859
|
+
return extractEdgesColonInherit(path5, lines, {
|
|
6860
|
+
importRe: /^\s*import\s+([\w.]+)/,
|
|
6861
|
+
importTarget: lastWord,
|
|
6862
|
+
// Swift DOES carry real conformance on an enum, and its query emits those edges.
|
|
6863
|
+
declKeywords: ["class", "struct", "enum", "protocol"]
|
|
6864
|
+
});
|
|
6865
|
+
case "php":
|
|
6866
|
+
return extractEdgesPhp(path5, lines);
|
|
6427
6867
|
default:
|
|
6428
6868
|
return [];
|
|
6429
6869
|
}
|