@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/chunk-UBCM5Y6R.mjs
DELETED
|
@@ -1,275 +0,0 @@
|
|
|
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);
|
|
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) {
|
|
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
|
-
)
|
|
126
|
-
);
|
|
127
|
-
} else if (declaration.type === "ClassDeclaration" && declaration.id) {
|
|
128
|
-
exports.push(
|
|
129
|
-
this.createExport(
|
|
130
|
-
declaration.id.name,
|
|
131
|
-
"class",
|
|
132
|
-
node,
|
|
133
|
-
// Pass the outer ExportNamedDeclaration
|
|
134
|
-
code
|
|
135
|
-
)
|
|
136
|
-
);
|
|
137
|
-
} else if (declaration.type === "TSTypeAliasDeclaration") {
|
|
138
|
-
exports.push(
|
|
139
|
-
this.createExport(
|
|
140
|
-
declaration.id.name,
|
|
141
|
-
"type",
|
|
142
|
-
node,
|
|
143
|
-
// Pass the outer ExportNamedDeclaration
|
|
144
|
-
code
|
|
145
|
-
)
|
|
146
|
-
);
|
|
147
|
-
} else if (declaration.type === "TSInterfaceDeclaration") {
|
|
148
|
-
exports.push(
|
|
149
|
-
this.createExport(
|
|
150
|
-
declaration.id.name,
|
|
151
|
-
"interface",
|
|
152
|
-
node,
|
|
153
|
-
// Pass the outer ExportNamedDeclaration
|
|
154
|
-
code
|
|
155
|
-
)
|
|
156
|
-
);
|
|
157
|
-
} else if (declaration.type === "VariableDeclaration") {
|
|
158
|
-
for (const decl of declaration.declarations) {
|
|
159
|
-
if (decl.id.type === "Identifier") {
|
|
160
|
-
exports.push(
|
|
161
|
-
this.createExport(
|
|
162
|
-
decl.id.name,
|
|
163
|
-
"const",
|
|
164
|
-
node,
|
|
165
|
-
// Pass the outer ExportNamedDeclaration
|
|
166
|
-
code,
|
|
167
|
-
decl.init
|
|
168
|
-
)
|
|
169
|
-
);
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
} else if (node.type === "ExportDefaultDeclaration") {
|
|
175
|
-
exports.push(this.createExport("default", "default", node, code));
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
return exports;
|
|
179
|
-
}
|
|
180
|
-
createExport(name, type, node, code, initializer) {
|
|
181
|
-
const documentation = this.extractDocumentation(node, code);
|
|
182
|
-
let methodCount;
|
|
183
|
-
let propertyCount;
|
|
184
|
-
let parameters;
|
|
185
|
-
let isPrimitive = false;
|
|
186
|
-
if (initializer) {
|
|
187
|
-
if (initializer.type === "Literal" || initializer.type === "TemplateLiteral" && initializer.expressions.length === 0) {
|
|
188
|
-
isPrimitive = true;
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
const structNode = node.type === "ExportNamedDeclaration" ? node.declaration : node.type === "ExportDefaultDeclaration" ? node.declaration : node;
|
|
192
|
-
if (structNode.type === "ClassDeclaration" || structNode.type === "TSInterfaceDeclaration") {
|
|
193
|
-
const body = structNode.type === "ClassDeclaration" ? structNode.body.body : structNode.body.body;
|
|
194
|
-
methodCount = body.filter(
|
|
195
|
-
(m) => m.type === "MethodDefinition" || m.type === "TSMethodSignature"
|
|
196
|
-
).length;
|
|
197
|
-
propertyCount = body.filter(
|
|
198
|
-
(m) => m.type === "PropertyDefinition" || m.type === "TSPropertySignature"
|
|
199
|
-
).length;
|
|
200
|
-
if (structNode.type === "ClassDeclaration") {
|
|
201
|
-
const constructor = body.find(
|
|
202
|
-
(m) => m.type === "MethodDefinition" && m.kind === "constructor"
|
|
203
|
-
);
|
|
204
|
-
if (constructor && constructor.value && constructor.value.params) {
|
|
205
|
-
parameters = constructor.value.params.map((p) => {
|
|
206
|
-
if (p.type === "Identifier") return p.name;
|
|
207
|
-
if (p.type === "TSParameterProperty" && p.parameter.type === "Identifier") {
|
|
208
|
-
return p.parameter.name;
|
|
209
|
-
}
|
|
210
|
-
return void 0;
|
|
211
|
-
}).filter(Boolean);
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
if (!parameters && (structNode.type === "FunctionDeclaration" || structNode.type === "TSDeclareFunction" || structNode.type === "MethodDefinition")) {
|
|
216
|
-
const funcNode = structNode.type === "MethodDefinition" ? structNode.value : structNode;
|
|
217
|
-
if (funcNode && funcNode.params) {
|
|
218
|
-
parameters = funcNode.params.map((p) => {
|
|
219
|
-
if (p.type === "Identifier") return p.name;
|
|
220
|
-
return void 0;
|
|
221
|
-
}).filter(Boolean);
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
return {
|
|
225
|
-
name,
|
|
226
|
-
type,
|
|
227
|
-
isPrimitive,
|
|
228
|
-
loc: node.loc ? {
|
|
229
|
-
start: { line: node.loc.start.line, column: node.loc.start.column },
|
|
230
|
-
end: { line: node.loc.end.line, column: node.loc.end.column }
|
|
231
|
-
} : void 0,
|
|
232
|
-
documentation,
|
|
233
|
-
methodCount,
|
|
234
|
-
propertyCount,
|
|
235
|
-
parameters,
|
|
236
|
-
isPure: this.isLikelyPure(node),
|
|
237
|
-
hasSideEffects: !this.isLikelyPure(node)
|
|
238
|
-
};
|
|
239
|
-
}
|
|
240
|
-
extractDocumentation(node, code) {
|
|
241
|
-
if (node.range) {
|
|
242
|
-
const start = node.range[0];
|
|
243
|
-
const precedingCode = code.substring(0, start);
|
|
244
|
-
const jsdocMatch = precedingCode.match(/\/\*\*([\s\S]*?)\*\/\s*$/);
|
|
245
|
-
if (jsdocMatch) {
|
|
246
|
-
return {
|
|
247
|
-
content: jsdocMatch[1].trim(),
|
|
248
|
-
type: "jsdoc"
|
|
249
|
-
};
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
return void 0;
|
|
253
|
-
}
|
|
254
|
-
isLikelyPure(node) {
|
|
255
|
-
const structNode = node.type === "ExportNamedDeclaration" ? node.declaration : node.type === "ExportDefaultDeclaration" ? node.declaration : node;
|
|
256
|
-
if (structNode.type === "VariableDeclaration" && structNode.kind === "const")
|
|
257
|
-
return true;
|
|
258
|
-
if (structNode.type === "FunctionDeclaration" || structNode.type === "TSDeclareFunction" || structNode.type === "MethodDefinition" && structNode.value) {
|
|
259
|
-
const body = structNode.type === "MethodDefinition" ? structNode.value.body : structNode.body;
|
|
260
|
-
if (body && body.type === "BlockStatement") {
|
|
261
|
-
const bodyContent = JSON.stringify(body);
|
|
262
|
-
if (bodyContent.includes('"name":"console"') || bodyContent.includes('"name":"process"') || bodyContent.includes('"type":"AssignmentExpression"')) {
|
|
263
|
-
return false;
|
|
264
|
-
}
|
|
265
|
-
return true;
|
|
266
|
-
}
|
|
267
|
-
return true;
|
|
268
|
-
}
|
|
269
|
-
return false;
|
|
270
|
-
}
|
|
271
|
-
};
|
|
272
|
-
|
|
273
|
-
export {
|
|
274
|
-
TypeScriptParser
|
|
275
|
-
};
|