Repository navigation
fix(cli): accept --flag=value for global output flags - #3811
Conversation
`rea <command> --format=json` failed with "Unknown flag: --format". `--filter-output=...`, `--token-limit=...` and `--token-offset=...` failed the same way. Incur reads these global flags only in spaced form, so the equals form fell through to the command parser. Command options already accept both forms, and `rea mcp doctor` parses `--format=` itself. A valued output flag with no value (`--format` last, or `--format=`) also reported the flag as unknown with code UNKNOWN. normalizeCliOutputArguments, in the module that owns output-argument interpretation, now splits the equals forms of the four valued output flags. The entry point passes the normalized argv to rea's output validation and to Incur, so both read the same effective values. A missing value now fails with MISSING_OUTPUT_VALUE and names the flag. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
[Medium impact] The PR appears safe to merge; the previous finding is fixed and no new blocking issue remains. SummaryThe PR makes valued global output flags accept
Reviews (2) · Last reviewed commit: "fix(cli): detect missing output values w..." · Reviewed by Greptile |
The missing-value check scanned argv again after parsing, so it also checked tokens the parser had already consumed as values. For example, `--filter-output --format` selects the field `--format`, yet the second scan reported `--format` as missing a value. parseCliOutputArguments now records the first valued flag it skips for lack of a value, in the same pass that consumes values. Cover normalizeCliOutputArguments directly: values containing `=`, empty values, and command options that only share a prefix. Export it in the dispatcher test's runtime stub as well. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Summary
rea <command> --format=jsonfailed withUnknown flag: --format, and so did--filter-output=...,--token-limit=...and--token-offset=.... Command options already accept--flag=value(--table=tworks), andrea mcp doctorparses--format=itself. Agents write the equals form often, so each such call failed and had to be retried.A valued output flag with no value (
--formatas the last argument, or--format=) also failed withUnknown flag: --formatand codeUNKNOWN, which points at the wrong problem.Now the equals forms behave exactly like the spaced forms. A missing value fails before the command runs with
MISSING_OUTPUT_VALUE: --format requires a value, as in --format <value> or --format=<value>.Problem and expected behavior
Incur extracts its global flags with exact token matches (
token === '--format' && argv[i + 1]). An equals form, or a flag without a value, therefore passes through to the command's option parser, which reports the global flag as unknown. rea'sparseCliOutputArgumentsmirrored that behavior on purpose, so rea's output validation agreed with what Incur would apply. The equals form was consistently ignored rather than honored.Change and scope
src/cliOutput.ts, which owns output-argument interpretation, gainsnormalizeCliOutputArguments. It splits--format=V,--filter-output=V,--token-limit=Vand--token-offset=Vinto the spaced form. Everything else is unchanged, including boolean flags,--json, command options and values that merely contain=.scripts/rea.mjspasses the normalized argv tovalidateCliOutputArguments,createCliResultOutput, Incurserveand the empty-filter fallback. All four therefore read the same effective values, preserving the invariant the existing tests protect.validateCliOutputArgumentsreportsMISSING_OUTPUT_VALUEfor a valued output flag that is last or followed by an empty value. This check runs after the existing filter-slice and token-window checks, so their precedence is unchanged.docs/cli.mddocuments both forms and the new error.mcp doctor, which has its own parser that already accepts--format=; command-local options; MCP.Contract and boundary impact
src/cliOutput.ts), applied at the entry point before Incur.MISSING_OUTPUT_VALUE. Schemas and MCP are unchanged.Expected effects:
Evidence and regression coverage
tests/boundary/cli/cliOutput.test.ts, all through the compiled CLI:--format=json --filter-output=capabilities[0,1]returns the filtered JSON, and--json --token-limit=5is rejected as a token window exactly like the spaced form. The previous assertion, that--token-limit=5was not an active builtin, encoded the old behavior.--format=json --token-limit=5.--format,--filter-output,--token-limitand--token-offset=, and a trailing--format, assertMISSING_OUTPUT_VALUEnaming the flag.src/cliOutput.tsandscripts/rea.mjs, both updated tests fail (Tests 2 failed | 16 passed).Validation performed
npm run test:focused -- tests/boundary/cli/cliOutput.test.ts tests/boundary/cli/closedStdout.test.ts tests/boundary/cli/jsonOutput.test.ts tests/boundary/cli/cliOptionAliases.test.ts: 65 passednpm run test:focused -- tests/boundary/cli/mcpDoctorHelpCli.test.ts tests/boundary/cli/javascriptIntegrityPolicyCli.test.ts tests/boundary/cli/nativeUiScenarioInputCli.test.ts: 15 passed. These cover command-local "Unknown flag" errors, which are unchanged.npm run check:fast: passed;npm run docs:check: passed/Applications/Ghostty.app:--format=json,--format=json --filter-output=...and--token-limit=20now match their spaced forms.--format=, a trailing--format, and--filter-output "" --format yamlgiveMISSING_OUTPUT_VALUEin the selected structured format.--format=xmlstill gives Incur'sInvalid formatmessage.Compatibility, safety, and release
1, now withMISSING_OUTPUT_VALUEinstead ofUNKNOWN.Author readiness
Human owner:
Before merge
type(scope): outcome.🤖 Generated with Claude Code