fix: honor CLAUDE_CONFIG_DIR in hooks (#37)
ponytail-activate.js and ponytail-runtime.js hardcoded ~/.claude for the flag file and settings lookup, ignoring CLAUDE_CONFIG_DIR. Add a shared getClaudeDir() to ponytail-config.js and use it in both. Regression test added to hooks.test.js. Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
6d990f8c54
commit
01578c0cd4
@@ -8,8 +8,7 @@
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const os = require('os');
|
||||
const { getDefaultMode } = require('./ponytail-config');
|
||||
const { getDefaultMode, getClaudeDir } = require('./ponytail-config');
|
||||
const { getPonytailInstructions } = require('./ponytail-instructions');
|
||||
const {
|
||||
clearMode,
|
||||
@@ -18,7 +17,7 @@ const {
|
||||
writeHookOutput,
|
||||
} = require('./ponytail-runtime');
|
||||
|
||||
const claudeDir = path.join(os.homedir(), '.claude');
|
||||
const claudeDir = getClaudeDir();
|
||||
const settingsPath = path.join(claudeDir, 'settings.json');
|
||||
|
||||
const mode = getDefaultMode();
|
||||
|
||||
@@ -50,6 +50,11 @@ function getConfigPath() {
|
||||
return path.join(getConfigDir(), 'config.json');
|
||||
}
|
||||
|
||||
function getClaudeDir() {
|
||||
// ponytail: CLAUDE_CONFIG_DIR overrides ~/.claude, matching Claude Code.
|
||||
return process.env.CLAUDE_CONFIG_DIR || path.join(os.homedir(), '.claude');
|
||||
}
|
||||
|
||||
function getDefaultMode() {
|
||||
// 1. Environment variable (highest priority)
|
||||
const envMode = process.env.PONYTAIL_DEFAULT_MODE;
|
||||
@@ -89,6 +94,7 @@ module.exports = {
|
||||
getDefaultMode,
|
||||
getConfigDir,
|
||||
getConfigPath,
|
||||
getClaudeDir,
|
||||
normalizeMode,
|
||||
normalizeConfigMode,
|
||||
normalizePersistedMode,
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const os = require('os');
|
||||
const { getClaudeDir } = require('./ponytail-config');
|
||||
|
||||
const isCodex = Boolean(process.env.PLUGIN_DATA);
|
||||
const statePath = isCodex
|
||||
? path.join(process.env.PLUGIN_DATA, '.ponytail-active')
|
||||
: path.join(os.homedir(), '.claude', '.ponytail-active');
|
||||
: path.join(getClaudeDir(), '.ponytail-active');
|
||||
|
||||
function setMode(mode) {
|
||||
fs.mkdirSync(path.dirname(statePath), { recursive: true });
|
||||
|
||||
Reference in New Issue
Block a user