Skip to content

save-session.sh and run-consolidation.sh use wrong PROJECT_DIR when installed via plugin marketplace #5

@luisbarcia

Description

@luisbarcia

Bug

When installed via the Claude Code plugin marketplace, save-session.sh and run-consolidation.sh calculate PROJECT_DIR incorrectly using relative path navigation (dirname "$0")/../../.."), which resolves to the plugin cache directory instead of the actual project root.

Root Cause

Line 57 of save-session.sh and line 37 of run-consolidation.sh:

PROJECT_DIR="$(cd "$(dirname "$0")/../../.." && pwd)"

When installed manually (copied to .claude/remember/scripts/), this resolves correctly:

.claude/remember/scripts/save-session.sh → ../../.. → project root ✓

When installed via marketplace (runs from cache), it resolves to:

~/.claude/plugins/cache/claude-plugins-official/remember/<hash>/scripts/save-session.sh
→ ../../.. → ~/.claude/plugins/cache/claude-plugins-official/ ✗

The hook entry scripts (session-start-hook.sh, post-tool-hook.sh) already use $CLAUDE_PROJECT_DIR correctly, but the background scripts they spawn (save-session.sh, run-consolidation.sh) recalculate from scratch and lose it.

Symptoms

  • now.md never created
  • remember.md stays empty
  • 92% of autonomous save logs are 0 bytes
  • Non-empty logs show: cd: .../claude-plugins-official/.claude/remember: No such file or directory

Second issue: _parse_response in haiku.py

Claude CLI v2.1.86+ with --output-format json returns a list of message objects, not a single dict with a result key. haiku.py:101 calls data.get("result") which fails with AttributeError: 'list' object has no attribute 'get'.

Suggested Fix

save-session.sh and run-consolidation.sh:

PROJECT_DIR="${CLAUDE_PROJECT_DIR:-$(cd "$(dirname "$0")/../../.." && pwd)}"
PIPELINE_DIR="${CLAUDE_PLUGIN_ROOT:-${PROJECT_DIR}/.claude/remember}"

session-start-hook.sh and post-tool-hook.sh (ensure env propagates to subprocesses):

export CLAUDE_PROJECT_DIR="$PROJECT" CLAUDE_PLUGIN_ROOT="$PLUGIN_ROOT"

haiku.py: Handle list response format from CLI v2.1.86+.

Environment

  • Claude Code: 2.1.86
  • macOS Darwin 25.3.0
  • Plugin installed via claude-plugins-official marketplace
  • Python 3.10+

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions