Skip to content

bug(hook): pnpm run <script> is rewritten to rtk pnpm run <script>, which is not a valid subcommand and silently applies no filtering #3516

Open

Description

@triggerhive-gijs

Observed with: rtk 0.45.0 (Homebrew, macOS 15 / arm64), Claude Code PreToolUse hook (rtk-rewrite.sh, rtk-hook-version: 3).

Summary

rtk rewrite maps pnpm run <script> to rtk pnpm run <script>. But run is not a subcommand of rtk pnpm — the only ones are list, outdated, install and typecheck. The rewritten command silently falls through to plain pnpm and applies no filtering at all, while the caller has every reason to believe the output was compressed.

This makes the rewrite strictly worse than leaving the command alone. A passthrough is honest; this one is a filter that quietly does nothing.

Reproduction

Any pnpm project with a typecheck script (here: "typecheck": "nuxt typecheck", but tsc --noEmit behaves the same).

$ rtk rewrite "pnpm run typecheck"
rtk pnpm run typecheck          # exit 3

Now compare the three paths on the same project, same green result:

Command Exit Bytes
pnpm typecheck (raw) 0 2673
rtk pnpm run typecheck (what the hook produces) 0 2673
rtk pnpm typecheck (the filtered entrypoint) 0 28
$ diff -q b.txt c.txt && echo "identical"
identical

The output of rtk pnpm run typecheck is byte-identical to unfiltered pnpm typecheck. The filtered path drops the same run to TypeScript: No errors found, a 99% reduction.

Second, related problem: rtk pnpm run test hangs

rtk rewrite "pnpm test" correctly exits 1 (no mapping), but rtk pnpm run test — the shape a user reaches for by analogy — falls through to pnpm test, which in a Vitest project starts watch mode and never returns. Under an agent harness that is not merely slow, it blocks the session until the process is killed manually. Whatever the fix for the run passthrough, it would help to reject unknown rtk pnpm subcommands loudly instead of forwarding them.

Suggested fix

Either of these would resolve it:

  1. Have rtk pnpm run <script> resolve to the same handler as rtk pnpm <script> when a handler exists for that script name, so run becomes a transparent alias.
  2. Or drop the pnpm run <script> entry from the rewrite registry entirely, so the hook passes it through unchanged rather than producing a command that looks filtered and isn't.

Option 1 is the more useful of the two, since pnpm run typecheck is the canonical form and is what many projects document.

Not a duplicate of

Activity

  1. pszymkowiak commented on Aug 10, 2026

    @pszymkowiak
    Collaborator

    wshm · Automated triage by AI

    🔍 Automated Triage

    🐛 Category bug
    🟠 Priority high
    🎯 Confidence 90%

    Summary

    rtk pnpm run <script> silently falls through to unfiltered pnpm (no error, no compression) and for run test falls into vitest watch mode, hanging the session; alias run <script> to the equivalent filtered rtk pnpm <script> handler or drop the rewrite entry entirely, and reject unknown rtk pnpm subcommands loudly.

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

    📁 Relevant files
    • src/rewrite/pnpm.rs

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

  2. nightcityblade commented on Aug 10, 2026

    @nightcityblade

    Hi, I'd like to work on this. I'll submit a PR shortly.

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:clibugpriority:high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions