Просмотр исходного кода

ensure @opencode-ai/plugin exists only on first run

Dax Raad 1 месяц назад
Родитель
Сommit
97977f6ad4
2 измененных файлов с 5 добавлено и 6 удалено
  1. 5 1
      packages/opencode/src/config/config.ts
  2. 0 5
      packages/opencode/src/worktree/index.ts

+ 5 - 1
packages/opencode/src/config/config.ts

@@ -18,6 +18,7 @@ import { LSPServer } from "../lsp/server"
 import { BunProc } from "@/bun"
 import { Installation } from "@/installation"
 import { ConfigMarkdown } from "./markdown"
+import { existsSync } from "fs"
 
 export namespace Config {
   const log = Log.create({ service: "config" })
@@ -103,7 +104,10 @@ export namespace Config {
         }
       }
 
-      installDependencies(dir)
+      const exists = existsSync(path.join(dir, "node_modules"))
+      const installing = installDependencies(dir)
+      if (!exists) await installing
+
       result.command = mergeDeep(result.command ?? {}, await loadCommand(dir))
       result.agent = mergeDeep(result.agent, await loadAgent(dir))
       result.agent = mergeDeep(result.agent, await loadMode(dir))

+ 0 - 5
packages/opencode/src/worktree/index.ts

@@ -212,11 +212,6 @@ export namespace Worktree {
       throw new StartCommandFailedError({ message: errorText(ran) || "Worktree start command failed" })
     }
 
-    const opencodeDir = path.join(info.directory, ".opencode")
-    if (await Bun.file(opencodeDir).exists()) {
-      await Config.installDependencies(info.directory)
-    }
-
     return info
   })
 }