@aiready/core 0.24.4 → 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 +272 -114
- 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
|
}
|
|
@@ -771,7 +777,9 @@ var init_python_parser = __esm({
|
|
|
771
777
|
}
|
|
772
778
|
});
|
|
773
779
|
} else if (child.type === PYTHON_CONSTANTS.NODES.ALIASED_IMPORT) {
|
|
774
|
-
const nameNode = child.childForFieldName(
|
|
780
|
+
const nameNode = child.childForFieldName(
|
|
781
|
+
PYTHON_CONSTANTS.FIELDS.NAME
|
|
782
|
+
);
|
|
775
783
|
if (nameNode) {
|
|
776
784
|
const source = nameNode.text;
|
|
777
785
|
imports.push({
|
|
@@ -792,7 +800,9 @@ var init_python_parser = __esm({
|
|
|
792
800
|
}
|
|
793
801
|
}
|
|
794
802
|
} else if (node.type === PYTHON_CONSTANTS.NODES.IMPORT_FROM_STATEMENT) {
|
|
795
|
-
const moduleNameNode = node.childForFieldName(
|
|
803
|
+
const moduleNameNode = node.childForFieldName(
|
|
804
|
+
PYTHON_CONSTANTS.FIELDS.MODULE_NAME
|
|
805
|
+
);
|
|
796
806
|
if (moduleNameNode) {
|
|
797
807
|
const source = moduleNameNode.text;
|
|
798
808
|
const specifiers = [];
|
|
@@ -800,7 +810,9 @@ var init_python_parser = __esm({
|
|
|
800
810
|
if (child.type === PYTHON_CONSTANTS.NODES.DOTTED_NAME && child !== moduleNameNode) {
|
|
801
811
|
specifiers.push(child.text);
|
|
802
812
|
} else if (child.type === PYTHON_CONSTANTS.NODES.ALIASED_IMPORT) {
|
|
803
|
-
const nameNode = child.childForFieldName(
|
|
813
|
+
const nameNode = child.childForFieldName(
|
|
814
|
+
PYTHON_CONSTANTS.FIELDS.NAME
|
|
815
|
+
);
|
|
804
816
|
if (nameNode) specifiers.push(nameNode.text);
|
|
805
817
|
} else if (child.type === PYTHON_CONSTANTS.NODES.WILDCARD_IMPORT) {
|
|
806
818
|
specifiers.push(PYTHON_CONSTANTS.SPECIAL.WILDCARD);
|
|
@@ -884,7 +896,9 @@ var init_python_parser = __esm({
|
|
|
884
896
|
} else if (node.type === PYTHON_CONSTANTS.NODES.EXPRESSION_STATEMENT) {
|
|
885
897
|
const assignment = node.firstChild;
|
|
886
898
|
if (assignment && assignment.type === PYTHON_CONSTANTS.NODES.ASSIGNMENT) {
|
|
887
|
-
const left = assignment.childForFieldName(
|
|
899
|
+
const left = assignment.childForFieldName(
|
|
900
|
+
PYTHON_CONSTANTS.FIELDS.LEFT
|
|
901
|
+
);
|
|
888
902
|
if (left && left.type === PYTHON_CONSTANTS.NODES.IDENTIFIER) {
|
|
889
903
|
const name = left.text;
|
|
890
904
|
const isInternal = name === PYTHON_CONSTANTS.SPECIAL.DUNDER_ALL || name === PYTHON_CONSTANTS.SPECIAL.DUNDER_VERSION || name === PYTHON_CONSTANTS.SPECIAL.DUNDER_AUTHOR;
|
|
@@ -915,16 +929,15 @@ var init_python_parser = __esm({
|
|
|
915
929
|
* Extract parameter names from a function definition node.
|
|
916
930
|
*/
|
|
917
931
|
extractParameters(node) {
|
|
918
|
-
const paramsNode = node.childForFieldName(
|
|
932
|
+
const paramsNode = node.childForFieldName(
|
|
933
|
+
PYTHON_CONSTANTS.FIELDS.PARAMETERS
|
|
934
|
+
);
|
|
919
935
|
if (!paramsNode) return [];
|
|
920
936
|
return paramsNode.children.filter(
|
|
921
937
|
(c) => c.type === PYTHON_CONSTANTS.NODES.IDENTIFIER || c.type === PYTHON_CONSTANTS.NODES.TYPED_PARAMETER || c.type === PYTHON_CONSTANTS.NODES.DEFAULT_PARAMETER
|
|
922
938
|
).map((c) => {
|
|
923
939
|
if (c.type === PYTHON_CONSTANTS.NODES.IDENTIFIER) return c.text;
|
|
924
|
-
|
|
925
|
-
return c.firstChild?.text || "unknown";
|
|
926
|
-
}
|
|
927
|
-
return "unknown";
|
|
940
|
+
return c.firstChild?.text || "unknown";
|
|
928
941
|
});
|
|
929
942
|
}
|
|
930
943
|
/**
|
|
@@ -943,8 +956,13 @@ var init_python_parser = __esm({
|
|
|
943
956
|
]
|
|
944
957
|
};
|
|
945
958
|
} catch (error) {
|
|
946
|
-
const
|
|
947
|
-
wrapper
|
|
959
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
960
|
+
const wrapper = new Error(
|
|
961
|
+
`Failed to parse Python file ${filePath}: ${message}`
|
|
962
|
+
);
|
|
963
|
+
if (error instanceof Error) {
|
|
964
|
+
wrapper.cause = error;
|
|
965
|
+
}
|
|
948
966
|
throw wrapper;
|
|
949
967
|
}
|
|
950
968
|
}
|
|
@@ -1087,15 +1105,19 @@ var init_python_parser = __esm({
|
|
|
1087
1105
|
});
|
|
1088
1106
|
|
|
1089
1107
|
// src/parsers/shared-parser-utils.ts
|
|
1108
|
+
function getNodeProperty(node, prop) {
|
|
1109
|
+
if (!node) return null;
|
|
1110
|
+
return node[prop] ?? null;
|
|
1111
|
+
}
|
|
1090
1112
|
function analyzeGeneralMetadata(node, code, options = {}) {
|
|
1091
1113
|
const metadata = {
|
|
1092
1114
|
isPure: true,
|
|
1093
1115
|
hasSideEffects: false
|
|
1094
1116
|
};
|
|
1095
1117
|
try {
|
|
1096
|
-
let prev = node
|
|
1118
|
+
let prev = getNodeProperty(node, "previousNamedSibling") || getNodeProperty(node, "previousSibling") || null;
|
|
1097
1119
|
while (prev && (!prev.type || !prev.text.trim())) {
|
|
1098
|
-
prev = prev
|
|
1120
|
+
prev = getNodeProperty(prev, "previousSibling");
|
|
1099
1121
|
}
|
|
1100
1122
|
if (!prev && node.parent) {
|
|
1101
1123
|
const children = node.parent.children;
|
|
@@ -1108,9 +1130,9 @@ function analyzeGeneralMetadata(node, code, options = {}) {
|
|
|
1108
1130
|
}
|
|
1109
1131
|
}
|
|
1110
1132
|
while (prev && /attribute|decorator/i.test(prev.type)) {
|
|
1111
|
-
prev = prev
|
|
1133
|
+
prev = getNodeProperty(prev, "previousNamedSibling") || getNodeProperty(prev, "previousSibling") || null;
|
|
1112
1134
|
while (prev && (!prev.type || !prev.text.trim())) {
|
|
1113
|
-
prev = prev
|
|
1135
|
+
prev = getNodeProperty(prev, "previousSibling");
|
|
1114
1136
|
}
|
|
1115
1137
|
}
|
|
1116
1138
|
while (prev && (/comment|xml|doc|slash/i.test(prev.type) || prev.text.trim().startsWith("//") || prev.text.trim().startsWith("///"))) {
|
|
@@ -1136,7 +1158,7 @@ function analyzeGeneralMetadata(node, code, options = {}) {
|
|
|
1136
1158
|
};
|
|
1137
1159
|
break;
|
|
1138
1160
|
}
|
|
1139
|
-
prev = prev
|
|
1161
|
+
prev = getNodeProperty(prev, "previousSibling");
|
|
1140
1162
|
}
|
|
1141
1163
|
} catch {
|
|
1142
1164
|
}
|
|
@@ -1173,8 +1195,12 @@ function extractParameterNames(node) {
|
|
|
1173
1195
|
const params = [];
|
|
1174
1196
|
const candidates = [
|
|
1175
1197
|
// common field name
|
|
1176
|
-
node
|
|
1177
|
-
|
|
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,
|
|
1178
1204
|
node.children.find((c) => c.type === "parameter_list") || null,
|
|
1179
1205
|
node.children.find((c) => c.type === "parameters") || null,
|
|
1180
1206
|
node.children.find((c) => c.type === "formal_parameters") || null,
|
|
@@ -1184,7 +1210,9 @@ function extractParameterNames(node) {
|
|
|
1184
1210
|
if (!list) return params;
|
|
1185
1211
|
for (const child of list.children) {
|
|
1186
1212
|
if (!child) continue;
|
|
1187
|
-
const id = child
|
|
1213
|
+
const id = getNodeProperty(child, "childForFieldName")?.childForFieldName?.(
|
|
1214
|
+
"name"
|
|
1215
|
+
) || child.children.find(
|
|
1188
1216
|
(c) => [
|
|
1189
1217
|
"identifier",
|
|
1190
1218
|
"variable_name",
|
|
@@ -1636,11 +1664,17 @@ var init_csharp_parser = __esm({
|
|
|
1636
1664
|
const isPublic = modifiers.includes("public") || modifiers.includes("protected");
|
|
1637
1665
|
if (isPublic) {
|
|
1638
1666
|
const metadata = this.analyzeMetadata(node, code);
|
|
1639
|
-
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
|
+
}
|
|
1640
1674
|
const fullName = nextClass ? `${nextClass}.${nameNode.text}` : nextNamespace ? `${nextNamespace}.${nameNode.text}` : nameNode.text;
|
|
1641
|
-
|
|
1675
|
+
const exportItem = {
|
|
1642
1676
|
name: fullName,
|
|
1643
|
-
type:
|
|
1677
|
+
type: exportType,
|
|
1644
1678
|
loc: {
|
|
1645
1679
|
start: {
|
|
1646
1680
|
line: node.startPosition.row + 1,
|
|
@@ -1653,7 +1687,8 @@ var init_csharp_parser = __esm({
|
|
|
1653
1687
|
},
|
|
1654
1688
|
visibility: modifiers.includes("public") ? "public" : "protected",
|
|
1655
1689
|
...metadata
|
|
1656
|
-
}
|
|
1690
|
+
};
|
|
1691
|
+
exports2.push(exportItem);
|
|
1657
1692
|
nextClass = fullName;
|
|
1658
1693
|
}
|
|
1659
1694
|
}
|
|
@@ -1664,9 +1699,9 @@ var init_csharp_parser = __esm({
|
|
|
1664
1699
|
const isPublic = modifiers.includes("public") || modifiers.includes("protected");
|
|
1665
1700
|
if (isPublic) {
|
|
1666
1701
|
const metadata = this.analyzeMetadata(node, code);
|
|
1667
|
-
|
|
1702
|
+
const methodItem = {
|
|
1668
1703
|
name: nameNode.text,
|
|
1669
|
-
type: node.type === "method_declaration" ? "function" : "
|
|
1704
|
+
type: node.type === "method_declaration" ? "function" : "variable",
|
|
1670
1705
|
parentClass: currentClass,
|
|
1671
1706
|
loc: {
|
|
1672
1707
|
start: {
|
|
@@ -1681,7 +1716,8 @@ var init_csharp_parser = __esm({
|
|
|
1681
1716
|
visibility: modifiers.includes("public") ? "public" : "protected",
|
|
1682
1717
|
parameters: node.type === "method_declaration" ? this.extractParameters(node) : void 0,
|
|
1683
1718
|
...metadata
|
|
1684
|
-
}
|
|
1719
|
+
};
|
|
1720
|
+
exports2.push(methodItem);
|
|
1685
1721
|
}
|
|
1686
1722
|
}
|
|
1687
1723
|
}
|
|
@@ -3524,7 +3560,7 @@ function extractExportsWithDependencies(ast, fileImports) {
|
|
|
3524
3560
|
type: "default",
|
|
3525
3561
|
imports: usedImports,
|
|
3526
3562
|
dependencies: [],
|
|
3527
|
-
typeReferences,
|
|
3563
|
+
typeReferences: [],
|
|
3528
3564
|
loc: node.loc
|
|
3529
3565
|
});
|
|
3530
3566
|
} else if (node.type === "ExportAllDeclaration") {
|
|
@@ -3573,6 +3609,7 @@ function findUsedImports(node, importedNames) {
|
|
|
3573
3609
|
usedImports.add(n.name);
|
|
3574
3610
|
}
|
|
3575
3611
|
for (const key in n) {
|
|
3612
|
+
if (key === "parent") continue;
|
|
3576
3613
|
const value = n[key];
|
|
3577
3614
|
if (value && typeof value === "object") {
|
|
3578
3615
|
if (Array.isArray(value)) {
|
|
@@ -3616,6 +3653,7 @@ function extractTypeReferences(node) {
|
|
|
3616
3653
|
}
|
|
3617
3654
|
}
|
|
3618
3655
|
for (const key of Object.keys(n)) {
|
|
3656
|
+
if (key === "parent") continue;
|
|
3619
3657
|
const value = n[key];
|
|
3620
3658
|
if (Array.isArray(value)) {
|
|
3621
3659
|
value.forEach(visit);
|
|
@@ -3980,65 +4018,146 @@ var REPORT_STYLES = `
|
|
|
3980
4018
|
`;
|
|
3981
4019
|
|
|
3982
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
|
+
};
|
|
3983
4072
|
function tag(name, content = "", attrs = {}) {
|
|
3984
4073
|
const attrStr = Object.entries(attrs).map(([k, v]) => ` ${k}="${v}"`).join("");
|
|
3985
4074
|
return `<${name}${attrStr}>${content}</${name}>`;
|
|
3986
4075
|
}
|
|
3987
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, "");
|
|
3988
4084
|
return `<!DOCTYPE html>
|
|
3989
|
-
|
|
3990
|
-
|
|
3991
|
-
<meta
|
|
3992
|
-
<meta
|
|
3993
|
-
${tag(
|
|
3994
|
-
${tag(
|
|
3995
|
-
|
|
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}>`;
|
|
3996
4092
|
}
|
|
3997
4093
|
function generateReportHero(title, subtitle) {
|
|
3998
|
-
return tag(
|
|
3999
|
-
|
|
4000
|
-
|
|
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
|
+
);
|
|
4001
4101
|
}
|
|
4002
4102
|
function generateStatCards(cards) {
|
|
4003
4103
|
const cardsHtml = cards.map(
|
|
4004
4104
|
(c) => tag(
|
|
4005
|
-
|
|
4006
|
-
tag(
|
|
4007
|
-
|
|
4008
|
-
...c.color ? {
|
|
4009
|
-
}) + tag(
|
|
4010
|
-
|
|
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 }
|
|
4011
4113
|
)
|
|
4012
4114
|
).join("");
|
|
4013
|
-
return tag(
|
|
4115
|
+
return tag(REPORT_CONSTANTS.TAGS.DIV, cardsHtml, {
|
|
4116
|
+
[REPORT_CONSTANTS.ATTRS.CLASS]: REPORT_CONSTANTS.CLASSES.STATS
|
|
4117
|
+
});
|
|
4014
4118
|
}
|
|
4015
4119
|
function generateTable(config) {
|
|
4016
4120
|
const head = tag(
|
|
4017
|
-
|
|
4018
|
-
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
|
+
)
|
|
4019
4126
|
);
|
|
4020
4127
|
const body = tag(
|
|
4021
|
-
|
|
4128
|
+
REPORT_CONSTANTS.TAGS.TBODY,
|
|
4022
4129
|
config.rows.map(
|
|
4023
|
-
(row) => tag(
|
|
4130
|
+
(row) => tag(
|
|
4131
|
+
REPORT_CONSTANTS.TAGS.TR,
|
|
4132
|
+
row.map((cell) => tag(REPORT_CONSTANTS.TAGS.TD, cell)).join("")
|
|
4133
|
+
)
|
|
4024
4134
|
).join("")
|
|
4025
4135
|
);
|
|
4026
|
-
return tag(
|
|
4136
|
+
return tag(REPORT_CONSTANTS.TAGS.TABLE, head + body);
|
|
4027
4137
|
}
|
|
4028
4138
|
function generateIssueSummary(crit, maj, min, savings) {
|
|
4029
4139
|
const details = [
|
|
4030
|
-
tag(
|
|
4031
|
-
|
|
4032
|
-
|
|
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
|
+
})
|
|
4033
4149
|
].join(" ");
|
|
4034
4150
|
const savingsHtml = savings ? tag(
|
|
4035
|
-
|
|
4036
|
-
tag(
|
|
4151
|
+
REPORT_CONSTANTS.TAGS.P,
|
|
4152
|
+
tag(REPORT_CONSTANTS.TAGS.STRONG, "Potential Savings: ") + savings.toLocaleString() + " tokens"
|
|
4037
4153
|
) : "";
|
|
4038
4154
|
return tag(
|
|
4039
|
-
|
|
4040
|
-
tag(
|
|
4041
|
-
{
|
|
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
|
+
}
|
|
4042
4161
|
);
|
|
4043
4162
|
}
|
|
4044
4163
|
function generateReportFooter(options) {
|
|
@@ -4047,33 +4166,41 @@ function generateReportFooter(options) {
|
|
|
4047
4166
|
if (options.packageUrl)
|
|
4048
4167
|
links.push(
|
|
4049
4168
|
tag(
|
|
4050
|
-
|
|
4051
|
-
`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
|
+
})}`
|
|
4052
4173
|
)
|
|
4053
4174
|
);
|
|
4054
4175
|
if (options.bugUrl)
|
|
4055
4176
|
links.push(
|
|
4056
4177
|
tag(
|
|
4057
|
-
|
|
4058
|
-
`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
|
+
})}`
|
|
4059
4182
|
)
|
|
4060
4183
|
);
|
|
4061
4184
|
return tag(
|
|
4062
|
-
|
|
4185
|
+
REPORT_CONSTANTS.TAGS.DIV,
|
|
4063
4186
|
tag(
|
|
4064
|
-
|
|
4065
|
-
`Generated by ${tag(
|
|
4187
|
+
REPORT_CONSTANTS.TAGS.P,
|
|
4188
|
+
`Generated by ${tag(REPORT_CONSTANTS.TAGS.STRONG, "@aiready/" + options.packageName)}` + version
|
|
4066
4189
|
) + links.join(""),
|
|
4067
|
-
{
|
|
4190
|
+
{ [REPORT_CONSTANTS.ATTRS.CLASS]: REPORT_CONSTANTS.CLASSES.FOOTER }
|
|
4068
4191
|
);
|
|
4069
4192
|
}
|
|
4070
4193
|
function wrapInCard(content, title) {
|
|
4071
|
-
return tag(
|
|
4072
|
-
|
|
4073
|
-
|
|
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
|
+
);
|
|
4074
4201
|
}
|
|
4075
4202
|
function generateCompleteReport(options, body) {
|
|
4076
|
-
return generateReportHead(options.title) + tag(
|
|
4203
|
+
return generateReportHead(options.title) + tag(REPORT_CONSTANTS.TAGS.BODY, body + generateReportFooter(options));
|
|
4077
4204
|
}
|
|
4078
4205
|
function generateStandardHtmlReport(options, stats, sections, score) {
|
|
4079
4206
|
const hero = generateReportHero(
|
|
@@ -4081,9 +4208,13 @@ function generateStandardHtmlReport(options, stats, sections, score) {
|
|
|
4081
4208
|
`Generated on ${(/* @__PURE__ */ new Date()).toLocaleString()}`
|
|
4082
4209
|
);
|
|
4083
4210
|
const scoreCard = score ? tag(
|
|
4084
|
-
|
|
4085
|
-
tag(
|
|
4086
|
-
|
|
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 }
|
|
4087
4218
|
) : "";
|
|
4088
4219
|
const statsCards = generateStatCards(stats);
|
|
4089
4220
|
const bodyContent = `
|
|
@@ -4183,6 +4314,31 @@ var RecommendationPriority = /* @__PURE__ */ ((RecommendationPriority2) => {
|
|
|
4183
4314
|
})(RecommendationPriority || {});
|
|
4184
4315
|
|
|
4185
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
|
+
};
|
|
4186
4342
|
var DEFAULT_TOOL_WEIGHTS = {
|
|
4187
4343
|
["pattern-detect" /* PatternDetect */]: 22,
|
|
4188
4344
|
["context-analyzer" /* ContextAnalyzer */]: 19,
|
|
@@ -4270,22 +4426,22 @@ var CONTEXT_TIER_THRESHOLDS = {
|
|
|
4270
4426
|
frontier: { idealTokens: 5e4, criticalTokens: 15e4, idealDepth: 10 }
|
|
4271
4427
|
};
|
|
4272
4428
|
var SIZE_ADJUSTED_THRESHOLDS = {
|
|
4273
|
-
xs:
|
|
4429
|
+
xs: SCORING_CONSTANTS.THRESHOLDS.XS,
|
|
4274
4430
|
// < 50 files
|
|
4275
|
-
small:
|
|
4431
|
+
small: SCORING_CONSTANTS.THRESHOLDS.SMALL,
|
|
4276
4432
|
// 50-200 files
|
|
4277
|
-
medium:
|
|
4433
|
+
medium: SCORING_CONSTANTS.THRESHOLDS.MEDIUM,
|
|
4278
4434
|
// 200-500 files
|
|
4279
|
-
large:
|
|
4435
|
+
large: SCORING_CONSTANTS.THRESHOLDS.LARGE,
|
|
4280
4436
|
// 500-2000 files
|
|
4281
|
-
enterprise:
|
|
4437
|
+
enterprise: SCORING_CONSTANTS.THRESHOLDS.ENTERPRISE
|
|
4282
4438
|
// 2000+ files
|
|
4283
4439
|
};
|
|
4284
4440
|
function getProjectSizeTier(fileCount) {
|
|
4285
|
-
if (fileCount <
|
|
4286
|
-
if (fileCount <
|
|
4287
|
-
if (fileCount <
|
|
4288
|
-
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";
|
|
4289
4445
|
return "enterprise";
|
|
4290
4446
|
}
|
|
4291
4447
|
function getRecommendedThreshold(fileCount, modelTier = "standard") {
|
|
@@ -4301,14 +4457,16 @@ function getToolWeight(toolName, toolConfig, cliOverride, profile = "default" /*
|
|
|
4301
4457
|
if (cliOverride !== void 0) return cliOverride;
|
|
4302
4458
|
if (toolConfig?.scoreWeight !== void 0) return toolConfig.scoreWeight;
|
|
4303
4459
|
const profileWeights = SCORING_PROFILES[profile] ?? DEFAULT_TOOL_WEIGHTS;
|
|
4304
|
-
return profileWeights[toolName] ?? DEFAULT_TOOL_WEIGHTS[toolName] ??
|
|
4460
|
+
return profileWeights[toolName] ?? DEFAULT_TOOL_WEIGHTS[toolName] ?? SCORING_CONSTANTS.WEIGHTS.DEFAULT;
|
|
4305
4461
|
}
|
|
4306
4462
|
function parseWeightString(weightStr) {
|
|
4307
4463
|
const weights = /* @__PURE__ */ new Map();
|
|
4308
4464
|
if (!weightStr) return weights;
|
|
4309
|
-
const pairs = weightStr.split(
|
|
4465
|
+
const pairs = weightStr.split(SCORING_CONSTANTS.DELIMITERS.LIST);
|
|
4310
4466
|
for (const pair of pairs) {
|
|
4311
|
-
const [toolShortName, weightValueStr] = pair.split(
|
|
4467
|
+
const [toolShortName, weightValueStr] = pair.split(
|
|
4468
|
+
SCORING_CONSTANTS.DELIMITERS.PAIR
|
|
4469
|
+
);
|
|
4312
4470
|
if (toolShortName && weightValueStr) {
|
|
4313
4471
|
const toolName = normalizeToolName(toolShortName.trim());
|
|
4314
4472
|
const weight = parseInt(weightValueStr.trim(), 10);
|
|
@@ -4323,7 +4481,7 @@ function calculateOverallScore(toolOutputs, config, cliWeights) {
|
|
|
4323
4481
|
if (toolOutputs.size === 0) {
|
|
4324
4482
|
throw new Error("No tool outputs provided for scoring");
|
|
4325
4483
|
}
|
|
4326
|
-
const profile = config?.
|
|
4484
|
+
const profile = config?.profile || "default" /* Default */;
|
|
4327
4485
|
const weights = /* @__PURE__ */ new Map();
|
|
4328
4486
|
for (const [toolName] of toolOutputs.entries()) {
|
|
4329
4487
|
const cliWeight = cliWeights?.get(toolName);
|
|
@@ -4337,7 +4495,7 @@ function calculateOverallScore(toolOutputs, config, cliWeights) {
|
|
|
4337
4495
|
const toolsUsed = [];
|
|
4338
4496
|
const calculationWeights = {};
|
|
4339
4497
|
for (const [toolName, output] of toolOutputs.entries()) {
|
|
4340
|
-
const weight = weights.get(toolName) ??
|
|
4498
|
+
const weight = weights.get(toolName) ?? SCORING_CONSTANTS.WEIGHTS.DEFAULT;
|
|
4341
4499
|
weightedSum += output.score * weight;
|
|
4342
4500
|
totalWeight += weight;
|
|
4343
4501
|
toolsUsed.push(toolName);
|
|
@@ -4348,11 +4506,11 @@ function calculateOverallScore(toolOutputs, config, cliWeights) {
|
|
|
4348
4506
|
const rating = getRating(overall);
|
|
4349
4507
|
const formulaParts = Array.from(toolOutputs.entries()).map(
|
|
4350
4508
|
([name, output]) => {
|
|
4351
|
-
const weight = weights.get(name) ??
|
|
4509
|
+
const weight = weights.get(name) ?? SCORING_CONSTANTS.WEIGHTS.DEFAULT;
|
|
4352
4510
|
return `(${output.score} \xD7 ${weight})`;
|
|
4353
4511
|
}
|
|
4354
4512
|
);
|
|
4355
|
-
const formulaStr = `[${formulaParts.join(
|
|
4513
|
+
const formulaStr = `[${formulaParts.join(SCORING_CONSTANTS.DELIMITERS.FORMULA_JOIN)}] / ${totalWeight} = ${overall}`;
|
|
4356
4514
|
return {
|
|
4357
4515
|
overall,
|
|
4358
4516
|
rating,
|
|
@@ -4368,7 +4526,7 @@ function calculateOverallScore(toolOutputs, config, cliWeights) {
|
|
|
4368
4526
|
}
|
|
4369
4527
|
function getRatingWithContext(score, fileCount, modelTier = "standard") {
|
|
4370
4528
|
const threshold = getRecommendedThreshold(fileCount, modelTier);
|
|
4371
|
-
const normalized = score - threshold +
|
|
4529
|
+
const normalized = score - threshold + SCORING_CONSTANTS.THRESHOLDS.NORMALIZATION_OFFSET;
|
|
4372
4530
|
return getRating(normalized);
|
|
4373
4531
|
}
|
|
4374
4532
|
function getRatingDisplay(rating) {
|
|
@@ -4438,22 +4596,22 @@ function buildFactorsFromDimensions(dimensions, dimensionNames, rawData) {
|
|
|
4438
4596
|
}
|
|
4439
4597
|
function formatDimensionDescription(key, rawData) {
|
|
4440
4598
|
if (key === "testCoverageRatio" && rawData.testFiles !== void 0) {
|
|
4441
|
-
return `${rawData.testFiles} test files / ${rawData.sourceFiles} source files`;
|
|
4599
|
+
return `${String(rawData.testFiles)} test files / ${String(rawData.sourceFiles)} source files`;
|
|
4442
4600
|
}
|
|
4443
4601
|
if (key === "purityScore" && rawData.pureFunctions !== void 0) {
|
|
4444
|
-
return `${rawData.pureFunctions}/${rawData.totalFunctions} functions are pure`;
|
|
4602
|
+
return `${String(rawData.pureFunctions)}/${String(rawData.totalFunctions)} functions are pure`;
|
|
4445
4603
|
}
|
|
4446
4604
|
if (key === "dependencyInjectionScore" && rawData.injectionPatterns !== void 0) {
|
|
4447
|
-
return `${rawData.injectionPatterns}/${rawData.totalClasses} classes use DI`;
|
|
4605
|
+
return `${String(rawData.injectionPatterns)}/${String(rawData.totalClasses)} classes use DI`;
|
|
4448
4606
|
}
|
|
4449
4607
|
if (key === "structureClarityScore" && rawData.deepDirectories !== void 0) {
|
|
4450
|
-
return `${rawData.deepDirectories} of ${rawData.totalDirectories} dirs exceed recommended depth`;
|
|
4608
|
+
return `${String(rawData.deepDirectories)} of ${String(rawData.totalDirectories)} dirs exceed recommended depth`;
|
|
4451
4609
|
}
|
|
4452
4610
|
if (key === "apiClarityScore" && rawData.untypedExports !== void 0) {
|
|
4453
|
-
return `${rawData.untypedExports} of ${rawData.totalExports} exports lack type annotations`;
|
|
4611
|
+
return `${String(rawData.untypedExports)} of ${String(rawData.totalExports)} exports lack type annotations`;
|
|
4454
4612
|
}
|
|
4455
4613
|
if (key === "graphStabilityScore") {
|
|
4456
|
-
return `${rawData.score}/100`;
|
|
4614
|
+
return `${String(rawData.score)}/100`;
|
|
4457
4615
|
}
|
|
4458
4616
|
return void 0;
|
|
4459
4617
|
}
|
|
@@ -4491,7 +4649,7 @@ function buildStandardToolScore(params) {
|
|
|
4491
4649
|
score,
|
|
4492
4650
|
rawMetrics: {
|
|
4493
4651
|
...rawData,
|
|
4494
|
-
rating: rating || rawData.rating
|
|
4652
|
+
rating: rating || String(rawData.rating)
|
|
4495
4653
|
},
|
|
4496
4654
|
factors,
|
|
4497
4655
|
recommendations: recs
|