Skip to content

feat: add yarn workspace command with smart filter routing#226

Open
denneulin wants to merge 7 commits intortk-ai:masterfrom
denneulin:feat/yarn-cmd
Open

feat: add yarn workspace command with smart filter routing#226
denneulin wants to merge 7 commits intortk-ai:masterfrom
denneulin:feat/yarn-cmd

Conversation

@denneulin
Copy link

Summary

Add rtk yarn workspace <pkg> [run] <script> command that strips yarn boilerplate and routes script output
through existing specialized filters for maximum token savings.

  • Boilerplate stripping: Removes YN-prefixed info lines, resolution/fetch/link progress, yarn classic
    headers (yarn run v1.x, Done in Xs, info lines). Returns ok ✓ when output is pure boilerplate.
  • Smart filter routing: Routes workspace scripts to existing RTK filters based on script name:
    • vitest → vitest parser, tsc/typecheck → tsc filter, lint/lint:* → generic lint filter,
      prettier/format → prettier filter, test/test:* → test runner summary
    • Prefix exclusions prevent misrouting (test:e2e, test:playwright, test:cypress, lint:fix
      passthrough)
  • Graceful degradation: catch_unwind on filter panics, empty-output guard, fallback to stripped output
    with stderr warning
  • Early-exit on failure: When yarn itself fails (non-zero exit), outputs stripped stderr/stdout directly
    without routing through filters (prevents error masking)

Changes

File Change
src/yarn_cmd.rs New module (704 lines): filter_yarn_output(), route_script(), apply_filter(),
run() + 25 tests
src/main.rs Register Commands::Yarn with trailing_var_arg + 5 Clap parsing tests
src/lint_cmd.rs filter_generic_lint: fn → pub(crate)
src/runner.rs extract_test_summary: fn → pub(crate)
src/tsc_cmd.rs filter_tsc_output: fn → pub(crate)

Test plan

  • cargo fmt --all --check passes
  • cargo clippy --all-targets passes
  • cargo test --all passes (30+ new tests)
  • Manual: rtk yarn workspace <pkg> run vitest on a real yarn workspace project
  • Manual: rtk yarn workspace <pkg> run typecheck with typecheck not existing

denneulin and others added 7 commits February 20, 2026 00:40
…plate filtering

- Add yarn_cmd.rs with run() for workspace command execution
- Implement filter_yarn_output() stripping YN-prefixed, resolution/fetch/link, classic boilerplate
- Add 7 unit tests covering clean output, YN prefix, resolution steps, empty, classic, mixed, and token savings
- Add mod yarn_cmd declaration in main.rs for compilation
- Follow npm_cmd pattern: capture output, filter stdout, pass stderr, track tokens, tee on failure, preserve exit codes

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… parsing tests

- Add mod yarn_cmd declaration (alphabetical after wget_cmd)
- Add Commands::Yarn variant with trailing_var_arg and allow_hyphen_values
- Add match arm routing to yarn_cmd::run() with verbose and skip_env
- Add 5 Clap parsing tests: basic, scoped package with slash, without run, extra args, simple package

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ross-module access

- Make filter_tsc_output pub(crate) in tsc_cmd.rs
- Make filter_generic_lint pub(crate) in lint_cmd.rs
- Make extract_test_summary pub(crate) in runner.rs
- Add FilterRoute enum, PREFIX_EXCLUSIONS, route_script(), apply_filter() to yarn_cmd.rs
- apply_filter includes panic catch_unwind and empty-output guard for graceful degradation
…with tracking labels and tests

- Replace passthrough-only filtering with capture+strip+route+filter pattern
- Add "ok checkmark" guard to skip routing when all output is boilerplate
- Routing-aware tracking labels: "vitest (via yarn workspace)" for routed, "yarn workspace (passthrough)" for unrouted
- Add 11 comprehensive tests: 4 routing, 5 apply_filter integration, 1 guard, 1 end-to-end
- Fix clippy suggestion: use PREFIX_EXCLUSIONS.contains() instead of iter().any()
- Check exit code after command execution, before filter routing
- Failed yarn commands now print raw stdout/stderr without filter processing
- Tee raw output and track with "(failed)" label on failure path
- Move exit_code extraction before routing to share variable with safety net
- Prevents misleading "TypeScript compilation completed" on yarn errors

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- test_failed_command_should_not_route_to_filter: proves tsc filter masks yarn errors without early-exit
- test_successful_command_still_routes_through_filters: verifies happy path (strip/route/filter) is unchanged
- 20 yarn_cmd tests total (18 existing + 2 new), full suite 437 pass

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments