If you already use Pi, you can point PiG at the same directories. PiG does not copy or merge anything: with one environment variable it reads and writes Pi's agent directory.
Step 1: prerequisites
- pig 0.7.0 or later (
pig --versionprints0.7.0+1.5.0for the 0.7.0 release). - An existing Pi agent directory:
~/.pi/agentby default, or the directory named byPI_CODING_AGENT_DIR. - Stop any Pi or older PiG process that has a session open before you share its files. Do not edit one session from two processes at once.
Step 2: opt in
Set PIG_USE_PI_DIRS=1 on the command that starts PiG:
PIG_USE_PI_DIRS=1 pigOnly the exact value 1 enables sharing. PiG then uses Pi's agent directory and the project .pi resources. It selects the directory before it reads settings, so the opt-in cannot live inside a settings file. Project trust still applies.
To make it permanent, set it where you set your other environment, or use an alias for the one command:
alias pig='PIG_USE_PI_DIRS=1 pig'Step 3: know what is shared
- Shared mode uses
PI_CODING_AGENT_DIR(or~/.pi/agent) andPI_CODING_AGENT_SESSION_DIR. It ignores the PiG-specificPIG_CODING_AGENT_*overrides.--session-dirstill wins. PIG_HOMEstill selects PiG-owned state: SDK caches, documentation and user Piglets.- PiG's configuration page states that settings, authentication and session formats are compatible with Pi's, that writes to auth, settings, trust and the model-catalog cache use Pi's lock-directory protocol, and that settings writes keep unknown keys. PiG does not write
models.json. - Use Pi-compatible Packages and resources in the shared settings.
Unset the variable to return to separate PiG directories. The shared files stay where they are. The full rules are in Configuration.
Step 4: verify
Run one prompt and look at the Pi directory:
PIG_USE_PI_DIRS=1 pig -p "Say hello"
ls "${PI_CODING_AGENT_DIR:-$HOME/.pi/agent}/sessions"A new session file appears under Pi's sessions directory, and PiG's own state directory (PIG_HOME) stays empty of sessions. The screenshot below is this check with a scripted model.
Related
- Upstream Pi, the reference implementation.
- Editor adapters that look in Pi's directory (pi-acp, Powerline) need the same variable; see Configuration.
