summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDax Raad <[email protected]>2026-02-05 10:07:59 -0500
committerDax Raad <[email protected]>2026-02-05 10:07:59 -0500
commita1c46e05ee628f16f92ead49c956b5c0bec2783a (patch)
tree0ff15d934906e68f69964615065075bf517229a3
parent1fe1457cfa0d908f2718bd6afee74ea7d8d3db0d (diff)
downloadopencode-a1c46e05ee628f16f92ead49c956b5c0bec2783a.tar.gz
opencode-a1c46e05ee628f16f92ead49c956b5c0bec2783a.zip
core: fix plugin installation to use direct package.json manipulation instead of bun add
This ensures plugins install more reliably by writing dependencies directly to package.json rather than relying on bun add commands which can fail in certain environments. Also adds a small delay to ensure filesystem operations complete before proceeding.
-rw-r--r--packages/opencode/src/config/config.ts27
1 files changed, 10 insertions, 17 deletions
diff --git a/packages/opencode/src/config/config.ts b/packages/opencode/src/config/config.ts
index dfb86dbe2..ed1b15500 100644
--- a/packages/opencode/src/config/config.ts
+++ b/packages/opencode/src/config/config.ts
@@ -249,29 +249,22 @@ export namespace Config {
export async function installDependencies(dir: string) {
const pkg = path.join(dir, "package.json")
- const targetVersion = Installation.isLocal() ? "latest" : Installation.VERSION
-
- if (!(await Bun.file(pkg).exists())) {
- await Bun.write(pkg, "{}")
+ const targetVersion = Installation.isLocal() ? "*" : Installation.VERSION
+
+ const json = await Bun.file(pkg)
+ .json()
+ .catch(() => ({}))
+ json.dependencies = {
+ ...json.dependencies,
+ "@opencode-ai/plugin": targetVersion,
}
+ await Bun.write(pkg, JSON.stringify(json, null, 2))
+ await new Promise((resolve) => setTimeout(resolve, 3000))
const gitignore = path.join(dir, ".gitignore")
const hasGitIgnore = await Bun.file(gitignore).exists()
if (!hasGitIgnore) await Bun.write(gitignore, ["node_modules", "package.json", "bun.lock", ".gitignore"].join("\n"))
- await BunProc.run(
- [
- "add",
- `@opencode-ai/plugin@${targetVersion}`,
- "--exact",
- // TODO: get rid of this case (see: https://github.com/oven-sh/bun/issues/19936)
- ...(proxied() ? ["--no-cache"] : []),
- ],
- {
- cwd: dir,
- },
- ).catch(() => {})
-
// Install any additional dependencies defined in the package.json
// This allows local plugins and custom tools to use external packages
await BunProc.run(