rtk-ai/rtk

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

Open

#836 ouverte le 25 mars 2026

Voir sur GitHub
 (1 commentaire) (0 réactions) (0 assignés)Rust (2 914 forks)batch import
area:clibugeffort-smallgood first issuepriority:medium

Métriques du dépôt

Stars
 (48 085 stars)
Métriques de merge PR
 (Merge moyen 11j 1h) (45 PRs mergées en 30 j)

Description

Summary

Users who ran an earlier version of rtk init --copilot (or rtk init when Copilot support was first introduced in #605) end up with a .github/hooks/rtk-rewrite.json containing:

{
  "hooks": {
    "PreToolUse": [
      {
        "type": "command",
        "command": "rtk hook",
        "cwd": ".",
        "timeout": 5
      }
    ]
  }
}

"rtk hook" requires a subcommand (gemini or copilot). Without one, it prints help and exits non-zero. This fires on every Bash tool call, silently logging a parse_failure with raw_command = "hook" in history.db.

Reproduction

  1. Have .github/hooks/rtk-rewrite.json with "command": "rtk hook" in your project
  2. Run any Bash command through Claude Code
  3. Run rtk gain --failures → see Nx hook entries with fallback_succeeded = 0
  4. Query the DB directly:
    sqlite3 ~/Library/Application\ Support/rtk/history.db \
      "SELECT error_message FROM parse_failures WHERE raw_command = 'hook' LIMIT 1;"
    
    → Returns the full rtk hook --help output as the error message

Impact

  • Inflated failure count in rtk gain --failures
  • Spurious fallback_succeeded = 0 entries (no actual fallback occurs — the hook returns non-zero, Claude Code runs the original command unchanged)
  • Silent — no visible error to the user

Root cause

Commit #605 (feat(copilot): add Copilot hook support) included .github/hooks/rtk-rewrite.json with "command": "rtk hook" instead of "command": "rtk hook copilot". The fix in the pending Copilot integration (see #823) generates the correct "rtk hook copilot" command, but does not migrate or clean up existing broken files.

Neither rtk init --show nor rtk init --uninstall check .github/hooks/ for orphaned files.

Note: different from #712

Issue #712 reports that rtk init doesn't wire up rtk hook at all. This issue is the inverse: rtk init did write .github/hooks/rtk-rewrite.json, but with an incomplete command that silently breaks on every invocation.

Proposed fix

  1. rtk init --show detects .github/hooks/rtk-rewrite.json with "rtk hook" and warns with actionable guidance
  2. rtk init -g --uninstall removes the broken file as part of cleanup

PR with the fix is attached.

Guide contributeur