Skip to content

fix(hooks): use getPaiDir() instead of hardcoded ~/.claude paths#1039

Open
MarvinDontPanic wants to merge 1 commit intodanielmiessler:mainfrom
MarvinDontPanic:fix/hooks-use-getpaidir
Open

fix(hooks): use getPaiDir() instead of hardcoded ~/.claude paths#1039
MarvinDontPanic wants to merge 1 commit intodanielmiessler:mainfrom
MarvinDontPanic:fix/hooks-use-getpaidir

Conversation

@MarvinDontPanic
Copy link
Copy Markdown

Summary

Replaces hardcoded join(HOME, '.claude') fallbacks with getPaiDir() from hooks/lib/paths.ts in 4 hooks:

  • LastResponseCache.hook.ts — cache path via getPaiDir()
  • RatingCapture.hook.tsBASE_DIR via getPaiDir()
  • SessionCleanup.hook.tsBASE_DIR via getPaiDir()
  • WorkCompletionLearning.hook.tsBASE_DIR via getPaiDir()

Motivation

Claude Code v2.1.78+ hardened ~/.claude/ as a protected directory, blocking writes even with --dangerously-skip-permissions. Users who set PAI_DIR to install PAI outside ~/.claude/ need hooks to respect that variable.

getPaiDir() already exists in hooks/lib/paths.ts and is used by SecurityValidator, SessionAutoName, RelationshipMemory, KittyEnvPersist, and LoadContext. This completes the migration for the remaining 4 hooks.

Related: #992, #873, #994

Backward Compatible

Yes — getPaiDir() falls back to ~/.claude when PAI_DIR is not set.

Test plan

  • Hooks work with default PAI_DIR=~/.claude
  • Hooks work with custom PAI_DIR=~/pai

🤖 Generated with Claude Code

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant