Skip to content

fix(cli): reject extra positional arguments passed to add - #3891

Merged
miguel-heygen merged 2 commits into
mainfrom
fix/add-command-extra-positional-args
Oct 2, 2026
Merged

miguel-heygen merged 2 commits into
mainfrom
fix/add-command-extra-positional-args

Conversation

@miga-heygen

@miga-heygen miga-heygen commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

add <a> <b> <c> installed only <a> and exited 0, silently dropping <b> and <c>. citty binds only the first positional token to name; the rest land in args._, which add never read.

add installs 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 --json the 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() rejects args._.slice(1) when it is non-empty, via the existing failUsage().
  • packages/cli/src/commands/add.test.ts: one test runs add a --dir <dir> b c through citty's own parseArgs and asserts a CliUsageError, no fetch, and a message naming b, 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.ts in packages/cli: 30/30 pass, exit 0
  • Mutation: disabling the guard makes the rejection test fail (1 failed, 29 passed, exit 1)
  • tsc --noEmit -p packages/cli: exit 0
  • oxfmt --check on both changed files: exit 0

miga-heygen and others added 2 commits October 2, 2026 05:21
`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]>
@miguel-heygen
miguel-heygen force-pushed the fix/add-command-extra-positional-args branch from 5d2eda4 to 2313fca Compare October 2, 2026 12:29
@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Edit accuracy: accurate 1216 (base branch 1216), smooth 1022 of those

The gate passes.
Smoothness is reported in the artifact, not gated. A case fails only if it fails 2 of 3 runs.

Quarantined, measured but not gated (1)

@miguel-heygen
miguel-heygen merged commit ded5fa8 into main Oct 2, 2026
146 checks passed
@miguel-heygen
miguel-heygen deleted the fix/add-command-extra-positional-args branch October 2, 2026 13:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants