Skip to content
Merged
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 @@ -54,6 +54,9 @@ export const Flag = {
get OPENCODE_DISABLE_PROJECT_CONFIG() {
return truthy("OPENCODE_DISABLE_PROJECT_CONFIG")
},
get OPENCODE_DISABLE_CONFIG_DEP_INSTALL() {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SUGGESTION: New flag OPENCODE_DISABLE_CONFIG_DEP_INSTALL is undocumented. Add it to the "Escape hatches" list in packages/core/src/plugin/skill/customize-opencode.md (next to OPENCODE_DISABLE_DEFAULT_PLUGINS) and note it is for test/CI use only, since production config dependency installs are unchanged by default.

return truthy("OPENCODE_DISABLE_CONFIG_DEP_INSTALL")
},
get OPENCODE_EXPERIMENTAL_REFERENCES() {
return enabledByExperimental("OPENCODE_EXPERIMENTAL_REFERENCES")
},
Expand Down
7 changes: 7 additions & 0 deletions packages/core/src/plugin/skill/customize-opencode.md
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,13 @@ When a user's config is broken and opencode won't start, these env vars help:
- `OPENCODE_DISABLE_EXTERNAL_SKILLS=1`,
`OPENCODE_DISABLE_CLAUDE_CODE_SKILLS=1`: skip the external skill scans under
`~/.claude/` and `~/.agents/`.
- `OPENCODE_DISABLE_CONFIG_DEP_INSTALL=1`: skip the background
`@opencode-ai/plugin` install that every instance boot forks per config
directory. Meant for hermetic tests and CI: the install is real registry
network I/O, and a stalled registry wedges instance disposal (scope close
awaits the uncancelable install fiber), hanging a gate until its outer
timeout. The HTTP API exerciser sets this for exactly that reason. Leave it
unset in normal use so plugin dependencies stay current.

## When proposing edits

Expand Down
6 changes: 6 additions & 0 deletions packages/opencode/script/httpapi-exercise.ts
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
// The exerciser gates HTTP routes, not config dependency installs. Every
// instance boot otherwise forks a real `@opencode-ai/plugin` registry install
// per config directory, and a stalled registry wedges instance disposal
// (scope close awaits the uncancelable install fiber), which hung the Linux
// CI gate for the full action timeout. Keep every exerciser boot hermetic.
process.env.OPENCODE_DISABLE_CONFIG_DEP_INSTALL = "1"
await import("../test/server/httpapi-exercise/index")
42 changes: 22 additions & 20 deletions packages/opencode/src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -435,26 +435,28 @@ const layer = Layer.effect(

yield* ensureGitignore(dir).pipe(Effect.orDie)

const dep = yield* npmSvc
.install(dir, {
add: [
{
name: "@opencode-ai/plugin",
version: InstallationLocal ? undefined : InstallationVersion,
},
],
})
.pipe(
Effect.exit,
Effect.tap((exit) =>
Exit.isFailure(exit)
? Effect.logWarning("background dependency install failed", { dir, error: String(exit.cause) })
: Effect.void,
),
Effect.asVoid,
Effect.forkDetach,
)
deps.push(dep)
if (!Flag.OPENCODE_DISABLE_CONFIG_DEP_INSTALL) {
const dep = yield* npmSvc
.install(dir, {
add: [
{
name: "@opencode-ai/plugin",
version: InstallationLocal ? undefined : InstallationVersion,
},
],
})
.pipe(
Effect.exit,
Effect.tap((exit) =>
Exit.isFailure(exit)
? Effect.logWarning("background dependency install failed", { dir, error: String(exit.cause) })
: Effect.void,
),
Effect.asVoid,
Effect.forkDetach,
)
deps.push(dep)
}

result.command = mergeDeep(result.command ?? {}, yield* Effect.promise(() => ConfigCommand.load(dir)))
result.agent = mergeDeep(result.agent ?? {}, yield* Effect.promise(() => ConfigAgent.load(dir)))
Expand Down
7 changes: 7 additions & 0 deletions packages/opencode/test/server/httpapi-listen.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,12 @@ describe("HttpApi Server.listen", () => {
},
})
const previous = process.env.OPENCODE_DISABLE_DEFAULT_PLUGINS
const previousDepInstall = process.env.OPENCODE_DISABLE_CONFIG_DEP_INSTALL
process.env.OPENCODE_DISABLE_DEFAULT_PLUGINS = "1"
// The test plugin imports nothing, so the background @opencode-ai/plugin
// install that config-with-plugins waits on is pure cost here - and on
// Windows CI (Arborist on NTFS + Defender) it exceeds the 30s test budget.
process.env.OPENCODE_DISABLE_CONFIG_DEP_INSTALL = "1"
let listener: Awaited<ReturnType<typeof startListener>> | undefined
try {
listener = await startListener()
Expand All @@ -350,6 +355,8 @@ describe("HttpApi Server.listen", () => {
if (listener) await stop(listener, "timed out cleaning up plugin client listener").catch(() => undefined)
if (previous === undefined) delete process.env.OPENCODE_DISABLE_DEFAULT_PLUGINS
else process.env.OPENCODE_DISABLE_DEFAULT_PLUGINS = previous
if (previousDepInstall === undefined) delete process.env.OPENCODE_DISABLE_CONFIG_DEP_INSTALL
else process.env.OPENCODE_DISABLE_CONFIG_DEP_INSTALL = previousDepInstall
}
})

Expand Down
Loading