Repository navigation
fix(plugin): give hooks the event on stdin, cap the input variable - #491
Merged
Merged
Conversation
Two ways hooks failed for reasons outside the hook: - WHYCODES_TOOL_INPUT carried the whole tool input. A `write` past one environment string (128 KiB on Linux, 32K chars on Windows) made the spawn fail, so a block_on_failure pre_tool hook refused every large write and a transform hook was silently skipped. The variable is now cut at 16K chars. - stdin was null. Hooks written for other tools read the event as JSON from stdin, and failed on an empty one. stdin now carries the event as one JSON object with the full tool input, fed alongside the wait so a hook that never reads it neither stalls nor errors. Co-Authored-By: Claude Opus 5.5 <[email protected]>
mrnasil
enabled auto-merge (squash)
November 25, 2026 15:04
Merged
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.
Hooks failed in two ways that had nothing to do with the hook itself.
Large tool input broke the spawn.
WHYCODES_TOOL_INPUTcarried the whole tool input. Awritelarger than one environment string (128 KiB on Linux, 32K chars on Windows) made the spawn fail with exit -1. Ablock_on_failurepre_tool hook then refused every large write, and apre_tool_transformhook was silently skipped. The variable is now cut at 16K chars.stdin was null. Hooks written for other tools, including the ones
importbrings in, read the event as JSON from stdin and failed on an empty one. stdin now carries one JSON object:hook_event_name,cwd,session_id;tool_name,tool_use_idand the fulltool_input;tool_is_errorandtool_output;WHYCODES_prefix (prompt, …).The payload is written alongside the wait for the hook to exit. A hook that never reads stdin does not stall, and its broken pipe is only logged at debug level.
docs/config.mdanddocs/guide.mddescribe stdin and the 16K cut. The plugin crate gains the tokioio-utilandmacrosfeatures.Tests:
cats stdin gets the JSON;writeinput no longer blocks ablock_on_failurehook.hooks.rshas 100% line coverage on Linux (WSL), and the tests pass on Windows.🤖 Generated with Claude Code