Skip to content

Hook doesn't rewrite common command variants (cat -n, grep -n, git status, pnpm --filter ... run) #4479

Open

Description

@engga-paqtcom

In a 30-day rtk discover scan (8,797 Bash commands, rtk 0.43.0), ~4,400 commands RTK already handles were not rewritten (~1.3M tokens saveable).

Missed: cat -n (820), grep -n (1110), git status (978), ls -la (461), find <abs path> (693).
Also not rewritten: command find, \grep, (rtk pnpm ...) subshell/prefix forms, and pnpm --filter <app> run <script> 2>&1 (238).

Suspected: variants with pipes, && chains, 2>&1 / /dev/null redirects, or backslash/command prefixes aren't matched.

Expected: the hook rewrites these forms when piped, chained, redirected, or prefixed.

Activity

  1. rtk-wshm-sync-bot commented on Oct 7, 2026

    @rtk-wshm-sync-bot

    wshm · Automated triage by AI

    🔍 Automated Triage

    🐛 Category bug
    🟠 Priority high
    🎯 Confidence 78%

    Summary

    Hook fails to rewrite common command forms when piped/chained/redirected or prefixed (cat -n, grep -n, git status, ls -la, find, pnpm --filter), losing ~1.3M tokens of savings per discover scan

    📁 Relevant files
    • src/rewrite.rs
    • src/discover.rs
    • src/hook/mod.rs

    Suggested Actions

    1. Request the raw rtk discover output/log to see exact unmatched command strings
    2. Audit the command-matching regex/parser for pipe, &&, 2>&1, and command/backslash prefix handling
    3. Cross-check against Pick the filter from the final command and run the command as typed: one mechanism for path-prefixed, runner-prefixed and aliased invocations #4315 (filter selection from final command / prefixed invocations) — likely same root cause
    4. Add regression tests for each listed variant (cat -n, grep -n, git status, ls -la, find , pnpm --filter)

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

  2. KuSh commented on Nov 28, 2026

    @KuSh
    Collaborator

    Status on v1.2.1: most forms from this report are now rewritten (cat -n, grep -n, git status, ls -la, find with an absolute path, pnpm --filter ... run build 2>&1, && chains, 2>&1 | head, (cd web && pnpm list)). Two still pass through: a backslash-escaped command (\grep foo bar) and a bare subshell ((pnpm list)). cat -n f | head stays raw on purpose. Narrowing this issue to those two forms; if your discover output shows other misses on v1.2.1, please paste the raw command strings.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions