@aiready/core 0.23.2 → 0.23.3
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/__tests__/parser-factory.test.d.ts +1 -1
- package/dist/__tests__/parser-factory.test.js +62 -50
- package/dist/__tests__/python-parser.test.d.ts +1 -1
- package/dist/__tests__/python-parser.test.js +111 -109
- package/dist/__tests__/scoring.test.d.ts +1 -1
- package/dist/__tests__/scoring.test.js +193 -176
- package/dist/chunk-3YI4IS3D.mjs +191 -173
- package/dist/chunk-5HIXDC3X.mjs +273 -251
- package/dist/chunk-5V3L53AE.mjs +805 -0
- package/dist/chunk-CKVKHN3G.mjs +228 -211
- package/dist/chunk-COHIBX3Q.mjs +213 -195
- package/dist/chunk-CWRCDSKZ.mjs +91 -82
- package/dist/chunk-D3D3NCRR.mjs +147 -129
- package/dist/chunk-HCFYP7UD.mjs +805 -0
- package/dist/chunk-HFLFBA6F.mjs +79 -72
- package/dist/chunk-HKSARRCD.mjs +66 -58
- package/dist/chunk-JJ5JL5FX.mjs +91 -82
- package/dist/chunk-KDSTXVLQ.mjs +724 -0
- package/dist/chunk-KI7XORTN.mjs +91 -82
- package/dist/chunk-LTMHFNFK.mjs +690 -0
- package/dist/chunk-LTNXTXRI.mjs +228 -211
- package/dist/chunk-M22BXHBR.mjs +805 -0
- package/dist/chunk-MH3A3LX6.mjs +200 -182
- package/dist/chunk-NGHT7JOG.mjs +697 -0
- package/dist/chunk-OQ6IGDXG.mjs +147 -129
- package/dist/chunk-QAFB3HXQ.mjs +181 -165
- package/dist/chunk-QQBKXHLU.mjs +678 -0
- package/dist/chunk-RDHYGES7.mjs +678 -0
- package/dist/chunk-SWTDBVYJ.mjs +228 -213
- package/dist/chunk-UIWL5JQB.mjs +79 -72
- package/dist/chunk-UQGI67WR.mjs +79 -72
- package/dist/chunk-UTZOO4XO.mjs +147 -131
- package/dist/chunk-X4F46I5L.mjs +213 -195
- package/dist/chunk-XKK7YHPX.mjs +204 -186
- package/dist/chunk-YCA4FTEK.mjs +190 -172
- package/dist/chunk-ZSZRRTJM.mjs +719 -0
- package/dist/client-BgmiMoil.d.mts +1344 -0
- package/dist/client-BgmiMoil.d.ts +1344 -0
- package/dist/client-BxGrPuuN.d.mts +1191 -0
- package/dist/client-BxGrPuuN.d.ts +1191 -0
- package/dist/client-D-cn9ydj.d.mts +1136 -0
- package/dist/client-D-cn9ydj.d.ts +1136 -0
- package/dist/client-D9seCH4K.d.mts +1334 -0
- package/dist/client-D9seCH4K.d.ts +1334 -0
- package/dist/client-DIXIh7rw.d.mts +1193 -0
- package/dist/client-DIXIh7rw.d.ts +1193 -0
- package/dist/client-DVHXWOHw.d.mts +1245 -0
- package/dist/client-DVHXWOHw.d.ts +1245 -0
- package/dist/client.d.mts +2 -1098
- package/dist/client.d.ts +2 -1098
- package/dist/client.js +23 -43
- package/dist/client.mjs +3 -25
- package/dist/index.d.mts +325 -103
- package/dist/index.d.ts +325 -103
- package/dist/index.js +307 -324
- package/dist/index.mjs +283 -306
- package/dist/parsers/parser-factory.d.ts +45 -45
- package/dist/parsers/parser-factory.js +86 -84
- package/dist/parsers/python-parser.d.ts +33 -28
- package/dist/parsers/python-parser.js +224 -222
- package/dist/parsers/typescript-parser.d.ts +15 -10
- package/dist/parsers/typescript-parser.js +223 -197
- package/dist/scoring.d.ts +59 -49
- package/dist/scoring.js +129 -127
- package/dist/types/language.d.ts +104 -93
- package/dist/types/language.js +23 -23
- package/dist/types.d.ts +105 -87
- package/dist/types.js +1 -1
- package/dist/utils/ast-parser.d.ts +42 -33
- package/dist/utils/ast-parser.js +159 -162
- package/dist/utils/cli-helpers.d.ts +27 -10
- package/dist/utils/cli-helpers.js +45 -43
- package/dist/utils/config.d.ts +8 -3
- package/dist/utils/config.js +67 -69
- package/dist/utils/file-scanner.d.ts +1 -1
- package/dist/utils/file-scanner.js +80 -76
- package/dist/utils/metrics.d.ts +1 -1
- package/dist/utils/metrics.js +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -127,12 +127,17 @@ __export(index_exports, {
|
|
|
127
127
|
getProjectSizeTier: () => getProjectSizeTier,
|
|
128
128
|
getRating: () => getRating,
|
|
129
129
|
getRatingDisplay: () => getRatingDisplay,
|
|
130
|
+
getRatingSlug: () => getRatingSlug,
|
|
130
131
|
getRatingWithContext: () => getRatingWithContext,
|
|
131
132
|
getRecommendedThreshold: () => getRecommendedThreshold,
|
|
132
133
|
getRepoMetadata: () => getRepoMetadata,
|
|
133
134
|
getSafetyIcon: () => getSafetyIcon,
|
|
134
135
|
getScoreBar: () => getScoreBar,
|
|
136
|
+
getSeverityBadge: () => getSeverityBadge,
|
|
135
137
|
getSeverityColor: () => getSeverityColor,
|
|
138
|
+
getSeverityEnum: () => getSeverityEnum,
|
|
139
|
+
getSeverityLevel: () => getSeverityLevel,
|
|
140
|
+
getSeverityValue: () => getSeverityValue,
|
|
136
141
|
getSupportedLanguages: () => getSupportedLanguages,
|
|
137
142
|
getToolWeight: () => getToolWeight,
|
|
138
143
|
getWasmPath: () => getWasmPath,
|
|
@@ -328,33 +333,28 @@ var UnifiedReportSchema = import_zod.z.object({
|
|
|
328
333
|
// src/types.ts
|
|
329
334
|
var GLOBAL_INFRA_OPTIONS = [
|
|
330
335
|
"rootDir",
|
|
331
|
-
// Essential for every tool
|
|
332
336
|
"include",
|
|
333
337
|
"exclude",
|
|
334
|
-
"onProgress",
|
|
335
|
-
"progressCallback",
|
|
336
|
-
"includeTests",
|
|
337
|
-
"useSmartDefaults",
|
|
338
|
-
"streamResults",
|
|
339
|
-
"batchSize",
|
|
340
|
-
"costConfig",
|
|
341
338
|
"tools",
|
|
342
|
-
"
|
|
339
|
+
"scoring"
|
|
340
|
+
];
|
|
341
|
+
var GLOBAL_SCAN_OPTIONS = [
|
|
342
|
+
"rootDir",
|
|
343
|
+
"include",
|
|
344
|
+
"exclude",
|
|
345
|
+
"config",
|
|
346
|
+
"threshold",
|
|
347
|
+
"output",
|
|
348
|
+
"format",
|
|
349
|
+
"parallel",
|
|
350
|
+
"showBreakdown"
|
|
343
351
|
];
|
|
344
352
|
var COMMON_FINE_TUNING_OPTIONS = [
|
|
345
353
|
"maxDepth",
|
|
346
354
|
"minSimilarity",
|
|
347
|
-
"
|
|
348
|
-
"
|
|
349
|
-
// AI Signal Clarity options
|
|
350
|
-
"checkMagicLiterals",
|
|
351
|
-
"checkBooleanTraps",
|
|
352
|
-
"checkAmbiguousNames",
|
|
353
|
-
"checkUndocumentedExports",
|
|
354
|
-
"checkImplicitSideEffects",
|
|
355
|
-
"checkDeepCallbacks"
|
|
355
|
+
"threshold",
|
|
356
|
+
"showBreakdown"
|
|
356
357
|
];
|
|
357
|
-
var GLOBAL_SCAN_OPTIONS = [...GLOBAL_INFRA_OPTIONS];
|
|
358
358
|
|
|
359
359
|
// src/types/language.ts
|
|
360
360
|
var Language = /* @__PURE__ */ ((Language3) => {
|
|
@@ -783,6 +783,7 @@ function isSourceFile(filePath) {
|
|
|
783
783
|
// src/utils/cli-helpers.ts
|
|
784
784
|
var import_fs2 = require("fs");
|
|
785
785
|
var import_path2 = require("path");
|
|
786
|
+
var import_chalk = __toESM(require("chalk"));
|
|
786
787
|
function resolveOutputPath(userPath, defaultFilename, workingDir = process.cwd()) {
|
|
787
788
|
let outputPath;
|
|
788
789
|
if (userPath) {
|
|
@@ -850,22 +851,72 @@ function emitProgress(processed, total, toolId, message, onProgress, throttleCou
|
|
|
850
851
|
onProgress(processed, total, `${message} (${processed}/${total})`);
|
|
851
852
|
}
|
|
852
853
|
}
|
|
853
|
-
function getSeverityColor(severity,
|
|
854
|
+
function getSeverityColor(severity, chalkInstance = import_chalk.default) {
|
|
854
855
|
switch (severity.toLowerCase()) {
|
|
855
856
|
case "critical":
|
|
856
857
|
case "high-risk":
|
|
857
858
|
case "blind-risk":
|
|
858
|
-
return
|
|
859
|
+
return chalkInstance.red;
|
|
859
860
|
case "major":
|
|
860
861
|
case "moderate-risk":
|
|
861
|
-
return
|
|
862
|
+
return chalkInstance.yellow;
|
|
862
863
|
case "minor":
|
|
863
864
|
case "safe":
|
|
864
|
-
return
|
|
865
|
+
return chalkInstance.green;
|
|
866
|
+
case "info":
|
|
867
|
+
return chalkInstance.blue;
|
|
868
|
+
default:
|
|
869
|
+
return chalkInstance.white;
|
|
870
|
+
}
|
|
871
|
+
}
|
|
872
|
+
function getSeverityValue(s) {
|
|
873
|
+
if (!s) return 0;
|
|
874
|
+
switch (s.toLowerCase()) {
|
|
875
|
+
case "critical":
|
|
876
|
+
return 4;
|
|
877
|
+
case "major":
|
|
878
|
+
return 3;
|
|
879
|
+
case "minor":
|
|
880
|
+
return 2;
|
|
865
881
|
case "info":
|
|
866
|
-
return
|
|
882
|
+
return 1;
|
|
867
883
|
default:
|
|
868
|
-
return
|
|
884
|
+
return 0;
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
function getSeverityLevel(s) {
|
|
888
|
+
return getSeverityValue(s);
|
|
889
|
+
}
|
|
890
|
+
function getSeverityBadge(severity, chalkInstance = import_chalk.default) {
|
|
891
|
+
const val = getSeverityValue(
|
|
892
|
+
typeof severity === "string" ? severity : severity
|
|
893
|
+
);
|
|
894
|
+
switch (val) {
|
|
895
|
+
case 4:
|
|
896
|
+
return chalkInstance.bgRed.white.bold(" CRITICAL ");
|
|
897
|
+
case 3:
|
|
898
|
+
return chalkInstance.bgYellow.black.bold(" MAJOR ");
|
|
899
|
+
case 2:
|
|
900
|
+
return chalkInstance.bgBlue.white.bold(" MINOR ");
|
|
901
|
+
case 1:
|
|
902
|
+
return chalkInstance.bgCyan.black(" INFO ");
|
|
903
|
+
default:
|
|
904
|
+
return chalkInstance.bgCyan.black(" INFO ");
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
function getSeverityEnum(s) {
|
|
908
|
+
const level = getSeverityLevel(s);
|
|
909
|
+
switch (level) {
|
|
910
|
+
case 4:
|
|
911
|
+
return "critical";
|
|
912
|
+
case 3:
|
|
913
|
+
return "major";
|
|
914
|
+
case 2:
|
|
915
|
+
return "minor";
|
|
916
|
+
case 1:
|
|
917
|
+
return "info";
|
|
918
|
+
default:
|
|
919
|
+
return "info";
|
|
869
920
|
}
|
|
870
921
|
}
|
|
871
922
|
function findLatestReport(dirPath) {
|
|
@@ -1314,94 +1365,6 @@ var TypeScriptParser = class {
|
|
|
1314
1365
|
}
|
|
1315
1366
|
};
|
|
1316
1367
|
|
|
1317
|
-
// src/parsers/tree-sitter-utils.ts
|
|
1318
|
-
var Parser = __toESM(require("web-tree-sitter"));
|
|
1319
|
-
var path = __toESM(require("path"));
|
|
1320
|
-
var fs = __toESM(require("fs"));
|
|
1321
|
-
var isTreeSitterInitialized = false;
|
|
1322
|
-
async function initTreeSitter() {
|
|
1323
|
-
if (isTreeSitterInitialized) return;
|
|
1324
|
-
try {
|
|
1325
|
-
const wasmPath = getWasmPath("web-tree-sitter");
|
|
1326
|
-
await Parser.Parser.init({
|
|
1327
|
-
locateFile() {
|
|
1328
|
-
return wasmPath || "web-tree-sitter.wasm";
|
|
1329
|
-
}
|
|
1330
|
-
});
|
|
1331
|
-
isTreeSitterInitialized = true;
|
|
1332
|
-
} catch (error) {
|
|
1333
|
-
console.error("Failed to initialize web-tree-sitter:", error);
|
|
1334
|
-
isTreeSitterInitialized = true;
|
|
1335
|
-
}
|
|
1336
|
-
}
|
|
1337
|
-
function findInPnpmStore(startDir, fileName, depth = 0) {
|
|
1338
|
-
if (depth > 8) return null;
|
|
1339
|
-
const pnpmDir = path.join(startDir, "node_modules", ".pnpm");
|
|
1340
|
-
if (fs.existsSync(pnpmDir)) {
|
|
1341
|
-
return findFileRecursively(pnpmDir, fileName, 0);
|
|
1342
|
-
}
|
|
1343
|
-
const parent = path.dirname(startDir);
|
|
1344
|
-
if (parent === startDir) return null;
|
|
1345
|
-
return findInPnpmStore(parent, fileName, depth + 1);
|
|
1346
|
-
}
|
|
1347
|
-
function findFileRecursively(dir, fileName, depth) {
|
|
1348
|
-
if (depth > 6) return null;
|
|
1349
|
-
try {
|
|
1350
|
-
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
1351
|
-
for (const entry of entries) {
|
|
1352
|
-
if (entry.isFile() && entry.name === fileName) {
|
|
1353
|
-
return path.join(dir, entry.name);
|
|
1354
|
-
}
|
|
1355
|
-
}
|
|
1356
|
-
for (const entry of entries) {
|
|
1357
|
-
if (entry.isDirectory()) {
|
|
1358
|
-
const found = findFileRecursively(
|
|
1359
|
-
path.join(dir, entry.name),
|
|
1360
|
-
fileName,
|
|
1361
|
-
depth + 1
|
|
1362
|
-
);
|
|
1363
|
-
if (found) return found;
|
|
1364
|
-
}
|
|
1365
|
-
}
|
|
1366
|
-
} catch (err) {
|
|
1367
|
-
}
|
|
1368
|
-
return null;
|
|
1369
|
-
}
|
|
1370
|
-
function getWasmPath(language) {
|
|
1371
|
-
const wasmFileName = language === "web-tree-sitter" ? "web-tree-sitter.wasm" : `tree-sitter-${language}.wasm`;
|
|
1372
|
-
const immediatePaths = [
|
|
1373
|
-
path.join(process.cwd(), wasmFileName),
|
|
1374
|
-
path.join(__dirname, wasmFileName),
|
|
1375
|
-
path.join(__dirname, "assets", wasmFileName)
|
|
1376
|
-
];
|
|
1377
|
-
for (const p of immediatePaths) {
|
|
1378
|
-
if (fs.existsSync(p)) return p;
|
|
1379
|
-
}
|
|
1380
|
-
const pnpmPath = findInPnpmStore(__dirname, wasmFileName);
|
|
1381
|
-
if (pnpmPath) return pnpmPath;
|
|
1382
|
-
const pnpmPathCwd = findInPnpmStore(process.cwd(), wasmFileName);
|
|
1383
|
-
if (pnpmPathCwd) return pnpmPathCwd;
|
|
1384
|
-
console.warn(
|
|
1385
|
-
`[Parser] WASM file for ${language} not found. CWD: ${process.cwd()}, DIR: ${__dirname}`
|
|
1386
|
-
);
|
|
1387
|
-
return null;
|
|
1388
|
-
}
|
|
1389
|
-
async function setupParser(language) {
|
|
1390
|
-
await initTreeSitter();
|
|
1391
|
-
const wasmPath = getWasmPath(language);
|
|
1392
|
-
if (!wasmPath) {
|
|
1393
|
-
return null;
|
|
1394
|
-
}
|
|
1395
|
-
try {
|
|
1396
|
-
const parser = new Parser.Parser();
|
|
1397
|
-
const Lang = await Parser.Language.load(wasmPath);
|
|
1398
|
-
parser.setLanguage(Lang);
|
|
1399
|
-
return parser;
|
|
1400
|
-
} catch (error) {
|
|
1401
|
-
return null;
|
|
1402
|
-
}
|
|
1403
|
-
}
|
|
1404
|
-
|
|
1405
1368
|
// src/parsers/metadata-utils.ts
|
|
1406
1369
|
function analyzeNodeMetadata(node, code, options) {
|
|
1407
1370
|
const metadata = {
|
|
@@ -1497,11 +1460,97 @@ function analyzeNodeMetadata(node, code, options) {
|
|
|
1497
1460
|
return metadata;
|
|
1498
1461
|
}
|
|
1499
1462
|
|
|
1500
|
-
// src/parsers/
|
|
1501
|
-
var
|
|
1463
|
+
// src/parsers/tree-sitter-utils.ts
|
|
1464
|
+
var Parser = __toESM(require("web-tree-sitter"));
|
|
1465
|
+
var path = __toESM(require("path"));
|
|
1466
|
+
var fs = __toESM(require("fs"));
|
|
1467
|
+
var isTreeSitterInitialized = false;
|
|
1468
|
+
async function initTreeSitter() {
|
|
1469
|
+
if (isTreeSitterInitialized) return;
|
|
1470
|
+
try {
|
|
1471
|
+
const wasmPath = getWasmPath("web-tree-sitter");
|
|
1472
|
+
await Parser.Parser.init({
|
|
1473
|
+
locateFile() {
|
|
1474
|
+
return wasmPath || "web-tree-sitter.wasm";
|
|
1475
|
+
}
|
|
1476
|
+
});
|
|
1477
|
+
isTreeSitterInitialized = true;
|
|
1478
|
+
} catch (error) {
|
|
1479
|
+
console.error("Failed to initialize web-tree-sitter:", error);
|
|
1480
|
+
isTreeSitterInitialized = true;
|
|
1481
|
+
}
|
|
1482
|
+
}
|
|
1483
|
+
function findInPnpmStore(startDir, fileName, depth = 0) {
|
|
1484
|
+
if (depth > 8) return null;
|
|
1485
|
+
const pnpmDir = path.join(startDir, "node_modules", ".pnpm");
|
|
1486
|
+
if (fs.existsSync(pnpmDir)) {
|
|
1487
|
+
return findFileRecursively(pnpmDir, fileName, 0);
|
|
1488
|
+
}
|
|
1489
|
+
const parent = path.dirname(startDir);
|
|
1490
|
+
if (parent === startDir) return null;
|
|
1491
|
+
return findInPnpmStore(parent, fileName, depth + 1);
|
|
1492
|
+
}
|
|
1493
|
+
function findFileRecursively(dir, fileName, depth) {
|
|
1494
|
+
if (depth > 6) return null;
|
|
1495
|
+
try {
|
|
1496
|
+
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
1497
|
+
for (const entry of entries) {
|
|
1498
|
+
if (entry.isFile() && entry.name === fileName) {
|
|
1499
|
+
return path.join(dir, entry.name);
|
|
1500
|
+
}
|
|
1501
|
+
}
|
|
1502
|
+
for (const entry of entries) {
|
|
1503
|
+
if (entry.isDirectory()) {
|
|
1504
|
+
const found = findFileRecursively(
|
|
1505
|
+
path.join(dir, entry.name),
|
|
1506
|
+
fileName,
|
|
1507
|
+
depth + 1
|
|
1508
|
+
);
|
|
1509
|
+
if (found) return found;
|
|
1510
|
+
}
|
|
1511
|
+
}
|
|
1512
|
+
} catch (err) {
|
|
1513
|
+
}
|
|
1514
|
+
return null;
|
|
1515
|
+
}
|
|
1516
|
+
function getWasmPath(language) {
|
|
1517
|
+
const wasmFileName = language === "web-tree-sitter" ? "web-tree-sitter.wasm" : `tree-sitter-${language}.wasm`;
|
|
1518
|
+
const immediatePaths = [
|
|
1519
|
+
path.join(process.cwd(), wasmFileName),
|
|
1520
|
+
path.join(__dirname, wasmFileName),
|
|
1521
|
+
path.join(__dirname, "assets", wasmFileName)
|
|
1522
|
+
];
|
|
1523
|
+
for (const p of immediatePaths) {
|
|
1524
|
+
if (fs.existsSync(p)) return p;
|
|
1525
|
+
}
|
|
1526
|
+
const pnpmPath = findInPnpmStore(__dirname, wasmFileName);
|
|
1527
|
+
if (pnpmPath) return pnpmPath;
|
|
1528
|
+
const pnpmPathCwd = findInPnpmStore(process.cwd(), wasmFileName);
|
|
1529
|
+
if (pnpmPathCwd) return pnpmPathCwd;
|
|
1530
|
+
console.warn(
|
|
1531
|
+
`[Parser] WASM file for ${language} not found. CWD: ${process.cwd()}, DIR: ${__dirname}`
|
|
1532
|
+
);
|
|
1533
|
+
return null;
|
|
1534
|
+
}
|
|
1535
|
+
async function setupParser(language) {
|
|
1536
|
+
await initTreeSitter();
|
|
1537
|
+
const wasmPath = getWasmPath(language);
|
|
1538
|
+
if (!wasmPath) {
|
|
1539
|
+
return null;
|
|
1540
|
+
}
|
|
1541
|
+
try {
|
|
1542
|
+
const parser = new Parser.Parser();
|
|
1543
|
+
const Lang = await Parser.Language.load(wasmPath);
|
|
1544
|
+
parser.setLanguage(Lang);
|
|
1545
|
+
return parser;
|
|
1546
|
+
} catch (error) {
|
|
1547
|
+
return null;
|
|
1548
|
+
}
|
|
1549
|
+
}
|
|
1550
|
+
|
|
1551
|
+
// src/parsers/base-parser.ts
|
|
1552
|
+
var BaseLanguageParser = class {
|
|
1502
1553
|
constructor() {
|
|
1503
|
-
this.language = "python" /* Python */;
|
|
1504
|
-
this.extensions = [".py"];
|
|
1505
1554
|
this.parser = null;
|
|
1506
1555
|
this.initialized = false;
|
|
1507
1556
|
}
|
|
@@ -1510,19 +1559,18 @@ var PythonParser = class {
|
|
|
1510
1559
|
*/
|
|
1511
1560
|
async initialize() {
|
|
1512
1561
|
if (this.initialized) return;
|
|
1513
|
-
|
|
1514
|
-
|
|
1562
|
+
try {
|
|
1563
|
+
this.parser = await setupParser(this.getParserName());
|
|
1564
|
+
this.initialized = true;
|
|
1565
|
+
} catch (error) {
|
|
1566
|
+
console.warn(`Failed to initialize ${this.language} parser:`, error);
|
|
1567
|
+
}
|
|
1515
1568
|
}
|
|
1516
1569
|
async getAST(code, filePath) {
|
|
1517
1570
|
if (!this.initialized) await this.initialize();
|
|
1518
1571
|
if (!this.parser) return null;
|
|
1519
1572
|
return this.parser.parse(code);
|
|
1520
1573
|
}
|
|
1521
|
-
analyzeMetadata(node, code) {
|
|
1522
|
-
return analyzeNodeMetadata(node, code, {
|
|
1523
|
-
sideEffectSignatures: ["print(", "input(", "open("]
|
|
1524
|
-
});
|
|
1525
|
-
}
|
|
1526
1574
|
parse(code, filePath) {
|
|
1527
1575
|
if (!this.initialized || !this.parser) {
|
|
1528
1576
|
return this.parseRegex(code, filePath);
|
|
@@ -1532,19 +1580,42 @@ var PythonParser = class {
|
|
|
1532
1580
|
if (!tree || tree.rootNode.type === "ERROR" || tree.rootNode.hasError) {
|
|
1533
1581
|
return this.parseRegex(code, filePath);
|
|
1534
1582
|
}
|
|
1535
|
-
const
|
|
1536
|
-
const
|
|
1537
|
-
const exports2 = this.extractExportsAST(rootNode, code);
|
|
1583
|
+
const imports = this.extractImportsAST(tree.rootNode);
|
|
1584
|
+
const exports2 = this.extractExportsAST(tree.rootNode, code);
|
|
1538
1585
|
return {
|
|
1539
1586
|
exports: exports2,
|
|
1540
1587
|
imports,
|
|
1541
|
-
language:
|
|
1588
|
+
language: this.language,
|
|
1542
1589
|
warnings: []
|
|
1543
1590
|
};
|
|
1544
1591
|
} catch (error) {
|
|
1592
|
+
console.warn(
|
|
1593
|
+
`AST parsing failed for ${filePath}, falling back to regex: ${error.message}`
|
|
1594
|
+
);
|
|
1545
1595
|
return this.parseRegex(code, filePath);
|
|
1546
1596
|
}
|
|
1547
1597
|
}
|
|
1598
|
+
canHandle(filePath) {
|
|
1599
|
+
const lowerPath = filePath.toLowerCase();
|
|
1600
|
+
return this.extensions.some((ext) => lowerPath.endsWith(ext));
|
|
1601
|
+
}
|
|
1602
|
+
};
|
|
1603
|
+
|
|
1604
|
+
// src/parsers/python-parser.ts
|
|
1605
|
+
var PythonParser = class extends BaseLanguageParser {
|
|
1606
|
+
constructor() {
|
|
1607
|
+
super(...arguments);
|
|
1608
|
+
this.language = "python" /* Python */;
|
|
1609
|
+
this.extensions = [".py"];
|
|
1610
|
+
}
|
|
1611
|
+
getParserName() {
|
|
1612
|
+
return "python";
|
|
1613
|
+
}
|
|
1614
|
+
analyzeMetadata(node, code) {
|
|
1615
|
+
return analyzeNodeMetadata(node, code, {
|
|
1616
|
+
sideEffectSignatures: ["print(", "input(", "open("]
|
|
1617
|
+
});
|
|
1618
|
+
}
|
|
1548
1619
|
extractImportsAST(rootNode) {
|
|
1549
1620
|
const imports = [];
|
|
1550
1621
|
const processImportNode = (node) => {
|
|
@@ -1978,25 +2049,14 @@ function extractParameterNames(node) {
|
|
|
1978
2049
|
}
|
|
1979
2050
|
|
|
1980
2051
|
// src/parsers/java-parser.ts
|
|
1981
|
-
var JavaParser = class {
|
|
2052
|
+
var JavaParser = class extends BaseLanguageParser {
|
|
1982
2053
|
constructor() {
|
|
2054
|
+
super(...arguments);
|
|
1983
2055
|
this.language = "java" /* Java */;
|
|
1984
2056
|
this.extensions = [".java"];
|
|
1985
|
-
this.parser = null;
|
|
1986
|
-
this.initialized = false;
|
|
1987
2057
|
}
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
*/
|
|
1991
|
-
async initialize() {
|
|
1992
|
-
if (this.initialized) return;
|
|
1993
|
-
this.parser = await setupParser("java");
|
|
1994
|
-
this.initialized = true;
|
|
1995
|
-
}
|
|
1996
|
-
async getAST(code, filePath) {
|
|
1997
|
-
if (!this.initialized) await this.initialize();
|
|
1998
|
-
if (!this.parser) return null;
|
|
1999
|
-
return this.parser.parse(code);
|
|
2058
|
+
getParserName() {
|
|
2059
|
+
return "java";
|
|
2000
2060
|
}
|
|
2001
2061
|
analyzeMetadata(node, code) {
|
|
2002
2062
|
return analyzeGeneralMetadata(node, code, {
|
|
@@ -2008,31 +2068,6 @@ var JavaParser = class {
|
|
|
2008
2068
|
]
|
|
2009
2069
|
});
|
|
2010
2070
|
}
|
|
2011
|
-
parse(code, filePath) {
|
|
2012
|
-
if (!this.initialized || !this.parser) {
|
|
2013
|
-
return this.parseRegex(code, filePath);
|
|
2014
|
-
}
|
|
2015
|
-
try {
|
|
2016
|
-
const tree = this.parser.parse(code);
|
|
2017
|
-
if (!tree || tree.rootNode.type === "ERROR" || tree.rootNode.hasError) {
|
|
2018
|
-
return this.parseRegex(code, filePath);
|
|
2019
|
-
}
|
|
2020
|
-
const rootNode = tree.rootNode;
|
|
2021
|
-
const imports = this.extractImportsAST(rootNode);
|
|
2022
|
-
const exports2 = this.extractExportsAST(rootNode, code);
|
|
2023
|
-
return {
|
|
2024
|
-
exports: exports2,
|
|
2025
|
-
imports,
|
|
2026
|
-
language: "java" /* Java */,
|
|
2027
|
-
warnings: []
|
|
2028
|
-
};
|
|
2029
|
-
} catch (error) {
|
|
2030
|
-
console.warn(
|
|
2031
|
-
`AST parsing failed for ${filePath}, falling back to regex: ${error.message}`
|
|
2032
|
-
);
|
|
2033
|
-
return this.parseRegex(code, filePath);
|
|
2034
|
-
}
|
|
2035
|
-
}
|
|
2036
2071
|
parseRegex(code, filePath) {
|
|
2037
2072
|
const lines = code.split("\n");
|
|
2038
2073
|
const exports2 = [];
|
|
@@ -2221,54 +2256,20 @@ var JavaParser = class {
|
|
|
2221
2256
|
};
|
|
2222
2257
|
|
|
2223
2258
|
// src/parsers/csharp-parser.ts
|
|
2224
|
-
var CSharpParser = class {
|
|
2259
|
+
var CSharpParser = class extends BaseLanguageParser {
|
|
2225
2260
|
constructor() {
|
|
2261
|
+
super(...arguments);
|
|
2226
2262
|
this.language = "csharp" /* CSharp */;
|
|
2227
2263
|
this.extensions = [".cs"];
|
|
2228
|
-
this.parser = null;
|
|
2229
|
-
this.initialized = false;
|
|
2230
2264
|
}
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
*/
|
|
2234
|
-
async initialize() {
|
|
2235
|
-
if (this.initialized) return;
|
|
2236
|
-
this.parser = await setupParser("c_sharp");
|
|
2237
|
-
this.initialized = true;
|
|
2238
|
-
}
|
|
2239
|
-
async getAST(code, filePath) {
|
|
2240
|
-
if (!this.initialized) await this.initialize();
|
|
2241
|
-
if (!this.parser) return null;
|
|
2242
|
-
return this.parser.parse(code);
|
|
2265
|
+
getParserName() {
|
|
2266
|
+
return "c_sharp";
|
|
2243
2267
|
}
|
|
2244
2268
|
analyzeMetadata(node, code) {
|
|
2245
2269
|
return analyzeGeneralMetadata(node, code, {
|
|
2246
2270
|
sideEffectSignatures: ["Console.Write", "File.Write", "Logging."]
|
|
2247
2271
|
});
|
|
2248
2272
|
}
|
|
2249
|
-
parse(code, filePath) {
|
|
2250
|
-
if (!this.initialized || !this.parser) {
|
|
2251
|
-
return this.parseRegex(code, filePath);
|
|
2252
|
-
}
|
|
2253
|
-
try {
|
|
2254
|
-
const tree = this.parser.parse(code);
|
|
2255
|
-
if (!tree) throw new Error("Parser.parse(code) returned null");
|
|
2256
|
-
const rootNode = tree.rootNode;
|
|
2257
|
-
const imports = this.extractImportsAST(rootNode);
|
|
2258
|
-
const exports2 = this.extractExportsAST(rootNode, code);
|
|
2259
|
-
return {
|
|
2260
|
-
exports: exports2,
|
|
2261
|
-
imports,
|
|
2262
|
-
language: "csharp" /* CSharp */,
|
|
2263
|
-
warnings: []
|
|
2264
|
-
};
|
|
2265
|
-
} catch (error) {
|
|
2266
|
-
console.warn(
|
|
2267
|
-
`AST parsing failed for ${filePath}, falling back to regex: ${error.message}`
|
|
2268
|
-
);
|
|
2269
|
-
return this.parseRegex(code, filePath);
|
|
2270
|
-
}
|
|
2271
|
-
}
|
|
2272
2273
|
parseRegex(code, filePath) {
|
|
2273
2274
|
const lines = code.split("\n");
|
|
2274
2275
|
const exports2 = [];
|
|
@@ -2465,56 +2466,20 @@ var CSharpParser = class {
|
|
|
2465
2466
|
};
|
|
2466
2467
|
|
|
2467
2468
|
// src/parsers/go-parser.ts
|
|
2468
|
-
var GoParser = class {
|
|
2469
|
+
var GoParser = class extends BaseLanguageParser {
|
|
2469
2470
|
constructor() {
|
|
2471
|
+
super(...arguments);
|
|
2470
2472
|
this.language = "go" /* Go */;
|
|
2471
2473
|
this.extensions = [".go"];
|
|
2472
|
-
this.parser = null;
|
|
2473
|
-
this.initialized = false;
|
|
2474
2474
|
}
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
*/
|
|
2478
|
-
async initialize() {
|
|
2479
|
-
if (this.initialized) return;
|
|
2480
|
-
this.parser = await setupParser("go");
|
|
2481
|
-
this.initialized = true;
|
|
2482
|
-
}
|
|
2483
|
-
async getAST(code, filePath) {
|
|
2484
|
-
if (!this.initialized) await this.initialize();
|
|
2485
|
-
if (!this.parser) return null;
|
|
2486
|
-
return this.parser.parse(code);
|
|
2475
|
+
getParserName() {
|
|
2476
|
+
return "go";
|
|
2487
2477
|
}
|
|
2488
2478
|
analyzeMetadata(node, code) {
|
|
2489
2479
|
return analyzeGeneralMetadata(node, code, {
|
|
2490
2480
|
sideEffectSignatures: ["<-", "fmt.Print", "fmt.Fprintf", "os.Exit"]
|
|
2491
2481
|
});
|
|
2492
2482
|
}
|
|
2493
|
-
parse(code, filePath) {
|
|
2494
|
-
if (!this.initialized || !this.parser) {
|
|
2495
|
-
return this.parseRegex(code, filePath);
|
|
2496
|
-
}
|
|
2497
|
-
try {
|
|
2498
|
-
const tree = this.parser.parse(code);
|
|
2499
|
-
if (!tree || tree.rootNode.type === "ERROR" || tree.rootNode.hasError) {
|
|
2500
|
-
return this.parseRegex(code, filePath);
|
|
2501
|
-
}
|
|
2502
|
-
const rootNode = tree.rootNode;
|
|
2503
|
-
const imports = this.extractImportsAST(rootNode);
|
|
2504
|
-
const exports2 = this.extractExportsAST(rootNode, code);
|
|
2505
|
-
return {
|
|
2506
|
-
exports: exports2,
|
|
2507
|
-
imports,
|
|
2508
|
-
language: "go" /* Go */,
|
|
2509
|
-
warnings: []
|
|
2510
|
-
};
|
|
2511
|
-
} catch (error) {
|
|
2512
|
-
console.warn(
|
|
2513
|
-
`AST parsing failed for ${filePath}, falling back to regex: ${error.message}`
|
|
2514
|
-
);
|
|
2515
|
-
return this.parseRegex(code, filePath);
|
|
2516
|
-
}
|
|
2517
|
-
}
|
|
2518
2483
|
parseRegex(code, filePath) {
|
|
2519
2484
|
const lines = code.split("\n");
|
|
2520
2485
|
const exports2 = [];
|
|
@@ -2841,48 +2806,7 @@ function getSupportedLanguages() {
|
|
|
2841
2806
|
return ParserFactory.getInstance().getSupportedLanguages();
|
|
2842
2807
|
}
|
|
2843
2808
|
|
|
2844
|
-
// src/utils/ast-
|
|
2845
|
-
function parseFileExports(code, filePath) {
|
|
2846
|
-
const parser = getParser(filePath);
|
|
2847
|
-
if (parser && parser.language !== "typescript" /* TypeScript */ && parser.language !== "javascript" /* JavaScript */) {
|
|
2848
|
-
try {
|
|
2849
|
-
const result = parser.parse(code, filePath);
|
|
2850
|
-
return {
|
|
2851
|
-
exports: result.exports.map((e) => ({
|
|
2852
|
-
name: e.name,
|
|
2853
|
-
type: e.type,
|
|
2854
|
-
imports: e.imports || [],
|
|
2855
|
-
dependencies: e.dependencies || [],
|
|
2856
|
-
typeReferences: e.typeReferences || [],
|
|
2857
|
-
loc: e.loc ? {
|
|
2858
|
-
start: { line: e.loc.start.line, column: e.loc.start.column },
|
|
2859
|
-
end: { line: e.loc.end.line, column: e.loc.end.column }
|
|
2860
|
-
} : void 0
|
|
2861
|
-
})),
|
|
2862
|
-
imports: result.imports.map((i) => ({
|
|
2863
|
-
source: i.source,
|
|
2864
|
-
specifiers: i.specifiers,
|
|
2865
|
-
isTypeOnly: i.isTypeOnly || false
|
|
2866
|
-
}))
|
|
2867
|
-
};
|
|
2868
|
-
} catch (e) {
|
|
2869
|
-
return { exports: [], imports: [] };
|
|
2870
|
-
}
|
|
2871
|
-
}
|
|
2872
|
-
try {
|
|
2873
|
-
const ast = (0, import_typescript_estree2.parse)(code, {
|
|
2874
|
-
loc: true,
|
|
2875
|
-
range: true,
|
|
2876
|
-
jsx: filePath.endsWith(".tsx") || filePath.endsWith(".jsx"),
|
|
2877
|
-
filePath
|
|
2878
|
-
});
|
|
2879
|
-
const imports = extractFileImports(ast);
|
|
2880
|
-
const exports2 = extractExportsWithDependencies(ast, imports);
|
|
2881
|
-
return { exports: exports2, imports };
|
|
2882
|
-
} catch (error) {
|
|
2883
|
-
return { exports: [], imports: [] };
|
|
2884
|
-
}
|
|
2885
|
-
}
|
|
2809
|
+
// src/utils/ast-visitor.ts
|
|
2886
2810
|
function extractFileImports(ast) {
|
|
2887
2811
|
const imports = [];
|
|
2888
2812
|
for (const node of ast.body) {
|
|
@@ -2940,22 +2864,23 @@ function extractExportsWithDependencies(ast, fileImports) {
|
|
|
2940
2864
|
}
|
|
2941
2865
|
return exports2;
|
|
2942
2866
|
}
|
|
2943
|
-
function extractFromDeclaration(
|
|
2867
|
+
function extractFromDeclaration(node) {
|
|
2868
|
+
if (!node) return [];
|
|
2944
2869
|
const results = [];
|
|
2945
|
-
if (
|
|
2946
|
-
results.push({ name:
|
|
2947
|
-
} else if (
|
|
2948
|
-
results.push({ name:
|
|
2949
|
-
} else if (
|
|
2950
|
-
for (const
|
|
2951
|
-
if (
|
|
2952
|
-
results.push({ name:
|
|
2870
|
+
if (node.type === "FunctionDeclaration" && node.id) {
|
|
2871
|
+
results.push({ name: node.id.name, type: "function" });
|
|
2872
|
+
} else if (node.type === "ClassDeclaration" && node.id) {
|
|
2873
|
+
results.push({ name: node.id.name, type: "class" });
|
|
2874
|
+
} else if (node.type === "VariableDeclaration") {
|
|
2875
|
+
for (const decl of node.declarations) {
|
|
2876
|
+
if (decl.id.type === "Identifier") {
|
|
2877
|
+
results.push({ name: decl.id.name, type: "const" });
|
|
2953
2878
|
}
|
|
2954
2879
|
}
|
|
2955
|
-
} else if (
|
|
2956
|
-
results.push({ name:
|
|
2957
|
-
} else if (
|
|
2958
|
-
results.push({ name:
|
|
2880
|
+
} else if (node.type === "TSInterfaceDeclaration" && node.id) {
|
|
2881
|
+
results.push({ name: node.id.name, type: "interface" });
|
|
2882
|
+
} else if (node.type === "TSTypeAliasDeclaration" && node.id) {
|
|
2883
|
+
results.push({ name: node.id.name, type: "type" });
|
|
2959
2884
|
}
|
|
2960
2885
|
return results;
|
|
2961
2886
|
}
|
|
@@ -2983,16 +2908,6 @@ function findUsedImports(node, importedNames) {
|
|
|
2983
2908
|
visit(node);
|
|
2984
2909
|
return Array.from(usedImports);
|
|
2985
2910
|
}
|
|
2986
|
-
function calculateImportSimilarity(export1, export2) {
|
|
2987
|
-
if (export1.imports.length === 0 && export2.imports.length === 0) {
|
|
2988
|
-
return 1;
|
|
2989
|
-
}
|
|
2990
|
-
const set1 = new Set(export1.imports);
|
|
2991
|
-
const set2 = new Set(export2.imports);
|
|
2992
|
-
const intersection = new Set([...set1].filter((x) => set2.has(x)));
|
|
2993
|
-
const union = /* @__PURE__ */ new Set([...set1, ...set2]);
|
|
2994
|
-
return intersection.size / union.size;
|
|
2995
|
-
}
|
|
2996
2911
|
function extractTypeReferences(node) {
|
|
2997
2912
|
const types = /* @__PURE__ */ new Set();
|
|
2998
2913
|
function visit(n) {
|
|
@@ -3030,6 +2945,59 @@ function extractTypeReferences(node) {
|
|
|
3030
2945
|
visit(node);
|
|
3031
2946
|
return Array.from(types);
|
|
3032
2947
|
}
|
|
2948
|
+
|
|
2949
|
+
// src/utils/ast-parser.ts
|
|
2950
|
+
function parseFileExports(code, filePath) {
|
|
2951
|
+
const parser = getParser(filePath);
|
|
2952
|
+
if (parser && parser.language !== "typescript" /* TypeScript */ && parser.language !== "javascript" /* JavaScript */) {
|
|
2953
|
+
try {
|
|
2954
|
+
const result = parser.parse(code, filePath);
|
|
2955
|
+
return {
|
|
2956
|
+
exports: result.exports.map((e) => ({
|
|
2957
|
+
name: e.name,
|
|
2958
|
+
type: e.type,
|
|
2959
|
+
imports: e.imports || [],
|
|
2960
|
+
dependencies: e.dependencies || [],
|
|
2961
|
+
typeReferences: e.typeReferences || [],
|
|
2962
|
+
loc: e.loc ? {
|
|
2963
|
+
start: { line: e.loc.start.line, column: e.loc.start.column },
|
|
2964
|
+
end: { line: e.loc.end.line, column: e.loc.end.column }
|
|
2965
|
+
} : void 0
|
|
2966
|
+
})),
|
|
2967
|
+
imports: result.imports.map((i) => ({
|
|
2968
|
+
source: i.source,
|
|
2969
|
+
specifiers: i.specifiers,
|
|
2970
|
+
isTypeOnly: i.isTypeOnly || false
|
|
2971
|
+
}))
|
|
2972
|
+
};
|
|
2973
|
+
} catch (e) {
|
|
2974
|
+
return { exports: [], imports: [] };
|
|
2975
|
+
}
|
|
2976
|
+
}
|
|
2977
|
+
try {
|
|
2978
|
+
const ast = (0, import_typescript_estree2.parse)(code, {
|
|
2979
|
+
loc: true,
|
|
2980
|
+
range: true,
|
|
2981
|
+
jsx: filePath.endsWith(".tsx") || filePath.endsWith(".jsx"),
|
|
2982
|
+
filePath
|
|
2983
|
+
});
|
|
2984
|
+
const imports = extractFileImports(ast);
|
|
2985
|
+
const exports2 = extractExportsWithDependencies(ast, imports);
|
|
2986
|
+
return { exports: exports2, imports };
|
|
2987
|
+
} catch (error) {
|
|
2988
|
+
return { exports: [], imports: [] };
|
|
2989
|
+
}
|
|
2990
|
+
}
|
|
2991
|
+
function calculateImportSimilarity(export1, export2) {
|
|
2992
|
+
if (export1.imports.length === 0 && export2.imports.length === 0) {
|
|
2993
|
+
return 1;
|
|
2994
|
+
}
|
|
2995
|
+
const set1 = new Set(export1.imports);
|
|
2996
|
+
const set2 = new Set(export2.imports);
|
|
2997
|
+
const intersection = new Set([...set1].filter((x) => set2.has(x)));
|
|
2998
|
+
const union = /* @__PURE__ */ new Set([...set1, ...set2]);
|
|
2999
|
+
return intersection.size / union.size;
|
|
3000
|
+
}
|
|
3033
3001
|
function parseCode(code, language) {
|
|
3034
3002
|
return null;
|
|
3035
3003
|
}
|
|
@@ -3093,14 +3061,14 @@ async function loadConfig(rootDir) {
|
|
|
3093
3061
|
return config;
|
|
3094
3062
|
} catch (error) {
|
|
3095
3063
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
3096
|
-
const
|
|
3064
|
+
const configError = new Error(
|
|
3097
3065
|
`Failed to load config from ${configPath}: ${errorMessage}`
|
|
3098
3066
|
);
|
|
3099
3067
|
try {
|
|
3100
|
-
|
|
3068
|
+
configError.cause = error instanceof Error ? error : void 0;
|
|
3101
3069
|
} catch {
|
|
3102
3070
|
}
|
|
3103
|
-
throw
|
|
3071
|
+
throw configError;
|
|
3104
3072
|
}
|
|
3105
3073
|
}
|
|
3106
3074
|
const parent = (0, import_path3.dirname)(currentDir);
|
|
@@ -3113,28 +3081,28 @@ async function loadConfig(rootDir) {
|
|
|
3113
3081
|
}
|
|
3114
3082
|
function mergeConfigWithDefaults(userConfig, defaults) {
|
|
3115
3083
|
if (!userConfig) return defaults;
|
|
3116
|
-
const
|
|
3084
|
+
const mergedConfig = { ...defaults };
|
|
3117
3085
|
if (userConfig.scan) {
|
|
3118
|
-
if (userConfig.scan.include)
|
|
3119
|
-
if (userConfig.scan.exclude)
|
|
3086
|
+
if (userConfig.scan.include) mergedConfig.include = userConfig.scan.include;
|
|
3087
|
+
if (userConfig.scan.exclude) mergedConfig.exclude = userConfig.scan.exclude;
|
|
3120
3088
|
}
|
|
3121
3089
|
const toolOverrides = userConfig.tools && !Array.isArray(userConfig.tools) && typeof userConfig.tools === "object" ? userConfig.tools : userConfig.toolConfigs;
|
|
3122
3090
|
if (toolOverrides) {
|
|
3123
|
-
if (!
|
|
3091
|
+
if (!mergedConfig.toolConfigs) mergedConfig.toolConfigs = {};
|
|
3124
3092
|
for (const [toolName, toolConfig] of Object.entries(toolOverrides)) {
|
|
3125
3093
|
if (typeof toolConfig === "object" && toolConfig !== null) {
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
...
|
|
3094
|
+
mergedConfig[toolName] = { ...mergedConfig[toolName], ...toolConfig };
|
|
3095
|
+
mergedConfig.toolConfigs[toolName] = {
|
|
3096
|
+
...mergedConfig.toolConfigs[toolName],
|
|
3129
3097
|
...toolConfig
|
|
3130
3098
|
};
|
|
3131
3099
|
}
|
|
3132
3100
|
}
|
|
3133
3101
|
}
|
|
3134
3102
|
if (userConfig.output) {
|
|
3135
|
-
|
|
3103
|
+
mergedConfig.output = { ...mergedConfig.output, ...userConfig.output };
|
|
3136
3104
|
}
|
|
3137
|
-
return
|
|
3105
|
+
return mergedConfig;
|
|
3138
3106
|
}
|
|
3139
3107
|
|
|
3140
3108
|
// src/utils/visualization.ts
|
|
@@ -3503,6 +3471,13 @@ function getRating(score) {
|
|
|
3503
3471
|
if (score >= 40) return "Needs Work" /* NeedsWork */;
|
|
3504
3472
|
return "Critical" /* Critical */;
|
|
3505
3473
|
}
|
|
3474
|
+
function getRatingSlug(score) {
|
|
3475
|
+
if (score >= 90) return "excellent";
|
|
3476
|
+
if (score >= 75) return "good";
|
|
3477
|
+
if (score >= 60) return "fair";
|
|
3478
|
+
if (score >= 40) return "needs-work";
|
|
3479
|
+
return "critical";
|
|
3480
|
+
}
|
|
3506
3481
|
function getRatingWithContext(score, fileCount, modelTier = "standard") {
|
|
3507
3482
|
const threshold = getRecommendedThreshold(fileCount, modelTier);
|
|
3508
3483
|
const normalized = score - threshold + 70;
|
|
@@ -3772,7 +3747,10 @@ function predictAcceptanceRate(toolOutputs) {
|
|
|
3772
3747
|
impact: Math.round((50 - aiSignalClarity.score) * 2e-3 * 100)
|
|
3773
3748
|
});
|
|
3774
3749
|
}
|
|
3775
|
-
const totalImpact = factors.reduce(
|
|
3750
|
+
const totalImpact = factors.reduce(
|
|
3751
|
+
(sum, f) => sum + f.impact / 100,
|
|
3752
|
+
0
|
|
3753
|
+
);
|
|
3776
3754
|
const rate = Math.max(0.05, Math.min(0.8, baseRate + totalImpact));
|
|
3777
3755
|
let confidence = 0.35;
|
|
3778
3756
|
if (toolOutputs.size >= 4) confidence = 0.75;
|
|
@@ -5112,12 +5090,17 @@ function emitIssuesAsAnnotations(issues) {
|
|
|
5112
5090
|
getProjectSizeTier,
|
|
5113
5091
|
getRating,
|
|
5114
5092
|
getRatingDisplay,
|
|
5093
|
+
getRatingSlug,
|
|
5115
5094
|
getRatingWithContext,
|
|
5116
5095
|
getRecommendedThreshold,
|
|
5117
5096
|
getRepoMetadata,
|
|
5118
5097
|
getSafetyIcon,
|
|
5119
5098
|
getScoreBar,
|
|
5099
|
+
getSeverityBadge,
|
|
5120
5100
|
getSeverityColor,
|
|
5101
|
+
getSeverityEnum,
|
|
5102
|
+
getSeverityLevel,
|
|
5103
|
+
getSeverityValue,
|
|
5121
5104
|
getSupportedLanguages,
|
|
5122
5105
|
getToolWeight,
|
|
5123
5106
|
getWasmPath,
|