ultracode 5.4.0 → 5.6.0

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 (151) hide show
  1. package/dist/chunks/analysis-tool-handlers-GH5FDEWW.js +817 -0
  2. package/dist/chunks/analysis-tool-handlers-IXP4MWZX.js +817 -0
  3. package/dist/chunks/analysis-tool-handlers-LC2BTQYK.js +13 -0
  4. package/dist/chunks/analysis-tool-handlers-QYFKQPFL.js +817 -0
  5. package/dist/chunks/autodoc-tool-handlers-2HF6ERYN.js +1112 -0
  6. package/dist/chunks/autodoc-tool-handlers-4OGQJ7C3.js +1112 -0
  7. package/dist/chunks/autodoc-tool-handlers-N736CB56.js +138 -0
  8. package/dist/chunks/autodoc-tool-handlers-NQYBY6U4.js +1112 -0
  9. package/dist/chunks/branch-tool-handlers-KW3H4FJK.js +276 -0
  10. package/dist/chunks/branch-tool-handlers-QOUDZKJ2.js +276 -0
  11. package/dist/chunks/branch-tool-handlers-RB2U36KI.js +2 -0
  12. package/dist/chunks/branch-tool-handlers-ZHJM6PDK.js +276 -0
  13. package/dist/chunks/chunk-2Z6OQPYC.js +656 -0
  14. package/dist/chunks/chunk-3MQ7LRPN.js +322 -0
  15. package/dist/chunks/chunk-4W6QYGXZ.js +10 -0
  16. package/dist/chunks/chunk-533NFGUG.js +1 -0
  17. package/dist/chunks/chunk-5NUPOPWM.js +1 -0
  18. package/dist/chunks/chunk-AK4HIPA2.js +322 -0
  19. package/dist/chunks/chunk-B3H5NS3I.js +656 -0
  20. package/dist/chunks/chunk-DPTZHDST.js +4 -0
  21. package/dist/chunks/chunk-E5HQWLU5.js +322 -0
  22. package/dist/chunks/chunk-EOH25B5P.js +572 -0
  23. package/dist/chunks/chunk-ESV6F6E3.js +3179 -0
  24. package/dist/chunks/chunk-FPELPFER.js +924 -0
  25. package/dist/chunks/chunk-G6J42I55.js +161 -0
  26. package/dist/chunks/chunk-GCQE7ZYW.js +1 -0
  27. package/dist/chunks/chunk-GTIF6MOX.js +1 -0
  28. package/dist/chunks/chunk-I6STSSAK.js +2 -0
  29. package/dist/chunks/chunk-J2WBGTK2.js +4697 -0
  30. package/dist/chunks/chunk-KAYOX5EB.js +4697 -0
  31. package/dist/chunks/chunk-KPMTACOT.js +656 -0
  32. package/dist/chunks/chunk-L376GZ44.js +3179 -0
  33. package/dist/chunks/chunk-LCTOTHDA.js +15 -0
  34. package/dist/chunks/chunk-LEDJ7GVQ.js +316 -0
  35. package/dist/chunks/chunk-LH4OUKNZ.js +277 -0
  36. package/dist/chunks/chunk-O6IE2MEZ.js +161 -0
  37. package/dist/chunks/chunk-OEXPCY3F.js +316 -0
  38. package/dist/chunks/chunk-OMXOLFDN.js +924 -0
  39. package/dist/chunks/chunk-PLPBXWOU.js +3179 -0
  40. package/dist/chunks/chunk-PWLE5DN2.js +572 -0
  41. package/dist/chunks/chunk-PY43JPWL.js +447 -0
  42. package/dist/chunks/chunk-Q3B4EB7A.js +15 -0
  43. package/dist/chunks/chunk-Q5LPVLXA.js +337 -0
  44. package/dist/chunks/chunk-QIRZHZK2.js +5 -0
  45. package/dist/chunks/chunk-ROQ27LSL.js +924 -0
  46. package/dist/chunks/chunk-S5Q7BD6J.js +572 -0
  47. package/dist/chunks/chunk-SAMX3HJQ.js +337 -0
  48. package/dist/chunks/chunk-SV3WKUNV.js +1 -0
  49. package/dist/chunks/chunk-TCHCDCDO.js +167 -0
  50. package/dist/chunks/chunk-TR3HS7U6.js +316 -0
  51. package/dist/chunks/chunk-TUWE6FCW.js +167 -0
  52. package/dist/chunks/chunk-TVOTA7EE.js +277 -0
  53. package/dist/chunks/chunk-VS44D772.js +337 -0
  54. package/dist/chunks/chunk-WIE3G5ES.js +167 -0
  55. package/dist/chunks/chunk-XG3ACLWR.js +5 -0
  56. package/dist/chunks/chunk-XJ2Z5QQO.js +1 -0
  57. package/dist/chunks/chunk-XK2NY7RB.js +277 -0
  58. package/dist/chunks/chunk-Y4F7NZFZ.js +4700 -0
  59. package/dist/chunks/chunk-YS75L3ZS.js +161 -0
  60. package/dist/chunks/chunk-ZVG5HHI3.js +15 -0
  61. package/dist/chunks/dev-agent-DDDIVWOF.js +1 -0
  62. package/dist/chunks/dev-agent-E2VCFKXN.js +1624 -0
  63. package/dist/chunks/dev-agent-KJNSU5KQ.js +1624 -0
  64. package/dist/chunks/dev-agent-NDERYIPV.js +1624 -0
  65. package/dist/chunks/faiss-provider-7R4BQDIV.js +12 -0
  66. package/dist/chunks/faiss-provider-7ZFRSDN5.js +12 -0
  67. package/dist/chunks/faiss-provider-SXB7FTLB.js +1 -0
  68. package/dist/chunks/faiss-provider-TKLBEUSH.js +12 -0
  69. package/dist/chunks/file-tool-handlers-5DODQXGF.js +1027 -0
  70. package/dist/chunks/file-tool-handlers-KGHLE4KR.js +1027 -0
  71. package/dist/chunks/file-tool-handlers-KTOQ4NFS.js +12 -0
  72. package/dist/chunks/file-tool-handlers-V4SFUDQB.js +1027 -0
  73. package/dist/chunks/graph-metrics-tool-handlers-3AV4X4ZY.js +65 -0
  74. package/dist/chunks/graph-metrics-tool-handlers-3VMDQHJ6.js +65 -0
  75. package/dist/chunks/graph-metrics-tool-handlers-BZ6E6YHF.js +1 -0
  76. package/dist/chunks/graph-metrics-tool-handlers-IYBGSXL7.js +65 -0
  77. package/dist/chunks/graph-storage-factory-2CQ2RPDV.js +13 -0
  78. package/dist/chunks/graph-storage-factory-C5SMMYL6.js +13 -0
  79. package/dist/chunks/graph-storage-factory-EEO2V3GJ.js +1 -0
  80. package/dist/chunks/graph-storage-factory-WBCTXP34.js +13 -0
  81. package/dist/chunks/history-tool-handlers-AS7OQFZI.js +1 -0
  82. package/dist/chunks/history-tool-handlers-FSNJYXV2.js +208 -0
  83. package/dist/chunks/history-tool-handlers-JZAH4EIQ.js +208 -0
  84. package/dist/chunks/history-tool-handlers-KCSCXZ7T.js +208 -0
  85. package/dist/chunks/incremental-updater-A2EL4QXU.js +14 -0
  86. package/dist/chunks/incremental-updater-EQIKBVY2.js +14 -0
  87. package/dist/chunks/incremental-updater-JFGRPH3B.js +14 -0
  88. package/dist/chunks/incremental-updater-S5BAAGHP.js +1 -0
  89. package/dist/chunks/indexer-agent-ASKY7JPG.js +1 -0
  90. package/dist/chunks/indexer-agent-NKAOF323.js +21 -0
  91. package/dist/chunks/indexer-agent-PJN5IOKQ.js +21 -0
  92. package/dist/chunks/indexer-agent-WRJFWKZX.js +21 -0
  93. package/dist/chunks/indexing-pipeline-D4P2O72Z.js +249 -0
  94. package/dist/chunks/indexing-pipeline-L7C543N4.js +1 -0
  95. package/dist/chunks/indexing-pipeline-NHPRN3AB.js +249 -0
  96. package/dist/chunks/indexing-pipeline-ZAXCZU22.js +249 -0
  97. package/dist/chunks/layered-faiss-provider-62CNW54X.js +1 -0
  98. package/dist/chunks/layered-faiss-provider-O7L77GFX.js +12 -0
  99. package/dist/chunks/layered-faiss-provider-RVHLHLPK.js +12 -0
  100. package/dist/chunks/layered-faiss-provider-YT7EDIJI.js +12 -0
  101. package/dist/chunks/merge-agent-3RF7VFF5.js +2481 -0
  102. package/dist/chunks/merge-agent-JCKTCBCE.js +2481 -0
  103. package/dist/chunks/merge-agent-VCL7OXPN.js +2481 -0
  104. package/dist/chunks/merge-agent-ZGK24WVF.js +11 -0
  105. package/dist/chunks/merge-tool-handlers-GV2LOIKU.js +277 -0
  106. package/dist/chunks/merge-tool-handlers-TYDWU5X2.js +277 -0
  107. package/dist/chunks/merge-tool-handlers-U7X2ZO2M.js +1 -0
  108. package/dist/chunks/merge-tool-handlers-YH62ZLPJ.js +277 -0
  109. package/dist/chunks/pattern-tool-handlers-76NF5JDS.js +13 -0
  110. package/dist/chunks/pattern-tool-handlers-IJAGEIVD.js +1549 -0
  111. package/dist/chunks/pattern-tool-handlers-VA5WYA62.js +1549 -0
  112. package/dist/chunks/pattern-tool-handlers-WQ6UBMJS.js +1549 -0
  113. package/dist/chunks/query-agent-36ADGCFZ.js +1 -0
  114. package/dist/chunks/query-agent-H22CR5N5.js +191 -0
  115. package/dist/chunks/query-agent-K2UGZS4M.js +191 -0
  116. package/dist/chunks/query-agent-YJCEHOXD.js +191 -0
  117. package/dist/chunks/semantic-agent-AC7CBEDE.js +6381 -0
  118. package/dist/chunks/semantic-agent-HK5X6CKU.js +6381 -0
  119. package/dist/chunks/semantic-agent-KONIKEGW.js +6381 -0
  120. package/dist/chunks/semantic-agent-LH6IZ2L7.js +137 -0
  121. package/dist/chunks/semantic-tool-handlers-5LMSH2U7.js +3 -0
  122. package/dist/chunks/semantic-tool-handlers-735UMO7Y.js +817 -0
  123. package/dist/chunks/semantic-tool-handlers-BNUYPP7X.js +817 -0
  124. package/dist/chunks/semantic-tool-handlers-MYZPEUD2.js +817 -0
  125. package/dist/chunks/snapshot-tool-handlers-6SIHZT2F.js +201 -0
  126. package/dist/chunks/snapshot-tool-handlers-DS4P3KOT.js +201 -0
  127. package/dist/chunks/snapshot-tool-handlers-JYHRFPC7.js +201 -0
  128. package/dist/chunks/snapshot-tool-handlers-YEHMAT3L.js +1 -0
  129. package/dist/chunks/storage-paths-A3C7WHHG.js +8 -0
  130. package/dist/chunks/storage-paths-HDYH7WPM.js +1 -0
  131. package/dist/chunks/storage-paths-IMFRHBWF.js +8 -0
  132. package/dist/chunks/storage-paths-P3PUSMUD.js +8 -0
  133. package/dist/chunks/taint-tool-handlers-CWESOOMQ.js +68 -0
  134. package/dist/chunks/taint-tool-handlers-OG3NVVP3.js +1 -0
  135. package/dist/chunks/taint-tool-handlers-ON3G3FA7.js +68 -0
  136. package/dist/chunks/taint-tool-handlers-P4P5J6DB.js +68 -0
  137. package/dist/chunks/tracing-tool-handlers-4BDCXTZZ.js +3935 -0
  138. package/dist/chunks/tracing-tool-handlers-6FPNM7HX.js +3935 -0
  139. package/dist/chunks/tracing-tool-handlers-LQTQ5SKK.js +89 -0
  140. package/dist/chunks/tracing-tool-handlers-XRQX2DTS.js +3935 -0
  141. package/dist/chunks/validation-tool-handlers-DZUG7KYY.js +2 -0
  142. package/dist/chunks/validation-tool-handlers-O6TGFSH5.js +555 -0
  143. package/dist/chunks/validation-tool-handlers-RREUYKIR.js +555 -0
  144. package/dist/chunks/validation-tool-handlers-XPWSMS37.js +555 -0
  145. package/dist/index.js +13 -13
  146. package/dist/roslyn-addon/.build-hash +1 -1
  147. package/dist/roslyn-addon/ILGPU.Algorithms.dll +0 -0
  148. package/dist/roslyn-addon/ILGPU.dll +0 -0
  149. package/dist/roslyn-addon/UltraCode.CSharp.deps.json +35 -0
  150. package/dist/roslyn-addon/UltraCode.CSharp.dll +0 -0
  151. package/package.json +1 -1
