@aiready/core 0.23.5 → 0.23.7
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/{client-D-cn9ydj.d.mts → client-BrIMPk89.d.mts} +94 -16
- package/dist/{client-D-cn9ydj.d.ts → client-BrIMPk89.d.ts} +94 -16
- package/dist/client-C5BuGX4F.d.mts +1205 -0
- package/dist/client-C5BuGX4F.d.ts +1205 -0
- package/dist/{client-BF9NjhE8.d.mts → client-CKcjnPXt.d.mts} +1 -0
- package/dist/{client-BF9NjhE8.d.ts → client-CKcjnPXt.d.ts} +1 -0
- package/dist/client.d.mts +1 -1
- package/dist/client.d.ts +1 -1
- package/dist/index.d.mts +464 -134
- package/dist/index.d.ts +464 -134
- package/dist/index.js +211 -47
- package/dist/index.mjs +211 -44
- package/package.json +1 -1
- package/dist/__tests__/parser-factory.test.d.ts +0 -5
- package/dist/__tests__/parser-factory.test.d.ts.map +0 -1
- package/dist/__tests__/parser-factory.test.js +0 -70
- package/dist/__tests__/parser-factory.test.js.map +0 -1
- package/dist/__tests__/python-parser.test.d.ts +0 -5
- package/dist/__tests__/python-parser.test.d.ts.map +0 -1
- package/dist/__tests__/python-parser.test.js +0 -194
- package/dist/__tests__/python-parser.test.js.map +0 -1
- package/dist/__tests__/scoring.test.d.ts +0 -2
- package/dist/__tests__/scoring.test.d.ts.map +0 -1
- package/dist/__tests__/scoring.test.js +0 -197
- package/dist/__tests__/scoring.test.js.map +0 -1
- package/dist/chunk-3YI4IS3D.mjs +0 -601
- package/dist/chunk-5HIXDC3X.mjs +0 -716
- package/dist/chunk-5V3L53AE.mjs +0 -805
- package/dist/chunk-CKVKHN3G.mjs +0 -660
- package/dist/chunk-COHIBX3Q.mjs +0 -635
- package/dist/chunk-CWRCDSKZ.mjs +0 -417
- package/dist/chunk-D3D3NCRR.mjs +0 -556
- package/dist/chunk-HCFYP7UD.mjs +0 -805
- package/dist/chunk-HFLFBA6F.mjs +0 -417
- package/dist/chunk-HKSARRCD.mjs +0 -365
- package/dist/chunk-JJ5JL5FX.mjs +0 -417
- package/dist/chunk-KDSTXVLQ.mjs +0 -724
- package/dist/chunk-KI7XORTN.mjs +0 -417
- package/dist/chunk-LTMHFNFK.mjs +0 -690
- package/dist/chunk-LTNXTXRI.mjs +0 -659
- package/dist/chunk-M22BXHBR.mjs +0 -805
- package/dist/chunk-MH3A3LX6.mjs +0 -615
- package/dist/chunk-NGHT7JOG.mjs +0 -697
- package/dist/chunk-OQ6IGDXG.mjs +0 -553
- package/dist/chunk-QAFB3HXQ.mjs +0 -590
- package/dist/chunk-QQBKXHLU.mjs +0 -678
- package/dist/chunk-RDHYGES7.mjs +0 -678
- package/dist/chunk-SWTDBVYJ.mjs +0 -660
- package/dist/chunk-UIWL5JQB.mjs +0 -417
- package/dist/chunk-UQGI67WR.mjs +0 -417
- package/dist/chunk-UTZOO4XO.mjs +0 -553
- package/dist/chunk-X4F46I5L.mjs +0 -635
- package/dist/chunk-XKK7YHPX.mjs +0 -619
- package/dist/chunk-YCA4FTEK.mjs +0 -600
- package/dist/chunk-ZSZRRTJM.mjs +0 -719
- package/dist/client-BgmiMoil.d.mts +0 -1344
- package/dist/client-BgmiMoil.d.ts +0 -1344
- package/dist/client-BxGrPuuN.d.mts +0 -1191
- package/dist/client-BxGrPuuN.d.ts +0 -1191
- package/dist/client-D9seCH4K.d.mts +0 -1334
- package/dist/client-D9seCH4K.d.ts +0 -1334
- package/dist/client-DIXIh7rw.d.mts +0 -1193
- package/dist/client-DIXIh7rw.d.ts +0 -1193
- package/dist/client-DVHXWOHw.d.mts +0 -1245
- package/dist/client-DVHXWOHw.d.ts +0 -1245
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/parsers/parser-factory.d.ts +0 -69
- package/dist/parsers/parser-factory.d.ts.map +0 -1
- package/dist/parsers/parser-factory.js +0 -116
- package/dist/parsers/parser-factory.js.map +0 -1
- package/dist/parsers/python-parser.d.ts +0 -47
- package/dist/parsers/python-parser.d.ts.map +0 -1
- package/dist/parsers/python-parser.js +0 -243
- package/dist/parsers/python-parser.js.map +0 -1
- package/dist/parsers/typescript-parser.d.ts +0 -22
- package/dist/parsers/typescript-parser.d.ts.map +0 -1
- package/dist/parsers/typescript-parser.js +0 -242
- package/dist/parsers/typescript-parser.js.map +0 -1
- package/dist/scoring.d.ts +0 -120
- package/dist/scoring.d.ts.map +0 -1
- package/dist/scoring.js +0 -197
- package/dist/scoring.js.map +0 -1
- package/dist/types/language.d.ts +0 -172
- package/dist/types/language.d.ts.map +0 -1
- package/dist/types/language.js +0 -45
- package/dist/types/language.js.map +0 -1
- package/dist/types.d.ts +0 -122
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -2
- package/dist/types.js.map +0 -1
- package/dist/utils/ast-parser.d.ts +0 -59
- package/dist/utils/ast-parser.d.ts.map +0 -1
- package/dist/utils/ast-parser.js +0 -213
- package/dist/utils/ast-parser.js.map +0 -1
- package/dist/utils/cli-helpers.d.ts +0 -54
- package/dist/utils/cli-helpers.d.ts.map +0 -1
- package/dist/utils/cli-helpers.js +0 -78
- package/dist/utils/cli-helpers.js.map +0 -1
- package/dist/utils/config.d.ts +0 -9
- package/dist/utils/config.d.ts.map +0 -1
- package/dist/utils/config.js +0 -80
- package/dist/utils/config.js.map +0 -1
- package/dist/utils/file-scanner.d.ts +0 -16
- package/dist/utils/file-scanner.d.ts.map +0 -1
- package/dist/utils/file-scanner.js +0 -104
- package/dist/utils/file-scanner.js.map +0 -1
- package/dist/utils/metrics.d.ts +0 -6
- package/dist/utils/metrics.d.ts.map +0 -1
- package/dist/utils/metrics.js +0 -8
- package/dist/utils/metrics.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -111,8 +111,6 @@ __export(index_exports, {
|
|
|
111
111
|
estimateCostFromBudget: () => estimateCostFromBudget,
|
|
112
112
|
estimateTokens: () => estimateTokens,
|
|
113
113
|
exportHistory: () => exportHistory,
|
|
114
|
-
extractFunctions: () => extractFunctions,
|
|
115
|
-
extractImports: () => extractImports,
|
|
116
114
|
findLatestReport: () => findLatestReport,
|
|
117
115
|
findLatestScanReport: () => findLatestScanReport,
|
|
118
116
|
formatAcceptanceRate: () => formatAcceptanceRate,
|
|
@@ -158,7 +156,6 @@ __export(index_exports, {
|
|
|
158
156
|
loadScoreHistory: () => loadScoreHistory,
|
|
159
157
|
mergeConfigWithDefaults: () => mergeConfigWithDefaults,
|
|
160
158
|
normalizeToolName: () => normalizeToolName,
|
|
161
|
-
parseCode: () => parseCode,
|
|
162
159
|
parseFileExports: () => parseFileExports,
|
|
163
160
|
parseWeightString: () => parseWeightString,
|
|
164
161
|
predictAcceptanceRate: () => predictAcceptanceRate,
|
|
@@ -857,7 +854,7 @@ function resolveOutputPath(userPath, defaultFilename, workingDir = process.cwd()
|
|
|
857
854
|
if ((0, import_fs2.statSync)(workingDir).isFile()) {
|
|
858
855
|
baseDir = (0, import_path2.dirname)(workingDir);
|
|
859
856
|
}
|
|
860
|
-
} catch
|
|
857
|
+
} catch {
|
|
861
858
|
}
|
|
862
859
|
const aireadyDir = (0, import_path2.join)(baseDir, ".aiready");
|
|
863
860
|
outputPath = (0, import_path2.join)(aireadyDir, defaultFilename);
|
|
@@ -1029,8 +1026,8 @@ function findLatestScanReport(scanReportsDir, reportFilePrefix) {
|
|
|
1029
1026
|
return idB - idA;
|
|
1030
1027
|
});
|
|
1031
1028
|
return (0, import_path2.join)(scanReportsDir, reportFiles[0]);
|
|
1032
|
-
} catch
|
|
1033
|
-
console.error("Error while finding latest scan report
|
|
1029
|
+
} catch {
|
|
1030
|
+
console.error("Error while finding latest scan report");
|
|
1034
1031
|
return null;
|
|
1035
1032
|
}
|
|
1036
1033
|
}
|
|
@@ -1095,7 +1092,19 @@ function createProvider(config) {
|
|
|
1095
1092
|
};
|
|
1096
1093
|
}
|
|
1097
1094
|
|
|
1098
|
-
// src/utils/
|
|
1095
|
+
// src/utils/similarity-utils.ts
|
|
1096
|
+
function calculateImportSimilarity(export1, export2) {
|
|
1097
|
+
if (export1.imports.length === 0 && export2.imports.length === 0) {
|
|
1098
|
+
return 1;
|
|
1099
|
+
}
|
|
1100
|
+
const set1 = new Set(export1.imports);
|
|
1101
|
+
const set2 = new Set(export2.imports);
|
|
1102
|
+
const intersection = new Set([...set1].filter((x) => set2.has(x)));
|
|
1103
|
+
const union = /* @__PURE__ */ new Set([...set1, ...set2]);
|
|
1104
|
+
return intersection.size / union.size;
|
|
1105
|
+
}
|
|
1106
|
+
|
|
1107
|
+
// src/utils/dependency-analyzer.ts
|
|
1099
1108
|
var import_typescript_estree2 = require("@typescript-eslint/typescript-estree");
|
|
1100
1109
|
|
|
1101
1110
|
// src/parsers/typescript-parser.ts
|
|
@@ -1125,7 +1134,7 @@ var TypeScriptParser = class {
|
|
|
1125
1134
|
hasSideEffects: false
|
|
1126
1135
|
};
|
|
1127
1136
|
const start = node.range?.[0] ?? 0;
|
|
1128
|
-
const preceding = code.slice(Math.max(0, start -
|
|
1137
|
+
const preceding = code.slice(Math.max(0, start - 1e3), start);
|
|
1129
1138
|
const jsdocMatches = Array.from(
|
|
1130
1139
|
preceding.matchAll(/\/\*\*([\s\S]*?)\*\//g)
|
|
1131
1140
|
);
|
|
@@ -1134,9 +1143,24 @@ var TypeScriptParser = class {
|
|
|
1134
1143
|
const matchEndIndex = (lastMatch.index || 0) + lastMatch[0].length;
|
|
1135
1144
|
const between = preceding.slice(matchEndIndex);
|
|
1136
1145
|
if (/^\s*$/.test(between)) {
|
|
1146
|
+
const precedingStartOffset = Math.max(0, start - 1e3);
|
|
1147
|
+
const absoluteStartOffset = precedingStartOffset + (lastMatch.index || 0);
|
|
1148
|
+
const absoluteEndOffset = precedingStartOffset + matchEndIndex;
|
|
1149
|
+
const codeBeforeStart = code.slice(0, absoluteStartOffset);
|
|
1150
|
+
const startLines = codeBeforeStart.split("\n");
|
|
1151
|
+
const startLine = startLines.length;
|
|
1152
|
+
const startColumn = startLines[startLines.length - 1].length;
|
|
1153
|
+
const codeBeforeEnd = code.slice(0, absoluteEndOffset);
|
|
1154
|
+
const endLines = codeBeforeEnd.split("\n");
|
|
1155
|
+
const endLine = endLines.length;
|
|
1156
|
+
const endColumn = endLines[endLines.length - 1].length;
|
|
1137
1157
|
metadata.documentation = {
|
|
1138
1158
|
content: lastMatch[1].replace(/^\s*\*+/gm, "").trim(),
|
|
1139
|
-
type: "jsdoc"
|
|
1159
|
+
type: "jsdoc",
|
|
1160
|
+
loc: {
|
|
1161
|
+
start: { line: startLine, column: startColumn },
|
|
1162
|
+
end: { line: endLine, column: endColumn }
|
|
1163
|
+
}
|
|
1140
1164
|
};
|
|
1141
1165
|
}
|
|
1142
1166
|
}
|
|
@@ -1445,37 +1469,60 @@ function analyzeNodeMetadata(node, code, options) {
|
|
|
1445
1469
|
let prev = node.previousSibling || null;
|
|
1446
1470
|
while (prev && /comment/i.test(prev.type)) {
|
|
1447
1471
|
const text = prev.text || "";
|
|
1472
|
+
const loc = {
|
|
1473
|
+
start: {
|
|
1474
|
+
line: prev.startPosition.row + 1,
|
|
1475
|
+
column: prev.startPosition.column
|
|
1476
|
+
},
|
|
1477
|
+
end: {
|
|
1478
|
+
line: prev.endPosition.row + 1,
|
|
1479
|
+
column: prev.endPosition.column
|
|
1480
|
+
}
|
|
1481
|
+
};
|
|
1448
1482
|
if (text.trim().startsWith("/**") || text.trim().startsWith("/*")) {
|
|
1449
1483
|
metadata.documentation = {
|
|
1450
1484
|
content: text.replace(/^[/*]+|[/*]+$/g, "").trim(),
|
|
1451
|
-
type: "comment"
|
|
1485
|
+
type: "comment",
|
|
1486
|
+
loc
|
|
1452
1487
|
};
|
|
1453
1488
|
break;
|
|
1454
1489
|
}
|
|
1455
1490
|
if (text.trim().startsWith("///")) {
|
|
1456
1491
|
metadata.documentation = {
|
|
1457
1492
|
content: text.replace(/^\/\/\//, "").trim(),
|
|
1458
|
-
type: "xml-doc"
|
|
1493
|
+
type: "xml-doc",
|
|
1494
|
+
loc
|
|
1459
1495
|
};
|
|
1460
1496
|
break;
|
|
1461
1497
|
}
|
|
1462
1498
|
if (text.trim().startsWith("//")) {
|
|
1463
1499
|
metadata.documentation = {
|
|
1464
1500
|
content: text.replace(/^\/\//, "").trim(),
|
|
1465
|
-
type: "comment"
|
|
1501
|
+
type: "comment",
|
|
1502
|
+
loc
|
|
1466
1503
|
};
|
|
1467
1504
|
break;
|
|
1468
1505
|
}
|
|
1469
1506
|
prev = prev.previousSibling;
|
|
1470
1507
|
}
|
|
1471
|
-
if (node.type === "function_definition") {
|
|
1508
|
+
if (node.type === "function_definition" || node.type === "class_definition") {
|
|
1472
1509
|
const body2 = node.childForFieldName ? node.childForFieldName("body") : node.children.find((c) => c.type === "block");
|
|
1473
1510
|
if (body2 && body2.children.length > 0) {
|
|
1474
1511
|
const firstStmt = body2.children[0];
|
|
1475
1512
|
if (firstStmt.type === "expression_statement" && firstStmt.firstChild?.type === "string") {
|
|
1476
1513
|
metadata.documentation = {
|
|
1477
1514
|
content: firstStmt.firstChild.text.replace(/['"`]/g, "").trim(),
|
|
1478
|
-
type: "docstring"
|
|
1515
|
+
type: "docstring",
|
|
1516
|
+
loc: {
|
|
1517
|
+
start: {
|
|
1518
|
+
line: firstStmt.startPosition.row + 1,
|
|
1519
|
+
column: firstStmt.startPosition.column
|
|
1520
|
+
},
|
|
1521
|
+
end: {
|
|
1522
|
+
line: firstStmt.endPosition.row + 1,
|
|
1523
|
+
column: firstStmt.endPosition.column
|
|
1524
|
+
}
|
|
1525
|
+
}
|
|
1479
1526
|
};
|
|
1480
1527
|
}
|
|
1481
1528
|
}
|
|
@@ -1682,11 +1729,24 @@ var PythonParser = class extends BaseLanguageParser {
|
|
|
1682
1729
|
getParserName() {
|
|
1683
1730
|
return "python";
|
|
1684
1731
|
}
|
|
1732
|
+
/**
|
|
1733
|
+
* Analyze metadata for a Python node (purity, side effects).
|
|
1734
|
+
*
|
|
1735
|
+
* @param node - Tree-sitter node to analyze.
|
|
1736
|
+
* @param code - Source code for context.
|
|
1737
|
+
* @returns Partial ExportInfo containing discovered metadata.
|
|
1738
|
+
*/
|
|
1685
1739
|
analyzeMetadata(node, code) {
|
|
1686
1740
|
return analyzeNodeMetadata(node, code, {
|
|
1687
1741
|
sideEffectSignatures: ["print(", "input(", "open("]
|
|
1688
1742
|
});
|
|
1689
1743
|
}
|
|
1744
|
+
/**
|
|
1745
|
+
* Extract import information using AST walk.
|
|
1746
|
+
*
|
|
1747
|
+
* @param rootNode - Root node of the Python AST.
|
|
1748
|
+
* @returns Array of discovered ImportInfo objects.
|
|
1749
|
+
*/
|
|
1690
1750
|
extractImportsAST(rootNode) {
|
|
1691
1751
|
const imports = [];
|
|
1692
1752
|
const processImportNode = (node) => {
|
|
@@ -1768,6 +1828,13 @@ var PythonParser = class extends BaseLanguageParser {
|
|
|
1768
1828
|
}
|
|
1769
1829
|
return imports;
|
|
1770
1830
|
}
|
|
1831
|
+
/**
|
|
1832
|
+
* Extract export information using AST walk.
|
|
1833
|
+
*
|
|
1834
|
+
* @param rootNode - Root node of the Python AST.
|
|
1835
|
+
* @param code - Source code for documentation extraction.
|
|
1836
|
+
* @returns Array of discovered ExportInfo objects.
|
|
1837
|
+
*/
|
|
1771
1838
|
extractExportsAST(rootNode, code) {
|
|
1772
1839
|
const exports2 = [];
|
|
1773
1840
|
for (const node of rootNode.children) {
|
|
@@ -1846,6 +1913,12 @@ var PythonParser = class extends BaseLanguageParser {
|
|
|
1846
1913
|
}
|
|
1847
1914
|
return exports2;
|
|
1848
1915
|
}
|
|
1916
|
+
/**
|
|
1917
|
+
* Extract parameter names from a function definition node.
|
|
1918
|
+
*
|
|
1919
|
+
* @param node - Function definition node.
|
|
1920
|
+
* @returns Array of parameter name strings.
|
|
1921
|
+
*/
|
|
1849
1922
|
extractParameters(node) {
|
|
1850
1923
|
const paramsNode = node.childForFieldName("parameters");
|
|
1851
1924
|
if (!paramsNode) return [];
|
|
@@ -1859,6 +1932,13 @@ var PythonParser = class extends BaseLanguageParser {
|
|
|
1859
1932
|
return "unknown";
|
|
1860
1933
|
});
|
|
1861
1934
|
}
|
|
1935
|
+
/**
|
|
1936
|
+
* Fallback regex-based parsing when tree-sitter is unavailable.
|
|
1937
|
+
*
|
|
1938
|
+
* @param code - Source code content.
|
|
1939
|
+
* @param filePath - Path to the file being parsed.
|
|
1940
|
+
* @returns Consolidated ParseResult.
|
|
1941
|
+
*/
|
|
1862
1942
|
parseRegex(code, filePath) {
|
|
1863
1943
|
try {
|
|
1864
1944
|
const imports = this.extractImportsRegex(code, filePath);
|
|
@@ -2132,6 +2212,13 @@ var JavaParser = class extends BaseLanguageParser {
|
|
|
2132
2212
|
getParserName() {
|
|
2133
2213
|
return "java";
|
|
2134
2214
|
}
|
|
2215
|
+
/**
|
|
2216
|
+
* Analyze metadata for a Java node (purity, side effects).
|
|
2217
|
+
*
|
|
2218
|
+
* @param node - Tree-sitter node to analyze.
|
|
2219
|
+
* @param code - Source code for context.
|
|
2220
|
+
* @returns Partial ExportInfo containing discovered metadata.
|
|
2221
|
+
*/
|
|
2135
2222
|
analyzeMetadata(node, code) {
|
|
2136
2223
|
return analyzeGeneralMetadata(node, code, {
|
|
2137
2224
|
sideEffectSignatures: [
|
|
@@ -2211,6 +2298,12 @@ var JavaParser = class extends BaseLanguageParser {
|
|
|
2211
2298
|
warnings: ["Parser falling back to regex-based analysis"]
|
|
2212
2299
|
};
|
|
2213
2300
|
}
|
|
2301
|
+
/**
|
|
2302
|
+
* Extract import information using AST walk.
|
|
2303
|
+
*
|
|
2304
|
+
* @param rootNode - Root node of the Java AST.
|
|
2305
|
+
* @returns Array of discovered ImportInfo objects.
|
|
2306
|
+
*/
|
|
2214
2307
|
extractImportsAST(rootNode) {
|
|
2215
2308
|
const imports = [];
|
|
2216
2309
|
for (const node of rootNode.children) {
|
|
@@ -2244,6 +2337,13 @@ var JavaParser = class extends BaseLanguageParser {
|
|
|
2244
2337
|
}
|
|
2245
2338
|
return imports;
|
|
2246
2339
|
}
|
|
2340
|
+
/**
|
|
2341
|
+
* Extract export information (classes, interfaces, methods) using AST walk.
|
|
2342
|
+
*
|
|
2343
|
+
* @param rootNode - Root node of the Java AST.
|
|
2344
|
+
* @param code - Source code for documentation extraction.
|
|
2345
|
+
* @returns Array of discovered ExportInfo objects.
|
|
2346
|
+
*/
|
|
2247
2347
|
extractExportsAST(rootNode, code) {
|
|
2248
2348
|
const exports2 = [];
|
|
2249
2349
|
for (const node of rootNode.children) {
|
|
@@ -2274,11 +2374,25 @@ var JavaParser = class extends BaseLanguageParser {
|
|
|
2274
2374
|
}
|
|
2275
2375
|
return exports2;
|
|
2276
2376
|
}
|
|
2377
|
+
/**
|
|
2378
|
+
* Extract modifiers (visibility, static, etc.) from a node.
|
|
2379
|
+
*
|
|
2380
|
+
* @param node - AST node to extract modifiers from.
|
|
2381
|
+
* @returns Array of modifier strings.
|
|
2382
|
+
*/
|
|
2277
2383
|
getModifiers(node) {
|
|
2278
2384
|
const modifiersNode = node.children.find((c) => c.type === "modifiers");
|
|
2279
2385
|
if (!modifiersNode) return [];
|
|
2280
2386
|
return modifiersNode.children.map((c) => c.text);
|
|
2281
2387
|
}
|
|
2388
|
+
/**
|
|
2389
|
+
* Extract methods and nested exports from a class or interface body.
|
|
2390
|
+
*
|
|
2391
|
+
* @param parentNode - Class or interface declaration node.
|
|
2392
|
+
* @param parentName - Name of the parent class/interface.
|
|
2393
|
+
* @param exports - Array to collect discovered exports into.
|
|
2394
|
+
* @param code - Source code for context.
|
|
2395
|
+
*/
|
|
2282
2396
|
extractSubExports(parentNode, parentName, exports2, code) {
|
|
2283
2397
|
const bodyNode = parentNode.children.find((c) => c.type === "class_body");
|
|
2284
2398
|
if (!bodyNode) return;
|
|
@@ -2337,11 +2451,24 @@ var CSharpParser = class extends BaseLanguageParser {
|
|
|
2337
2451
|
getParserName() {
|
|
2338
2452
|
return "c_sharp";
|
|
2339
2453
|
}
|
|
2454
|
+
/**
|
|
2455
|
+
* Analyze metadata for a C# node (purity, side effects).
|
|
2456
|
+
*
|
|
2457
|
+
* @param node - Tree-sitter node to analyze.
|
|
2458
|
+
* @param code - Source code for context.
|
|
2459
|
+
* @returns Partial ExportInfo containing discovered metadata.
|
|
2460
|
+
*/
|
|
2340
2461
|
analyzeMetadata(node, code) {
|
|
2341
2462
|
return analyzeGeneralMetadata(node, code, {
|
|
2342
2463
|
sideEffectSignatures: ["Console.Write", "File.Write", "Logging."]
|
|
2343
2464
|
});
|
|
2344
2465
|
}
|
|
2466
|
+
/**
|
|
2467
|
+
* Fallback regex-based parsing when tree-sitter is unavailable.
|
|
2468
|
+
*
|
|
2469
|
+
* @param code - Source code content.
|
|
2470
|
+
* @returns Consolidated ParseResult.
|
|
2471
|
+
*/
|
|
2345
2472
|
parseRegex(code) {
|
|
2346
2473
|
const lines = code.split("\n");
|
|
2347
2474
|
const exports2 = [];
|
|
@@ -2403,6 +2530,12 @@ var CSharpParser = class extends BaseLanguageParser {
|
|
|
2403
2530
|
warnings: ["Parser falling back to regex-based analysis"]
|
|
2404
2531
|
};
|
|
2405
2532
|
}
|
|
2533
|
+
/**
|
|
2534
|
+
* Extract import information (usings) using AST walk.
|
|
2535
|
+
*
|
|
2536
|
+
* @param rootNode - Root node of the C# AST.
|
|
2537
|
+
* @returns Array of discovered ImportInfo objects.
|
|
2538
|
+
*/
|
|
2406
2539
|
extractImportsAST(rootNode) {
|
|
2407
2540
|
const imports = [];
|
|
2408
2541
|
const findUsings = (node) => {
|
|
@@ -2436,6 +2569,14 @@ var CSharpParser = class extends BaseLanguageParser {
|
|
|
2436
2569
|
findUsings(rootNode);
|
|
2437
2570
|
return imports;
|
|
2438
2571
|
}
|
|
2572
|
+
/**
|
|
2573
|
+
* Extract export information (classes, methods, properties) using AST walk.
|
|
2574
|
+
* Handles nested namespaces and classes.
|
|
2575
|
+
*
|
|
2576
|
+
* @param rootNode - Root node of the C# AST.
|
|
2577
|
+
* @param code - Source code for documentation extraction.
|
|
2578
|
+
* @returns Array of discovered ExportInfo objects.
|
|
2579
|
+
*/
|
|
2439
2580
|
extractExportsAST(rootNode, code) {
|
|
2440
2581
|
const exports2 = [];
|
|
2441
2582
|
const traverse = (node, currentNamespace, currentClass) => {
|
|
@@ -2547,11 +2688,24 @@ var GoParser = class extends BaseLanguageParser {
|
|
|
2547
2688
|
getParserName() {
|
|
2548
2689
|
return "go";
|
|
2549
2690
|
}
|
|
2691
|
+
/**
|
|
2692
|
+
* Analyze metadata for a Go node (purity, side effects).
|
|
2693
|
+
*
|
|
2694
|
+
* @param node - Tree-sitter node to analyze.
|
|
2695
|
+
* @param code - Source code for context.
|
|
2696
|
+
* @returns Partial ExportInfo containing discovered metadata.
|
|
2697
|
+
*/
|
|
2550
2698
|
analyzeMetadata(node, code) {
|
|
2551
2699
|
return analyzeGeneralMetadata(node, code, {
|
|
2552
2700
|
sideEffectSignatures: ["<-", "fmt.Print", "fmt.Fprintf", "os.Exit"]
|
|
2553
2701
|
});
|
|
2554
2702
|
}
|
|
2703
|
+
/**
|
|
2704
|
+
* Fallback regex-based parsing when tree-sitter is unavailable.
|
|
2705
|
+
*
|
|
2706
|
+
* @param code - Source code content.
|
|
2707
|
+
* @returns Consolidated ParseResult.
|
|
2708
|
+
*/
|
|
2555
2709
|
parseRegex(code) {
|
|
2556
2710
|
const lines = code.split("\n");
|
|
2557
2711
|
const exports2 = [];
|
|
@@ -2629,6 +2783,12 @@ var GoParser = class extends BaseLanguageParser {
|
|
|
2629
2783
|
warnings: ["Parser falling back to regex-based analysis"]
|
|
2630
2784
|
};
|
|
2631
2785
|
}
|
|
2786
|
+
/**
|
|
2787
|
+
* Extract import information using AST walk.
|
|
2788
|
+
*
|
|
2789
|
+
* @param rootNode - Root node of the Go AST.
|
|
2790
|
+
* @returns Array of discovered ImportInfo objects.
|
|
2791
|
+
*/
|
|
2632
2792
|
extractImportsAST(rootNode) {
|
|
2633
2793
|
const imports = [];
|
|
2634
2794
|
const findImports = (node) => {
|
|
@@ -2662,6 +2822,13 @@ var GoParser = class extends BaseLanguageParser {
|
|
|
2662
2822
|
findImports(rootNode);
|
|
2663
2823
|
return imports;
|
|
2664
2824
|
}
|
|
2825
|
+
/**
|
|
2826
|
+
* Extract export information (functions, types, vars) using AST walk.
|
|
2827
|
+
*
|
|
2828
|
+
* @param rootNode - Root node of the Go AST.
|
|
2829
|
+
* @param code - Source code for documentation extraction.
|
|
2830
|
+
* @returns Array of discovered ExportInfo objects.
|
|
2831
|
+
*/
|
|
2665
2832
|
extractExportsAST(rootNode, code) {
|
|
2666
2833
|
const exports2 = [];
|
|
2667
2834
|
const isExported = (name) => {
|
|
@@ -3018,7 +3185,7 @@ function extractTypeReferences(node) {
|
|
|
3018
3185
|
return Array.from(types);
|
|
3019
3186
|
}
|
|
3020
3187
|
|
|
3021
|
-
// src/utils/
|
|
3188
|
+
// src/utils/dependency-analyzer.ts
|
|
3022
3189
|
function parseFileExports(code, filePath) {
|
|
3023
3190
|
const parser = getParser(filePath);
|
|
3024
3191
|
if (parser && parser.language !== "typescript" /* TypeScript */ && parser.language !== "javascript" /* JavaScript */) {
|
|
@@ -3060,29 +3227,6 @@ function parseFileExports(code, filePath) {
|
|
|
3060
3227
|
return { exports: [], imports: [] };
|
|
3061
3228
|
}
|
|
3062
3229
|
}
|
|
3063
|
-
function calculateImportSimilarity(export1, export2) {
|
|
3064
|
-
if (export1.imports.length === 0 && export2.imports.length === 0) {
|
|
3065
|
-
return 1;
|
|
3066
|
-
}
|
|
3067
|
-
const set1 = new Set(export1.imports);
|
|
3068
|
-
const set2 = new Set(export2.imports);
|
|
3069
|
-
const intersection = new Set([...set1].filter((x) => set2.has(x)));
|
|
3070
|
-
const union = /* @__PURE__ */ new Set([...set1, ...set2]);
|
|
3071
|
-
return intersection.size / union.size;
|
|
3072
|
-
}
|
|
3073
|
-
function parseCode(_code, _language) {
|
|
3074
|
-
void _code;
|
|
3075
|
-
void _language;
|
|
3076
|
-
return null;
|
|
3077
|
-
}
|
|
3078
|
-
function extractFunctions(_ast) {
|
|
3079
|
-
void _ast;
|
|
3080
|
-
return [];
|
|
3081
|
-
}
|
|
3082
|
-
function extractImports(_ast) {
|
|
3083
|
-
void _ast;
|
|
3084
|
-
return [];
|
|
3085
|
-
}
|
|
3086
3230
|
|
|
3087
3231
|
// src/utils/metrics.ts
|
|
3088
3232
|
function estimateTokens(text) {
|
|
@@ -4619,14 +4763,32 @@ function calculateDocDrift(params) {
|
|
|
4619
4763
|
uncommentedExports,
|
|
4620
4764
|
totalExports,
|
|
4621
4765
|
outdatedComments,
|
|
4622
|
-
undocumentedComplexity
|
|
4766
|
+
undocumentedComplexity,
|
|
4767
|
+
actualDrift
|
|
4623
4768
|
} = params;
|
|
4624
4769
|
const uncommentedRatio = totalExports > 0 ? uncommentedExports / totalExports : 0;
|
|
4625
|
-
const
|
|
4626
|
-
const
|
|
4627
|
-
const
|
|
4770
|
+
const outdatedRatio = totalExports > 0 ? outdatedComments / totalExports : 0;
|
|
4771
|
+
const complexityRatio = totalExports > 0 ? undocumentedComplexity / totalExports : 0;
|
|
4772
|
+
const driftRatio = totalExports > 0 ? actualDrift / totalExports : 0;
|
|
4773
|
+
const DRIFT_THRESHOLD = 0.2;
|
|
4774
|
+
const OUTDATED_THRESHOLD = 0.4;
|
|
4775
|
+
const COMPLEXITY_THRESHOLD = 0.2;
|
|
4776
|
+
const UNCOMMENTED_THRESHOLD = 0.8;
|
|
4777
|
+
const driftRisk = Math.min(100, driftRatio / DRIFT_THRESHOLD * 100);
|
|
4778
|
+
const outdatedRisk = Math.min(
|
|
4779
|
+
100,
|
|
4780
|
+
outdatedRatio / OUTDATED_THRESHOLD * 100
|
|
4781
|
+
);
|
|
4782
|
+
const complexityRisk = Math.min(
|
|
4783
|
+
100,
|
|
4784
|
+
complexityRatio / COMPLEXITY_THRESHOLD * 100
|
|
4785
|
+
);
|
|
4786
|
+
const uncommentedRisk = Math.min(
|
|
4787
|
+
100,
|
|
4788
|
+
uncommentedRatio / UNCOMMENTED_THRESHOLD * 100
|
|
4789
|
+
);
|
|
4628
4790
|
const risk = Math.round(
|
|
4629
|
-
|
|
4791
|
+
driftRisk * 0.4 + complexityRisk * 0.3 + outdatedRisk * 0.2 + uncommentedRisk * 0.1
|
|
4630
4792
|
);
|
|
4631
4793
|
const finalRisk = Math.min(100, Math.max(0, risk));
|
|
4632
4794
|
const score = totalExports > 0 ? 100 - finalRisk : 100;
|
|
@@ -4638,6 +4800,10 @@ function calculateDocDrift(params) {
|
|
|
4638
4800
|
else if (score >= 40) rating = "high";
|
|
4639
4801
|
else rating = "severe";
|
|
4640
4802
|
const recommendations = [];
|
|
4803
|
+
if (actualDrift > 0)
|
|
4804
|
+
recommendations.push(
|
|
4805
|
+
`Review ${actualDrift} functions where code was changed after documentation was last updated.`
|
|
4806
|
+
);
|
|
4641
4807
|
if (outdatedComments > 0)
|
|
4642
4808
|
recommendations.push(
|
|
4643
4809
|
`Update or remove ${outdatedComments} outdated comments that contradict the code.`
|
|
@@ -4656,7 +4822,8 @@ function calculateDocDrift(params) {
|
|
|
4656
4822
|
dimensions: {
|
|
4657
4823
|
uncommentedExports,
|
|
4658
4824
|
outdatedComments,
|
|
4659
|
-
undocumentedComplexity
|
|
4825
|
+
undocumentedComplexity,
|
|
4826
|
+
actualDrift
|
|
4660
4827
|
},
|
|
4661
4828
|
recommendations
|
|
4662
4829
|
};
|
|
@@ -5152,8 +5319,6 @@ function emitIssuesAsAnnotations(issues) {
|
|
|
5152
5319
|
estimateCostFromBudget,
|
|
5153
5320
|
estimateTokens,
|
|
5154
5321
|
exportHistory,
|
|
5155
|
-
extractFunctions,
|
|
5156
|
-
extractImports,
|
|
5157
5322
|
findLatestReport,
|
|
5158
5323
|
findLatestScanReport,
|
|
5159
5324
|
formatAcceptanceRate,
|
|
@@ -5199,7 +5364,6 @@ function emitIssuesAsAnnotations(issues) {
|
|
|
5199
5364
|
loadScoreHistory,
|
|
5200
5365
|
mergeConfigWithDefaults,
|
|
5201
5366
|
normalizeToolName,
|
|
5202
|
-
parseCode,
|
|
5203
5367
|
parseFileExports,
|
|
5204
5368
|
parseWeightString,
|
|
5205
5369
|
predictAcceptanceRate,
|