Repository navigation
fix: report from a Codex session on Windows - #17
Merged
Merged
Conversation
Every hook failed there: `hook exited with code 1` on each event, plus
`invalid stop hook JSON output`, because cmd.exe writes its own error to
stdout and Codex reads a Stop hook's stdout as a decision.
Two causes, both on this side. Codex substitutes `${KEY}` and nothing
else before handing the line to a shell, so the bare $CLAUDE_PLUGIN_ROOT
the Codex registration used only worked because the Unix shell expanded
what Codex had left alone -- `cmd.exe /C` does not. And cmd.exe cannot
execute a .sh at all.
The registration now spells the braced form, the one the Claude Code
registration has always used, and each hook gained a `commandWindows`
handing the same script and the same argument to hooks/win-run.cmd,
which finds Git Bash -- on PATH, then at its default install -- and
exits 0 whether or not it does. Codex prefers `commandWindows` on
Windows and ignores it elsewhere, so one registration still serves both
and nothing about a Unix run changes.
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.
A Codex session on Windows failed every hook this plugin registers —
hook exited with code 1onSessionStart,UserPromptSubmitandStop, plushook returned invalid stop hook JSON outputon top of it. Nothing reached lich, and the errors sat in the user's transcript.Two causes, both on this side.
The plugin root was spelled the one way Codex does not expand. Codex substitutes
${KEY}and nothing else before handing the line to a shell (discovery.rs):hooks/codex-hooks.jsonused the bare$CLAUDE_PLUGIN_ROOT. On Unix that survives by accident — hooks go to$SHELL -lc, and the shell expands what Codex left alone. On Windows they go tocmd.exe /C, which does not, so every hook ran a path that does not exist. Fixed by using the braced form, the onehooks/hooks.jsonhas always used.cmd.exe cannot execute a
.sh. Each hook now also registers acommandWindowshanding the same script and the same argument tohooks/win-run.cmd, which looks for Git Bash — onPATH, then at its default install — and always exits 0, bash or no bash. Codex pickscommandWindowsovercommandon Windows and ignores it everywhere else, so one registration still serves both.The
invalid stop hook JSON outputline was the second symptom of the first cause: cmd.exe writes its error to stdout, and Codex reads a Stop hook's stdout as a decision. The wrapper drops output for that reason too.Nothing about a Unix run changes.
Test plan
node --test tests/*.test.mjs— 129 passcodex-hooks.jsonmay not carry a bare$CLAUDE_PLUGIN_ROOT, and every hook'scommandWindowsmust wrap itscommandthroughwin-run.cmdNot in this PR
docs/providers.mdstill says Codex has noSessionEnd. It has one now — the event is in the currentHookEventsToml— so theidlereport may already be firing. Left alone until it is verified against a real session.