pub fn build_settings_with_hooks(
user_settings_content: Option<&str>,
user_hooks_content: Option<&str>,
) -> Option<String>Expand description
Build .claude/settings.json content with the auto-injected
PreToolUse Bash hook and PreCompact hooks (under the "hooks"
key). PreToolUse redirects Bash invocations into the streaming
wrapper (agentmux-bashwrap exec); PreCompact (two entries,
matcher "manual" / "auto") pings the sidecar the instant
compaction starts (agentmux-bashwrap precompact) — see
docs/specs/SPEC_COMPACTION_DETECTION_AND_HANDLING_2026_07_31.md
§4.2. User-supplied settings.json (from the agent’s
content_map["settings"]) is parsed and merged at the top level;
user-supplied legacy hooks content (from content_map["hooks"])
is merged into settings.hooks.
File location matters. Claude Code reads project hooks from
<project>/.claude/settings.json under the "hooks" key.
A standalone .claude/hooks.json is NOT a Claude Code
discovery location — that was the v0.33.804 streaming-bug root
cause: the file was written but Claude never read it, so the
PreToolUse hook never fired and live streaming silently failed.
See docs/specs/SPEC_STREAMING_BASH_RUNNER_2026_05_11.md §5
and Claude Code docs: https://code.claude.com/docs/en/hooks.md