Files
oh-my-claudecode/scripts
BellmanandClaude Sonnet 4.6 c2fd39507d fix(hooks): avoid sh+find-node.sh on Windows to prevent false hook error labels (closes #899) (#902)
On Windows with MSYS2/Git Bash the sh->find-node.sh->node chain introduced
in v4.3.4 (#892) triggers Claude Code UI bug anthropics/claude-code#17088,
which mislabels every successful hook as an error.  find-node.sh exists solely
to locate node for nvm/fnm users on Unix, where node is not on PATH in
non-interactive shells.  On Windows, node.exe is always on PATH so the sh
wrapper is unnecessary and harmful.

Fix: at setup time, patch hooks.json inside the plugin directory to rewrite
every sh+find-node.sh command to a direct `node` invocation.  The patch is
applied in two places so it fires as early as possible:

1. scripts/plugin-setup.mjs — runs when the plugin is first installed.
2. src/hooks/setup/index.ts processSetupInit — runs on the first SessionStart
   after the plugin is loaded, covering any update that overwrites hooks.json.

The patch is idempotent: already-direct commands are left untouched, and the
file is only written when at least one command is actually changed.

Also exports patchHooksJsonForWindows for direct unit testing, and adds
6 tests in src/hooks/setup/__tests__/windows-patch.test.ts covering the
simple case, trailing args preservation, idempotency, multi-event patching,
and missing-file no-ops.

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-23 18:01:04 +09:00
..