nanocoder
nanocoder copied to clipboard
[Bug] The CLI silently ignores unknown flags and subcommands (--mdoe plan runs in auto-accept, nanocoder reveiw opens the app)
Description
nanocoder checks flag values (--mode bogus is rejected) but never checks flag names or subcommand names. A typo in --mode is dropped, so run falls back to its default auto-accept mode instead of the mode you asked for. A mistyped subcommand such as reveiw falls through to the interactive app.
Environment
- OS: Windows 11 (10.0.26300)
- Node version: 22.22.3
- Nanocoder version: 1.31.0 (main at 9d88dda7)
- Provider: Ollama
- Model: qwen2.5:1.5b
Steps to Reproduce
- Run
nanocoder --trust-directory --mdoe plan run "Reply with the single word OK". - Run
nanocoder --trust-directory --bogusflag run "Reply with the single word OK". - Run
nanocoder reveiw main. - Run
nanocoder conifg list. - Run
nanocoder "fix the tests"(forgotrun). - For comparison, run
nanocoder --trust-directory --mode plan run ...and--mode bogus.
Expected Behavior
Each of 1-5 stops with a clear error, for example Unknown option --mdoe. Did you mean --mode? or Unknown command "reveiw". Did you mean "review"?, and a non-zero exit code.
Actual Behavior
--mdoe plan run ... -> banner "nanocoder · Ollama · qwen2.5:1.5b · auto-accept", exit 0
--mode plan run ... -> banner "... · plan"
--bogusflag run ... -> runs normally, exit 0
reveiw main -> opens the interactive "Security Warning" screen
conifg list -> opens the interactive "Security Warning" screen
"fix the tests" -> opens the interactive "Security Warning" screen (the prompt is dropped)
--mode bogus -> Invalid --mode value: "bogus". Must be one of: normal, auto-accept, yolo, plan, architect
Suggested Fix
source/cli.tsx: the subcommands are matched one by one (args[0] === 'storage'at line 45,daemon69,skills97,config116,init130,completion184,worktree297,review522,codex/copilotlogin 677/702). After those checks, reject unknown leading words and any--flagthat is not inKNOWN_RUN_FLAGS(source/run-prompt-args.ts:80) or a global flag. Add a "did you mean" suggestion.- The
rundefault is set atcli.tsx:736(developmentMode: cliMode ?? 'auto-accept'). - Add tests that run the CLI with
--mdoeandreveiw.
Additional Context
- Related but different: #1238 (the
--flag=valueform, closed). - [x] I have searched existing issues to ensure this is not a duplicate
- [x] I can reproduce this issue consistently
- [x] This issue occurs with the latest version of nanocoder