summaryrefslogtreecommitdiffhomepage
path: root/packages/web/src
diff options
context:
space:
mode:
authorTyler Gannon <[email protected]>2026-02-03 15:18:41 -0600
committerGitHub <[email protected]>2026-02-03 15:18:41 -0600
commita30696f9bfefc58d640316c6a864c9bb255de690 (patch)
tree3c2579e57db3e5a7f235b9b20296a4a3bc01bb2e /packages/web/src
parent25bdd77b1d765a9cac5d02ede93c075f25d6ca6f (diff)
downloadopencode-a30696f9bfefc58d640316c6a864c9bb255de690.tar.gz
opencode-a30696f9bfefc58d640316c6a864c9bb255de690.zip
feat(plugin): add shell.env hook for manipulating environment in tools and shell (#12012)
Diffstat (limited to 'packages/web/src')
-rw-r--r--packages/web/src/content/docs/plugins.mdx21
1 files changed, 21 insertions, 0 deletions
diff --git a/packages/web/src/content/docs/plugins.mdx b/packages/web/src/content/docs/plugins.mdx
index ba530a6d9..394fecc40 100644
--- a/packages/web/src/content/docs/plugins.mdx
+++ b/packages/web/src/content/docs/plugins.mdx
@@ -192,6 +192,10 @@ Plugins can subscribe to events as seen below in the Examples section. Here is a
- `todo.updated`
+#### Shell Events
+
+- `shell.env`
+
#### Tool Events
- `tool.execute.after`
@@ -254,6 +258,23 @@ export const EnvProtection = async ({ project, client, $, directory, worktree })
---
+### Inject environment variables
+
+Inject environment variables into all shell execution (AI tools and user terminals):
+
+```javascript title=".opencode/plugins/inject-env.js"
+export const InjectEnvPlugin = async () => {
+ return {
+ "shell.env": async (input, output) => {
+ output.env.MY_API_KEY = "secret"
+ output.env.PROJECT_ROOT = input.cwd
+ },
+ }
+}
+```
+
+---
+
### Custom tools
Plugins can also add custom tools to opencode: