mirror of
https://github.com/JuliusBrussee/caveman.git
synced 2026-08-11 13:21:09 +02:00
fix: respect CLAUDE_CONFIG_DIR env var across all hooks
All hook files hardcoded ~/.claude as the Claude config directory. Users who set CLAUDE_CONFIG_DIR (e.g. for XDG compliance) had hooks writing to the wrong location. Now all hooks check CLAUDE_CONFIG_DIR first, falling back to ~/.claude. Closes #140
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
// caveman — Claude Code SessionStart activation hook
|
||||
//
|
||||
// Runs on every session start:
|
||||
// 1. Writes flag file at ~/.claude/.caveman-active (statusline reads this)
|
||||
// 1. Writes flag file at $CLAUDE_CONFIG_DIR/.caveman-active (statusline reads this)
|
||||
// 2. Emits caveman ruleset as hidden SessionStart context
|
||||
// 3. Detects missing statusline config and emits setup nudge
|
||||
|
||||
@@ -11,7 +11,7 @@ const path = require('path');
|
||||
const os = require('os');
|
||||
const { getDefaultMode } = require('./caveman-config');
|
||||
|
||||
const claudeDir = path.join(os.homedir(), '.claude');
|
||||
const claudeDir = process.env.CLAUDE_CONFIG_DIR || path.join(os.homedir(), '.claude');
|
||||
const flagPath = path.join(claudeDir, '.caveman-active');
|
||||
const settingsPath = path.join(claudeDir, 'settings.json');
|
||||
|
||||
@@ -54,7 +54,7 @@ const modeLabel = mode === 'wenyan' ? 'wenyan-full' : mode;
|
||||
|
||||
// Read SKILL.md — the single source of truth for caveman behavior.
|
||||
// Plugin installs: __dirname = <plugin_root>/hooks/, SKILL.md at <plugin_root>/skills/caveman/SKILL.md
|
||||
// Standalone installs: __dirname = ~/.claude/hooks/, SKILL.md won't exist — falls back to hardcoded rules.
|
||||
// Standalone installs: __dirname = $CLAUDE_CONFIG_DIR/hooks/, SKILL.md won't exist — falls back to hardcoded rules.
|
||||
let skillContent = '';
|
||||
try {
|
||||
skillContent = fs.readFileSync(
|
||||
@@ -137,7 +137,7 @@ try {
|
||||
output += "\n\n" +
|
||||
"STATUSLINE SETUP NEEDED: The caveman plugin includes a statusline badge showing active mode " +
|
||||
"(e.g. [CAVEMAN], [CAVEMAN:ULTRA]). It is not configured yet. " +
|
||||
"To enable, add this to ~/.claude/settings.json: " +
|
||||
"To enable, add this to " + path.join(claudeDir, 'settings.json') + ": " +
|
||||
statusLineSnippet + " " +
|
||||
"Proactively offer to set this up for the user on first interaction.";
|
||||
}
|
||||
|
||||
@@ -7,7 +7,8 @@ const path = require('path');
|
||||
const os = require('os');
|
||||
const { getDefaultMode } = require('./caveman-config');
|
||||
|
||||
const flagPath = path.join(os.homedir(), '.claude', '.caveman-active');
|
||||
const claudeDir = process.env.CLAUDE_CONFIG_DIR || path.join(os.homedir(), '.claude');
|
||||
const flagPath = path.join(claudeDir, '.caveman-active');
|
||||
|
||||
let input = '';
|
||||
process.stdin.on('data', chunk => { input += chunk; });
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
$Flag = Join-Path $HOME ".claude/.caveman-active"
|
||||
$ClaudeDir = if ($env:CLAUDE_CONFIG_DIR) { $env:CLAUDE_CONFIG_DIR } else { Join-Path $HOME ".claude" }
|
||||
$Flag = Join-Path $ClaudeDir ".caveman-active"
|
||||
if (-not (Test-Path $Flag)) {
|
||||
exit 0
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
# Plugin users: Claude will offer to set this up on first session.
|
||||
# Standalone users: install.sh wires this automatically.
|
||||
|
||||
FLAG="$HOME/.claude/.caveman-active"
|
||||
FLAG="${CLAUDE_CONFIG_DIR:-$HOME/.claude}/.caveman-active"
|
||||
[ ! -f "$FLAG" ] && exit 0
|
||||
|
||||
MODE=$(cat "$FLAG" 2>/dev/null)
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ if (-not (Get-Command node -ErrorAction SilentlyContinue)) {
|
||||
exit 1
|
||||
}
|
||||
|
||||
$ClaudeDir = Join-Path $env:USERPROFILE ".claude"
|
||||
$ClaudeDir = if ($env:CLAUDE_CONFIG_DIR) { $env:CLAUDE_CONFIG_DIR } else { Join-Path $env:USERPROFILE ".claude" }
|
||||
$HooksDir = Join-Path $ClaudeDir "hooks"
|
||||
$Settings = Join-Path $ClaudeDir "settings.json"
|
||||
$RepoUrl = "https://raw.githubusercontent.com/JuliusBrussee/caveman/main/hooks"
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@ if ! command -v node >/dev/null 2>&1; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
CLAUDE_DIR="$HOME/.claude"
|
||||
CLAUDE_DIR="${CLAUDE_CONFIG_DIR:-$HOME/.claude}"
|
||||
HOOKS_DIR="$CLAUDE_DIR/hooks"
|
||||
SETTINGS="$CLAUDE_DIR/settings.json"
|
||||
REPO_URL="https://raw.githubusercontent.com/JuliusBrussee/caveman/main/hooks"
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ param()
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
$ClaudeDir = Join-Path $env:USERPROFILE ".claude"
|
||||
$ClaudeDir = if ($env:CLAUDE_CONFIG_DIR) { $env:CLAUDE_CONFIG_DIR } else { Join-Path $env:USERPROFILE ".claude" }
|
||||
$HooksDir = Join-Path $ClaudeDir "hooks"
|
||||
$Settings = Join-Path $ClaudeDir "settings.json"
|
||||
$FlagFile = Join-Path $ClaudeDir ".caveman-active"
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
# or: bash <(curl -s https://raw.githubusercontent.com/JuliusBrussee/caveman/main/hooks/uninstall.sh)
|
||||
set -e
|
||||
|
||||
CLAUDE_DIR="$HOME/.claude"
|
||||
CLAUDE_DIR="${CLAUDE_CONFIG_DIR:-$HOME/.claude}"
|
||||
HOOKS_DIR="$CLAUDE_DIR/hooks"
|
||||
SETTINGS="$CLAUDE_DIR/settings.json"
|
||||
FLAG_FILE="$CLAUDE_DIR/.caveman-active"
|
||||
|
||||
Reference in New Issue
Block a user