Przeglądaj źródła

refactor: migrate src/session/instruction.ts from Bun.file() to Filesystem module (#14130)

Dax 5 miesięcy temu
rodzic
commit
ae398539c5
1 zmienionych plików z 4 dodań i 8 usunięć
  1. 4 8
      packages/opencode/src/session/instruction.ts

+ 4 - 8
packages/opencode/src/session/instruction.ts

@@ -85,7 +85,7 @@ export namespace InstructionPrompt {
     }
 
     for (const file of globalFiles()) {
-      if (await Bun.file(file).exists()) {
+      if (await Filesystem.exists(file)) {
         paths.add(path.resolve(file))
         break
       }
@@ -120,9 +120,7 @@ export namespace InstructionPrompt {
     const paths = await systemPaths()
 
     const files = Array.from(paths).map(async (p) => {
-      const content = await Bun.file(p)
-        .text()
-        .catch(() => "")
+      const content = await Filesystem.readText(p).catch(() => "")
       return content ? "Instructions from: " + p + "\n" + content : ""
     })
 
@@ -164,7 +162,7 @@ export namespace InstructionPrompt {
   export async function find(dir: string) {
     for (const file of FILES) {
       const filepath = path.resolve(path.join(dir, file))
-      if (await Bun.file(filepath).exists()) return filepath
+      if (await Filesystem.exists(filepath)) return filepath
     }
   }
 
@@ -182,9 +180,7 @@ export namespace InstructionPrompt {
 
       if (found && found !== target && !system.has(found) && !already.has(found) && !isClaimed(messageID, found)) {
         claim(messageID, found)
-        const content = await Bun.file(found)
-          .text()
-          .catch(() => undefined)
+        const content = await Filesystem.readText(found).catch(() => undefined)
         if (content) {
           results.push({ filepath: found, content: "Instructions from: " + found + "\n" + content })
         }