From 899c51cba6610666031ea3d5d2f506c08de6d3d1 Mon Sep 17 00:00:00 2001 From: ousamabenyounes Date: Mon, 14 Sep 2026 10:25:16 +0200 Subject: [PATCH] fix(statusline): detect RTK rewrite hook --- scripts/tokenwar-statusline.sh | 6 +++++- tests/statusline.bats | 12 ++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/scripts/tokenwar-statusline.sh b/scripts/tokenwar-statusline.sh index 45c8e9f..481a235 100755 --- a/scripts/tokenwar-statusline.sh +++ b/scripts/tokenwar-statusline.sh @@ -219,7 +219,11 @@ if command -v "$RTK_BIN" >/dev/null 2>&1; then const cfg = JSON.parse(readFileSync(path, "utf8")); const pre = (cfg.hooks && cfg.hooks.PreToolUse) || []; return pre.some(h => (h.matcher||"") === "Bash" - && (h.hooks||[]).some(x => (x.command||"").includes("rtk hook"))); + && (h.hooks||[]).some(x => { + const command = x.command || ""; + return command.includes("rtk hook") + || command.includes("rtk-rewrite.sh"); + })); } catch { return false; } }; const wired = wiredIn(process.env.SETTINGS) || wiredIn(process.env.SETTINGS_LOCAL); diff --git a/tests/statusline.bats b/tests/statusline.bats index dfa52cd..489fc89 100644 --- a/tests/statusline.bats +++ b/tests/statusline.bats @@ -110,6 +110,18 @@ EOF [[ "$output" == *"${GREEN}[caveman 84cc3c1]"* ]] } +@test "rtk rewrite script hook → rtk green" { + write_settings <<'EOF' +{"hooks":{"PreToolUse":[{"matcher":"Bash","hooks":[{"command":"/another/users/home/.claude/hooks/rtk-rewrite.sh"}]}]}} +EOF + mock_claude_with_plugins '[]' + mock_rtk_alive + + run bash "$SCRIPT" <<<'{}' + [ "$status" -eq 0 ] + [[ "$output" == *"${GREEN}[rtk 44.7M]"* ]] +} + @test "pxpipe installed → pxpipe badge green" { write_settings <<'EOF' {}