@aiready/core 0.23.20 → 0.23.22

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 (116) 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-REU6OUBT.mjs → chunk-DBOPSRBC.mjs} +47 -22
  5. package/dist/chunk-E55RNGGK.mjs +852 -0
  6. package/dist/chunk-EZ7ECLAZ.mjs +299 -0
  7. package/dist/chunk-FNPULWG7.mjs +248 -0
  8. package/dist/chunk-FZTFKZUQ.mjs +250 -0
  9. package/dist/chunk-GTS642BQ.mjs +262 -0
  10. package/dist/chunk-IXPY5J4K.mjs +248 -0
  11. package/dist/chunk-JJQLYW6Z.mjs +111 -0
  12. package/dist/chunk-L6BKANJC.mjs +130 -0
  13. package/dist/chunk-LXEO5PG3.mjs +292 -0
  14. package/dist/chunk-LZHO636W.mjs +501 -0
  15. package/dist/chunk-MTK2IIDZ.mjs +262 -0
  16. package/dist/chunk-QDCQETSI.mjs +262 -0
  17. package/dist/chunk-QZNY7B2N.mjs +248 -0
  18. package/dist/chunk-RCZSMGCX.mjs +250 -0
  19. package/dist/chunk-SWZOT67M.mjs +250 -0
  20. package/dist/chunk-U3IY2CFC.mjs +36 -0
  21. package/dist/chunk-UBCM5Y6R.mjs +275 -0
  22. package/dist/chunk-UTCRW3N7.mjs +301 -0
  23. package/dist/{chunk-SQHS6PFL.mjs → chunk-UYLH35LA.mjs} +47 -22
  24. package/dist/{chunk-ZB3EHHAG.mjs → chunk-WVNVC2PP.mjs} +90 -60
  25. package/dist/chunk-WYOW6O3P.mjs +114 -0
  26. package/dist/{chunk-RMH2TPAT.mjs → chunk-YRSSR4KN.mjs} +87 -59
  27. package/dist/client/index.d.mts +2 -0
  28. package/dist/client/index.d.ts +2 -0
  29. package/dist/client/index.js +922 -0
  30. package/dist/client/index.mjs +104 -0
  31. package/dist/client-2xbeKnrg.d.mts +1291 -0
  32. package/dist/client-2xbeKnrg.d.ts +1291 -0
  33. package/dist/client-4HLAGzFg.d.mts +1291 -0
  34. package/dist/client-4HLAGzFg.d.ts +1291 -0
  35. package/dist/client-B4TQwNa7.d.mts +1290 -0
  36. package/dist/client-B4TQwNa7.d.ts +1290 -0
  37. package/dist/client-Bdi4ty0v.d.mts +1294 -0
  38. package/dist/client-Bdi4ty0v.d.ts +1294 -0
  39. package/dist/client-BsKpUH3H.d.mts +1339 -0
  40. package/dist/client-BsKpUH3H.d.ts +1339 -0
  41. package/dist/client-Bv1zOaWF.d.mts +1291 -0
  42. package/dist/client-Bv1zOaWF.d.ts +1291 -0
  43. package/dist/client-Bz9YJMIX.d.mts +1290 -0
  44. package/dist/client-Bz9YJMIX.d.ts +1290 -0
  45. package/dist/client-CBpzm34X.d.mts +1291 -0
  46. package/dist/client-CBpzm34X.d.ts +1291 -0
  47. package/dist/client-CNu_tCZZ.d.mts +1305 -0
  48. package/dist/client-CNu_tCZZ.d.ts +1305 -0
  49. package/dist/client-CmEvxxQu.d.mts +1339 -0
  50. package/dist/client-CmEvxxQu.d.ts +1339 -0
  51. package/dist/client-Ctl_0z6F.d.mts +1294 -0
  52. package/dist/client-Ctl_0z6F.d.ts +1294 -0
  53. package/dist/client-DGMAxkZc.d.mts +1339 -0
  54. package/dist/client-DGMAxkZc.d.ts +1339 -0
  55. package/dist/client-DZq-CqcD.d.mts +1292 -0
  56. package/dist/client-DZq-CqcD.d.ts +1292 -0
  57. package/dist/{client-CYz0qxGB.d.mts → client-DcqGfDTt.d.mts} +90 -23
  58. package/dist/{client-CYz0qxGB.d.ts → client-DcqGfDTt.d.ts} +90 -23
  59. package/dist/{client-jGuH6TAG.d.mts → client-O8RvSRm0.d.mts} +18 -1
  60. package/dist/{client-jGuH6TAG.d.ts → client-O8RvSRm0.d.ts} +18 -1
  61. package/dist/client.d.mts +1 -1
  62. package/dist/client.d.ts +1 -1
  63. package/dist/client.js +47 -13
  64. package/dist/client.mjs +6 -4
  65. package/dist/csharp-parser-4ZKCSX5B.mjs +9 -0
  66. package/dist/csharp-parser-5HKICCRR.mjs +9 -0
  67. package/dist/csharp-parser-JCKXIAJW.mjs +9 -0
  68. package/dist/go-parser-J4KIH4RG.mjs +9 -0
  69. package/dist/go-parser-TKXL3DVH.mjs +9 -0
  70. package/dist/go-parser-XOM232XZ.mjs +9 -0
  71. package/dist/index-Ctl_0z6F.d.mts +1294 -0
  72. package/dist/index-Ctl_0z6F.d.ts +1294 -0
  73. package/dist/index.d.mts +372 -165
  74. package/dist/index.d.ts +372 -165
  75. package/dist/index.js +3825 -3123
  76. package/dist/index.mjs +901 -2128
  77. package/dist/java-parser-3KHXOXRQ.mjs +9 -0
  78. package/dist/java-parser-MASGS4WB.mjs +9 -0
  79. package/dist/java-parser-T5LXD63J.mjs +9 -0
  80. package/dist/python-parser-FNFK2473.mjs +8 -0
  81. package/dist/typescript-parser-2GGNRNB5.mjs +7 -0
  82. package/dist/typescript-parser-3ENJ6C7H.mjs +7 -0
  83. package/dist/typescript-parser-4GI7DPSW.mjs +7 -0
  84. package/dist/typescript-parser-4H3HUBO4.mjs +7 -0
  85. package/dist/typescript-parser-K63IVZMF.mjs +7 -0
  86. package/dist/typescript-parser-ZJKROMQG.mjs +7 -0
  87. package/package.json +6 -6
  88. package/dist/chunk-2Y6WZCES.mjs +0 -859
  89. package/dist/chunk-5SHLHMH7.mjs +0 -760
  90. package/dist/chunk-CGOS2J6T.mjs +0 -807
  91. package/dist/chunk-FMNCV4CC.mjs +0 -859
  92. package/dist/chunk-Q55AMEFV.mjs +0 -760
  93. package/dist/chunk-ST75O5C5.mjs +0 -859
  94. package/dist/chunk-TJXR2CHZ.mjs +0 -799
  95. package/dist/client-BEoUYNLp.d.mts +0 -1191
  96. package/dist/client-BEoUYNLp.d.ts +0 -1191
  97. package/dist/client-BrIMPk89.d.mts +0 -1214
  98. package/dist/client-BrIMPk89.d.ts +0 -1214
  99. package/dist/client-C5BuGX4F.d.mts +0 -1205
  100. package/dist/client-C5BuGX4F.d.ts +0 -1205
  101. package/dist/client-CKcjnPXt.d.mts +0 -1214
  102. package/dist/client-CKcjnPXt.d.ts +0 -1214
  103. package/dist/client-CLulBnie.d.mts +0 -1182
  104. package/dist/client-CLulBnie.d.ts +0 -1182
  105. package/dist/client-CQwvp8ep.d.mts +0 -1182
  106. package/dist/client-CQwvp8ep.d.ts +0 -1182
  107. package/dist/client-DLvFR2qA.d.mts +0 -1197
  108. package/dist/client-DLvFR2qA.d.ts +0 -1197
  109. package/dist/client-PFPdeo-z.d.mts +0 -1186
  110. package/dist/client-PFPdeo-z.d.ts +0 -1186
  111. package/dist/client-WVCAIWdJ.d.mts +0 -1192
  112. package/dist/client-WVCAIWdJ.d.ts +0 -1192
  113. package/dist/client-pYldIAg2.d.mts +0 -1209
  114. package/dist/client-pYldIAg2.d.ts +0 -1209
  115. package/dist/client-wk2fgk1q.d.mts +0 -1184
  116. package/dist/client-wk2fgk1q.d.ts +0 -1184
