Skip to content

feat(js): add Bun runtime support (bun test, run, bunx)#1374

Open
HenriqueSchroeder wants to merge 16 commits intortk-ai:developfrom
HenriqueSchroeder:feat/bun-support
Open

feat(js): add Bun runtime support (bun test, run, bunx)#1374
HenriqueSchroeder wants to merge 16 commits intortk-ai:developfrom
HenriqueSchroeder:feat/bun-support

Conversation

@HenriqueSchroeder
Copy link
Copy Markdown

Summary

Adds Bun runtime support to RTK with filters for bun test, bun run, bun install, bun build, and bunx.

What's new

  • bun test filter: strips passing tests, keeps failures with error context, compact summary. Handles both TTY (/) and piped ((pass)/(fail)) formats. Buffers lines preceding a fail marker since Bun prints error context before the marker, then flushes them on match.
  • bun install filter: strips progress bars, keeps summary.
  • bun build filter: compact build output.
  • bun run <script> filter: passes through script output with error-focused filtering.
  • bunx passthrough with intelligent routing (tsc, eslint, prisma → specialized filters).
  • Discovery rules so bunx tsc, bunx eslint, etc. get rewritten to specialized RTK filters.

Token savings

All filters verified >= 60% savings against real bun test output (see tests/fixtures/bun_test_real.txt, 140 lines of real bun output with 79 pass / 2 fail).

Tests

  • Snapshot tests for all filter variants
  • Token savings assertions with real fixtures (bun_test_real.txt)
  • Clap routing tests for bun test/run/install/build subcommands and bunx

Test plan

  • cargo test — 1372 tests pass locally
  • cargo clippy --all-targets — no new warnings in bun_cmd.rs
  • cargo fmt --all --check — clean
  • Manual: rtk bun test in a Bun project verifies end-to-end filtering

Notes

Branch is based on an older point in history (pre-0.37.0). Merge conflicts with current develop (notably src/discover/rules.rs where Bun entries need to be combined with the expanded npx/pnpm exec patterns, and src/main.rs PrismaCommands derive) are expected and will need resolution before merge.

🤖 Generated with Claude Code

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 17, 2026

CLA assistant check
All committers have signed the CLA.

@pszymkowiak pszymkowiak added effort-large Plusieurs jours, nouveau module enhancement New feature or request labels Apr 17, 2026
@pszymkowiak
Copy link
Copy Markdown
Collaborator

[w] wshm · Automated triage by AI

📊 Automated PR Analysis

Type feature
🟡 Risk medium

Summary

Adds comprehensive Bun runtime support to RTK, including filters for bun test, bun install, bun build, bun run, and bunx commands. Implements intelligent routing for bunx to specialized filters (tsc, eslint, prisma) and includes snapshot tests, token savings assertions, and clap routing tests.

Review Checklist

  • Tests present
  • Breaking change
  • Docs updated

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

Comment thread src/cmds/js/bun_cmd.rs
Comment thread src/discover/rules.rs Outdated
Comment thread src/cmds/js/bun_cmd.rs Outdated
Comment thread src/main.rs Outdated
Comment thread src/core/utils.rs Outdated
Comment thread src/cmds/js/bun_cmd.rs Outdated
Comment thread src/cmds/js/bun_cmd.rs Outdated
Comment thread src/cmds/js/bun_cmd.rs Outdated
Comment thread src/cmds/js/bun_cmd.rs
Comment on lines +258 to +261
if trimmed.starts_with("Resolving")
|| trimmed.starts_with("Downloading")
|| trimmed.starts_with("Extracting")
{
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you test bun in non English environment? Something like LC_ALL=de_DE.UTF-8 to see if bun has i18n output.

If that's the case, we should run it with env("LC_ALL", "C") to ensure consistent output whatever user's config

Comment thread src/cmds/js/bun_cmd.rs Outdated
Comment thread src/discover/rules.rs
rtk_cmd: "rtk tsc",
rewrite_prefixes: &[
"bun x tsc",
"bunx tsc",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing bun tsc and bun run tsc
Same goes for other commands

Comment thread src/main.rs
},
/// Passthrough: runs any unsupported bun subcommand directly
#[command(external_subcommand)]
Other(Vec<OsString>),
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the rewrite should take care of most cases but you should special case bun x in case a tool directly call it

Comment thread src/main.rs Outdated
Comment thread src/main.rs Outdated
@KuSh KuSh self-assigned this Apr 30, 2026
HenriqueSchroeder and others added 15 commits May 4, 2026 17:11
Bun prints (pass)/(fail) when stdout is piped (RTK's case) but
the initial filter only matched TTY ✓/✗ markers. Rewrote
filter_bun_test to:
- handle both TTY and piped formats
- buffer lines preceding a fail marker (Bun emits error context
  before the marker) and flush them on match
- skip the trailing "N tests failed:" summary (duplicates already
  captured failures)

Replaced synthetic fixtures with real bun test output and added
bun_test_real.txt to guard the >=60% token savings target under
real-world conditions.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
- README.md: added rtk bun test (Test Runners), rtk bun build + rtk bunx
  (Build & Lint), rtk bun install + rtk bun run (Package Managers)
- docs/guide/what-rtk-covers.md: added bun test/install/build/run/bunx
  rows to the JavaScript / TypeScript table

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Comment thread src/cmds/js/bun_cmd.rs Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort-large Plusieurs jours, nouveau module enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants