From 0adc76a1db40cc7562d6f74007f6db2b0a38e159 Mon Sep 17 00:00:00 2001 From: Longlone Date: Tue, 9 Dec 2025 11:46:21 +0800 Subject: [PATCH] feat: add bun_no_cache configuration option to disable Bun cache during package installation --- packages/opencode/src/bun/index.ts | 7 +++++++ packages/opencode/src/config/config.ts | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/packages/opencode/src/bun/index.ts b/packages/opencode/src/bun/index.ts index edf74c310..584683dd3 100644 --- a/packages/opencode/src/bun/index.ts +++ b/packages/opencode/src/bun/index.ts @@ -4,6 +4,7 @@ import { Log } from "../util/log" import path from "path" import { NamedError } from "@opencode-ai/util/error" import { readableStreamToText } from "bun" +import { Config } from "../config/config" import { createRequire } from "module" import { Lock } from "../util/lock" @@ -76,6 +77,12 @@ export namespace BunProc { // Build command arguments const args = ["add", "--force", "--exact", "--cwd", Global.Path.cache, pkg + "@" + version] + // Add --no-cache flag if configured + const config = await Config.get() + if (config.bun_no_cache) { + args.push("--no-cache") + } + // Let Bun handle registry resolution: // - If .npmrc files exist, Bun will use them automatically // - If no .npmrc files exist, Bun will default to https://registry.npmjs.org diff --git a/packages/opencode/src/config/config.ts b/packages/opencode/src/config/config.ts index 267278b74..98d3b783a 100644 --- a/packages/opencode/src/config/config.ts +++ b/packages/opencode/src/config/config.ts @@ -671,6 +671,10 @@ export namespace Config { url: z.string().optional().describe("Enterprise URL"), }) .optional(), + bun_no_cache: z + .boolean() + .optional() + .describe("Disable Bun cache when installing packages (adds --no-cache flag)"), experimental: z .object({ hook: z