@notlebedev/pi-direnv0.2.1
direnv / nix flake dev shell environment integration for the pi coding agent
Untested on omp
This is a pi package. No one has reported whether it works on omp yet. If you try it, add your result below.
Reports 0
No reports yet.
Readme
pi-direnv
A pi extension that loads a project's direnv environment into Pi's bash tool and keeps it up to date as you change your dev shell. Add a package to your Nix flake, reload, and use it without restarting Pi.
What it does
- Loads the project's
.envrcenvironment when a Pi session starts. Like direnv itself,.envrcis discovered by walking up from the session's working directory, and the loaded environment applies to the whole tree rooted at the.envrcdirectory. The agent's bash tool and!/!!commands use it. - Reloads the environment when the dev shell's inputs change. It uses direnv's
own record of the files it tracks (
DIRENV_WATCHES), sowatch_file/watch_direntries and flake inputs are honored without configuration; new packages and variables are available to agent right away. - Reminds the agent when the environment needs reloading. The agent can reload it
automatically, or you can use
/direnv reload. - Provides
/direnvfor status,/direnv reloadto reload, and/direnv allowto approve the.envrcand reload.
Install
Install the published package for your user (all projects):
pi install npm:@notlebedev/pi-direnv
To install for the current project instead (requires project trust):
pi install --local npm:@notlebedev/pi-direnv
Pin a version with @0.2.1, for example
npm:@notlebedev/pi-direnv@0.2.1. You can also add the package to the
packages list in your Pi settings, or install straight from git:
pi install git:github.com/NotLebedev/pi-direnv@v0.2.1
Once published, the package appears in the Pi package gallery.
You need direnv on your PATH, a .envrc in the project root, and an approved
.envrc. Approve it yourself with direnv allow (or /direnv allow in Pi).
The extension never approves .envrc files automatically.
pi-direnv includes a direnv-dev-shell skill for tasks that need a missing
command or require changes to the project's dev shell. It guides the agent to
make minimal shell changes, call direnv_reload, and verify the updated Bash
environment. It also tells the user when a dev-shell file changes and treats
task-only package additions as temporary unless they are needed project-wide.
The skill preserves the explicit .envrc approval boundary. Pi can load it
automatically when relevant; invoke it directly with /skill:direnv-dev-shell
when needed.
Quick start
For a Nix flake project, put this in .envrc:
use flake
Define a dev shell in flake.nix, then approve the environment and start Pi:
direnv allow
pi
Reload workflow
- At session start, pi-direnv loads
.envrcso the agent's bash commands use the project's environment. - You or the agent adds a package or changes dev-shell configuration.
- pi-direnv notices that direnv's tracked inputs changed, marks the environment
stale, and reminds the agent to call
direnv_reload. This tool reloads direnv and injects the updated environment into the bash tool. - The agent can now use the new package in bash, without restarting Pi.
You can also reload manually with /direnv reload. If .envrc changed, approve
it first with /direnv allow.
Compatibility
Another extension that overrides Pi's bash tool can prevent this extension
from applying the environment. If the dev shell is not available in bash, remove
the conflicting extension or make sure pi-direnv loads first; then run
/reload.
Development
Requires Node.js 22.19 or newer. With Nix, enter the provided development shell
using nix develop, then run:
npm install
npm test
npm run typecheck