mirror of
https://github.com/instructkr/claw-code.git
synced 2026-04-14 12:04:49 +08:00
Malformed hook stdout that looks like JSON was collapsing into low-signal failure text during hook execution. This change preserves plain-text hook feedback for normal text hooks, but upgrades malformed JSON-like output into an explicit hook_invalid_json diagnostic that includes phase, tool, command, and bounded stdout/stderr previews. It also adds a regression test for malformed-but-nonempty output. Constraint: User scoped the implementation to rust/crates/runtime/src/hooks.rs and tests only Constraint: Existing plain-text hook feedback must remain intact for non-JSON hook output Rejected: Treat every non-JSON stdout payload as invalid JSON | would break legitimate plain-text hook feedback Confidence: high Scope-risk: narrow Directive: Keep malformed-hook diagnostics bounded and preserve the plain-text fallback for hooks that intentionally emit text Tested: cargo test --manifest-path rust/Cargo.toml -p runtime hooks::tests:: -- --nocapture Tested: cargo test --manifest-path rust/Cargo.toml -p runtime -- --nocapture Tested: cargo clippy --manifest-path rust/Cargo.toml -p runtime --all-targets -- -D warnings Not-tested: Full workspace clippy/test sweep outside runtime crate