Skip to content

bug(discover): a tab between command and subcommand classifies as Supported but never rewrites #4100

Open

Description

@KuSh

Same class as #3995 (absolute-path arm, fixed 2026-09-13): classify_command and the rewrite
disagree about what separates a command from its subcommand.

  • the rule patterns match \s+ — ^pnpm\s+(exec|i|install|…), ^cargo\s+(build|test|…), …

  • strip_word_prefix (src/discover/registry.rs:1930) accepts only a literal ASCII space:

    } else if cmd.len() > prefix.len()
        && cmd.starts_with(prefix)
        && cmd.as_bytes()[prefix.len()] == b' '

So a tab-separated command is classified Supported and then returned unchanged by the hook.
rtk discover and rtk session count it as covered; the command streams raw.

Verified on develop (5e0f92cd) with rtk rewrite, tab written as \t:

command rewrite
git status rtk git status
git\tstatus (nothing)
cargo\tbuild (nothing)
npm\trun build (nothing)
pnpm\tinstall (nothing)

Not tool-specific — it is every rule that goes through strip_word_prefix.

A tab really is a valid separator here, so the classify side is the one that is right:
the shell grammar treats space and tab as blanks when tokenising a command line, independent
of IFS. bash -xc $'git\t--version' traces as + git --version and prints
git version 2.53.0.

And it reaches the hook. Feeding a PreToolUse payload to rtk hook claude — the tab
survives JSON transport as \t:

tool_input.command updatedInput.command returned
git status rtk git status
git\tstatus (none — unchanged)
pnpm\tinstall (none — unchanged)

Frequency: low. An agent writing shell almost always uses a single space, so this is a
correctness gap rather than a material source of lost savings — worth closing for the
consistency of the two sides, not urgent.

Found while reviewing #3275 with a differential fuzz asserting
classify == Supported(rtk pnpm) ⇒ rewrite fires. Over 6528 generated pnpm spellings it trips
64 times, all tab-separated, and the count is identical on develop and on that PR's head —
so this is pre-existing and #3275 neither adds to it nor fixes it.

A fix should make the two sides share one notion of the boundary rather than widening
strip_word_prefix alone: widening only the classify side is what #3275 round 1 had to close,
and widening only the rewrite side would rewrite forms classify still calls Unsupported.

Activity

  1. added
    bug
    good first issue
    on Sep 17, 2026
  2. rtk-wshm-sync-bot commented on Sep 17, 2026

    @rtk-wshm-sync-bot

    wshm · Automated triage by AI

    🔍 Automated Triage

    🐛 Category bug
    🟢 Priority low
    🎯 Confidence 93%

    Summary

    classify_command treats tab as a valid command/subcommand separator but strip_word_prefix (registry.rs:1930) only matches a literal space, so tab-separated commands are classified Supported yet never rewritten — unify the boundary logic used by both sides.

    This looks like a simple fix that could be auto-resolved. Repo maintainers can use /wshm fix to attempt it.

    📁 Relevant files
    • src/discover/registry.rs

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

  3. KuSh commented on Nov 28, 2026

    @KuSh
    CollaboratorAuthor

    The TOML-filter branch of the rewrite has the same tab problem, through strip_absolute_path: it finds the first word with find(' '), so when the words are separated by tabs the whole command is taken as one word, and a / anywhere in it makes the basename after the last / the thing matched.

    hook input rtk rewrite
    jj log src/a.py rtk jj log src/a.py
    jj<TAB>log<TAB>src/a.py none
    make -C src/x rtk make -C src/x
    make<TAB>-C<TAB>src/x none

    Without a / the tab form is rewritten (jj<TAB>log -r @ → rtk jj<TAB>log -r @). Same result on develop 8bb6096 and on #5134's head.

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

    area:clibuggood first issuepriority:low

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions