fix: honor PI_CODING_AGENT_DIR env override for Pi paths#74
Merged
Conversation
Pi uses a single agent directory (`~/.pi/agent`) and does not use XDG. The base dir can be overridden with the PI_CODING_AGENT_DIR env var (tilde-expanded, including ~\ on Windows). Previous code hardcoded ~/.pi/agent for Pi auth, settings, and SYSTEM.md, ignoring the env override. It also used string concatenation for the Pi auth path, producing mixed separators on Windows. Changes: - Add Pi path resolvers to xdg-paths.ts (getPiAgentDir, getPiAuthPath, getPiSettingsPath) - Add expandTilde helper for PI_CODING_AGENT_DIR tilde expansion - Update pi.ts to use new resolvers for settings.json and SYSTEM.md paths - Update auth-sync.ts to use getPiAuthPath instead of string concatenation - Add comprehensive tests for xdg-paths.ts (21 tests) All 244 tests pass.
e4d070c to
0887f56
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The CLI hardcoded Pi's agent directory as
~/.pi/agent, ignoring thePI_CODING_AGENT_DIRenv override that Pi supports. It also used string concatenation with forward slashes for the Pi auth path, which produces mixed path separators on Windows.Pi resolves its agent dir via
getAgentDir()insrc/config.ts:PI_CODING_AGENT_DIR(tilde-expanded, including~\on Windows)homedir() + /.pi/agentChanges
Updated:
src/commands/code/xdg-paths.tsgetPiAgentDir(homeDir)— honorsPI_CODING_AGENT_DIRwith tilde expansiongetPiAuthPath(homeDir)—agentDir/auth.jsongetPiSettingsPath(homeDir)—agentDir/settings.jsonexpandTilde()helper handling~/,~\, and bare~Updated:
src/commands/code/pi.ts— uses new resolvers for settings.json and SYSTEM.mdUpdated:
src/commands/code/auth-sync.ts— usesgetPiAuthPath()instead of string concatNew:
src/commands/code/__tests__/xdg-paths.test.ts— 21 tests covering all Pi and OpenCode path resolution pathsVerification
All 244 tests pass.
Checklist
PI_CODING_AGENT_DIRif set (tilde-expanded), elsehomedir + /.pi/agent<agentDir>/settings.jsonPI_CODING_AGENT_DIR%APPDATA%or%LOCALAPPDATA%on Windows