Skip to content

fix(gain): stop warning "No hook installed" at non-Claude agents - #3961

Closed
locoholy wants to merge 1 commit into
rtk-ai:developfrom
locoholy:fix/hook-check-all-agents
Closed

locoholy wants to merge 1 commit into
rtk-ai:developfrom
locoholy:fix/hook-check-all-agents

Conversation

@locoholy

@locoholy locoholy commented Sep 9, 2026

Copy link
Copy Markdown

Summary

  • hook_check::status() only inspects Claude Code, so rtk gain tells anyone on Codex, Gemini, Cursor, Droid, Hermes or Vibe that no hook is installed — forever — while their integration is working fine.
  • other_integration_installed already existed for exactly this, but only under #[cfg(test)]. Production never called it.
  • This promotes it, has status() consult it before reporting Missing, and adds the integrations that appeared after it was written.

The bug, as a user sees it

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

The hook is installed — just not for Claude Code. status() resolves ~/.claude, finds no RTK hook there, and reports Missing. But a ~/.claude directory only means Claude Code has been run on this machine at some point; it says nothing about which agent the user actually works in. The suggested remedy (rtk init -g) targets an agent they may not use, so following it does not clear the warning either.

Measured on a machine with the Gemini hook installed and no Claude hook:

released 0.48.0 → [rtk] /!\ No hook installed — run `rtk init -g` …
this build      → (nothing)

Why the tests did not catch it

other_integration_installed sat inside the #[cfg(test)] module with four green tests behind it. Those tests only ever proved that a helper nothing calls behaves correctly. Moving it into production is most of this diff.

While moving it I checked the list against the integrations RTK actually ships today: Factory Droid (~/.factory/hooks.json) and Mistral Vibe (~/.vibe/hooks.toml) were missing, so their users were in exactly the same position. Codex's hooks.json is listed alongside its AGENTS.md.

Design notes

Detection keys on RTK's own artifacts, not on agents being present. A machine with Codex installed but RTK not wired into it should still get the warning — that user genuinely has no hook. test_other_integration_ignores_unrelated_files pins this: dropping ~/.codex/config.toml, ~/.cursor/mcp.json and ~/.gemini/settings.json into a home directory does not count as an integration.

A new test walks the artifact list itself (test_other_integration_detects_every_listed_artifact), so an integration added later that forgets to register here fails in CI rather than in a user's terminal — which is how this drifted in the first place.

any_other_integration_installed returns Option<bool> so an unresolvable home directory stays distinguishable from a resolved one with nothing in it. The caller treats "don't know" as "keep the existing behaviour" rather than silently suppressing the warning.

AGENTS_MD moved from a private const in init.rs to pub(super) so hook_check can share it instead of re-declaring the literal.

Scope

Only the false warning. Not touched, found while working here and happy to send separately: HookCommands::Check discards its --agent argument in src/main.rs, so rtk hook check --agent anything returns the generic rewrite regardless of the agent named.

Test plan

  • cargo fmt --all && cargo clippy --all-targets -- -D warnings && cargo test — clean; 3398 tests pass
  • New: every artifact in the detection list is exercised; Droid/Vibe/Codex-hook regressions pinned; unrelated agent config files confirmed not to count
  • Manual: rtk gain on a machine with a Gemini hook and no Claude hook — released binary warns, this build does not

`hook_check::status()` only ever inspected Claude Code. The presence of a
`~/.claude` directory means Claude Code has been run on the machine, not
that it is the agent in use — so a user whose agent is Codex, Gemini,
Cursor, Droid, Hermes or Vibe got

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

on every `rtk gain`, forever, with a remedy aimed at an agent they do not
use. Their working integration was invisible to the check.

A helper for exactly this already existed — `other_integration_installed`
— but only inside `#[cfg(test)]`, so production never called it and its
green tests proved nothing about the warning users actually see. This
promotes it out of the test module, has `status()` consult it before
reporting `Missing`, and extends it to the integrations added since it
was written: Factory Droid's `hooks.json` and Mistral Vibe's `hooks.toml`
were both invisible.

Detection keys on RTK's own installed artifacts, never on an agent's
config directory existing, so a machine with Codex installed but RTK not
wired into it still gets the warning it should. A new test walks the
artifact list itself, so an integration added later that forgets to
register here fails in CI rather than in a user's terminal.

Measured on a machine with the Gemini hook installed and no Claude hook:
released 0.48.0 prints the warning, this build prints nothing.
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@rtk-wshm-sync-bot rtk-wshm-sync-bot Bot added bug Something isn't working hook-check false-positive labels Sep 9, 2026
@rtk-wshm-sync-bot

Copy link
Copy Markdown

wshm · Automated triage by AI

📊 Automated PR Analysis

🐛 Type bug-fix
🟢 Risk low

Summary

Fixes rtk gain incorrectly warning 'No hook installed' for users on non-Claude agents (Codex, Gemini, Cursor, Droid, Hermes, Vibe) whose hooks are actually installed. Promotes the previously test-only other_integration_installed helper to production use in hook_check::status(), and adds detection for Factory Droid and Mistral Vibe integrations that were missing from the artifact list.

Review Checklist

  • Tests present
  • Breaking change
  • Docs updated

Analyzed automatically by wshm · This is an automated analysis, not a human review.

@KuSh

KuSh commented Oct 3, 2026

Copy link
Copy Markdown
Collaborator

Thanks for working on this. Closing as a duplicate of #4343, which fixes the same false 'No hook installed' warning (#913) on the current develop layout. It reads each tool's registered hook entry rather than checking whether a file exists, so it also catches current Cursor hooks.json installs, Antigravity, Trae and Pi, and its CI is green. Review or comments are welcome on #4343, and if your change covers a case it misses, please reply here.

@KuSh KuSh closed this Oct 3, 2026
@KuSh KuSh added the duplicate This issue or pull request already exists label Oct 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working duplicate This issue or pull request already exists false-positive hook-check

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants