Skip to content

fix(init): detect and clean up orphaned .github/hooks/rtk-rewrite.json with broken hook command#837

Open
rolf-quadra wants to merge 1 commit intortk-ai:developfrom
rolf-quadra:fix/orphaned-copilot-hook-json
Open

fix(init): detect and clean up orphaned .github/hooks/rtk-rewrite.json with broken hook command#837
rolf-quadra wants to merge 1 commit intortk-ai:developfrom
rolf-quadra:fix/orphaned-copilot-hook-json

Conversation

@rolf-quadra
Copy link

Fixes #836

What

  • rtk init --show: warns when .github/hooks/rtk-rewrite.json exists with "command": "rtk hook" (missing subcommand), with actionable guidance pointing to rtk gain --failures and the fix
  • rtk init -g --uninstall: removes the broken file as part of standard cleanup (only when the command is the broken "rtk hook" — a correctly configured "rtk hook copilot" file is left untouched)

Why

Users who ran an earlier rtk init --copilot (introduced in #605) got .github/hooks/rtk-rewrite.json with "command": "rtk hook" (no subcommand). Since rtk hook requires gemini or copilot, it prints help and exits non-zero on every Bash tool call. RTK silently logs a parse_failure with raw_command = "hook" and fallback_succeeded = 0 in history.db, inflating rtk gain --failures stats with no visible error to the user.

The pending Copilot integration (#823) correctly generates "rtk hook copilot", but neither rtk init --show nor rtk init --uninstall check .github/hooks/ for these orphaned files.

Changes

src/init.rs only — 66 lines added, no deletions, no new dependencies.

Test

# Reproduce
echo '{"hooks":{"PreToolUse":[{"type":"command","command":"rtk hook","cwd":".","timeout":5}]}}' \
  > .github/hooks/rtk-rewrite.json

# Should warn
rtk init --show

# Should remove
rtk init -g --uninstall
ls .github/hooks/rtk-rewrite.json  # should be gone

@CLAassistant
Copy link

CLAassistant commented Mar 25, 2026

CLA assistant check
All committers have signed the CLA.

@aeppling
Copy link
Contributor

Hey

We are cleaning up the codebase and improving the project structure for better onboarding. As part of this effort, PR #826 reorganizes src/ from a flat layout into subfolders.

No logic changes — only file moves and import path updates.

What you need to do

Rebase your branch on develop when receiving this comment:

git fetch origin && git rebase origin/develop

Git 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

Users who ran an earlier rtk init --copilot (from commit rtk-ai#605) ended up
with .github/hooks/rtk-rewrite.json containing "command": "rtk hook"
(missing subcommand). This causes RTK to log a spurious parse_failure on
every Bash tool call, inflating rtk gain --failures stats silently.

- rtk init --show: warns when the broken file is detected, with actionable
  guidance pointing to rtk gain --failures and the fix
- rtk init -g --uninstall: removes the broken file as part of standard
  cleanup (only when command is the broken "rtk hook", leaves a correctly
  configured "rtk hook copilot" file untouched)

Fixes rtk-ai#836
@rolf-quadra rolf-quadra force-pushed the fix/orphaned-copilot-hook-json branch from b712f13 to 3f9e822 Compare March 26, 2026 23:30
@rolf-quadra
Copy link
Author

Refactored to comply with the repository reorg.

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.

[bug] .github/hooks/rtk-rewrite.json with broken "rtk hook" command causes spurious parse_failure entries per session

3 participants