Skip to content

fix(hooks): recognize rtk hook commands that carry rtk flags - #4265

Open
mrhard9090 wants to merge 1 commit into
rtk-ai:developfrom
mrhard9090:fix/hook-detect-flags
Open

mrhard9090 wants to merge 1 commit into
rtk-ai:developfrom
mrhard9090:fix/hook-detect-flags

Conversation

@mrhard9090

Copy link
Copy Markdown
Contributor

Summary

Fixes #4211

  • is_rtk_hook_command accepted a hook only when it split into exactly rtk hook <agent>. A registration that uses the documented flags, such as rtk hook claude --ultra-compact --skip-env or rtk --ultra-compact hook claude, was reported as missing: rtk verify printed SKIP RTK hook not installed and the No hook installed banner kept coming back, although the hook runs.
  • The arguments after the binary now go through arg_tokenizer::tokenize. --ultra-compact, --skip-env, --verbose and -v clusters are skipped. What remains must be exactly hook <agent>. Any other flag, an attached value, -- or an extra argument still fails the match.
  • The same helper serves the status check, rtk init (which no longer adds a second hook next to a flagged one), uninstall (which now removes a flagged hook) and the codex/trae checks.
  • Not changed: KuSh's note that the banner ignores the group matcher and hook type. That is a separate fix.

Test plan

  • New claude_hook_command_accepts_rtk_flags. claude_hook_command_rejects_other_commands gains an unknown flag, an extra argument, an attached value, -- and a missing agent.
  • Built on Windows and ran rtk verify with CLAUDE_CONFIG_DIR pointing to a settings.json from the issue's probe. rtk hook claude, rtk hook claude --ultra-compact --skip-env and rtk --ultra-compact hook claude report PASS native binary hook registered. rtk hook claude --bogus still reports SKIP RTK hook not installed.
  • cargo fmt --all && cargo clippy --all-targets (clean) && cargo test on Windows (MSVC): 3742 passed, 2 failed. find_cmd::run_from_args_propagates_find_exit_status and stream::test_read_lines_lossy_preserves_lines_after_invalid_utf8 fail the same way on develop on this machine.

Written with help from Claude Opus 5.5.

A hook registered as `rtk hook claude --ultra-compact --skip-env` or
`rtk --ultra-compact hook claude` was reported as not installed because
detection required exactly three words. Skip the flags that leave the
hook unchanged and match the rest.

Fixes rtk-ai#4211
@CLAassistant

CLAassistant commented Sep 26, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@rtk-wshm-sync-bot rtk-wshm-sync-bot Bot added bug Something isn't working hooks labels Sep 26, 2026
@rtk-wshm-sync-bot

Copy link
Copy Markdown

wshm · Automated triage by AI

📊 Automated PR Analysis

🐛 Type bug-fix
🟡 Risk medium

Summary

Fixes rtk's hook-detection logic so that rtk hook <agent> commands carrying rtk's own flags (--ultra-compact, --skip-env, --verbose/-v) are correctly recognized as installed hooks. Previously, any flags on the hook command caused it to be misreported as missing by rtk verify, init, and uninstall.

Review Checklist

  • Tests present
  • Breaking change
  • Docs updated

Linked issues: #4211


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

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

Labels

bug Something isn't working hooks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rtk verify and the "No hook installed" banner reject a native hook that carries any documented flag

2 participants