@aiready/core 0.23.20 → 0.23.21
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-2N7ISIKE.mjs +158 -0
- package/dist/chunk-ARUIZO7M.mjs +297 -0
- package/dist/chunk-CYC5EGEI.mjs +297 -0
- package/dist/{chunk-REU6OUBT.mjs → chunk-DBOPSRBC.mjs} +47 -22
- package/dist/chunk-EZ7ECLAZ.mjs +299 -0
- package/dist/chunk-FNPULWG7.mjs +248 -0
- package/dist/chunk-FZTFKZUQ.mjs +250 -0
- package/dist/chunk-GTS642BQ.mjs +262 -0
- package/dist/chunk-IXPY5J4K.mjs +248 -0
- package/dist/chunk-JJQLYW6Z.mjs +111 -0
- package/dist/chunk-L6BKANJC.mjs +130 -0
- package/dist/chunk-LXEO5PG3.mjs +292 -0
- package/dist/chunk-LZHO636W.mjs +501 -0
- package/dist/chunk-MTK2IIDZ.mjs +262 -0
- package/dist/chunk-QDCQETSI.mjs +262 -0
- package/dist/chunk-QZNY7B2N.mjs +248 -0
- package/dist/chunk-RCZSMGCX.mjs +250 -0
- package/dist/chunk-SWZOT67M.mjs +250 -0
- package/dist/chunk-U3IY2CFC.mjs +36 -0
- package/dist/chunk-UBCM5Y6R.mjs +275 -0
- package/dist/chunk-UTCRW3N7.mjs +301 -0
- package/dist/{chunk-SQHS6PFL.mjs → chunk-UYLH35LA.mjs} +47 -22
- package/dist/{chunk-ZB3EHHAG.mjs → chunk-WVNVC2PP.mjs} +90 -60
- package/dist/chunk-WYOW6O3P.mjs +114 -0
- package/dist/{chunk-RMH2TPAT.mjs → chunk-YRSSR4KN.mjs} +87 -59
- package/dist/client-2xbeKnrg.d.mts +1291 -0
- package/dist/client-2xbeKnrg.d.ts +1291 -0
- package/dist/client-4HLAGzFg.d.mts +1291 -0
- package/dist/client-4HLAGzFg.d.ts +1291 -0
- package/dist/client-B4TQwNa7.d.mts +1290 -0
- package/dist/client-B4TQwNa7.d.ts +1290 -0
- package/dist/client-Bdi4ty0v.d.mts +1294 -0
- package/dist/client-Bdi4ty0v.d.ts +1294 -0
- package/dist/client-BsKpUH3H.d.mts +1339 -0
- package/dist/client-BsKpUH3H.d.ts +1339 -0
- package/dist/client-Bv1zOaWF.d.mts +1291 -0
- package/dist/client-Bv1zOaWF.d.ts +1291 -0
- package/dist/client-Bz9YJMIX.d.mts +1290 -0
- package/dist/client-Bz9YJMIX.d.ts +1290 -0
- package/dist/client-CBpzm34X.d.mts +1291 -0
- package/dist/client-CBpzm34X.d.ts +1291 -0
- package/dist/client-CNu_tCZZ.d.mts +1305 -0
- package/dist/client-CNu_tCZZ.d.ts +1305 -0
- package/dist/client-CmEvxxQu.d.mts +1339 -0
- package/dist/client-CmEvxxQu.d.ts +1339 -0
- package/dist/client-DGMAxkZc.d.mts +1339 -0
- package/dist/client-DGMAxkZc.d.ts +1339 -0
- package/dist/client-DZq-CqcD.d.mts +1292 -0
- package/dist/client-DZq-CqcD.d.ts +1292 -0
- package/dist/{client-CYz0qxGB.d.mts → client-DcqGfDTt.d.mts} +90 -23
- package/dist/{client-CYz0qxGB.d.ts → client-DcqGfDTt.d.ts} +90 -23
- package/dist/{client-jGuH6TAG.d.mts → client-O8RvSRm0.d.mts} +18 -1
- package/dist/{client-jGuH6TAG.d.ts → client-O8RvSRm0.d.ts} +18 -1
- package/dist/client.d.mts +1 -1
- package/dist/client.d.ts +1 -1
- package/dist/client.js +47 -13
- package/dist/client.mjs +6 -4
- package/dist/csharp-parser-4ZKCSX5B.mjs +9 -0
- package/dist/csharp-parser-5HKICCRR.mjs +9 -0
- package/dist/csharp-parser-JCKXIAJW.mjs +9 -0
- package/dist/go-parser-J4KIH4RG.mjs +9 -0
- package/dist/go-parser-TKXL3DVH.mjs +9 -0
- package/dist/go-parser-XOM232XZ.mjs +9 -0
- package/dist/index.d.mts +269 -60
- package/dist/index.d.ts +269 -60
- package/dist/index.js +3733 -3031
- package/dist/index.mjs +802 -2029
- package/dist/java-parser-3KHXOXRQ.mjs +9 -0
- package/dist/java-parser-MASGS4WB.mjs +9 -0
- package/dist/java-parser-T5LXD63J.mjs +9 -0
- package/dist/python-parser-FNFK2473.mjs +8 -0
- package/dist/typescript-parser-2GGNRNB5.mjs +7 -0
- package/dist/typescript-parser-3ENJ6C7H.mjs +7 -0
- package/dist/typescript-parser-4GI7DPSW.mjs +7 -0
- package/dist/typescript-parser-4H3HUBO4.mjs +7 -0
- package/dist/typescript-parser-K63IVZMF.mjs +7 -0
- package/dist/typescript-parser-ZJKROMQG.mjs +7 -0
- package/package.json +1 -1
- package/dist/chunk-2Y6WZCES.mjs +0 -859
- package/dist/chunk-5SHLHMH7.mjs +0 -760
- package/dist/chunk-CGOS2J6T.mjs +0 -807
- package/dist/chunk-FMNCV4CC.mjs +0 -859
- package/dist/chunk-Q55AMEFV.mjs +0 -760
- package/dist/chunk-ST75O5C5.mjs +0 -859
- package/dist/chunk-TJXR2CHZ.mjs +0 -799
- package/dist/client-BEoUYNLp.d.mts +0 -1191
- package/dist/client-BEoUYNLp.d.ts +0 -1191
- package/dist/client-BrIMPk89.d.mts +0 -1214
- package/dist/client-BrIMPk89.d.ts +0 -1214
- package/dist/client-C5BuGX4F.d.mts +0 -1205
- package/dist/client-C5BuGX4F.d.ts +0 -1205
- package/dist/client-CKcjnPXt.d.mts +0 -1214
- package/dist/client-CKcjnPXt.d.ts +0 -1214
- package/dist/client-CLulBnie.d.mts +0 -1182
- package/dist/client-CLulBnie.d.ts +0 -1182
- package/dist/client-CQwvp8ep.d.mts +0 -1182
- package/dist/client-CQwvp8ep.d.ts +0 -1182
- package/dist/client-DLvFR2qA.d.mts +0 -1197
- package/dist/client-DLvFR2qA.d.ts +0 -1197
- package/dist/client-PFPdeo-z.d.mts +0 -1186
- package/dist/client-PFPdeo-z.d.ts +0 -1186
- package/dist/client-WVCAIWdJ.d.mts +0 -1192
- package/dist/client-WVCAIWdJ.d.ts +0 -1192
- package/dist/client-pYldIAg2.d.mts +0 -1209
- package/dist/client-pYldIAg2.d.ts +0 -1209
- package/dist/client-wk2fgk1q.d.mts +0 -1184
- package/dist/client-wk2fgk1q.d.ts +0 -1184
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ParseError
|
|
3
|
+
} from "./chunk-U3IY2CFC.mjs";
|
|
4
|
+
|
|
5
|
+
// src/parsers/typescript-parser.ts
|
|
6
|
+
import { parse } from "@typescript-eslint/typescript-estree";
|
|
7
|
+
var TypeScriptParser = class {
|
|
8
|
+
constructor() {
|
|
9
|
+
this.language = "typescript" /* TypeScript */;
|
|
10
|
+
this.extensions = [".ts", ".tsx", ".js", ".jsx"];
|
|
11
|
+
}
|
|
12
|
+
async initialize() {
|
|
13
|
+
}
|
|
14
|
+
canHandle(filePath2) {
|
|
15
|
+
return this.extensions.some((ext) => filePath2.endsWith(ext));
|
|
16
|
+
}
|
|
17
|
+
async getAST(code, filePath2) {
|
|
18
|
+
try {
|
|
19
|
+
return parse(code, {
|
|
20
|
+
filePath: filePath2,
|
|
21
|
+
loc: true,
|
|
22
|
+
range: true,
|
|
23
|
+
tokens: true,
|
|
24
|
+
comment: true,
|
|
25
|
+
jsx: filePath2.endsWith("x")
|
|
26
|
+
});
|
|
27
|
+
} catch (error) {
|
|
28
|
+
throw new ParseError(error.message, filePath2, {
|
|
29
|
+
line: error.lineNumber || 1,
|
|
30
|
+
column: error.column || 0
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
parse(code, filePath2) {
|
|
35
|
+
try {
|
|
36
|
+
const ast = parse(code, {
|
|
37
|
+
filePath: filePath2,
|
|
38
|
+
loc: true,
|
|
39
|
+
range: true,
|
|
40
|
+
tokens: true,
|
|
41
|
+
comment: true,
|
|
42
|
+
jsx: filePath2.endsWith("x")
|
|
43
|
+
});
|
|
44
|
+
const imports = this.extractImports(ast);
|
|
45
|
+
const exports = this.extractExports(ast, code);
|
|
46
|
+
return {
|
|
47
|
+
exports,
|
|
48
|
+
imports,
|
|
49
|
+
language: this.language
|
|
50
|
+
};
|
|
51
|
+
} catch (error) {
|
|
52
|
+
throw new ParseError(error.message, filePath2, {
|
|
53
|
+
line: error.lineNumber || 1,
|
|
54
|
+
column: error.column || 0
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
getNamingConventions() {
|
|
59
|
+
return {
|
|
60
|
+
variablePattern: /^[a-z][a-zA-Z0-9]*$/,
|
|
61
|
+
functionPattern: /^[a-z][a-zA-Z0-9]*$/,
|
|
62
|
+
classPattern: /^[A-Z][a-zA-Z0-9]*$/,
|
|
63
|
+
constantPattern: /^[A-Z][A-Z0-9_]*$/,
|
|
64
|
+
typePattern: /^[A-Z][a-zA-Z0-9]*$/,
|
|
65
|
+
interfacePattern: /^I?[A-Z][a-zA-Z0-9]*$/
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
analyzeMetadata(node, code) {
|
|
69
|
+
if (!code) return {};
|
|
70
|
+
return {
|
|
71
|
+
isPure: this.isLikelyPure(node),
|
|
72
|
+
hasSideEffects: !this.isLikelyPure(node)
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
extractImports(ast) {
|
|
76
|
+
const imports = [];
|
|
77
|
+
for (const node of ast.body) {
|
|
78
|
+
if (node.type === "ImportDeclaration") {
|
|
79
|
+
const specifiers = [];
|
|
80
|
+
let isTypeOnly = false;
|
|
81
|
+
if (node.importKind === "type") {
|
|
82
|
+
isTypeOnly = true;
|
|
83
|
+
}
|
|
84
|
+
for (const spec of node.specifiers) {
|
|
85
|
+
if (spec.type === "ImportSpecifier") {
|
|
86
|
+
const imported = spec.imported;
|
|
87
|
+
const name = imported.type === "Identifier" ? imported.name : imported.value;
|
|
88
|
+
specifiers.push(name);
|
|
89
|
+
} else if (spec.type === "ImportDefaultSpecifier") {
|
|
90
|
+
specifiers.push("default");
|
|
91
|
+
} else if (spec.type === "ImportNamespaceSpecifier") {
|
|
92
|
+
specifiers.push("*");
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
imports.push({
|
|
96
|
+
source: node.source.value,
|
|
97
|
+
specifiers,
|
|
98
|
+
isTypeOnly,
|
|
99
|
+
loc: node.loc ? {
|
|
100
|
+
start: {
|
|
101
|
+
line: node.loc.start.line,
|
|
102
|
+
column: node.loc.start.column
|
|
103
|
+
},
|
|
104
|
+
end: { line: node.loc.end.line, column: node.loc.end.column }
|
|
105
|
+
} : void 0
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return imports;
|
|
110
|
+
}
|
|
111
|
+
extractExports(ast, code) {
|
|
112
|
+
const exports = [];
|
|
113
|
+
for (const node of ast.body) {
|
|
114
|
+
if (node.type === "ExportNamedDeclaration") {
|
|
115
|
+
if (node.declaration) {
|
|
116
|
+
const declaration = node.declaration;
|
|
117
|
+
if ((declaration.type === "FunctionDeclaration" || declaration.type === "TSDeclareFunction") && declaration.id) {
|
|
118
|
+
exports.push(
|
|
119
|
+
this.createExport(
|
|
120
|
+
declaration.id.name,
|
|
121
|
+
"function",
|
|
122
|
+
node,
|
|
123
|
+
// Pass the outer ExportNamedDeclaration
|
|
124
|
+
code,
|
|
125
|
+
filePath
|
|
126
|
+
)
|
|
127
|
+
);
|
|
128
|
+
} else if (declaration.type === "ClassDeclaration" && declaration.id) {
|
|
129
|
+
exports.push(
|
|
130
|
+
this.createExport(
|
|
131
|
+
declaration.id.name,
|
|
132
|
+
"class",
|
|
133
|
+
node,
|
|
134
|
+
// Pass the outer ExportNamedDeclaration
|
|
135
|
+
code,
|
|
136
|
+
filePath
|
|
137
|
+
)
|
|
138
|
+
);
|
|
139
|
+
} else if (declaration.type === "TSTypeAliasDeclaration") {
|
|
140
|
+
exports.push(
|
|
141
|
+
this.createExport(
|
|
142
|
+
declaration.id.name,
|
|
143
|
+
"type",
|
|
144
|
+
node,
|
|
145
|
+
// Pass the outer ExportNamedDeclaration
|
|
146
|
+
code,
|
|
147
|
+
filePath
|
|
148
|
+
)
|
|
149
|
+
);
|
|
150
|
+
} else if (declaration.type === "TSInterfaceDeclaration") {
|
|
151
|
+
exports.push(
|
|
152
|
+
this.createExport(
|
|
153
|
+
declaration.id.name,
|
|
154
|
+
"interface",
|
|
155
|
+
node,
|
|
156
|
+
// Pass the outer ExportNamedDeclaration
|
|
157
|
+
code,
|
|
158
|
+
filePath
|
|
159
|
+
)
|
|
160
|
+
);
|
|
161
|
+
} else if (declaration.type === "VariableDeclaration") {
|
|
162
|
+
for (const decl of declaration.declarations) {
|
|
163
|
+
if (decl.id.type === "Identifier") {
|
|
164
|
+
exports.push(
|
|
165
|
+
this.createExport(
|
|
166
|
+
decl.id.name,
|
|
167
|
+
"const",
|
|
168
|
+
node,
|
|
169
|
+
// Pass the outer ExportNamedDeclaration
|
|
170
|
+
code,
|
|
171
|
+
filePath,
|
|
172
|
+
decl.init
|
|
173
|
+
)
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
} else if (node.type === "ExportDefaultDeclaration") {
|
|
180
|
+
exports.push(this.createExport("default", "default", node, code, filePath));
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
return exports;
|
|
184
|
+
}
|
|
185
|
+
createExport(name, type, node, code, filePath2, initializer) {
|
|
186
|
+
const documentation = this.extractDocumentation(node, code);
|
|
187
|
+
let methodCount;
|
|
188
|
+
let propertyCount;
|
|
189
|
+
let parameters;
|
|
190
|
+
let isPrimitive = false;
|
|
191
|
+
let isTyped = false;
|
|
192
|
+
if (initializer) {
|
|
193
|
+
if (initializer.type === "Literal" || initializer.type === "TemplateLiteral" && initializer.expressions.length === 0) {
|
|
194
|
+
isPrimitive = true;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
const structNode = node.type === "ExportNamedDeclaration" ? node.declaration : node.type === "ExportDefaultDeclaration" ? node.declaration : node;
|
|
198
|
+
if (filePath2.endsWith(".ts") || filePath2.endsWith(".tsx")) {
|
|
199
|
+
if (structNode.type === "TSTypeAliasDeclaration" || structNode.type === "TSInterfaceDeclaration" || structNode.type === "TSEnumDeclaration") {
|
|
200
|
+
isTyped = true;
|
|
201
|
+
} else if (structNode.type === "FunctionDeclaration" || structNode.type === "TSDeclareFunction") {
|
|
202
|
+
const hasReturnType = !!structNode.returnType;
|
|
203
|
+
const allParamsTyped = structNode.params.length === 0 || structNode.params.every((p) => !!p.typeAnnotation);
|
|
204
|
+
isTyped = hasReturnType && allParamsTyped;
|
|
205
|
+
} else if (structNode.type === "VariableDeclaration") {
|
|
206
|
+
isTyped = structNode.declarations.every(
|
|
207
|
+
(d) => !!d.id.typeAnnotation || !!d.init
|
|
208
|
+
);
|
|
209
|
+
} else if (structNode.type === "ClassDeclaration") {
|
|
210
|
+
isTyped = true;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
if (structNode.type === "ClassDeclaration" || structNode.type === "TSInterfaceDeclaration") {
|
|
214
|
+
const body = structNode.type === "ClassDeclaration" ? structNode.body.body : structNode.body.body;
|
|
215
|
+
methodCount = body.filter(
|
|
216
|
+
(m) => m.type === "MethodDefinition" || m.type === "TSMethodSignature"
|
|
217
|
+
).length;
|
|
218
|
+
propertyCount = body.filter(
|
|
219
|
+
(m) => m.type === "PropertyDefinition" || m.type === "TSPropertySignature"
|
|
220
|
+
).length;
|
|
221
|
+
if (structNode.type === "ClassDeclaration") {
|
|
222
|
+
const constructor = body.find(
|
|
223
|
+
(m) => m.type === "MethodDefinition" && m.kind === "constructor"
|
|
224
|
+
);
|
|
225
|
+
if (constructor && constructor.value && constructor.value.params) {
|
|
226
|
+
parameters = constructor.value.params.map((p) => {
|
|
227
|
+
if (p.type === "Identifier") return p.name;
|
|
228
|
+
if (p.type === "TSParameterProperty" && p.parameter.type === "Identifier") {
|
|
229
|
+
return p.parameter.name;
|
|
230
|
+
}
|
|
231
|
+
return void 0;
|
|
232
|
+
}).filter(Boolean);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
if (!parameters && (structNode.type === "FunctionDeclaration" || structNode.type === "TSDeclareFunction" || structNode.type === "MethodDefinition")) {
|
|
237
|
+
const funcNode = structNode.type === "MethodDefinition" ? structNode.value : structNode;
|
|
238
|
+
if (funcNode && funcNode.params) {
|
|
239
|
+
parameters = funcNode.params.map((p) => {
|
|
240
|
+
if (p.type === "Identifier") return p.name;
|
|
241
|
+
return void 0;
|
|
242
|
+
}).filter(Boolean);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
return {
|
|
246
|
+
name,
|
|
247
|
+
type,
|
|
248
|
+
isPrimitive,
|
|
249
|
+
loc: node.loc ? {
|
|
250
|
+
start: { line: node.loc.start.line, column: node.loc.start.column },
|
|
251
|
+
end: { line: node.loc.end.line, column: node.loc.end.column }
|
|
252
|
+
} : void 0,
|
|
253
|
+
documentation,
|
|
254
|
+
methodCount,
|
|
255
|
+
propertyCount,
|
|
256
|
+
parameters,
|
|
257
|
+
isPure: this.isLikelyPure(node),
|
|
258
|
+
hasSideEffects: !this.isLikelyPure(node),
|
|
259
|
+
isTyped
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
extractDocumentation(node, code) {
|
|
263
|
+
if (node.range) {
|
|
264
|
+
const start = node.range[0];
|
|
265
|
+
const precedingCode = code.substring(0, start);
|
|
266
|
+
const jsdocMatch = precedingCode.match(/\/\*\*([\s\S]*?)\*\/\s*$/);
|
|
267
|
+
if (jsdocMatch) {
|
|
268
|
+
return {
|
|
269
|
+
content: jsdocMatch[1].trim(),
|
|
270
|
+
type: "jsdoc"
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
return void 0;
|
|
275
|
+
}
|
|
276
|
+
isLikelyPure(node) {
|
|
277
|
+
const structNode = node.type === "ExportNamedDeclaration" ? node.declaration : node.type === "ExportDefaultDeclaration" ? node.declaration : node;
|
|
278
|
+
if (structNode.type === "VariableDeclaration" && structNode.kind === "const")
|
|
279
|
+
return true;
|
|
280
|
+
if (structNode.type === "FunctionDeclaration" || structNode.type === "TSDeclareFunction" || structNode.type === "MethodDefinition" && structNode.value) {
|
|
281
|
+
const body = structNode.type === "MethodDefinition" ? structNode.value.body : structNode.body;
|
|
282
|
+
if (body && body.type === "BlockStatement") {
|
|
283
|
+
const bodyContent = JSON.stringify(body);
|
|
284
|
+
if (bodyContent.includes('"name":"console"') || bodyContent.includes('"name":"process"') || bodyContent.includes('"type":"AssignmentExpression"')) {
|
|
285
|
+
return false;
|
|
286
|
+
}
|
|
287
|
+
return true;
|
|
288
|
+
}
|
|
289
|
+
return true;
|
|
290
|
+
}
|
|
291
|
+
return false;
|
|
292
|
+
}
|
|
293
|
+
};
|
|
294
|
+
|
|
295
|
+
export {
|
|
296
|
+
TypeScriptParser
|
|
297
|
+
};
|
|
@@ -344,26 +344,54 @@ var ReadinessRating = /* @__PURE__ */ ((ReadinessRating2) => {
|
|
|
344
344
|
ReadinessRating2["Critical"] = "Critical";
|
|
345
345
|
return ReadinessRating2;
|
|
346
346
|
})(ReadinessRating || {});
|
|
347
|
+
function getRatingMetadata(score) {
|
|
348
|
+
if (score >= 90) {
|
|
349
|
+
return {
|
|
350
|
+
label: "Excellent",
|
|
351
|
+
slug: "excellent",
|
|
352
|
+
emoji: "\u2705",
|
|
353
|
+
rating: "Excellent" /* Excellent */
|
|
354
|
+
};
|
|
355
|
+
}
|
|
356
|
+
if (score >= 75) {
|
|
357
|
+
return {
|
|
358
|
+
label: "Good",
|
|
359
|
+
slug: "good",
|
|
360
|
+
emoji: "\u{1F44D}",
|
|
361
|
+
rating: "Good" /* Good */
|
|
362
|
+
};
|
|
363
|
+
}
|
|
364
|
+
if (score >= 60) {
|
|
365
|
+
return {
|
|
366
|
+
label: "Fair",
|
|
367
|
+
slug: "fair",
|
|
368
|
+
emoji: "\u{1F44C}",
|
|
369
|
+
rating: "Fair" /* Fair */
|
|
370
|
+
};
|
|
371
|
+
}
|
|
372
|
+
if (score >= 40) {
|
|
373
|
+
return {
|
|
374
|
+
label: "Needs Work",
|
|
375
|
+
slug: "needs-work",
|
|
376
|
+
emoji: "\u{1F528}",
|
|
377
|
+
rating: "Needs Work" /* NeedsWork */
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
return {
|
|
381
|
+
label: "Critical",
|
|
382
|
+
slug: "critical",
|
|
383
|
+
emoji: "\u{1F6A8}",
|
|
384
|
+
rating: "Critical" /* Critical */
|
|
385
|
+
};
|
|
386
|
+
}
|
|
347
387
|
function getRatingLabel(score) {
|
|
348
|
-
|
|
349
|
-
if (score >= 75) return "Good";
|
|
350
|
-
if (score >= 60) return "Fair";
|
|
351
|
-
if (score >= 40) return "Needs Work";
|
|
352
|
-
return "Critical";
|
|
388
|
+
return getRatingMetadata(score).label;
|
|
353
389
|
}
|
|
354
390
|
function getRatingSlug(score) {
|
|
355
|
-
|
|
356
|
-
if (score >= 75) return "good";
|
|
357
|
-
if (score >= 60) return "fair";
|
|
358
|
-
if (score >= 40) return "needs-work";
|
|
359
|
-
return "critical";
|
|
391
|
+
return getRatingMetadata(score).slug;
|
|
360
392
|
}
|
|
361
393
|
function getRatingEmoji(score) {
|
|
362
|
-
|
|
363
|
-
if (score >= 75) return "\u{1F44D}";
|
|
364
|
-
if (score >= 60) return "\u{1F44C}";
|
|
365
|
-
if (score >= 40) return "\u{1F528}";
|
|
366
|
-
return "\u{1F6A8}";
|
|
394
|
+
return getRatingMetadata(score).emoji;
|
|
367
395
|
}
|
|
368
396
|
function getToolEmoji(score) {
|
|
369
397
|
return getRatingEmoji(score);
|
|
@@ -383,11 +411,7 @@ function getPriorityIcon(priority) {
|
|
|
383
411
|
}
|
|
384
412
|
}
|
|
385
413
|
function getRating(score) {
|
|
386
|
-
|
|
387
|
-
if (score >= 75) return "Good" /* Good */;
|
|
388
|
-
if (score >= 60) return "Fair" /* Fair */;
|
|
389
|
-
if (score >= 40) return "Needs Work" /* NeedsWork */;
|
|
390
|
-
return "Critical" /* Critical */;
|
|
414
|
+
return getRatingMetadata(score).rating;
|
|
391
415
|
}
|
|
392
416
|
|
|
393
417
|
// src/scoring.ts
|
|
@@ -557,8 +581,8 @@ function calculateOverallScore(toolOutputs, config, cliWeights) {
|
|
|
557
581
|
const rating = getRating(overall);
|
|
558
582
|
const formulaParts = Array.from(toolOutputs.entries()).map(
|
|
559
583
|
([name, output]) => {
|
|
560
|
-
const
|
|
561
|
-
return `(${output.score} \xD7 ${
|
|
584
|
+
const weight = weights.get(name) ?? 5;
|
|
585
|
+
return `(${output.score} \xD7 ${weight})`;
|
|
562
586
|
}
|
|
563
587
|
);
|
|
564
588
|
const formulaStr = `[${formulaParts.join(" + ")}] / ${totalWeight} = ${overall}`;
|
|
@@ -832,6 +856,7 @@ export {
|
|
|
832
856
|
LANGUAGE_EXTENSIONS,
|
|
833
857
|
ParseError,
|
|
834
858
|
ReadinessRating,
|
|
859
|
+
getRatingMetadata,
|
|
835
860
|
getRatingLabel,
|
|
836
861
|
getRatingSlug,
|
|
837
862
|
getRatingEmoji,
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ParseError
|
|
3
|
+
} from "./chunk-U3IY2CFC.mjs";
|
|
4
|
+
|
|
5
|
+
// src/parsers/typescript-parser.ts
|
|
6
|
+
import { parse } from "@typescript-eslint/typescript-estree";
|
|
7
|
+
var TypeScriptParser = class {
|
|
8
|
+
constructor() {
|
|
9
|
+
this.language = "typescript" /* TypeScript */;
|
|
10
|
+
this.extensions = [".ts", ".tsx", ".js", ".jsx"];
|
|
11
|
+
}
|
|
12
|
+
async initialize() {
|
|
13
|
+
}
|
|
14
|
+
canHandle(filePath) {
|
|
15
|
+
return this.extensions.some((ext) => filePath.endsWith(ext));
|
|
16
|
+
}
|
|
17
|
+
async getAST(code, filePath) {
|
|
18
|
+
try {
|
|
19
|
+
return parse(code, {
|
|
20
|
+
filePath,
|
|
21
|
+
loc: true,
|
|
22
|
+
range: true,
|
|
23
|
+
tokens: true,
|
|
24
|
+
comment: true,
|
|
25
|
+
jsx: filePath.endsWith("x")
|
|
26
|
+
});
|
|
27
|
+
} catch (error) {
|
|
28
|
+
throw new ParseError(error.message, filePath, {
|
|
29
|
+
line: error.lineNumber || 1,
|
|
30
|
+
column: error.column || 0
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
parse(code, filePath) {
|
|
35
|
+
try {
|
|
36
|
+
const ast = parse(code, {
|
|
37
|
+
filePath,
|
|
38
|
+
loc: true,
|
|
39
|
+
range: true,
|
|
40
|
+
tokens: true,
|
|
41
|
+
comment: true,
|
|
42
|
+
jsx: filePath.endsWith("x")
|
|
43
|
+
});
|
|
44
|
+
const imports = this.extractImports(ast);
|
|
45
|
+
const exports = this.extractExports(ast, code, filePath);
|
|
46
|
+
return {
|
|
47
|
+
exports,
|
|
48
|
+
imports,
|
|
49
|
+
language: this.language
|
|
50
|
+
};
|
|
51
|
+
} catch (error) {
|
|
52
|
+
throw new ParseError(error.message, filePath, {
|
|
53
|
+
line: error.lineNumber || 1,
|
|
54
|
+
column: error.column || 0
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
getNamingConventions() {
|
|
59
|
+
return {
|
|
60
|
+
variablePattern: /^[a-z][a-zA-Z0-9]*$/,
|
|
61
|
+
functionPattern: /^[a-z][a-zA-Z0-9]*$/,
|
|
62
|
+
classPattern: /^[A-Z][a-zA-Z0-9]*$/,
|
|
63
|
+
constantPattern: /^[A-Z][A-Z0-9_]*$/,
|
|
64
|
+
typePattern: /^[A-Z][a-zA-Z0-9]*$/,
|
|
65
|
+
interfacePattern: /^I?[A-Z][a-zA-Z0-9]*$/
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
analyzeMetadata(node, code) {
|
|
69
|
+
if (!code) return {};
|
|
70
|
+
return {
|
|
71
|
+
isPure: this.isLikelyPure(node),
|
|
72
|
+
hasSideEffects: !this.isLikelyPure(node)
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
extractImports(ast) {
|
|
76
|
+
const imports = [];
|
|
77
|
+
for (const node of ast.body) {
|
|
78
|
+
if (node.type === "ImportDeclaration") {
|
|
79
|
+
const specifiers = [];
|
|
80
|
+
let isTypeOnly = false;
|
|
81
|
+
if (node.importKind === "type") {
|
|
82
|
+
isTypeOnly = true;
|
|
83
|
+
}
|
|
84
|
+
for (const spec of node.specifiers) {
|
|
85
|
+
if (spec.type === "ImportSpecifier") {
|
|
86
|
+
const imported = spec.imported;
|
|
87
|
+
const name = imported.type === "Identifier" ? imported.name : imported.value;
|
|
88
|
+
specifiers.push(name);
|
|
89
|
+
} else if (spec.type === "ImportDefaultSpecifier") {
|
|
90
|
+
specifiers.push("default");
|
|
91
|
+
} else if (spec.type === "ImportNamespaceSpecifier") {
|
|
92
|
+
specifiers.push("*");
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
imports.push({
|
|
96
|
+
source: node.source.value,
|
|
97
|
+
specifiers,
|
|
98
|
+
isTypeOnly,
|
|
99
|
+
loc: node.loc ? {
|
|
100
|
+
start: {
|
|
101
|
+
line: node.loc.start.line,
|
|
102
|
+
column: node.loc.start.column
|
|
103
|
+
},
|
|
104
|
+
end: { line: node.loc.end.line, column: node.loc.end.column }
|
|
105
|
+
} : void 0
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return imports;
|
|
110
|
+
}
|
|
111
|
+
extractExports(ast, code, filePath) {
|
|
112
|
+
const exports = [];
|
|
113
|
+
for (const node of ast.body) {
|
|
114
|
+
if (node.type === "ExportNamedDeclaration") {
|
|
115
|
+
if (node.declaration) {
|
|
116
|
+
const declaration = node.declaration;
|
|
117
|
+
if ((declaration.type === "FunctionDeclaration" || declaration.type === "TSDeclareFunction") && declaration.id) {
|
|
118
|
+
exports.push(
|
|
119
|
+
this.createExport(
|
|
120
|
+
declaration.id.name,
|
|
121
|
+
"function",
|
|
122
|
+
node,
|
|
123
|
+
// Pass the outer ExportNamedDeclaration
|
|
124
|
+
code,
|
|
125
|
+
filePath
|
|
126
|
+
)
|
|
127
|
+
);
|
|
128
|
+
} else if (declaration.type === "ClassDeclaration" && declaration.id) {
|
|
129
|
+
exports.push(
|
|
130
|
+
this.createExport(
|
|
131
|
+
declaration.id.name,
|
|
132
|
+
"class",
|
|
133
|
+
node,
|
|
134
|
+
// Pass the outer ExportNamedDeclaration
|
|
135
|
+
code,
|
|
136
|
+
filePath
|
|
137
|
+
)
|
|
138
|
+
);
|
|
139
|
+
} else if (declaration.type === "TSTypeAliasDeclaration") {
|
|
140
|
+
exports.push(
|
|
141
|
+
this.createExport(
|
|
142
|
+
declaration.id.name,
|
|
143
|
+
"type",
|
|
144
|
+
node,
|
|
145
|
+
// Pass the outer ExportNamedDeclaration
|
|
146
|
+
code,
|
|
147
|
+
filePath
|
|
148
|
+
)
|
|
149
|
+
);
|
|
150
|
+
} else if (declaration.type === "TSInterfaceDeclaration") {
|
|
151
|
+
exports.push(
|
|
152
|
+
this.createExport(
|
|
153
|
+
declaration.id.name,
|
|
154
|
+
"interface",
|
|
155
|
+
node,
|
|
156
|
+
// Pass the outer ExportNamedDeclaration
|
|
157
|
+
code,
|
|
158
|
+
filePath
|
|
159
|
+
)
|
|
160
|
+
);
|
|
161
|
+
} else if (declaration.type === "VariableDeclaration") {
|
|
162
|
+
for (const decl of declaration.declarations) {
|
|
163
|
+
if (decl.id.type === "Identifier") {
|
|
164
|
+
exports.push(
|
|
165
|
+
this.createExport(
|
|
166
|
+
decl.id.name,
|
|
167
|
+
"const",
|
|
168
|
+
node,
|
|
169
|
+
// Pass the outer ExportNamedDeclaration
|
|
170
|
+
code,
|
|
171
|
+
filePath,
|
|
172
|
+
decl.init
|
|
173
|
+
)
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
} else if (node.type === "ExportDefaultDeclaration") {
|
|
180
|
+
exports.push(this.createExport("default", "default", node, code, filePath));
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
return exports;
|
|
184
|
+
}
|
|
185
|
+
createExport(name, type, node, code, filePath, initializer) {
|
|
186
|
+
const documentation = this.extractDocumentation(node, code);
|
|
187
|
+
let methodCount;
|
|
188
|
+
let propertyCount;
|
|
189
|
+
let parameters;
|
|
190
|
+
let isPrimitive = false;
|
|
191
|
+
let isTyped = false;
|
|
192
|
+
if (initializer) {
|
|
193
|
+
if (initializer.type === "Literal" || initializer.type === "TemplateLiteral" && initializer.expressions.length === 0) {
|
|
194
|
+
isPrimitive = true;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
const structNode = node.type === "ExportNamedDeclaration" ? node.declaration : node.type === "ExportDefaultDeclaration" ? node.declaration : node;
|
|
198
|
+
if (filePath.endsWith(".ts") || filePath.endsWith(".tsx")) {
|
|
199
|
+
if (structNode.type === "TSTypeAliasDeclaration" || structNode.type === "TSInterfaceDeclaration" || structNode.type === "TSEnumDeclaration") {
|
|
200
|
+
isTyped = true;
|
|
201
|
+
} else if (structNode.type === "FunctionDeclaration" || structNode.type === "TSDeclareFunction") {
|
|
202
|
+
const hasReturnType = !!structNode.returnType;
|
|
203
|
+
const allParamsTyped = structNode.params.length === 0 || structNode.params.every((p) => !!p.typeAnnotation);
|
|
204
|
+
isTyped = hasReturnType && allParamsTyped;
|
|
205
|
+
} else if (structNode.type === "VariableDeclaration") {
|
|
206
|
+
isTyped = structNode.declarations.every(
|
|
207
|
+
(d) => !!d.id.typeAnnotation || !!d.init
|
|
208
|
+
);
|
|
209
|
+
} else if (structNode.type === "ClassDeclaration") {
|
|
210
|
+
isTyped = true;
|
|
211
|
+
}
|
|
212
|
+
} else if (filePath.endsWith(".js") || filePath.endsWith(".jsx")) {
|
|
213
|
+
isTyped = false;
|
|
214
|
+
}
|
|
215
|
+
if (structNode.type === "ClassDeclaration" || structNode.type === "TSInterfaceDeclaration") {
|
|
216
|
+
const body = structNode.type === "ClassDeclaration" ? structNode.body.body : structNode.body.body;
|
|
217
|
+
methodCount = body.filter(
|
|
218
|
+
(m) => m.type === "MethodDefinition" || m.type === "TSMethodSignature"
|
|
219
|
+
).length;
|
|
220
|
+
propertyCount = body.filter(
|
|
221
|
+
(m) => m.type === "PropertyDefinition" || m.type === "TSPropertySignature"
|
|
222
|
+
).length;
|
|
223
|
+
if (structNode.type === "ClassDeclaration") {
|
|
224
|
+
const constructor = body.find(
|
|
225
|
+
(m) => m.type === "MethodDefinition" && m.kind === "constructor"
|
|
226
|
+
);
|
|
227
|
+
if (constructor && constructor.value && constructor.value.params) {
|
|
228
|
+
parameters = constructor.value.params.map((p) => {
|
|
229
|
+
if (p.type === "Identifier") return p.name;
|
|
230
|
+
if (p.type === "TSParameterProperty" && p.parameter.type === "Identifier") {
|
|
231
|
+
return p.parameter.name;
|
|
232
|
+
}
|
|
233
|
+
return void 0;
|
|
234
|
+
}).filter(Boolean);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
if (!parameters && (structNode.type === "FunctionDeclaration" || structNode.type === "TSDeclareFunction" || structNode.type === "MethodDefinition")) {
|
|
239
|
+
const funcNode = structNode.type === "MethodDefinition" ? structNode.value : structNode;
|
|
240
|
+
if (funcNode && funcNode.params) {
|
|
241
|
+
parameters = funcNode.params.map((p) => {
|
|
242
|
+
if (p.type === "Identifier") return p.name;
|
|
243
|
+
return void 0;
|
|
244
|
+
}).filter(Boolean);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
return {
|
|
248
|
+
name,
|
|
249
|
+
type,
|
|
250
|
+
isPrimitive,
|
|
251
|
+
loc: node.loc ? {
|
|
252
|
+
start: { line: node.loc.start.line, column: node.loc.start.column },
|
|
253
|
+
end: { line: node.loc.end.line, column: node.loc.end.column }
|
|
254
|
+
} : void 0,
|
|
255
|
+
documentation,
|
|
256
|
+
methodCount,
|
|
257
|
+
propertyCount,
|
|
258
|
+
parameters,
|
|
259
|
+
isPure: this.isLikelyPure(node),
|
|
260
|
+
hasSideEffects: !this.isLikelyPure(node),
|
|
261
|
+
isTyped
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
extractDocumentation(node, code) {
|
|
265
|
+
if (node.range) {
|
|
266
|
+
const start = node.range[0];
|
|
267
|
+
const precedingCode = code.substring(0, start);
|
|
268
|
+
const jsdocMatch = precedingCode.match(/\/\*\*([\s\S]*?)\*\/\s*$/);
|
|
269
|
+
if (jsdocMatch) {
|
|
270
|
+
return {
|
|
271
|
+
content: jsdocMatch[1].trim(),
|
|
272
|
+
type: "jsdoc"
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
return void 0;
|
|
277
|
+
}
|
|
278
|
+
isLikelyPure(node) {
|
|
279
|
+
const structNode = node.type === "ExportNamedDeclaration" ? node.declaration : node.type === "ExportDefaultDeclaration" ? node.declaration : node;
|
|
280
|
+
if (structNode.type === "VariableDeclaration" && structNode.kind === "const")
|
|
281
|
+
return true;
|
|
282
|
+
if (structNode.type === "FunctionDeclaration" || structNode.type === "TSDeclareFunction" || structNode.type === "MethodDefinition" && structNode.value) {
|
|
283
|
+
const body = structNode.type === "MethodDefinition" ? structNode.value.body : structNode.body;
|
|
284
|
+
if (body && body.type === "BlockStatement") {
|
|
285
|
+
const bodyContent = JSON.stringify(body);
|
|
286
|
+
if (bodyContent.includes('"name":"console"') || bodyContent.includes('"name":"process"') || bodyContent.includes('"type":"AssignmentExpression"')) {
|
|
287
|
+
return false;
|
|
288
|
+
}
|
|
289
|
+
return true;
|
|
290
|
+
}
|
|
291
|
+
return true;
|
|
292
|
+
}
|
|
293
|
+
return false;
|
|
294
|
+
}
|
|
295
|
+
};
|
|
296
|
+
|
|
297
|
+
export {
|
|
298
|
+
TypeScriptParser
|
|
299
|
+
};
|