Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/core/src/flag/flag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,7 @@ export const Flag = {
get OPENCODE_CLIENT() {
return process.env["OPENCODE_CLIENT"] ?? "cli"
},
get OPENCODE_DISABLE_PLUGIN_INSTALL() {
return truthy("OPENCODE_DISABLE_PLUGIN_INSTALL")
},
}
6 changes: 6 additions & 0 deletions packages/core/src/npm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { Global } from "./global"
import { EffectFlock } from "./util/effect-flock"
import { makeRuntime } from "./effect/runtime"
import { NpmConfig } from "./npm-config"
import { Flag } from "./flag/flag"

export class InstallFailedError extends Schema.TaggedErrorClass<InstallFailedError>()("NpmInstallFailedError", {
add: Schema.Array(Schema.String).pipe(Schema.optional),
Expand Down Expand Up @@ -111,6 +112,9 @@ export const layer = Layer.effect(
)

const add = Effect.fn("Npm.add")(function* (pkg: string) {
if (Flag.OPENCODE_DISABLE_PLUGIN_INSTALL) {
return resolveEntryPoint(pkg, "")
}
const dir = directory(pkg)
const name = (() => {
try {
Expand All @@ -135,6 +139,8 @@ export const layer = Layer.effect(
}, Effect.scoped)

const install: Interface["install"] = Effect.fn("Npm.install")(function* (dir, input) {
if (Flag.OPENCODE_DISABLE_PLUGIN_INSTALL) return

const canWrite = yield* afs.access(dir, { writable: true }).pipe(
Effect.as(true),
Effect.orElseSucceed(() => false),
Expand Down
8 changes: 8 additions & 0 deletions packages/opencode/src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,10 @@ export const Info = Schema.Struct({
description:
"Automatically update to the latest version. Set to true to auto-update, false to disable, or 'notify' to show update notifications",
}),
pluginAutoInstall: Schema.optional(Schema.Boolean).annotate({
description:
"Enable or disable automatic plugin installation. When false, plugins will not be auto-installed (equivalent to OPENCODE_DISABLE_PLUGIN_INSTALL=true)",
}),
disabled_providers: Schema.optional(Schema.mutable(Schema.Array(Schema.String))).annotate({
description: "Disable providers that are loaded automatically",
}),
Expand Down Expand Up @@ -732,6 +736,10 @@ export const layer = Layer.effect(
result.compaction = { ...result.compaction, prune: false }
}

if (result.pluginAutoInstall === false) {
process.env["OPENCODE_DISABLE_PLUGIN_INSTALL"] = "true"
}

return {
config: result,
directories,
Expand Down
Loading