Skip to content

Bug: auto_memory_project_key() generates wrong path on Windows/MINGW #16

@josheee1117

Description

@josheee1117

Summary

On Windows (Git Bash / MINGW64), auto_memory_project_key() in _lib.sh generates a project key that does not match Claude Code's actual ~/.claude/projects/<key>/ directory name. This causes Pensieve to create a duplicate project directory and write MEMORY.md to the wrong location.

Environment

  • OS: Windows 10/11 (MINGW64_NT)
  • Shell: Git Bash (MSYS2)
  • Pensieve version: 0.5.16

Root Cause

auto_memory_project_key() (line 69 of tools/loop/scripts/_lib.sh) calls to_posix_path() before encoding, which:

  1. Lowercases the drive letter: D:/d (Claude Code preserves original case)
  2. Only replaces / with -: misses _- replacement

Current code

auto_memory_project_key() {
    local pr
    pr="$(to_posix_path "$(project_root)")"  # Bug: converts to POSIX first
    ...
    encoded="${pr//\//-}"       # Bug: only replaces /
    ...
}

Result comparison (example path D:\my_project\app)

Key generated Correct?
Claude Code D--my-project-app
Pensieve -d-my_project-app

This creates a duplicate directory under ~/.claude/projects/, and MEMORY.md is written to the wrong one — making it invisible to Claude Code.

Fix

Replace the POSIX-based encoding with direct character substitution that matches Claude Code's algorithm:

auto_memory_project_key() {
    local pr
    pr="$(project_root)"  # Use raw path, do NOT convert to POSIX
    [[ -n "$pr" ]] || {
        echo ""
        return 0
    }

    local encoded
    # Match Claude Code's project key encoding:
    # Replace : / \ with -
    encoded="${pr//[:\/\]/-}"
    # Replace _ with -
    encoded="${encoded//_/-}"
    echo "$encoded"
}

Verified

After applying the fix, the generated key matches Claude Code's actual directory name. scan-structure.sh passes with Status: aligned, MUST_FIX: 0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions