Skip to content

Windows compatibility: 4 bugs prevent auto-save pipeline from working #6

Closed

Description

@sixside

Summary

The remember plugin's auto-save pipeline (PostToolUse hook -> save-session.sh -> Haiku summarization) silently fails on Windows. Four independent bugs combine to make the pipeline completely non-functional. The SessionStart hook and /remember skill work fine since they don't hit the same code paths.

Environment

  • Windows 11 Pro
  • Claude Code CLI (bash shell via Git Bash)
  • Python 3.13
  • Plugin version 0.1.0

Bugs

1. save-session.sh and run-consolidation.sh compute wrong PROJECT_DIR

Both scripts use:

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

This resolves relative to the script's location in the plugin cache (~/.claude/plugins/cache/claude-plugins-official), not the actual project directory. The session-start-hook.sh correctly uses CLAUDE_PROJECT_DIR, but these two scripts don't.

Fix: Use CLAUDE_PROJECT_DIR (and pass it via env vars from the calling hooks since nohup background processes need it explicitly):

PROJECT_DIR="${CLAUDE_PROJECT_DIR:-.}"
PIPELINE_DIR="${CLAUDE_PLUGIN_ROOT:-$(cd "$SCRIPT_DIR/.." && pwd)}"

2. Wrong session directory slug algorithm

All three shell scripts and extract.py use tr '/' '-' (or .replace("/", "-") in Python) to generate the project slug for finding JSONL session files. On Windows, paths use backslashes and colons (C:\Users\...), so this produces C:-Users-primemate-Solutions-_General.

Claude Code actually generates slugs like C--Users-primemate-Solutions--General -- it replaces all non-alphanumeric characters (not just /) with -.

Fix (shell):

SESSION_DIR="$HOME/.claude/projects/$(echo "$PROJECT" | sed 's/[^a-zA-Z0-9-]/-/g')"

Fix (Python, extract.py _session_dir):

import re
slug = re.sub(r'[^a-zA-Z0-9-]', '-', project_dir)
return os.path.expanduser("~/.claude/projects/" + slug)

3. PIPELINE_DIR points to wrong location

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

PIPELINE_DIR="${PROJECT_DIR}/.claude/remember"

But the pipeline module is in the plugin cache, not in the project's .claude/remember/ directory. Should use CLAUDE_PLUGIN_ROOT.

4. Python open() calls lack UTF-8 encoding

Windows Python defaults to cp1252 encoding. The JSONL session files contain UTF-8 characters, causing UnicodeDecodeError in extract.py's count_lines(), extract_messages(), and get_last_save_line(). Multiple open() calls in shell.py and prompts.py have the same issue.

Fix: Either add encoding="utf-8" to all open() calls, or set export PYTHONUTF8=1 in the shell scripts before calling Python.

Affected files

  • scripts/save-session.sh (bugs 1, 3)
  • scripts/run-consolidation.sh (bugs 1, 3)
  • scripts/post-tool-hook.sh (bug 2, also needs to pass env vars to nohup)
  • scripts/session-start-hook.sh (bug 2, also needs to pass env vars to background calls)
  • pipeline/extract.py (bugs 2, 4)
  • pipeline/shell.py (bug 4)
  • pipeline/prompts.py (bug 4)

Result

After patching all four bugs locally, the full pipeline works: extraction, Haiku summarization, now.md creation, NDC compression to today-*.md, and position tracking via last-save.json.

Activity

  1. fdaviddpt commented on Mar 30, 2026

    @fdaviddpt
    Contributor

    Fixed in v0.2.0 (commit 22fd949). All four bugs addressed:

    1. ✅ PROJECT_DIR — was fixed in PR Fix PROJECT_DIR path traversal when installed via plugin cache #2 (March 23), but marketplace pins to install-time commit
    2. ✅ Path slug — tr '/' '-' replaced with sed 's/[^a-zA-Z0-9]/-/g' across all 4 scripts
    3. ✅ PIPELINE_DIR — was fixed in PR Fix PROJECT_DIR path traversal when installed via plugin cache #2 alongside PROJECT_DIR
    4. ✅ Python encoding — encoding="utf-8" added to all open() calls (~20 sites)

    To update: we've submitted the updated version to Anthropic's marketplace. Once they approve it, run /plugin in Claude Code, find "remember", and reinstall it.

    In the meantime, you can install directly from the repo to get the fix now:

    1. Uninstall the marketplace version via /plugin
    2. Clone https://github.com/Digital-Process-Tools/claude-remember into your project's .claude/remember/ directory
    3. Follow the manual setup in the README

    Thanks for the thorough diagnosis — you basically wrote the fix for us.

  2. sixside commented on Mar 30, 2026

    @sixside
    Author

    The v0.2.0 commit (22fd949) fixed 3 of the 4 bugs listed here but missed one.

    pipeline/haiku.py:72 still has cwd="/tmp" in call_haiku(). On Windows, Python's subprocess.run() doesn't resolve /tmp the way Git Bash does, so it throws NotADirectoryError: [WinError 267]. This kills the entire consolidation pipeline — recent.md, archive.md, and core-memories.md never get generated.

    The shell scripts (save-session.sh, run-consolidation.sh) use cd /tmp && which works fine under Git Bash. It's only the Python cwd="/tmp" that breaks.

    Fix is one line in haiku.py:

    # line 72, change:
    cwd="/tmp",
    # to:
    cwd=os.environ.get("TEMP", os.environ.get("TMPDIR", "/tmp")),
  3. fdaviddpt commented on Mar 30, 2026

    @fdaviddpt
    Contributor

    Fixed the remaining cwd="/tmp" bug in pipeline/haiku.py (commit 618fc72). Now uses tempfile.gettempdir() which returns the platform-appropriate temp directory. All Python /tmp references are resolved — the shell script ones work fine under Git Bash.

  4. fdaviddpt commented on Mar 30, 2026

    @fdaviddpt
    Contributor

    Thanks @sixside for the detailed report — great catch on the Python vs Git Bash distinction. Wouldn't have found this without your analysis.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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