diff options
| author | Tyler Gannon <[email protected]> | 2026-02-03 15:18:41 -0600 |
|---|---|---|
| committer | GitHub <[email protected]> | 2026-02-03 15:18:41 -0600 |
| commit | a30696f9bfefc58d640316c6a864c9bb255de690 (patch) | |
| tree | 3c2579e57db3e5a7f235b9b20296a4a3bc01bb2e /packages/web | |
| parent | 25bdd77b1d765a9cac5d02ede93c075f25d6ca6f (diff) | |
| download | opencode-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')
| -rw-r--r-- | packages/web/src/content/docs/plugins.mdx | 21 |
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: |
