@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
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
// src/parsers/shared-parser-utils.ts
|
|
2
|
+
function getNodeProperty(node, prop) {
|
|
3
|
+
if (!node) return null;
|
|
4
|
+
return node[prop] ?? null;
|
|
5
|
+
}
|
|
2
6
|
var SIDE_EFFECT_KEYWORDS = [
|
|
3
7
|
"print(",
|
|
4
8
|
"console.",
|
|
@@ -19,11 +23,27 @@ function analyzeGeneralMetadata(node, code, options = {}) {
|
|
|
19
23
|
hasSideEffects: false
|
|
20
24
|
};
|
|
21
25
|
try {
|
|
22
|
-
let prev = node
|
|
26
|
+
let prev = getNodeProperty(node, "previousNamedSibling") || getNodeProperty(node, "previousSibling") || null;
|
|
27
|
+
while (prev && (!prev.type || !prev.text.trim())) {
|
|
28
|
+
prev = getNodeProperty(prev, "previousSibling");
|
|
29
|
+
}
|
|
30
|
+
if (!prev && node.parent) {
|
|
31
|
+
const children = node.parent.children;
|
|
32
|
+
const idx = children.indexOf(node);
|
|
33
|
+
if (idx > 0) {
|
|
34
|
+
prev = children[idx - 1];
|
|
35
|
+
while (prev && idx > 0 && (!prev.type || !prev.text.trim())) {
|
|
36
|
+
prev = children[idx - 2] || null;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
23
40
|
while (prev && /attribute|decorator/i.test(prev.type)) {
|
|
24
|
-
prev = prev
|
|
41
|
+
prev = getNodeProperty(prev, "previousNamedSibling") || getNodeProperty(prev, "previousSibling") || null;
|
|
42
|
+
while (prev && (!prev.type || !prev.text.trim())) {
|
|
43
|
+
prev = getNodeProperty(prev, "previousSibling");
|
|
44
|
+
}
|
|
25
45
|
}
|
|
26
|
-
while (prev && /comment|xml|doc/i.test(prev.type)) {
|
|
46
|
+
while (prev && (/comment|xml|doc|slash/i.test(prev.type) || prev.text.trim().startsWith("//") || prev.text.trim().startsWith("///"))) {
|
|
27
47
|
const text = prev.text || "";
|
|
28
48
|
if (text.trim().startsWith("/**")) {
|
|
29
49
|
metadata.documentation = {
|
|
@@ -46,7 +66,7 @@ function analyzeGeneralMetadata(node, code, options = {}) {
|
|
|
46
66
|
};
|
|
47
67
|
break;
|
|
48
68
|
}
|
|
49
|
-
prev = prev
|
|
69
|
+
prev = getNodeProperty(prev, "previousSibling");
|
|
50
70
|
}
|
|
51
71
|
} catch {
|
|
52
72
|
}
|
|
@@ -83,8 +103,12 @@ function extractParameterNames(node) {
|
|
|
83
103
|
const params = [];
|
|
84
104
|
const candidates = [
|
|
85
105
|
// common field name
|
|
86
|
-
node
|
|
87
|
-
|
|
106
|
+
getNodeProperty(node, "childForFieldName") ? getNodeProperty(node, "childForFieldName")?.childForFieldName?.(
|
|
107
|
+
"parameters"
|
|
108
|
+
) ?? null : null,
|
|
109
|
+
getNodeProperty(node, "childForFieldName") ? getNodeProperty(node, "childForFieldName")?.childForFieldName?.(
|
|
110
|
+
"parameter_list"
|
|
111
|
+
) ?? null : null,
|
|
88
112
|
node.children.find((c) => c.type === "parameter_list") || null,
|
|
89
113
|
node.children.find((c) => c.type === "parameters") || null,
|
|
90
114
|
node.children.find((c) => c.type === "formal_parameters") || null,
|
|
@@ -94,7 +118,9 @@ function extractParameterNames(node) {
|
|
|
94
118
|
if (!list) return params;
|
|
95
119
|
for (const child of list.children) {
|
|
96
120
|
if (!child) continue;
|
|
97
|
-
const id = child
|
|
121
|
+
const id = getNodeProperty(child, "childForFieldName")?.childForFieldName?.(
|
|
122
|
+
"name"
|
|
123
|
+
) || child.children.find(
|
|
98
124
|
(c) => [
|
|
99
125
|
"identifier",
|
|
100
126
|
"variable_name",
|
|
@@ -25,9 +25,10 @@ var TypeScriptParser = class {
|
|
|
25
25
|
jsx: filePath.endsWith("x")
|
|
26
26
|
});
|
|
27
27
|
} catch (error) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
const err = error;
|
|
29
|
+
throw new ParseError(err.message || "Unknown error", filePath, {
|
|
30
|
+
line: err.lineNumber || 1,
|
|
31
|
+
column: err.column || 0
|
|
31
32
|
});
|
|
32
33
|
}
|
|
33
34
|
}
|
|
@@ -166,7 +167,6 @@ var TypeScriptParser = class {
|
|
|
166
167
|
decl.id.name,
|
|
167
168
|
"const",
|
|
168
169
|
node,
|
|
169
|
-
// Pass the outer ExportNamedDeclaration
|
|
170
170
|
code,
|
|
171
171
|
filePath,
|
|
172
172
|
decl.init
|
|
@@ -177,7 +177,9 @@ var TypeScriptParser = class {
|
|
|
177
177
|
}
|
|
178
178
|
}
|
|
179
179
|
} else if (node.type === "ExportDefaultDeclaration") {
|
|
180
|
-
exports.push(
|
|
180
|
+
exports.push(
|
|
181
|
+
this.createExport("default", "default", node, code, filePath)
|
|
182
|
+
);
|
|
181
183
|
}
|
|
182
184
|
}
|
|
183
185
|
return exports;
|
|
@@ -194,16 +196,19 @@ var TypeScriptParser = class {
|
|
|
194
196
|
isPrimitive = true;
|
|
195
197
|
}
|
|
196
198
|
}
|
|
197
|
-
|
|
199
|
+
let structNode = node.type === "ExportNamedDeclaration" && node.declaration ? node.declaration : node.type === "ExportDefaultDeclaration" ? node.declaration : node;
|
|
200
|
+
if (!structNode) structNode = node;
|
|
198
201
|
if (filePath.endsWith(".ts") || filePath.endsWith(".tsx")) {
|
|
199
202
|
if (structNode.type === "TSTypeAliasDeclaration" || structNode.type === "TSInterfaceDeclaration" || structNode.type === "TSEnumDeclaration") {
|
|
200
203
|
isTyped = true;
|
|
201
204
|
} else if (structNode.type === "FunctionDeclaration" || structNode.type === "TSDeclareFunction") {
|
|
202
|
-
const
|
|
203
|
-
const
|
|
205
|
+
const func = structNode;
|
|
206
|
+
const hasReturnType = !!func.returnType;
|
|
207
|
+
const allParamsTyped = func.params.length === 0 || func.params.every((p) => !!p.typeAnnotation);
|
|
204
208
|
isTyped = hasReturnType && allParamsTyped;
|
|
205
209
|
} else if (structNode.type === "VariableDeclaration") {
|
|
206
|
-
|
|
210
|
+
const variable = structNode;
|
|
211
|
+
isTyped = variable.declarations.every(
|
|
207
212
|
(d) => !!d.id.typeAnnotation || !!d.init
|
|
208
213
|
);
|
|
209
214
|
} else if (structNode.type === "ClassDeclaration") {
|
|
@@ -231,7 +236,7 @@ var TypeScriptParser = class {
|
|
|
231
236
|
return p.parameter.name;
|
|
232
237
|
}
|
|
233
238
|
return void 0;
|
|
234
|
-
}).filter(
|
|
239
|
+
}).filter((p) => !!p);
|
|
235
240
|
}
|
|
236
241
|
}
|
|
237
242
|
}
|
|
@@ -241,7 +246,7 @@ var TypeScriptParser = class {
|
|
|
241
246
|
parameters = funcNode.params.map((p) => {
|
|
242
247
|
if (p.type === "Identifier") return p.name;
|
|
243
248
|
return void 0;
|
|
244
|
-
}).filter(
|
|
249
|
+
}).filter((p) => !!p);
|
|
245
250
|
}
|
|
246
251
|
}
|
|
247
252
|
return {
|
|
@@ -276,11 +281,11 @@ var TypeScriptParser = class {
|
|
|
276
281
|
return void 0;
|
|
277
282
|
}
|
|
278
283
|
isLikelyPure(node) {
|
|
279
|
-
const
|
|
280
|
-
if (
|
|
281
|
-
|
|
282
|
-
if (
|
|
283
|
-
const body =
|
|
284
|
+
const sn = node.type === "ExportNamedDeclaration" && node.declaration ? node.declaration : node.type === "ExportDefaultDeclaration" ? node.declaration : node;
|
|
285
|
+
if (!sn) return false;
|
|
286
|
+
if (sn.type === "VariableDeclaration" && sn.kind === "const") return true;
|
|
287
|
+
if (sn.type === "FunctionDeclaration" || sn.type === "MethodDefinition") {
|
|
288
|
+
const body = sn.type === "MethodDefinition" ? sn.value.body : sn.body;
|
|
284
289
|
if (body && body.type === "BlockStatement") {
|
|
285
290
|
const bodyContent = JSON.stringify(body);
|
|
286
291
|
if (bodyContent.includes('"name":"console"') || bodyContent.includes('"name":"process"') || bodyContent.includes('"type":"AssignmentExpression"')) {
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
// src/parsers/shared-parser-utils.ts
|
|
2
|
+
function getNodeProperty(node, prop) {
|
|
3
|
+
if (!node) return null;
|
|
4
|
+
return node[prop] ?? null;
|
|
5
|
+
}
|
|
2
6
|
var SIDE_EFFECT_KEYWORDS = [
|
|
3
7
|
"print(",
|
|
4
8
|
"console.",
|
|
@@ -19,9 +23,9 @@ function analyzeGeneralMetadata(node, code, options = {}) {
|
|
|
19
23
|
hasSideEffects: false
|
|
20
24
|
};
|
|
21
25
|
try {
|
|
22
|
-
let prev = node
|
|
26
|
+
let prev = getNodeProperty(node, "previousNamedSibling") || getNodeProperty(node, "previousSibling") || null;
|
|
23
27
|
while (prev && (!prev.type || !prev.text.trim())) {
|
|
24
|
-
prev = prev
|
|
28
|
+
prev = getNodeProperty(prev, "previousSibling");
|
|
25
29
|
}
|
|
26
30
|
if (!prev && node.parent) {
|
|
27
31
|
const children = node.parent.children;
|
|
@@ -34,9 +38,9 @@ function analyzeGeneralMetadata(node, code, options = {}) {
|
|
|
34
38
|
}
|
|
35
39
|
}
|
|
36
40
|
while (prev && /attribute|decorator/i.test(prev.type)) {
|
|
37
|
-
prev = prev
|
|
41
|
+
prev = getNodeProperty(prev, "previousNamedSibling") || getNodeProperty(prev, "previousSibling") || null;
|
|
38
42
|
while (prev && (!prev.type || !prev.text.trim())) {
|
|
39
|
-
prev = prev
|
|
43
|
+
prev = getNodeProperty(prev, "previousSibling");
|
|
40
44
|
}
|
|
41
45
|
}
|
|
42
46
|
while (prev && (/comment|xml|doc|slash/i.test(prev.type) || prev.text.trim().startsWith("//") || prev.text.trim().startsWith("///"))) {
|
|
@@ -62,7 +66,7 @@ function analyzeGeneralMetadata(node, code, options = {}) {
|
|
|
62
66
|
};
|
|
63
67
|
break;
|
|
64
68
|
}
|
|
65
|
-
prev = prev
|
|
69
|
+
prev = getNodeProperty(prev, "previousSibling");
|
|
66
70
|
}
|
|
67
71
|
} catch {
|
|
68
72
|
}
|
|
@@ -99,8 +103,8 @@ function extractParameterNames(node) {
|
|
|
99
103
|
const params = [];
|
|
100
104
|
const candidates = [
|
|
101
105
|
// common field name
|
|
102
|
-
node
|
|
103
|
-
node
|
|
106
|
+
getNodeProperty(node, "childForFieldName") ? getNodeProperty(node, "childForFieldName")?.childForFieldName?.("parameters") ?? null : null,
|
|
107
|
+
getNodeProperty(node, "childForFieldName") ? getNodeProperty(node, "childForFieldName")?.childForFieldName?.("parameter_list") ?? null : null,
|
|
104
108
|
node.children.find((c) => c.type === "parameter_list") || null,
|
|
105
109
|
node.children.find((c) => c.type === "parameters") || null,
|
|
106
110
|
node.children.find((c) => c.type === "formal_parameters") || null,
|
|
@@ -110,7 +114,7 @@ function extractParameterNames(node) {
|
|
|
110
114
|
if (!list) return params;
|
|
111
115
|
for (const child of list.children) {
|
|
112
116
|
if (!child) continue;
|
|
113
|
-
const id = child
|
|
117
|
+
const id = getNodeProperty(child, "childForFieldName")?.childForFieldName?.("name") || child.children.find(
|
|
114
118
|
(c) => [
|
|
115
119
|
"identifier",
|
|
116
120
|
"variable_name",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
analyzeGeneralMetadata,
|
|
3
3
|
extractParameterNames
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-3D3I5K5W.mjs";
|
|
5
5
|
import {
|
|
6
6
|
BaseLanguageParser
|
|
7
7
|
} from "./chunk-2N7ISIKE.mjs";
|
|
@@ -161,11 +161,17 @@ var CSharpParser = class extends BaseLanguageParser {
|
|
|
161
161
|
const isPublic = modifiers.includes("public") || modifiers.includes("protected");
|
|
162
162
|
if (isPublic) {
|
|
163
163
|
const metadata = this.analyzeMetadata(node, code);
|
|
164
|
-
const
|
|
164
|
+
const nodeType = node.type.replace("_declaration", "");
|
|
165
|
+
let exportType = "class";
|
|
166
|
+
if (nodeType === "record" || nodeType === "struct" || nodeType === "enum") {
|
|
167
|
+
exportType = "class";
|
|
168
|
+
} else if (nodeType === "interface" || nodeType === "interface_declaration") {
|
|
169
|
+
exportType = "interface";
|
|
170
|
+
}
|
|
165
171
|
const fullName = nextClass ? `${nextClass}.${nameNode.text}` : nextNamespace ? `${nextNamespace}.${nameNode.text}` : nameNode.text;
|
|
166
|
-
|
|
172
|
+
const exportItem = {
|
|
167
173
|
name: fullName,
|
|
168
|
-
type:
|
|
174
|
+
type: exportType,
|
|
169
175
|
loc: {
|
|
170
176
|
start: {
|
|
171
177
|
line: node.startPosition.row + 1,
|
|
@@ -178,7 +184,8 @@ var CSharpParser = class extends BaseLanguageParser {
|
|
|
178
184
|
},
|
|
179
185
|
visibility: modifiers.includes("public") ? "public" : "protected",
|
|
180
186
|
...metadata
|
|
181
|
-
}
|
|
187
|
+
};
|
|
188
|
+
exports.push(exportItem);
|
|
182
189
|
nextClass = fullName;
|
|
183
190
|
}
|
|
184
191
|
}
|
|
@@ -189,9 +196,9 @@ var CSharpParser = class extends BaseLanguageParser {
|
|
|
189
196
|
const isPublic = modifiers.includes("public") || modifiers.includes("protected");
|
|
190
197
|
if (isPublic) {
|
|
191
198
|
const metadata = this.analyzeMetadata(node, code);
|
|
192
|
-
|
|
199
|
+
const methodItem = {
|
|
193
200
|
name: nameNode.text,
|
|
194
|
-
type: node.type === "method_declaration" ? "function" : "
|
|
201
|
+
type: node.type === "method_declaration" ? "function" : "variable",
|
|
195
202
|
parentClass: currentClass,
|
|
196
203
|
loc: {
|
|
197
204
|
start: {
|
|
@@ -206,7 +213,8 @@ var CSharpParser = class extends BaseLanguageParser {
|
|
|
206
213
|
visibility: modifiers.includes("public") ? "public" : "protected",
|
|
207
214
|
parameters: node.type === "method_declaration" ? this.extractParameters(node) : void 0,
|
|
208
215
|
...metadata
|
|
209
|
-
}
|
|
216
|
+
};
|
|
217
|
+
exports.push(methodItem);
|
|
210
218
|
}
|
|
211
219
|
}
|
|
212
220
|
}
|
|
@@ -561,6 +561,31 @@ var RecommendationPriority = /* @__PURE__ */ ((RecommendationPriority2) => {
|
|
|
561
561
|
})(RecommendationPriority || {});
|
|
562
562
|
|
|
563
563
|
// src/scoring.ts
|
|
564
|
+
var SCORING_CONSTANTS = {
|
|
565
|
+
WEIGHTS: {
|
|
566
|
+
DEFAULT: 5,
|
|
567
|
+
MAX: 100
|
|
568
|
+
},
|
|
569
|
+
THRESHOLDS: {
|
|
570
|
+
XS: 80,
|
|
571
|
+
SMALL: 75,
|
|
572
|
+
MEDIUM: 70,
|
|
573
|
+
LARGE: 65,
|
|
574
|
+
ENTERPRISE: 58,
|
|
575
|
+
NORMALIZATION_OFFSET: 70
|
|
576
|
+
},
|
|
577
|
+
FILE_COUNTS: {
|
|
578
|
+
XS: 50,
|
|
579
|
+
SMALL: 200,
|
|
580
|
+
MEDIUM: 500,
|
|
581
|
+
LARGE: 2e3
|
|
582
|
+
},
|
|
583
|
+
DELIMITERS: {
|
|
584
|
+
LIST: ",",
|
|
585
|
+
PAIR: ":",
|
|
586
|
+
FORMULA_JOIN: " + "
|
|
587
|
+
}
|
|
588
|
+
};
|
|
564
589
|
var DEFAULT_TOOL_WEIGHTS = {
|
|
565
590
|
["pattern-detect" /* PatternDetect */]: 22,
|
|
566
591
|
["context-analyzer" /* ContextAnalyzer */]: 19,
|
|
@@ -648,22 +673,22 @@ var CONTEXT_TIER_THRESHOLDS = {
|
|
|
648
673
|
frontier: { idealTokens: 5e4, criticalTokens: 15e4, idealDepth: 10 }
|
|
649
674
|
};
|
|
650
675
|
var SIZE_ADJUSTED_THRESHOLDS = {
|
|
651
|
-
xs:
|
|
676
|
+
xs: SCORING_CONSTANTS.THRESHOLDS.XS,
|
|
652
677
|
// < 50 files
|
|
653
|
-
small:
|
|
678
|
+
small: SCORING_CONSTANTS.THRESHOLDS.SMALL,
|
|
654
679
|
// 50-200 files
|
|
655
|
-
medium:
|
|
680
|
+
medium: SCORING_CONSTANTS.THRESHOLDS.MEDIUM,
|
|
656
681
|
// 200-500 files
|
|
657
|
-
large:
|
|
682
|
+
large: SCORING_CONSTANTS.THRESHOLDS.LARGE,
|
|
658
683
|
// 500-2000 files
|
|
659
|
-
enterprise:
|
|
684
|
+
enterprise: SCORING_CONSTANTS.THRESHOLDS.ENTERPRISE
|
|
660
685
|
// 2000+ files
|
|
661
686
|
};
|
|
662
687
|
function getProjectSizeTier(fileCount) {
|
|
663
|
-
if (fileCount <
|
|
664
|
-
if (fileCount <
|
|
665
|
-
if (fileCount <
|
|
666
|
-
if (fileCount <
|
|
688
|
+
if (fileCount < SCORING_CONSTANTS.FILE_COUNTS.XS) return "xs";
|
|
689
|
+
if (fileCount < SCORING_CONSTANTS.FILE_COUNTS.SMALL) return "small";
|
|
690
|
+
if (fileCount < SCORING_CONSTANTS.FILE_COUNTS.MEDIUM) return "medium";
|
|
691
|
+
if (fileCount < SCORING_CONSTANTS.FILE_COUNTS.LARGE) return "large";
|
|
667
692
|
return "enterprise";
|
|
668
693
|
}
|
|
669
694
|
function getRecommendedThreshold(fileCount, modelTier = "standard") {
|
|
@@ -679,14 +704,16 @@ function getToolWeight(toolName, toolConfig, cliOverride, profile = "default" /*
|
|
|
679
704
|
if (cliOverride !== void 0) return cliOverride;
|
|
680
705
|
if (toolConfig?.scoreWeight !== void 0) return toolConfig.scoreWeight;
|
|
681
706
|
const profileWeights = SCORING_PROFILES[profile] ?? DEFAULT_TOOL_WEIGHTS;
|
|
682
|
-
return profileWeights[toolName] ?? DEFAULT_TOOL_WEIGHTS[toolName] ??
|
|
707
|
+
return profileWeights[toolName] ?? DEFAULT_TOOL_WEIGHTS[toolName] ?? SCORING_CONSTANTS.WEIGHTS.DEFAULT;
|
|
683
708
|
}
|
|
684
709
|
function parseWeightString(weightStr) {
|
|
685
710
|
const weights = /* @__PURE__ */ new Map();
|
|
686
711
|
if (!weightStr) return weights;
|
|
687
|
-
const pairs = weightStr.split(
|
|
712
|
+
const pairs = weightStr.split(SCORING_CONSTANTS.DELIMITERS.LIST);
|
|
688
713
|
for (const pair of pairs) {
|
|
689
|
-
const [toolShortName, weightValueStr] = pair.split(
|
|
714
|
+
const [toolShortName, weightValueStr] = pair.split(
|
|
715
|
+
SCORING_CONSTANTS.DELIMITERS.PAIR
|
|
716
|
+
);
|
|
690
717
|
if (toolShortName && weightValueStr) {
|
|
691
718
|
const toolName = normalizeToolName(toolShortName.trim());
|
|
692
719
|
const weight = parseInt(weightValueStr.trim(), 10);
|
|
@@ -701,7 +728,7 @@ function calculateOverallScore(toolOutputs, config, cliWeights) {
|
|
|
701
728
|
if (toolOutputs.size === 0) {
|
|
702
729
|
throw new Error("No tool outputs provided for scoring");
|
|
703
730
|
}
|
|
704
|
-
const profile = config?.
|
|
731
|
+
const profile = config?.profile || "default" /* Default */;
|
|
705
732
|
const weights = /* @__PURE__ */ new Map();
|
|
706
733
|
for (const [toolName] of toolOutputs.entries()) {
|
|
707
734
|
const cliWeight = cliWeights?.get(toolName);
|
|
@@ -715,7 +742,7 @@ function calculateOverallScore(toolOutputs, config, cliWeights) {
|
|
|
715
742
|
const toolsUsed = [];
|
|
716
743
|
const calculationWeights = {};
|
|
717
744
|
for (const [toolName, output] of toolOutputs.entries()) {
|
|
718
|
-
const weight = weights.get(toolName) ??
|
|
745
|
+
const weight = weights.get(toolName) ?? SCORING_CONSTANTS.WEIGHTS.DEFAULT;
|
|
719
746
|
weightedSum += output.score * weight;
|
|
720
747
|
totalWeight += weight;
|
|
721
748
|
toolsUsed.push(toolName);
|
|
@@ -726,11 +753,11 @@ function calculateOverallScore(toolOutputs, config, cliWeights) {
|
|
|
726
753
|
const rating = getRating(overall);
|
|
727
754
|
const formulaParts = Array.from(toolOutputs.entries()).map(
|
|
728
755
|
([name, output]) => {
|
|
729
|
-
const weight = weights.get(name) ??
|
|
756
|
+
const weight = weights.get(name) ?? SCORING_CONSTANTS.WEIGHTS.DEFAULT;
|
|
730
757
|
return `(${output.score} \xD7 ${weight})`;
|
|
731
758
|
}
|
|
732
759
|
);
|
|
733
|
-
const formulaStr = `[${formulaParts.join(
|
|
760
|
+
const formulaStr = `[${formulaParts.join(SCORING_CONSTANTS.DELIMITERS.FORMULA_JOIN)}] / ${totalWeight} = ${overall}`;
|
|
734
761
|
return {
|
|
735
762
|
overall,
|
|
736
763
|
rating,
|
|
@@ -746,7 +773,7 @@ function calculateOverallScore(toolOutputs, config, cliWeights) {
|
|
|
746
773
|
}
|
|
747
774
|
function getRatingWithContext(score, fileCount, modelTier = "standard") {
|
|
748
775
|
const threshold = getRecommendedThreshold(fileCount, modelTier);
|
|
749
|
-
const normalized = score - threshold +
|
|
776
|
+
const normalized = score - threshold + SCORING_CONSTANTS.THRESHOLDS.NORMALIZATION_OFFSET;
|
|
750
777
|
return getRating(normalized);
|
|
751
778
|
}
|
|
752
779
|
function getRatingDisplay(rating) {
|
|
@@ -25,9 +25,10 @@ var TypeScriptParser = class {
|
|
|
25
25
|
jsx: filePath.endsWith("x")
|
|
26
26
|
});
|
|
27
27
|
} catch (error) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
const err = error;
|
|
29
|
+
throw new ParseError(err.message || "Unknown error", filePath, {
|
|
30
|
+
line: err.lineNumber || 1,
|
|
31
|
+
column: err.column || 0
|
|
31
32
|
});
|
|
32
33
|
}
|
|
33
34
|
}
|
|
@@ -166,7 +167,6 @@ var TypeScriptParser = class {
|
|
|
166
167
|
decl.id.name,
|
|
167
168
|
"const",
|
|
168
169
|
node,
|
|
169
|
-
// Pass the outer ExportNamedDeclaration
|
|
170
170
|
code,
|
|
171
171
|
filePath,
|
|
172
172
|
decl.init
|
|
@@ -196,16 +196,19 @@ var TypeScriptParser = class {
|
|
|
196
196
|
isPrimitive = true;
|
|
197
197
|
}
|
|
198
198
|
}
|
|
199
|
-
|
|
199
|
+
let structNode = node.type === "ExportNamedDeclaration" && node.declaration ? node.declaration : node.type === "ExportDefaultDeclaration" ? node.declaration : node;
|
|
200
|
+
if (!structNode) structNode = node;
|
|
200
201
|
if (filePath.endsWith(".ts") || filePath.endsWith(".tsx")) {
|
|
201
202
|
if (structNode.type === "TSTypeAliasDeclaration" || structNode.type === "TSInterfaceDeclaration" || structNode.type === "TSEnumDeclaration") {
|
|
202
203
|
isTyped = true;
|
|
203
204
|
} else if (structNode.type === "FunctionDeclaration" || structNode.type === "TSDeclareFunction") {
|
|
204
|
-
const
|
|
205
|
-
const
|
|
205
|
+
const func = structNode;
|
|
206
|
+
const hasReturnType = !!func.returnType;
|
|
207
|
+
const allParamsTyped = func.params.length === 0 || func.params.every((p) => !!p.typeAnnotation);
|
|
206
208
|
isTyped = hasReturnType && allParamsTyped;
|
|
207
209
|
} else if (structNode.type === "VariableDeclaration") {
|
|
208
|
-
|
|
210
|
+
const variable = structNode;
|
|
211
|
+
isTyped = variable.declarations.every(
|
|
209
212
|
(d) => !!d.id.typeAnnotation || !!d.init
|
|
210
213
|
);
|
|
211
214
|
} else if (structNode.type === "ClassDeclaration") {
|
|
@@ -233,7 +236,7 @@ var TypeScriptParser = class {
|
|
|
233
236
|
return p.parameter.name;
|
|
234
237
|
}
|
|
235
238
|
return void 0;
|
|
236
|
-
}).filter(
|
|
239
|
+
}).filter((p) => !!p);
|
|
237
240
|
}
|
|
238
241
|
}
|
|
239
242
|
}
|
|
@@ -243,7 +246,7 @@ var TypeScriptParser = class {
|
|
|
243
246
|
parameters = funcNode.params.map((p) => {
|
|
244
247
|
if (p.type === "Identifier") return p.name;
|
|
245
248
|
return void 0;
|
|
246
|
-
}).filter(
|
|
249
|
+
}).filter((p) => !!p);
|
|
247
250
|
}
|
|
248
251
|
}
|
|
249
252
|
return {
|
|
@@ -278,11 +281,12 @@ var TypeScriptParser = class {
|
|
|
278
281
|
return void 0;
|
|
279
282
|
}
|
|
280
283
|
isLikelyPure(node) {
|
|
281
|
-
const
|
|
282
|
-
if (
|
|
284
|
+
const sn = node.type === "ExportNamedDeclaration" && node.declaration ? node.declaration : node.type === "ExportDefaultDeclaration" ? node.declaration : node;
|
|
285
|
+
if (!sn) return false;
|
|
286
|
+
if (sn.type === "VariableDeclaration" && sn.kind === "const")
|
|
283
287
|
return true;
|
|
284
|
-
if (
|
|
285
|
-
const body =
|
|
288
|
+
if (sn.type === "FunctionDeclaration" || sn.type === "MethodDefinition") {
|
|
289
|
+
const body = sn.type === "MethodDefinition" ? sn.value.body : sn.body;
|
|
286
290
|
if (body && body.type === "BlockStatement") {
|
|
287
291
|
const bodyContent = JSON.stringify(body);
|
|
288
292
|
if (bodyContent.includes('"name":"console"') || bodyContent.includes('"name":"process"') || bodyContent.includes('"type":"AssignmentExpression"')) {
|
|
@@ -9,7 +9,7 @@ function analyzeNodeMetadata(node, code, options) {
|
|
|
9
9
|
hasSideEffects: false
|
|
10
10
|
};
|
|
11
11
|
try {
|
|
12
|
-
let prev = node.previousSibling
|
|
12
|
+
let prev = node.previousSibling;
|
|
13
13
|
while (prev && /comment/i.test(prev.type)) {
|
|
14
14
|
const text = prev.text || "";
|
|
15
15
|
const loc = {
|
|
@@ -49,7 +49,7 @@ function analyzeNodeMetadata(node, code, options) {
|
|
|
49
49
|
prev = prev.previousSibling;
|
|
50
50
|
}
|
|
51
51
|
if (node.type === "function_definition" || node.type === "class_definition") {
|
|
52
|
-
const body2 = node.childForFieldName
|
|
52
|
+
const body2 = node.childForFieldName("body") || node.children.find((c) => c.type === "block");
|
|
53
53
|
if (body2 && body2.children.length > 0) {
|
|
54
54
|
const firstStmt = body2.children[0];
|
|
55
55
|
if (firstStmt.type === "expression_statement" && firstStmt.firstChild?.type === "string") {
|
|
@@ -113,7 +113,7 @@ function analyzeNodeMetadata(node, code, options) {
|
|
|
113
113
|
} catch {
|
|
114
114
|
}
|
|
115
115
|
};
|
|
116
|
-
const body = node.childForFieldName
|
|
116
|
+
const body = node.childForFieldName("body") || node.children.find(
|
|
117
117
|
(c) => /body|block|class_body|declaration_list|function_body/.test(c.type)
|
|
118
118
|
);
|
|
119
119
|
if (body) walk(body);
|
|
@@ -179,6 +179,9 @@ var PythonParser = class extends BaseLanguageParser {
|
|
|
179
179
|
this.language = "python" /* Python */;
|
|
180
180
|
this.extensions = [".py"];
|
|
181
181
|
}
|
|
182
|
+
/**
|
|
183
|
+
* Returns the canonical name of this parser.
|
|
184
|
+
*/
|
|
182
185
|
getParserName() {
|
|
183
186
|
return "python";
|
|
184
187
|
}
|
|
@@ -379,10 +382,7 @@ var PythonParser = class extends BaseLanguageParser {
|
|
|
379
382
|
(c) => c.type === PYTHON_CONSTANTS.NODES.IDENTIFIER || c.type === PYTHON_CONSTANTS.NODES.TYPED_PARAMETER || c.type === PYTHON_CONSTANTS.NODES.DEFAULT_PARAMETER
|
|
380
383
|
).map((c) => {
|
|
381
384
|
if (c.type === PYTHON_CONSTANTS.NODES.IDENTIFIER) return c.text;
|
|
382
|
-
|
|
383
|
-
return c.firstChild?.text || "unknown";
|
|
384
|
-
}
|
|
385
|
-
return "unknown";
|
|
385
|
+
return c.firstChild?.text || "unknown";
|
|
386
386
|
});
|
|
387
387
|
}
|
|
388
388
|
/**
|
|
@@ -401,10 +401,13 @@ var PythonParser = class extends BaseLanguageParser {
|
|
|
401
401
|
]
|
|
402
402
|
};
|
|
403
403
|
} catch (error) {
|
|
404
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
404
405
|
const wrapper = new Error(
|
|
405
|
-
`Failed to parse Python file ${filePath}: ${
|
|
406
|
+
`Failed to parse Python file ${filePath}: ${message}`
|
|
406
407
|
);
|
|
407
|
-
|
|
408
|
+
if (error instanceof Error) {
|
|
409
|
+
wrapper.cause = error;
|
|
410
|
+
}
|
|
408
411
|
throw wrapper;
|
|
409
412
|
}
|
|
410
413
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
analyzeGeneralMetadata,
|
|
3
3
|
extractParameterNames
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-DHFOYNMW.mjs";
|
|
5
5
|
import {
|
|
6
6
|
BaseLanguageParser
|
|
7
7
|
} from "./chunk-2N7ISIKE.mjs";
|
|
@@ -161,11 +161,17 @@ var CSharpParser = class extends BaseLanguageParser {
|
|
|
161
161
|
const isPublic = modifiers.includes("public") || modifiers.includes("protected");
|
|
162
162
|
if (isPublic) {
|
|
163
163
|
const metadata = this.analyzeMetadata(node, code);
|
|
164
|
-
const
|
|
164
|
+
const nodeType = node.type.replace("_declaration", "");
|
|
165
|
+
let exportType = "class";
|
|
166
|
+
if (nodeType === "record" || nodeType === "struct" || nodeType === "enum") {
|
|
167
|
+
exportType = "class";
|
|
168
|
+
} else if (nodeType === "interface" || nodeType === "interface_declaration") {
|
|
169
|
+
exportType = "interface";
|
|
170
|
+
}
|
|
165
171
|
const fullName = nextClass ? `${nextClass}.${nameNode.text}` : nextNamespace ? `${nextNamespace}.${nameNode.text}` : nameNode.text;
|
|
166
|
-
|
|
172
|
+
const exportItem = {
|
|
167
173
|
name: fullName,
|
|
168
|
-
type:
|
|
174
|
+
type: exportType,
|
|
169
175
|
loc: {
|
|
170
176
|
start: {
|
|
171
177
|
line: node.startPosition.row + 1,
|
|
@@ -178,7 +184,8 @@ var CSharpParser = class extends BaseLanguageParser {
|
|
|
178
184
|
},
|
|
179
185
|
visibility: modifiers.includes("public") ? "public" : "protected",
|
|
180
186
|
...metadata
|
|
181
|
-
}
|
|
187
|
+
};
|
|
188
|
+
exports.push(exportItem);
|
|
182
189
|
nextClass = fullName;
|
|
183
190
|
}
|
|
184
191
|
}
|
|
@@ -189,9 +196,9 @@ var CSharpParser = class extends BaseLanguageParser {
|
|
|
189
196
|
const isPublic = modifiers.includes("public") || modifiers.includes("protected");
|
|
190
197
|
if (isPublic) {
|
|
191
198
|
const metadata = this.analyzeMetadata(node, code);
|
|
192
|
-
|
|
199
|
+
const methodItem = {
|
|
193
200
|
name: nameNode.text,
|
|
194
|
-
type: node.type === "method_declaration" ? "function" : "
|
|
201
|
+
type: node.type === "method_declaration" ? "function" : "variable",
|
|
195
202
|
parentClass: currentClass,
|
|
196
203
|
loc: {
|
|
197
204
|
start: {
|
|
@@ -206,7 +213,8 @@ var CSharpParser = class extends BaseLanguageParser {
|
|
|
206
213
|
visibility: modifiers.includes("public") ? "public" : "protected",
|
|
207
214
|
parameters: node.type === "method_declaration" ? this.extractParameters(node) : void 0,
|
|
208
215
|
...metadata
|
|
209
|
-
}
|
|
216
|
+
};
|
|
217
|
+
exports.push(methodItem);
|
|
210
218
|
}
|
|
211
219
|
}
|
|
212
220
|
}
|