Skip to content

feat(bash): expand shell.env hook context with messageID and agent#21773

Open
micuintus wants to merge 1 commit intoanomalyco:devfrom
micuintus:feat/shell-env-hook-expansion
Open

feat(bash): expand shell.env hook context with messageID and agent#21773
micuintus wants to merge 1 commit intoanomalyco:devfrom
micuintus:feat/shell-env-hook-expansion

Conversation

@micuintus
Copy link
Copy Markdown

@micuintus micuintus commented Apr 9, 2026

Issue for this PR

Closes #21767

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Expands the Plugin.trigger("shell.env", ...) call in bash.ts to pass messageID and agent in the context. This lets plugins set env vars conditionally based on which message or agent triggered the bash command.

Only the bash.ts call site is expanded (agent-initiated commands). The other call sites in prompt.ts and pty/index.ts are for user-initiated commands — expanding those is a separate concern.

Also updates the ShellEnv type in @opencode/plugin to include the new fields.

How did you verify your code works?

  • Unit test in packages/opencode/test/tool/shell-env-hook.test.ts
  • bun turbo typecheck passes

Screenshots / recordings

No UI changes.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Part of the plugin primitives work split from #21687 (tracking issue #20018).

@github-actions github-actions bot added needs:compliance This means the issue will auto-close after 2 hours. and removed needs:compliance This means the issue will auto-close after 2 hours. labels Apr 9, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 9, 2026

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@micuintus micuintus force-pushed the feat/shell-env-hook-expansion branch 2 times, most recently from 92f73ab to abfa0c7 Compare April 10, 2026 03:10
Plugins can now access messageID and agent in the shell.env hook,
enabling them to inject full session callback context into bash env vars.
@micuintus micuintus force-pushed the feat/shell-env-hook-expansion branch from abfa0c7 to bd727cb Compare April 11, 2026 10:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE]: expand shell.env hook context with messageID and agent

1 participant