nanocoder icon indicating copy to clipboard operation
nanocoder copied to clipboard

[Bug] The CLI silently ignores unknown flags and subcommands (--mdoe plan runs in auto-accept, nanocoder reveiw opens the app)

Open addyCooks opened this issue 1 month ago • 0 comments

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

  1. Run nanocoder --trust-directory --mdoe plan run "Reply with the single word OK".
  2. Run nanocoder --trust-directory --bogusflag run "Reply with the single word OK".
  3. Run nanocoder reveiw main.
  4. Run nanocoder conifg list.
  5. Run nanocoder "fix the tests" (forgot run).
  6. 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, daemon 69, skills 97, config 116, init 130, completion 184, worktree 297, review 522, codex/copilot login 677/702). After those checks, reject unknown leading words and any --flag that is not in KNOWN_RUN_FLAGS (source/run-prompt-args.ts:80) or a global flag. Add a "did you mean" suggestion.
  • The run default is set at cli.tsx:736 (developmentMode: cliMode ?? 'auto-accept').
  • Add tests that run the CLI with --mdoe and reveiw.

Additional Context

  • Related but different: #1238 (the --flag=value form, 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

addyCooks avatar Oct 13 '26 11:10 addyCooks