@aiready/core 0.21.14 → 0.21.16

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/index.js CHANGED
@@ -35,15 +35,18 @@ __export(index_exports, {
35
35
  AnalysisStatusSchema: () => AnalysisStatusSchema,
36
36
  COMMON_FINE_TUNING_OPTIONS: () => COMMON_FINE_TUNING_OPTIONS,
37
37
  CONTEXT_TIER_THRESHOLDS: () => CONTEXT_TIER_THRESHOLDS,
38
+ CSharpParser: () => CSharpParser,
38
39
  DEFAULT_COST_CONFIG: () => DEFAULT_COST_CONFIG,
39
40
  DEFAULT_EXCLUDE: () => DEFAULT_EXCLUDE,
40
41
  DEFAULT_TOOL_WEIGHTS: () => DEFAULT_TOOL_WEIGHTS,
41
42
  FRIENDLY_TOOL_NAMES: () => FRIENDLY_TOOL_NAMES,
42
43
  GLOBAL_INFRA_OPTIONS: () => GLOBAL_INFRA_OPTIONS,
43
44
  GLOBAL_SCAN_OPTIONS: () => GLOBAL_SCAN_OPTIONS,
45
+ GoParser: () => GoParser,
44
46
  IssueSchema: () => IssueSchema,
45
47
  IssueType: () => IssueType,
46
48
  IssueTypeSchema: () => IssueTypeSchema,
49
+ JavaParser: () => JavaParser,
47
50
  LANGUAGE_EXTENSIONS: () => LANGUAGE_EXTENSIONS,
48
51
  Language: () => Language,
49
52
  LocationSchema: () => LocationSchema,
@@ -333,15 +336,15 @@ var COMMON_FINE_TUNING_OPTIONS = [
333
336
  var GLOBAL_SCAN_OPTIONS = [...GLOBAL_INFRA_OPTIONS];
334
337
 
335
338
  // src/types/language.ts
336
- var Language = /* @__PURE__ */ ((Language3) => {
337
- Language3["TypeScript"] = "typescript";
338
- Language3["JavaScript"] = "javascript";
339
- Language3["Python"] = "python";
340
- Language3["Java"] = "java";
341
- Language3["Go"] = "go";
342
- Language3["Rust"] = "rust";
343
- Language3["CSharp"] = "csharp";
344
- return Language3;
339
+ var Language = /* @__PURE__ */ ((Language6) => {
340
+ Language6["TypeScript"] = "typescript";
341
+ Language6["JavaScript"] = "javascript";
342
+ Language6["Python"] = "python";
343
+ Language6["Java"] = "java";
344
+ Language6["Go"] = "go";
345
+ Language6["Rust"] = "rust";
346
+ Language6["CSharp"] = "csharp";
347
+ return Language6;
345
348
  })(Language || {});
346
349
  var LANGUAGE_EXTENSIONS = {
347
350
  ".ts": "typescript" /* TypeScript */,
@@ -1030,19 +1033,23 @@ var PythonParser = class {
1030
1033
  const possiblePaths = [
1031
1034
  path.join(
1032
1035
  process.cwd(),
1033
- "node_modules/tree-sitter-python/tree-sitter-python.wasm"
1036
+ "node_modules/@unit-mesh/treesitter-artifacts/wasm/tree-sitter-python.wasm"
1034
1037
  ),
1035
1038
  path.join(
1036
1039
  __dirname,
1037
- "../../node_modules/tree-sitter-python/tree-sitter-python.wasm"
1040
+ "../../node_modules/@unit-mesh/treesitter-artifacts/wasm/tree-sitter-python.wasm"
1038
1041
  ),
1039
1042
  path.join(
1040
1043
  __dirname,
1041
- "../../../node_modules/tree-sitter-python/tree-sitter-python.wasm"
1044
+ "../../../node_modules/@unit-mesh/treesitter-artifacts/wasm/tree-sitter-python.wasm"
1042
1045
  ),
1043
1046
  path.join(
1044
1047
  __dirname,
1045
- "../../../../node_modules/tree-sitter-python/tree-sitter-python.wasm"
1048
+ "../../../../node_modules/@unit-mesh/treesitter-artifacts/wasm/tree-sitter-python.wasm"
1049
+ ),
1050
+ path.join(
1051
+ process.cwd(),
1052
+ "node_modules/tree-sitter-wasms/out/tree-sitter-python.wasm"
1046
1053
  ),
1047
1054
  path.join(__dirname, "../assets/tree-sitter-python.wasm")
1048
1055
  ];
@@ -1420,6 +1427,668 @@ var PythonParser = class {
1420
1427
  }
1421
1428
  };
1422
1429
 
1430
+ // src/parsers/java-parser.ts
1431
+ var Parser3 = __toESM(require("web-tree-sitter"));
1432
+ var path2 = __toESM(require("path"));
1433
+ var fs2 = __toESM(require("fs"));
1434
+ var JavaParser = class {
1435
+ constructor() {
1436
+ this.language = "java" /* Java */;
1437
+ this.extensions = [".java"];
1438
+ this.parser = null;
1439
+ this.initialized = false;
1440
+ }
1441
+ /**
1442
+ * Initialize the tree-sitter parser
1443
+ */
1444
+ async initialize() {
1445
+ if (this.initialized) return;
1446
+ try {
1447
+ if (typeof Parser3.Parser.init === "function") {
1448
+ await Parser3.Parser.init();
1449
+ }
1450
+ this.parser = new Parser3.Parser();
1451
+ const possiblePaths = [
1452
+ path2.join(
1453
+ process.cwd(),
1454
+ "node_modules/@unit-mesh/treesitter-artifacts/wasm/tree-sitter-java.wasm"
1455
+ ),
1456
+ path2.join(
1457
+ __dirname,
1458
+ "../../node_modules/@unit-mesh/treesitter-artifacts/wasm/tree-sitter-java.wasm"
1459
+ ),
1460
+ path2.join(
1461
+ __dirname,
1462
+ "../../../node_modules/@unit-mesh/treesitter-artifacts/wasm/tree-sitter-java.wasm"
1463
+ ),
1464
+ path2.join(
1465
+ __dirname,
1466
+ "../../../../node_modules/@unit-mesh/treesitter-artifacts/wasm/tree-sitter-java.wasm"
1467
+ ),
1468
+ path2.join(
1469
+ process.cwd(),
1470
+ "node_modules/tree-sitter-wasms/out/tree-sitter-java.wasm"
1471
+ )
1472
+ ];
1473
+ let wasmPath = "";
1474
+ for (const p of possiblePaths) {
1475
+ if (fs2.existsSync(p)) {
1476
+ wasmPath = p;
1477
+ break;
1478
+ }
1479
+ }
1480
+ if (!wasmPath) {
1481
+ console.warn(
1482
+ `Java WASM not found. Tried paths: ${possiblePaths.join(", ")}`
1483
+ );
1484
+ return;
1485
+ }
1486
+ const Java = await Parser3.Language.load(wasmPath);
1487
+ this.parser.setLanguage(Java);
1488
+ this.initialized = true;
1489
+ } catch (error) {
1490
+ console.error("Failed to initialize tree-sitter-java:", error);
1491
+ if (error instanceof Error && error.stack) {
1492
+ console.error(error.stack);
1493
+ }
1494
+ }
1495
+ }
1496
+ parse(code, filePath) {
1497
+ if (!this.initialized || !this.parser) {
1498
+ throw new ParseError(
1499
+ `JavaParser not initialized for ${filePath}`,
1500
+ filePath
1501
+ );
1502
+ }
1503
+ try {
1504
+ const tree = this.parser.parse(code);
1505
+ if (!tree) throw new Error("Parser.parse(code) returned null");
1506
+ const rootNode = tree.rootNode;
1507
+ const imports = this.extractImportsAST(rootNode);
1508
+ const exports2 = this.extractExportsAST(rootNode);
1509
+ return {
1510
+ exports: exports2,
1511
+ imports,
1512
+ language: "java" /* Java */,
1513
+ warnings: []
1514
+ };
1515
+ } catch (error) {
1516
+ throw new ParseError(
1517
+ `AST parsing failed for ${filePath}: ${error.message}`,
1518
+ filePath
1519
+ );
1520
+ }
1521
+ }
1522
+ extractImportsAST(rootNode) {
1523
+ const imports = [];
1524
+ for (const node of rootNode.children) {
1525
+ if (node.type === "import_declaration") {
1526
+ let sourceArr = [];
1527
+ let isStatic = false;
1528
+ let isWildcard = false;
1529
+ for (const child of node.children) {
1530
+ if (child.type === "static") isStatic = true;
1531
+ if (child.type === "scoped_identifier" || child.type === "identifier") {
1532
+ sourceArr.push(child.text);
1533
+ }
1534
+ if (child.type === "asterisk") isWildcard = true;
1535
+ }
1536
+ const source = sourceArr.join(".");
1537
+ if (source) {
1538
+ imports.push({
1539
+ source: isWildcard ? `${source}.*` : source,
1540
+ specifiers: isWildcard ? ["*"] : [source.split(".").pop() || source],
1541
+ loc: {
1542
+ start: {
1543
+ line: node.startPosition.row + 1,
1544
+ column: node.startPosition.column
1545
+ },
1546
+ end: {
1547
+ line: node.endPosition.row + 1,
1548
+ column: node.endPosition.column
1549
+ }
1550
+ }
1551
+ });
1552
+ }
1553
+ }
1554
+ }
1555
+ return imports;
1556
+ }
1557
+ extractExportsAST(rootNode) {
1558
+ const exports2 = [];
1559
+ for (const node of rootNode.children) {
1560
+ if (node.type === "class_declaration" || node.type === "interface_declaration" || node.type === "enum_declaration") {
1561
+ const nameNode = node.children.find((c) => c.type === "identifier");
1562
+ if (nameNode) {
1563
+ const modifiers = this.getModifiers(node);
1564
+ exports2.push({
1565
+ name: nameNode.text,
1566
+ type: node.type === "class_declaration" ? "class" : "interface",
1567
+ loc: {
1568
+ start: {
1569
+ line: node.startPosition.row + 1,
1570
+ column: node.startPosition.column
1571
+ },
1572
+ end: {
1573
+ line: node.endPosition.row + 1,
1574
+ column: node.endPosition.column
1575
+ }
1576
+ },
1577
+ visibility: modifiers.includes("public") ? "public" : "private"
1578
+ });
1579
+ this.extractSubExports(node, nameNode.text, exports2);
1580
+ }
1581
+ }
1582
+ }
1583
+ return exports2;
1584
+ }
1585
+ getModifiers(node) {
1586
+ const modifiersNode = node.children.find((c) => c.type === "modifiers");
1587
+ if (!modifiersNode) return [];
1588
+ return modifiersNode.children.map((c) => c.text);
1589
+ }
1590
+ extractSubExports(parentNode, parentName, exports2) {
1591
+ const bodyNode = parentNode.children.find((c) => c.type === "class_body");
1592
+ if (!bodyNode) return;
1593
+ for (const node of bodyNode.children) {
1594
+ if (node.type === "method_declaration") {
1595
+ const nameNode = node.children.find((c) => c.type === "identifier");
1596
+ const modifiers = this.getModifiers(node);
1597
+ if (nameNode && modifiers.includes("public")) {
1598
+ exports2.push({
1599
+ name: nameNode.text,
1600
+ type: "function",
1601
+ parentClass: parentName,
1602
+ visibility: "public",
1603
+ loc: {
1604
+ start: {
1605
+ line: node.startPosition.row + 1,
1606
+ column: node.startPosition.column
1607
+ },
1608
+ end: {
1609
+ line: node.endPosition.row + 1,
1610
+ column: node.endPosition.column
1611
+ }
1612
+ },
1613
+ parameters: this.extractParameters(node)
1614
+ });
1615
+ }
1616
+ }
1617
+ }
1618
+ }
1619
+ extractParameters(node) {
1620
+ const paramsNode = node.children.find(
1621
+ (c) => c.type === "formal_parameters"
1622
+ );
1623
+ if (!paramsNode) return [];
1624
+ return paramsNode.children.filter((c) => c.type === "formal_parameter").map((c) => {
1625
+ const idNode = c.children.find((child) => child.type === "identifier");
1626
+ return idNode ? idNode.text : "unknown";
1627
+ });
1628
+ }
1629
+ getNamingConventions() {
1630
+ return {
1631
+ variablePattern: /^[a-z][a-zA-Z0-9]*$/,
1632
+ functionPattern: /^[a-z][a-zA-Z0-9]*$/,
1633
+ classPattern: /^[A-Z][a-zA-Z0-9]*$/,
1634
+ constantPattern: /^[A-Z][A-Z0-9_]*$/,
1635
+ exceptions: ["main", "serialVersionUID"]
1636
+ };
1637
+ }
1638
+ canHandle(filePath) {
1639
+ return filePath.toLowerCase().endsWith(".java");
1640
+ }
1641
+ };
1642
+
1643
+ // src/parsers/csharp-parser.ts
1644
+ var Parser5 = __toESM(require("web-tree-sitter"));
1645
+ var path3 = __toESM(require("path"));
1646
+ var fs3 = __toESM(require("fs"));
1647
+ var CSharpParser = class {
1648
+ constructor() {
1649
+ this.language = "csharp" /* CSharp */;
1650
+ this.extensions = [".cs"];
1651
+ this.parser = null;
1652
+ this.initialized = false;
1653
+ }
1654
+ /**
1655
+ * Initialize the tree-sitter parser
1656
+ */
1657
+ async initialize() {
1658
+ if (this.initialized) return;
1659
+ try {
1660
+ if (typeof Parser5.Parser.init === "function") {
1661
+ await Parser5.Parser.init();
1662
+ }
1663
+ this.parser = new Parser5.Parser();
1664
+ const possiblePaths = [
1665
+ path3.join(
1666
+ process.cwd(),
1667
+ "node_modules/@unit-mesh/treesitter-artifacts/wasm/tree-sitter-c_sharp.wasm"
1668
+ ),
1669
+ path3.join(
1670
+ __dirname,
1671
+ "../../node_modules/@unit-mesh/treesitter-artifacts/wasm/tree-sitter-c_sharp.wasm"
1672
+ ),
1673
+ path3.join(
1674
+ __dirname,
1675
+ "../../../node_modules/@unit-mesh/treesitter-artifacts/wasm/tree-sitter-c_sharp.wasm"
1676
+ ),
1677
+ path3.join(
1678
+ __dirname,
1679
+ "../../../../node_modules/@unit-mesh/treesitter-artifacts/wasm/tree-sitter-c_sharp.wasm"
1680
+ )
1681
+ ];
1682
+ let wasmPath = "";
1683
+ for (const p of possiblePaths) {
1684
+ if (fs3.existsSync(p)) {
1685
+ wasmPath = p;
1686
+ break;
1687
+ }
1688
+ }
1689
+ if (!wasmPath) {
1690
+ console.warn(
1691
+ `C# WASM not found. Tried paths: ${possiblePaths.join(", ")}`
1692
+ );
1693
+ return;
1694
+ }
1695
+ const CSharp = await Parser5.Language.load(wasmPath);
1696
+ this.parser.setLanguage(CSharp);
1697
+ this.initialized = true;
1698
+ } catch (error) {
1699
+ console.error("Failed to initialize tree-sitter-c-sharp:", error);
1700
+ }
1701
+ }
1702
+ parse(code, filePath) {
1703
+ if (!this.initialized || !this.parser) {
1704
+ throw new ParseError(
1705
+ `CSharpParser not initialized for ${filePath}`,
1706
+ filePath
1707
+ );
1708
+ }
1709
+ try {
1710
+ const tree = this.parser.parse(code);
1711
+ if (!tree) throw new Error("Parser.parse(code) returned null");
1712
+ const rootNode = tree.rootNode;
1713
+ const imports = this.extractImportsAST(rootNode);
1714
+ const exports2 = this.extractExportsAST(rootNode);
1715
+ return {
1716
+ exports: exports2,
1717
+ imports,
1718
+ language: "csharp" /* CSharp */,
1719
+ warnings: []
1720
+ };
1721
+ } catch (error) {
1722
+ throw new ParseError(
1723
+ `AST parsing failed for ${filePath}: ${error.message}`,
1724
+ filePath
1725
+ );
1726
+ }
1727
+ }
1728
+ extractImportsAST(rootNode) {
1729
+ const imports = [];
1730
+ const findUsings = (node) => {
1731
+ if (node.type === "using_directive") {
1732
+ const nameNode = node.childForFieldName("name") || node.children.find(
1733
+ (c) => c.type === "qualified_name" || c.type === "identifier"
1734
+ );
1735
+ if (nameNode) {
1736
+ const aliasNode = node.childForFieldName("alias");
1737
+ imports.push({
1738
+ source: nameNode.text,
1739
+ specifiers: aliasNode ? [aliasNode.text] : [nameNode.text.split(".").pop() || nameNode.text],
1740
+ loc: {
1741
+ start: {
1742
+ line: node.startPosition.row + 1,
1743
+ column: node.startPosition.column
1744
+ },
1745
+ end: {
1746
+ line: node.endPosition.row + 1,
1747
+ column: node.endPosition.column
1748
+ }
1749
+ }
1750
+ });
1751
+ }
1752
+ }
1753
+ for (let i = 0; i < node.childCount; i++) {
1754
+ const child = node.child(i);
1755
+ if (child) findUsings(child);
1756
+ }
1757
+ };
1758
+ findUsings(rootNode);
1759
+ return imports;
1760
+ }
1761
+ extractExportsAST(rootNode) {
1762
+ const exports2 = [];
1763
+ const traverse = (node, currentNamespace, currentClass) => {
1764
+ let nextNamespace = currentNamespace;
1765
+ let nextClass = currentClass;
1766
+ if (node.type === "namespace_declaration" || node.type === "file_scoped_namespace_declaration") {
1767
+ const nameNode = node.childForFieldName("name") || node.children.find(
1768
+ (c) => c.type === "identifier" || c.type === "qualified_name"
1769
+ );
1770
+ if (nameNode) {
1771
+ nextNamespace = currentNamespace ? `${currentNamespace}.${nameNode.text}` : nameNode.text;
1772
+ }
1773
+ } else if (node.type === "class_declaration" || node.type === "interface_declaration" || node.type === "enum_declaration" || node.type === "struct_declaration" || node.type === "record_declaration") {
1774
+ const nameNode = node.childForFieldName("name") || node.children.find((c) => c.type === "identifier");
1775
+ if (nameNode) {
1776
+ const modifiers = this.getModifiers(node);
1777
+ const isPublic = modifiers.includes("public") || modifiers.includes("protected");
1778
+ if (isPublic) {
1779
+ const type = node.type.replace("_declaration", "");
1780
+ const fullName = nextClass ? `${nextClass}.${nameNode.text}` : nextNamespace ? `${nextNamespace}.${nameNode.text}` : nameNode.text;
1781
+ exports2.push({
1782
+ name: fullName,
1783
+ type: type === "record" ? "class" : type,
1784
+ loc: {
1785
+ start: {
1786
+ line: node.startPosition.row + 1,
1787
+ column: node.startPosition.column
1788
+ },
1789
+ end: {
1790
+ line: node.endPosition.row + 1,
1791
+ column: node.endPosition.column
1792
+ }
1793
+ },
1794
+ visibility: modifiers.includes("public") ? "public" : "protected"
1795
+ });
1796
+ nextClass = fullName;
1797
+ }
1798
+ }
1799
+ } else if (node.type === "method_declaration" || node.type === "property_declaration") {
1800
+ const nameNode = node.childForFieldName("name") || node.children.find((c) => c.type === "identifier");
1801
+ if (nameNode) {
1802
+ const modifiers = this.getModifiers(node);
1803
+ const isPublic = modifiers.includes("public") || modifiers.includes("protected");
1804
+ if (isPublic) {
1805
+ exports2.push({
1806
+ name: nameNode.text,
1807
+ type: node.type === "method_declaration" ? "function" : "property",
1808
+ parentClass: currentClass,
1809
+ loc: {
1810
+ start: {
1811
+ line: node.startPosition.row + 1,
1812
+ column: node.startPosition.column
1813
+ },
1814
+ end: {
1815
+ line: node.endPosition.row + 1,
1816
+ column: node.endPosition.column
1817
+ }
1818
+ },
1819
+ visibility: modifiers.includes("public") ? "public" : "protected",
1820
+ parameters: node.type === "method_declaration" ? this.extractParameters(node) : void 0
1821
+ });
1822
+ }
1823
+ }
1824
+ }
1825
+ for (let i = 0; i < node.childCount; i++) {
1826
+ const child = node.child(i);
1827
+ if (child) traverse(child, nextNamespace, nextClass);
1828
+ }
1829
+ };
1830
+ traverse(rootNode);
1831
+ return exports2;
1832
+ }
1833
+ getModifiers(node) {
1834
+ const modifiers = [];
1835
+ for (const child of node.children) {
1836
+ if (child.type === "modifier") {
1837
+ modifiers.push(child.text);
1838
+ }
1839
+ }
1840
+ return modifiers;
1841
+ }
1842
+ extractParameters(node) {
1843
+ const params = [];
1844
+ const parameterList = node.childForFieldName("parameters") || node.children.find((c) => c.type === "parameter_list");
1845
+ if (parameterList) {
1846
+ for (const param of parameterList.children) {
1847
+ if (param.type === "parameter") {
1848
+ const nameNode = param.childForFieldName("name") || param.children.find((c) => c.type === "identifier");
1849
+ if (nameNode) {
1850
+ params.push(nameNode.text);
1851
+ }
1852
+ }
1853
+ }
1854
+ }
1855
+ return params;
1856
+ }
1857
+ getNamingConventions() {
1858
+ return {
1859
+ variablePattern: /^[a-z][a-zA-Z0-9]*$/,
1860
+ functionPattern: /^[A-Z][a-zA-Z0-9]*$/,
1861
+ classPattern: /^[A-Z][a-zA-Z0-9]*$/,
1862
+ constantPattern: /^[A-Z][a-zA-Z0-9_]*$/
1863
+ };
1864
+ }
1865
+ canHandle(filePath) {
1866
+ return filePath.toLowerCase().endsWith(".cs");
1867
+ }
1868
+ };
1869
+
1870
+ // src/parsers/go-parser.ts
1871
+ var Parser7 = __toESM(require("web-tree-sitter"));
1872
+ var path4 = __toESM(require("path"));
1873
+ var fs4 = __toESM(require("fs"));
1874
+ var GoParser = class {
1875
+ constructor() {
1876
+ this.language = "go" /* Go */;
1877
+ this.extensions = [".go"];
1878
+ this.parser = null;
1879
+ this.initialized = false;
1880
+ }
1881
+ /**
1882
+ * Initialize the tree-sitter parser
1883
+ */
1884
+ async initialize() {
1885
+ if (this.initialized) return;
1886
+ try {
1887
+ if (typeof Parser7.Parser.init === "function") {
1888
+ await Parser7.Parser.init();
1889
+ }
1890
+ this.parser = new Parser7.Parser();
1891
+ const possiblePaths = [
1892
+ path4.join(
1893
+ process.cwd(),
1894
+ "node_modules/@unit-mesh/treesitter-artifacts/wasm/tree-sitter-go.wasm"
1895
+ ),
1896
+ path4.join(
1897
+ __dirname,
1898
+ "../../node_modules/@unit-mesh/treesitter-artifacts/wasm/tree-sitter-go.wasm"
1899
+ ),
1900
+ path4.join(
1901
+ __dirname,
1902
+ "../../../node_modules/@unit-mesh/treesitter-artifacts/wasm/tree-sitter-go.wasm"
1903
+ ),
1904
+ path4.join(
1905
+ __dirname,
1906
+ "../../../../node_modules/@unit-mesh/treesitter-artifacts/wasm/tree-sitter-go.wasm"
1907
+ )
1908
+ ];
1909
+ let wasmPath = "";
1910
+ for (const p of possiblePaths) {
1911
+ if (fs4.existsSync(p)) {
1912
+ wasmPath = p;
1913
+ break;
1914
+ }
1915
+ }
1916
+ if (!wasmPath) {
1917
+ console.warn(
1918
+ `Go WASM not found. Tried paths: ${possiblePaths.join(", ")}`
1919
+ );
1920
+ return;
1921
+ }
1922
+ const Go = await Parser7.Language.load(wasmPath);
1923
+ this.parser.setLanguage(Go);
1924
+ this.initialized = true;
1925
+ } catch (error) {
1926
+ console.error("Failed to initialize tree-sitter-go:", error);
1927
+ }
1928
+ }
1929
+ parse(code, filePath) {
1930
+ if (!this.initialized || !this.parser) {
1931
+ throw new ParseError(
1932
+ `GoParser not initialized for ${filePath}`,
1933
+ filePath
1934
+ );
1935
+ }
1936
+ try {
1937
+ const tree = this.parser.parse(code);
1938
+ if (!tree) throw new Error("Parser.parse(code) returned null");
1939
+ const rootNode = tree.rootNode;
1940
+ const imports = this.extractImportsAST(rootNode);
1941
+ const exports2 = this.extractExportsAST(rootNode);
1942
+ return {
1943
+ exports: exports2,
1944
+ imports,
1945
+ language: "go" /* Go */,
1946
+ warnings: []
1947
+ };
1948
+ } catch (error) {
1949
+ throw new ParseError(
1950
+ `AST parsing failed for ${filePath}: ${error.message}`,
1951
+ filePath
1952
+ );
1953
+ }
1954
+ }
1955
+ extractImportsAST(rootNode) {
1956
+ const imports = [];
1957
+ const findImports = (node) => {
1958
+ if (node.type === "import_spec") {
1959
+ const pathNode = node.children.find(
1960
+ (c) => c.type === "interpreted_string_literal"
1961
+ );
1962
+ if (pathNode) {
1963
+ const source = pathNode.text.replace(/"/g, "");
1964
+ imports.push({
1965
+ source,
1966
+ specifiers: [source.split("/").pop() || source],
1967
+ loc: {
1968
+ start: {
1969
+ line: node.startPosition.row + 1,
1970
+ column: node.startPosition.column
1971
+ },
1972
+ end: {
1973
+ line: node.endPosition.row + 1,
1974
+ column: node.endPosition.column
1975
+ }
1976
+ }
1977
+ });
1978
+ }
1979
+ }
1980
+ for (let i = 0; i < node.childCount; i++) {
1981
+ const child = node.child(i);
1982
+ if (child) findImports(child);
1983
+ }
1984
+ };
1985
+ findImports(rootNode);
1986
+ return imports;
1987
+ }
1988
+ extractExportsAST(rootNode) {
1989
+ const exports2 = [];
1990
+ const isExported = (name) => {
1991
+ return /^[A-Z]/.test(name);
1992
+ };
1993
+ const traverse = (node) => {
1994
+ if (node.type === "function_declaration" || node.type === "method_declaration") {
1995
+ const nameNode = node.childForFieldName("name") || node.children.find((c) => c.type === "identifier");
1996
+ if (nameNode && isExported(nameNode.text)) {
1997
+ exports2.push({
1998
+ name: nameNode.text,
1999
+ type: "function",
2000
+ loc: {
2001
+ start: {
2002
+ line: node.startPosition.row + 1,
2003
+ column: node.startPosition.column
2004
+ },
2005
+ end: {
2006
+ line: node.endPosition.row + 1,
2007
+ column: node.endPosition.column
2008
+ }
2009
+ },
2010
+ visibility: "public",
2011
+ parameters: this.extractParameters(node)
2012
+ });
2013
+ }
2014
+ } else if (node.type === "type_spec") {
2015
+ const nameNode = node.childForFieldName("name") || node.children.find((c) => c.type === "type_identifier");
2016
+ if (nameNode && isExported(nameNode.text)) {
2017
+ const type = node.children.some((c) => c.type === "struct_type") ? "class" : "interface";
2018
+ exports2.push({
2019
+ name: nameNode.text,
2020
+ type,
2021
+ loc: {
2022
+ start: {
2023
+ line: node.startPosition.row + 1,
2024
+ column: node.startPosition.column
2025
+ },
2026
+ end: {
2027
+ line: node.endPosition.row + 1,
2028
+ column: node.endPosition.column
2029
+ }
2030
+ },
2031
+ visibility: "public"
2032
+ });
2033
+ }
2034
+ } else if (node.type === "var_spec" || node.type === "const_spec") {
2035
+ const identifiers = node.children.filter(
2036
+ (c) => c.type === "identifier"
2037
+ );
2038
+ for (const idNode of identifiers) {
2039
+ if (isExported(idNode.text)) {
2040
+ exports2.push({
2041
+ name: idNode.text,
2042
+ type: "variable",
2043
+ loc: {
2044
+ start: {
2045
+ line: idNode.startPosition.row + 1,
2046
+ column: idNode.startPosition.column
2047
+ },
2048
+ end: {
2049
+ line: idNode.endPosition.row + 1,
2050
+ column: idNode.endPosition.column
2051
+ }
2052
+ },
2053
+ visibility: "public"
2054
+ });
2055
+ }
2056
+ }
2057
+ }
2058
+ for (let i = 0; i < node.childCount; i++) {
2059
+ const child = node.child(i);
2060
+ if (child) traverse(child);
2061
+ }
2062
+ };
2063
+ traverse(rootNode);
2064
+ return exports2;
2065
+ }
2066
+ extractParameters(node) {
2067
+ const params = [];
2068
+ const parameterList = node.childForFieldName("parameters") || node.children.find((c) => c.type === "parameter_list");
2069
+ if (parameterList) {
2070
+ for (const param of parameterList.children) {
2071
+ if (param.type === "parameter_declaration") {
2072
+ const names = param.children.filter((c) => c.type === "identifier");
2073
+ names.forEach((n) => params.push(n.text));
2074
+ }
2075
+ }
2076
+ }
2077
+ return params;
2078
+ }
2079
+ getNamingConventions() {
2080
+ return {
2081
+ variablePattern: /^[a-zA-Z][a-zA-Z0-9]*$/,
2082
+ functionPattern: /^[a-zA-Z][a-zA-Z0-9]*$/,
2083
+ classPattern: /^[a-zA-Z][a-zA-Z0-9]*$/,
2084
+ constantPattern: /^[a-zA-Z_][a-zA-Z0-9_]*$/
2085
+ };
2086
+ }
2087
+ canHandle(filePath) {
2088
+ return filePath.toLowerCase().endsWith(".go");
2089
+ }
2090
+ };
2091
+
1423
2092
  // src/parsers/parser-factory.ts
1424
2093
  var ParserFactory = class _ParserFactory {
1425
2094
  constructor() {
@@ -1429,6 +2098,9 @@ var ParserFactory = class _ParserFactory {
1429
2098
  );
1430
2099
  this.registerParser(new TypeScriptParser());
1431
2100
  this.registerParser(new PythonParser());
2101
+ this.registerParser(new JavaParser());
2102
+ this.registerParser(new CSharpParser());
2103
+ this.registerParser(new GoParser());
1432
2104
  }
1433
2105
  /**
1434
2106
  * Get singleton instance
@@ -1531,7 +2203,7 @@ function getSupportedLanguages() {
1531
2203
  // src/utils/ast-parser.ts
1532
2204
  function parseFileExports(code, filePath) {
1533
2205
  const parser = getParser(filePath);
1534
- if (parser && parser.language === "python" /* Python */) {
2206
+ if (parser && (parser.language === "python" /* Python */ || parser.language === "java" /* Java */)) {
1535
2207
  try {
1536
2208
  const result = parser.parse(code, filePath);
1537
2209
  return {
@@ -3563,15 +4235,18 @@ function getRepoMetadata(directory) {
3563
4235
  AnalysisStatusSchema,
3564
4236
  COMMON_FINE_TUNING_OPTIONS,
3565
4237
  CONTEXT_TIER_THRESHOLDS,
4238
+ CSharpParser,
3566
4239
  DEFAULT_COST_CONFIG,
3567
4240
  DEFAULT_EXCLUDE,
3568
4241
  DEFAULT_TOOL_WEIGHTS,
3569
4242
  FRIENDLY_TOOL_NAMES,
3570
4243
  GLOBAL_INFRA_OPTIONS,
3571
4244
  GLOBAL_SCAN_OPTIONS,
4245
+ GoParser,
3572
4246
  IssueSchema,
3573
4247
  IssueType,
3574
4248
  IssueTypeSchema,
4249
+ JavaParser,
3575
4250
  LANGUAGE_EXTENSIONS,
3576
4251
  Language,
3577
4252
  LocationSchema,