fix(utils): convert Windows hook path backslashes to forward slashes - #542
Merged
uladzislausvetlakou merged 3 commits intoSep 7, 2026
Conversation
Migration 006 rewrote installed Claude/Gemini hook commands to the
absolute codemie binary path but preserved Windows backslashes. When
Claude Code executes hooks via bash (Git Bash on Windows), every
\X sequence in the path is consumed as an escape — the path collapses
to gibberish and every hook fails with:
/usr/bin/bash: line 1: C:UserspavelAppDataRoamingnpmcodemie:
command not found
resolveCodemieBinary() now normalizes all Windows paths to forward
slashes on every return branch (getCommandPath, argv1, and the
node + .js Windows fallback). No-op on POSIX where paths never have
backslashes.
Refs: EPMCDME-14762
Raise all hook timeouts to 10 s (Claude: seconds unit; Gemini: ms unit) so slow-starting codemie hook processes are not killed prematurely on Windows where process startup is measurably slower. Refs: EPMCDME-14762 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
A replace-all edit for 3000→10000 ms accidentally matched the substring inside 30000, producing 100000 ms. Correct value is 30000 ms (30 s), which was intentional in the original file. Refs: EPMCDME-14762 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes Claude Code hook errors on Windows where every hook (SessionStart, Stop, UserPromptSubmit, etc.) failed with
command not foundafter migration 006 rewrote hooks.json.Refs: EPMCDME-14762
Root Cause
Migration 006 (
006-resolve-hook-command-paths) rewrites installed Claude/Gemini hook commands to the absolute codemie binary path. On Windows,resolveCodemieBinary()returned Windows-style paths with backslashes (e.g.C:\Users\pavel\AppData\Roaming\npm\codemie).When Claude Code executes hooks via bash (Git Bash on Windows), every
\Xsequence in the path is consumed as a shell escape — the path collapses to garbage and the hook fails:Changes
src/utils/hook-command.ts: addedtoForwardSlash()helper; applied on every branch ofresolveCodemieBinary()(getCommandPathresult,argv1fallback,node + .jsWindows fallback withprocess.execPath).src/utils/__tests__/hook-command.test.ts: updated the Windows.jsfallback assertion; added two new cases covering forward-slash conversion ofgetCommandPathoutput (with and without spaces).No changes on POSIX — paths never contain backslashes there, so
toForwardSlash()is a no-op.Testing
src/utils/__tests__/hook-command.test.ts(11 cases, all pass) andsrc/migrations/__tests__/006-resolve-hook-command-paths.migration.test.ts(4 cases, all pass) — 15/15 green.C:\Users\...\codemie.cmd, bash execution →command not found, exit 127.C:/Users/.../codemie.cmd, bash execution → exit 0.Checklist
lint-staged,typecheck, targeted vitest)main