Commit 31bdcbb
committed
types(mcp): finish the option-plumbing sweep, and cover both arms of every fallback (#9824)
The review found `explainReviewRiskCli` reading `options.login` raw. That one was the visible end of a
family -- seven more sites read an option without narrowing it, each reachable by an ordinary typo:
- `analyze-branch --login` and `review-pr --login` sent boolean `true` as the contributor login.
- `login --github-token` with no value took the token branch with `true` as the token, instead of
falling through to the device flow.
- `Number(options.limit)` on a bare `--limit` is 1, so the flag silently capped an audit at one row
rather than leaving the server's default in place. Same for `--window-days`.
- `String(options.since)` sent `?since=true`, which the route reads as a cursor.
- `validate-config --file` passed a `!options.file` guard (a bare flag is `true`, which is truthy)
and then read the manifest from the path "".
Rather than add an eighth copy of each chain, the duplicated ones are now single helpers --
`resolveLogin` (flag, profile session, then two env vars, at 14 call sites), `readOptionalTextFile`
and `issueNumbersOption` -- so there is one place to get it right and one place to test.
`optionalInteger` and `optionalNumber` lose their `any` parameters, which is this issue's subject.
`branchEligibilityFromOptions` restated the route's two enums by hand and dropped anything it did not
recognise. It parses against `branchEligibilityFields` now, exported from the contract for the
purpose: the schema was a pipe, so its members were unreachable through it.
Coverage: the diff is at 100% of lines AND branches in the CLI. Every fallback is exercised from both
sides in `test/unit/mcp-cli-option-resolution.test.ts`, in-process -- the subprocess harness the rest
of the CLI suite uses runs the compiled `dist/`, which v8 cannot instrument, so a path covered only
there reads as uncovered and a regression in one of these arms would land unnoticed.1 parent 9d7f567 commit 31bdcbb
4 files changed
Lines changed: 452 additions & 55 deletions
File tree
- packages
- loopover-contract/src
- loopover-mcp/bin
- test/unit
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
344 | 344 | | |
345 | 345 | | |
346 | 346 | | |
347 | | - | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
348 | 355 | | |
349 | 356 | | |
350 | 357 | | |
351 | 358 | | |
352 | 359 | | |
353 | 360 | | |
354 | 361 | | |
355 | | - | |
356 | | - | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
357 | 369 | | |
358 | 370 | | |
359 | 371 | | |
| |||
0 commit comments