Two gaps left by the held-candidate approach:
pnpm dev run build allow -- runs `dev`, passing it `run build`
pnpm --loglevel debug dev allow -- `debug` read as the script name
npm has no implicit script form (`npm dev` is not a command), so for npm a
bare token before `run` is always an option value — which is what keeps
`npm --userconfig /tmp/npmrc run dev` blocked without enumerating npm's config
surface. pnpm/yarn/bun do accept `pnpm dev`, so for them the FIRST bare token
is the script and everything after it, `run` included, is its argument.
Their option sets are finite, so the value-taking list is extended with the
ones that can precede an implicit script (--loglevel, --reporter, --store-dir,
--registry, --network-timeout, --env-file, ...).
Scanning every candidate token fixed the npm-config bypass but blocked valid
commands: `npm run run dev` runs a script called `run` with `dev` as its
argument, and `npm run build dev` passes `dev` to build. Both were refused
outside tmux.
Anchor on the keyword instead. With a `run`, the script is the token right
after it and everything later is that script's argument. Without one
(`pnpm dev`), the first bare token is the script — held rather than returned,
because a `run` further along proves it was an option value, which is what
keeps `npm --userconfig /tmp/npmrc run dev` blocked without needing to know
npm's whole config surface.
npm accepts any config key as `--key value`, so listing the value-taking
options can never be complete. `npm --userconfig /tmp/npmrc run dev` read the
script name as `/tmp/npmrc`, and the dev server started outside tmux.
Collect every candidate token after the manager word instead of only the
first, keeping the known value-taking options (so `--workspace dev` still
means a workspace named dev, not the dev script) and the `--` stop. An unknown
option's value now gets scanned too: that costs a false positive only when a
config value is literally `dev`, and a refusal the user sees beats a guard
that silently did nothing.
The auto-tmux tests now gate on tmux availability like their neighbours —
without tmux the hook passes the command through by design — and assert the
hook's exit code before parsing its stdout.
pre-bash-dev-server-block.js refuses a dev server outside tmux and
auto-tmux-dev.js is what puts it in tmux, so a command one recognises and the
other does not is the worst outcome: refused, and never detached.
Both carried a copy of the same raw-text regex, each with a comment asking the
other to stay byte-identical — which is exactly how the previous commit left
them, since widening the blocker to quoted and option-separated spellings did
not reach the wrapper.
The classification now lives in scripts/lib/dev-command.js and both hooks call
it. pre-bash-dev-server-block.js drops from 304 lines to 34.