Repository navigation
Conversation
The builtin --token-limit and --token-offset values passed through Number() coercion, so spellings such as 0x10, 1e3, " 5 ", and 5.0 were silently reinterpreted as integers instead of being refused. Admit decimal token text only, as the numeric command options already do through cliIntegerArgument.
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 stricter check preserves valid decimal token-window values. SummaryThe PR rejects non-decimal spellings for
Reviews (1) · Last reviewed commit: "fix(cli): reject non-decimal token windo..." · Reviewed by Greptile |
Summary
The builtin
--token-limitand--token-offsetoptions validated their value withNumber()coercion, so non-decimal spellings were silently reinterpreted instead of refused. They now admit decimal token text only, matching the numeric command options admitted throughcliIntegerArgument(#8919).No linked issue. This completes the same admission rule for the builtin output options that #8386 and #8920 apply to command options. #5544 changes the same options for window bounds; the spelling admission here supersedes its explicit hexadecimal allowance, so its decimal-spelling branch would no longer be reachable for hex input.
Problem and expected behavior
Smallest trigger on current
main(560674e):1e3," 5 ", and5.0are accepted the same way;Number()rewrites the token instead of reporting the spelling. Violated invariant: these options take decimal nonnegative safe integers, and an invalid value must fail withINVALID_OUTPUT_VALUEon its own field before dispatch. After this change all four spellings fail withINVALID_OUTPUT_VALUEnaming the flag.Change and scope
cliOutputValueRejectioninsrc/cliOutput.tsnow requires/^[0-9]+$/uplus a safe-integer value, so hexadecimal, exponent, padded, fractional, signed, and non-ASCII digit spellings are refused on the field.docs/cli.mdstates the decimal-digits spelling for token windows.Follow the contribution scope. Ordinary fix within existing boundaries; maintainer scope decision not applicable.
Contract and boundary impact
cliOutput.ts, before command dispatch. Consumers:validateCliOutputArgumentsdiagnostics; no other callers read these spellings.--token-limit/--token-offsethave no MCP counterpart, so tool schemas and catalog are unchanged.Expected effects:
Evidence and regression coverage
tests/boundary/cli/cliOutput.test.tsrejects0x10,0b101,1e3," 5 ",5.0,+5, and٥for both flags and accepts007, keeping the existing cases.main(560674e).--token-limit 0x10returns{"ok":false,"error":{"code":"INVALID_OUTPUT_VALUE","message":"Invalid value for --token-limit: \"0x10\". Expected a nonnegative safe integer written in decimal digits."}}before any command runs;--token-limit 5and--token-limit 9007199254740991keep working.Boundary regressions covered: malformed-input admission for the builtin argument boundary (wrong-spelling values must fail on their own field). Lifecycle regressions: not applicable; no resources or targets involved.
Validation performed
npm run test:focused -- tests/boundary/cli/cliOutput.test.ts— 64/64 passed (includes the new cases).npm run test:focused -- tests/boundary/cli/cliTokenWindowOutput.test.ts tests/boundary/cli/dispatcher.test.ts tests/boundary/cli/versionReportCli.test.ts tests/boundary/cli/markdownArgumentErrors.test.ts tests/boundary/cli/explicitSensitiveArgumentsCli.test.ts tests/boundary/cli/textUnicodeOutput.test.ts tests/boundary/cli/completions.test.ts— 7 files, 76/76 passed.npm run check:fast— passed (typecheck + lint).npm run docs:check— 9/9 passed.--token-limit 0x10|1e3|" 5 "|5.0all fail withINVALID_OUTPUT_VALUE;5,0,9007199254740991still produce output.Compatibility, safety, and release
Author readiness
Human owner: @Goldloli
Before merge
type(scope): outcome.