Repository navigation
Description
Summary
pnpm run bb:dev -- <command> <positional> --<flag> fails for any CLI command that takes a positional argument followed by a flag, with error: too many arguments. The root cause is not bb's own argument parsing: pnpm 9.15.0 forwards the -- separator itself as a literal argument to the underlying script, and Commander.js treats that literal -- as "end of options," so the trailing flag gets parsed as an extra positional instead of an option.
Versions and environment
- bb from source at commit
99c0ad71841ff6ff2d42b3f7864b6dba0b0f7337(main) - pnpm 9.15.0 (
packageManagerpin inpackage.json), Node v22.19.0 - macOS 25.5.0 (Darwin), arm64
- No provider/agent involved; pure CLI dev-workflow bug
Steps to reproduce
pnpm run --silent bb:dev -- machine show <id> --json- Observe:
error: too many arguments for 'show'. Expected 1 argument but got 2.
Also fails reordered (pnpm run --silent bb:dev -- machine show --json <id>) with the same error, and fails for other commands with the same positional-then-flag shape (machine join-code --json, machine remove <id> --yes).
Does not reproduce when the same args are handed to the compiled CLI directly, bypassing pnpm's -- forwarding:
node apps/cli/dist/index.js machine show <id> --json
That runs fine (only fails later, on "machine not found," for an unrelated reason: I used a fake id).
Minimal isolation, no bb code involved at all:
// package.json
"scripts": { "debug:argv": "node -e 'console.error(process.argv.slice(2))'" }
$ pnpm run --silent debug:argv -- foo bar
[ '--', 'foo', 'bar' ]
$ npm run debug:argv -- foo bar
[ 'foo', 'bar' ]
pnpm includes the literal -- token in argv passed to the script; npm strips it. bb's packages/scripts/src/commands/run-cli.ts forwards process.argv.slice(2) straight through to the spawned CLI process (resolveCliExecution, lines 17-33), so that leading -- lands as a real CLI argument: node apps/cli/dist/index.js -- machine show <id> --json. Commander then treats everything after that -- as literal positionals, so --json becomes a second positional for the show <id-or-name> command (defined here), which only accepts one.
Confirmed directly:
$ node apps/cli/dist/index.js -- machine show <id> --json
error: too many arguments for 'show'. Expected 1 argument but got 2.
$ node apps/cli/dist/index.js machine show <id> --json
Error: Machine '<id>' was not found. Available machines: ...
Expected vs actual
Actual: any pnpm run bb:dev -- <command> <positional> --<flag> invocation fails at the parser with error: too many arguments for '<command>'. Expected N but got N+1, before bb's own command logic ever runs.
Expected: pnpm run bb:dev -- machine show <id> --json behaves the same as calling the compiled CLI directly with those same logical arguments.
Evidence
package.jsonscript:"bb:dev", line 48.run-cli.tsforwarding site:resolveCliExecution, lines 17-33.- Measured by direct comparison of
pnpm runvsnpm runargv forwarding for the same script and args (above); the discrepancy is 100% reproducible across repeated runs.
What you ruled out
- Not a bug in bb's Commander command definitions: calling the compiled CLI directly with identical logical arguments (no
--prefix) works correctly. - Not fixed by reordering the flag before the positional; both orders fail identically once the stray
--is present. - Not specific to
machine show:machine join-code --jsonandmachine remove <id> --yesfail the same way, and the minimalnode -erepro shows it has nothing to do with bb's command definitions at all. - Searched open and closed issues for this; found none.
Suggested priority and effort
Low-to-medium — no data loss, but it silently breaks routine bb:dev CLI usage and scripting for anyone who follows the normal pnpm run bb:dev -- <args> convention with a trailing flag, with no obvious workaround short of calling the compiled CLI directly or hitting the HTTP API instead. Effort looks Low: strip a single leading literal -- token from cliArgs in resolveCliExecution before forwarding it to the spawned CLI process.
AGENT GENERATED
Activity
technicalpickles commentedon Sep 3, 2026
Correction on scope, doesn't change the root cause but changes who's actually affected.
This repo's own docs never use the invocation form I reproduced with. README.md and docs/debugging-and-qa.md consistently document the shorthand
pnpm bb:dev <args>(norun, no--), for example:Just verified that form works fine end to end:
(fails for a real reason, no server running in that test, but the args parsed correctly, no "too many arguments").
The bug only reproduces with the more npm-idiomatic
pnpm run bb:dev -- <args>(explicitrun, explicit--), which is where pnpm 9.15.0's literal----forwarding quirk kicks in. So this affects people who type the standard-lookingpnpm run <script> -- <args>form instead of this repo's documentedpnpm <script> <args>shorthand, not everyone usingbb:dev.Root cause and fix location (strip a leading literal
--inresolveCliExecution) are unchanged. Downgrading how many people this actually hits since the documented usage avoids it entirely.bb-slop-cop commentedon Sep 3, 2026
🚨 SLOP COP 🚨 ·
new-issue-autopilotcli,confirmed-repromainand passed after the fix.Normalize the development CLI package separator (get-bb#2999)