Repository navigation
fix(cli): reject extra positional arguments passed to add - #3891
Merged
Merged
Conversation
`add <a> <b> <c>` silently installed only `<a>` and exited 0, discarding `<b>` and `<c>` with no warning. citty binds only the first positional token to `name`; every token after it still lands in `args._`, but nothing read it. `add` now rejects the extra arguments up front, before touching the registry, naming exactly what was dropped. Co-Authored-By: Miguel Angel <[email protected]>
…ugh citty parsing
miguel-heygen
force-pushed
the
fix/add-command-extra-positional-args
branch
from
October 2, 2026 12:29
5d2eda4 to
2313fca
Compare
Contributor
Edit accuracy: accurate 1216 (base branch 1216), smooth 1022 of thoseThe gate passes. Quarantined, measured but not gated (1)
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
add <a> <b> <c>installed only<a>and exited 0, silently dropping<b>and<c>. citty binds only the first positional token toname; the rest land inargs._, whichaddnever read.addinstalls one item or tag per invocation (a tag is the bulk-install path, e.g.add html-in-canvas). This keeps that contract and makes it honest: extra positional arguments now fail with a usage error that names them, before any project-config write or registry request. With--jsonthe error is printed as{ ok: false, error }, the same shape the command already uses for its other failures.Changes
packages/cli/src/commands/add.ts:run()rejectsargs._.slice(1)when it is non-empty, via the existingfailUsage().packages/cli/src/commands/add.test.ts: one test runsadd a --dir <dir> b cthrough citty's ownparseArgsand asserts aCliUsageError, no fetch, and a message namingb, c; one test checks that a normal single-item install still succeeds.Size
About 60 changed lines: a five-line guard in one command plus two tests. The bug is one unread array, so the fix is small.
Test plan
vitest run src/commands/add.test.tsinpackages/cli: 30/30 pass, exit 0tsc --noEmit -p packages/cli: exit 0oxfmt --checkon both changed files: exit 0