From 2ad7f29adc2557435e7468255a30b857906f1540 Mon Sep 17 00:00:00 2001 From: Dick Swart Date: Sun, 22 Mar 2026 08:19:11 +1300 Subject: [PATCH] Fix PROJECT_DIR path traversal when installed via plugin cache When installed via the Claude Code plugin system, scripts resolve PROJECT_DIR by navigating up 3 levels from their own path. This works when copied into .claude/remember/scripts/ but breaks in the plugin cache (resolves to the cache root instead of the project root). Use CLAUDE_PROJECT_DIR (set by Claude Code for all hooks) with the existing path traversal as a fallback for backwards compatibility. Apply the same fix to PIPELINE_DIR using CLAUDE_PLUGIN_ROOT. session-start-hook.sh already used CLAUDE_PROJECT_DIR correctly; save-session.sh and run-consolidation.sh now match that pattern. Fixes #1 --- scripts/run-consolidation.sh | 7 ++++--- scripts/save-session.sh | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/scripts/run-consolidation.sh b/scripts/run-consolidation.sh index 2bcef2f..b470d2a 100755 --- a/scripts/run-consolidation.sh +++ b/scripts/run-consolidation.sh @@ -13,7 +13,8 @@ # run-consolidation.sh # no arguments needed # # ENVIRONMENT -# (none — PROJECT_DIR is auto-detected from script path) +# CLAUDE_PROJECT_DIR Project root (set by Claude Code; falls back to path traversal) +# CLAUDE_PLUGIN_ROOT Plugin install directory (set by Claude Code) # # DEPENDENCIES # python3, claude CLI (Haiku) @@ -34,8 +35,8 @@ set -e -PROJECT_DIR="$(cd "$(dirname "$0")/../../.." && pwd)" -PIPELINE_DIR="${PROJECT_DIR}/.claude/remember" +PROJECT_DIR="${CLAUDE_PROJECT_DIR:-$(cd "$(dirname "$0")/../../.." && pwd)}" +PIPELINE_DIR="${CLAUDE_PLUGIN_ROOT:-${PROJECT_DIR}/.claude/remember}" source "$(dirname "$0")/log.sh" rotate_logs diff --git a/scripts/save-session.sh b/scripts/save-session.sh index 3f8d6f3..cae4418 100755 --- a/scripts/save-session.sh +++ b/scripts/save-session.sh @@ -54,8 +54,8 @@ set -e trap 'log "error" "FAILED at line $LINENO (exit $?)"' ERR -PROJECT_DIR="$(cd "$(dirname "$0")/../../.." && pwd)" -PIPELINE_DIR="${PROJECT_DIR}/.claude/remember" +PROJECT_DIR="${CLAUDE_PROJECT_DIR:-$(cd "$(dirname "$0")/../../.." && pwd)}" +PIPELINE_DIR="${CLAUDE_PLUGIN_ROOT:-${PROJECT_DIR}/.claude/remember}" source "$(dirname "$0")/log.sh" REMEMBER_TZ=$(config ".timezone" "Europe/Paris")