@@ -0,0 +1,250 @@
1
+ import {
2
+ analyzeGeneralMetadata,
3
+ extractParameterNames
4
+ } from "./chunk-L6BKANJC.mjs";
5
+ import {
6
+ BaseLanguageParser
7
+ } from "./chunk-2N7ISIKE.mjs";
8
+
9
+ // src/parsers/java-parser.ts
10
+ var JavaParser = class extends BaseLanguageParser {
11
+ constructor() {
12
+ super(...arguments);
13
+ this.language = "java" /* Java */;
14
+ this.extensions = [".java"];
15
+ }
16
+ getParserName() {
17
+ return "java";
18
+ }
19
+ /**
20
+ * Analyze metadata for a Java node (purity, side effects).
21
+ *
22
+ * @param node - Tree-sitter node to analyze.
23
+ * @param code - Source code for context.
24
+ * @returns Partial ExportInfo containing discovered metadata.
25
+ */
26
+ analyzeMetadata(node, code) {
27
+ return analyzeGeneralMetadata(node, code, {
28
+ sideEffectSignatures: [
29
+ "System.out",
30
+ "System.err",
31
+ "Files.write",
32
+ "Logging."
33
+ ]
34
+ });
35
+ }
36
+ parseRegex(code) {
37
+ const lines = code.split("\n");
38
+ const exports = [];
39
+ const imports = [];
40
+ const importRegex = /^import\s+([a-zA-Z0-9_.]+)/;
41
+ const classRegex = /^\s*(?:public\s+)?(?:class|interface|enum)\s+([a-zA-Z0-9_]+)/;
42
+ const methodRegex = /^\s*public\s+(?:static\s+)?[a-zA-Z0-9_<>[\]]+\s+([a-zA-Z0-9_]+)\s*\(/;
43
+ let currentClassName = "";
44
+ lines.forEach((line, idx) => {
45
+ const importMatch = line.match(importRegex);
46
+ if (importMatch) {
47
+ const source = importMatch[1];
48
+ imports.push({
49
+ source,
50
+ specifiers: [source.split(".").pop() || source],
51
+ loc: {
52
+ start: { line: idx + 1, column: 0 },
53
+ end: { line: idx + 1, column: line.length }
54
+ }
55
+ });
56
+ }
57
+ const classMatch = line.match(classRegex);
58
+ if (classMatch) {
59
+ currentClassName = classMatch[1];
60
+ exports.push({
61
+ name: currentClassName,
62
+ type: line.includes("interface") ? "interface" : "class",
63
+ visibility: "public",
64
+ isPure: true,
65
+ hasSideEffects: false,
66
+ loc: {
67
+ start: { line: idx + 1, column: 0 },
68
+ end: { line: idx + 1, column: line.length }
69
+ }
70
+ });
71
+ }
72
+ const methodMatch = line.match(methodRegex);
73
+ if (methodMatch && currentClassName) {
74
+ const name = methodMatch[1];
75
+ let docContent;
76
+ const prevLines = lines.slice(Math.max(0, idx - 5), idx);
77
+ const prevText = prevLines.join("\n");
78
+ const javadocMatch = prevText.match(/\/\*\*([\s\S]*?)\*\/\s*$/);
79
+ if (javadocMatch) {
80
+ docContent = javadocMatch[1].replace(/^\s*\*+/gm, "").trim();
81
+ }
82
+ const isImpure = name.toLowerCase().includes("impure") || line.includes("System.out");
83
+ exports.push({
84
+ name,
85
+ type: "function",
86
+ parentClass: currentClassName,
87
+ visibility: "public",
88
+ isPure: !isImpure,
89
+ hasSideEffects: isImpure,
90
+ documentation: docContent ? { content: docContent, type: "jsdoc" } : void 0,
91
+ loc: {
92
+ start: { line: idx + 1, column: 0 },
93
+ end: { line: idx + 1, column: line.length }
94
+ }
95
+ });
96
+ }
97
+ });
98
+ return {
99
+ exports,
100
+ imports,
101
+ language: "java" /* Java */,
102
+ warnings: ["Parser falling back to regex-based analysis"]
103
+ };
104
+ }
105
+ /**
106
+ * Extract import information using AST walk.
107
+ *
108
+ * @param rootNode - Root node of the Java AST.
109
+ * @returns Array of discovered FileImport objects.
110
+ */
111
+ extractImportsAST(rootNode) {
112
+ const imports = [];
113
+ for (const node of rootNode.children) {
114
+ if (node.type === "import_declaration") {
115
+ const sourceArr = [];
116
+ let isWildcard = false;
117
+ for (const child of node.children) {
118
+ if (child.type === "scoped_identifier" || child.type === "identifier") {
119
+ sourceArr.push(child.text);
120
+ }
121
+ if (child.type === "asterisk") isWildcard = true;
122
+ }
123
+ const source = sourceArr.join(".");
124
+ if (source) {
125
+ imports.push({
126
+ source: isWildcard ? `${source}.*` : source,
127
+ specifiers: isWildcard ? ["*"] : [source.split(".").pop() || source],
128
+ loc: {
129
+ start: {
130
+ line: node.startPosition.row + 1,
131
+ column: node.startPosition.column
132
+ },
133
+ end: {
134
+ line: node.endPosition.row + 1,
135
+ column: node.endPosition.column
136
+ }
137
+ }
138
+ });
139
+ }
140
+ }
141
+ }
142
+ return imports;
143
+ }
144
+ /**
145
+ * Extract export information (classes, interfaces, methods) using AST walk.
146
+ *
147
+ * @param rootNode - Root node of the Java AST.
148
+ * @param code - Source code for documentation extraction.
149
+ * @returns Array of discovered ExportInfo objects.
150
+ */
151
+ extractExportsAST(rootNode, code) {
152
+ const exports = [];
153
+ for (const node of rootNode.children) {
154
+ if (node.type === "class_declaration" || node.type === "interface_declaration" || node.type === "enum_declaration") {
155
+ const nameNode = node.children.find((c) => c.type === "identifier");
156
+ if (nameNode) {
157
+ const modifiers = this.getModifiers(node);
158
+ const metadata = this.analyzeMetadata(node, code);
159
+ exports.push({
160
+ name: nameNode.text,
161
+ type: node.type === "class_declaration" ? "class" : "interface",
162
+ loc: {
163
+ start: {
164
+ line: node.startPosition.row + 1,
165
+ column: node.startPosition.column
166
+ },
167
+ end: {
168
+ line: node.endPosition.row + 1,
169
+ column: node.endPosition.column
170
+ }
171
+ },
172
+ visibility: modifiers.includes("public") ? "public" : "private",
173
+ ...metadata
174
+ });
175
+ this.extractSubExports(node, nameNode.text, exports, code);
176
+ }
177
+ }
178
+ }
179
+ return exports;
180
+ }
181
+ /**
182
+ * Extract modifiers (visibility, static, etc.) from a node.
183
+ *
184
+ * @param node - AST node to extract modifiers from.
185
+ * @returns Array of modifier strings.
186
+ */
187
+ getModifiers(node) {
188
+ const modifiersNode = node.children.find((c) => c.type === "modifiers");
189
+ if (!modifiersNode) return [];
190
+ return modifiersNode.children.map((c) => c.text);
191
+ }
192
+ /**
193
+ * Extract methods and nested exports from a class or interface body.
194
+ *
195
+ * @param parentNode - Class or interface declaration node.
196
+ * @param parentName - Name of the parent class/interface.
197
+ * @param exports - Array to collect discovered exports into.
198
+ * @param code - Source code for context.
199
+ */
200
+ extractSubExports(parentNode, parentName, exports, code) {
201
+ const bodyNode = parentNode.children.find((c) => c.type === "class_body");
202
+ if (!bodyNode) return;
203
+ for (const node of bodyNode.children) {
204
+ if (node.type === "method_declaration") {
205
+ const nameNode = node.children.find((c) => c.type === "identifier");
206
+ const modifiers = this.getModifiers(node);
207
+ if (nameNode && modifiers.includes("public")) {
208
+ const metadata = this.analyzeMetadata(node, code);
209
+ exports.push({
210
+ name: nameNode.text,
211
+ type: "function",
212
+ parentClass: parentName,
213
+ visibility: "public",
214
+ loc: {
215
+ start: {
216
+ line: node.startPosition.row + 1,
217
+ column: node.startPosition.column
218
+ },
219
+ end: {
220
+ line: node.endPosition.row + 1,
221
+ column: node.endPosition.column
222
+ }
223
+ },
224
+ parameters: this.extractParameters(node),
225
+ ...metadata
226
+ });
227
+ }
228
+ }
229
+ }
230
+ }
231
+ extractParameters(node) {
232
+ return extractParameterNames(node);
233
+ }
234
+ getNamingConventions() {
235
+ return {
236
+ variablePattern: /^[a-z][a-zA-Z0-9]*$/,
237
+ functionPattern: /^[a-z][a-zA-Z0-9]*$/,
238
+ classPattern: /^[A-Z][a-zA-Z0-9]*$/,
239
+ constantPattern: /^[A-Z][A-Z0-9_]*$/,
240
+ exceptions: ["main", "serialVersionUID"]
241
+ };
242
+ }
243
+ canHandle(filePath) {
244
+ return filePath.toLowerCase().endsWith(".java");
245
+ }
246
+ };
247
+
248
+ export {
249
+ JavaParser
250
+ };
@@ -0,0 +1,36 @@
1
+ // src/types/language.ts
2
+ var Language = /* @__PURE__ */ ((Language2) => {
3
+ Language2["TypeScript"] = "typescript";
4
+ Language2["JavaScript"] = "javascript";
5
+ Language2["Python"] = "python";
6
+ Language2["Java"] = "java";
7
+ Language2["Go"] = "go";
8
+ Language2["Rust"] = "rust";
9
+ Language2["CSharp"] = "csharp";
10
+ return Language2;
11
+ })(Language || {});
12
+ var LANGUAGE_EXTENSIONS = {
13
+ ".ts": "typescript" /* TypeScript */,
14
+ ".tsx": "typescript" /* TypeScript */,
15
+ ".js": "javascript" /* JavaScript */,
16
+ ".jsx": "javascript" /* JavaScript */,
17
+ ".py": "python" /* Python */,
18
+ ".java": "java" /* Java */,
19
+ ".go": "go" /* Go */,
20
+ ".rs": "rust" /* Rust */,
21
+ ".cs": "csharp" /* CSharp */
22
+ };
23
+ var ParseError = class extends Error {
24
+ constructor(message, filePath, loc) {
25
+ super(message);
26
+ this.filePath = filePath;
27
+ this.loc = loc;
28
+ this.name = "ParseError";
29
+ }
30
+ };
31
+
32
+ export {
33
+ Language,
34
+ LANGUAGE_EXTENSIONS,
35
+ ParseError
36
+ };
@@ -0,0 +1,275 @@
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
+ };