Skip to content

feat(npm): structured NpmCommands sub-enum with smart script routing#443

Draft
jackfreem wants to merge 2 commits intortk-ai:masterfrom
jackfreem:jackf/feat-npm-subcommands
Draft

feat(npm): structured NpmCommands sub-enum with smart script routing#443
jackfreem wants to merge 2 commits intortk-ai:masterfrom
jackfreem:jackf/feat-npm-subcommands

Conversation

@jackfreem
Copy link

@jackfreem jackfreem commented Mar 9, 2026

Why

The flat rtk npm <args> design had no way to distinguish npm run <script> from other npm subcommands (install, ci, audit, …), and provided no script-aware filter routing. PR #440 patched the immediate double-run bug; this PR replaces the design root-cause.

What

  • Add NpmCommands sub-enum (Run { script, args } + Other passthrough), mirroring the PnpmCommands pattern from PR feat(pnpm): add rtk pnpm [run] <script> with smart filter routing #232
  • Route well-known scripts to specialised filters in main.rs:
    • buildnext_cmd
    • typecheck / tsctsc_cmd
    • lintlint_cmd
    • everything else → npm_cmd::run_script (boilerplate stripping)
  • Add npm_cmd::run_passthrough for non-run subcommands (install, ci, audit, …)
  • Make filter_npm_output pub so it can be reused by other modules
  • Remove the old npm_cmd::run catch-all that caused the double-run bug

References

Replace the flat `rtk npm <args>` catch-all with a proper subcommand
enum matching the pnpm architecture (PR rtk-ai#232):

  rtk npm run build       → next_cmd filter
  rtk npm run typecheck   → tsc_cmd filter
  rtk npm run lint        → lint_cmd filter
  rtk npm run <other>     → boilerplate stripping (run_script)
  rtk npm install / ci …  → raw passthrough (run_passthrough)

Both `rtk npm run build` and `rtk npm build` now correctly invoke
`npm run build`; the earlier double-run bug (rtk-ai#438) is structurally
impossible with explicit subcommand parsing.

Closes rtk-ai#438
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.

'rtk npm run build' is expecting to be run as 'rtk npm build', which confuses the LLM

1 participant