Преглед на файлове

refactor: migrate cli/cmd/mcp.ts from Bun.file()/Bun.write() to Filesystem module

Replace Bun-specific file operations with Filesystem module:

- Replace Bun.file().exists() with Filesystem.exists()

- Replace Bun.file().text() with Filesystem.readText()

- Replace Bun.write() with Filesystem.write()
Dax Raad преди 2 месеца
родител
ревизия
ad30e5b378
променени са 1 файла, в които са добавени 5 реда и са изтрити 6 реда
  1. 5 6
      packages/opencode/src/cli/cmd/mcp.ts

+ 5 - 6
packages/opencode/src/cli/cmd/mcp.ts

@@ -13,6 +13,7 @@ import { Installation } from "../../installation"
 import path from "path"
 import { Global } from "../../global"
 import { modify, applyEdits } from "jsonc-parser"
+import { Filesystem } from "../../util/filesystem"
 import { Bus } from "../../bus"
 
 function getAuthStatusIcon(status: MCP.AuthStatus): string {
@@ -388,7 +389,7 @@ async function resolveConfigPath(baseDir: string, global = false) {
   }
 
   for (const candidate of candidates) {
-    if (await Bun.file(candidate).exists()) {
+    if (await Filesystem.exists(candidate)) {
       return candidate
     }
   }
@@ -398,11 +399,9 @@ async function resolveConfigPath(baseDir: string, global = false) {
 }
 
 async function addMcpToConfig(name: string, mcpConfig: Config.Mcp, configPath: string) {
-  const file = Bun.file(configPath)
-
   let text = "{}"
-  if (await file.exists()) {
-    text = await file.text()
+  if (await Filesystem.exists(configPath)) {
+    text = await Filesystem.readText(configPath)
   }
 
   // Use jsonc-parser to modify while preserving comments
@@ -411,7 +410,7 @@ async function addMcpToConfig(name: string, mcpConfig: Config.Mcp, configPath: s
   })
   const result = applyEdits(text, edits)
 
-  await Bun.write(configPath, result)
+  await Filesystem.write(configPath, result)
 
   return configPath
 }