fix(tools): use PAI_DIR env var instead of hardcoded ~/.claude paths#1040
Open
MarvinDontPanic wants to merge 2 commits intodanielmiessler:mainfrom
Open
fix(tools): use PAI_DIR env var instead of hardcoded ~/.claude paths#1040MarvinDontPanic wants to merge 2 commits intodanielmiessler:mainfrom
MarvinDontPanic wants to merge 2 commits intodanielmiessler:mainfrom
Conversation
Add process.env.PAI_DIR fallback to 15 PAI Tools that hardcode ~/.claude as the base directory. Each tool now checks PAI_DIR first, falling back to ~/.claude for backward compatibility. This enables PAI_DIR portability — users can set PAI_DIR to install PAI outside ~/.claude/ (e.g. to work around Claude Code v2.1.78+ sensitive directory protection). Special case: BuildCLAUDE.ts still writes CLAUDE.md to ~/.claude/ since Claude Code reads it from that fixed location, but reads PAI content from PAI_DIR. Tools fixed: ActivityParser, AlgorithmPhaseReport, Banner, BannerMatrix, BannerNeofetch, BannerRetro, BuildCLAUDE, FeatureRegistry, LearningPatternSynthesis, LoadSkillConfig, NeofetchBanner, pai, RebuildPAI, SessionHarvester, SessionProgress. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace hardcoded join(HOME, '.claude') fallbacks with getPaiDir() from hooks/lib/paths.ts in 4 hooks: LastResponseCache, RatingCapture, SessionCleanup, WorkCompletionLearning. This enables PAI_DIR portability — users can set PAI_DIR to install PAI outside ~/.claude/ (e.g. to work around Claude Code v2.1.78+ sensitive directory protection). Complements existing getPaiDir() usage in SecurityValidator, SessionAutoName, RelationshipMemory, KittyEnvPersist, LoadContext. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Summary
Adds
process.env.PAI_DIRfallback to 15 PAI Tools that hardcode~/.claudeas the base directory. Each tool now checksPAI_DIRfirst, falling back to~/.claudefor backward compatibility.Tools fixed: ActivityParser, AlgorithmPhaseReport, Banner, BannerMatrix, BannerNeofetch, BannerRetro, BuildCLAUDE, FeatureRegistry, LearningPatternSynthesis, LoadSkillConfig, NeofetchBanner, pai, RebuildPAI, SessionHarvester, SessionProgress.
Also includes the 4 hook fixes from #1039 (LastResponseCache, RatingCapture, SessionCleanup, WorkCompletionLearning) since the tools branch was built on top of that work.
Motivation
Claude Code v2.1.78+ hardened
~/.claude/as a protected directory. Users who setPAI_DIRoutside~/.claude/need tools to respect that variable. Currently, 15 tools ignorePAI_DIRentirely.Related: #992, #873, #994, #1039
Special case: BuildCLAUDE.ts
BuildCLAUDE.tsreads PAI content fromPAI_DIRbut ALWAYS writesCLAUDE.mdto~/.claude/CLAUDE.mdsince Claude Code reads it from that fixed location.Backward Compatible
Yes — all tools fall back to
~/.claudewhenPAI_DIRis not set.Test plan
PAI_DIR=~/.claudePAI_DIR=~/pai~/.claude/CLAUDE.mdregardless ofPAI_DIR🤖 Generated with Claude Code