Persistent "No hook installed" warning on Windows after rtk init -g --opencode
Description
After running rtk init -g --opencode (and also rtk init -g), the command rtk gain still shows this warning:
[warn] No hook installed — run
rtk init -gfor automatic token savings
This warning appears every time even though:
- The OpenCode plugin has been installed successfully (
rtk init --showshows[ok] OpenCode: plugin installed) rtk --versionworks correctly (currently v0.34.1)rtk gainsuccessfully shows token savings statistics- Cursor hook is also installed and working
Steps to Reproduce
- Install RTK on Windows (
rtk-x86_64-pc-windows-msvc.zip) - Add
C:\rtkto PATH - Run
rtk init -g --opencode - Restart OpenCode
- Run
rtk gain
→ Warning still appears.
Expected Behavior
rtk gain should recognize that the OpenCode plugin is installed and not show the "No hook installed" warning (or show a more accurate message for OpenCode/Windows).
Actual Behavior
The warning persists, which is confusing even though token savings are working and the plugin is active.
Environment
- OS: Windows 11
- RTK Version: 0.34.1
- Tool: OpenCode (with custom plugin
rtk.ts) - Other hooks: Cursor hook also installed
Additional Context
According to the troubleshooting docs, OpenCode uses a custom tool.execute.before plugin instead of native Unix-style hooks. The detection logic in rtk gain seems to only check for native hooks, causing this misleading warning on Windows.
It would be great if RTK could:
- Better detect OpenCode plugin installation on Windows, or
- Show a more specific message like "OpenCode plugin installed (native hook not available on Windows)" when the plugin is present.
Thanks!
Same issue. Looking for a way to silence this warning please, thanks!
same issue with codex
same issue
same issue
wshm · Automated triage by AI
🔍 Automated Triage
| 🐛 Category | bug |
| 🟡 Priority | medium |
| 🎯 Confidence | 88% |
Summary
rtk gain emits false 'No hook installed' warning on Windows when OpenCode plugin is installed — hook detection logic does not check for OpenCode plugin presence
This looks like a simple fix that could be auto-resolved. Repo maintainers can use
/wshm fixto attempt it.
📁 Relevant files
src/gain.rssrc/init.rs
Triaged automatically by wshm · This is an automated analysis, not a human review.
same issue with claude code
I have a similar issue on linux & claude code; I ran rtk init -g resulting in;
rtk init --show
rtk Configuration:
[ok] Hook: /home/cwr/.claude/hooks/rtk-rewrite.sh (thin delegator, version 3)
[ok] RTK.md: /home/cwr/.claude/RTK.md (slim mode)
[ok] Integrity: hook hash verified
[ok] Global (~/.claude/CLAUDE.md): @RTK.md reference
[--] Local (./CLAUDE.md): not found
[ok] settings.json: RTK hook configured
[--] OpenCode: plugin not found
[--] Cursor hook: not found
[--] Cursor hooks.json: not found
but claude still shows this warning and rtk gain is empty as well
Root Cause Analysis
I traced the detection logic in src/hooks/hook_check.rs and found the exact cause:
The Problem
hook_installed_path() (line 111) only checks for the bash script file, not the settings.json binary hook entry:
fn hook_installed_path() -> Option<PathBuf> {
let home = dirs::home_dir()?;
let path = home
.join(CLAUDE_DIR) // .claude
.join(HOOKS_SUBDIR) // hooks
.join(REWRITE_HOOK_FILE); // rtk-rewrite.sh <-- only checks this file!
if path.exists() {
Some(path)
} else {
None // <-- Missing status, triggers warning
}
}
On Windows:
rtk init -grefuses to create the bash script ("Hook-based mode requires Unix"—src/hooks/init.rs:946)- The
settings.jsonbinary hook entry ("rtk hook claude") IS correctly registered - But
hook_check.rsnever readssettings.json— it only looks for the.shfile - Result: permanent
HookStatus::Missingon Windows, even when the hook is functional
This is especially relevant now that PR #956 (feat: binary hook w/ native cmd exec) has landed on develop, which registers binary hooks in settings.json instead of bash scripts.
Workaround
Create a dummy script file with the expected version tag:
mkdir -p ~/.claude/hooks
cat > ~/.claude/hooks/rtk-rewrite.sh << 'SCRIPT'
#!/bin/sh
# rtk-hook-version:3
# Dummy file for Windows binary hook detection (see #913)
# The actual hook is registered in settings.json as: rtk hook claude
SCRIPT
This satisfies hook_installed_path() and parse_hook_version() — warning disappears immediately.
Suggested Fix
hook_check.rs should also check settings.json for the binary hook pattern ("rtk hook claude") as an alternative to the bash script file. Something like:
fn hook_installed_path() -> Option<PathBuf> {
let home = dirs::home_dir()?;
// Check bash script (existing)
let script = home.join(CLAUDE_DIR).join(HOOKS_SUBDIR).join(REWRITE_HOOK_FILE);
if script.exists() {
return Some(script);
}
// Check settings.json for binary hook (new)
if binary_hook_registered_in_settings(&home) {
return Some(/* sentinel or refactor to enum */);
}
None
}
Environment
- OS: Windows 11
- RTK: dev-0.37.0-rc.153 (binary reports 0.34.3 — version string not updated in RC)
- Hook: Registered in
~/.claude/settings.jsonvia"rtk hook claude"
cc @pszymkowiak @aeppling — This is likely a quick follow-up to PR #956. The binary hook engine works great on Windows, but hook_check.rs still only looks for the bash script file. Would you be open to a PR that adds settings.json detection as a fallback?
Fix is on develop branch, release asap, we just need another maintainer approval
Should be resolved in 0.37.2
Root Cause + Workaround
Root Cause
rtk init -g --opencode installs the opencode plugin but not the Claude Code hook. RTK's internal check (hook_check.rs) only looks for the Claude Code hook in ~/.claude/settings.json — if missing, it emits the warning on every command.
This is a false positive for opencode users. The opencode plugin (tool.execute.before -> rtk rewrite) handles token rewriting for all commands executed through opencode. The Claude Code hook (rtk hook claude) is a PreToolUse hook that only fires when Claude Code runs a bash command — it does NOT help opencode users at all, neither inside opencode nor in a direct terminal.
So the warning is misleading: it tells opencode users to install a hook that is irrelevant to their setup.
Workaround
Run rtk init -g --auto-patch to silence the warning:
rtk init -g --auto-patch # installs Claude Code hook (silences the check)
rtk init -g --opencode # installs opencode plugin (actual token rewriting)
This installs the Claude Code hook in ~/.claude/settings.json, which satisfies hook_check.rs. The hook is harmless — it only activates when Claude Code runs, not opencode.
Verification
Before workaround:
$ rtk git status
[rtk] /!\ No hook installed -- run `rtk init -g` for automatic token savings
* develop
After workaround:
$ rtk git status
* develop
Warning is gone.
Suggested Fix for RTK
hook_check.rs should recognize the opencode plugin as a valid hook mechanism. Two options:
- Check for
~/.config/opencode/plugins/rtk.tsexistence — if present, the opencode plugin is active and the warning should be suppressed - Have
rtk init -g --opencodeset an env var (e.g.RTK_OPENCODE_PLUGIN=1in a config file) thathook_check.rsrecognizes
This would make the warning accurate: it would only fire when neither the Claude Code hook nor the opencode plugin is installed.
Environment
- RTK: 0.44.2
- OS: Windows 11
- Integration: opencode plugin
Another way to reach this: a Cursor-only install. hook_check::status() only looks for the Claude hook in ~/.claude/settings.json, so any agent other than Claude gets the warning as soon as a ~/.claude directory exists.
With #3000 (--agent cursor stops installing Claude Code files), on a home that has an empty ~/.claude:
$ rtk init -g --agent cursor --auto-patch # exit 0, writes only ~/.cursor/hooks.json
$ rtk ls
[rtk] /!\ No hook installed — run `rtk init -g` for automatic token savings
On current develop, rtk init -g --gemini --auto-patch followed by rtk ls prints the same line. The suggested rtk init -g would install the Claude Code files that these users chose not to install.
One more arm, from #3711 (native Antigravity hook): a project set up with rtk init --agent antigravity gets the same warning from rtk gain as soon as ~/.claude exists, for the reason named above: hook_check::status() inspects Claude's settings.json only. Antigravity's hook lives in .agents/plugins/rtk/hooks.json (or ~/.gemini/config/plugins/rtk/hooks.json with -g), so the detection has nothing to look at. Same mechanism, one more agent to cover when this is fixed.
Part of the path is fixed, so this needs a retest rather than a close.
The plugin used to be a TypeScript file that had to find rtk on its own. It is now a shim over rtk hook opencode, and hook detection has an --agent opencode mode, so rtk gain is no longer blind to the integration by construction.
But #4518 reports that rtk hook check --agent opencode and the live plugin do not always agree on the same machine, so the warning may be gone while the answer behind it is still wrong. Worth confirming both halves on your box.
Leaving open.