fix(memory): honor PI_CODING_AGENT_DIR for user-scope memory#166
Merged
tintinweb merged 3 commits intoJul 23, 2026
Merged
Conversation
resolveMemoryDir hardcoded ~/.pi/agent-memory/ for the user scope, ignoring a relocated agent dir (PI_CODING_AGENT_DIR). Every other module already routes through getAgentDir() — memory.ts was the one exception, silently recreating ~/.pi for users who moved their config. - user scope now resolves to <agentDir>/agent-memory/<name> - legacy ~/.pi/agent-memory/<name> is still used (read + write) when it exists and the new location doesn't, so existing memories aren't orphaned - symlinked legacy dirs are ignored (consistent with existing symlink defense) - tests for new resolution, legacy fallback, preference order, and symlink rejection (homedir mocked); README updated
The user-scope tests leaked the real homedir: the legacy ~/.pi/agent-memory fallback check hit actual home state, so they passed only in a clean environment. memory-legacy-fallback.test.ts additionally crashed at import because the hoisted homedir mock returned undefined while pi-coding-agent evaluates getAgentDir() at module load. - default the hoisted homedir mock to a valid string so import-time getAgentDir() no longer throws - mock homedir in memory.test.ts and point it at a temp home so the legacy fallback check is deterministic regardless of the developer's ~/.pi state - drop the vacuous "falls back to legacy" test in memory.test.ts; its real coverage lives in memory-legacy-fallback.test.ts
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.
as someone who likes to keep my dotfiles inside
~/.configit's a bit annoying that the agent-memory feature hardcodes~/.pias the global memory dir. This PR adds behaviour for respecting thePI_CODING_AGENT_DIRdir. Let me know if you have any feedback!Code written by Claude Fable 5. Here's it's PR description: