@aiready/core 0.24.19 → 0.24.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.
Files changed (39) hide show
  1. package/dist/chunk-3NEZ5M7Y.mjs +385 -340
  2. package/dist/chunk-5IVDH26E.mjs +142 -88
  3. package/dist/chunk-BE52N7T2.mjs +892 -0
  4. package/dist/chunk-GQMKSUA4.mjs +381 -336
  5. package/dist/chunk-LRM26BOB.mjs +381 -336
  6. package/dist/chunk-MOM3IXCA.mjs +146 -91
  7. package/dist/chunk-OT6FOHL4.mjs +144 -88
  8. package/dist/chunk-OVWWYI75.mjs +307 -0
  9. package/dist/chunk-U3IY2CFC.mjs +18 -22
  10. package/dist/chunk-WPFXQH5F.mjs +307 -0
  11. package/dist/chunk-WUDUSXUE.mjs +366 -0
  12. package/dist/chunk-YQATXOKD.mjs +36 -0
  13. package/dist/chunk-YVPVNRFQ.mjs +937 -0
  14. package/dist/client/index.mjs +2 -2
  15. package/dist/csharp-parser-JE5MWHQS.mjs +9 -0
  16. package/dist/csharp-parser-XW7WHE77.mjs +5 -9
  17. package/dist/go-parser-KTG4CGF5.mjs +5 -9
  18. package/dist/go-parser-T7PR6WJI.mjs +9 -0
  19. package/dist/index-CcP12wb-.d.mts +996 -693
  20. package/dist/index-CcP12wb-.d.ts +996 -693
  21. package/dist/index-DGbarGnr.d.mts +996 -693
  22. package/dist/index-DGbarGnr.d.ts +996 -693
  23. package/dist/index-slasaNzr.d.mts +998 -695
  24. package/dist/index-slasaNzr.d.ts +998 -695
  25. package/dist/index.d.mts +32 -1
  26. package/dist/index.d.ts +32 -1
  27. package/dist/index.js +35 -2
  28. package/dist/index.mjs +41 -9
  29. package/dist/java-parser-EOKMGQ6B.mjs +5 -9
  30. package/dist/java-parser-WGOXKULP.mjs +9 -0
  31. package/dist/python-parser-7NCR7VCQ.mjs +8 -0
  32. package/dist/python-parser-BCI7JVLF.mjs +4 -8
  33. package/dist/typescript-parser-3KYGSSY5.mjs +3 -0
  34. package/dist/typescript-parser-4BA4VYAF.mjs +3 -7
  35. package/dist/typescript-parser-FOUPHVFI.mjs +3 -7
  36. package/dist/typescript-parser-G3TSNR7O.mjs +7 -0
  37. package/dist/typescript-parser-RMNCTHRD.mjs +3 -7
  38. package/dist/typescript-parser-WALISXF4.mjs +7 -0
  39. package/package.json +11 -10
@@ -1,16 +1,13 @@
1
- import {
2
- ParseError
3
- } from "./chunk-U3IY2CFC.mjs";
1
+ import { ParseError } from './chunk-U3IY2CFC.mjs';
4
2
 
5
3
  // src/parsers/typescript-parser.ts
6
- import { parse } from "@typescript-eslint/typescript-estree";
4
+ import { parse } from '@typescript-eslint/typescript-estree';
7
5
  var TypeScriptParser = class {
8
6
  constructor() {
9
- this.language = "typescript" /* TypeScript */;
10
- this.extensions = [".ts", ".tsx", ".js", ".jsx"];
11
- }
12
- async initialize() {
7
+ this.language = 'typescript' /* TypeScript */;
8
+ this.extensions = ['.ts', '.tsx', '.js', '.jsx'];
13
9
  }
10
+ async initialize() {}
14
11
  canHandle(filePath) {
15
12
  return this.extensions.some((ext) => filePath.endsWith(ext));
16
13
  }
@@ -22,13 +19,13 @@ var TypeScriptParser = class {
22
19
  range: true,
23
20
  tokens: true,
24
21
  comment: true,
25
- jsx: filePath.endsWith("x")
22
+ jsx: filePath.endsWith('x'),
26
23
  });
27
24
  } catch (error) {
28
25
  const err = error;
29
- throw new ParseError(err.message || "Unknown error", filePath, {
26
+ throw new ParseError(err.message || 'Unknown error', filePath, {
30
27
  line: err.lineNumber || 1,
31
- column: err.column || 0
28
+ column: err.column || 0,
32
29
  });
33
30
  }
34
31
  }
@@ -40,19 +37,19 @@ var TypeScriptParser = class {
40
37
  range: true,
41
38
  tokens: true,
42
39
  comment: true,
43
- jsx: filePath.endsWith("x")
40
+ jsx: filePath.endsWith('x'),
44
41
  });
45
42
  const imports = this.extractImports(ast);
46
43
  const exports = this.extractExports(ast, code, filePath);
47
44
  return {
48
45
  exports,
49
46
  imports,
50
- language: this.language
47
+ language: this.language,
51
48
  };
52
49
  } catch (error) {
53
50
  throw new ParseError(error.message, filePath, {
54
51
  line: error.lineNumber || 1,
55
- column: error.column || 0
52
+ column: error.column || 0,
56
53
  });
57
54
  }
58
55
  }
@@ -63,47 +60,50 @@ var TypeScriptParser = class {
63
60
  classPattern: /^[A-Z][a-zA-Z0-9]*$/,
64
61
  constantPattern: /^[A-Z][A-Z0-9_]*$/,
65
62
  typePattern: /^[A-Z][a-zA-Z0-9]*$/,
66
- interfacePattern: /^I?[A-Z][a-zA-Z0-9]*$/
63
+ interfacePattern: /^I?[A-Z][a-zA-Z0-9]*$/,
67
64
  };
68
65
  }
69
66
  analyzeMetadata(node, code) {
70
67
  if (!code) return {};
71
68
  return {
72
69
  isPure: this.isLikelyPure(node),
73
- hasSideEffects: !this.isLikelyPure(node)
70
+ hasSideEffects: !this.isLikelyPure(node),
74
71
  };
75
72
  }
76
73
  extractImports(ast) {
77
74
  const imports = [];
78
75
  for (const node of ast.body) {
79
- if (node.type === "ImportDeclaration") {
76
+ if (node.type === 'ImportDeclaration') {
80
77
  const specifiers = [];
81
78
  let isTypeOnly = false;
82
- if (node.importKind === "type") {
79
+ if (node.importKind === 'type') {
83
80
  isTypeOnly = true;
84
81
  }
85
82
  for (const spec of node.specifiers) {
86
- if (spec.type === "ImportSpecifier") {
83
+ if (spec.type === 'ImportSpecifier') {
87
84
  const imported = spec.imported;
88
- const name = imported.type === "Identifier" ? imported.name : imported.value;
85
+ const name =
86
+ imported.type === 'Identifier' ? imported.name : imported.value;
89
87
  specifiers.push(name);
90
- } else if (spec.type === "ImportDefaultSpecifier") {
91
- specifiers.push("default");
92
- } else if (spec.type === "ImportNamespaceSpecifier") {
93
- specifiers.push("*");
88
+ } else if (spec.type === 'ImportDefaultSpecifier') {
89
+ specifiers.push('default');
90
+ } else if (spec.type === 'ImportNamespaceSpecifier') {
91
+ specifiers.push('*');
94
92
  }
95
93
  }
96
94
  imports.push({
97
95
  source: node.source.value,
98
96
  specifiers,
99
97
  isTypeOnly,
100
- loc: node.loc ? {
101
- start: {
102
- line: node.loc.start.line,
103
- column: node.loc.start.column
104
- },
105
- end: { line: node.loc.end.line, column: node.loc.end.column }
106
- } : void 0
98
+ loc: node.loc
99
+ ? {
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
+ }
106
+ : void 0,
107
107
  });
108
108
  }
109
109
  }
@@ -112,60 +112,67 @@ var TypeScriptParser = class {
112
112
  extractExports(ast, code, filePath) {
113
113
  const exports = [];
114
114
  for (const node of ast.body) {
115
- if (node.type === "ExportNamedDeclaration") {
115
+ if (node.type === 'ExportNamedDeclaration') {
116
116
  if (node.declaration) {
117
117
  const declaration = node.declaration;
118
- if ((declaration.type === "FunctionDeclaration" || declaration.type === "TSDeclareFunction") && declaration.id) {
118
+ if (
119
+ (declaration.type === 'FunctionDeclaration' ||
120
+ declaration.type === 'TSDeclareFunction') &&
121
+ declaration.id
122
+ ) {
119
123
  exports.push(
120
124
  this.createExport(
121
125
  declaration.id.name,
122
- "function",
126
+ 'function',
123
127
  node,
124
128
  // Pass the outer ExportNamedDeclaration
125
129
  code,
126
130
  filePath
127
131
  )
128
132
  );
129
- } else if (declaration.type === "ClassDeclaration" && declaration.id) {
133
+ } else if (
134
+ declaration.type === 'ClassDeclaration' &&
135
+ declaration.id
136
+ ) {
130
137
  exports.push(
131
138
  this.createExport(
132
139
  declaration.id.name,
133
- "class",
140
+ 'class',
134
141
  node,
135
142
  // Pass the outer ExportNamedDeclaration
136
143
  code,
137
144
  filePath
138
145
  )
139
146
  );
140
- } else if (declaration.type === "TSTypeAliasDeclaration") {
147
+ } else if (declaration.type === 'TSTypeAliasDeclaration') {
141
148
  exports.push(
142
149
  this.createExport(
143
150
  declaration.id.name,
144
- "type",
151
+ 'type',
145
152
  node,
146
153
  // Pass the outer ExportNamedDeclaration
147
154
  code,
148
155
  filePath
149
156
  )
150
157
  );
151
- } else if (declaration.type === "TSInterfaceDeclaration") {
158
+ } else if (declaration.type === 'TSInterfaceDeclaration') {
152
159
  exports.push(
153
160
  this.createExport(
154
161
  declaration.id.name,
155
- "interface",
162
+ 'interface',
156
163
  node,
157
164
  // Pass the outer ExportNamedDeclaration
158
165
  code,
159
166
  filePath
160
167
  )
161
168
  );
162
- } else if (declaration.type === "VariableDeclaration") {
169
+ } else if (declaration.type === 'VariableDeclaration') {
163
170
  for (const decl of declaration.declarations) {
164
- if (decl.id.type === "Identifier") {
171
+ if (decl.id.type === 'Identifier') {
165
172
  exports.push(
166
173
  this.createExport(
167
174
  decl.id.name,
168
- "const",
175
+ 'const',
169
176
  node,
170
177
  code,
171
178
  filePath,
@@ -176,9 +183,9 @@ var TypeScriptParser = class {
176
183
  }
177
184
  }
178
185
  }
179
- } else if (node.type === "ExportDefaultDeclaration") {
186
+ } else if (node.type === 'ExportDefaultDeclaration') {
180
187
  exports.push(
181
- this.createExport("default", "default", node, code, filePath)
188
+ this.createExport('default', 'default', node, code, filePath)
182
189
  );
183
190
  }
184
191
  }
@@ -192,78 +199,118 @@ var TypeScriptParser = class {
192
199
  let isPrimitive = false;
193
200
  let isTyped = false;
194
201
  if (initializer) {
195
- if (initializer.type === "Literal" || initializer.type === "TemplateLiteral" && initializer.expressions.length === 0) {
202
+ if (
203
+ initializer.type === 'Literal' ||
204
+ (initializer.type === 'TemplateLiteral' &&
205
+ initializer.expressions.length === 0)
206
+ ) {
196
207
  isPrimitive = true;
197
208
  }
198
209
  }
199
- let structNode = node.type === "ExportNamedDeclaration" && node.declaration ? node.declaration : node.type === "ExportDefaultDeclaration" ? node.declaration : node;
210
+ let structNode =
211
+ node.type === 'ExportNamedDeclaration' && node.declaration
212
+ ? node.declaration
213
+ : node.type === 'ExportDefaultDeclaration'
214
+ ? node.declaration
215
+ : node;
200
216
  if (!structNode) structNode = node;
201
- if (filePath.endsWith(".ts") || filePath.endsWith(".tsx")) {
202
- if (structNode.type === "TSTypeAliasDeclaration" || structNode.type === "TSInterfaceDeclaration" || structNode.type === "TSEnumDeclaration") {
217
+ if (filePath.endsWith('.ts') || filePath.endsWith('.tsx')) {
218
+ if (
219
+ structNode.type === 'TSTypeAliasDeclaration' ||
220
+ structNode.type === 'TSInterfaceDeclaration' ||
221
+ structNode.type === 'TSEnumDeclaration'
222
+ ) {
203
223
  isTyped = true;
204
- } else if (structNode.type === "FunctionDeclaration" || structNode.type === "TSDeclareFunction") {
224
+ } else if (
225
+ structNode.type === 'FunctionDeclaration' ||
226
+ structNode.type === 'TSDeclareFunction'
227
+ ) {
205
228
  const func = structNode;
206
229
  const hasReturnType = !!func.returnType;
207
- const allParamsTyped = func.params.length === 0 || func.params.every((p) => !!p.typeAnnotation);
230
+ const allParamsTyped =
231
+ func.params.length === 0 ||
232
+ func.params.every((p) => !!p.typeAnnotation);
208
233
  isTyped = hasReturnType && allParamsTyped;
209
- } else if (structNode.type === "VariableDeclaration") {
234
+ } else if (structNode.type === 'VariableDeclaration') {
210
235
  const variable = structNode;
211
236
  isTyped = variable.declarations.every(
212
237
  (d) => !!d.id.typeAnnotation || !!d.init
213
238
  );
214
- } else if (structNode.type === "ClassDeclaration") {
239
+ } else if (structNode.type === 'ClassDeclaration') {
215
240
  isTyped = true;
216
241
  }
217
- } else if (filePath.endsWith(".js") || filePath.endsWith(".jsx")) {
242
+ } else if (filePath.endsWith('.js') || filePath.endsWith('.jsx')) {
218
243
  isTyped = false;
219
244
  }
220
- if (structNode.type === "ClassDeclaration" || structNode.type === "TSInterfaceDeclaration") {
221
- const body = structNode.type === "ClassDeclaration" ? structNode.body.body : structNode.body.body;
245
+ if (
246
+ structNode.type === 'ClassDeclaration' ||
247
+ structNode.type === 'TSInterfaceDeclaration'
248
+ ) {
249
+ const body =
250
+ structNode.type === 'ClassDeclaration'
251
+ ? structNode.body.body
252
+ : structNode.body.body;
222
253
  methodCount = body.filter(
223
- (m) => m.type === "MethodDefinition" || m.type === "TSMethodSignature"
254
+ (m) => m.type === 'MethodDefinition' || m.type === 'TSMethodSignature'
224
255
  ).length;
225
256
  propertyCount = body.filter(
226
- (m) => m.type === "PropertyDefinition" || m.type === "TSPropertySignature"
257
+ (m) =>
258
+ m.type === 'PropertyDefinition' || m.type === 'TSPropertySignature'
227
259
  ).length;
228
- if (structNode.type === "ClassDeclaration") {
260
+ if (structNode.type === 'ClassDeclaration') {
229
261
  const constructor = body.find(
230
- (m) => m.type === "MethodDefinition" && m.kind === "constructor"
262
+ (m) => m.type === 'MethodDefinition' && m.kind === 'constructor'
231
263
  );
232
264
  if (constructor && constructor.value && constructor.value.params) {
233
- parameters = constructor.value.params.map((p) => {
234
- if (p.type === "Identifier") return p.name;
235
- if (p.type === "TSParameterProperty" && p.parameter.type === "Identifier") {
236
- return p.parameter.name;
237
- }
238
- return void 0;
239
- }).filter((p) => !!p);
265
+ parameters = constructor.value.params
266
+ .map((p) => {
267
+ if (p.type === 'Identifier') return p.name;
268
+ if (
269
+ p.type === 'TSParameterProperty' &&
270
+ p.parameter.type === 'Identifier'
271
+ ) {
272
+ return p.parameter.name;
273
+ }
274
+ return void 0;
275
+ })
276
+ .filter((p) => !!p);
240
277
  }
241
278
  }
242
279
  }
243
- if (!parameters && (structNode.type === "FunctionDeclaration" || structNode.type === "TSDeclareFunction" || structNode.type === "MethodDefinition")) {
244
- const funcNode = structNode.type === "MethodDefinition" ? structNode.value : structNode;
280
+ if (
281
+ !parameters &&
282
+ (structNode.type === 'FunctionDeclaration' ||
283
+ structNode.type === 'TSDeclareFunction' ||
284
+ structNode.type === 'MethodDefinition')
285
+ ) {
286
+ const funcNode =
287
+ structNode.type === 'MethodDefinition' ? structNode.value : structNode;
245
288
  if (funcNode && funcNode.params) {
246
- parameters = funcNode.params.map((p) => {
247
- if (p.type === "Identifier") return p.name;
248
- return void 0;
249
- }).filter((p) => !!p);
289
+ parameters = funcNode.params
290
+ .map((p) => {
291
+ if (p.type === 'Identifier') return p.name;
292
+ return void 0;
293
+ })
294
+ .filter((p) => !!p);
250
295
  }
251
296
  }
252
297
  return {
253
298
  name,
254
299
  type,
255
300
  isPrimitive,
256
- loc: node.loc ? {
257
- start: { line: node.loc.start.line, column: node.loc.start.column },
258
- end: { line: node.loc.end.line, column: node.loc.end.column }
259
- } : void 0,
301
+ loc: node.loc
302
+ ? {
303
+ start: { line: node.loc.start.line, column: node.loc.start.column },
304
+ end: { line: node.loc.end.line, column: node.loc.end.column },
305
+ }
306
+ : void 0,
260
307
  documentation,
261
308
  methodCount,
262
309
  propertyCount,
263
310
  parameters,
264
311
  isPure: this.isLikelyPure(node),
265
312
  hasSideEffects: !this.isLikelyPure(node),
266
- isTyped
313
+ isTyped,
267
314
  };
268
315
  }
269
316
  extractDocumentation(node, code) {
@@ -274,24 +321,34 @@ var TypeScriptParser = class {
274
321
  if (jsdocMatch) {
275
322
  return {
276
323
  content: jsdocMatch[1].trim(),
277
- type: "jsdoc"
324
+ type: 'jsdoc',
278
325
  };
279
326
  }
280
327
  }
281
328
  return void 0;
282
329
  }
283
330
  isLikelyPure(node) {
284
- const sn = node.type === "ExportNamedDeclaration" && node.declaration ? node.declaration : node.type === "ExportDefaultDeclaration" ? node.declaration : node;
331
+ const sn =
332
+ node.type === 'ExportNamedDeclaration' && node.declaration
333
+ ? node.declaration
334
+ : node.type === 'ExportDefaultDeclaration'
335
+ ? node.declaration
336
+ : node;
285
337
  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;
289
- if (body && body.type === "BlockStatement") {
290
- const bodyContent = JSON.stringify(
291
- body,
292
- (_, v) => typeof v === "bigint" ? v.toString() : v
338
+ if (sn.type === 'VariableDeclaration' && sn.kind === 'const') return true;
339
+ if (sn.type === 'FunctionDeclaration' || sn.type === 'MethodDefinition') {
340
+ const body = sn.type === 'MethodDefinition' ? sn.value.body : sn.body;
341
+ if (body && body.type === 'BlockStatement') {
342
+ const bodyContent = JSON.stringify(body, (_, v) =>
343
+ typeof v === 'bigint' ? v.toString() : v
293
344
  );
294
- if (bodyContent.includes('"name":"console"') || bodyContent.includes('"name":"process"') || bodyContent.includes('"name":"fs"') || bodyContent.includes('"name":"fetch"') || bodyContent.includes('"name":"axios"')) {
345
+ if (
346
+ bodyContent.includes('"name":"console"') ||
347
+ bodyContent.includes('"name":"process"') ||
348
+ bodyContent.includes('"name":"fs"') ||
349
+ bodyContent.includes('"name":"fetch"') ||
350
+ bodyContent.includes('"name":"axios"')
351
+ ) {
295
352
  return false;
296
353
  }
297
354
  return true;
@@ -302,6 +359,4 @@ var TypeScriptParser = class {
302
359
  }
303
360
  };
304
361
 
305
- export {
306
- TypeScriptParser
307
- };
362
+ export { TypeScriptParser };