Repository navigation
feat(config): add suppress_hook_warning option - #776
Conversation
📊 Automated PR Analysis
SummaryAdds a new Review Checklist
Linked issues: #682 Analyzed automatically by wshm · This is an automated analysis, not a human review. |
pszymkowiak
left a comment
There was a problem hiding this comment.
LGTM — clean and useful. Config field + env var, serde(default) for backward compat, 4 tests. Exactly what OpenCode and non-hook setups need.
One minor suggestion: consider also checking the env var in runtime_check() (integrity.rs) for consistency, but not a blocker.
|
Hey We are cleaning up the codebase and improving the project structure for better onboarding. As part of this effort, PR #826 reorganizes No logic changes — only file moves and import path updates. What you need to doRebase your branch on git fetch origin && git rebase origin/developGit detects renames automatically. If you get import conflicts, update the paths: use crate::git; // now: use crate::cmds::git::git;
use crate::tracking; // now: use crate::core::tracking;
use crate::config; // now: use crate::core::config;
use crate::init; // now: use crate::hooks::init;
use crate::gain; // now: use crate::analytics::gain;Need help rebasing? Tag @aeppling |
02ea499 to
f8d2f3c
Compare
|
Rebased onto develop in f8d2f3c. |
f8d2f3c to
65795c6
Compare
|
Rebased onto develop in 65795c6 - resolved a conflict in src/core/config.rs (kept the helper functions I originally added) and fixed a stale import path in hook_check.rs. The two suppress_hook_warning tests pass locally. Let me know if anything else is needed before merge. |
KuSh
left a comment
There was a problem hiding this comment.
Thanks for the rebase work on this — the feature itself is the right shape, and the [hooks] config + env-var pair is the correct place for it. One blocker before this can go in, plus three smaller things worth folding in while the branch is being touched.
Blocker
telemetry_enabled() in src/core/config.rs has no callers and will fail the build (see inline comment). It's unrelated to this PR's scope and appears to be a conflict-resolution artifact.
This PR needs another rebase
develop has since added transparent_prefixes: Vec<String> to HooksConfig, and GitHub now reports this branch as CONFLICTING / DIRTY.
Note: develop itself is currently broken — not your fault, and not something you need to fix here
While verifying this PR I applied both hunks onto develop and found that develop does not build on its own, independently of this PR: src/cmds/php/phpt_cmd.rs:162 uses lazy_static::lazy_static! but lazy_static is not in Cargo.toml, and src/discover/rules.rs is missing the pipeline_final_safe field. Both regressions came in with the .phpt filter merge (#1503, e8541d1).
That is already fixed by #3793. So when you rebase and cargo clippy --all-targets explodes with E0433 cannot find crate lazy_static and E0063 missing field pipeline_final_safe, those seven errors are not yours — ignore them, or rebase on top of #3793 to get a clean run. The only error attributable to this PR is the telemetry_enabled one flagged inline.
Note on the existing approval
The 2026-03-26 approval predates two rebases and was given on 02ea499, before the conflict resolution that introduced telemetry_enabled(), so it doesn't cover the current head.
On the suggestion to also check the env var in integrity.rs::runtime_check() — I'd leave that one alone. That path only prints on IntegrityStatus::Tampered, which is a security signal rather than recurring noise, so it shouldn't be suppressible by the same switch.
65795c6 to
dfb8886
Compare
|
All four are in dfb8886, rebased onto current develop. The dead telemetry_enabled is gone. It was a conflict-resolution artifact exactly as you guessed, and dropping it is what makes the branch build under warnings = deny. The env var is a real override now: Ok("1") suppresses, any other value forces the warning back on, and only an unset var falls through to config.toml. That also moves it onto the as_deref() == Ok("1") shape the rest of the repo uses. hook_warning_suppressed() runs before status() now, so a suppressed user pays neither the hook probe nor the config read that used to follow it. Documented in configuration.md, both the [hooks] sample and the environment variable table, plus the README snippet. On develop being broken: it builds clean at f83c0cf. cargo fmt --check, cargo clippy --all-targets with zero warnings, and the config and hook tests all pass locally against that base, so the lazy_static and pipeline_final_safe errors you hit are gone. |
KuSh
left a comment
There was a problem hiding this comment.
Second pass on dfb8886f. All four threads from the previous round are genuinely addressed and I've resolved them — the rebase is clean, telemetry_enabled() is gone, docs are in, and I verified cargo clippy --all-targets is clean with 3074 tests passing at this head.
Three new points below. Up front: the first one is partly my fault — my previous comment asked for an env-var override and the literal implementation of that ask has a sharper edge than I anticipated. The suggested fix below reconciles both rounds, so please don't just revert to what you had.
Also worth noting my earlier pointer to #3793 for the develop build break is now stale — that PR was closed, but the lazy_static breakage is gone from your base anyway, so it's moot.
Add hooks.suppress_hook_warning config option and RTK_SUPPRESS_HOOK_WARNING
env var to disable "No hook installed" and "Hook outdated" warnings.
Users running rtk via CLAUDE.md instructions instead of hooks, or with
tools like OpenCode, get these warnings on every command. The warnings
waste tokens and confuse AI agents since rtk is working correctly.
RTK_SUPPRESS_HOOK_WARNING=1 suppresses; any other value forces the warning
on; unset falls back to the config file. Both default to false so existing
behavior is unchanged. The env parse follows the repo's
as_deref() == Ok("1") convention.
The suppression check runs before status() so the suppressed path does not
pay for the hook probe.
Documented in configuration.md (the hooks block and the env var table) and
README.md.
Fixes rtk-ai#682
Signed-off-by: Matt Van Horn <[email protected]>
…verride Parse RTK_SUPPRESS_HOOK_WARNING as a truthy/falsy override that falls back to config when unset or unrecognised, keep the HookStatus::Ok fast path free of config loading, and suppress only the missing-hook warning so the outdated-hook upgrade prompt stays visible. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01CNmJZVV9u6pBhcwVhwkPp6
dfb8886 to
4e53f76
Compare
|
All three are in 4e53f76, on top of a rebase onto develop. The env var now parses truthy and falsy values and only overrides when it is actually set, so |
…sition `rtk gain` printed its own missing-hook line from a bare `status()` match, outside `maybe_warn`, so neither `hooks.suppress_hook_warning` nor `RTK_SUPPRESS_HOOK_WARNING` reached it — on the report the no-hook audience reads most. Gate that arm on the same helper; the outdated-hook prompt stays visible, as it does everywhere else. The new unit tests exercise the parser alone, so folding env and config together with `||` — which drops the falsy force-off — left the whole suite green. Drive the composition through the binary instead, and give the env table the `=0` row that overrides the config flag. The suite pins `XDG_CONFIG_HOME`/`XDG_DATA_HOME` to the temporary home and seeds the config in both the XDG and the macOS location, so the loader cannot resolve past it: `dirs::config_dir` is `~/.config` on Linux but `~/Library/Application Support` on macOS, and a runner that exports either `XDG_*` reached the developer's own config before. Co-Authored-By: Claude Opus 5 <[email protected]>
f3e2cbf to
d2e906a
Compare
KuSh
left a comment
There was a problem hiding this comment.
Round 3 of 3 — APPROVED
Claim: let users permanently silence the recurring missing-hook warning via hooks.suppress_hook_warning and RTK_SUPPRESS_HOOK_WARNING.
Scope: accept.
CI @d2e906a0: all green — clippy, fmt, doc review, test presence, ubuntu/macos/windows, Security Scan, semgrep, benchmark, CLA.
Blocks merge (0)
Everything from the first two rounds is verified fixed by execution, not by reading. I built this head and the previously reviewed one with separate target dirs (hashes confirmed distinct) and ran a 90-cell matrix — 2 hook states x 3 config states x 15 env values — each cell in a fresh HOME/XDG_CONFIG_HOME/XDG_DATA_HOME/CLAUDE_CONFIG_DIR under LC_ALL=C:
| before | after | |
|---|---|---|
cfg=true, env "" / " " (the CI empty-string veto) |
WARNS | silent |
cfg=*, env true/TRUE/" true "/yes/on |
WARNS | silent |
cfg=true, env maybe / 2 |
WARNS | silent |
| Outdated hook + suppression | silent | WARN-outdated |
23 of 90 cells changed, all in the intended direction, and the falsy force-off (0/false/no/off beating cfg=true) is intact. The hot-path fix is confirmed by syscall count: on HookStatus::Ok the previous head opened config.toml twice, this one opens it once. Merge onto latest develop is clean and green.
Nicely done on parse_suppress_hook_warning_env — extracting the pure parser is what made the precedence testable without touching process env or the config cache.
Fixup pushed — d2e906a0
Two things I folded in rather than sending back for a fourth round:
rtk gainignored the flag. It prints its own missing-hook line from a barestatus()match, outsidemaybe_warn, so neither the config option nor the env var reached it — on the report the no-hook audience reads most, which is the audience#682is about. ItsMissingarm is now gated onhook_warning_suppressed(); the outdated prompt stays visible, consistent with the scoping in this PR.- The env tests were tautologies. They exercise the parser alone, so
hook_warning_suppressed()— which composes env and config — had no coverage. Rewriting it asconfig || env.unwrap_or(false), dropping the falsy force-off this PR just added, kept the entire suite green while the binary silently regressed.tests/hook_warning_scope_test.rsnow drives the composition through the real binary, and both gaps are mutation-checked: reverting either fix fails a test.
The suite also now pins XDG_CONFIG_HOME/XDG_DATA_HOME to the temp home and seeds the config in both the XDG and macOS locations. My first attempt at these tests passed locally and failed on both Unix runners — dirs::config_dir() is ~/.config on Linux but ~/Library/Application Support on macOS. That was my bug, fixed in the same commit; it incidentally hardens the pre-existing tests in that file, which were reading the developer's real config too.
Next
Nothing — approving. Merges as-is.
|
Thanks for the merge, @KuSh. The env var should cover the CLAUDE.md and OpenCode paths without anyone needing to touch |
Summary
hooks.suppress_hook_warningconfig option inconfig.tomlRTK_SUPPRESS_HOOK_WARNING=1env var as zero-config alternativeWhy this matters
Users running rtk via CLAUDE.md instructions (instead of hooks) or with tools like OpenCode get
[rtk] /!\ No hook installedon every command (#682). The warning wastes tokens and confuses AI agents - @btbxbob reports it printing on everygit add,git commit, andgit status. 5 users across Windows and OpenCode report the same problem.Currently the warning is rate-limited to once per day, but there's no way to suppress it permanently.
Changes
src/config.rs:suppress_hook_warning: boolfield toHooksConfig(defaults tofalse)hook_warning_suppressed()helper that checks the env var first, then config filesrc/hook_check.rs:check_and_warn()now returns early whenhook_warning_suppressed()is trueThe
rtk gaindiagnostic output (src/gain.rs) still shows hook status since that's an explicit diagnostic command.Usage
Config file (
~/.config/rtk/config.toml):Or env var (useful for CI, OpenCode, non-Claude tools):
export RTK_SUPPRESS_HOOK_WARNING=1Test plan
cargo fmt --all --check && cargo clippy --all-targets && cargo test(1074 tests pass)suppress_hook_warningdeserializes correctly from TOMLfalse(existing behavior unchanged)[hooks]section defaults tofalseFixes #682
This contribution was developed with AI assistance (Claude Code).