Expand description
hook subcommand.
Reads a PreToolUse JSON event on stdin (the contract Claude Code
uses for hooks: see docs/specs/SPEC_STREAMING_BASH_RUNNER_2026_05_11.md
§5). If the event is a Bash invocation whose command hasn’t
already been wrapped, emit an updatedInput.command that invokes
agentmux-bashwrap exec with the original command base64-encoded
into argv. Idempotent — if the command is already wrapped, pass
through with no rewrite.
All errors degrade to a pass-through response so a hook failure never blocks Claude’s tool execution.
Structs§
- PreTool
UseInput 🔒 - Subset of the PreToolUse payload we care about. Extra fields are ignored (serde default).
- Scan
Result 🔒
Enums§
- OutKind 🔒
Constants§
Functions§
- build_
response - Build the hook response for a PreToolUse payload. Public for testability — callers in tests feed in a payload string and assert the response shape without going through stdin.
- is_
dev_ 🔒null - Strip one layer of matching surrounding quotes for the
/dev/nullcheck. - is_
space 🔒 - passthrough 🔒
- read_
word 🔒 - Read one shell word (quote-aware) starting at/after
from, skipping leading spaces. Returns the word’s byte range, or None if there’s no word. - record_
response - The hook’s response when the CLI’s shell prefix is this wrapper: record the Bash call for the prefix process to claim (prefix.rs), and answer nothing, so the CLI runs the call exactly as the model made it, its permission rules and checks included. A call that can’t be recorded still runs; it just isn’t streamed. docs/specs/SPEC_BASH_STREAMING_VIA_SHELL_PREFIX_2026_10_10.md §2.2.
- run_
pretooluse_ bash - scan_
redirect 🔒 - Quote/group-aware scan for a single top-level trailing output redirect. Returns None on any bail condition (see the module comment above).
- shell_
quote 🔒 - Quote a value for embedding in a shell argv position.
- skip_
spaces 🔒 - tee_
redirect_ 🔒rewrite - Rewrite a recognized trailing redirect to a
teepipeline, orNoneto pass the command through unchanged.