orion-super-agent-dev 0.1.13 → 0.1.15
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 +473 -15
- package/out/main.js +8247 -4442
- 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 {
|
|
@@ -5312,6 +5551,24 @@ var import_fs2 = require("fs");
|
|
|
5312
5551
|
var import_fs = require("fs");
|
|
5313
5552
|
var import_path = require("path");
|
|
5314
5553
|
var tmpSeq = 0;
|
|
5554
|
+
var RENAME_CONTENTION = /* @__PURE__ */ new Set(["EPERM", "EACCES", "EBUSY"]);
|
|
5555
|
+
function retriesRenameContention(code, platform = process.platform) {
|
|
5556
|
+
return platform === "win32" && code !== void 0 && RENAME_CONTENTION.has(code);
|
|
5557
|
+
}
|
|
5558
|
+
async function renameWhenUnlocked(tmp, target) {
|
|
5559
|
+
const ATTEMPTS = 20;
|
|
5560
|
+
const DELAY_MS = 5;
|
|
5561
|
+
for (let attempt = 1; ; attempt++) {
|
|
5562
|
+
try {
|
|
5563
|
+
await import_fs.promises.rename(tmp, target);
|
|
5564
|
+
return;
|
|
5565
|
+
} catch (err2) {
|
|
5566
|
+
const code = err2.code;
|
|
5567
|
+
if (attempt >= ATTEMPTS || !retriesRenameContention(code)) throw err2;
|
|
5568
|
+
await new Promise((resolve5) => setTimeout(resolve5, DELAY_MS));
|
|
5569
|
+
}
|
|
5570
|
+
}
|
|
5571
|
+
}
|
|
5315
5572
|
async function atomicWriteFile(targetPath, content, options = {}) {
|
|
5316
5573
|
const encoding = options.encoding ?? "utf8";
|
|
5317
5574
|
let target = targetPath;
|
|
@@ -5337,7 +5594,7 @@ async function atomicWriteFile(targetPath, content, options = {}) {
|
|
|
5337
5594
|
await handle4.close();
|
|
5338
5595
|
}
|
|
5339
5596
|
if (targetExists && targetMode !== void 0) await import_fs.promises.chmod(tmp, targetMode);
|
|
5340
|
-
await
|
|
5597
|
+
await renameWhenUnlocked(tmp, target);
|
|
5341
5598
|
} catch {
|
|
5342
5599
|
await import_fs.promises.unlink(tmp).catch(() => {
|
|
5343
5600
|
});
|
|
@@ -5895,6 +6152,46 @@ var RUBY_RULES = [
|
|
|
5895
6152
|
{ match: /^\s*class\s+(\w+)/, kind: "class", nameGroup: 1 },
|
|
5896
6153
|
{ match: /^\s*module\s+(\w+)/, kind: "type", nameGroup: 1 }
|
|
5897
6154
|
];
|
|
6155
|
+
var C_FAMILY_RULES = [
|
|
6156
|
+
{ match: /^\s*(?:template\s*<[^>]*>\s*)?class\s+(\w+)/, kind: "class", nameGroup: 1 },
|
|
6157
|
+
{ match: /^\s*(?:typedef\s+)?struct\s+(\w+)/, kind: "struct", nameGroup: 1 },
|
|
6158
|
+
{ match: /^\s*enum(?:\s+class)?\s+(\w+)/, kind: "enum", nameGroup: 1 },
|
|
6159
|
+
{ match: /^\s*namespace\s+(\w+)/, kind: "type", nameGroup: 1 },
|
|
6160
|
+
// A definition, not a declaration: the line must open a body, so `void go();` is correctly
|
|
6161
|
+
// skipped. Leading indentation IS allowed, because a class's methods are indented and they are
|
|
6162
|
+
// most of the content of the large C++ files this fallback exists to serve — anchoring at column
|
|
6163
|
+
// 0 found the class and none of its methods.
|
|
6164
|
+
//
|
|
6165
|
+
// Allowing indentation is what makes the negative lookahead load-bearing: without it, `if (x) {`,
|
|
6166
|
+
// `while (y) {` and `for (i) {` all parse as functions named after the keyword. `\b` in the
|
|
6167
|
+
// lookahead keeps a real function called `news()` or `deleter()` matchable.
|
|
6168
|
+
{
|
|
6169
|
+
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+)*\{/,
|
|
6170
|
+
kind: "function",
|
|
6171
|
+
nameGroup: 1
|
|
6172
|
+
}
|
|
6173
|
+
];
|
|
6174
|
+
var CSHARP_RULES = [
|
|
6175
|
+
{ match: /^\s*(?:public|private|protected|internal|static|sealed|abstract|partial|\s)*class\s+(\w+)/, kind: "class", nameGroup: 1 },
|
|
6176
|
+
{ match: /^\s*(?:public|private|protected|internal|partial|\s)*interface\s+(\w+)/, kind: "interface", nameGroup: 1 },
|
|
6177
|
+
{ match: /^\s*(?:public|private|protected|internal|readonly|record|partial|\s)*struct\s+(\w+)/, kind: "struct", nameGroup: 1 },
|
|
6178
|
+
{ match: /^\s*(?:public|private|protected|internal|\s)*enum\s+(\w+)/, kind: "enum", nameGroup: 1 },
|
|
6179
|
+
{ 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 }
|
|
6180
|
+
];
|
|
6181
|
+
var PHP_RULES = [
|
|
6182
|
+
{ match: /^\s*(?:abstract\s+|final\s+)*class\s+(\w+)/, kind: "class", nameGroup: 1 },
|
|
6183
|
+
{ match: /^\s*interface\s+(\w+)/, kind: "interface", nameGroup: 1 },
|
|
6184
|
+
{ match: /^\s*trait\s+(\w+)/, kind: "class", nameGroup: 1 },
|
|
6185
|
+
{ match: /^\s*(?:(?:public|private|protected|static|abstract|final)\s+)*function\s+&?(\w+)\s*\(/, kind: "function", nameGroup: 1 }
|
|
6186
|
+
];
|
|
6187
|
+
var SWIFT_RULES = [
|
|
6188
|
+
{ match: /^\s*(?:(?:public|private|internal|fileprivate|open|final)\s+)*class\s+(\w+)/, kind: "class", nameGroup: 1 },
|
|
6189
|
+
{ match: /^\s*(?:(?:public|private|internal|fileprivate|open)\s+)*struct\s+(\w+)/, kind: "struct", nameGroup: 1 },
|
|
6190
|
+
{ match: /^\s*(?:(?:public|private|internal|fileprivate|open|indirect)\s+)*enum\s+(\w+)/, kind: "enum", nameGroup: 1 },
|
|
6191
|
+
{ match: /^\s*(?:(?:public|private|internal|fileprivate|open)\s+)*protocol\s+(\w+)/, kind: "interface", nameGroup: 1 },
|
|
6192
|
+
{ match: /^\s*extension\s+(\w+)/, kind: "type", nameGroup: 1 },
|
|
6193
|
+
{ match: /^\s*(?:(?:public|private|internal|fileprivate|open|static|class|final|override|mutating)\s+)*func\s+(\w+)/, kind: "function", nameGroup: 1 }
|
|
6194
|
+
];
|
|
5898
6195
|
function languageFor(path5) {
|
|
5899
6196
|
const dot = path5.lastIndexOf(".");
|
|
5900
6197
|
const ext = dot >= 0 ? path5.slice(dot).toLowerCase() : "";
|
|
@@ -5921,6 +6218,20 @@ function languageFor(path5) {
|
|
|
5921
6218
|
return { family: "java", rules: JAVA_KOTLIN_RULES };
|
|
5922
6219
|
case ".rb":
|
|
5923
6220
|
return { family: "ruby", rules: RUBY_RULES };
|
|
6221
|
+
// `.h` follows the same C++-over-C choice the tree-sitter mapping makes (loader.ts
|
|
6222
|
+
// `langFromExt`) — the extension is ambiguous and C++ is the more forgiving superset.
|
|
6223
|
+
case ".c":
|
|
6224
|
+
case ".cpp":
|
|
6225
|
+
case ".cc":
|
|
6226
|
+
case ".h":
|
|
6227
|
+
case ".hpp":
|
|
6228
|
+
return { family: "cfamily", rules: C_FAMILY_RULES };
|
|
6229
|
+
case ".cs":
|
|
6230
|
+
return { family: "csharp", rules: CSHARP_RULES };
|
|
6231
|
+
case ".php":
|
|
6232
|
+
return { family: "php", rules: PHP_RULES };
|
|
6233
|
+
case ".swift":
|
|
6234
|
+
return { family: "swift", rules: SWIFT_RULES };
|
|
5924
6235
|
default:
|
|
5925
6236
|
return { family: "other", rules: [] };
|
|
5926
6237
|
}
|
|
@@ -6052,6 +6363,13 @@ function lastWord(s) {
|
|
|
6052
6363
|
const m = s.match(/(\w+)\s*$/);
|
|
6053
6364
|
return m ? m[1] : s;
|
|
6054
6365
|
}
|
|
6366
|
+
function pathBasename(s) {
|
|
6367
|
+
const parts2 = s.trim().split(/[\\/]/);
|
|
6368
|
+
return parts2[parts2.length - 1] || s;
|
|
6369
|
+
}
|
|
6370
|
+
function jsModuleTarget(spec) {
|
|
6371
|
+
return pathBasename(spec).replace(/\.(d\.)?ts$/, "").replace(/\.js$/, "");
|
|
6372
|
+
}
|
|
6055
6373
|
function extractEdgesPython(path5, lines) {
|
|
6056
6374
|
const edges = [];
|
|
6057
6375
|
const scope = [];
|
|
@@ -6161,7 +6479,7 @@ function extractEdgesJsTs(path5, lines) {
|
|
|
6161
6479
|
if (importMatch) {
|
|
6162
6480
|
const moduleSpec = importMatch[5];
|
|
6163
6481
|
if (moduleSpec) {
|
|
6164
|
-
const tgt =
|
|
6482
|
+
const tgt = jsModuleTarget(moduleSpec);
|
|
6165
6483
|
if (tgt) {
|
|
6166
6484
|
edges.push({
|
|
6167
6485
|
kind: "imports",
|
|
@@ -6386,7 +6704,7 @@ function extractEdgesRuby(path5, lines) {
|
|
|
6386
6704
|
const line = lines[i2];
|
|
6387
6705
|
const requireMatch = /^\s*require(?:_relative)?\s+['"]([^'"]+)['"]/.exec(line);
|
|
6388
6706
|
if (requireMatch) {
|
|
6389
|
-
const tgt =
|
|
6707
|
+
const tgt = pathBasename(requireMatch[1]).replace(/\.rb$/, "");
|
|
6390
6708
|
edges.push({
|
|
6391
6709
|
kind: "imports",
|
|
6392
6710
|
source_path: path5,
|
|
@@ -6408,6 +6726,122 @@ function extractEdgesRuby(path5, lines) {
|
|
|
6408
6726
|
}
|
|
6409
6727
|
return edges;
|
|
6410
6728
|
}
|
|
6729
|
+
function stripBracketGroups(s) {
|
|
6730
|
+
let out2 = s;
|
|
6731
|
+
for (let i2 = 0; i2 < 8; i2++) {
|
|
6732
|
+
const next = out2.replace(/<[^<>]*>/g, " ").replace(/\([^()]*\)/g, " ");
|
|
6733
|
+
if (next === out2) break;
|
|
6734
|
+
out2 = next;
|
|
6735
|
+
}
|
|
6736
|
+
return out2;
|
|
6737
|
+
}
|
|
6738
|
+
var declRegexCache = /* @__PURE__ */ new Map();
|
|
6739
|
+
function declRegexFor(keywords) {
|
|
6740
|
+
const key = keywords.join("|");
|
|
6741
|
+
let re = declRegexCache.get(key);
|
|
6742
|
+
if (!re) {
|
|
6743
|
+
re = new RegExp(`^\\s*(?:[\\w[\\]]+\\s+)*?(?:${key})\\s+(\\w+)\\s*:\\s*([^{;/]+)`);
|
|
6744
|
+
declRegexCache.set(key, re);
|
|
6745
|
+
}
|
|
6746
|
+
return re;
|
|
6747
|
+
}
|
|
6748
|
+
function extractEdgesColonInherit(path5, lines, opts) {
|
|
6749
|
+
const edges = [];
|
|
6750
|
+
const declRe = declRegexFor(opts.declKeywords);
|
|
6751
|
+
for (let i2 = 0; i2 < lines.length; i2++) {
|
|
6752
|
+
const line = lines[i2];
|
|
6753
|
+
const imp = opts.importRe.exec(line);
|
|
6754
|
+
if (imp && imp[1]) {
|
|
6755
|
+
const target = opts.importTarget(imp[1]);
|
|
6756
|
+
if (target) {
|
|
6757
|
+
edges.push({
|
|
6758
|
+
kind: "imports",
|
|
6759
|
+
source_path: path5,
|
|
6760
|
+
source_name: "",
|
|
6761
|
+
target: target.toLowerCase(),
|
|
6762
|
+
line: i2 + 1
|
|
6763
|
+
});
|
|
6764
|
+
}
|
|
6765
|
+
}
|
|
6766
|
+
const decl = declRe.exec(line);
|
|
6767
|
+
if (decl) {
|
|
6768
|
+
const child = decl[1];
|
|
6769
|
+
let list = decl[2];
|
|
6770
|
+
const whereAt = list.search(/\bwhere\b/);
|
|
6771
|
+
if (whereAt >= 0) list = list.slice(0, whereAt);
|
|
6772
|
+
for (const raw of stripBracketGroups(list).split(",")) {
|
|
6773
|
+
let base = raw;
|
|
6774
|
+
if (opts.baseNoise) base = base.replace(opts.baseNoise, " ");
|
|
6775
|
+
const first = base.trim().split(/\s+/)[0] ?? "";
|
|
6776
|
+
const name2 = first.includes(".") ? first.split(".").pop() ?? "" : first;
|
|
6777
|
+
if (/^\w+$/.test(name2) && name2 !== child) {
|
|
6778
|
+
edges.push({
|
|
6779
|
+
kind: "extends",
|
|
6780
|
+
source_path: path5,
|
|
6781
|
+
source_name: child,
|
|
6782
|
+
target: name2.toLowerCase(),
|
|
6783
|
+
line: i2 + 1
|
|
6784
|
+
});
|
|
6785
|
+
}
|
|
6786
|
+
}
|
|
6787
|
+
}
|
|
6788
|
+
}
|
|
6789
|
+
return edges;
|
|
6790
|
+
}
|
|
6791
|
+
function extractEdgesPhp(path5, lines) {
|
|
6792
|
+
const edges = [];
|
|
6793
|
+
for (let i2 = 0; i2 < lines.length; i2++) {
|
|
6794
|
+
const line = lines[i2];
|
|
6795
|
+
const use = /^\s*use\s+([\w\\]+)\s*(?:as\s+\w+\s*)?;/.exec(line);
|
|
6796
|
+
if (use) {
|
|
6797
|
+
edges.push({
|
|
6798
|
+
kind: "imports",
|
|
6799
|
+
source_path: path5,
|
|
6800
|
+
source_name: "",
|
|
6801
|
+
target: lastWord(use[1].replace(/\\/g, ".")).toLowerCase(),
|
|
6802
|
+
line: i2 + 1
|
|
6803
|
+
});
|
|
6804
|
+
}
|
|
6805
|
+
const req = /^\s*(?:require|include)(?:_once)?\s*\(?\s*['"]([^'"]+)['"]/.exec(line);
|
|
6806
|
+
if (req) {
|
|
6807
|
+
edges.push({
|
|
6808
|
+
kind: "imports",
|
|
6809
|
+
source_path: path5,
|
|
6810
|
+
source_name: "",
|
|
6811
|
+
target: pathBasename(req[1]).toLowerCase(),
|
|
6812
|
+
line: i2 + 1
|
|
6813
|
+
});
|
|
6814
|
+
}
|
|
6815
|
+
const decl = /^\s*(?:abstract\s+|final\s+)*class\s+(\w+)(?:\s+extends\s+([\w\\]+))?(?:\s+implements\s+([\w\\,\s]+))?/.exec(line);
|
|
6816
|
+
if (decl) {
|
|
6817
|
+
const child = decl[1];
|
|
6818
|
+
if (decl[2]) {
|
|
6819
|
+
edges.push({
|
|
6820
|
+
kind: "extends",
|
|
6821
|
+
source_path: path5,
|
|
6822
|
+
source_name: child,
|
|
6823
|
+
target: lastWord(decl[2].replace(/\\/g, ".")).toLowerCase(),
|
|
6824
|
+
line: i2 + 1
|
|
6825
|
+
});
|
|
6826
|
+
}
|
|
6827
|
+
if (decl[3]) {
|
|
6828
|
+
for (const raw of decl[3].split(",")) {
|
|
6829
|
+
const name2 = lastWord(raw.trim().replace(/\\/g, "."));
|
|
6830
|
+
if (name2) {
|
|
6831
|
+
edges.push({
|
|
6832
|
+
kind: "implements",
|
|
6833
|
+
source_path: path5,
|
|
6834
|
+
source_name: child,
|
|
6835
|
+
target: name2.toLowerCase(),
|
|
6836
|
+
line: i2 + 1
|
|
6837
|
+
});
|
|
6838
|
+
}
|
|
6839
|
+
}
|
|
6840
|
+
}
|
|
6841
|
+
}
|
|
6842
|
+
}
|
|
6843
|
+
return edges;
|
|
6844
|
+
}
|
|
6411
6845
|
function extractEdges(path5, content) {
|
|
6412
6846
|
const { family } = languageFor(path5);
|
|
6413
6847
|
const lines = content.split("\n");
|
|
@@ -6424,6 +6858,30 @@ function extractEdges(path5, content) {
|
|
|
6424
6858
|
return extractEdgesJava(path5, lines);
|
|
6425
6859
|
case "ruby":
|
|
6426
6860
|
return extractEdgesRuby(path5, lines);
|
|
6861
|
+
case "cfamily":
|
|
6862
|
+
return extractEdgesColonInherit(path5, lines, {
|
|
6863
|
+
importRe: /^\s*#\s*include\s+"([^"]+)"/,
|
|
6864
|
+
importTarget: pathBasename,
|
|
6865
|
+
// C++ `enum class Foo : int` names a storage type, not a base — excluded (see declKeywords).
|
|
6866
|
+
declKeywords: ["class", "struct"],
|
|
6867
|
+
baseNoise: /\b(?:public|private|protected|virtual)\b/g
|
|
6868
|
+
});
|
|
6869
|
+
case "csharp":
|
|
6870
|
+
return extractEdgesColonInherit(path5, lines, {
|
|
6871
|
+
importRe: /^\s*(?:global\s+)?using\s+(?:static\s+)?([\w.]+)\s*;/,
|
|
6872
|
+
importTarget: lastWord,
|
|
6873
|
+
// `enum Color : byte` is a storage type, not a base — excluded (see declKeywords).
|
|
6874
|
+
declKeywords: ["class", "struct", "interface"]
|
|
6875
|
+
});
|
|
6876
|
+
case "swift":
|
|
6877
|
+
return extractEdgesColonInherit(path5, lines, {
|
|
6878
|
+
importRe: /^\s*import\s+([\w.]+)/,
|
|
6879
|
+
importTarget: lastWord,
|
|
6880
|
+
// Swift DOES carry real conformance on an enum, and its query emits those edges.
|
|
6881
|
+
declKeywords: ["class", "struct", "enum", "protocol"]
|
|
6882
|
+
});
|
|
6883
|
+
case "php":
|
|
6884
|
+
return extractEdgesPhp(path5, lines);
|
|
6427
6885
|
default:
|
|
6428
6886
|
return [];
|
|
6429
6887
|
}
|