Skip to content

Hooks commands break on Windows when username contains spaces #477

Closed

Description

@Vincentzpf

Bug Description

The hooks.json in the agentmemory plugin uses unquoted paths for node commands, which breaks on Windows when
the user's home directory contains spaces (e.g., C:\Users\Vincent zhang\).

Root Cause

All node commands in hooks.json are written as:

"command": "node ${CLAUDE_PLUGIN_ROOT}/scripts/stop.mjs"

When CLAUDE_PLUGIN_ROOT expands to a path with spaces (e.g., C:\Users\Vincent
zhang\.claude\plugins\cache\agentmemory\agentmemory\0.9.17), the shell splits on the space, so node tries to load
C:\Users\Vincent as a JavaScript file instead of the full path.

Error Output

Stop hook error: Failed with non-blocking status code: C:\Users\Vincent:1
[06A4:40D8][2025-12-28T15:56:45]i001: Burn v3.14.1.8722, Windows v10.0 (Build 26100: Service Pack 0), path:
C:\WINDOWS\Temp\{25129A09-FB47-4B3E-9CC8-B591F9199C2C}\.cr\VC_redist.x64.exe
^^
SyntaxError: Invalid or unexpected token
    at wrapSafe (node:internal/modules/cjs/loader:1789:18)
    at Module._compile (node:internal/modules/cjs/loader:1830:20)
    ...

Node.js tries to load C:\Users\Vincent as a file, which is a directory, hence the SyntaxError.

Affected File

hooks/hooks.json — all 11 node commands are affected across: SessionStart, UserPromptSubmit, PreToolUse,
PostToolUse, PostToolUseFailure, PreCompact, SubagentStart, SubagentStop, Notification, TaskCompleted, Stop,
SessionEnd.

Fix

Add double quotes around the script path:

"command": "node \"${CLAUDE_PLUGIN_ROOT}/scripts/stop.mjs\""

Compare with the superpowers plugin which already does this correctly:

"command": "\"${CLAUDE_PLUGIN_ROOT}/hooks/run-hook.cmd\" session-start"

Environment

- OS: Windows 11 Pro 10.0.26100
- Plugin version: agentmemory 0.9.17
- Node.js: v26.1.0
---

Activity

  1. added a commit that references this issue on May 19, 2026
    1838f4d
  2. added a commit that references this issue on Jul 27, 2026
    fa24862
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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions