@aiready/core 0.23.6 → 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-BrIMPk89.d.mts +1214 -0
- package/dist/client-BrIMPk89.d.ts +1214 -0
- package/dist/client-C5BuGX4F.d.mts +1205 -0
- package/dist/client-C5BuGX4F.d.ts +1205 -0
- package/dist/client.d.mts +1 -1
- package/dist/client.d.ts +1 -1
- package/dist/index.d.mts +458 -136
- package/dist/index.d.ts +458 -136
- package/dist/index.js +137 -34
- package/dist/index.mjs +137 -31
- package/package.json +1 -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
|
|
@@ -1720,11 +1729,24 @@ var PythonParser = class extends BaseLanguageParser {
|
|
|
1720
1729
|
getParserName() {
|
|
1721
1730
|
return "python";
|
|
1722
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
|
+
*/
|
|
1723
1739
|
analyzeMetadata(node, code) {
|
|
1724
1740
|
return analyzeNodeMetadata(node, code, {
|
|
1725
1741
|
sideEffectSignatures: ["print(", "input(", "open("]
|
|
1726
1742
|
});
|
|
1727
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
|
+
*/
|
|
1728
1750
|
extractImportsAST(rootNode) {
|
|
1729
1751
|
const imports = [];
|
|
1730
1752
|
const processImportNode = (node) => {
|
|
@@ -1806,6 +1828,13 @@ var PythonParser = class extends BaseLanguageParser {
|
|
|
1806
1828
|
}
|
|
1807
1829
|
return imports;
|
|
1808
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
|
+
*/
|
|
1809
1838
|
extractExportsAST(rootNode, code) {
|
|
1810
1839
|
const exports2 = [];
|
|
1811
1840
|
for (const node of rootNode.children) {
|
|
@@ -1884,6 +1913,12 @@ var PythonParser = class extends BaseLanguageParser {
|
|
|
1884
1913
|
}
|
|
1885
1914
|
return exports2;
|
|
1886
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
|
+
*/
|
|
1887
1922
|
extractParameters(node) {
|
|
1888
1923
|
const paramsNode = node.childForFieldName("parameters");
|
|
1889
1924
|
if (!paramsNode) return [];
|
|
@@ -1897,6 +1932,13 @@ var PythonParser = class extends BaseLanguageParser {
|
|
|
1897
1932
|
return "unknown";
|
|
1898
1933
|
});
|
|
1899
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
|
+
*/
|
|
1900
1942
|
parseRegex(code, filePath) {
|
|
1901
1943
|
try {
|
|
1902
1944
|
const imports = this.extractImportsRegex(code, filePath);
|
|
@@ -2170,6 +2212,13 @@ var JavaParser = class extends BaseLanguageParser {
|
|
|
2170
2212
|
getParserName() {
|
|
2171
2213
|
return "java";
|
|
2172
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
|
+
*/
|
|
2173
2222
|
analyzeMetadata(node, code) {
|
|
2174
2223
|
return analyzeGeneralMetadata(node, code, {
|
|
2175
2224
|
sideEffectSignatures: [
|
|
@@ -2249,6 +2298,12 @@ var JavaParser = class extends BaseLanguageParser {
|
|
|
2249
2298
|
warnings: ["Parser falling back to regex-based analysis"]
|
|
2250
2299
|
};
|
|
2251
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
|
+
*/
|
|
2252
2307
|
extractImportsAST(rootNode) {
|
|
2253
2308
|
const imports = [];
|
|
2254
2309
|
for (const node of rootNode.children) {
|
|
@@ -2282,6 +2337,13 @@ var JavaParser = class extends BaseLanguageParser {
|
|
|
2282
2337
|
}
|
|
2283
2338
|
return imports;
|
|
2284
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
|
+
*/
|
|
2285
2347
|
extractExportsAST(rootNode, code) {
|
|
2286
2348
|
const exports2 = [];
|
|
2287
2349
|
for (const node of rootNode.children) {
|
|
@@ -2312,11 +2374,25 @@ var JavaParser = class extends BaseLanguageParser {
|
|
|
2312
2374
|
}
|
|
2313
2375
|
return exports2;
|
|
2314
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
|
+
*/
|
|
2315
2383
|
getModifiers(node) {
|
|
2316
2384
|
const modifiersNode = node.children.find((c) => c.type === "modifiers");
|
|
2317
2385
|
if (!modifiersNode) return [];
|
|
2318
2386
|
return modifiersNode.children.map((c) => c.text);
|
|
2319
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
|
+
*/
|
|
2320
2396
|
extractSubExports(parentNode, parentName, exports2, code) {
|
|
2321
2397
|
const bodyNode = parentNode.children.find((c) => c.type === "class_body");
|
|
2322
2398
|
if (!bodyNode) return;
|
|
@@ -2375,11 +2451,24 @@ var CSharpParser = class extends BaseLanguageParser {
|
|
|
2375
2451
|
getParserName() {
|
|
2376
2452
|
return "c_sharp";
|
|
2377
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
|
+
*/
|
|
2378
2461
|
analyzeMetadata(node, code) {
|
|
2379
2462
|
return analyzeGeneralMetadata(node, code, {
|
|
2380
2463
|
sideEffectSignatures: ["Console.Write", "File.Write", "Logging."]
|
|
2381
2464
|
});
|
|
2382
2465
|
}
|
|
2466
|
+
/**
|
|
2467
|
+
* Fallback regex-based parsing when tree-sitter is unavailable.
|
|
2468
|
+
*
|
|
2469
|
+
* @param code - Source code content.
|
|
2470
|
+
* @returns Consolidated ParseResult.
|
|
2471
|
+
*/
|
|
2383
2472
|
parseRegex(code) {
|
|
2384
2473
|
const lines = code.split("\n");
|
|
2385
2474
|
const exports2 = [];
|
|
@@ -2441,6 +2530,12 @@ var CSharpParser = class extends BaseLanguageParser {
|
|
|
2441
2530
|
warnings: ["Parser falling back to regex-based analysis"]
|
|
2442
2531
|
};
|
|
2443
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
|
+
*/
|
|
2444
2539
|
extractImportsAST(rootNode) {
|
|
2445
2540
|
const imports = [];
|
|
2446
2541
|
const findUsings = (node) => {
|
|
@@ -2474,6 +2569,14 @@ var CSharpParser = class extends BaseLanguageParser {
|
|
|
2474
2569
|
findUsings(rootNode);
|
|
2475
2570
|
return imports;
|
|
2476
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
|
+
*/
|
|
2477
2580
|
extractExportsAST(rootNode, code) {
|
|
2478
2581
|
const exports2 = [];
|
|
2479
2582
|
const traverse = (node, currentNamespace, currentClass) => {
|
|
@@ -2585,11 +2688,24 @@ var GoParser = class extends BaseLanguageParser {
|
|
|
2585
2688
|
getParserName() {
|
|
2586
2689
|
return "go";
|
|
2587
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
|
+
*/
|
|
2588
2698
|
analyzeMetadata(node, code) {
|
|
2589
2699
|
return analyzeGeneralMetadata(node, code, {
|
|
2590
2700
|
sideEffectSignatures: ["<-", "fmt.Print", "fmt.Fprintf", "os.Exit"]
|
|
2591
2701
|
});
|
|
2592
2702
|
}
|
|
2703
|
+
/**
|
|
2704
|
+
* Fallback regex-based parsing when tree-sitter is unavailable.
|
|
2705
|
+
*
|
|
2706
|
+
* @param code - Source code content.
|
|
2707
|
+
* @returns Consolidated ParseResult.
|
|
2708
|
+
*/
|
|
2593
2709
|
parseRegex(code) {
|
|
2594
2710
|
const lines = code.split("\n");
|
|
2595
2711
|
const exports2 = [];
|
|
@@ -2667,6 +2783,12 @@ var GoParser = class extends BaseLanguageParser {
|
|
|
2667
2783
|
warnings: ["Parser falling back to regex-based analysis"]
|
|
2668
2784
|
};
|
|
2669
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
|
+
*/
|
|
2670
2792
|
extractImportsAST(rootNode) {
|
|
2671
2793
|
const imports = [];
|
|
2672
2794
|
const findImports = (node) => {
|
|
@@ -2700,6 +2822,13 @@ var GoParser = class extends BaseLanguageParser {
|
|
|
2700
2822
|
findImports(rootNode);
|
|
2701
2823
|
return imports;
|
|
2702
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
|
+
*/
|
|
2703
2832
|
extractExportsAST(rootNode, code) {
|
|
2704
2833
|
const exports2 = [];
|
|
2705
2834
|
const isExported = (name) => {
|
|
@@ -3056,7 +3185,7 @@ function extractTypeReferences(node) {
|
|
|
3056
3185
|
return Array.from(types);
|
|
3057
3186
|
}
|
|
3058
3187
|
|
|
3059
|
-
// src/utils/
|
|
3188
|
+
// src/utils/dependency-analyzer.ts
|
|
3060
3189
|
function parseFileExports(code, filePath) {
|
|
3061
3190
|
const parser = getParser(filePath);
|
|
3062
3191
|
if (parser && parser.language !== "typescript" /* TypeScript */ && parser.language !== "javascript" /* JavaScript */) {
|
|
@@ -3098,29 +3227,6 @@ function parseFileExports(code, filePath) {
|
|
|
3098
3227
|
return { exports: [], imports: [] };
|
|
3099
3228
|
}
|
|
3100
3229
|
}
|
|
3101
|
-
function calculateImportSimilarity(export1, export2) {
|
|
3102
|
-
if (export1.imports.length === 0 && export2.imports.length === 0) {
|
|
3103
|
-
return 1;
|
|
3104
|
-
}
|
|
3105
|
-
const set1 = new Set(export1.imports);
|
|
3106
|
-
const set2 = new Set(export2.imports);
|
|
3107
|
-
const intersection = new Set([...set1].filter((x) => set2.has(x)));
|
|
3108
|
-
const union = /* @__PURE__ */ new Set([...set1, ...set2]);
|
|
3109
|
-
return intersection.size / union.size;
|
|
3110
|
-
}
|
|
3111
|
-
function parseCode(_code, _language) {
|
|
3112
|
-
void _code;
|
|
3113
|
-
void _language;
|
|
3114
|
-
return null;
|
|
3115
|
-
}
|
|
3116
|
-
function extractFunctions(_ast) {
|
|
3117
|
-
void _ast;
|
|
3118
|
-
return [];
|
|
3119
|
-
}
|
|
3120
|
-
function extractImports(_ast) {
|
|
3121
|
-
void _ast;
|
|
3122
|
-
return [];
|
|
3123
|
-
}
|
|
3124
3230
|
|
|
3125
3231
|
// src/utils/metrics.ts
|
|
3126
3232
|
function estimateTokens(text) {
|
|
@@ -5213,8 +5319,6 @@ function emitIssuesAsAnnotations(issues) {
|
|
|
5213
5319
|
estimateCostFromBudget,
|
|
5214
5320
|
estimateTokens,
|
|
5215
5321
|
exportHistory,
|
|
5216
|
-
extractFunctions,
|
|
5217
|
-
extractImports,
|
|
5218
5322
|
findLatestReport,
|
|
5219
5323
|
findLatestScanReport,
|
|
5220
5324
|
formatAcceptanceRate,
|
|
@@ -5260,7 +5364,6 @@ function emitIssuesAsAnnotations(issues) {
|
|
|
5260
5364
|
loadScoreHistory,
|
|
5261
5365
|
mergeConfigWithDefaults,
|
|
5262
5366
|
normalizeToolName,
|
|
5263
|
-
parseCode,
|
|
5264
5367
|
parseFileExports,
|
|
5265
5368
|
parseWeightString,
|
|
5266
5369
|
predictAcceptanceRate,
|
package/dist/index.mjs
CHANGED
|
@@ -464,7 +464,7 @@ function resolveOutputPath(userPath, defaultFilename, workingDir = process.cwd()
|
|
|
464
464
|
if (statSync(workingDir).isFile()) {
|
|
465
465
|
baseDir = dirname2(workingDir);
|
|
466
466
|
}
|
|
467
|
-
} catch
|
|
467
|
+
} catch {
|
|
468
468
|
}
|
|
469
469
|
const aireadyDir = join2(baseDir, ".aiready");
|
|
470
470
|
outputPath = join2(aireadyDir, defaultFilename);
|
|
@@ -636,8 +636,8 @@ function findLatestScanReport(scanReportsDir, reportFilePrefix) {
|
|
|
636
636
|
return idB - idA;
|
|
637
637
|
});
|
|
638
638
|
return join2(scanReportsDir, reportFiles[0]);
|
|
639
|
-
} catch
|
|
640
|
-
console.error("Error while finding latest scan report
|
|
639
|
+
} catch {
|
|
640
|
+
console.error("Error while finding latest scan report");
|
|
641
641
|
return null;
|
|
642
642
|
}
|
|
643
643
|
}
|
|
@@ -702,7 +702,19 @@ function createProvider(config) {
|
|
|
702
702
|
};
|
|
703
703
|
}
|
|
704
704
|
|
|
705
|
-
// src/utils/
|
|
705
|
+
// src/utils/similarity-utils.ts
|
|
706
|
+
function calculateImportSimilarity(export1, export2) {
|
|
707
|
+
if (export1.imports.length === 0 && export2.imports.length === 0) {
|
|
708
|
+
return 1;
|
|
709
|
+
}
|
|
710
|
+
const set1 = new Set(export1.imports);
|
|
711
|
+
const set2 = new Set(export2.imports);
|
|
712
|
+
const intersection = new Set([...set1].filter((x) => set2.has(x)));
|
|
713
|
+
const union = /* @__PURE__ */ new Set([...set1, ...set2]);
|
|
714
|
+
return intersection.size / union.size;
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
// src/utils/dependency-analyzer.ts
|
|
706
718
|
import { parse as parse2 } from "@typescript-eslint/typescript-estree";
|
|
707
719
|
|
|
708
720
|
// src/parsers/typescript-parser.ts
|
|
@@ -1327,11 +1339,24 @@ var PythonParser = class extends BaseLanguageParser {
|
|
|
1327
1339
|
getParserName() {
|
|
1328
1340
|
return "python";
|
|
1329
1341
|
}
|
|
1342
|
+
/**
|
|
1343
|
+
* Analyze metadata for a Python node (purity, side effects).
|
|
1344
|
+
*
|
|
1345
|
+
* @param node - Tree-sitter node to analyze.
|
|
1346
|
+
* @param code - Source code for context.
|
|
1347
|
+
* @returns Partial ExportInfo containing discovered metadata.
|
|
1348
|
+
*/
|
|
1330
1349
|
analyzeMetadata(node, code) {
|
|
1331
1350
|
return analyzeNodeMetadata(node, code, {
|
|
1332
1351
|
sideEffectSignatures: ["print(", "input(", "open("]
|
|
1333
1352
|
});
|
|
1334
1353
|
}
|
|
1354
|
+
/**
|
|
1355
|
+
* Extract import information using AST walk.
|
|
1356
|
+
*
|
|
1357
|
+
* @param rootNode - Root node of the Python AST.
|
|
1358
|
+
* @returns Array of discovered ImportInfo objects.
|
|
1359
|
+
*/
|
|
1335
1360
|
extractImportsAST(rootNode) {
|
|
1336
1361
|
const imports = [];
|
|
1337
1362
|
const processImportNode = (node) => {
|
|
@@ -1413,6 +1438,13 @@ var PythonParser = class extends BaseLanguageParser {
|
|
|
1413
1438
|
}
|
|
1414
1439
|
return imports;
|
|
1415
1440
|
}
|
|
1441
|
+
/**
|
|
1442
|
+
* Extract export information using AST walk.
|
|
1443
|
+
*
|
|
1444
|
+
* @param rootNode - Root node of the Python AST.
|
|
1445
|
+
* @param code - Source code for documentation extraction.
|
|
1446
|
+
* @returns Array of discovered ExportInfo objects.
|
|
1447
|
+
*/
|
|
1416
1448
|
extractExportsAST(rootNode, code) {
|
|
1417
1449
|
const exports = [];
|
|
1418
1450
|
for (const node of rootNode.children) {
|
|
@@ -1491,6 +1523,12 @@ var PythonParser = class extends BaseLanguageParser {
|
|
|
1491
1523
|
}
|
|
1492
1524
|
return exports;
|
|
1493
1525
|
}
|
|
1526
|
+
/**
|
|
1527
|
+
* Extract parameter names from a function definition node.
|
|
1528
|
+
*
|
|
1529
|
+
* @param node - Function definition node.
|
|
1530
|
+
* @returns Array of parameter name strings.
|
|
1531
|
+
*/
|
|
1494
1532
|
extractParameters(node) {
|
|
1495
1533
|
const paramsNode = node.childForFieldName("parameters");
|
|
1496
1534
|
if (!paramsNode) return [];
|
|
@@ -1504,6 +1542,13 @@ var PythonParser = class extends BaseLanguageParser {
|
|
|
1504
1542
|
return "unknown";
|
|
1505
1543
|
});
|
|
1506
1544
|
}
|
|
1545
|
+
/**
|
|
1546
|
+
* Fallback regex-based parsing when tree-sitter is unavailable.
|
|
1547
|
+
*
|
|
1548
|
+
* @param code - Source code content.
|
|
1549
|
+
* @param filePath - Path to the file being parsed.
|
|
1550
|
+
* @returns Consolidated ParseResult.
|
|
1551
|
+
*/
|
|
1507
1552
|
parseRegex(code, filePath) {
|
|
1508
1553
|
try {
|
|
1509
1554
|
const imports = this.extractImportsRegex(code, filePath);
|
|
@@ -1777,6 +1822,13 @@ var JavaParser = class extends BaseLanguageParser {
|
|
|
1777
1822
|
getParserName() {
|
|
1778
1823
|
return "java";
|
|
1779
1824
|
}
|
|
1825
|
+
/**
|
|
1826
|
+
* Analyze metadata for a Java node (purity, side effects).
|
|
1827
|
+
*
|
|
1828
|
+
* @param node - Tree-sitter node to analyze.
|
|
1829
|
+
* @param code - Source code for context.
|
|
1830
|
+
* @returns Partial ExportInfo containing discovered metadata.
|
|
1831
|
+
*/
|
|
1780
1832
|
analyzeMetadata(node, code) {
|
|
1781
1833
|
return analyzeGeneralMetadata(node, code, {
|
|
1782
1834
|
sideEffectSignatures: [
|
|
@@ -1856,6 +1908,12 @@ var JavaParser = class extends BaseLanguageParser {
|
|
|
1856
1908
|
warnings: ["Parser falling back to regex-based analysis"]
|
|
1857
1909
|
};
|
|
1858
1910
|
}
|
|
1911
|
+
/**
|
|
1912
|
+
* Extract import information using AST walk.
|
|
1913
|
+
*
|
|
1914
|
+
* @param rootNode - Root node of the Java AST.
|
|
1915
|
+
* @returns Array of discovered ImportInfo objects.
|
|
1916
|
+
*/
|
|
1859
1917
|
extractImportsAST(rootNode) {
|
|
1860
1918
|
const imports = [];
|
|
1861
1919
|
for (const node of rootNode.children) {
|
|
@@ -1889,6 +1947,13 @@ var JavaParser = class extends BaseLanguageParser {
|
|
|
1889
1947
|
}
|
|
1890
1948
|
return imports;
|
|
1891
1949
|
}
|
|
1950
|
+
/**
|
|
1951
|
+
* Extract export information (classes, interfaces, methods) using AST walk.
|
|
1952
|
+
*
|
|
1953
|
+
* @param rootNode - Root node of the Java AST.
|
|
1954
|
+
* @param code - Source code for documentation extraction.
|
|
1955
|
+
* @returns Array of discovered ExportInfo objects.
|
|
1956
|
+
*/
|
|
1892
1957
|
extractExportsAST(rootNode, code) {
|
|
1893
1958
|
const exports = [];
|
|
1894
1959
|
for (const node of rootNode.children) {
|
|
@@ -1919,11 +1984,25 @@ var JavaParser = class extends BaseLanguageParser {
|
|
|
1919
1984
|
}
|
|
1920
1985
|
return exports;
|
|
1921
1986
|
}
|
|
1987
|
+
/**
|
|
1988
|
+
* Extract modifiers (visibility, static, etc.) from a node.
|
|
1989
|
+
*
|
|
1990
|
+
* @param node - AST node to extract modifiers from.
|
|
1991
|
+
* @returns Array of modifier strings.
|
|
1992
|
+
*/
|
|
1922
1993
|
getModifiers(node) {
|
|
1923
1994
|
const modifiersNode = node.children.find((c) => c.type === "modifiers");
|
|
1924
1995
|
if (!modifiersNode) return [];
|
|
1925
1996
|
return modifiersNode.children.map((c) => c.text);
|
|
1926
1997
|
}
|
|
1998
|
+
/**
|
|
1999
|
+
* Extract methods and nested exports from a class or interface body.
|
|
2000
|
+
*
|
|
2001
|
+
* @param parentNode - Class or interface declaration node.
|
|
2002
|
+
* @param parentName - Name of the parent class/interface.
|
|
2003
|
+
* @param exports - Array to collect discovered exports into.
|
|
2004
|
+
* @param code - Source code for context.
|
|
2005
|
+
*/
|
|
1927
2006
|
extractSubExports(parentNode, parentName, exports, code) {
|
|
1928
2007
|
const bodyNode = parentNode.children.find((c) => c.type === "class_body");
|
|
1929
2008
|
if (!bodyNode) return;
|
|
@@ -1982,11 +2061,24 @@ var CSharpParser = class extends BaseLanguageParser {
|
|
|
1982
2061
|
getParserName() {
|
|
1983
2062
|
return "c_sharp";
|
|
1984
2063
|
}
|
|
2064
|
+
/**
|
|
2065
|
+
* Analyze metadata for a C# node (purity, side effects).
|
|
2066
|
+
*
|
|
2067
|
+
* @param node - Tree-sitter node to analyze.
|
|
2068
|
+
* @param code - Source code for context.
|
|
2069
|
+
* @returns Partial ExportInfo containing discovered metadata.
|
|
2070
|
+
*/
|
|
1985
2071
|
analyzeMetadata(node, code) {
|
|
1986
2072
|
return analyzeGeneralMetadata(node, code, {
|
|
1987
2073
|
sideEffectSignatures: ["Console.Write", "File.Write", "Logging."]
|
|
1988
2074
|
});
|
|
1989
2075
|
}
|
|
2076
|
+
/**
|
|
2077
|
+
* Fallback regex-based parsing when tree-sitter is unavailable.
|
|
2078
|
+
*
|
|
2079
|
+
* @param code - Source code content.
|
|
2080
|
+
* @returns Consolidated ParseResult.
|
|
2081
|
+
*/
|
|
1990
2082
|
parseRegex(code) {
|
|
1991
2083
|
const lines = code.split("\n");
|
|
1992
2084
|
const exports = [];
|
|
@@ -2048,6 +2140,12 @@ var CSharpParser = class extends BaseLanguageParser {
|
|
|
2048
2140
|
warnings: ["Parser falling back to regex-based analysis"]
|
|
2049
2141
|
};
|
|
2050
2142
|
}
|
|
2143
|
+
/**
|
|
2144
|
+
* Extract import information (usings) using AST walk.
|
|
2145
|
+
*
|
|
2146
|
+
* @param rootNode - Root node of the C# AST.
|
|
2147
|
+
* @returns Array of discovered ImportInfo objects.
|
|
2148
|
+
*/
|
|
2051
2149
|
extractImportsAST(rootNode) {
|
|
2052
2150
|
const imports = [];
|
|
2053
2151
|
const findUsings = (node) => {
|
|
@@ -2081,6 +2179,14 @@ var CSharpParser = class extends BaseLanguageParser {
|
|
|
2081
2179
|
findUsings(rootNode);
|
|
2082
2180
|
return imports;
|
|
2083
2181
|
}
|
|
2182
|
+
/**
|
|
2183
|
+
* Extract export information (classes, methods, properties) using AST walk.
|
|
2184
|
+
* Handles nested namespaces and classes.
|
|
2185
|
+
*
|
|
2186
|
+
* @param rootNode - Root node of the C# AST.
|
|
2187
|
+
* @param code - Source code for documentation extraction.
|
|
2188
|
+
* @returns Array of discovered ExportInfo objects.
|
|
2189
|
+
*/
|
|
2084
2190
|
extractExportsAST(rootNode, code) {
|
|
2085
2191
|
const exports = [];
|
|
2086
2192
|
const traverse = (node, currentNamespace, currentClass) => {
|
|
@@ -2192,11 +2298,24 @@ var GoParser = class extends BaseLanguageParser {
|
|
|
2192
2298
|
getParserName() {
|
|
2193
2299
|
return "go";
|
|
2194
2300
|
}
|
|
2301
|
+
/**
|
|
2302
|
+
* Analyze metadata for a Go node (purity, side effects).
|
|
2303
|
+
*
|
|
2304
|
+
* @param node - Tree-sitter node to analyze.
|
|
2305
|
+
* @param code - Source code for context.
|
|
2306
|
+
* @returns Partial ExportInfo containing discovered metadata.
|
|
2307
|
+
*/
|
|
2195
2308
|
analyzeMetadata(node, code) {
|
|
2196
2309
|
return analyzeGeneralMetadata(node, code, {
|
|
2197
2310
|
sideEffectSignatures: ["<-", "fmt.Print", "fmt.Fprintf", "os.Exit"]
|
|
2198
2311
|
});
|
|
2199
2312
|
}
|
|
2313
|
+
/**
|
|
2314
|
+
* Fallback regex-based parsing when tree-sitter is unavailable.
|
|
2315
|
+
*
|
|
2316
|
+
* @param code - Source code content.
|
|
2317
|
+
* @returns Consolidated ParseResult.
|
|
2318
|
+
*/
|
|
2200
2319
|
parseRegex(code) {
|
|
2201
2320
|
const lines = code.split("\n");
|
|
2202
2321
|
const exports = [];
|
|
@@ -2274,6 +2393,12 @@ var GoParser = class extends BaseLanguageParser {
|
|
|
2274
2393
|
warnings: ["Parser falling back to regex-based analysis"]
|
|
2275
2394
|
};
|
|
2276
2395
|
}
|
|
2396
|
+
/**
|
|
2397
|
+
* Extract import information using AST walk.
|
|
2398
|
+
*
|
|
2399
|
+
* @param rootNode - Root node of the Go AST.
|
|
2400
|
+
* @returns Array of discovered ImportInfo objects.
|
|
2401
|
+
*/
|
|
2277
2402
|
extractImportsAST(rootNode) {
|
|
2278
2403
|
const imports = [];
|
|
2279
2404
|
const findImports = (node) => {
|
|
@@ -2307,6 +2432,13 @@ var GoParser = class extends BaseLanguageParser {
|
|
|
2307
2432
|
findImports(rootNode);
|
|
2308
2433
|
return imports;
|
|
2309
2434
|
}
|
|
2435
|
+
/**
|
|
2436
|
+
* Extract export information (functions, types, vars) using AST walk.
|
|
2437
|
+
*
|
|
2438
|
+
* @param rootNode - Root node of the Go AST.
|
|
2439
|
+
* @param code - Source code for documentation extraction.
|
|
2440
|
+
* @returns Array of discovered ExportInfo objects.
|
|
2441
|
+
*/
|
|
2310
2442
|
extractExportsAST(rootNode, code) {
|
|
2311
2443
|
const exports = [];
|
|
2312
2444
|
const isExported = (name) => {
|
|
@@ -2663,7 +2795,7 @@ function extractTypeReferences(node) {
|
|
|
2663
2795
|
return Array.from(types);
|
|
2664
2796
|
}
|
|
2665
2797
|
|
|
2666
|
-
// src/utils/
|
|
2798
|
+
// src/utils/dependency-analyzer.ts
|
|
2667
2799
|
function parseFileExports(code, filePath) {
|
|
2668
2800
|
const parser = getParser(filePath);
|
|
2669
2801
|
if (parser && parser.language !== "typescript" /* TypeScript */ && parser.language !== "javascript" /* JavaScript */) {
|
|
@@ -2705,29 +2837,6 @@ function parseFileExports(code, filePath) {
|
|
|
2705
2837
|
return { exports: [], imports: [] };
|
|
2706
2838
|
}
|
|
2707
2839
|
}
|
|
2708
|
-
function calculateImportSimilarity(export1, export2) {
|
|
2709
|
-
if (export1.imports.length === 0 && export2.imports.length === 0) {
|
|
2710
|
-
return 1;
|
|
2711
|
-
}
|
|
2712
|
-
const set1 = new Set(export1.imports);
|
|
2713
|
-
const set2 = new Set(export2.imports);
|
|
2714
|
-
const intersection = new Set([...set1].filter((x) => set2.has(x)));
|
|
2715
|
-
const union = /* @__PURE__ */ new Set([...set1, ...set2]);
|
|
2716
|
-
return intersection.size / union.size;
|
|
2717
|
-
}
|
|
2718
|
-
function parseCode(_code, _language) {
|
|
2719
|
-
void _code;
|
|
2720
|
-
void _language;
|
|
2721
|
-
return null;
|
|
2722
|
-
}
|
|
2723
|
-
function extractFunctions(_ast) {
|
|
2724
|
-
void _ast;
|
|
2725
|
-
return [];
|
|
2726
|
-
}
|
|
2727
|
-
function extractImports(_ast) {
|
|
2728
|
-
void _ast;
|
|
2729
|
-
return [];
|
|
2730
|
-
}
|
|
2731
2840
|
|
|
2732
2841
|
// src/utils/metrics.ts
|
|
2733
2842
|
function estimateTokens(text) {
|
|
@@ -4387,8 +4496,6 @@ export {
|
|
|
4387
4496
|
estimateCostFromBudget,
|
|
4388
4497
|
estimateTokens,
|
|
4389
4498
|
exportHistory,
|
|
4390
|
-
extractFunctions,
|
|
4391
|
-
extractImports,
|
|
4392
4499
|
findLatestReport,
|
|
4393
4500
|
findLatestScanReport,
|
|
4394
4501
|
formatAcceptanceRate,
|
|
@@ -4434,7 +4541,6 @@ export {
|
|
|
4434
4541
|
loadScoreHistory,
|
|
4435
4542
|
mergeConfigWithDefaults,
|
|
4436
4543
|
normalizeToolName,
|
|
4437
|
-
parseCode,
|
|
4438
4544
|
parseFileExports,
|
|
4439
4545
|
parseWeightString,
|
|
4440
4546
|
predictAcceptanceRate,
|