Skip to content

fix(hooks): keep the hook protocol channel free of the setup nag - #3614

Open
rhishi99 wants to merge 1 commit into
rtk-ai:developfrom
rhishi99:fix/hook-protocol-stderr-silence
Open

fix(hooks): keep the hook protocol channel free of the setup nag#3614
rhishi99 wants to merge 1 commit into
rtk-ai:developfrom
rhishi99:fix/hook-protocol-stderr-silence

Conversation

@rhishi99

Copy link
Copy Markdown

Problem

rtk hook and rtk rewrite are the hook. The agent that invokes them parses their stdout and stderr as a protocol channel, so an extra line there is corruption, not a diagnostic.

maybe_warn() was allowed to fire for both. On a machine that has Claude Code installed but not the rtk hook, that puts

[rtk] /!\ No hook installed - run `rtk init -g` for automatic token savings

into the protocol stream once a day. Gain was already excluded for exactly this reason; Hook and Rewrite were missed.

This is not theoretical

On such a machine, ten tests in tests/copilot_selfheal_test.rs fail today — every one on the same assertion:

stderr must stay silent (protocol safety) for payload {"tool_name":"Bash",...},
got: [rtk] /!\ No hook installed - run `rtk init -g` ...

CI never sees it because a fresh runner has no ~/.claude at all, so status() returns Ok and the warning never fires. The tests are correct; the nag was leaking into a channel it must never touch.

Fix

Add Commands::Hook and Commands::Rewrite to the same exclusion list Commands::Gain already sits in.

Testing

No new test — copilot_selfheal_test.rs already pins this contract with 12 assertions on stderr silence; they were simply unreachable in CI. Before/after on an affected machine:

before: test result: FAILED. 2 passed; 10 failed
after:  test result: ok.    12 passed;  0 failed

Full suite, cargo fmt --check, and cargo clippy --all-targets clean on x86_64-pc-windows-gnu.

🤖 Generated with Claude Code

`rtk hook` and `rtk rewrite` are the hook. The agent that invokes them
parses their stdout and stderr as a protocol channel, so any extra line
there is corruption, not a diagnostic.

`maybe_warn()` was allowed to fire for them, which meant a developer with
Claude Code installed but without the rtk hook got

    [rtk] /!\ No hook installed - run `rtk init -g` for automatic token savings

emitted mid-protocol once a day. Gain was already excluded for the same
reason; Hook and Rewrite were missed.

This is not theoretical: on such a machine ten tests in
`copilot_selfheal_test.rs` fail today, every one of them on the
`stderr must stay silent (protocol safety)` assertion. CI never sees it
because a fresh runner has no `~/.claude` at all, so `status()` reports
Ok and the warning never fires.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@CLAassistant

CLAassistant commented Aug 20, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants