fix(npx): dispatch unknown tools to npx instead of npm#1458
fix(npx): dispatch unknown tools to npx instead of npm#1458KuSh merged 4 commits intortk-ai:developfrom
Conversation
The generic fallback arm of `Commands::Npx` called `npm_cmd::run`, which executes `npm` instead of `npx`. This broke every non-routed npx invocation. `rtk npx cowsay hello` failed with `npm error Missing script: "cowsay"` because the rewrite hook sends `npx ...` through as `rtk npx ...`, and `rtk npx` was then running npm. Mirror the existing prisma generic-subcommand passthrough pattern: resolve npx, forward all args, record a tracked passthrough, and propagate the exit status. Fixes rtk-ai#815
|
Note: the failing benchmark test is pre-existing |
Per @KuSh's review on rtk-ai#1458, the generic npx passthrough arm built its own Command + tracking::TimedExecution inline, duplicating the logic already covered by core::runner::run_passthrough. The sticking point was `SKIP_ENV_VALIDATION`: the existing helper takes tool + args and builds the Command itself, so there was no seam for a caller-supplied env var. Add a `run_passthrough_cmd` variant that accepts a pre-built Command and refactor the existing `run_passthrough` to delegate to it. The npx arm now builds a Command, sets SKIP_ENV_VALIDATION when requested, and hands it to the shared helper. This also upgrades the npx passthrough from a raw `cmd.status()` to the shared streaming + tracking path that pnpm_cmd already uses, so verbose logging and telemetry stay consistent across tools.
|
@KuSh all fixed up |
Add `npm_cmd::exec` for npx and an internal `run_filtered` helper that both `run` (npm) and `exec` (npx) share. The helper resolves the command, applies args, honors SKIP_ENV_VALIDATION, and routes through runner::run_filtered with the npm output filter. The npx fallback in main.rs collapses to `npm_cmd::exec(&args, cli.verbose, cli.skip_env)?`. Per @KuSh review on rtk-ai#1458.
|
Pushed a5e6bf5: moved everything into npm_cmd. Added a private One call-out: I kept Verified: |
KuSh
left a comment
There was a problem hiding this comment.
Just one unneeded change left, otherwise LGTM!
Restores src/core/runner.rs to the develop state. After a5e6bf5 moved npx execution into npm_cmd::exec (routing through runner::run_filtered), nothing calls run_passthrough_cmd anymore. Addresses review feedback on PR rtk-ai#1458.
Per @KuSh's review on #1458, the generic npx passthrough arm built its own Command + tracking::TimedExecution inline, duplicating the logic already covered by core::runner::run_passthrough. The sticking point was `SKIP_ENV_VALIDATION`: the existing helper takes tool + args and builds the Command itself, so there was no seam for a caller-supplied env var. Add a `run_passthrough_cmd` variant that accepts a pre-built Command and refactor the existing `run_passthrough` to delegate to it. The npx arm now builds a Command, sets SKIP_ENV_VALIDATION when requested, and hands it to the shared helper. This also upgrades the npx passthrough from a raw `cmd.status()` to the shared streaming + tracking path that pnpm_cmd already uses, so verbose logging and telemetry stay consistent across tools.
Add `npm_cmd::exec` for npx and an internal `run_filtered` helper that both `run` (npm) and `exec` (npx) share. The helper resolves the command, applies args, honors SKIP_ENV_VALIDATION, and routes through runner::run_filtered with the npm output filter. The npx fallback in main.rs collapses to `npm_cmd::exec(&args, cli.verbose, cli.skip_env)?`. Per @KuSh review on #1458.
Summary
rtk npxdispatching tonpminstead ofnpxfor unrouted tools. The fallback arm ofCommands::Npxcallednpm_cmd::run, sortk npx cowsay hellotried to runnpm cowsay helloand failed with "Missing script".npxpassthrough modeled on the existing prisma generic-subcommand arm a few lines up in the same file.--skip-env(setsSKIP_ENV_VALIDATION=1on the spawned process, matching whatnpm_cmd::rundid).Evidence
Test plan
cargo fmt --all --check && cargo clippy --all-targets && cargo testpass locally (1679 tests, 0 failed). Pre-existing clippy warnings are unrelated to this change.rtk 0.37.2still reproduces withnpm error code ENOENT. Rebuilttarget/debug/rtkfrom this branch routes through npx and prints the cowsay output (see demo above).test_npx_unknown_tool_passthroughnext to the existing clap parsing tests to pin the parse-level contract.Notes
developper CONTRIBUTING.md.CHANGELOG.mdedit since release-please generates entries from commit messages.develop(post feat(refacto-codebase-onboarding): partie 1 - folders and technical docs #826 layout), and preserves--skip-env.Fixes #815