@pi-lab/env
Global environment loader extension for pi coding agent
Package details
Install @pi-lab/env from npm and Pi will load the resources declared by the package manifest.
$ pi install npm:@pi-lab/env- Package
@pi-lab/env- Version
1.1.0- Published
- Nov 2, 2026
- Downloads
- 486/mo · 151/wk
- Author
- cheny341
- License
- MIT
- Types
- extension
- Size
- 15.5 KB
- Dependencies
- 2 dependencies · 1 peer
Pi manifest JSON
{
"extensions": [
"./src/index.ts"
]
}Security note
Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.
README
@pi-lab/env 
Load environment variables for pi from settings and dotenv files.
Install
pi install npm:@pi-lab/env
Usage
Add an env block to ~/.pi/agent/settings.json:
{
"env": {
"OPENAI_API_KEY": "${OPENAI_KEY_PROD}",
"ANTHROPIC_BASE_URL": "https://${GATEWAY_HOST}/anthropic",
"HTTP_PROXY": "http://${PROXY_HOST:-127.0.0.1}:7890"
}
}
You can also use ~/.pi/agent/.env. The legacy ~/.pi/agent/pi-lab/.env
location is used when .env is absent. Set PI_CODING_AGENT_DIR to use a
different agent directory for all global files.
Trusted projects can add or override values in .pi/settings.json. Project
settings are ignored unless Pi confirms trust. Restart pi after editing files.
Variable references
In settings values:
${VAR}uses an existing environment variable. If missing, it stays literal and warns without logging values.${VAR:-default}uses the literal default when the variable is missing or empty.$${VAR}produces the literal text${VAR}.
References use environment values present when this extension loads, not values
it subsequently loads from settings or dotenv. Variable names must match
[A-Za-z_][A-Za-z0-9_]*. No nested expressions, recursive expansion, or command
execution. Dotenv parsing is unchanged.
Loading and precedence
Existing environment variables take priority, followed by trusted project settings, global settings, then dotenv. Values changed or deleted by another extension are left alone.
Put @pi-lab/env before packages that need these variables during startup.
Global values load early; project values load when the session starts and cannot
change tools already registered. Reload preserves existing process values.