From 35445dbc9928533976b0b2329978081338829ddf Mon Sep 17 00:00:00 2001 From: "exe.dev user" Date: Thu, 3 Dec 2026 23:21:20 +0000 Subject: [PATCH 1/3] fix(opencode): add a flag to skip the config dependency install Co-Authored-By: Claude Fable 5.2 --- packages/core/src/flag/flag.ts | 3 ++ packages/opencode/src/config/config.ts | 2 ++ packages/opencode/test/config/config.test.ts | 29 +++++++++++++++++++- 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/packages/core/src/flag/flag.ts b/packages/core/src/flag/flag.ts index 866310ff5a..b7340dd657 100644 --- a/packages/core/src/flag/flag.ts +++ b/packages/core/src/flag/flag.ts @@ -54,6 +54,9 @@ export const Flag = { get OPENCODE_DISABLE_PROJECT_CONFIG() { return truthy("OPENCODE_DISABLE_PROJECT_CONFIG") }, + get OPENCODE_DISABLE_CONFIG_INSTALL() { + return truthy("OPENCODE_DISABLE_CONFIG_INSTALL") + }, get OPENCODE_EXPERIMENTAL_REFERENCES() { return enabledByExperimental("OPENCODE_EXPERIMENTAL_REFERENCES") }, diff --git a/packages/opencode/src/config/config.ts b/packages/opencode/src/config/config.ts index a452ec3030..7a659ba3ed 100644 --- a/packages/opencode/src/config/config.ts +++ b/packages/opencode/src/config/config.ts @@ -445,6 +445,8 @@ const layer = Layer.effect( ], }) .pipe( + // A cloud sandbox starts with an empty cache, so each start would download the full package version list. + Effect.when(Effect.sync(() => !Flag.OPENCODE_DISABLE_CONFIG_INSTALL)), Effect.exit, Effect.tap((exit) => Exit.isFailure(exit) diff --git a/packages/opencode/test/config/config.test.ts b/packages/opencode/test/config/config.test.ts index e281831ddf..2b7a6e3c34 100644 --- a/packages/opencode/test/config/config.test.ts +++ b/packages/opencode/test/config/config.test.ts @@ -96,12 +96,13 @@ const configLayer = ( auth?: Layer.Layer account?: Layer.Layer client?: HttpClient.HttpClient + npm?: Layer.Layer } = {}, ) => LayerNode.compile(LayerNode.group([Config.node, FSUtil.node, Env.node, CrossSpawnSpawner.node]), [ [Auth.node, options.auth ?? AuthTest.empty], [Account.node, options.account ?? AccountTest.empty], - [Npm.node, NpmTest.noop], + [Npm.node, options.npm ?? NpmTest.noop], [httpClient, Layer.succeed(HttpClient.HttpClient, options.client ?? unexpectedHttp)], ]) @@ -966,6 +967,32 @@ it.effect("installs dependencies in writable OPENCODE_CONFIG_DIR", () => }).pipe(Effect.provide(testInstanceStoreLayer), Effect.provide(LayerNode.compile(CrossSpawnSpawner.node))), ) +const installs: string[] = [] +const recordedInstalls = testEffect( + configLayer({ + npm: Layer.mock(Npm.Service)({ install: (dir) => Effect.sync(() => void installs.push(dir)) }), + }), +) + +recordedInstalls.effect("skips the dependency install only when OPENCODE_DISABLE_CONFIG_INSTALL is set", () => + Effect.gen(function* () { + const load = Effect.fnUntraced(function* (disabled: string | undefined) { + const dir = yield* tmpdirScoped() + const configDir = path.join(dir, "configdir") + yield* withProcessEnvs( + { OPENCODE_CONFIG_DIR: configDir, OPENCODE_DISABLE_CONFIG_INSTALL: disabled }, + Config.Service.use((svc) => svc.get().pipe(Effect.andThen(svc.waitForDependencies()))).pipe( + provideInstanceEffect(dir), + ), + ) + return configDir + }) + + expect(installs).not.toContain(yield* load("1")) + expect(installs).toContain(yield* load(undefined)) + }).pipe(Effect.provide(testInstanceStoreLayer), Effect.provide(LayerNode.compile(CrossSpawnSpawner.node))), +) + // Note: deduplication and serialization of npm installs is now handled by the // core Npm.Service (via EffectFlock). Those behaviors are tested in the core // package's npm tests, not here. From adf2221eba20a89f98557f7884f251618a823833 Mon Sep 17 00:00:00 2001 From: "exe.dev user" Date: Thu, 3 Dec 2026 23:51:42 +0000 Subject: [PATCH 2/3] test(opencode): assert that the disabled load installs in no config directory Co-Authored-By: Claude Fable 5.2 --- packages/opencode/src/config/config.ts | 2 +- packages/opencode/test/config/config.test.ts | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/opencode/src/config/config.ts b/packages/opencode/src/config/config.ts index 7a659ba3ed..17c389c316 100644 --- a/packages/opencode/src/config/config.ts +++ b/packages/opencode/src/config/config.ts @@ -445,7 +445,7 @@ const layer = Layer.effect( ], }) .pipe( - // A cloud sandbox starts with an empty cache, so each start would download the full package version list. + // A cloud sandbox starts with an empty cache, so each start downloads the full package version list. Effect.when(Effect.sync(() => !Flag.OPENCODE_DISABLE_CONFIG_INSTALL)), Effect.exit, Effect.tap((exit) => diff --git a/packages/opencode/test/config/config.test.ts b/packages/opencode/test/config/config.test.ts index 2b7a6e3c34..01dc0362f1 100644 --- a/packages/opencode/test/config/config.test.ts +++ b/packages/opencode/test/config/config.test.ts @@ -988,7 +988,9 @@ recordedInstalls.effect("skips the dependency install only when OPENCODE_DISABLE return configDir }) - expect(installs).not.toContain(yield* load("1")) + const before = installs.length + yield* load("1") + expect(installs.length).toBe(before) expect(installs).toContain(yield* load(undefined)) }).pipe(Effect.provide(testInstanceStoreLayer), Effect.provide(LayerNode.compile(CrossSpawnSpawner.node))), ) From 296ffda28837f2783466114d6967ebdc7154ceba Mon Sep 17 00:00:00 2001 From: "exe.dev user" Date: Thu, 3 Dec 2026 23:57:24 +0000 Subject: [PATCH 3/3] docs(opencode): say that the download happens only without the guard Co-Authored-By: Claude Fable 5.2 --- packages/opencode/src/config/config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/opencode/src/config/config.ts b/packages/opencode/src/config/config.ts index 17c389c316..17d87d9bef 100644 --- a/packages/opencode/src/config/config.ts +++ b/packages/opencode/src/config/config.ts @@ -445,7 +445,7 @@ const layer = Layer.effect( ], }) .pipe( - // A cloud sandbox starts with an empty cache, so each start downloads the full package version list. + // Without this guard, each start with an empty cache downloads the full package version list. Effect.when(Effect.sync(() => !Flag.OPENCODE_DISABLE_CONFIG_INSTALL)), Effect.exit, Effect.tap((exit) =>