Skip to content

fix(ccusage): prefer bunx before npx#691

Open
dck wants to merge 1 commit intortk-ai:developfrom
dck:master
Open

fix(ccusage): prefer bunx before npx#691
dck wants to merge 1 commit intortk-ai:developfrom
dck:master

Conversation

@dck
Copy link

@dck dck commented Mar 18, 2026

Summary

This fixes rtk cc-economics when ccusage is not installed as a direct binary but is available through Bun. RTK previously hardcoded a direct ccusage binary first and npx second, which caused it to miss valid bunx ccusage setups and, in practice, select older or less capable ccusage builds (at least on my machine) than the user’s normal workflow. Separately, bunx is significantly faster than npx for one-off package execution. Users with Bun installed should get it as the first fallback before npx.

The improvement:
The change introduces layered runner selection for ccusage with this priority: direct binary → bunx → pnpm dlx → yarn dlx → npx. It also removes the interactive npx ccusage --help probe, which could add latency or hang-like behavior before the real command even ran.

How It Works

ccusage execution is now selected through a dedicated runner policy instead of ad hoc probing.

The new selection order is:

  1. ccusage
  2. bunx ccusage
  3. pnpm dlx ccusage
  4. yarn dlx ccusage
  5. npx --yes ccusage

This is important for RTK because cc-economics depends on ccusage features and output shape, and different runners can resolve different installed versions in real user environments. In my local
investigation, bunx ccusage resolved a newer build than npx ccusage, and the older npx path did not support commands that RTK expects, such as weekly reporting.

Test plan

  • cargo fmt --all --check — clean
  • cargo clippy --all-targets — no new warnings
  • cargo test ccusage — 14/14 pass
  • Runner priority tests verify: binary > bunx > pnpm > yarn > npx
  • None case tested when no runner is available

@dck dck changed the base branch from master to develop March 18, 2026 12:09
@dck dck force-pushed the master branch 2 times, most recently from d025764 to d57bfcc Compare March 18, 2026 12:13
Add layered ccusage runner fallback with bunx ahead of pnpm dlx, yarn dlx, and npx, and remove the interactive npx help probe.

Signed-off-by: Denis Usanov <denis@usanov.info>
@dck
Copy link
Author

dck commented Mar 20, 2026

@pszymkowiak could you please take a look at this small PR?

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

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.

2 participants