@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.
Files changed (106) hide show
  1. package/dist/{chunk-RCZSMGCX.mjs → chunk-2IUCKF4Z.mjs} +1 -1
  2. package/dist/{chunk-WYOW6O3P.mjs → chunk-3D3I5K5W.mjs} +33 -7
  3. package/dist/{chunk-GTS642BQ.mjs → chunk-3FAI4YNO.mjs} +1 -1
  4. package/dist/{chunk-EZ7ECLAZ.mjs → chunk-5IVDH26E.mjs} +21 -16
  5. package/dist/{chunk-SWZOT67M.mjs → chunk-6T5O7OAY.mjs} +1 -1
  6. package/dist/{chunk-L6BKANJC.mjs → chunk-DHFOYNMW.mjs} +12 -8
  7. package/dist/{chunk-QZNY7B2N.mjs → chunk-EHUK4VMH.mjs} +16 -8
  8. package/dist/{chunk-MTK2IIDZ.mjs → chunk-EJ74KPCV.mjs} +1 -1
  9. package/dist/{chunk-2ILVUVRK.mjs → chunk-FAESSLG7.mjs} +44 -17
  10. package/dist/{chunk-UTCRW3N7.mjs → chunk-Q4LOPVH6.mjs} +18 -14
  11. package/dist/{chunk-WH4ZGRVF.mjs → chunk-QY5YG2AZ.mjs} +12 -9
  12. package/dist/{chunk-IXPY5J4K.mjs → chunk-X63YJX5G.mjs} +16 -8
  13. package/dist/client/index.d.mts +1 -1
  14. package/dist/client/index.d.ts +1 -1
  15. package/dist/client/index.js +44 -17
  16. package/dist/client/index.mjs +1 -1
  17. package/dist/{csharp-parser-4ZKCSX5B.mjs → csharp-parser-C52DNAKT.mjs} +2 -2
  18. package/dist/{csharp-parser-5HKICCRR.mjs → csharp-parser-XW7WHE77.mjs} +2 -2
  19. package/dist/{go-parser-TKXL3DVH.mjs → go-parser-GO4BIRDD.mjs} +2 -2
  20. package/dist/{go-parser-XOM232XZ.mjs → go-parser-KTG4CGF5.mjs} +2 -2
  21. package/dist/{index-CkM98qn1.d.mts → index-ChiWzeQs.d.mts} +188 -180
  22. package/dist/{index-CkM98qn1.d.ts → index-ChiWzeQs.d.ts} +188 -180
  23. package/dist/{index-EQ2jRSlB.d.mts → index-PI6qMP2H.d.mts} +182 -178
  24. package/dist/{index-EQ2jRSlB.d.ts → index-PI6qMP2H.d.ts} +182 -178
  25. package/dist/index.d.mts +50 -15
  26. package/dist/index.d.ts +50 -15
  27. package/dist/index.js +272 -114
  28. package/dist/index.mjs +161 -66
  29. package/dist/{java-parser-MASGS4WB.mjs → java-parser-EOKMGQ6B.mjs} +2 -2
  30. package/dist/{java-parser-T5LXD63J.mjs → java-parser-G47O53QP.mjs} +2 -2
  31. package/dist/{python-parser-FNFK2473.mjs → python-parser-BCI7JVLF.mjs} +1 -1
  32. package/dist/{typescript-parser-2GGNRNB5.mjs → typescript-parser-4BA4VYAF.mjs} +1 -1
  33. package/dist/{typescript-parser-3ENJ6C7H.mjs → typescript-parser-WFGH52WB.mjs} +1 -1
  34. package/package.json +1 -1
  35. package/dist/chunk-ARUIZO7M.mjs +0 -297
  36. package/dist/chunk-AZRUQG5T.mjs +0 -537
  37. package/dist/chunk-CYC5EGEI.mjs +0 -297
  38. package/dist/chunk-DBOPSRBC.mjs +0 -884
  39. package/dist/chunk-E55RNGGK.mjs +0 -852
  40. package/dist/chunk-FNPULWG7.mjs +0 -248
  41. package/dist/chunk-FZTFKZUQ.mjs +0 -250
  42. package/dist/chunk-G4Z45SMK.mjs +0 -852
  43. package/dist/chunk-JJQLYW6Z.mjs +0 -111
  44. package/dist/chunk-LEITCMH3.mjs +0 -535
  45. package/dist/chunk-LTAZ7Z62.mjs +0 -855
  46. package/dist/chunk-LXEO5PG3.mjs +0 -292
  47. package/dist/chunk-LZHO636W.mjs +0 -501
  48. package/dist/chunk-MPWWAAHQ.mjs +0 -548
  49. package/dist/chunk-QDCQETSI.mjs +0 -262
  50. package/dist/chunk-SM6INS52.mjs +0 -501
  51. package/dist/chunk-UBCM5Y6R.mjs +0 -275
  52. package/dist/chunk-UYLH35LA.mjs +0 -884
  53. package/dist/chunk-WVNVC2PP.mjs +0 -852
  54. package/dist/chunk-XQSEJ7WN.mjs +0 -547
  55. package/dist/chunk-YRSSR4KN.mjs +0 -850
  56. package/dist/client-2xbeKnrg.d.mts +0 -1291
  57. package/dist/client-2xbeKnrg.d.ts +0 -1291
  58. package/dist/client-4HLAGzFg.d.mts +0 -1291
  59. package/dist/client-4HLAGzFg.d.ts +0 -1291
  60. package/dist/client-B4TQwNa7.d.mts +0 -1290
  61. package/dist/client-B4TQwNa7.d.ts +0 -1290
  62. package/dist/client-Bdi4ty0v.d.mts +0 -1294
  63. package/dist/client-Bdi4ty0v.d.ts +0 -1294
  64. package/dist/client-BsKpUH3H.d.mts +0 -1339
  65. package/dist/client-BsKpUH3H.d.ts +0 -1339
  66. package/dist/client-Bv1zOaWF.d.mts +0 -1291
  67. package/dist/client-Bv1zOaWF.d.ts +0 -1291
  68. package/dist/client-Bz9YJMIX.d.mts +0 -1290
  69. package/dist/client-Bz9YJMIX.d.ts +0 -1290
  70. package/dist/client-CBpzm34X.d.mts +0 -1291
  71. package/dist/client-CBpzm34X.d.ts +0 -1291
  72. package/dist/client-CNu_tCZZ.d.mts +0 -1305
  73. package/dist/client-CNu_tCZZ.d.ts +0 -1305
  74. package/dist/client-CmEvxxQu.d.mts +0 -1339
  75. package/dist/client-CmEvxxQu.d.ts +0 -1339
  76. package/dist/client-Ctl_0z6F.d.mts +0 -1294
  77. package/dist/client-Ctl_0z6F.d.ts +0 -1294
  78. package/dist/client-DGMAxkZc.d.mts +0 -1339
  79. package/dist/client-DGMAxkZc.d.ts +0 -1339
  80. package/dist/client-DZq-CqcD.d.mts +0 -1292
  81. package/dist/client-DZq-CqcD.d.ts +0 -1292
  82. package/dist/client-DcqGfDTt.d.mts +0 -1284
  83. package/dist/client-DcqGfDTt.d.ts +0 -1284
  84. package/dist/client-O8RvSRm0.d.mts +0 -1261
  85. package/dist/client-O8RvSRm0.d.ts +0 -1261
  86. package/dist/client.d.mts +0 -2
  87. package/dist/client.d.ts +0 -2
  88. package/dist/client.js +0 -922
  89. package/dist/client.mjs +0 -104
  90. package/dist/csharp-parser-JCKXIAJW.mjs +0 -9
  91. package/dist/go-parser-J4KIH4RG.mjs +0 -9
  92. package/dist/index-Ctl_0z6F.d.mts +0 -1294
  93. package/dist/index-Ctl_0z6F.d.ts +0 -1294
  94. package/dist/index-DLHCsiAk.d.mts +0 -1294
  95. package/dist/index-DLHCsiAk.d.ts +0 -1294
  96. package/dist/java-parser-3KHXOXRQ.mjs +0 -9
  97. package/dist/python-parser-7QISP7LK.mjs +0 -8
  98. package/dist/python-parser-PDCO35VN.mjs +0 -8
  99. package/dist/python-parser-QAAL56MC.mjs +0 -8
  100. package/dist/python-parser-R7HLPNZK.mjs +0 -8
  101. package/dist/python-parser-SJ3LFZFJ.mjs +0 -8
  102. package/dist/python-parser-UFLCDT6L.mjs +0 -8
  103. package/dist/typescript-parser-4GI7DPSW.mjs +0 -7
  104. package/dist/typescript-parser-4H3HUBO4.mjs +0 -7
  105. package/dist/typescript-parser-K63IVZMF.mjs +0 -7
  106. package/dist/typescript-parser-ZJKROMQG.mjs +0 -7
@@ -1,501 +0,0 @@
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 importsStr = fromMatch[2];
417
- if (importsStr.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 = importsStr.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
- };