Skip to content

[Bug] Windows: Memory not saved on /compact (missing SessionEnd hook + bun-runner.js path issue) #1202

@XCZ-XieJunHao

Description

@XCZ-XieJunHao

Bug Description

CC-Mem plugin fails to save memory on Windows when using /compact command due to two issues:

  1. Missing SessionEnd hook - The hooks.json only has Stop hook, not SessionEnd hook
  2. bun-runner.js cannot find npm-installed Bun - Only checks ~/.bun/bin/bun.exe, but npm installs to %APPDATA%\npm\node_modules\bun\bin\bun.exe

Steps to Reproduce

  1. Install Bun via npm: npm install -g bun
  2. Install CC-Mem plugin
  3. Use Claude Code and run /compact command
  4. Check database timestamp: ls -la ~/.claude-mem/claude-mem.db*
  5. Database is not updated

Expected Behavior

After running /compact, the memory should be saved to database and timestamps should be updated.

Environment

  • Claude-mem version: 10.3.1
  • Claude Code version: 2.1.50
  • OS: Windows 11
  • Platform: win32

Root Cause

Issue 1: Missing SessionEnd Hook

File: ~/.claude/plugins/cache/thedotmack/claude-mem/10.3.1/hooks/hooks.json

The SessionEnd hook is missing, which is triggered by /compact command. Only Stop hook exists.

Issue 2: bun-runner.js Path Detection

File: ~/.claude/plugins/cache/thedotmack/claude-mem/10.3.1/scripts/bun-runner.js

The findBun() function only checks:

  • ~/.bun/bin/bun.exe (official installer)
  • PATH (returns shell script on Windows via npm)

But npm installs Bun to: %USERPROFILE%\AppData\Roaming\npm\node_modules\bun\bin\bun.exe

Proposed Fix

1. Add SessionEnd hook to hooks.json

"SessionEnd": [
  {
    "hooks": [
      {
        "type": "command",
        "command": "node \"\/scripts/bun-runner.js\" \"\/scripts/worker-service.cjs\" start",
        "timeout": 60
      },
      {
        "type": "command",
        "command": "node \"\/scripts/bun-runner.js\" \"\/scripts/worker-service.cjs\" hook claude-code summarize",
        "timeout": 120
      },
      {
        "type": "command",
        "command": "node \"\/scripts/bun-runner.js\" \"\/scripts/worker-service.cjs\" hook claude-code session-complete",
        "timeout": 30
      }
    ]
  }
]

2. Update bun-runner.js findBun() function

const bunPaths = IS_WINDOWS
  ? [
      join(homedir(), '.bun', 'bin', 'bun.exe'),
      join(homedir(), 'AppData', 'Roaming', 'npm', 'node_modules', 'bun', 'bin', 'bun.exe')  // Add this line
    ]
  : [...]

Also modify to check known paths first on Windows (not PATH which contains shell scripts).

Workaround

Manually edit the files mentioned above in ~/.claude/plugins/cache/thedotmack/claude-mem/10.3.1/ and restart Claude Code.

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