opencode-env-loader
v1.0.0
Published
OpenCode plugin to auto-load project environment before shell execution
Downloads
123
Maintainers
Readme
opencode-env-loader
OpenCode plugin to auto-load project environment before shell execution.
Features
- Automatically detects Java/Go/Python/Node development commands
- Injects project-level
.opencode/shellrcbefore command execution - Supports SDKMAN, pyenv, nvm, goenv, and more
Installation
- Add to your
opencode.json:
{
"plugin": ["opencode-env-loader"]
}Create
.opencode/shellrcin your project root.Restart OpenCode.
Configuration
Create a .opencode/shellrc file in your project with your environment setup.
See examples/ directory for reference configurations for Java, Go, Python, and Node.
Java Example (.opencode/shellrc)
source "$HOME/.sdkman/bin/sdkman-init.sh"
sdk use java 17.0.18-temPython Example (.opencode/shellrc)
source .venv/bin/activateGo Example (.opencode/shellrc)
export GOENV_ROOT="$HOME/.goenv"
export PATH="$GOENV_ROOT/bin:$PATH"
eval "$(goenv init -)"
goenv local 1.21Node Example (.opencode/shellrc)
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
nvm use 20How It Works
The plugin hooks into tool.execute.before and:
- Detects if the command is a development tool (java, mvn, go, python, npm, etc.)
- If yes, prepends the content of
.opencode/shellrcto the command - Adds an AI prompt to ignore the setup commands
License
MIT
