@aiready/core 0.24.23 → 0.24.26

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 (59) hide show
  1. package/dist/chunk-3GCIM6XG.mjs +904 -0
  2. package/dist/chunk-3S5WU6KX.mjs +552 -0
  3. package/dist/chunk-4OMXBYX7.mjs +167 -0
  4. package/dist/chunk-6YWGFKZG.mjs +250 -0
  5. package/dist/chunk-A3BIROBZ.mjs +902 -0
  6. package/dist/chunk-BYMQDORS.mjs +256 -0
  7. package/dist/chunk-CBZNRNEF.mjs +309 -0
  8. package/dist/chunk-ET2WRQSM.mjs +262 -0
  9. package/dist/chunk-F4FTHFHK.mjs +552 -0
  10. package/dist/chunk-G737F72Q.mjs +256 -0
  11. package/dist/chunk-GVFUAIWU.mjs +864 -0
  12. package/dist/chunk-KSEA5XDH.mjs +894 -0
  13. package/dist/chunk-LMIZRJFV.mjs +256 -0
  14. package/dist/chunk-LRPBPWBM.mjs +170 -0
  15. package/dist/chunk-MOTBXU6W.mjs +902 -0
  16. package/dist/chunk-OAH6FVVF.mjs +919 -0
  17. package/dist/chunk-OCM6HLBM.mjs +262 -0
  18. package/dist/chunk-OFBRNGKT.mjs +893 -0
  19. package/dist/chunk-P3KYGPO4.mjs +262 -0
  20. package/dist/chunk-PNWSO6XQ.mjs +250 -0
  21. package/dist/chunk-SO6UKAPR.mjs +164 -0
  22. package/dist/chunk-T2FW6AAF.mjs +552 -0
  23. package/dist/chunk-TQX77RIC.mjs +250 -0
  24. package/dist/chunk-X64EJ3ZO.mjs +314 -0
  25. package/dist/client/index.d.mts +1 -1
  26. package/dist/client/index.d.ts +1 -1
  27. package/dist/client/index.js +32 -5
  28. package/dist/client/index.mjs +1 -1
  29. package/dist/csharp-parser-3CGM6FKB.mjs +9 -0
  30. package/dist/csharp-parser-UWRUYHUH.mjs +9 -0
  31. package/dist/csharp-parser-WIAIE3DD.mjs +9 -0
  32. package/dist/go-parser-AH5QNS4O.mjs +9 -0
  33. package/dist/go-parser-CSAB23BL.mjs +9 -0
  34. package/dist/go-parser-Q3HI32B7.mjs +9 -0
  35. package/dist/index-CL_0jxiJ.d.mts +1315 -0
  36. package/dist/index-CL_0jxiJ.d.ts +1315 -0
  37. package/dist/index-ClwnZa_Y.d.mts +1333 -0
  38. package/dist/index-ClwnZa_Y.d.ts +1333 -0
  39. package/dist/index-DC0cdf0g.d.mts +1321 -0
  40. package/dist/index-DC0cdf0g.d.ts +1321 -0
  41. package/dist/index-DKqKGhcJ.d.mts +1309 -0
  42. package/dist/index-DKqKGhcJ.d.ts +1309 -0
  43. package/dist/index-DNnlhdk0.d.mts +1318 -0
  44. package/dist/index-DNnlhdk0.d.ts +1318 -0
  45. package/dist/index-De2xy_k5.d.mts +1326 -0
  46. package/dist/index-De2xy_k5.d.ts +1326 -0
  47. package/dist/index.d.mts +104 -20
  48. package/dist/index.d.ts +104 -20
  49. package/dist/index.js +581 -147
  50. package/dist/index.mjs +507 -134
  51. package/dist/java-parser-GUKWCEYS.mjs +9 -0
  52. package/dist/java-parser-XTWT5Y5I.mjs +9 -0
  53. package/dist/java-parser-YP5XWLQK.mjs +9 -0
  54. package/dist/python-parser-AOPXUEIV.mjs +8 -0
  55. package/dist/python-parser-FB55P6UA.mjs +8 -0
  56. package/dist/python-parser-WIJPSRKC.mjs +8 -0
  57. package/dist/typescript-parser-5ZWLLMWJ.mjs +7 -0
  58. package/dist/typescript-parser-TWPRLYK6.mjs +7 -0
  59. package/package.json +5 -1
