fix(mcp): parse --json=false and --exit-code=false as real booleans#8725
Conversation
…hey disable parseOptions generic inline-equals handler stored the raw string for every flag, so --json=false became the truthy string false and turned JSON output ON across all options.json consumers (and --exit-code=false still escalated doctor exit code). Parse the json/exit-code inline values to real booleans at the single parse choke point — the explicit boolean-comparison convention already used for --refresh/--help — make doctor exit-code check === true, and teach argsWantJson that --json=false does not want JSON. Bare --json and --json=true are unchanged; only the =false form changes behavior (now correctly disabling). In-process runCli tests cover whoami --json=false/--json/--json=true and doctor --exit-code=false/bare/=true against a failing check.
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8725 +/- ##
==========================================
- Coverage 90.56% 83.82% -6.74%
==========================================
Files 96 98 +2
Lines 22490 24757 +2267
Branches 3884 4744 +860
==========================================
+ Hits 20367 20752 +385
- Misses 1945 3727 +1782
- Partials 178 278 +100
Flags with carried forward coverage won't be shown. Click here to find out more.
|
|
Tip ✅ LoopOver review result - approve/merge recommendedReview updated: 2026-07-26 01:15:26 UTC
Review summary Nits — 5 non-blocking
Decision drivers
Context & advisory signals — never blocks the verdict
Linked issue satisfactionAddressed Review context
Contributor next steps
Signal definitions
🧪 Chat with LoopOverAsk LoopOver a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.
Full command reference: https://loopover.ai/docs/loopover-commands 🧪 Experimental — new and may change. 🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed 💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →. Checked by LoopOver, a quiet PR intelligence layer for OSS maintainers.
|
Closes #8689
Problem
parseOptions' generic--key=valueinline-equals handler (added for--format=table, #2231) stores the raw string for every flag. So--json=falsesetoptions.json = "false"— a non-empty, truthy string — and everyoptions.jsonconsumer (23 call sites) pluscli-error.ts'sargsWantJsonchecks truthiness, so the flag turned JSON output ON, the opposite of what it says. The identical bug hitdoctor --exit-code=false, which still escalated the exit code to 1.Fix
The Requirements allow "the same
=== true(or equivalent explicit boolean-parsing) pattern" — this PR implements the explicit boolean parse at the single choke point every consumer flows through, so all 23options.jsonconsumers anddoctor'soptions.exitCodecheck compare against a guaranteed real boolean (never a raw string), exactly the semantics of the--refresh/--help=== trueconvention:parseOptions(packages/loopover-mcp/bin/loopover-mcp.ts): the inline--key=valuevalues for the boolean flagsjson/exitCodenow parse to a real boolean — only the exact string"false"(and empty"", which was already falsy) disables; any other value keeps today's enabling behavior. Bare--jsonand--json=trueare unchanged; only the=falseform changes behavior (now correctly disabling).doctor: the exit-code check is now the explicitoptions.exitCode === true && …comparison (the--refreshline-4033 convention), so--exit-code=falsekeeps the exit code at 0 even when checks need attention.argsWantJson(packages/loopover-mcp/lib/cli-error.ts):--json=falseno longer counts as wanting JSON on the failure path.Tests (in-process
runCli, the mcp-cli-basics.test.ts #8587 pattern)New
test/unit/mcp-cli-bool-flag-parsing.test.ts+ anargsWantJsoncase intest/unit/mcp-cli-error.test.ts, all red onmainbefore the fix:whoami --json=false→ plain textJSONbored\n, not JSON{"status":"authenticated","l…doctor --exit-code=falsevs failing auth check → exit 0status: "needs_attention"expected 1 to be +0--json/--json=truestill enable JSON--exit-code/--exit-code=truestill escalateargsWantJson("--json=false")→ falseexpected true to be falseinit-client --print=codexrenders the codex snippetFull runs:
mcp-cli-bool-flag-parsing,mcp-cli-error,mcp-cli-basics,mcp-cli-doctor— 51/51 passing;tsc --noEmitclean.Coverage
Every changed executable line in
bin/loopover-mcp.ts(thebooleanFlagsset, the inline boolean parse, doctor's return) andlib/cli-error.tsis exercised in-process with both branch directions taken (verified against the lcov report: allBRDAarms on the changed lines are non-zero), covering the=falseand default/=truebranches for both flags as required.