rtk-ai / rtk-ai/rtk

feat: pnpm workspace filter support (--filter/-F)

Open
#512 2 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area:cli effort-large enhancement help wanted priority:medium
Dominant language
Rust
Stars
81.1k
Forks
5.1k
Avg merge
4d 21h
Merged PRs (30d)
35

Description

Problem

Monorepo Node.js users (pnpm workspaces) get zero token savings from RTK because all their commands go through pnpm --filter <workspace> <tool>:

pnpm --filter web prettier --check .
pnpm --filter web tsc --noEmit
pnpm -F @scope/pkg vitest run

The rewrite layer and Clap parsing both fail to match these patterns. Root cause: every PATTERN regex assumes pnpm <subcommand> with no flags between pnpm and the subcommand. pnpm --filter web breaks all matching.

Strategy: Rewrite-Layer Normalization

Strip pnpm (--filter|-F) <workspace> in the rewrite layer before classification, then propagate the workspace value to tool modules via a hidden --pnpm-filter Clap global arg.

Why not pattern expansion: Adding pnpm --filter \S+ <tool> variants to every PATTERN regex and rewrite_prefixes array is combinatorial (7+ tools × 2 flag forms). Doesn't scale.

Expected behavior

# Hook rewrites transparently
pnpm --filter web prettier --check .  →  rtk prettier --pnpm-filter web --check .
pnpm -F web tsc --noEmit              →  rtk tsc --pnpm-filter web --noEmit
pnpm --filter web vitest run          →  rtk vitest --pnpm-filter web run
pnpm --filter web list                →  rtk pnpm --pnpm-filter web list

# rtk discover correctly classifies these as Supported (not Unsupported)
rtk discover  →  pnpm --filter web prettier  [Supported, ~70% savings]

Files to modify (10 total)

File Change
src/discover/registry.rs Rewrite core extraction, pnpm filter strip/inject, classify_command update
src/main.rs --pnpm-filter global Clap arg + 8 dispatch updates
src/utils.rs New package_manager_filtered_exec()
src/prettier_cmd.rs Add pnpm_filter param
src/format_cmd.rs Add pnpm_filter param
src/tsc_cmd.rs Add pnpm_filter param
src/vitest_cmd.rs Add pnpm_filter param
src/lint_cmd.rs Add pnpm_filter param
src/playwright_cmd.rs Add pnpm_filter param
src/pnpm_cmd.rs Add pnpm_filter param

Edge cases

  • Scoped packages: @scope/pkg\S+ regex handles it
  • Glob patterns: ./packages/*\S+ handles it
  • No filter: all existing behavior unchanged (pnpm_filter = None throughout)
  • Env prefixes: sudo pnpm --filter web prettier — env prefix stripped first, re-added after rewrite
  • Unknown commands: pnpm --filter web unknown-cmd → no rewrite (passthrough)

Out of scope (future)

  • pnpm -w (workspace root flag)
  • pnpm -r / --recursive
  • pnpm --filter-prod

Related

Reported by Stephane (monorepo Node user via Slack).

Sub-issues: Phase 1 (#registry), Phase 2 (#main), Phase 3 (#utils), Phase 4 (#tool-modules)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with src/discover/registry.rs to trace command extraction and classification, then follow the --pnpm-filter dispatch changes in src/main.rs and the execution helpers in src/utils.rs. Review the listed tool modules for filter propagation; the work is done when pnpm --filter and -F commands rewrite correctly, existing unfiltered behavior is unchanged, and unknown commands pass through.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, rust
Domain
cli, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.