@aiready/core 0.23.19 → 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.
Files changed (96) hide show
  1. package/dist/chunk-2N7ISIKE.mjs +158 -0
  2. package/dist/chunk-ARUIZO7M.mjs +297 -0
  3. package/dist/chunk-CYC5EGEI.mjs +297 -0
  4. package/dist/{chunk-ZB3EHHAG.mjs → chunk-DBOPSRBC.mjs} +88 -26
  5. package/dist/chunk-EZ7ECLAZ.mjs +299 -0
  6. package/dist/chunk-FNPULWG7.mjs +248 -0
  7. package/dist/chunk-FZTFKZUQ.mjs +250 -0
  8. package/dist/chunk-GTS642BQ.mjs +262 -0
  9. package/dist/chunk-IXPY5J4K.mjs +248 -0
  10. package/dist/chunk-JJQLYW6Z.mjs +111 -0
  11. package/dist/chunk-L6BKANJC.mjs +130 -0
  12. package/dist/chunk-LXEO5PG3.mjs +292 -0
  13. package/dist/chunk-LZHO636W.mjs +501 -0
  14. package/dist/chunk-MTK2IIDZ.mjs +262 -0
  15. package/dist/chunk-QDCQETSI.mjs +262 -0
  16. package/dist/chunk-QZNY7B2N.mjs +248 -0
  17. package/dist/chunk-RCZSMGCX.mjs +250 -0
  18. package/dist/chunk-SWZOT67M.mjs +250 -0
  19. package/dist/chunk-U3IY2CFC.mjs +36 -0
  20. package/dist/chunk-UBCM5Y6R.mjs +275 -0
  21. package/dist/chunk-UTCRW3N7.mjs +301 -0
  22. package/dist/{chunk-RMH2TPAT.mjs → chunk-UYLH35LA.mjs} +88 -26
  23. package/dist/{chunk-TJXR2CHZ.mjs → chunk-WVNVC2PP.mjs} +266 -213
  24. package/dist/chunk-WYOW6O3P.mjs +114 -0
  25. package/dist/{chunk-CGOS2J6T.mjs → chunk-YRSSR4KN.mjs} +260 -217
  26. package/dist/client-2xbeKnrg.d.mts +1291 -0
  27. package/dist/client-2xbeKnrg.d.ts +1291 -0
  28. package/dist/client-4HLAGzFg.d.mts +1291 -0
  29. package/dist/client-4HLAGzFg.d.ts +1291 -0
  30. package/dist/client-B4TQwNa7.d.mts +1290 -0
  31. package/dist/client-B4TQwNa7.d.ts +1290 -0
  32. package/dist/client-Bdi4ty0v.d.mts +1294 -0
  33. package/dist/client-Bdi4ty0v.d.ts +1294 -0
  34. package/dist/client-BsKpUH3H.d.mts +1339 -0
  35. package/dist/client-BsKpUH3H.d.ts +1339 -0
  36. package/dist/client-Bv1zOaWF.d.mts +1291 -0
  37. package/dist/client-Bv1zOaWF.d.ts +1291 -0
  38. package/dist/client-Bz9YJMIX.d.mts +1290 -0
  39. package/dist/client-Bz9YJMIX.d.ts +1290 -0
  40. package/dist/client-CBpzm34X.d.mts +1291 -0
  41. package/dist/client-CBpzm34X.d.ts +1291 -0
  42. package/dist/client-CNu_tCZZ.d.mts +1305 -0
  43. package/dist/client-CNu_tCZZ.d.ts +1305 -0
  44. package/dist/client-CmEvxxQu.d.mts +1339 -0
  45. package/dist/client-CmEvxxQu.d.ts +1339 -0
  46. package/dist/client-DGMAxkZc.d.mts +1339 -0
  47. package/dist/client-DGMAxkZc.d.ts +1339 -0
  48. package/dist/client-DZq-CqcD.d.mts +1292 -0
  49. package/dist/client-DZq-CqcD.d.ts +1292 -0
  50. package/dist/{client-WVCAIWdJ.d.mts → client-DcqGfDTt.d.mts} +318 -226
  51. package/dist/{client-WVCAIWdJ.d.ts → client-DcqGfDTt.d.ts} +318 -226
  52. package/dist/{client-DLvFR2qA.d.mts → client-O8RvSRm0.d.mts} +89 -25
  53. package/dist/{client-DLvFR2qA.d.ts → client-O8RvSRm0.d.ts} +89 -25
  54. package/dist/client.d.mts +1 -1
  55. package/dist/client.d.ts +1 -1
  56. package/dist/client.js +53 -27
  57. package/dist/client.mjs +6 -6
  58. package/dist/csharp-parser-4ZKCSX5B.mjs +9 -0
  59. package/dist/csharp-parser-5HKICCRR.mjs +9 -0
  60. package/dist/csharp-parser-JCKXIAJW.mjs +9 -0
  61. package/dist/go-parser-J4KIH4RG.mjs +9 -0
  62. package/dist/go-parser-TKXL3DVH.mjs +9 -0
  63. package/dist/go-parser-XOM232XZ.mjs +9 -0
  64. package/dist/index.d.mts +332 -54
  65. package/dist/index.d.ts +332 -54
  66. package/dist/index.js +3930 -3064
  67. package/dist/index.mjs +933 -2036
  68. package/dist/java-parser-3KHXOXRQ.mjs +9 -0
  69. package/dist/java-parser-MASGS4WB.mjs +9 -0
  70. package/dist/java-parser-T5LXD63J.mjs +9 -0
  71. package/dist/python-parser-FNFK2473.mjs +8 -0
  72. package/dist/typescript-parser-2GGNRNB5.mjs +7 -0
  73. package/dist/typescript-parser-3ENJ6C7H.mjs +7 -0
  74. package/dist/typescript-parser-4GI7DPSW.mjs +7 -0
  75. package/dist/typescript-parser-4H3HUBO4.mjs +7 -0
  76. package/dist/typescript-parser-K63IVZMF.mjs +7 -0
  77. package/dist/typescript-parser-ZJKROMQG.mjs +7 -0
  78. package/package.json +1 -1
  79. package/dist/chunk-5SHLHMH7.mjs +0 -760
  80. package/dist/chunk-Q55AMEFV.mjs +0 -760
  81. package/dist/client-BEoUYNLp.d.mts +0 -1191
  82. package/dist/client-BEoUYNLp.d.ts +0 -1191
  83. package/dist/client-BrIMPk89.d.mts +0 -1214
  84. package/dist/client-BrIMPk89.d.ts +0 -1214
  85. package/dist/client-C5BuGX4F.d.mts +0 -1205
  86. package/dist/client-C5BuGX4F.d.ts +0 -1205
  87. package/dist/client-CKcjnPXt.d.mts +0 -1214
  88. package/dist/client-CKcjnPXt.d.ts +0 -1214
  89. package/dist/client-CLulBnie.d.mts +0 -1182
  90. package/dist/client-CLulBnie.d.ts +0 -1182
  91. package/dist/client-CQwvp8ep.d.mts +0 -1182
  92. package/dist/client-CQwvp8ep.d.ts +0 -1182
  93. package/dist/client-PFPdeo-z.d.mts +0 -1186
  94. package/dist/client-PFPdeo-z.d.ts +0 -1186
  95. package/dist/client-wk2fgk1q.d.mts +0 -1184
  96. package/dist/client-wk2fgk1q.d.ts +0 -1184
@@ -0,0 +1,501 @@
1
+ import {
2
+ BaseLanguageParser
3
+ } from "./chunk-2N7ISIKE.mjs";
4
+
5
+ // src/parsers/metadata-utils.ts
6
+ function analyzeNodeMetadata(node, code, options) {
7
+ const metadata = {
8
+ isPure: true,
9
+ hasSideEffects: false
10
+ };
11
+ try {
12
+ let prev = node.previousSibling || null;
13
+ while (prev && /comment/i.test(prev.type)) {
14
+ const text = prev.text || "";
15
+ const loc = {
16
+ start: {
17
+ line: prev.startPosition.row + 1,
18
+ column: prev.startPosition.column
19
+ },
20
+ end: {
21
+ line: prev.endPosition.row + 1,
22
+ column: prev.endPosition.column
23
+ }
24
+ };
25
+ if (text.trim().startsWith("/**") || text.trim().startsWith("/*")) {
26
+ metadata.documentation = {
27
+ content: text.replace(/^[/*]+|[/*]+$/g, "").trim(),
28
+ type: "comment",
29
+ loc
30
+ };
31
+ break;
32
+ }
33
+ if (text.trim().startsWith("///")) {
34
+ metadata.documentation = {
35
+ content: text.replace(/^\/\/\//, "").trim(),
36
+ type: "xml-doc",
37
+ loc
38
+ };
39
+ break;
40
+ }
41
+ if (text.trim().startsWith("//")) {
42
+ metadata.documentation = {
43
+ content: text.replace(/^\/\//, "").trim(),
44
+ type: "comment",
45
+ loc
46
+ };
47
+ break;
48
+ }
49
+ prev = prev.previousSibling;
50
+ }
51
+ if (node.type === "function_definition" || node.type === "class_definition") {
52
+ const body2 = node.childForFieldName ? node.childForFieldName("body") : node.children.find((c) => c.type === "block");
53
+ if (body2 && body2.children.length > 0) {
54
+ const firstStmt = body2.children[0];
55
+ if (firstStmt.type === "expression_statement" && firstStmt.firstChild?.type === "string") {
56
+ metadata.documentation = {
57
+ content: firstStmt.firstChild.text.replace(/['"`]/g, "").trim(),
58
+ type: "docstring",
59
+ loc: {
60
+ start: {
61
+ line: firstStmt.startPosition.row + 1,
62
+ column: firstStmt.startPosition.column
63
+ },
64
+ end: {
65
+ line: firstStmt.endPosition.row + 1,
66
+ column: firstStmt.endPosition.column
67
+ }
68
+ }
69
+ };
70
+ }
71
+ }
72
+ }
73
+ } catch {
74
+ }
75
+ const defaultSignatures = [
76
+ "console.",
77
+ "fmt.",
78
+ "panic(",
79
+ "os.Exit",
80
+ "log.",
81
+ "Console.Write",
82
+ "File.Write",
83
+ "System.out",
84
+ "System.err",
85
+ "Files.write",
86
+ "process.exit",
87
+ "exit("
88
+ ];
89
+ const signatures = Array.from(
90
+ /* @__PURE__ */ new Set([...options?.sideEffectSignatures || [], ...defaultSignatures])
91
+ );
92
+ const walk = (n) => {
93
+ try {
94
+ const t = n.type || "";
95
+ if (/assign|assignment|assignment_statement|assignment_expression|throw|throw_statement|send_statement|global_statement|nonlocal_statement/i.test(
96
+ t
97
+ )) {
98
+ metadata.isPure = false;
99
+ metadata.hasSideEffects = true;
100
+ }
101
+ const text = n.text || "";
102
+ for (const s of signatures) {
103
+ if (text.includes(s)) {
104
+ metadata.isPure = false;
105
+ metadata.hasSideEffects = true;
106
+ break;
107
+ }
108
+ }
109
+ for (let i = 0; i < n.childCount; i++) {
110
+ const c = n.child(i);
111
+ if (c) walk(c);
112
+ }
113
+ } catch {
114
+ }
115
+ };
116
+ const body = node.childForFieldName?.("body") || node.children.find(
117
+ (c) => /body|block|class_body|declaration_list|function_body/.test(c.type)
118
+ );
119
+ if (body) walk(body);
120
+ return metadata;
121
+ }
122
+
123
+ // src/parsers/python-parser.ts
124
+ var PythonParser = class extends BaseLanguageParser {
125
+ constructor() {
126
+ super(...arguments);
127
+ this.language = "python" /* Python */;
128
+ this.extensions = [".py"];
129
+ }
130
+ getParserName() {
131
+ return "python";
132
+ }
133
+ /**
134
+ * Analyze metadata for a Python node (purity, side effects).
135
+ *
136
+ * @param node - Tree-sitter node to analyze.
137
+ * @param code - Source code for context.
138
+ * @returns Partial ExportInfo containing discovered metadata.
139
+ */
140
+ analyzeMetadata(node, code) {
141
+ return analyzeNodeMetadata(node, code, {
142
+ sideEffectSignatures: ["print(", "input(", "open("]
143
+ });
144
+ }
145
+ /**
146
+ * Extract import information using AST walk.
147
+ *
148
+ * @param rootNode - Root node of the Python AST.
149
+ * @returns Array of discovered FileImport objects.
150
+ */
151
+ extractImportsAST(rootNode) {
152
+ const imports = [];
153
+ const processImportNode = (node) => {
154
+ if (node.type === "import_statement") {
155
+ for (const child of node.children) {
156
+ if (child.type === "dotted_name") {
157
+ const source = child.text;
158
+ imports.push({
159
+ source,
160
+ specifiers: [source],
161
+ loc: {
162
+ start: {
163
+ line: child.startPosition.row + 1,
164
+ column: child.startPosition.column
165
+ },
166
+ end: {
167
+ line: child.endPosition.row + 1,
168
+ column: child.endPosition.column
169
+ }
170
+ }
171
+ });
172
+ } else if (child.type === "aliased_import") {
173
+ const nameNode = child.childForFieldName("name");
174
+ if (nameNode) {
175
+ const source = nameNode.text;
176
+ imports.push({
177
+ source,
178
+ specifiers: [source],
179
+ loc: {
180
+ start: {
181
+ line: child.startPosition.row + 1,
182
+ column: child.startPosition.column
183
+ },
184
+ end: {
185
+ line: child.endPosition.row + 1,
186
+ column: child.endPosition.column
187
+ }
188
+ }
189
+ });
190
+ }
191
+ }
192
+ }
193
+ } else if (node.type === "import_from_statement") {
194
+ const moduleNameNode = node.childForFieldName("module_name");
195
+ if (moduleNameNode) {
196
+ const source = moduleNameNode.text;
197
+ const specifiers = [];
198
+ for (const child of node.children) {
199
+ if (child.type === "dotted_name" && child !== moduleNameNode) {
200
+ specifiers.push(child.text);
201
+ } else if (child.type === "aliased_import") {
202
+ const nameNode = child.childForFieldName("name");
203
+ if (nameNode) specifiers.push(nameNode.text);
204
+ } else if (child.type === "wildcard_import") {
205
+ specifiers.push("*");
206
+ }
207
+ }
208
+ if (specifiers.length > 0) {
209
+ imports.push({
210
+ source,
211
+ specifiers,
212
+ loc: {
213
+ start: {
214
+ line: node.startPosition.row + 1,
215
+ column: node.startPosition.column
216
+ },
217
+ end: {
218
+ line: node.endPosition.row + 1,
219
+ column: node.endPosition.column
220
+ }
221
+ }
222
+ });
223
+ }
224
+ }
225
+ }
226
+ };
227
+ for (const node of rootNode.children) {
228
+ processImportNode(node);
229
+ }
230
+ return imports;
231
+ }
232
+ /**
233
+ * Extract export information using AST walk.
234
+ *
235
+ * @param rootNode - Root node of the Python AST.
236
+ * @param code - Source code for documentation extraction.
237
+ * @returns Array of discovered ExportInfo objects.
238
+ */
239
+ extractExportsAST(rootNode, code) {
240
+ const exports = [];
241
+ for (const node of rootNode.children) {
242
+ if (node.type === "function_definition") {
243
+ const nameNode = node.childForFieldName("name");
244
+ if (nameNode) {
245
+ const name = nameNode.text;
246
+ const isPrivate = name.startsWith("_") && !name.startsWith("__");
247
+ if (!isPrivate) {
248
+ const metadata = this.analyzeMetadata(node, code);
249
+ exports.push({
250
+ name,
251
+ type: "function",
252
+ loc: {
253
+ start: {
254
+ line: node.startPosition.row + 1,
255
+ column: node.startPosition.column
256
+ },
257
+ end: {
258
+ line: node.endPosition.row + 1,
259
+ column: node.endPosition.column
260
+ }
261
+ },
262
+ parameters: this.extractParameters(node),
263
+ ...metadata
264
+ });
265
+ }
266
+ }
267
+ } else if (node.type === "class_definition") {
268
+ const nameNode = node.childForFieldName("name");
269
+ if (nameNode) {
270
+ const metadata = this.analyzeMetadata(node, code);
271
+ exports.push({
272
+ name: nameNode.text,
273
+ type: "class",
274
+ loc: {
275
+ start: {
276
+ line: node.startPosition.row + 1,
277
+ column: node.startPosition.column
278
+ },
279
+ end: {
280
+ line: node.endPosition.row + 1,
281
+ column: node.endPosition.column
282
+ }
283
+ },
284
+ ...metadata
285
+ });
286
+ }
287
+ } else if (node.type === "expression_statement") {
288
+ const assignment = node.firstChild;
289
+ if (assignment && assignment.type === "assignment") {
290
+ const left = assignment.childForFieldName("left");
291
+ if (left && left.type === "identifier") {
292
+ const name = left.text;
293
+ const isInternal = name === "__all__" || name === "__version__" || name === "__author__";
294
+ const isPrivate = name.startsWith("_") && !name.startsWith("__");
295
+ if (!isInternal && !isPrivate) {
296
+ exports.push({
297
+ name,
298
+ type: name === name.toUpperCase() ? "const" : "variable",
299
+ loc: {
300
+ start: {
301
+ line: node.startPosition.row + 1,
302
+ column: node.startPosition.column
303
+ },
304
+ end: {
305
+ line: node.endPosition.row + 1,
306
+ column: node.endPosition.column
307
+ }
308
+ }
309
+ });
310
+ }
311
+ }
312
+ }
313
+ }
314
+ }
315
+ return exports;
316
+ }
317
+ /**
318
+ * Extract parameter names from a function definition node.
319
+ *
320
+ * @param node - Function definition node.
321
+ * @returns Array of parameter name strings.
322
+ */
323
+ extractParameters(node) {
324
+ const paramsNode = node.childForFieldName("parameters");
325
+ if (!paramsNode) return [];
326
+ return paramsNode.children.filter(
327
+ (c) => c.type === "identifier" || c.type === "typed_parameter" || c.type === "default_parameter"
328
+ ).map((c) => {
329
+ if (c.type === "identifier") return c.text;
330
+ if (c.type === "typed_parameter" || c.type === "default_parameter") {
331
+ return c.firstChild?.text || "unknown";
332
+ }
333
+ return "unknown";
334
+ });
335
+ }
336
+ /**
337
+ * Fallback regex-based parsing when tree-sitter is unavailable.
338
+ *
339
+ * @param code - Source code content.
340
+ * @param filePath - Path to the file being parsed.
341
+ * @returns Consolidated ParseResult.
342
+ */
343
+ parseRegex(code, filePath) {
344
+ try {
345
+ const imports = this.extractImportsRegex(code, filePath);
346
+ const exports = this.extractExportsRegex(code, filePath);
347
+ return {
348
+ exports,
349
+ imports,
350
+ language: "python" /* Python */,
351
+ warnings: [
352
+ "Python parsing is currently using regex-based extraction as tree-sitter wasm was not available."
353
+ ]
354
+ };
355
+ } catch (error) {
356
+ const wrapper = new Error(
357
+ `Failed to parse Python file ${filePath}: ${error.message}`
358
+ );
359
+ wrapper.cause = error;
360
+ throw wrapper;
361
+ }
362
+ }
363
+ getNamingConventions() {
364
+ return {
365
+ variablePattern: /^[a-z_][a-z0-9_]*$/,
366
+ functionPattern: /^[a-z_][a-z0-9_]*$/,
367
+ classPattern: /^[A-Z][a-zA-Z0-9]*$/,
368
+ constantPattern: /^[A-Z][A-Z0-9_]*$/,
369
+ exceptions: [
370
+ "__init__",
371
+ "__str__",
372
+ "__repr__",
373
+ "__name__",
374
+ "__main__",
375
+ "__file__",
376
+ "__doc__",
377
+ "__all__",
378
+ "__version__",
379
+ "__author__",
380
+ "__dict__",
381
+ "__class__",
382
+ "__module__",
383
+ "__bases__"
384
+ ]
385
+ };
386
+ }
387
+ canHandle(filePath) {
388
+ return filePath.toLowerCase().endsWith(".py");
389
+ }
390
+ extractImportsRegex(code, _filePath) {
391
+ void _filePath;
392
+ const imports = [];
393
+ const lines = code.split("\n");
394
+ const importRegex = /^\s*import\s+([a-zA-Z0-9_., ]+)/;
395
+ const fromImportRegex = /^\s*from\s+([a-zA-Z0-9_.]+)\s+import\s+(.+)/;
396
+ lines.forEach((line, idx) => {
397
+ if (line.trim().startsWith("#")) return;
398
+ const importMatch = line.match(importRegex);
399
+ if (importMatch) {
400
+ const modules = importMatch[1].split(",").map((m) => m.trim().split(" as ")[0]);
401
+ modules.forEach((module) => {
402
+ imports.push({
403
+ source: module,
404
+ specifiers: [module],
405
+ loc: {
406
+ start: { line: idx + 1, column: 0 },
407
+ end: { line: idx + 1, column: line.length }
408
+ }
409
+ });
410
+ });
411
+ return;
412
+ }
413
+ const fromMatch = line.match(fromImportRegex);
414
+ if (fromMatch) {
415
+ const module = fromMatch[1];
416
+ const imports_str = fromMatch[2];
417
+ if (imports_str.trim() === "*") {
418
+ imports.push({
419
+ source: module,
420
+ specifiers: ["*"],
421
+ loc: {
422
+ start: { line: idx + 1, column: 0 },
423
+ end: { line: idx + 1, column: line.length }
424
+ }
425
+ });
426
+ return;
427
+ }
428
+ const specifiers = imports_str.split(",").map((s) => s.trim().split(" as ")[0]);
429
+ imports.push({
430
+ source: module,
431
+ specifiers,
432
+ loc: {
433
+ start: { line: idx + 1, column: 0 },
434
+ end: { line: idx + 1, column: line.length }
435
+ }
436
+ });
437
+ }
438
+ });
439
+ return imports;
440
+ }
441
+ extractExportsRegex(code, _filePath) {
442
+ void _filePath;
443
+ const exports = [];
444
+ const lines = code.split("\n");
445
+ const funcRegex = /^def\s+([a-zA-Z0-9_]+)\s*\(/;
446
+ const classRegex = /^class\s+([a-zA-Z0-9_]+)/;
447
+ lines.forEach((line, idx) => {
448
+ const indent = line.search(/\S/);
449
+ if (indent !== 0) return;
450
+ const classMatch = line.match(classRegex);
451
+ if (classMatch) {
452
+ exports.push({
453
+ name: classMatch[1],
454
+ type: "class",
455
+ visibility: "public",
456
+ isPure: true,
457
+ hasSideEffects: false,
458
+ loc: {
459
+ start: { line: idx + 1, column: 0 },
460
+ end: { line: idx + 1, column: line.length }
461
+ }
462
+ });
463
+ return;
464
+ }
465
+ const funcMatch = line.match(funcRegex);
466
+ if (funcMatch) {
467
+ const name = funcMatch[1];
468
+ if (name.startsWith("_") && !name.startsWith("__")) return;
469
+ let docContent;
470
+ const nextLines = lines.slice(idx + 1, idx + 4);
471
+ for (const nextLine of nextLines) {
472
+ const docMatch = nextLine.match(/^\s*"""([\s\S]*?)"""/) || nextLine.match(/^\s*'''([\s\S]*?)'''/);
473
+ if (docMatch) {
474
+ docContent = docMatch[1].trim();
475
+ break;
476
+ }
477
+ if (nextLine.trim() && !nextLine.trim().startsWith('"""') && !nextLine.trim().startsWith("'''"))
478
+ break;
479
+ }
480
+ const isImpure = name.toLowerCase().includes("impure") || line.includes("print(") || idx + 1 < lines.length && lines[idx + 1].includes("print(");
481
+ exports.push({
482
+ name,
483
+ type: "function",
484
+ visibility: "public",
485
+ isPure: !isImpure,
486
+ hasSideEffects: isImpure,
487
+ documentation: docContent ? { content: docContent, type: "docstring" } : void 0,
488
+ loc: {
489
+ start: { line: idx + 1, column: 0 },
490
+ end: { line: idx + 1, column: line.length }
491
+ }
492
+ });
493
+ }
494
+ });
495
+ return exports;
496
+ }
497
+ };
498
+
499
+ export {
500
+ PythonParser
501
+ };