Repository navigation
refactor(cli): one run-prompt parser, and strip the mouse flags - #1420
Conversation
The parser lived in cli.tsx with a hand-written copy in cli.spec.ts. The copy had fallen six flags behind the original — --mode, --json, --output-format, --trust-directory and the alt-screen pair were removed by the parser and left in the prompt by the copy — so those tests passed against a parser nobody ships. Resyncing the copy, which is what I did first, does not fix that. A duplicate that can drift will, and no test written against the duplicate can notice, because it is testing the duplicate. So there is one parser now, in run-prompt-args.ts, imported by cli.tsx and by the spec. The tests derive their cases from the parser's own flag lists rather than a list typed beside them, so a flag added to the parser is covered the moment it is added. A second test reads the long flags out of the --help text and fails when one is documented but not filtered. That second test immediately found --mouse and --no-mouse, which a hand-written enumeration had missed twice: they were documented, never stripped, and would arrive as the first words of the user's prompt. Display flags are meaningless on a non-interactive run, exactly like the alt-screen pair already handled. Kept free of imports so cli.tsx's --version/--help fast path stays intact. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
nc-review: nothing to raise@will-lamerton — nothing to raise from the automated review. The PR consolidates the run-prompt flag parser into 🔴 blocking · 🟠 a reviewer would ask for a change · ⚪ optional Automated code review — correctness, security, design, tests, plus duplicates and scope. A human still decides; this is not a substitute for review and is not exhaustive. The required status checks separately cover lint, formatting, types, unused dependencies, the test suite and the build. This bot never merges. Maintainers can rerun with |
…mpt parser Nano-Collective#1420 landed while this PR was open and removed the duplicated run-flag list, leaving one parser in run-prompt-args.ts. This branch had added a third copy in utils/cli-flags.ts, which is the thing Nano-Collective#1420 exists to prevent, and it had already drifted: it did not know --mouse/--no-mouse, so `nanocoder review --mouse main` filtered nothing, kept main as a second positional, and told the user their own branch name was an extra argument. Post-merge it would also have missed --prompt-file. So cli-flags.ts is gone. parseReviewCliArgs filters against the lists run-prompt-args.ts exports, and cli.tsx takes main's parseRunPrompt and --prompt-file handling unchanged. The spec keeps main's version of the shared tests, including the derived-from-the-parser coverage that replaced the hand-written mirror. The review guard tests and the flags-before-run tests come across as they were, and the filterCliFlags tests are replaced by one that walks RUN_FLAGS_WITH_VALUES/RUN_FLAGS_STANDALONE through the review parser, so the next flag added is covered the moment it is added. tsc, biome and knip clean; 112 tests pass across cli, review, review-cli and run-prompt-args.
Description
Follow-up to #1415, and a correction. I claimed there that a test now stopped the CLI parsing mirror from drifting again. It did not.
What I actually added enumerated the six flags I happened to have found and checked them against the hand-written copy. A seventh flag added to
cli.tsxtomorrow would drift exactly as before and that test would pass, happily, because it was testing the copy.Resyncing a duplicate does not fix a duplicate. So there is one parser now, in
run-prompt-args.ts, imported bycli.tsxand bycli.spec.ts. There is nothing left to drift.The tests are derived, not typed
--helptext and fails if one is documented but not filtered.That second test found two more flags
--mouseand--no-mouseare documented and were never stripped. So:sent the model a prompt beginning with the word
--mouse. Harmless in effect — nobody passes a mouse flag to a non-interactive run — but they are display concerns exactly like the--alt-screenpair that was already stripped, and my hand-written enumeration had missed them twice.--presetand--leanalso came up and are correctly excluded: they belong tonanocoder initand cannot followrun.Type of Change
Changeset
pnpm changeset) describing this change for the changelogTesting
Automated Tests
.spec.ts/tsxfilespnpm test:allcompletes successfully) — rancli.spec.ts(61 passing) plustest:types,test:lint,format:check,test:knipandbuild; the full suite is long-running and left to CIManual Testing
Re-ran the real binary after the extraction to confirm behaviour is unchanged — a 187 KB
--prompt-fileprompt still returns{"kind":"success","finalText":"ACCEPTED"}.run-prompt-args.tsis deliberately import-free socli.tsx's--version/--helpfast path is untouched.