@aiready/core 0.24.5 → 0.24.6
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/{chunk-RCZSMGCX.mjs → chunk-2IUCKF4Z.mjs} +1 -1
- package/dist/{chunk-WYOW6O3P.mjs → chunk-3D3I5K5W.mjs} +33 -7
- package/dist/{chunk-GTS642BQ.mjs → chunk-3FAI4YNO.mjs} +1 -1
- package/dist/{chunk-EZ7ECLAZ.mjs → chunk-5IVDH26E.mjs} +21 -16
- package/dist/{chunk-SWZOT67M.mjs → chunk-6T5O7OAY.mjs} +1 -1
- package/dist/{chunk-L6BKANJC.mjs → chunk-DHFOYNMW.mjs} +12 -8
- package/dist/{chunk-QZNY7B2N.mjs → chunk-EHUK4VMH.mjs} +16 -8
- package/dist/{chunk-MTK2IIDZ.mjs → chunk-EJ74KPCV.mjs} +1 -1
- package/dist/{chunk-2ILVUVRK.mjs → chunk-FAESSLG7.mjs} +44 -17
- package/dist/{chunk-UTCRW3N7.mjs → chunk-Q4LOPVH6.mjs} +18 -14
- package/dist/{chunk-WH4ZGRVF.mjs → chunk-QY5YG2AZ.mjs} +12 -9
- package/dist/{chunk-IXPY5J4K.mjs → chunk-X63YJX5G.mjs} +16 -8
- package/dist/client/index.d.mts +1 -1
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.js +44 -17
- package/dist/client/index.mjs +1 -1
- package/dist/{csharp-parser-4ZKCSX5B.mjs → csharp-parser-C52DNAKT.mjs} +2 -2
- package/dist/{csharp-parser-5HKICCRR.mjs → csharp-parser-XW7WHE77.mjs} +2 -2
- package/dist/{go-parser-TKXL3DVH.mjs → go-parser-GO4BIRDD.mjs} +2 -2
- package/dist/{go-parser-XOM232XZ.mjs → go-parser-KTG4CGF5.mjs} +2 -2
- package/dist/{index-CkM98qn1.d.mts → index-ChiWzeQs.d.mts} +188 -180
- package/dist/{index-CkM98qn1.d.ts → index-ChiWzeQs.d.ts} +188 -180
- package/dist/{index-EQ2jRSlB.d.mts → index-PI6qMP2H.d.mts} +182 -178
- package/dist/{index-EQ2jRSlB.d.ts → index-PI6qMP2H.d.ts} +182 -178
- package/dist/index.d.mts +50 -15
- package/dist/index.d.ts +50 -15
- package/dist/index.js +255 -109
- package/dist/index.mjs +161 -66
- package/dist/{java-parser-MASGS4WB.mjs → java-parser-EOKMGQ6B.mjs} +2 -2
- package/dist/{java-parser-T5LXD63J.mjs → java-parser-G47O53QP.mjs} +2 -2
- package/dist/{python-parser-FNFK2473.mjs → python-parser-BCI7JVLF.mjs} +1 -1
- package/dist/{typescript-parser-2GGNRNB5.mjs → typescript-parser-4BA4VYAF.mjs} +1 -1
- package/dist/{typescript-parser-3ENJ6C7H.mjs → typescript-parser-WFGH52WB.mjs} +1 -1
- package/package.json +1 -1
- package/dist/chunk-ARUIZO7M.mjs +0 -297
- package/dist/chunk-AZRUQG5T.mjs +0 -537
- package/dist/chunk-CYC5EGEI.mjs +0 -297
- package/dist/chunk-DBOPSRBC.mjs +0 -884
- package/dist/chunk-E55RNGGK.mjs +0 -852
- package/dist/chunk-FNPULWG7.mjs +0 -248
- package/dist/chunk-FZTFKZUQ.mjs +0 -250
- package/dist/chunk-G4Z45SMK.mjs +0 -852
- package/dist/chunk-JJQLYW6Z.mjs +0 -111
- package/dist/chunk-LEITCMH3.mjs +0 -535
- package/dist/chunk-LTAZ7Z62.mjs +0 -855
- package/dist/chunk-LXEO5PG3.mjs +0 -292
- package/dist/chunk-LZHO636W.mjs +0 -501
- package/dist/chunk-MPWWAAHQ.mjs +0 -548
- package/dist/chunk-QDCQETSI.mjs +0 -262
- package/dist/chunk-SM6INS52.mjs +0 -501
- package/dist/chunk-UBCM5Y6R.mjs +0 -275
- package/dist/chunk-UYLH35LA.mjs +0 -884
- package/dist/chunk-WVNVC2PP.mjs +0 -852
- package/dist/chunk-XQSEJ7WN.mjs +0 -547
- package/dist/chunk-YRSSR4KN.mjs +0 -850
- package/dist/client-2xbeKnrg.d.mts +0 -1291
- package/dist/client-2xbeKnrg.d.ts +0 -1291
- package/dist/client-4HLAGzFg.d.mts +0 -1291
- package/dist/client-4HLAGzFg.d.ts +0 -1291
- package/dist/client-B4TQwNa7.d.mts +0 -1290
- package/dist/client-B4TQwNa7.d.ts +0 -1290
- package/dist/client-Bdi4ty0v.d.mts +0 -1294
- package/dist/client-Bdi4ty0v.d.ts +0 -1294
- package/dist/client-BsKpUH3H.d.mts +0 -1339
- package/dist/client-BsKpUH3H.d.ts +0 -1339
- package/dist/client-Bv1zOaWF.d.mts +0 -1291
- package/dist/client-Bv1zOaWF.d.ts +0 -1291
- package/dist/client-Bz9YJMIX.d.mts +0 -1290
- package/dist/client-Bz9YJMIX.d.ts +0 -1290
- package/dist/client-CBpzm34X.d.mts +0 -1291
- package/dist/client-CBpzm34X.d.ts +0 -1291
- package/dist/client-CNu_tCZZ.d.mts +0 -1305
- package/dist/client-CNu_tCZZ.d.ts +0 -1305
- package/dist/client-CmEvxxQu.d.mts +0 -1339
- package/dist/client-CmEvxxQu.d.ts +0 -1339
- package/dist/client-Ctl_0z6F.d.mts +0 -1294
- package/dist/client-Ctl_0z6F.d.ts +0 -1294
- package/dist/client-DGMAxkZc.d.mts +0 -1339
- package/dist/client-DGMAxkZc.d.ts +0 -1339
- package/dist/client-DZq-CqcD.d.mts +0 -1292
- package/dist/client-DZq-CqcD.d.ts +0 -1292
- package/dist/client-DcqGfDTt.d.mts +0 -1284
- package/dist/client-DcqGfDTt.d.ts +0 -1284
- package/dist/client-O8RvSRm0.d.mts +0 -1261
- package/dist/client-O8RvSRm0.d.ts +0 -1261
- package/dist/client.d.mts +0 -2
- package/dist/client.d.ts +0 -2
- package/dist/client.js +0 -922
- package/dist/client.mjs +0 -104
- package/dist/csharp-parser-JCKXIAJW.mjs +0 -9
- package/dist/go-parser-J4KIH4RG.mjs +0 -9
- package/dist/index-Ctl_0z6F.d.mts +0 -1294
- package/dist/index-Ctl_0z6F.d.ts +0 -1294
- package/dist/index-DLHCsiAk.d.mts +0 -1294
- package/dist/index-DLHCsiAk.d.ts +0 -1294
- package/dist/java-parser-3KHXOXRQ.mjs +0 -9
- package/dist/python-parser-7QISP7LK.mjs +0 -8
- package/dist/python-parser-PDCO35VN.mjs +0 -8
- package/dist/python-parser-QAAL56MC.mjs +0 -8
- package/dist/python-parser-R7HLPNZK.mjs +0 -8
- package/dist/python-parser-SJ3LFZFJ.mjs +0 -8
- package/dist/python-parser-UFLCDT6L.mjs +0 -8
- package/dist/typescript-parser-4GI7DPSW.mjs +0 -7
- package/dist/typescript-parser-4H3HUBO4.mjs +0 -7
- package/dist/typescript-parser-K63IVZMF.mjs +0 -7
- package/dist/typescript-parser-ZJKROMQG.mjs +0 -7
package/dist/index.js
CHANGED
|
@@ -99,9 +99,10 @@ var init_typescript_parser = __esm({
|
|
|
99
99
|
jsx: filePath.endsWith("x")
|
|
100
100
|
});
|
|
101
101
|
} catch (error) {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
102
|
+
const err = error;
|
|
103
|
+
throw new ParseError(err.message || "Unknown error", filePath, {
|
|
104
|
+
line: err.lineNumber || 1,
|
|
105
|
+
column: err.column || 0
|
|
105
106
|
});
|
|
106
107
|
}
|
|
107
108
|
}
|
|
@@ -240,7 +241,6 @@ var init_typescript_parser = __esm({
|
|
|
240
241
|
decl.id.name,
|
|
241
242
|
"const",
|
|
242
243
|
node,
|
|
243
|
-
// Pass the outer ExportNamedDeclaration
|
|
244
244
|
code,
|
|
245
245
|
filePath,
|
|
246
246
|
decl.init
|
|
@@ -270,16 +270,19 @@ var init_typescript_parser = __esm({
|
|
|
270
270
|
isPrimitive = true;
|
|
271
271
|
}
|
|
272
272
|
}
|
|
273
|
-
|
|
273
|
+
let structNode = node.type === "ExportNamedDeclaration" && node.declaration ? node.declaration : node.type === "ExportDefaultDeclaration" ? node.declaration : node;
|
|
274
|
+
if (!structNode) structNode = node;
|
|
274
275
|
if (filePath.endsWith(".ts") || filePath.endsWith(".tsx")) {
|
|
275
276
|
if (structNode.type === "TSTypeAliasDeclaration" || structNode.type === "TSInterfaceDeclaration" || structNode.type === "TSEnumDeclaration") {
|
|
276
277
|
isTyped = true;
|
|
277
278
|
} else if (structNode.type === "FunctionDeclaration" || structNode.type === "TSDeclareFunction") {
|
|
278
|
-
const
|
|
279
|
-
const
|
|
279
|
+
const func = structNode;
|
|
280
|
+
const hasReturnType = !!func.returnType;
|
|
281
|
+
const allParamsTyped = func.params.length === 0 || func.params.every((p) => !!p.typeAnnotation);
|
|
280
282
|
isTyped = hasReturnType && allParamsTyped;
|
|
281
283
|
} else if (structNode.type === "VariableDeclaration") {
|
|
282
|
-
|
|
284
|
+
const variable = structNode;
|
|
285
|
+
isTyped = variable.declarations.every(
|
|
283
286
|
(d) => !!d.id.typeAnnotation || !!d.init
|
|
284
287
|
);
|
|
285
288
|
} else if (structNode.type === "ClassDeclaration") {
|
|
@@ -307,7 +310,7 @@ var init_typescript_parser = __esm({
|
|
|
307
310
|
return p.parameter.name;
|
|
308
311
|
}
|
|
309
312
|
return void 0;
|
|
310
|
-
}).filter(
|
|
313
|
+
}).filter((p) => !!p);
|
|
311
314
|
}
|
|
312
315
|
}
|
|
313
316
|
}
|
|
@@ -317,7 +320,7 @@ var init_typescript_parser = __esm({
|
|
|
317
320
|
parameters = funcNode.params.map((p) => {
|
|
318
321
|
if (p.type === "Identifier") return p.name;
|
|
319
322
|
return void 0;
|
|
320
|
-
}).filter(
|
|
323
|
+
}).filter((p) => !!p);
|
|
321
324
|
}
|
|
322
325
|
}
|
|
323
326
|
return {
|
|
@@ -352,11 +355,11 @@ var init_typescript_parser = __esm({
|
|
|
352
355
|
return void 0;
|
|
353
356
|
}
|
|
354
357
|
isLikelyPure(node) {
|
|
355
|
-
const
|
|
356
|
-
if (
|
|
357
|
-
|
|
358
|
-
if (
|
|
359
|
-
const body =
|
|
358
|
+
const sn = node.type === "ExportNamedDeclaration" && node.declaration ? node.declaration : node.type === "ExportDefaultDeclaration" ? node.declaration : node;
|
|
359
|
+
if (!sn) return false;
|
|
360
|
+
if (sn.type === "VariableDeclaration" && sn.kind === "const") return true;
|
|
361
|
+
if (sn.type === "FunctionDeclaration" || sn.type === "MethodDefinition") {
|
|
362
|
+
const body = sn.type === "MethodDefinition" ? sn.value.body : sn.body;
|
|
360
363
|
if (body && body.type === "BlockStatement") {
|
|
361
364
|
const bodyContent = JSON.stringify(body);
|
|
362
365
|
if (bodyContent.includes('"name":"console"') || bodyContent.includes('"name":"process"') || bodyContent.includes('"type":"AssignmentExpression"')) {
|
|
@@ -379,7 +382,7 @@ function analyzeNodeMetadata(node, code, options) {
|
|
|
379
382
|
hasSideEffects: false
|
|
380
383
|
};
|
|
381
384
|
try {
|
|
382
|
-
let prev = node.previousSibling
|
|
385
|
+
let prev = node.previousSibling;
|
|
383
386
|
while (prev && /comment/i.test(prev.type)) {
|
|
384
387
|
const text = prev.text || "";
|
|
385
388
|
const loc = {
|
|
@@ -419,7 +422,7 @@ function analyzeNodeMetadata(node, code, options) {
|
|
|
419
422
|
prev = prev.previousSibling;
|
|
420
423
|
}
|
|
421
424
|
if (node.type === "function_definition" || node.type === "class_definition") {
|
|
422
|
-
const body2 = node.childForFieldName
|
|
425
|
+
const body2 = node.childForFieldName("body") || node.children.find((c) => c.type === "block");
|
|
423
426
|
if (body2 && body2.children.length > 0) {
|
|
424
427
|
const firstStmt = body2.children[0];
|
|
425
428
|
if (firstStmt.type === "expression_statement" && firstStmt.firstChild?.type === "string") {
|
|
@@ -483,7 +486,7 @@ function analyzeNodeMetadata(node, code, options) {
|
|
|
483
486
|
} catch {
|
|
484
487
|
}
|
|
485
488
|
};
|
|
486
|
-
const body = node.childForFieldName
|
|
489
|
+
const body = node.childForFieldName("body") || node.children.find(
|
|
487
490
|
(c) => /body|block|class_body|declaration_list|function_body/.test(c.type)
|
|
488
491
|
);
|
|
489
492
|
if (body) walk(body);
|
|
@@ -731,6 +734,9 @@ var init_python_parser = __esm({
|
|
|
731
734
|
this.language = "python" /* Python */;
|
|
732
735
|
this.extensions = [".py"];
|
|
733
736
|
}
|
|
737
|
+
/**
|
|
738
|
+
* Returns the canonical name of this parser.
|
|
739
|
+
*/
|
|
734
740
|
getParserName() {
|
|
735
741
|
return "python";
|
|
736
742
|
}
|
|
@@ -931,10 +937,7 @@ var init_python_parser = __esm({
|
|
|
931
937
|
(c) => c.type === PYTHON_CONSTANTS.NODES.IDENTIFIER || c.type === PYTHON_CONSTANTS.NODES.TYPED_PARAMETER || c.type === PYTHON_CONSTANTS.NODES.DEFAULT_PARAMETER
|
|
932
938
|
).map((c) => {
|
|
933
939
|
if (c.type === PYTHON_CONSTANTS.NODES.IDENTIFIER) return c.text;
|
|
934
|
-
|
|
935
|
-
return c.firstChild?.text || "unknown";
|
|
936
|
-
}
|
|
937
|
-
return "unknown";
|
|
940
|
+
return c.firstChild?.text || "unknown";
|
|
938
941
|
});
|
|
939
942
|
}
|
|
940
943
|
/**
|
|
@@ -953,10 +956,13 @@ var init_python_parser = __esm({
|
|
|
953
956
|
]
|
|
954
957
|
};
|
|
955
958
|
} catch (error) {
|
|
959
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
956
960
|
const wrapper = new Error(
|
|
957
|
-
`Failed to parse Python file ${filePath}: ${
|
|
961
|
+
`Failed to parse Python file ${filePath}: ${message}`
|
|
958
962
|
);
|
|
959
|
-
|
|
963
|
+
if (error instanceof Error) {
|
|
964
|
+
wrapper.cause = error;
|
|
965
|
+
}
|
|
960
966
|
throw wrapper;
|
|
961
967
|
}
|
|
962
968
|
}
|
|
@@ -1099,15 +1105,19 @@ var init_python_parser = __esm({
|
|
|
1099
1105
|
});
|
|
1100
1106
|
|
|
1101
1107
|
// src/parsers/shared-parser-utils.ts
|
|
1108
|
+
function getNodeProperty(node, prop) {
|
|
1109
|
+
if (!node) return null;
|
|
1110
|
+
return node[prop] ?? null;
|
|
1111
|
+
}
|
|
1102
1112
|
function analyzeGeneralMetadata(node, code, options = {}) {
|
|
1103
1113
|
const metadata = {
|
|
1104
1114
|
isPure: true,
|
|
1105
1115
|
hasSideEffects: false
|
|
1106
1116
|
};
|
|
1107
1117
|
try {
|
|
1108
|
-
let prev = node
|
|
1118
|
+
let prev = getNodeProperty(node, "previousNamedSibling") || getNodeProperty(node, "previousSibling") || null;
|
|
1109
1119
|
while (prev && (!prev.type || !prev.text.trim())) {
|
|
1110
|
-
prev = prev
|
|
1120
|
+
prev = getNodeProperty(prev, "previousSibling");
|
|
1111
1121
|
}
|
|
1112
1122
|
if (!prev && node.parent) {
|
|
1113
1123
|
const children = node.parent.children;
|
|
@@ -1120,9 +1130,9 @@ function analyzeGeneralMetadata(node, code, options = {}) {
|
|
|
1120
1130
|
}
|
|
1121
1131
|
}
|
|
1122
1132
|
while (prev && /attribute|decorator/i.test(prev.type)) {
|
|
1123
|
-
prev = prev
|
|
1133
|
+
prev = getNodeProperty(prev, "previousNamedSibling") || getNodeProperty(prev, "previousSibling") || null;
|
|
1124
1134
|
while (prev && (!prev.type || !prev.text.trim())) {
|
|
1125
|
-
prev = prev
|
|
1135
|
+
prev = getNodeProperty(prev, "previousSibling");
|
|
1126
1136
|
}
|
|
1127
1137
|
}
|
|
1128
1138
|
while (prev && (/comment|xml|doc|slash/i.test(prev.type) || prev.text.trim().startsWith("//") || prev.text.trim().startsWith("///"))) {
|
|
@@ -1148,7 +1158,7 @@ function analyzeGeneralMetadata(node, code, options = {}) {
|
|
|
1148
1158
|
};
|
|
1149
1159
|
break;
|
|
1150
1160
|
}
|
|
1151
|
-
prev = prev
|
|
1161
|
+
prev = getNodeProperty(prev, "previousSibling");
|
|
1152
1162
|
}
|
|
1153
1163
|
} catch {
|
|
1154
1164
|
}
|
|
@@ -1185,8 +1195,12 @@ function extractParameterNames(node) {
|
|
|
1185
1195
|
const params = [];
|
|
1186
1196
|
const candidates = [
|
|
1187
1197
|
// common field name
|
|
1188
|
-
node
|
|
1189
|
-
|
|
1198
|
+
getNodeProperty(node, "childForFieldName") ? getNodeProperty(node, "childForFieldName")?.childForFieldName?.(
|
|
1199
|
+
"parameters"
|
|
1200
|
+
) ?? null : null,
|
|
1201
|
+
getNodeProperty(node, "childForFieldName") ? getNodeProperty(node, "childForFieldName")?.childForFieldName?.(
|
|
1202
|
+
"parameter_list"
|
|
1203
|
+
) ?? null : null,
|
|
1190
1204
|
node.children.find((c) => c.type === "parameter_list") || null,
|
|
1191
1205
|
node.children.find((c) => c.type === "parameters") || null,
|
|
1192
1206
|
node.children.find((c) => c.type === "formal_parameters") || null,
|
|
@@ -1196,7 +1210,9 @@ function extractParameterNames(node) {
|
|
|
1196
1210
|
if (!list) return params;
|
|
1197
1211
|
for (const child of list.children) {
|
|
1198
1212
|
if (!child) continue;
|
|
1199
|
-
const id = child
|
|
1213
|
+
const id = getNodeProperty(child, "childForFieldName")?.childForFieldName?.(
|
|
1214
|
+
"name"
|
|
1215
|
+
) || child.children.find(
|
|
1200
1216
|
(c) => [
|
|
1201
1217
|
"identifier",
|
|
1202
1218
|
"variable_name",
|
|
@@ -1648,11 +1664,17 @@ var init_csharp_parser = __esm({
|
|
|
1648
1664
|
const isPublic = modifiers.includes("public") || modifiers.includes("protected");
|
|
1649
1665
|
if (isPublic) {
|
|
1650
1666
|
const metadata = this.analyzeMetadata(node, code);
|
|
1651
|
-
const
|
|
1667
|
+
const nodeType = node.type.replace("_declaration", "");
|
|
1668
|
+
let exportType = "class";
|
|
1669
|
+
if (nodeType === "record" || nodeType === "struct" || nodeType === "enum") {
|
|
1670
|
+
exportType = "class";
|
|
1671
|
+
} else if (nodeType === "interface" || nodeType === "interface_declaration") {
|
|
1672
|
+
exportType = "interface";
|
|
1673
|
+
}
|
|
1652
1674
|
const fullName = nextClass ? `${nextClass}.${nameNode.text}` : nextNamespace ? `${nextNamespace}.${nameNode.text}` : nameNode.text;
|
|
1653
|
-
|
|
1675
|
+
const exportItem = {
|
|
1654
1676
|
name: fullName,
|
|
1655
|
-
type:
|
|
1677
|
+
type: exportType,
|
|
1656
1678
|
loc: {
|
|
1657
1679
|
start: {
|
|
1658
1680
|
line: node.startPosition.row + 1,
|
|
@@ -1665,7 +1687,8 @@ var init_csharp_parser = __esm({
|
|
|
1665
1687
|
},
|
|
1666
1688
|
visibility: modifiers.includes("public") ? "public" : "protected",
|
|
1667
1689
|
...metadata
|
|
1668
|
-
}
|
|
1690
|
+
};
|
|
1691
|
+
exports2.push(exportItem);
|
|
1669
1692
|
nextClass = fullName;
|
|
1670
1693
|
}
|
|
1671
1694
|
}
|
|
@@ -1676,9 +1699,9 @@ var init_csharp_parser = __esm({
|
|
|
1676
1699
|
const isPublic = modifiers.includes("public") || modifiers.includes("protected");
|
|
1677
1700
|
if (isPublic) {
|
|
1678
1701
|
const metadata = this.analyzeMetadata(node, code);
|
|
1679
|
-
|
|
1702
|
+
const methodItem = {
|
|
1680
1703
|
name: nameNode.text,
|
|
1681
|
-
type: node.type === "method_declaration" ? "function" : "
|
|
1704
|
+
type: node.type === "method_declaration" ? "function" : "variable",
|
|
1682
1705
|
parentClass: currentClass,
|
|
1683
1706
|
loc: {
|
|
1684
1707
|
start: {
|
|
@@ -1693,7 +1716,8 @@ var init_csharp_parser = __esm({
|
|
|
1693
1716
|
visibility: modifiers.includes("public") ? "public" : "protected",
|
|
1694
1717
|
parameters: node.type === "method_declaration" ? this.extractParameters(node) : void 0,
|
|
1695
1718
|
...metadata
|
|
1696
|
-
}
|
|
1719
|
+
};
|
|
1720
|
+
exports2.push(methodItem);
|
|
1697
1721
|
}
|
|
1698
1722
|
}
|
|
1699
1723
|
}
|
|
@@ -3536,7 +3560,7 @@ function extractExportsWithDependencies(ast, fileImports) {
|
|
|
3536
3560
|
type: "default",
|
|
3537
3561
|
imports: usedImports,
|
|
3538
3562
|
dependencies: [],
|
|
3539
|
-
typeReferences,
|
|
3563
|
+
typeReferences: [],
|
|
3540
3564
|
loc: node.loc
|
|
3541
3565
|
});
|
|
3542
3566
|
} else if (node.type === "ExportAllDeclaration") {
|
|
@@ -3585,6 +3609,7 @@ function findUsedImports(node, importedNames) {
|
|
|
3585
3609
|
usedImports.add(n.name);
|
|
3586
3610
|
}
|
|
3587
3611
|
for (const key in n) {
|
|
3612
|
+
if (key === "parent") continue;
|
|
3588
3613
|
const value = n[key];
|
|
3589
3614
|
if (value && typeof value === "object") {
|
|
3590
3615
|
if (Array.isArray(value)) {
|
|
@@ -3628,6 +3653,7 @@ function extractTypeReferences(node) {
|
|
|
3628
3653
|
}
|
|
3629
3654
|
}
|
|
3630
3655
|
for (const key of Object.keys(n)) {
|
|
3656
|
+
if (key === "parent") continue;
|
|
3631
3657
|
const value = n[key];
|
|
3632
3658
|
if (Array.isArray(value)) {
|
|
3633
3659
|
value.forEach(visit);
|
|
@@ -3992,65 +4018,146 @@ var REPORT_STYLES = `
|
|
|
3992
4018
|
`;
|
|
3993
4019
|
|
|
3994
4020
|
// src/utils/report-formatters.ts
|
|
4021
|
+
var REPORT_CONSTANTS = {
|
|
4022
|
+
TAGS: {
|
|
4023
|
+
HTML: "html",
|
|
4024
|
+
HEAD: "head",
|
|
4025
|
+
BODY: "body",
|
|
4026
|
+
TITLE: "title",
|
|
4027
|
+
STYLE: "style",
|
|
4028
|
+
META: "meta",
|
|
4029
|
+
DIV: "div",
|
|
4030
|
+
H1: "h1",
|
|
4031
|
+
H2: "h2",
|
|
4032
|
+
P: "p",
|
|
4033
|
+
SPAN: "span",
|
|
4034
|
+
STRONG: "strong",
|
|
4035
|
+
A: "a",
|
|
4036
|
+
TABLE: "table",
|
|
4037
|
+
THEAD: "thead",
|
|
4038
|
+
TBODY: "tbody",
|
|
4039
|
+
TR: "tr",
|
|
4040
|
+
TH: "th",
|
|
4041
|
+
TD: "td"
|
|
4042
|
+
},
|
|
4043
|
+
ATTRS: {
|
|
4044
|
+
LANG: "lang",
|
|
4045
|
+
CHARSET: "charset",
|
|
4046
|
+
NAME: "name",
|
|
4047
|
+
CONTENT: "content",
|
|
4048
|
+
VIEWPORT: "viewport",
|
|
4049
|
+
VIEWPORT_VAL: "width=device-width, initial-scale=1.0",
|
|
4050
|
+
UTF8: "UTF-8",
|
|
4051
|
+
EN: "en",
|
|
4052
|
+
CLASS: "class",
|
|
4053
|
+
STYLE: "style",
|
|
4054
|
+
HREF: "href"
|
|
4055
|
+
},
|
|
4056
|
+
CLASSES: {
|
|
4057
|
+
HERO: "hero",
|
|
4058
|
+
STAT_CARD: "stat-card",
|
|
4059
|
+
STAT_VALUE: "stat-value",
|
|
4060
|
+
STAT_LABEL: "stat-label",
|
|
4061
|
+
STATS: "stats",
|
|
4062
|
+
CARD: "card",
|
|
4063
|
+
CRITICAL: "critical",
|
|
4064
|
+
MAJOR: "major",
|
|
4065
|
+
MINOR: "minor",
|
|
4066
|
+
FOOTER: "footer",
|
|
4067
|
+
SCORE_CARD: "score-card",
|
|
4068
|
+
SCORE_VALUE: "score-value",
|
|
4069
|
+
SCORE_LABEL: "score-label"
|
|
4070
|
+
}
|
|
4071
|
+
};
|
|
3995
4072
|
function tag(name, content = "", attrs = {}) {
|
|
3996
4073
|
const attrStr = Object.entries(attrs).map(([k, v]) => ` ${k}="${v}"`).join("");
|
|
3997
4074
|
return `<${name}${attrStr}>${content}</${name}>`;
|
|
3998
4075
|
}
|
|
3999
4076
|
function generateReportHead(title, styles = REPORT_STYLES) {
|
|
4077
|
+
const metaCharset = tag("", "", {
|
|
4078
|
+
[REPORT_CONSTANTS.ATTRS.CHARSET]: REPORT_CONSTANTS.ATTRS.UTF8
|
|
4079
|
+
}).replace(/^<|>/g, "");
|
|
4080
|
+
const metaViewport = tag("", "", {
|
|
4081
|
+
[REPORT_CONSTANTS.ATTRS.NAME]: REPORT_CONSTANTS.ATTRS.VIEWPORT,
|
|
4082
|
+
[REPORT_CONSTANTS.ATTRS.CONTENT]: REPORT_CONSTANTS.ATTRS.VIEWPORT_VAL
|
|
4083
|
+
}).replace(/^<|>/g, "");
|
|
4000
4084
|
return `<!DOCTYPE html>
|
|
4001
|
-
|
|
4002
|
-
|
|
4003
|
-
<meta
|
|
4004
|
-
<meta
|
|
4005
|
-
${tag(
|
|
4006
|
-
${tag(
|
|
4007
|
-
|
|
4085
|
+
<${REPORT_CONSTANTS.TAGS.HTML} ${REPORT_CONSTANTS.ATTRS.LANG}="${REPORT_CONSTANTS.ATTRS.EN}">
|
|
4086
|
+
<${REPORT_CONSTANTS.TAGS.HEAD}>
|
|
4087
|
+
<meta ${metaCharset}>
|
|
4088
|
+
<meta ${metaViewport}>
|
|
4089
|
+
${tag(REPORT_CONSTANTS.TAGS.TITLE, title)}
|
|
4090
|
+
${tag(REPORT_CONSTANTS.TAGS.STYLE, styles)}
|
|
4091
|
+
</${REPORT_CONSTANTS.TAGS.HEAD}>`;
|
|
4008
4092
|
}
|
|
4009
4093
|
function generateReportHero(title, subtitle) {
|
|
4010
|
-
return tag(
|
|
4011
|
-
|
|
4012
|
-
|
|
4094
|
+
return tag(
|
|
4095
|
+
REPORT_CONSTANTS.TAGS.DIV,
|
|
4096
|
+
tag(REPORT_CONSTANTS.TAGS.H1, title) + (subtitle ? tag(REPORT_CONSTANTS.TAGS.P, subtitle) : ""),
|
|
4097
|
+
{
|
|
4098
|
+
[REPORT_CONSTANTS.ATTRS.CLASS]: REPORT_CONSTANTS.CLASSES.HERO
|
|
4099
|
+
}
|
|
4100
|
+
);
|
|
4013
4101
|
}
|
|
4014
4102
|
function generateStatCards(cards) {
|
|
4015
4103
|
const cardsHtml = cards.map(
|
|
4016
4104
|
(c) => tag(
|
|
4017
|
-
|
|
4018
|
-
tag(
|
|
4019
|
-
|
|
4020
|
-
...c.color ? {
|
|
4021
|
-
}) + tag(
|
|
4022
|
-
|
|
4105
|
+
REPORT_CONSTANTS.TAGS.DIV,
|
|
4106
|
+
tag(REPORT_CONSTANTS.TAGS.DIV, String(c.value), {
|
|
4107
|
+
[REPORT_CONSTANTS.ATTRS.CLASS]: REPORT_CONSTANTS.CLASSES.STAT_VALUE,
|
|
4108
|
+
...c.color ? { [REPORT_CONSTANTS.ATTRS.STYLE]: `color: ${c.color}` } : {}
|
|
4109
|
+
}) + tag(REPORT_CONSTANTS.TAGS.DIV, c.label, {
|
|
4110
|
+
[REPORT_CONSTANTS.ATTRS.CLASS]: REPORT_CONSTANTS.CLASSES.STAT_LABEL
|
|
4111
|
+
}),
|
|
4112
|
+
{ [REPORT_CONSTANTS.ATTRS.CLASS]: REPORT_CONSTANTS.CLASSES.STAT_CARD }
|
|
4023
4113
|
)
|
|
4024
4114
|
).join("");
|
|
4025
|
-
return tag(
|
|
4115
|
+
return tag(REPORT_CONSTANTS.TAGS.DIV, cardsHtml, {
|
|
4116
|
+
[REPORT_CONSTANTS.ATTRS.CLASS]: REPORT_CONSTANTS.CLASSES.STATS
|
|
4117
|
+
});
|
|
4026
4118
|
}
|
|
4027
4119
|
function generateTable(config) {
|
|
4028
4120
|
const head = tag(
|
|
4029
|
-
|
|
4030
|
-
tag(
|
|
4121
|
+
REPORT_CONSTANTS.TAGS.THEAD,
|
|
4122
|
+
tag(
|
|
4123
|
+
REPORT_CONSTANTS.TAGS.TR,
|
|
4124
|
+
config.headers.map((h) => tag(REPORT_CONSTANTS.TAGS.TH, h)).join("")
|
|
4125
|
+
)
|
|
4031
4126
|
);
|
|
4032
4127
|
const body = tag(
|
|
4033
|
-
|
|
4128
|
+
REPORT_CONSTANTS.TAGS.TBODY,
|
|
4034
4129
|
config.rows.map(
|
|
4035
|
-
(row) => tag(
|
|
4130
|
+
(row) => tag(
|
|
4131
|
+
REPORT_CONSTANTS.TAGS.TR,
|
|
4132
|
+
row.map((cell) => tag(REPORT_CONSTANTS.TAGS.TD, cell)).join("")
|
|
4133
|
+
)
|
|
4036
4134
|
).join("")
|
|
4037
4135
|
);
|
|
4038
|
-
return tag(
|
|
4136
|
+
return tag(REPORT_CONSTANTS.TAGS.TABLE, head + body);
|
|
4039
4137
|
}
|
|
4040
4138
|
function generateIssueSummary(crit, maj, min, savings) {
|
|
4041
4139
|
const details = [
|
|
4042
|
-
tag(
|
|
4043
|
-
|
|
4044
|
-
|
|
4140
|
+
tag(REPORT_CONSTANTS.TAGS.SPAN, `\u{1F534} Critical: ${crit}`, {
|
|
4141
|
+
[REPORT_CONSTANTS.ATTRS.CLASS]: REPORT_CONSTANTS.CLASSES.CRITICAL
|
|
4142
|
+
}),
|
|
4143
|
+
tag(REPORT_CONSTANTS.TAGS.SPAN, `\u{1F7E1} Major: ${maj}`, {
|
|
4144
|
+
[REPORT_CONSTANTS.ATTRS.CLASS]: REPORT_CONSTANTS.CLASSES.MAJOR
|
|
4145
|
+
}),
|
|
4146
|
+
tag(REPORT_CONSTANTS.TAGS.SPAN, `\u{1F535} Minor: ${min}`, {
|
|
4147
|
+
[REPORT_CONSTANTS.ATTRS.CLASS]: REPORT_CONSTANTS.CLASSES.MINOR
|
|
4148
|
+
})
|
|
4045
4149
|
].join(" ");
|
|
4046
4150
|
const savingsHtml = savings ? tag(
|
|
4047
|
-
|
|
4048
|
-
tag(
|
|
4151
|
+
REPORT_CONSTANTS.TAGS.P,
|
|
4152
|
+
tag(REPORT_CONSTANTS.TAGS.STRONG, "Potential Savings: ") + savings.toLocaleString() + " tokens"
|
|
4049
4153
|
) : "";
|
|
4050
4154
|
return tag(
|
|
4051
|
-
|
|
4052
|
-
tag(
|
|
4053
|
-
{
|
|
4155
|
+
REPORT_CONSTANTS.TAGS.DIV,
|
|
4156
|
+
tag(REPORT_CONSTANTS.TAGS.H2, "\u26A0\uFE0F Issues Summary") + tag(REPORT_CONSTANTS.TAGS.P, details) + savingsHtml,
|
|
4157
|
+
{
|
|
4158
|
+
[REPORT_CONSTANTS.ATTRS.CLASS]: REPORT_CONSTANTS.CLASSES.CARD,
|
|
4159
|
+
[REPORT_CONSTANTS.ATTRS.STYLE]: "margin-bottom: 30px;"
|
|
4160
|
+
}
|
|
4054
4161
|
);
|
|
4055
4162
|
}
|
|
4056
4163
|
function generateReportFooter(options) {
|
|
@@ -4059,33 +4166,41 @@ function generateReportFooter(options) {
|
|
|
4059
4166
|
if (options.packageUrl)
|
|
4060
4167
|
links.push(
|
|
4061
4168
|
tag(
|
|
4062
|
-
|
|
4063
|
-
`Like AIReady? ${tag(
|
|
4169
|
+
REPORT_CONSTANTS.TAGS.P,
|
|
4170
|
+
`Like AIReady? ${tag(REPORT_CONSTANTS.TAGS.A, "Star us on GitHub", {
|
|
4171
|
+
[REPORT_CONSTANTS.ATTRS.HREF]: options.packageUrl
|
|
4172
|
+
})}`
|
|
4064
4173
|
)
|
|
4065
4174
|
);
|
|
4066
4175
|
if (options.bugUrl)
|
|
4067
4176
|
links.push(
|
|
4068
4177
|
tag(
|
|
4069
|
-
|
|
4070
|
-
`Like AIReady? ${tag(
|
|
4178
|
+
REPORT_CONSTANTS.TAGS.P,
|
|
4179
|
+
`Like AIReady? ${tag(REPORT_CONSTANTS.TAGS.A, "Report it here", {
|
|
4180
|
+
[REPORT_CONSTANTS.ATTRS.HREF]: options.bugUrl
|
|
4181
|
+
})}`
|
|
4071
4182
|
)
|
|
4072
4183
|
);
|
|
4073
4184
|
return tag(
|
|
4074
|
-
|
|
4185
|
+
REPORT_CONSTANTS.TAGS.DIV,
|
|
4075
4186
|
tag(
|
|
4076
|
-
|
|
4077
|
-
`Generated by ${tag(
|
|
4187
|
+
REPORT_CONSTANTS.TAGS.P,
|
|
4188
|
+
`Generated by ${tag(REPORT_CONSTANTS.TAGS.STRONG, "@aiready/" + options.packageName)}` + version
|
|
4078
4189
|
) + links.join(""),
|
|
4079
|
-
{
|
|
4190
|
+
{ [REPORT_CONSTANTS.ATTRS.CLASS]: REPORT_CONSTANTS.CLASSES.FOOTER }
|
|
4080
4191
|
);
|
|
4081
4192
|
}
|
|
4082
4193
|
function wrapInCard(content, title) {
|
|
4083
|
-
return tag(
|
|
4084
|
-
|
|
4085
|
-
|
|
4194
|
+
return tag(
|
|
4195
|
+
REPORT_CONSTANTS.TAGS.DIV,
|
|
4196
|
+
(title ? tag(REPORT_CONSTANTS.TAGS.H2, title) : "") + content,
|
|
4197
|
+
{
|
|
4198
|
+
[REPORT_CONSTANTS.ATTRS.CLASS]: REPORT_CONSTANTS.CLASSES.CARD
|
|
4199
|
+
}
|
|
4200
|
+
);
|
|
4086
4201
|
}
|
|
4087
4202
|
function generateCompleteReport(options, body) {
|
|
4088
|
-
return generateReportHead(options.title) + tag(
|
|
4203
|
+
return generateReportHead(options.title) + tag(REPORT_CONSTANTS.TAGS.BODY, body + generateReportFooter(options));
|
|
4089
4204
|
}
|
|
4090
4205
|
function generateStandardHtmlReport(options, stats, sections, score) {
|
|
4091
4206
|
const hero = generateReportHero(
|
|
@@ -4093,9 +4208,13 @@ function generateStandardHtmlReport(options, stats, sections, score) {
|
|
|
4093
4208
|
`Generated on ${(/* @__PURE__ */ new Date()).toLocaleString()}`
|
|
4094
4209
|
);
|
|
4095
4210
|
const scoreCard = score ? tag(
|
|
4096
|
-
|
|
4097
|
-
tag(
|
|
4098
|
-
|
|
4211
|
+
REPORT_CONSTANTS.TAGS.DIV,
|
|
4212
|
+
tag(REPORT_CONSTANTS.TAGS.DIV, String(score.value), {
|
|
4213
|
+
[REPORT_CONSTANTS.ATTRS.CLASS]: REPORT_CONSTANTS.CLASSES.SCORE_VALUE
|
|
4214
|
+
}) + tag(REPORT_CONSTANTS.TAGS.DIV, score.label, {
|
|
4215
|
+
[REPORT_CONSTANTS.ATTRS.CLASS]: REPORT_CONSTANTS.CLASSES.SCORE_LABEL
|
|
4216
|
+
}),
|
|
4217
|
+
{ [REPORT_CONSTANTS.ATTRS.CLASS]: REPORT_CONSTANTS.CLASSES.SCORE_CARD }
|
|
4099
4218
|
) : "";
|
|
4100
4219
|
const statsCards = generateStatCards(stats);
|
|
4101
4220
|
const bodyContent = `
|
|
@@ -4195,6 +4314,31 @@ var RecommendationPriority = /* @__PURE__ */ ((RecommendationPriority2) => {
|
|
|
4195
4314
|
})(RecommendationPriority || {});
|
|
4196
4315
|
|
|
4197
4316
|
// src/scoring.ts
|
|
4317
|
+
var SCORING_CONSTANTS = {
|
|
4318
|
+
WEIGHTS: {
|
|
4319
|
+
DEFAULT: 5,
|
|
4320
|
+
MAX: 100
|
|
4321
|
+
},
|
|
4322
|
+
THRESHOLDS: {
|
|
4323
|
+
XS: 80,
|
|
4324
|
+
SMALL: 75,
|
|
4325
|
+
MEDIUM: 70,
|
|
4326
|
+
LARGE: 65,
|
|
4327
|
+
ENTERPRISE: 58,
|
|
4328
|
+
NORMALIZATION_OFFSET: 70
|
|
4329
|
+
},
|
|
4330
|
+
FILE_COUNTS: {
|
|
4331
|
+
XS: 50,
|
|
4332
|
+
SMALL: 200,
|
|
4333
|
+
MEDIUM: 500,
|
|
4334
|
+
LARGE: 2e3
|
|
4335
|
+
},
|
|
4336
|
+
DELIMITERS: {
|
|
4337
|
+
LIST: ",",
|
|
4338
|
+
PAIR: ":",
|
|
4339
|
+
FORMULA_JOIN: " + "
|
|
4340
|
+
}
|
|
4341
|
+
};
|
|
4198
4342
|
var DEFAULT_TOOL_WEIGHTS = {
|
|
4199
4343
|
["pattern-detect" /* PatternDetect */]: 22,
|
|
4200
4344
|
["context-analyzer" /* ContextAnalyzer */]: 19,
|
|
@@ -4282,22 +4426,22 @@ var CONTEXT_TIER_THRESHOLDS = {
|
|
|
4282
4426
|
frontier: { idealTokens: 5e4, criticalTokens: 15e4, idealDepth: 10 }
|
|
4283
4427
|
};
|
|
4284
4428
|
var SIZE_ADJUSTED_THRESHOLDS = {
|
|
4285
|
-
xs:
|
|
4429
|
+
xs: SCORING_CONSTANTS.THRESHOLDS.XS,
|
|
4286
4430
|
// < 50 files
|
|
4287
|
-
small:
|
|
4431
|
+
small: SCORING_CONSTANTS.THRESHOLDS.SMALL,
|
|
4288
4432
|
// 50-200 files
|
|
4289
|
-
medium:
|
|
4433
|
+
medium: SCORING_CONSTANTS.THRESHOLDS.MEDIUM,
|
|
4290
4434
|
// 200-500 files
|
|
4291
|
-
large:
|
|
4435
|
+
large: SCORING_CONSTANTS.THRESHOLDS.LARGE,
|
|
4292
4436
|
// 500-2000 files
|
|
4293
|
-
enterprise:
|
|
4437
|
+
enterprise: SCORING_CONSTANTS.THRESHOLDS.ENTERPRISE
|
|
4294
4438
|
// 2000+ files
|
|
4295
4439
|
};
|
|
4296
4440
|
function getProjectSizeTier(fileCount) {
|
|
4297
|
-
if (fileCount <
|
|
4298
|
-
if (fileCount <
|
|
4299
|
-
if (fileCount <
|
|
4300
|
-
if (fileCount <
|
|
4441
|
+
if (fileCount < SCORING_CONSTANTS.FILE_COUNTS.XS) return "xs";
|
|
4442
|
+
if (fileCount < SCORING_CONSTANTS.FILE_COUNTS.SMALL) return "small";
|
|
4443
|
+
if (fileCount < SCORING_CONSTANTS.FILE_COUNTS.MEDIUM) return "medium";
|
|
4444
|
+
if (fileCount < SCORING_CONSTANTS.FILE_COUNTS.LARGE) return "large";
|
|
4301
4445
|
return "enterprise";
|
|
4302
4446
|
}
|
|
4303
4447
|
function getRecommendedThreshold(fileCount, modelTier = "standard") {
|
|
@@ -4313,14 +4457,16 @@ function getToolWeight(toolName, toolConfig, cliOverride, profile = "default" /*
|
|
|
4313
4457
|
if (cliOverride !== void 0) return cliOverride;
|
|
4314
4458
|
if (toolConfig?.scoreWeight !== void 0) return toolConfig.scoreWeight;
|
|
4315
4459
|
const profileWeights = SCORING_PROFILES[profile] ?? DEFAULT_TOOL_WEIGHTS;
|
|
4316
|
-
return profileWeights[toolName] ?? DEFAULT_TOOL_WEIGHTS[toolName] ??
|
|
4460
|
+
return profileWeights[toolName] ?? DEFAULT_TOOL_WEIGHTS[toolName] ?? SCORING_CONSTANTS.WEIGHTS.DEFAULT;
|
|
4317
4461
|
}
|
|
4318
4462
|
function parseWeightString(weightStr) {
|
|
4319
4463
|
const weights = /* @__PURE__ */ new Map();
|
|
4320
4464
|
if (!weightStr) return weights;
|
|
4321
|
-
const pairs = weightStr.split(
|
|
4465
|
+
const pairs = weightStr.split(SCORING_CONSTANTS.DELIMITERS.LIST);
|
|
4322
4466
|
for (const pair of pairs) {
|
|
4323
|
-
const [toolShortName, weightValueStr] = pair.split(
|
|
4467
|
+
const [toolShortName, weightValueStr] = pair.split(
|
|
4468
|
+
SCORING_CONSTANTS.DELIMITERS.PAIR
|
|
4469
|
+
);
|
|
4324
4470
|
if (toolShortName && weightValueStr) {
|
|
4325
4471
|
const toolName = normalizeToolName(toolShortName.trim());
|
|
4326
4472
|
const weight = parseInt(weightValueStr.trim(), 10);
|
|
@@ -4335,7 +4481,7 @@ function calculateOverallScore(toolOutputs, config, cliWeights) {
|
|
|
4335
4481
|
if (toolOutputs.size === 0) {
|
|
4336
4482
|
throw new Error("No tool outputs provided for scoring");
|
|
4337
4483
|
}
|
|
4338
|
-
const profile = config?.
|
|
4484
|
+
const profile = config?.profile || "default" /* Default */;
|
|
4339
4485
|
const weights = /* @__PURE__ */ new Map();
|
|
4340
4486
|
for (const [toolName] of toolOutputs.entries()) {
|
|
4341
4487
|
const cliWeight = cliWeights?.get(toolName);
|
|
@@ -4349,7 +4495,7 @@ function calculateOverallScore(toolOutputs, config, cliWeights) {
|
|
|
4349
4495
|
const toolsUsed = [];
|
|
4350
4496
|
const calculationWeights = {};
|
|
4351
4497
|
for (const [toolName, output] of toolOutputs.entries()) {
|
|
4352
|
-
const weight = weights.get(toolName) ??
|
|
4498
|
+
const weight = weights.get(toolName) ?? SCORING_CONSTANTS.WEIGHTS.DEFAULT;
|
|
4353
4499
|
weightedSum += output.score * weight;
|
|
4354
4500
|
totalWeight += weight;
|
|
4355
4501
|
toolsUsed.push(toolName);
|
|
@@ -4360,11 +4506,11 @@ function calculateOverallScore(toolOutputs, config, cliWeights) {
|
|
|
4360
4506
|
const rating = getRating(overall);
|
|
4361
4507
|
const formulaParts = Array.from(toolOutputs.entries()).map(
|
|
4362
4508
|
([name, output]) => {
|
|
4363
|
-
const weight = weights.get(name) ??
|
|
4509
|
+
const weight = weights.get(name) ?? SCORING_CONSTANTS.WEIGHTS.DEFAULT;
|
|
4364
4510
|
return `(${output.score} \xD7 ${weight})`;
|
|
4365
4511
|
}
|
|
4366
4512
|
);
|
|
4367
|
-
const formulaStr = `[${formulaParts.join(
|
|
4513
|
+
const formulaStr = `[${formulaParts.join(SCORING_CONSTANTS.DELIMITERS.FORMULA_JOIN)}] / ${totalWeight} = ${overall}`;
|
|
4368
4514
|
return {
|
|
4369
4515
|
overall,
|
|
4370
4516
|
rating,
|
|
@@ -4380,7 +4526,7 @@ function calculateOverallScore(toolOutputs, config, cliWeights) {
|
|
|
4380
4526
|
}
|
|
4381
4527
|
function getRatingWithContext(score, fileCount, modelTier = "standard") {
|
|
4382
4528
|
const threshold = getRecommendedThreshold(fileCount, modelTier);
|
|
4383
|
-
const normalized = score - threshold +
|
|
4529
|
+
const normalized = score - threshold + SCORING_CONSTANTS.THRESHOLDS.NORMALIZATION_OFFSET;
|
|
4384
4530
|
return getRating(normalized);
|
|
4385
4531
|
}
|
|
4386
4532
|
function getRatingDisplay(rating) {
|
|
@@ -4450,22 +4596,22 @@ function buildFactorsFromDimensions(dimensions, dimensionNames, rawData) {
|
|
|
4450
4596
|
}
|
|
4451
4597
|
function formatDimensionDescription(key, rawData) {
|
|
4452
4598
|
if (key === "testCoverageRatio" && rawData.testFiles !== void 0) {
|
|
4453
|
-
return `${rawData.testFiles} test files / ${rawData.sourceFiles} source files`;
|
|
4599
|
+
return `${String(rawData.testFiles)} test files / ${String(rawData.sourceFiles)} source files`;
|
|
4454
4600
|
}
|
|
4455
4601
|
if (key === "purityScore" && rawData.pureFunctions !== void 0) {
|
|
4456
|
-
return `${rawData.pureFunctions}/${rawData.totalFunctions} functions are pure`;
|
|
4602
|
+
return `${String(rawData.pureFunctions)}/${String(rawData.totalFunctions)} functions are pure`;
|
|
4457
4603
|
}
|
|
4458
4604
|
if (key === "dependencyInjectionScore" && rawData.injectionPatterns !== void 0) {
|
|
4459
|
-
return `${rawData.injectionPatterns}/${rawData.totalClasses} classes use DI`;
|
|
4605
|
+
return `${String(rawData.injectionPatterns)}/${String(rawData.totalClasses)} classes use DI`;
|
|
4460
4606
|
}
|
|
4461
4607
|
if (key === "structureClarityScore" && rawData.deepDirectories !== void 0) {
|
|
4462
|
-
return `${rawData.deepDirectories} of ${rawData.totalDirectories} dirs exceed recommended depth`;
|
|
4608
|
+
return `${String(rawData.deepDirectories)} of ${String(rawData.totalDirectories)} dirs exceed recommended depth`;
|
|
4463
4609
|
}
|
|
4464
4610
|
if (key === "apiClarityScore" && rawData.untypedExports !== void 0) {
|
|
4465
|
-
return `${rawData.untypedExports} of ${rawData.totalExports} exports lack type annotations`;
|
|
4611
|
+
return `${String(rawData.untypedExports)} of ${String(rawData.totalExports)} exports lack type annotations`;
|
|
4466
4612
|
}
|
|
4467
4613
|
if (key === "graphStabilityScore") {
|
|
4468
|
-
return `${rawData.score}/100`;
|
|
4614
|
+
return `${String(rawData.score)}/100`;
|
|
4469
4615
|
}
|
|
4470
4616
|
return void 0;
|
|
4471
4617
|
}
|
|
@@ -4503,7 +4649,7 @@ function buildStandardToolScore(params) {
|
|
|
4503
4649
|
score,
|
|
4504
4650
|
rawMetrics: {
|
|
4505
4651
|
...rawData,
|
|
4506
|
-
rating: rating || rawData.rating
|
|
4652
|
+
rating: rating || String(rawData.rating)
|
|
4507
4653
|
},
|
|
4508
4654
|
factors,
|
|
4509
4655
|
recommendations: recs
|