Skip to content

feat(yarn): add yarn command support with smart delegation#867

Open
jzambrano12 wants to merge 3 commits intortk-ai:developfrom
jzambrano12:feat/yarn_commands
Open

feat(yarn): add yarn command support with smart delegation#867
jzambrano12 wants to merge 3 commits intortk-ai:developfrom
jzambrano12:feat/yarn_commands

Conversation

@jzambrano12
Copy link

Summary

  • Add yarn_cmd.rs module following the npm_cmd.rs flat-args pattern with run injection logic and YARN_SUBCOMMANDS list (35 known subcommands)
  • Smart routing: auto-detect known tools (vitest, tsc, eslint, biome, next, prettier, playwright) and delegate to existing specialized RTK filters for maximum savings (up to 99%)
  • Generic filter strips Yarn Classic v1 boilerplate (yarn run vX.Y.Z, $ cmd, Done in Xs) and Berry v2+ info lines (YN0000:)
  • Specialized install filter strips progress phases ([1/4]...), info/warning lines (75% reduction)
  • Register Yarn variant in Commands enum, routing, and operational command list in main.rs
  • Add discover/rewrite rules: yarn pattern + rule with per-subcommand savings estimates
  • Add yarn\s+ prefix to 7 existing tool patterns (tsc, lint, prettier, next, vitest, playwright, prisma) so yarn tsc, yarn vitest, etc. are recognized by discover

Motivation

rtk discover on a real project (615 sessions, 30 days) shows 126+ unhandled yarn commands:

yarn build          58 uses
yarn lint           19 uses
yarn check          17 uses
yarn vitest         14 uses
yarn tsc             9 uses
yarn validate-translations  9 uses

Token Savings

Command Strategy Expected Savings
yarn vitest Delegate to vitest_cmd 99%
yarn build Delegate to next_cmd or generic filter 85%
yarn lint Delegate to lint_cmd 84%
yarn tsc Delegate to tsc_cmd 83%
yarn install Specialized install filter 75%
yarn check Generic filter 65%
Custom scripts Generic boilerplate strip 10-40%

Test Plan

  • 35 yarn-specific tests passing (cargo test yarn → 35 passed)
  • Full suite: 1149 tests passing, 0 clippy errors, clean fmt
  • Unit tests: filter output, edge cases (ANSI, unicode, errors, Berry format, malformed input)
  • Token savings assertions (≥55% for install, ≥10% for generic)
  • Subcommand routing: all 35 YARN_SUBCOMMANDS verified, discover commands verified
  • Registry tests: rewrite/classify for yarn build, install, lint, tsc, vitest, check, add, compound, redirect
  • Smoke tests: help, --help, --version (conditional), --skip-env
  • cargo fmt --all --check && cargo clippy --all-targets && cargo test passes

Files Changed

File Action Lines
src/yarn_cmd.rs NEW +479 (module + 35 tests)
src/main.rs EDIT +13 (mod, enum, routing)
src/discover/rules.rs EDIT +41 (patterns, rules, prefixes)
src/discover/registry.rs EDIT +125 (12 rewrite/classify tests)
scripts/test-all.sh EDIT +12 (smoke tests)
CHANGELOG.md EDIT +5 (feature entries)
README.md EDIT +1 (command table)

@CLAassistant
Copy link

CLAassistant commented Mar 26, 2026

CLA assistant check
All committers have signed the CLA.

@aeppling
Copy link
Contributor

Hey

We are cleaning up the codebase and improving the project structure for better onboarding. As part of this effort, PR #826 reorganizes src/ from a flat layout into subfolders.

No logic changes — only file moves and import path updates.

What you need to do

Rebase your branch on develop when receiving this comment:

git fetch origin && git rebase origin/develop

Git detects renames automatically. If you get import conflicts, update the paths:

use crate::git;        // now: use crate::cmds::git::git;
use crate::tracking;   // now: use crate::core::tracking;
use crate::config;     // now: use crate::core::config;
use crate::init;       // now: use crate::hooks::init;
use crate::gain;       // now: use crate::analytics::gain;

Need help rebasing? Tag @aeppling

…ized filters

Add yarn_cmd.rs module following npm_cmd flat-args pattern with run injection
logic and YARN_SUBCOMMANDS list. Smart routing delegates vitest, tsc, eslint,
biome, next, prettier, and playwright to existing specialized filters for
maximum token savings. Generic filter strips Classic v1 and Berry boilerplate.
Includes install-specific filter and discover rules with yarn prefixes on
7 existing tool patterns.
25 new tests: unit tests for edge cases (errors, ANSI, unicode, Berry
format, malformed input), registry rewrite/classify tests for yarn
commands and tool delegation, token savings assertions, and smoke
tests in test-all.sh. Total yarn coverage: 35 tests.
@jzambrano12
Copy link
Author

Hey

We are cleaning up the codebase and improving the project structure for better onboarding. As part of this effort, PR #826 reorganizes src/ from a flat layout into subfolders.

No logic changes — only file moves and import path updates.

What you need to do

Rebase your branch on develop when receiving this comment:

git fetch origin && git rebase origin/develop

Git detects renames automatically. If you get import conflicts, update the paths:

use crate::git;        // now: use crate::cmds::git::git;
use crate::tracking;   // now: use crate::core::tracking;
use crate::config;     // now: use crate::core::config;
use crate::init;       // now: use crate::hooks::init;
use crate::gain;       // now: use crate::analytics::gain;

Need help rebasing? Tag @aeppling

Done!

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.

3 participants