|
14 | 14 |
|
15 | 15 | import { type MCPTool, getProjectCwd } from './types.js'; |
16 | 16 | import { validateIdentifier } from './validate-input.js'; |
17 | | -import { existsSync, readFileSync, writeFileSync, mkdirSync } from 'node:fs'; |
| 17 | +import { existsSync, readFileSync, writeFileSync, mkdirSync, unlinkSync, readdirSync } from 'node:fs'; |
18 | 18 | import { join } from 'node:path'; |
19 | 19 | import * as os from 'node:os'; |
20 | 20 |
|
@@ -222,7 +222,7 @@ export const performanceTools: MCPTool[] = [ |
222 | 222 | writeFileSync(probeFile, payload); |
223 | 223 | readFileSync(probeFile); |
224 | 224 | diskLatencyMs = Math.round((performance.now() - t0) * 100) / 100; |
225 | | - try { const { unlinkSync } = require('node:fs'); unlinkSync(probeFile); } catch { /* best-effort */ } |
| 225 | + try { unlinkSync(probeFile); } catch { /* best-effort */ } |
226 | 226 | } catch { /* disk probe failed, leave -1 */ } |
227 | 227 |
|
228 | 228 | // Check stored benchmark history for slow operations |
@@ -464,7 +464,7 @@ export const performanceTools: MCPTool[] = [ |
464 | 464 | .sort((a, b) => b.percentOfTotal - a.percentOfTotal); |
465 | 465 |
|
466 | 466 | // Cleanup probe file |
467 | | - try { const { unlinkSync } = require('node:fs'); unlinkSync(join(getPerfDir(), '.profile-probe')); } catch { /* ok */ } |
| 467 | + try { unlinkSync(join(getPerfDir(), '.profile-probe')); } catch { /* ok */ } |
468 | 468 |
|
469 | 469 | return { |
470 | 470 | success: true, |
@@ -514,7 +514,7 @@ export const performanceTools: MCPTool[] = [ |
514 | 514 | writeFileSync(probe, Buffer.alloc(4096, 0x42)); |
515 | 515 | readFileSync(probe); |
516 | 516 | diskLatencyBefore = Math.round((performance.now() - t0) * 100) / 100; |
517 | | - try { const { unlinkSync } = require('node:fs'); unlinkSync(probe); } catch { /* ok */ } |
| 517 | + try { unlinkSync(probe); } catch { /* ok */ } |
518 | 518 | } catch { /* ok */ } |
519 | 519 |
|
520 | 520 | const optimizations: Array<{ action: string; applied: boolean; effect?: string; recommendation?: string }> = []; |
@@ -559,9 +559,8 @@ export const performanceTools: MCPTool[] = [ |
559 | 559 | if (aggressive) { |
560 | 560 | try { |
561 | 561 | const dir = getPerfDir(); |
562 | | - const { readdirSync, unlinkSync: ul } = require('node:fs'); |
563 | 562 | const probes = readdirSync(dir).filter((f: string) => f.startsWith('.')); |
564 | | - probes.forEach((f: string) => { try { ul(join(dir, f)); } catch { /* ok */ } }); |
| 563 | + probes.forEach((f: string) => { try { unlinkSync(join(dir, f)); } catch { /* ok */ } }); |
565 | 564 | if (probes.length > 0) optimizations.push({ action: 'clear-probe-files', applied: true, effect: `Removed ${probes.length} probe file(s)` }); |
566 | 565 | } catch { /* ok */ } |
567 | 566 | } |
|
0 commit comments