@@ -0,0 +1,555 @@
1
+ import { OxlintLinter } from './chunk-JWCPPJ4E.js';
2
+ import { exec } from './chunk-R7CSWEXZ.js';
3
+ import { ValidateFileSchema, ValidateDirectorySchema } from './chunk-XGXCOGVI.js';
4
+ import { BaseToolHandler } from './chunk-SAMX3HJQ.js';
5
+ import './chunk-WIE3G5ES.js';
6
+ import './chunk-XK2NY7RB.js';
7
+ import './chunk-HEMJHRHZ.js';
8
+ import { toError } from './chunk-5WKPA33T.js';
9
+ import './chunk-BMHPPH2B.js';
10
+ import { init_logging, log } from './chunk-VCCBEJQ5.js';
11
+ import './chunk-NAQKA54E.js';
12
+ import { copyFile, readFile, unlink, access } from 'fs/promises';
13
+ import { join } from 'path';
14
+ import { LRUCache } from 'lru-cache';
15
+ import { tmpdir } from 'os';
16
+
17
+ // src/tools/handlers/validation-tool-handlers.ts
18
+ init_logging();
19
+ var CONFIG_FILES = {
20
+ biome: ["biome.json", "biome.jsonc"],
21
+ eslint: [
22
+ ".eslintrc",
23
+ ".eslintrc.js",
24
+ ".eslintrc.json",
25
+ ".eslintrc.yml",
26
+ ".eslintrc.yaml",
27
+ "eslint.config.js",
28
+ "eslint.config.mjs",
29
+ "eslint.config.cjs"
30
+ ],
31
+ oxlint: ["oxlint.config.ts", "oxlint.config.js"]
32
+ };
33
+ var configCache = new LRUCache({
34
+ max: 100,
35
+ ttl: 1e3 * 60 * 5
36
+ // 5 minutes
37
+ });
38
+ async function fileExists(path) {
39
+ try {
40
+ await access(path);
41
+ return true;
42
+ } catch {
43
+ return false;
44
+ }
45
+ }
46
+ async function detectLinterConfigsUncached(projectPath) {
47
+ const hasBiomeConfig = (await Promise.all(CONFIG_FILES.biome.map((f) => fileExists(join(projectPath, f))))).some(
48
+ (exists) => exists
49
+ );
50
+ const hasESLintConfig = (await Promise.all(CONFIG_FILES.eslint.map((f) => fileExists(join(projectPath, f))))).some(
51
+ (exists) => exists
52
+ );
53
+ const hasOxlintConfig = (await Promise.all(CONFIG_FILES.oxlint.map((f) => fileExists(join(projectPath, f))))).some(
54
+ (exists) => exists
55
+ );
56
+ let preferredFixerForTS = "oxlint";
57
+ if (hasBiomeConfig) {
58
+ preferredFixerForTS = "biome";
59
+ } else if (hasESLintConfig) {
60
+ preferredFixerForTS = "eslint";
61
+ } else if (hasOxlintConfig) {
62
+ preferredFixerForTS = "oxlint";
63
+ }
64
+ return {
65
+ hasBiomeConfig,
66
+ hasESLintConfig,
67
+ hasOxlintConfig,
68
+ preferredFixerForTS
69
+ };
70
+ }
71
+ async function detectLinterConfigs(projectPath) {
72
+ const cached = configCache.get(projectPath);
73
+ if (cached) {
74
+ return cached;
75
+ }
76
+ const result = await detectLinterConfigsUncached(projectPath);
77
+ configCache.set(projectPath, result);
78
+ return result;
79
+ }
80
+
81
+ // src/validation/linters/biome-linter.ts
82
+ init_logging();
83
+ var BiomeLinter = class {
84
+ name = "biome";
85
+ binPath = null;
86
+ /**
87
+ * Lint file with Biome
88
+ * @param filePath - Path to file to lint
89
+ * @param _content - File content (not used, Biome reads from disk)
90
+ * @param autofix - Apply automatic fixes (biome check --write)
91
+ * @param dryRun - Show what would be fixed without applying changes
92
+ */
93
+ async lint(filePath, _content, autofix = false, dryRun = false) {
94
+ try {
95
+ const bin = await this.getBinPath();
96
+ if (autofix && dryRun) {
97
+ const tempFile = join(tmpdir(), `biome-dryrun-${Date.now()}.tmp`);
98
+ try {
99
+ await copyFile(filePath, tempFile);
100
+ const command2 = `"${bin}" check --write --reporter=json "${tempFile}"`;
101
+ await exec(command2, { timeout: 3e4 });
102
+ const original = await readFile(filePath, "utf-8");
103
+ const fixed = await readFile(tempFile, "utf-8");
104
+ const problems = await this.lint(filePath, _content, false);
105
+ if (original !== fixed) {
106
+ problems.push({
107
+ severity: "info",
108
+ message: `[DRY-RUN] Would apply autofixes (${fixed.length - original.length} chars diff)`,
109
+ line: 0,
110
+ column: 0,
111
+ source: "biome"
112
+ });
113
+ }
114
+ return problems;
115
+ } finally {
116
+ await unlink(tempFile).catch(() => {
117
+ });
118
+ }
119
+ }
120
+ const writeFlag = autofix ? "--write" : "";
121
+ const command = `"${bin}" check ${writeFlag} --reporter=json "${filePath}"`;
122
+ const { stdout, stderr } = await exec(command, { timeout: 3e4 });
123
+ return this.parseOutput(stdout || stderr);
124
+ } catch (error) {
125
+ const err = error;
126
+ const output = err.stdout || err.stderr || "";
127
+ if (output) {
128
+ return this.parseOutput(output);
129
+ }
130
+ log.w("BIOME", "lint_fail", { err: String(error) });
131
+ return [];
132
+ }
133
+ }
134
+ parseOutput(output) {
135
+ try {
136
+ const parsed = JSON.parse(output);
137
+ if (!parsed.diagnostics) return [];
138
+ return parsed.diagnostics.map((d) => ({
139
+ severity: d.severity === "error" ? "error" : "warning",
140
+ message: d.message.content,
141
+ line: d.location?.span?.start?.line ?? 0,
142
+ column: d.location?.span?.start?.column ?? 0,
143
+ ruleId: d.category,
144
+ source: "biome"
145
+ }));
146
+ } catch {
147
+ return [];
148
+ }
149
+ }
150
+ async getBinPath() {
151
+ if (this.binPath) return this.binPath;
152
+ const { createRequire } = await import('module');
153
+ const { dirname, join: join3 } = await import('path');
154
+ const { access: access2 } = await import('fs/promises');
155
+ try {
156
+ const require2 = createRequire(import.meta.url);
157
+ const biomePkg = require2.resolve("@biomejs/biome/package.json");
158
+ const biomeDir = dirname(biomePkg);
159
+ const binPath = join3(biomeDir, "bin", "biome");
160
+ await access2(binPath);
161
+ this.binPath = binPath;
162
+ return binPath;
163
+ } catch (error) {
164
+ log.e("BIOME", "not_found", {
165
+ err: String(error),
166
+ hint: "Biome should be in dependencies"
167
+ });
168
+ throw new Error("Biome binary not found (check installation)");
169
+ }
170
+ }
171
+ };
172
+
173
+ // src/tools/handlers/validation-tool-handlers.ts
174
+ var ValidateFileToolHandler = class extends BaseToolHandler {
175
+ parseArgs(args) {
176
+ return ValidateFileSchema.parse(args);
177
+ }
178
+ async execute(args) {
179
+ const { extname } = await import('path');
180
+ const filePath = this.context.normalizeInputPath(args.filePath) || args.filePath;
181
+ const ext = extname(filePath).toLowerCase();
182
+ const results = [];
183
+ try {
184
+ const validators = args.validators || this.getDefaultValidators(ext);
185
+ for (const validator of validators) {
186
+ const result = await this.runValidator(
187
+ validator,
188
+ filePath,
189
+ args.fixable,
190
+ args.dryRun ?? false,
191
+ args.projectPath
192
+ );
193
+ results.push(result);
194
+ }
195
+ const totalErrors = results.reduce((sum, r) => sum + (r.errors || 0), 0);
196
+ const totalWarnings = results.reduce((sum, r) => sum + (r.warnings || 0), 0);
197
+ return {
198
+ content: [
199
+ {
200
+ type: "text",
201
+ text: JSON.stringify(
202
+ {
203
+ file: filePath,
204
+ validators,
205
+ totalErrors,
206
+ totalWarnings,
207
+ isValid: totalErrors === 0,
208
+ results
209
+ },
210
+ null,
211
+ 2
212
+ )
213
+ }
214
+ ]
215
+ };
216
+ } catch (error) {
217
+ const err = toError(error);
218
+ return {
219
+ content: [{ type: "text", text: JSON.stringify({ error: err.message }) }]
220
+ };
221
+ }
222
+ }
223
+ getDefaultValidators(ext) {
224
+ const map = {
225
+ ".ts": ["oxlint", "tsc"],
226
+ ".tsx": ["oxlint", "tsc"],
227
+ ".js": ["oxlint"],
228
+ ".jsx": ["oxlint"],
229
+ ".py": ["pylint", "mypy"],
230
+ ".rs": ["cargo-check"],
231
+ ".go": ["go-vet"],
232
+ ".java": ["javac"],
233
+ ".cs": ["roslyn"],
234
+ ".csx": ["roslyn"]
235
+ };
236
+ return map[ext] || [];
237
+ }
238
+ async runValidator(validator, filePath, fixable, dryRun, projectPath) {
239
+ const { exec: exec2 } = await import('./shell-7G3FZNWY.js');
240
+ const { dirname, extname } = await import('path');
241
+ const cwd = dirname(filePath);
242
+ const ext = extname(filePath);
243
+ if (fixable && (validator === "oxlint" || ext === ".ts" || ext === ".tsx" || ext === ".js" || ext === ".jsx")) {
244
+ const configInfo = await detectLinterConfigs(projectPath || cwd);
245
+ if (configInfo.preferredFixerForTS === "biome") {
246
+ log.d("VALIDATION", "using_biome", { filePath, config: "biome.json" });
247
+ try {
248
+ const biomeLinter = new BiomeLinter();
249
+ const problems = await biomeLinter.lint(filePath, "", true, dryRun);
250
+ return {
251
+ validator: "biome",
252
+ errors: problems.filter((p) => p.severity === "error").length,
253
+ warnings: problems.filter((p) => p.severity === "warning").length,
254
+ issues: problems.map((p) => ({
255
+ line: p.line,
256
+ column: p.column,
257
+ message: p.message,
258
+ rule: p.ruleId,
259
+ severity: p.severity
260
+ }))
261
+ };
262
+ } catch (error) {
263
+ log.w("VALIDATION", "biome_failed_fallback", {
264
+ filePath,
265
+ err: String(error),
266
+ fallback: "oxlint"
267
+ });
268
+ }
269
+ } else if (configInfo.preferredFixerForTS === "eslint") {
270
+ log.d("VALIDATION", "eslint_config_detected", {
271
+ filePath,
272
+ config: ".eslintrc",
273
+ note: "ESLint not implemented, falling back to oxlint"
274
+ });
275
+ }
276
+ }
277
+ try {
278
+ let command;
279
+ switch (validator) {
280
+ case "oxlint": {
281
+ if (fixable || dryRun) {
282
+ const oxlintLinter = new OxlintLinter();
283
+ const problems = await oxlintLinter.lint(filePath, "", fixable, dryRun);
284
+ return {
285
+ validator: "oxlint",
286
+ errors: problems.filter((p) => p.severity === "error").length,
287
+ warnings: problems.filter((p) => p.severity === "warning").length,
288
+ issues: problems.map((p) => ({
289
+ line: p.line,
290
+ column: p.column,
291
+ message: p.message,
292
+ rule: p.ruleId,
293
+ severity: p.severity
294
+ }))
295
+ };
296
+ }
297
+ const oxlintBin = await this.findOxlintBin();
298
+ command = `"${oxlintBin}" --format json "${filePath}"`;
299
+ break;
300
+ }
301
+ case "tsc":
302
+ command = `npx tsc --noEmit "${filePath}" 2>&1`;
303
+ break;
304
+ case "pylint":
305
+ command = `pylint --output-format=json "${filePath}"`;
306
+ break;
307
+ case "mypy":
308
+ command = `mypy --no-error-summary "${filePath}"`;
309
+ break;
310
+ case "cargo-check":
311
+ command = `cargo check --message-format=json 2>&1`;
312
+ break;
313
+ case "go-vet":
314
+ command = `go vet "${filePath}" 2>&1`;
315
+ break;
316
+ case "roslyn": {
317
+ try {
318
+ const { getCSharpParser, ensureRoslynStarted, findSolutionFile } = await import('./addons-72SDV3F3.js');
319
+ let parser = getCSharpParser();
320
+ if (!parser) {
321
+ let dir = cwd;
322
+ let slnPath = null;
323
+ for (let i = 0; i < 10; i++) {
324
+ slnPath = findSolutionFile(dir);
325
+ if (slnPath) break;
326
+ const { dirname: dn } = await import('path');
327
+ const parent = dn(dir);
328
+ if (parent === dir) break;
329
+ dir = parent;
330
+ }
331
+ if (slnPath) {
332
+ parser = await ensureRoslynStarted(slnPath);
333
+ }
334
+ }
335
+ if (!parser) {
336
+ return {
337
+ validator: "roslyn",
338
+ errors: 0,
339
+ warnings: 0,
340
+ issues: [{ message: "Roslyn addon not available (no .sln found or DLL missing)", severity: "warning" }]
341
+ };
342
+ }
343
+ const parseResult = await parser.parseFile(filePath);
344
+ if (!parseResult || !parseResult.entities || parseResult.entities.length === 0) {
345
+ return { validator: "roslyn", errors: 0, warnings: 0, issues: [] };
346
+ }
347
+ const issues2 = [];
348
+ for (const entity of parseResult.entities) {
349
+ if (entity.metadata?.diagnostics) {
350
+ for (const diag of entity.metadata.diagnostics) {
351
+ issues2.push({
352
+ line: diag.line,
353
+ column: diag.column,
354
+ message: `${diag.id}: ${diag.message}`,
355
+ rule: diag.id,
356
+ severity: diag.severity === "error" ? "error" : diag.severity === "warning" ? "warning" : "info"
357
+ });
358
+ }
359
+ }
360
+ }
361
+ return {
362
+ validator: "roslyn",
363
+ errors: issues2.filter((i) => i.severity === "error").length,
364
+ warnings: issues2.filter((i) => i.severity === "warning").length,
365
+ issues: issues2
366
+ };
367
+ } catch (error) {
368
+ return {
369
+ validator: "roslyn",
370
+ errors: 1,
371
+ warnings: 0,
372
+ issues: [{ message: `Roslyn validation failed: ${String(error)}`, severity: "error" }]
373
+ };
374
+ }
375
+ }
376
+ default:
377
+ return { validator, errors: 0, warnings: 0, issues: [{ message: "Unknown validator", severity: "error" }] };
378
+ }
379
+ const result = await exec2(command, { cwd, timeout: 6e4 });
380
+ const issues = this.parseValidatorOutput(validator, result.stdout + result.stderr);
381
+ return {
382
+ validator,
383
+ errors: issues.filter((i) => i.severity === "error").length,
384
+ warnings: issues.filter((i) => i.severity === "warning").length,
385
+ issues
386
+ };
387
+ } catch (error) {
388
+ const execError = error;
389
+ const output = execError.stdout || execError.stderr || execError.message;
390
+ const issues = this.parseValidatorOutput(validator, output);
391
+ return {
392
+ validator,
393
+ errors: issues.filter((i) => i.severity === "error").length || 1,
394
+ warnings: issues.filter((i) => i.severity === "warning").length,
395
+ issues: issues.length > 0 ? issues : [{ message: output, severity: "error" }]
396
+ };
397
+ }
398
+ }
399
+ oxlintBinPath = null;
400
+ /**
401
+ * Find oxlint binary path from installed package
402
+ */
403
+ async findOxlintBin() {
404
+ if (this.oxlintBinPath) return this.oxlintBinPath;
405
+ const { createRequire } = await import('module');
406
+ const { dirname, join: join3 } = await import('path');
407
+ const { access: access2 } = await import('fs/promises');
408
+ try {
409
+ const require2 = createRequire(import.meta.url);
410
+ const oxlintPkg = require2.resolve("oxlint/package.json");
411
+ const oxlintDir = dirname(oxlintPkg);
412
+ const pkg = require2(oxlintPkg);
413
+ const binPath = typeof pkg.bin === "string" ? pkg.bin : typeof pkg.bin === "object" ? pkg.bin["oxlint"] : null;
414
+ if (binPath) {
415
+ const fullPath = join3(oxlintDir, binPath);
416
+ await access2(fullPath);
417
+ this.oxlintBinPath = fullPath;
418
+ return fullPath;
419
+ }
420
+ } catch {
421
+ }
422
+ this.oxlintBinPath = "npx oxlint";
423
+ return "npx oxlint";
424
+ }
425
+ parseValidatorOutput(validator, output) {
426
+ try {
427
+ if (validator === "oxlint") {
428
+ const parsed = JSON.parse(output);
429
+ if (parsed.diagnostics) {
430
+ return parsed.diagnostics.map((d) => ({
431
+ line: d.labels?.[0]?.span?.line,
432
+ column: d.labels?.[0]?.span?.column,
433
+ message: d.message,
434
+ rule: d.code,
435
+ severity: d.severity === "error" ? "error" : "warning"
436
+ }));
437
+ }
438
+ } else if (validator === "pylint") {
439
+ const parsed = JSON.parse(output);
440
+ if (Array.isArray(parsed)) {
441
+ return parsed.flatMap(
442
+ (file) => (file.messages || []).map(
443
+ (m) => ({
444
+ line: m.line,
445
+ column: m.column,
446
+ message: m.message || "Unknown error",
447
+ rule: m.ruleId || m.symbol,
448
+ severity: m.severity === 2 ? "error" : "warning"
449
+ })
450
+ )
451
+ );
452
+ }
453
+ }
454
+ } catch {
455
+ }
456
+ const issues = [];
457
+ const lines = output.split("\n");
458
+ for (const line of lines) {
459
+ if (line.includes("error") || line.includes("Error")) {
460
+ issues.push({ message: line.trim(), severity: "error" });
461
+ } else if (line.includes("warning") || line.includes("Warning")) {
462
+ issues.push({ message: line.trim(), severity: "warning" });
463
+ }
464
+ }
465
+ return issues;
466
+ }
467
+ };
468
+ var ValidateDirectoryToolHandler = class extends BaseToolHandler {
469
+ parseArgs(args) {
470
+ return ValidateDirectorySchema.parse(args);
471
+ }
472
+ async execute(args) {
473
+ const { glob } = await import('./glob-CGKPA3YD.js');
474
+ const directory = this.resolveProjectPath(args);
475
+ const extensions = args.extensions || [".ts", ".tsx", ".js", ".jsx", ".py"];
476
+ try {
477
+ const patterns = extensions.map((ext) => `**/*${ext}`);
478
+ let files = [];
479
+ for (const pattern of patterns) {
480
+ const found = await glob(pattern, { cwd: directory, absolute: true });
481
+ files.push(...found);
482
+ }
483
+ files = files.slice(0, args.maxFiles);
484
+ const validateHandler = new ValidateFileToolHandler(this.context);
485
+ const results = [];
486
+ if (args.parallel) {
487
+ const promises = files.map(async (file) => {
488
+ const result = await validateHandler.handle({
489
+ filePath: file,
490
+ projectPath: args.projectPath,
491
+ validators: args.validators,
492
+ fixable: args.fixable,
493
+ dryRun: args.dryRun
494
+ });
495
+ const text = result.content[0]?.text || "{}";
496
+ const parsed = JSON.parse(text);
497
+ return { file, ...parsed };
498
+ });
499
+ results.push(...await Promise.all(promises));
500
+ } else {
501
+ for (const file of files) {
502
+ const result = await validateHandler.handle({
503
+ filePath: file,
504
+ projectPath: args.projectPath,
505
+ validators: args.validators,
506
+ fixable: args.fixable,
507
+ dryRun: args.dryRun
508
+ });
509
+ const text = result.content[0]?.text || "{}";
510
+ const parsed = JSON.parse(text);
511
+ results.push({ file, ...parsed });
512
+ }
513
+ }
514
+ const totalErrors = results.reduce((sum, r) => sum + (r.totalErrors || 0), 0);
515
+ const totalWarnings = results.reduce((sum, r) => sum + (r.totalWarnings || 0), 0);
516
+ const invalidFiles = results.filter((r) => !r.isValid);
517
+ return {
518
+ content: [
519
+ {
520
+ type: "text",
521
+ text: JSON.stringify(
522
+ {
523
+ directory,
524
+ filesValidated: files.length,
525
+ totalErrors,
526
+ totalWarnings,
527
+ invalidFilesCount: invalidFiles.length,
528
+ summary: {
529
+ passed: files.length - invalidFiles.length,
530
+ failed: invalidFiles.length
531
+ },
532
+ invalidFiles: invalidFiles.slice(0, 20).map((f) => ({
533
+ file: f.file,
534
+ errors: f.totalErrors,
535
+ warnings: f.totalWarnings
536
+ }))
537
+ },
538
+ null,
539
+ 2
540
+ )
541
+ }
542
+ ]
543
+ };
544
+ } catch (error) {
545
+ const err = toError(error);
546
+ return {
547
+ content: [{ type: "text", text: JSON.stringify({ error: err.message }) }]
548
+ };
549
+ }
550
+ }
551
+ };
552
+
553
+ export { ValidateDirectoryToolHandler, ValidateFileToolHandler };
554
+ //# sourceMappingURL=validation-tool-handlers-RREUYKIR.js.map
555
+ //# sourceMappingURL=validation-tool-handlers-RREUYKIR.js.map