Skip to content

feat(discover): rewrite bunx prisma → rtk prisma - #2005

Closed
YOMXXX wants to merge 1 commit into
rtk-ai:developfrom
YOMXXX:feat/bunx-prisma-rewrite
Closed

YOMXXX wants to merge 1 commit into
rtk-ai:developfrom
YOMXXX:feat/bunx-prisma-rewrite

Conversation

@YOMXXX

@YOMXXX YOMXXX commented May 21, 2026

Copy link
Copy Markdown
Contributor

Summary

Bun is the primary JS runtime on a growing share of Prisma projects. `bunx prisma ` is semantically equivalent to `npx prisma ` — same CLI, same output format, same subcommands — but the hook didn't recognise it, so the reporter's 45 monthly `bunx prisma` invocations (#1401) were flowing through the Bash hook completely unfiltered.

Fix

One `RtkRule` change in `src/discover/rules.rs`:

```diff

  • pattern: r"^((p?np(m|x)|p?npm\s+(exec|run|run-script)|npm\s+(rum|urn|x)|pnpm\s+dlx)\s+)?prisma",
  • pattern: r"^((p?np(m|x)|p?npm\s+(exec|run|run-script)|npm\s+(rum|urn|x)|pnpm\s+dlx|bunx)\s+)?prisma",
    rtk_cmd: "rtk prisma",
    rewrite_prefixes: &[
  •    "bunx prisma",
       "npm exec prisma",
       …
    
    ],
    ```

No new output-filtering logic — the entire Bun-Prisma stack goes through the same `src/cmds/js/prisma_cmd.rs` handler as npx/pnpm/npm; only the rewrite recognition was missing.

Behaviour

Input After
`bunx prisma migrate dev` `rtk prisma migrate dev`
`bunx prisma migrate dev --name add_col` `rtk prisma migrate dev --name add_col`
`bunx prisma migrate deploy` `rtk prisma migrate deploy`
`bunx prisma migrate status` `rtk prisma migrate status`
`bunx prisma generate` `rtk prisma generate`
`bunx prisma db seed` `rtk prisma db seed`
`bunx prisma studio` `rtk prisma studio`

`npx prisma` / `pnpm prisma` / `pnpm dlx prisma` continue to work exactly as before — same rule, just one more alternation branch.

Scope notes

  • This PR is intentionally narrow: it only adds `bunx` to the existing Prisma rule. Other `bun` runner forms (`bun x`, `bun run`, bare `bun prisma`) are not covered here; if usage data shows they matter we can extend the alternation in a follow-up.
  • Other RTK-handled binaries that ship as `bunx ` (vitest, playwright, tsc, prettier, biome, jest, eslint…) are out of scope. The reporter only flagged Prisma — happy to do a sweep in a separate PR if maintainers want broad bun adoption.

Test plan

  • `test_classify_prisma` and `test_rewrite_prisma` extended with `bunx prisma` (locks the invariant fence per runner).
  • New `test_rewrite_bunx_prisma_subcommands` covers the six subcommand shapes the reporter named.
  • `cargo fmt --all` clean.
  • `cargo clippy --all-targets` zero warnings.
  • `cargo test --bin rtk -- --test-threads=8` → 1910 passed.

Fixes #1401

Bun is now the primary JS runtime on a growing share of Prisma projects.
`bunx prisma <sub>` is semantically equivalent to `npx prisma <sub>` —
same CLI, same output format, same subcommands — but the hook didn't
recognise it, so 45+ monthly invocations per reporter were flowing
through the Bash hook completely unfiltered.

Add `bunx` to the existing Prisma `RtkRule`:

- Regex pattern: insert `|bunx` into the runner alternation so
  `bunx prisma …` classifies as `Supported(rtk prisma)`.
- `rewrite_prefixes`: add `"bunx prisma"` so the rewrite path produces
  `rtk prisma …` and main.rs's filter dispatch picks up the existing
  `src/cmds/js/prisma_cmd.rs` handler unchanged.

No new output-filtering logic is needed — the entire Bun-Prisma stack
goes through the same code path as npx/pnpm/npm; only the rewrite
recognition was missing.

Tests:
- Extend `test_classify_prisma` and `test_rewrite_prisma` with
  `bunx prisma` so the same per-runner invariant fence guards bun.
- Add `test_rewrite_bunx_prisma_subcommands` covering the six surface
  shapes the reporter calls out (`migrate dev`, `migrate dev --name …`,
  `migrate deploy`, `migrate status`, `generate`, `db seed`, `studio`).
  Pins the regex against a future tweak that silently drops one shape.

cargo fmt / clippy --all-targets / test --bin rtk: 1910 passed,
0 warnings.

Fixes rtk-ai#1401
@YOMXXX

YOMXXX commented May 25, 2026

Copy link
Copy Markdown
Contributor Author

Reviewer guide to reduce review time:

Expert lens: rewrite registry / JS tooling.

This is a narrow rule-table change: bunx prisma ... now routes through the existing rtk prisma handler, same as npx prisma, pnpm prisma, and related runners. There is no new Prisma output parser and no new command implementation.

Suggested review checks:

  • Verify the regex only adds the bunx runner branch and does not broaden matching beyond Prisma.
  • Verify rewrite_prefixes includes bunx prisma, so the rewrite strips the runner and leaves the Prisma subcommand unchanged.
  • Confirm existing non-bun Prisma runners remain covered by the expanded tests.

@KuSh

KuSh commented Sep 3, 2026

Copy link
Copy Markdown
Collaborator

Heads-up rather than a review: #988 (bun/deno runtime support) is close to landing and adds a broad ^bunx\s+ → rtk bunx rewrite rule.

That does not supersede this PR — routing bunx prisma to the prisma filter is strictly better than routing it to the generic bunx path, which is what #988 alone would do. Keeping this open.

It does mean the two rules overlap, and classify_command takes the first match in RULES, so once #988 merges this will need the prisma rule ordered ahead of the generic bunx one (and a test pinning that order, since it is otherwise silent). Worth a rebase after #988 to confirm the ordering still resolves the way you intend.

@KuSh KuSh self-assigned this Sep 9, 2026
@KuSh

KuSh commented Sep 19, 2026

Copy link
Copy Markdown
Collaborator

Thanks for this, and for the scoping notes that made the Prisma surface explicit. #988 (merged 2026-09-03) added Bun and Deno support, including a general ^bunx\s+ rewrite rule, so bunx prisma migrate dev is now rewritten to rtk bunx prisma migrate dev instead of streaming raw, which is the unfiltered behaviour issue #1401 reported. Adding bunx to the prisma rule no longer has an effect on top of that: classify_command keeps the last matching rule in the RULES array, and the bunx rule sits after the prisma one, so the rebased hunk would be a no-op and the new test would fail. There is still something worth doing here, which is routing bunx prisma to the dedicated prisma filter rather than the generic npm line filter, and that needs the bunx rule to defer to tool-specific rules; an issue or a narrow PR on that precedence question would be very welcome. Happy to reopen if you read the rule ordering differently.

@KuSh KuSh closed this Sep 19, 2026
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.

feat: rewrite bunx prisma → rtk prisma (bun runner for Prisma CLI)

2 participants