feat(plugin): add shell.env hook for manipulating environment in tools and shell (#12012)
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user