@aiready/core 0.24.5 → 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 +255 -109
  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,7 +1,7 @@
1
1
  import {
2
2
  analyzeGeneralMetadata,
3
3
  extractParameterNames
4
- } from "./chunk-WYOW6O3P.mjs";
4
+ } from "./chunk-DHFOYNMW.mjs";
5
5
  import {
6
6
  BaseLanguageParser
7
7
  } from "./chunk-2N7ISIKE.mjs";
@@ -1,4 +1,8 @@
1
1
  // src/parsers/shared-parser-utils.ts
2
+ function getNodeProperty(node, prop) {
3
+ if (!node) return null;
4
+ return node[prop] ?? null;
5
+ }
2
6
  var SIDE_EFFECT_KEYWORDS = [
3
7
  "print(",
4
8
  "console.",
@@ -19,11 +23,27 @@ function analyzeGeneralMetadata(node, code, options = {}) {
19
23
  hasSideEffects: false
20
24
  };
21
25
  try {
22
- let prev = node.previousNamedSibling || node.previousSibling || null;
26
+ let prev = getNodeProperty(node, "previousNamedSibling") || getNodeProperty(node, "previousSibling") || null;
27
+ while (prev && (!prev.type || !prev.text.trim())) {
28
+ prev = getNodeProperty(prev, "previousSibling");
29
+ }
30
+ if (!prev && node.parent) {
31
+ const children = node.parent.children;
32
+ const idx = children.indexOf(node);
33
+ if (idx > 0) {
34
+ prev = children[idx - 1];
35
+ while (prev && idx > 0 && (!prev.type || !prev.text.trim())) {
36
+ prev = children[idx - 2] || null;
37
+ }
38
+ }
39
+ }
23
40
  while (prev && /attribute|decorator/i.test(prev.type)) {
24
- prev = prev.previousNamedSibling || prev.previousSibling || null;
41
+ prev = getNodeProperty(prev, "previousNamedSibling") || getNodeProperty(prev, "previousSibling") || null;
42
+ while (prev && (!prev.type || !prev.text.trim())) {
43
+ prev = getNodeProperty(prev, "previousSibling");
44
+ }
25
45
  }
26
- while (prev && /comment|xml|doc/i.test(prev.type)) {
46
+ while (prev && (/comment|xml|doc|slash/i.test(prev.type) || prev.text.trim().startsWith("//") || prev.text.trim().startsWith("///"))) {
27
47
  const text = prev.text || "";
28
48
  if (text.trim().startsWith("/**")) {
29
49
  metadata.documentation = {
@@ -46,7 +66,7 @@ function analyzeGeneralMetadata(node, code, options = {}) {
46
66
  };
47
67
  break;
48
68
  }
49
- prev = prev.previousSibling || null;
69
+ prev = getNodeProperty(prev, "previousSibling");
50
70
  }
51
71
  } catch {
52
72
  }
@@ -83,8 +103,12 @@ function extractParameterNames(node) {
83
103
  const params = [];
84
104
  const candidates = [
85
105
  // common field name
86
- node.childForFieldName ? node.childForFieldName("parameters") : null,
87
- node.childForFieldName ? node.childForFieldName("parameter_list") : null,
106
+ getNodeProperty(node, "childForFieldName") ? getNodeProperty(node, "childForFieldName")?.childForFieldName?.(
107
+ "parameters"
108
+ ) ?? null : null,
109
+ getNodeProperty(node, "childForFieldName") ? getNodeProperty(node, "childForFieldName")?.childForFieldName?.(
110
+ "parameter_list"
111
+ ) ?? null : null,
88
112
  node.children.find((c) => c.type === "parameter_list") || null,
89
113
  node.children.find((c) => c.type === "parameters") || null,
90
114
  node.children.find((c) => c.type === "formal_parameters") || null,
@@ -94,7 +118,9 @@ function extractParameterNames(node) {
94
118
  if (!list) return params;
95
119
  for (const child of list.children) {
96
120
  if (!child) continue;
97
- const id = child.childForFieldName?.("name") || child.children.find(
121
+ const id = getNodeProperty(child, "childForFieldName")?.childForFieldName?.(
122
+ "name"
123
+ ) || child.children.find(
98
124
  (c) => [
99
125
  "identifier",
100
126
  "variable_name",
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  analyzeGeneralMetadata,
3
3
  extractParameterNames
4
- } from "./chunk-L6BKANJC.mjs";
4
+ } from "./chunk-DHFOYNMW.mjs";
5
5
  import {
6
6
  BaseLanguageParser
7
7
  } from "./chunk-2N7ISIKE.mjs";
@@ -25,9 +25,10 @@ var TypeScriptParser = class {
25
25
  jsx: filePath.endsWith("x")
26
26
  });
27
27
  } catch (error) {
28
- throw new ParseError(error.message, filePath, {
29
- line: error.lineNumber || 1,
30
- column: error.column || 0
28
+ const err = error;
29
+ throw new ParseError(err.message || "Unknown error", filePath, {
30
+ line: err.lineNumber || 1,
31
+ column: err.column || 0
31
32
  });
32
33
  }
33
34
  }
@@ -166,7 +167,6 @@ var TypeScriptParser = class {
166
167
  decl.id.name,
167
168
  "const",
168
169
  node,
169
- // Pass the outer ExportNamedDeclaration
170
170
  code,
171
171
  filePath,
172
172
  decl.init
@@ -177,7 +177,9 @@ var TypeScriptParser = class {
177
177
  }
178
178
  }
179
179
  } else if (node.type === "ExportDefaultDeclaration") {
180
- exports.push(this.createExport("default", "default", node, code, filePath));
180
+ exports.push(
181
+ this.createExport("default", "default", node, code, filePath)
182
+ );
181
183
  }
182
184
  }
183
185
  return exports;
@@ -194,16 +196,19 @@ var TypeScriptParser = class {
194
196
  isPrimitive = true;
195
197
  }
196
198
  }
197
- const structNode = node.type === "ExportNamedDeclaration" ? node.declaration : node.type === "ExportDefaultDeclaration" ? node.declaration : node;
199
+ let structNode = node.type === "ExportNamedDeclaration" && node.declaration ? node.declaration : node.type === "ExportDefaultDeclaration" ? node.declaration : node;
200
+ if (!structNode) structNode = node;
198
201
  if (filePath.endsWith(".ts") || filePath.endsWith(".tsx")) {
199
202
  if (structNode.type === "TSTypeAliasDeclaration" || structNode.type === "TSInterfaceDeclaration" || structNode.type === "TSEnumDeclaration") {
200
203
  isTyped = true;
201
204
  } else if (structNode.type === "FunctionDeclaration" || structNode.type === "TSDeclareFunction") {
202
- const hasReturnType = !!structNode.returnType;
203
- const allParamsTyped = structNode.params.length === 0 || structNode.params.every((p) => !!p.typeAnnotation);
205
+ const func = structNode;
206
+ const hasReturnType = !!func.returnType;
207
+ const allParamsTyped = func.params.length === 0 || func.params.every((p) => !!p.typeAnnotation);
204
208
  isTyped = hasReturnType && allParamsTyped;
205
209
  } else if (structNode.type === "VariableDeclaration") {
206
- isTyped = structNode.declarations.every(
210
+ const variable = structNode;
211
+ isTyped = variable.declarations.every(
207
212
  (d) => !!d.id.typeAnnotation || !!d.init
208
213
  );
209
214
  } else if (structNode.type === "ClassDeclaration") {
@@ -231,7 +236,7 @@ var TypeScriptParser = class {
231
236
  return p.parameter.name;
232
237
  }
233
238
  return void 0;
234
- }).filter(Boolean);
239
+ }).filter((p) => !!p);
235
240
  }
236
241
  }
237
242
  }
