summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDax Raad <[email protected]>2025-10-09 21:18:29 -0400
committerDax Raad <[email protected]>2025-10-09 21:18:49 -0400
commit096710a8cc58b7f4c81e516c9edb3147f9a5fb3f (patch)
treed9f90bd3918e6ad753ebdcdb30e74e9e6c060c89
parent50bb201187ed347424b50e4e1591e61b6f5009b9 (diff)
downloadopencode-096710a8cc58b7f4c81e516c9edb3147f9a5fb3f.tar.gz
opencode-096710a8cc58b7f4c81e516c9edb3147f9a5fb3f.zip
ensure @opencode-ai/plugin is available in `.opencode` folder
-rw-r--r--packages/opencode/src/config/config.ts14
1 files changed, 14 insertions, 0 deletions
diff --git a/packages/opencode/src/config/config.ts b/packages/opencode/src/config/config.ts
index 40e4d90a4..234d14573 100644
--- a/packages/opencode/src/config/config.ts
+++ b/packages/opencode/src/config/config.ts
@@ -15,6 +15,8 @@ import { Auth } from "../auth"
import { type ParseError as JsoncParseError, parse as parseJsonc, printParseErrorCode } from "jsonc-parser"
import { Instance } from "../project/instance"
import { LSPServer } from "../lsp/server"
+import { BunProc } from "@/bun"
+import { Installation } from "@/installation"
export namespace Config {
const log = Log.create({ service: "config" })
@@ -61,6 +63,7 @@ export namespace Config {
for (const dir of directories) {
await assertValid(dir).catch(() => {})
+ installDependencies(dir)
result.command = mergeDeep(result.command ?? {}, await loadCommand(dir))
result.agent = mergeDeep(result.agent, await loadAgent(dir))
result.agent = mergeDeep(result.agent, await loadMode(dir))
@@ -137,6 +140,17 @@ export namespace Config {
}
}
+ async function installDependencies(dir: string) {
+ await Bun.write(path.join(dir, "package.json"), "{}")
+ await Bun.write(path.join(dir, ".gitignore"), ["node_modules", "package.json", "bun.lock", ".gitignore"].join("\n"))
+ await BunProc.run(
+ ["add", "@opencode-ai/plugin@" + (Installation.isDev() ? "latest" : Installation.VERSION), "--exact"],
+ {
+ cwd: dir,
+ },
+ )
+ }
+
const COMMAND_GLOB = new Bun.Glob("command/**/*.md")
async function loadCommand(dir: string) {
const result: Record<string, Command> = {}