anomalyco / anomalyco/opencode

V2 Bash tool does not apply plugin shell.env hooks

Open
#41,117 1 comment 0 reactions 1 assignee View on GitHub

@kitlangton is already working on this.

Since Aug 7, 2026.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Description

The V2 Bash tool launches child processes without applying plugin-provided shell.env values. The legacy shell implementation calls plugin.trigger("shell.env", { cwd, sessionID, callID }, { env: {} }), while packages/core/src/tool/bash.ts launches ChildProcess.make(...) directly and contains a TODO for this missing behavior.

This breaks plugins that provide invocation-scoped environment variables to shell commands.

Reproduction

  1. Configure a local plugin with a shell.env hook that sets OPENCODE_SHELL_ENV_PROBE=present.
  2. Start OpenCode V2 with that plugin loaded.
  3. Ask the Bash tool to run printenv OPENCODE_SHELL_ENV_PROBE.
  4. Observe that the variable is absent.

Expected behavior

V2 Bash should invoke the same shell.env plugin contract with the active cwd, sessionID, and callID, then merge the returned values into the child process environment. Concurrent sessions must retain invocation-scoped isolation.

Version

Observed with OpenCode 1.18.4.

AI assistance: OpenAI gpt-5.6-sol via OpenCode inspected the runtime behavior and source paths and drafted this report. Chris Huber verified the reproduction and remains responsible for the report.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.