Skip to content

Commit 096710a

Browse files
committed
ensure @opencode-ai/plugin is available in .opencode folder
1 parent 50bb201 commit 096710a

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

‎packages/opencode/src/config/config.ts‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import { Auth } from "../auth"
1515
import { type ParseError as JsoncParseError, parse as parseJsonc, printParseErrorCode } from "jsonc-parser"
1616
import { Instance } from "../project/instance"
1717
import { LSPServer } from "../lsp/server"
18+
import { BunProc } from "@/bun"
19+
import { Installation } from "@/installation"
1820

1921
export namespace Config {
2022
const log = Log.create({ service: "config" })
@@ -61,6 +63,7 @@ export namespace Config {
6163

6264
for (const dir of directories) {
6365
await assertValid(dir).catch(() => {})
66+
installDependencies(dir)
6467
result.command = mergeDeep(result.command ?? {}, await loadCommand(dir))
6568
result.agent = mergeDeep(result.agent, await loadAgent(dir))
6669
result.agent = mergeDeep(result.agent, await loadMode(dir))
@@ -137,6 +140,17 @@ export namespace Config {
137140
}
138141
}
139142

143+
async function installDependencies(dir: string) {
144+
await Bun.write(path.join(dir, "package.json"), "{}")
145+
await Bun.write(path.join(dir, ".gitignore"), ["node_modules", "package.json", "bun.lock", ".gitignore"].join("\n"))
146+
await BunProc.run(
147+
["add", "@opencode-ai/plugin@" + (Installation.isDev() ? "latest" : Installation.VERSION), "--exact"],
148+
{
149+
cwd: dir,
150+
},
151+
)
152+
}
153+
140154
const COMMAND_GLOB = new Bun.Glob("command/**/*.md")
141155
async function loadCommand(dir: string) {
142156
const result: Record<string, Command> = {}

0 commit comments

Comments
 (0)