@@ -0,0 +1,552 @@
1
+ import {
2
+ BaseLanguageParser
3
+ } from "./chunk-4OMXBYX7.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;
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("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 PYTHON_CONSTANTS = {
125
+ NODES: {
126
+ IMPORT_STATEMENT: "import_statement",
127
+ IMPORT_FROM_STATEMENT: "import_from_statement",
128
+ DOTTED_NAME: "dotted_name",
129
+ ALIASED_IMPORT: "aliased_import",
130
+ WILDCARD_IMPORT: "wildcard_import",
131
+ FUNCTION_DEFINITION: "function_definition",
132
+ CLASS_DEFINITION: "class_definition",
133
+ EXPRESSION_STATEMENT: "expression_statement",
134
+ ASSIGNMENT: "assignment",
135
+ IDENTIFIER: "identifier",
136
+ TYPED_PARAMETER: "typed_parameter",
137
+ DEFAULT_PARAMETER: "default_parameter"
138
+ },
139
+ FIELDS: {
140
+ NAME: "name",
141
+ MODULE_NAME: "module_name",
142
+ LEFT: "left",
143
+ PARAMETERS: "parameters"
144
+ },
145
+ SPECIAL: {
146
+ WILDCARD: "*",
147
+ DUNDER_ALL: "__all__",
148
+ DUNDER_VERSION: "__version__",
149
+ DUNDER_AUTHOR: "__author__",
150
+ DUNDER_INIT: "__init__",
151
+ DUNDER_STR: "__str__",
152
+ DUNDER_REPR: "__repr__",
153
+ DUNDER_NAME: "__name__",
154
+ DUNDER_MAIN: "__main__",
155
+ DUNDER_FILE: "__file__",
156
+ DUNDER_DOC: "__doc__",
157
+ DUNDER_DICT: "__dict__",
158
+ DUNDER_CLASS: "__class__",
159
+ DUNDER_MODULE: "__module__",
160
+ DUNDER_BASES: "__bases__",
161
+ MAIN_VAL: "__main__"
162
+ },
163
+ BUILTINS: {
164
+ PRINT: "print(",
165
+ INPUT: "input(",
166
+ OPEN: "open("
167
+ },
168
+ TYPES: {
169
+ FUNCTION: "function",
170
+ CLASS: "class",
171
+ VARIABLE: "variable",
172
+ CONST: "const",
173
+ DOCSTRING: "docstring"
174
+ }
175
+ };
176
+ var PythonParser = class extends BaseLanguageParser {
177
+ constructor() {
178
+ super(...arguments);
179
+ this.language = "python" /* Python */;
180
+ this.extensions = [".py"];
181
+ }
182
+ /**
183
+ * Returns the canonical name of this parser.
184
+ */
185
+ getParserName() {
186
+ return "python";
187
+ }
188
+ /**
189
+ * Analyze metadata for a Python node (purity, side effects).
190
+ */
191
+ analyzeMetadata(node, code) {
192
+ return analyzeNodeMetadata(node, code, {
193
+ sideEffectSignatures: [
194
+ PYTHON_CONSTANTS.BUILTINS.PRINT,
195
+ PYTHON_CONSTANTS.BUILTINS.INPUT,
196
+ PYTHON_CONSTANTS.BUILTINS.OPEN
197
+ ]
198
+ });
199
+ }
200
+ /**
201
+ * Extract import information using AST walk.
202
+ */
203
+ extractImportsAST(rootNode) {
204
+ const imports = [];
205
+ const processImportNode = (node) => {
206
+ if (node.type === PYTHON_CONSTANTS.NODES.IMPORT_STATEMENT) {
207
+ for (const child of node.children) {
208
+ if (child.type === PYTHON_CONSTANTS.NODES.DOTTED_NAME) {
209
+ const source = child.text;
210
+ imports.push({
211
+ source,
212
+ specifiers: [source],
213
+ loc: {
214
+ start: {
215
+ line: child.startPosition.row + 1,
216
+ column: child.startPosition.column
217
+ },
218
+ end: {
219
+ line: child.endPosition.row + 1,
220
+ column: child.endPosition.column
221
+ }
222
+ }
223
+ });
224
+ } else if (child.type === PYTHON_CONSTANTS.NODES.ALIASED_IMPORT) {
225
+ const nameNode = child.childForFieldName(
226
+ PYTHON_CONSTANTS.FIELDS.NAME
227
+ );
228
+ if (nameNode) {
229
+ const source = nameNode.text;
230
+ imports.push({
231
+ source,
232
+ specifiers: [source],
233
+ loc: {
234
+ start: {
235
+ line: child.startPosition.row + 1,
236
+ column: child.startPosition.column
237
+ },
238
+ end: {
239
+ line: child.endPosition.row + 1,
240
+ column: child.endPosition.column
241
+ }
242
+ }
243
+ });
244
+ }
245
+ }
246
+ }
247
+ } else if (node.type === PYTHON_CONSTANTS.NODES.IMPORT_FROM_STATEMENT) {
248
+ const moduleNameNode = node.childForFieldName(
249
+ PYTHON_CONSTANTS.FIELDS.MODULE_NAME
250
+ );
251
+ if (moduleNameNode) {
252
+ const source = moduleNameNode.text;
253
+ const specifiers = [];
254
+ for (const child of node.children) {
255
+ if (child.type === PYTHON_CONSTANTS.NODES.DOTTED_NAME && child !== moduleNameNode) {
256
+ specifiers.push(child.text);
257
+ } else if (child.type === PYTHON_CONSTANTS.NODES.ALIASED_IMPORT) {
258
+ const nameNode = child.childForFieldName(
259
+ PYTHON_CONSTANTS.FIELDS.NAME
260
+ );
261
+ if (nameNode) specifiers.push(nameNode.text);
262
+ } else if (child.type === PYTHON_CONSTANTS.NODES.WILDCARD_IMPORT) {
263
+ specifiers.push(PYTHON_CONSTANTS.SPECIAL.WILDCARD);
264
+ }
265
+ }
266
+ if (specifiers.length > 0) {
267
+ imports.push({
268
+ source,
269
+ specifiers,
270
+ loc: {
271
+ start: {
272
+ line: node.startPosition.row + 1,
273
+ column: node.startPosition.column
274
+ },
275
+ end: {
276
+ line: node.endPosition.row + 1,
277
+ column: node.endPosition.column
278
+ }
279
+ }
280
+ });
281
+ }
282
+ }
283
+ }
284
+ };
285
+ for (const node of rootNode.children) {
286
+ processImportNode(node);
287
+ }
288
+ return imports;
289
+ }
290
+ /**
291
+ * Extract export information using AST walk.
292
+ */
293
+ extractExportsAST(rootNode, code) {
294
+ const exports = [];
295
+ for (const node of rootNode.children) {
296
+ if (node.type === PYTHON_CONSTANTS.NODES.FUNCTION_DEFINITION) {
297
+ const nameNode = node.childForFieldName(PYTHON_CONSTANTS.FIELDS.NAME);
298
+ if (nameNode) {
299
+ const name = nameNode.text;
300
+ const isPrivate = name.startsWith("_") && !name.startsWith("__");
301
+ if (!isPrivate) {
302
+ const metadata = this.analyzeMetadata(node, code);
303
+ exports.push({
304
+ name,
305
+ type: PYTHON_CONSTANTS.TYPES.FUNCTION,
306
+ loc: {
307
+ start: {
308
+ line: node.startPosition.row + 1,
309
+ column: node.startPosition.column
310
+ },
311
+ end: {
312
+ line: node.endPosition.row + 1,
313
+ column: node.endPosition.column
314
+ }
315
+ },
316
+ parameters: this.extractParameters(node),
317
+ ...metadata
318
+ });
319
+ }
320
+ }
321
+ } else if (node.type === PYTHON_CONSTANTS.NODES.CLASS_DEFINITION) {
322
+ const nameNode = node.childForFieldName(PYTHON_CONSTANTS.FIELDS.NAME);
323
+ if (nameNode) {
324
+ const metadata = this.analyzeMetadata(node, code);
325
+ exports.push({
326
+ name: nameNode.text,
327
+ type: PYTHON_CONSTANTS.TYPES.CLASS,
328
+ loc: {
329
+ start: {
330
+ line: node.startPosition.row + 1,
331
+ column: node.startPosition.column
332
+ },
333
+ end: {
334
+ line: node.endPosition.row + 1,
335
+ column: node.endPosition.column
336
+ }
337
+ },
338
+ ...metadata
339
+ });
340
+ }
341
+ } else if (node.type === PYTHON_CONSTANTS.NODES.EXPRESSION_STATEMENT) {
342
+ const assignment = node.firstChild;
343
+ if (assignment && assignment.type === PYTHON_CONSTANTS.NODES.ASSIGNMENT) {
344
+ const left = assignment.childForFieldName(
345
+ PYTHON_CONSTANTS.FIELDS.LEFT
346
+ );
347
+ if (left && left.type === PYTHON_CONSTANTS.NODES.IDENTIFIER) {
348
+ const name = left.text;
349
+ const isInternal = name === PYTHON_CONSTANTS.SPECIAL.DUNDER_ALL || name === PYTHON_CONSTANTS.SPECIAL.DUNDER_VERSION || name === PYTHON_CONSTANTS.SPECIAL.DUNDER_AUTHOR;
350
+ const isPrivate = name.startsWith("_") && !name.startsWith("__");
351
+ if (!isInternal && !isPrivate) {
352
+ exports.push({
353
+ name,
354
+ type: name === name.toUpperCase() ? PYTHON_CONSTANTS.TYPES.CONST : PYTHON_CONSTANTS.TYPES.VARIABLE,
355
+ loc: {
356
+ start: {
357
+ line: node.startPosition.row + 1,
358
+ column: node.startPosition.column
359
+ },
360
+ end: {
361
+ line: node.endPosition.row + 1,
362
+ column: node.endPosition.column
363
+ }
364
+ }
365
+ });
366
+ }
367
+ }
368
+ }
369
+ }
370
+ }
371
+ return exports;
372
+ }
373
+ /**
374
+ * Extract parameter names from a function definition node.
375
+ */
376
+ extractParameters(node) {
377
+ const paramsNode = node.childForFieldName(
378
+ PYTHON_CONSTANTS.FIELDS.PARAMETERS
379
+ );
380
+ if (!paramsNode) return [];
381
+ return paramsNode.children.filter(
382
+ (c) => c.type === PYTHON_CONSTANTS.NODES.IDENTIFIER || c.type === PYTHON_CONSTANTS.NODES.TYPED_PARAMETER || c.type === PYTHON_CONSTANTS.NODES.DEFAULT_PARAMETER
383
+ ).map((c) => {
384
+ if (c.type === PYTHON_CONSTANTS.NODES.IDENTIFIER) return c.text;
385
+ return c.firstChild?.text || "unknown";
386
+ });
387
+ }
388
+ /**
389
+ * Fallback regex-based parsing when tree-sitter is unavailable.
390
+ */
391
+ parseRegex(code, filePath) {
392
+ try {
393
+ const imports = this.extractImportsRegex(code, filePath);
394
+ const exports = this.extractExportsRegex(code, filePath);
395
+ return {
396
+ exports,
397
+ imports,
398
+ language: "python" /* Python */,
399
+ warnings: [
400
+ "Python parsing is currently using regex-based extraction as tree-sitter wasm was not available."
401
+ ]
402
+ };
403
+ } catch (error) {
404
+ const message = error instanceof Error ? error.message : String(error);
405
+ const wrapper = new Error(
406
+ `Failed to parse Python file ${filePath}: ${message}`
407
+ );
408
+ if (error instanceof Error) {
409
+ wrapper.cause = error;
410
+ }
411
+ throw wrapper;
412
+ }
413
+ }
414
+ getNamingConventions() {
415
+ return {
416
+ variablePattern: /^[a-z_][a-z0-9_]*$/,
417
+ functionPattern: /^[a-z_][a-z0-9_]*$/,
418
+ classPattern: /^[A-Z][a-zA-Z0-9]*$/,
419
+ constantPattern: /^[A-Z][A-Z0-9_]*$/,
420
+ exceptions: [
421
+ PYTHON_CONSTANTS.SPECIAL.DUNDER_INIT,
422
+ PYTHON_CONSTANTS.SPECIAL.DUNDER_STR,
423
+ PYTHON_CONSTANTS.SPECIAL.DUNDER_REPR,
424
+ PYTHON_CONSTANTS.SPECIAL.DUNDER_NAME,
425
+ PYTHON_CONSTANTS.SPECIAL.DUNDER_MAIN,
426
+ PYTHON_CONSTANTS.SPECIAL.DUNDER_FILE,
427
+ PYTHON_CONSTANTS.SPECIAL.DUNDER_DOC,
428
+ PYTHON_CONSTANTS.SPECIAL.DUNDER_ALL,
429
+ PYTHON_CONSTANTS.SPECIAL.DUNDER_VERSION,
430
+ PYTHON_CONSTANTS.SPECIAL.DUNDER_AUTHOR,
431
+ PYTHON_CONSTANTS.SPECIAL.DUNDER_DICT,
432
+ PYTHON_CONSTANTS.SPECIAL.DUNDER_CLASS,
433
+ PYTHON_CONSTANTS.SPECIAL.DUNDER_MODULE,
434
+ PYTHON_CONSTANTS.SPECIAL.DUNDER_BASES
435
+ ]
436
+ };
437
+ }
438
+ canHandle(filePath) {
439
+ return filePath.toLowerCase().endsWith(".py");
440
+ }
441
+ extractImportsRegex(code, _filePath) {
442
+ void _filePath;
443
+ const imports = [];
444
+ const lines = code.split("\n");
445
+ const importRegex = /^\s*import\s+([a-zA-Z0-9_., ]+)/;
446
+ const fromImportRegex = /^\s*from\s+([a-zA-Z0-9_.]+)\s+import\s+(.+)/;
447
+ lines.forEach((line, idx) => {
448
+ if (line.trim().startsWith("#")) return;
449
+ const importMatch = line.match(importRegex);
450
+ if (importMatch) {
451
+ const modules = importMatch[1].split(",").map((m) => m.trim().split(" as ")[0]);
452
+ modules.forEach((module) => {
453
+ imports.push({
454
+ source: module,
455
+ specifiers: [module],
456
+ loc: {
457
+ start: { line: idx + 1, column: 0 },
458
+ end: { line: idx + 1, column: line.length }
459
+ }
460
+ });
461
+ });
462
+ return;
463
+ }
464
+ const fromMatch = line.match(fromImportRegex);
465
+ if (fromMatch) {
466
+ const module = fromMatch[1];
467
+ const importsStr = fromMatch[2];
468
+ if (importsStr.trim() === PYTHON_CONSTANTS.SPECIAL.WILDCARD) {
469
+ imports.push({
470
+ source: module,
471
+ specifiers: [PYTHON_CONSTANTS.SPECIAL.WILDCARD],
472
+ loc: {
473
+ start: { line: idx + 1, column: 0 },
474
+ end: { line: idx + 1, column: line.length }
475
+ }
476
+ });
477
+ return;
478
+ }
479
+ const specifiers = importsStr.split(",").map((s) => s.trim().split(" as ")[0]);
480
+ imports.push({
481
+ source: module,
482
+ specifiers,
483
+ loc: {
484
+ start: { line: idx + 1, column: 0 },
485
+ end: { line: idx + 1, column: line.length }
486
+ }
487
+ });
488
+ }
489
+ });
490
+ return imports;
491
+ }
492
+ extractExportsRegex(code, _filePath) {
493
+ void _filePath;
494
+ const exports = [];
495
+ const lines = code.split("\n");
496
+ const funcRegex = /^def\s+([a-zA-Z0-9_]+)\s*\(/;
497
+ const classRegex = /^class\s+([a-zA-Z0-9_]+)/;
498
+ lines.forEach((line, idx) => {
499
+ const indent = line.search(/\S/);
500
+ if (indent !== 0) return;
501
+ const classMatch = line.match(classRegex);
502
+ if (classMatch) {
503
+ exports.push({
504
+ name: classMatch[1],
505
+ type: PYTHON_CONSTANTS.TYPES.CLASS,
506
+ visibility: "public",
507
+ isPure: true,
508
+ hasSideEffects: false,
509
+ loc: {
510
+ start: { line: idx + 1, column: 0 },
511
+ end: { line: idx + 1, column: line.length }
512
+ }
513
+ });
514
+ return;
515
+ }
516
+ const funcMatch = line.match(funcRegex);
517
+ if (funcMatch) {
518
+ const name = funcMatch[1];
519
+ if (name.startsWith("_") && !name.startsWith("__")) return;
520
+ let docContent;
521
+ const nextLines = lines.slice(idx + 1, idx + 4);
522
+ for (const nextLine of nextLines) {
523
+ const docMatch = nextLine.match(/^\s*"""([\s\S]*?)"""/) || nextLine.match(/^\s*'''([\s\S]*?)'''/);
524
+ if (docMatch) {
525
+ docContent = docMatch[1].trim();
526
+ break;
527
+ }
528
+ if (nextLine.trim() && !nextLine.trim().startsWith('"""') && !nextLine.trim().startsWith("'''"))
529
+ break;
530
+ }
531
+ const isImpure = name.toLowerCase().includes("impure") || line.includes(PYTHON_CONSTANTS.BUILTINS.PRINT) || idx + 1 < lines.length && lines[idx + 1].includes(PYTHON_CONSTANTS.BUILTINS.PRINT);
532
+ exports.push({
533
+ name,
534
+ type: PYTHON_CONSTANTS.TYPES.FUNCTION,
535
+ visibility: "public",
536
+ isPure: !isImpure,
537
+ hasSideEffects: isImpure,
538
+ documentation: docContent ? { content: docContent, type: PYTHON_CONSTANTS.TYPES.DOCSTRING } : void 0,
539
+ loc: {
540
+ start: { line: idx + 1, column: 0 },
541
+ end: { line: idx + 1, column: line.length }
542
+ }
543
+ });
544
+ }
545
+ });
546
+ return exports;
547
+ }
548
+ };
549
+
550
+ export {
551
+ PythonParser
552
+ };