@@ -241,7 +246,7 @@ var TypeScriptParser = class {
241
246
  parameters = funcNode.params.map((p) => {
242
247
  if (p.type === "Identifier") return p.name;
243
248
  return void 0;
244
- }).filter(Boolean);
249
+ }).filter((p) => !!p);
245
250
  }
246
251
  }
247
252
  return {
@@ -276,11 +281,11 @@ var TypeScriptParser = class {
276
281
  return void 0;
277
282
  }
278
283
  isLikelyPure(node) {
279
- const structNode = node.type === "ExportNamedDeclaration" ? node.declaration : node.type === "ExportDefaultDeclaration" ? node.declaration : node;
280
- if (structNode.type === "VariableDeclaration" && structNode.kind === "const")
281
- return true;
282
- if (structNode.type === "FunctionDeclaration" || structNode.type === "TSDeclareFunction" || structNode.type === "MethodDefinition" && structNode.value) {
283
- const body = structNode.type === "MethodDefinition" ? structNode.value.body : structNode.body;
284
+ const sn = node.type === "ExportNamedDeclaration" && node.declaration ? node.declaration : node.type === "ExportDefaultDeclaration" ? node.declaration : node;
285
+ 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;
284
289
  if (body && body.type === "BlockStatement") {
285
290
  const bodyContent = JSON.stringify(body);
286
291
  if (bodyContent.includes('"name":"console"') || bodyContent.includes('"name":"process"') || bodyContent.includes('"type":"AssignmentExpression"')) {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  analyzeGeneralMetadata,
3
3
  extractParameterNames
4
- } from "./chunk-L6BKANJC.mjs";
4
+ } from "./chunk-3D3I5K5W.mjs";
5
5
  import {
6
6
  BaseLanguageParser
7
7
  } from "./chunk-2N7ISIKE.mjs";
@@ -1,4 +1,8 @@
1
1
  // src/parsers/shared-parser-utils.ts
2
+ function getNodeProperty(node, prop) {
3
+ if (!node) return null;
4
+ return node[prop] ?? null;
5
+ }
2
6
  var SIDE_EFFECT_KEYWORDS = [
3
7
  "print(",
4
8
  "console.",
@@ -19,9 +23,9 @@ function analyzeGeneralMetadata(node, code, options = {}) {
19
23
  hasSideEffects: false
20
24
  };
21
25
  try {
22
- let prev = node.previousNamedSibling || node.previousSibling || null;
26
+ let prev = getNodeProperty(node, "previousNamedSibling") || getNodeProperty(node, "previousSibling") || null;
23
27
  while (prev && (!prev.type || !prev.text.trim())) {
24
- prev = prev.previousSibling || null;
28
+ prev = getNodeProperty(prev, "previousSibling");
25
29
  }
26
30
  if (!prev && node.parent) {
27
31
  const children = node.parent.children;
@@ -34,9 +38,9 @@ function analyzeGeneralMetadata(node, code, options = {}) {
34
38
  }
35
39
  }
36
40
  while (prev && /attribute|decorator/i.test(prev.type)) {
37
- prev = prev.previousNamedSibling || prev.previousSibling || null;
41
+ prev = getNodeProperty(prev, "previousNamedSibling") || getNodeProperty(prev, "previousSibling") || null;
38
42
  while (prev && (!prev.type || !prev.text.trim())) {
39
- prev = prev.previousSibling || null;
43
+ prev = getNodeProperty(prev, "previousSibling");
40
44
  }
41
45
  }
42
46
  while (prev && (/comment|xml|doc|slash/i.test(prev.type) || prev.text.trim().startsWith("//") || prev.text.trim().startsWith("///"))) {
@@ -62,7 +66,7 @@ function analyzeGeneralMetadata(node, code, options = {}) {
62
66
  };
63
67
  break;
64
68
  }
65
- prev = prev.previousSibling || null;
69
+ prev = getNodeProperty(prev, "previousSibling");
66
70
  }
67
71
  } catch {
68
72
  }
@@ -99,8 +103,8 @@ function extractParameterNames(node) {
99
103
  const params = [];
100
104
  const candidates = [
101
105
  // common field name
102
- node.childForFieldName ? node.childForFieldName("parameters") : null,
103
- node.childForFieldName ? node.childForFieldName("parameter_list") : null,
106
+ getNodeProperty(node, "childForFieldName") ? getNodeProperty(node, "childForFieldName")?.childForFieldName?.("parameters") ?? null : null,
107
+ getNodeProperty(node, "childForFieldName") ? getNodeProperty(node, "childForFieldName")?.childForFieldName?.("parameter_list") ?? null : null,
104
108
  node.children.find((c) => c.type === "parameter_list") || null,
105
109
  node.children.find((c) => c.type === "parameters") || null,
106
110
  node.children.find((c) => c.type === "formal_parameters") || null,
@@ -110,7 +114,7 @@ function extractParameterNames(node) {
110
114
  if (!list) return params;
111
115
  for (const child of list.children) {
112
116
  if (!child) continue;
113
- const id = child.childForFieldName?.("name") || child.children.find(
117
+ const id = getNodeProperty(child, "childForFieldName")?.childForFieldName?.("name") || child.children.find(
114
118
  (c) => [
115
119
  "identifier",
116
120
  "variable_name",
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  analyzeGeneralMetadata,
3
3
  extractParameterNames
4
- } from "./chunk-L6BKANJC.mjs";
4
+ } from "./chunk-3D3I5K5W.mjs";
5
5
  import {
6
6
  BaseLanguageParser
7
7
  } from "./chunk-2N7ISIKE.mjs";
@@ -161,11 +161,17 @@ var CSharpParser = class extends BaseLanguageParser {
161
161
  const isPublic = modifiers.includes("public") || modifiers.includes("protected");
162
162
  if (isPublic) {
163
163
  const metadata = this.analyzeMetadata(node, code);
164
- const type = node.type.replace("_declaration", "");
164
+ const nodeType = node.type.replace("_declaration", "");
165
+ let exportType = "class";
166
+ if (nodeType === "record" || nodeType === "struct" || nodeType === "enum") {
167
+ exportType = "class";
168
+ } else if (nodeType === "interface" || nodeType === "interface_declaration") {
169
+ exportType = "interface";
170
+ }
165
171
  const fullName = nextClass ? `${nextClass}.${nameNode.text}` : nextNamespace ? `${nextNamespace}.${nameNode.text}` : nameNode.text;
166
- exports.push({
172
+ const exportItem = {
167
173
  name: fullName,
168
- type: type === "record" ? "class" : type,
174
+ type: exportType,
169
175
  loc: {
170
176
  start: {
171
177
  line: node.startPosition.row + 1,
@@ -178,7 +184,8 @@ var CSharpParser = class extends BaseLanguageParser {
178
184
  },
179
185
  visibility: modifiers.includes("public") ? "public" : "protected",
180
186
  ...metadata
181
- });
187
+ };
188
+ exports.push(exportItem);
182
189
  nextClass = fullName;
183
190
  }
184
191
  }
@@ -189,9 +196,9 @@ var CSharpParser = class extends BaseLanguageParser {
189
196
  const isPublic = modifiers.includes("public") || modifiers.includes("protected");
190
197
  if (isPublic) {
191
198
  const metadata = this.analyzeMetadata(node, code);
192
- exports.push({
199
+ const methodItem = {
193
200
  name: nameNode.text,
194
- type: node.type === "method_declaration" ? "function" : "property",
201
+ type: node.type === "method_declaration" ? "function" : "variable",
195
202
  parentClass: currentClass,
196
203
  loc: {
197
204
  start: {
@@ -206,7 +213,8 @@ var CSharpParser = class extends BaseLanguageParser {
206
213
  visibility: modifiers.includes("public") ? "public" : "protected",
207
214
  parameters: node.type === "method_declaration" ? this.extractParameters(node) : void 0,
208
215
  ...metadata
209
- });
216
+ };
217
+ exports.push(methodItem);
210
218
  }
211
219
  }
212
220
  }
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  analyzeGeneralMetadata,
3
3
  extractParameterNames
4
- } from "./chunk-WYOW6O3P.mjs";
4
+ } from "./chunk-3D3I5K5W.mjs";
5
5
  import {
6
6
  BaseLanguageParser
7
7
  } from "./chunk-2N7ISIKE.mjs";
@@ -561,6 +561,31 @@ var RecommendationPriority = /* @__PURE__ */ ((RecommendationPriority2) => {
561
561
  })(RecommendationPriority || {});
562
562
 
563
563
  // src/scoring.ts
564
+ var SCORING_CONSTANTS = {
565
+ WEIGHTS: {
566
+ DEFAULT: 5,
567
+ MAX: 100
568
+ },
569
+ THRESHOLDS: {
570
+ XS: 80,
571
+ SMALL: 75,
572
+ MEDIUM: 70,
573
+ LARGE: 65,
574
+ ENTERPRISE: 58,
575
+ NORMALIZATION_OFFSET: 70
576
+ },
577
+ FILE_COUNTS: {
578
+ XS: 50,
579
+ SMALL: 200,
580
+ MEDIUM: 500,
581
+ LARGE: 2e3
582
+ },
583
+ DELIMITERS: {
584
+ LIST: ",",
585
+ PAIR: ":",
586
+ FORMULA_JOIN: " + "
587
+ }
588
+ };
564
589
  var DEFAULT_TOOL_WEIGHTS = {
565
590
  ["pattern-detect" /* PatternDetect */]: 22,
566
591
  ["context-analyzer" /* ContextAnalyzer */]: 19,
@@ -648,22 +673,22 @@ var CONTEXT_TIER_THRESHOLDS = {
648
673
  frontier: { idealTokens: 5e4, criticalTokens: 15e4, idealDepth: 10 }
649
674
  };
650
675
  var SIZE_ADJUSTED_THRESHOLDS = {
651
- xs: 80,
676
+ xs: SCORING_CONSTANTS.THRESHOLDS.XS,
652
677
  // < 50 files
653
- small: 75,
678
+ small: SCORING_CONSTANTS.THRESHOLDS.SMALL,
654
679
  // 50-200 files
655
- medium: 70,
680
+ medium: SCORING_CONSTANTS.THRESHOLDS.MEDIUM,
656
681
  // 200-500 files
657
- large: 65,
682
+ large: SCORING_CONSTANTS.THRESHOLDS.LARGE,
658
683
  // 500-2000 files
659
- enterprise: 58
684
+ enterprise: SCORING_CONSTANTS.THRESHOLDS.ENTERPRISE
660
685
  // 2000+ files
661
686
  };
662
687
  function getProjectSizeTier(fileCount) {
663
- if (fileCount < 50) return "xs";
664
- if (fileCount < 200) return "small";
665
- if (fileCount < 500) return "medium";
666
- if (fileCount < 2e3) return "large";
688
+ if (fileCount < SCORING_CONSTANTS.FILE_COUNTS.XS) return "xs";
689
+ if (fileCount < SCORING_CONSTANTS.FILE_COUNTS.SMALL) return "small";
690
+ if (fileCount < SCORING_CONSTANTS.FILE_COUNTS.MEDIUM) return "medium";
691
+ if (fileCount < SCORING_CONSTANTS.FILE_COUNTS.LARGE) return "large";
667
692
  return "enterprise";
668
693
  }
669
694
  function getRecommendedThreshold(fileCount, modelTier = "standard") {
@@ -679,14 +704,16 @@ function getToolWeight(toolName, toolConfig, cliOverride, profile = "default" /*
679
704
  if (cliOverride !== void 0) return cliOverride;
680
705
  if (toolConfig?.scoreWeight !== void 0) return toolConfig.scoreWeight;
681
706
  const profileWeights = SCORING_PROFILES[profile] ?? DEFAULT_TOOL_WEIGHTS;
682
- return profileWeights[toolName] ?? DEFAULT_TOOL_WEIGHTS[toolName] ?? 5;
707
+ return profileWeights[toolName] ?? DEFAULT_TOOL_WEIGHTS[toolName] ?? SCORING_CONSTANTS.WEIGHTS.DEFAULT;
683
708
  }
684
709
  function parseWeightString(weightStr) {
685
710
  const weights = /* @__PURE__ */ new Map();
686
711
  if (!weightStr) return weights;
687
- const pairs = weightStr.split(",");
712
+ const pairs = weightStr.split(SCORING_CONSTANTS.DELIMITERS.LIST);
688
713
  for (const pair of pairs) {
689
- const [toolShortName, weightValueStr] = pair.split(":");
714
+ const [toolShortName, weightValueStr] = pair.split(
715
+ SCORING_CONSTANTS.DELIMITERS.PAIR
716
+ );
690
717
  if (toolShortName && weightValueStr) {
691
718
  const toolName = normalizeToolName(toolShortName.trim());
692
719
  const weight = parseInt(weightValueStr.trim(), 10);
@@ -701,7 +728,7 @@ function calculateOverallScore(toolOutputs, config, cliWeights) {
701
728
  if (toolOutputs.size === 0) {
702
729
  throw new Error("No tool outputs provided for scoring");
703
730
  }
704
- const profile = config?.scoring?.profile || "default" /* Default */;
731
+ const profile = config?.profile || "default" /* Default */;
705
732
  const weights = /* @__PURE__ */ new Map();
706
733
  for (const [toolName] of toolOutputs.entries()) {
707
734
  const cliWeight = cliWeights?.get(toolName);
@@ -715,7 +742,7 @@ function calculateOverallScore(toolOutputs, config, cliWeights) {
715
742
  const toolsUsed = [];
716
743
  const calculationWeights = {};
717
744
  for (const [toolName, output] of toolOutputs.entries()) {
718
- const weight = weights.get(toolName) ?? 5;
745
+ const weight = weights.get(toolName) ?? SCORING_CONSTANTS.WEIGHTS.DEFAULT;
719
746
  weightedSum += output.score * weight;
720
747
  totalWeight += weight;
721
748
  toolsUsed.push(toolName);
@@ -726,11 +753,11 @@ function calculateOverallScore(toolOutputs, config, cliWeights) {
726
753
  const rating = getRating(overall);
727
754
  const formulaParts = Array.from(toolOutputs.entries()).map(
728
755
  ([name, output]) => {
729
- const weight = weights.get(name) ?? 5;
756
+ const weight = weights.get(name) ?? SCORING_CONSTANTS.WEIGHTS.DEFAULT;
730
757
  return `(${output.score} \xD7 ${weight})`;
731
758
  }
732
759
  );
733
- const formulaStr = `[${formulaParts.join(" + ")}] / ${totalWeight} = ${overall}`;
760
+ const formulaStr = `[${formulaParts.join(SCORING_CONSTANTS.DELIMITERS.FORMULA_JOIN)}] / ${totalWeight} = ${overall}`;
734
761
  return {
735
762
  overall,
736
763
  rating,
@@ -746,7 +773,7 @@ function calculateOverallScore(toolOutputs, config, cliWeights) {
746
773
  }
747
774
  function getRatingWithContext(score, fileCount, modelTier = "standard") {
748
775
  const threshold = getRecommendedThreshold(fileCount, modelTier);
749
- const normalized = score - threshold + 70;
776
+ const normalized = score - threshold + SCORING_CONSTANTS.THRESHOLDS.NORMALIZATION_OFFSET;
750
777
  return getRating(normalized);
751
778
  }
752
779
  function getRatingDisplay(rating) {
@@ -25,9 +25,10 @@ var TypeScriptParser = class {
25
25
  jsx: filePath.endsWith("x")
26
26
  });
27
27
  } catch (error) {
28
- throw new ParseError(error.message, filePath, {
29
- line: error.lineNumber || 1,
30
- column: error.column || 0
28
+ const err = error;
29
+ throw new ParseError(err.message || "Unknown error", filePath, {
30
+ line: err.lineNumber || 1,
31
+ column: err.column || 0
31
32
  });
32
33
  }
33
34
  }
@@ -166,7 +167,6 @@ var TypeScriptParser = class {
166
167
  decl.id.name,
167
168
  "const",
168
169
  node,
169
- // Pass the outer ExportNamedDeclaration
170
170
  code,
171
171
  filePath,
172
172
  decl.init
@@ -196,16 +196,19 @@ var TypeScriptParser = class {
196
196
  isPrimitive = true;
197
197
  }
198
198
  }
199
- const structNode = node.type === "ExportNamedDeclaration" ? node.declaration : node.type === "ExportDefaultDeclaration" ? node.declaration : node;
199
+ let structNode = node.type === "ExportNamedDeclaration" && node.declaration ? node.declaration : node.type === "ExportDefaultDeclaration" ? node.declaration : node;
200
+ if (!structNode) structNode = node;
200
201
  if (filePath.endsWith(".ts") || filePath.endsWith(".tsx")) {
201
202
  if (structNode.type === "TSTypeAliasDeclaration" || structNode.type === "TSInterfaceDeclaration" || structNode.type === "TSEnumDeclaration") {
202
203
  isTyped = true;
203
204
  } else if (structNode.type === "FunctionDeclaration" || structNode.type === "TSDeclareFunction") {
204
- const hasReturnType = !!structNode.returnType;
205
- const allParamsTyped = structNode.params.length === 0 || structNode.params.every((p) => !!p.typeAnnotation);
205
+ const func = structNode;
206
+ const hasReturnType = !!func.returnType;
207
+ const allParamsTyped = func.params.length === 0 || func.params.every((p) => !!p.typeAnnotation);
206
208
  isTyped = hasReturnType && allParamsTyped;
207
209
  } else if (structNode.type === "VariableDeclaration") {
208
- isTyped = structNode.declarations.every(
210
+ const variable = structNode;
211
+ isTyped = variable.declarations.every(
209
212
  (d) => !!d.id.typeAnnotation || !!d.init
210
213
  );
211
214
  } else if (structNode.type === "ClassDeclaration") {
@@ -233,7 +236,7 @@ var TypeScriptParser = class {
233
236
  return p.parameter.name;
234
237
  }
235
238
  return void 0;
236
- }).filter(Boolean);
239
+ }).filter((p) => !!p);
237
240
  }
238
241
  }
239
242
  }
@@ -243,7 +246,7 @@ var TypeScriptParser = class {
243
246
  parameters = funcNode.params.map((p) => {
244
247
  if (p.type === "Identifier") return p.name;
245
248
  return void 0;
246
- }).filter(Boolean);
249
+ }).filter((p) => !!p);
247
250
  }
248
251
  }
249
252
  return {
@@ -278,11 +281,12 @@ var TypeScriptParser = class {
278
281
  return void 0;
279
282
  }
280
283
  isLikelyPure(node) {
281
- const structNode = node.type === "ExportNamedDeclaration" ? node.declaration : node.type === "ExportDefaultDeclaration" ? node.declaration : node;
282
- if (structNode.type === "VariableDeclaration" && structNode.kind === "const")
284
+ const sn = node.type === "ExportNamedDeclaration" && node.declaration ? node.declaration : node.type === "ExportDefaultDeclaration" ? node.declaration : node;
285
+ if (!sn) return false;
286
+ if (sn.type === "VariableDeclaration" && sn.kind === "const")
283
287
  return true;
284
- if (structNode.type === "FunctionDeclaration" || structNode.type === "TSDeclareFunction" || structNode.type === "MethodDefinition" && structNode.value) {
285
- const body = structNode.type === "MethodDefinition" ? structNode.value.body : structNode.body;
288
+ if (sn.type === "FunctionDeclaration" || sn.type === "MethodDefinition") {
289
+ const body = sn.type === "MethodDefinition" ? sn.value.body : sn.body;
286
290
  if (body && body.type === "BlockStatement") {
287
291
  const bodyContent = JSON.stringify(body);
288
292
  if (bodyContent.includes('"name":"console"') || bodyContent.includes('"name":"process"') || bodyContent.includes('"type":"AssignmentExpression"')) {
@@ -9,7 +9,7 @@ function analyzeNodeMetadata(node, code, options) {
9
9
  hasSideEffects: false
10
10
  };
11
11
  try {
12
- let prev = node.previousSibling || null;
12
+ let prev = node.previousSibling;
13
13
  while (prev && /comment/i.test(prev.type)) {
14
14
  const text = prev.text || "";
15
15
  const loc = {
@@ -49,7 +49,7 @@ function analyzeNodeMetadata(node, code, options) {
49
49
  prev = prev.previousSibling;
50
50
  }
51
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");
52
+ const body2 = node.childForFieldName("body") || node.children.find((c) => c.type === "block");
53
53
  if (body2 && body2.children.length > 0) {
54
54
  const firstStmt = body2.children[0];
55
55
  if (firstStmt.type === "expression_statement" && firstStmt.firstChild?.type === "string") {
@@ -113,7 +113,7 @@ function analyzeNodeMetadata(node, code, options) {
113
113
  } catch {
114
114
  }
115
115
  };
116
- const body = node.childForFieldName?.("body") || node.children.find(
116
+ const body = node.childForFieldName("body") || node.children.find(
117
117
  (c) => /body|block|class_body|declaration_list|function_body/.test(c.type)
118
118
  );
119
119
  if (body) walk(body);
@@ -179,6 +179,9 @@ var PythonParser = class extends BaseLanguageParser {
179
179
  this.language = "python" /* Python */;
180
180
  this.extensions = [".py"];
181
181
  }
182
+ /**
183
+ * Returns the canonical name of this parser.
184
+ */
182
185
  getParserName() {
183
186
  return "python";
184
187
  }
@@ -379,10 +382,7 @@ var PythonParser = class extends BaseLanguageParser {
379
382
  (c) => c.type === PYTHON_CONSTANTS.NODES.IDENTIFIER || c.type === PYTHON_CONSTANTS.NODES.TYPED_PARAMETER || c.type === PYTHON_CONSTANTS.NODES.DEFAULT_PARAMETER
380
383
  ).map((c) => {
381
384
  if (c.type === PYTHON_CONSTANTS.NODES.IDENTIFIER) return c.text;
382
- if (c.type === PYTHON_CONSTANTS.NODES.TYPED_PARAMETER || c.type === PYTHON_CONSTANTS.NODES.DEFAULT_PARAMETER) {
383
- return c.firstChild?.text || "unknown";
384
- }
385
- return "unknown";
385
+ return c.firstChild?.text || "unknown";
386
386
  });
387
387
  }
388
388
  /**
@@ -401,10 +401,13 @@ var PythonParser = class extends BaseLanguageParser {
401
401
  ]
402
402
  };
403
403
  } catch (error) {
404
+ const message = error instanceof Error ? error.message : String(error);
404
405
  const wrapper = new Error(
405
- `Failed to parse Python file ${filePath}: ${error.message}`
406
+ `Failed to parse Python file ${filePath}: ${message}`
406
407
  );
407
- wrapper.cause = error;
408
+ if (error instanceof Error) {
409
+ wrapper.cause = error;
410
+ }
408
411
  throw wrapper;
409
412
  }
410
413
  }
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  analyzeGeneralMetadata,
3
3
  extractParameterNames
4
- } from "./chunk-WYOW6O3P.mjs";
4
+ } from "./chunk-DHFOYNMW.mjs";
5
5
  import {
6
6
  BaseLanguageParser
7
7
  } from "./chunk-2N7ISIKE.mjs";
@@ -161,11 +161,17 @@ var CSharpParser = class extends BaseLanguageParser {
161
161
  const isPublic = modifiers.includes("public") || modifiers.includes("protected");
162
162
  if (isPublic) {
163
163
  const metadata = this.analyzeMetadata(node, code);
164
- const type = node.type.replace("_declaration", "");
164
+ const nodeType = node.type.replace("_declaration", "");
165
+ let exportType = "class";
166
+ if (nodeType === "record" || nodeType === "struct" || nodeType === "enum") {
167
+ exportType = "class";
168
+ } else if (nodeType === "interface" || nodeType === "interface_declaration") {
169
+ exportType = "interface";
170
+ }
165
171
  const fullName = nextClass ? `${nextClass}.${nameNode.text}` : nextNamespace ? `${nextNamespace}.${nameNode.text}` : nameNode.text;
166
- exports.push({
172
+ const exportItem = {
167
173
  name: fullName,
168
- type: type === "record" ? "class" : type,
174
+ type: exportType,
169
175
  loc: {
170
176
  start: {
171
177
  line: node.startPosition.row + 1,
@@ -178,7 +184,8 @@ var CSharpParser = class extends BaseLanguageParser {
178
184
  },
179
185
  visibility: modifiers.includes("public") ? "public" : "protected",
180
186
  ...metadata
181
- });
187
+ };
188
+ exports.push(exportItem);
182
189
  nextClass = fullName;
183
190
  }
184
191
  }
@@ -189,9 +196,9 @@ var CSharpParser = class extends BaseLanguageParser {
189
196
  const isPublic = modifiers.includes("public") || modifiers.includes("protected");
190
197
  if (isPublic) {
191
198
  const metadata = this.analyzeMetadata(node, code);
192
- exports.push({
199
+ const methodItem = {
193
200
  name: nameNode.text,
194
- type: node.type === "method_declaration" ? "function" : "property",
201
+ type: node.type === "method_declaration" ? "function" : "variable",
195
202
  parentClass: currentClass,
196
203
  loc: {
197
204
  start: {
@@ -206,7 +213,8 @@ var CSharpParser = class extends BaseLanguageParser {
206
213
  visibility: modifiers.includes("public") ? "public" : "protected",
207
214
  parameters: node.type === "method_declaration" ? this.extractParameters(node) : void 0,
208
215
  ...metadata
209
- });
216
+ };
217
+ exports.push(methodItem);
210
218
  }
211
219
  }
212
220
  }