Skip to content

ref(cli): Remove the completion-only target parsers - #1750

Merged
BYK merged 1 commit into
mainfrom
ref/cli-remove-completion-only-parsers
Oct 30, 2026
Merged

BYK merged 1 commit into
mainfrom
ref/cli-remove-completion-only-parsers

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

Part of #1564

No command uses parseOrgTarget, parseOrgProjectTarget, or parseIssueTarget anymore. Every target and ID positional now goes through a bound parser (boundPositional, boundArguments, and the target-positional.ts parsers), and those parsers carry the completion kind themselves. The three identity parsers only survived as test fixtures.

  • Removed the three exports from completion-target.ts.
  • Removed them, and parseDashboardTarget (already deleted), from the lint rule name lists that banned them in commands. Removed their lint test cases too.
  • require-target-resolution now bans withCompletionTarget in command files. Without this, a command could rebuild an identity parser that tags the kind and leaves the value for func to parse. No command calls it today; only positional-parse.ts does. Added a lint test case for it.
  • introspect.test.ts now tags its own fixture parsers, so completion extraction keeps the same coverage.
  • Updated packages/cli/AGENTS.md and the doc comments to match.

No runtime behavior changes. The generated completion metadata does not change, because no command used these parsers.

Verified locally: pnpm run typecheck, pnpm run lint, node --test scripts/cli-lint-rules.test.mjs (65 pass), and vitest run test/lib/introspect.test.ts test/script.

via BYK.

--

View Session in Sentry

No command uses `parseOrgTarget`, `parseOrgProjectTarget`, or
`parseIssueTarget` since #1564 moved every target and ID positional onto
bound parsers, which carry the completion kind themselves. Remove them,
and drop them and the already-removed `parseDashboardTarget` from the lint
rules that banned them in commands.

The lint rule now bans `withCompletionTarget` in commands instead, so a
command cannot recreate an identity parser that only tags the kind. The
introspection tests tag their own fixture parsers.

Part of #1564

Co-Authored-By: BYK <burak.kaya@sentry.io>
@vercel

vercel Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
sentry-local Error Error Oct 30, 2026 12:37am UTC

Request Review

@BYK
BYK enabled auto-merge (squash) October 30, 2026 00:49
@BYK
BYK merged commit cadcf27 into main Oct 30, 2026
34 of 35 checks passed
@BYK
BYK deleted the ref/cli-remove-completion-only-parsers branch October 30, 2026 00:51
BYK added a commit that referenced this pull request Oct 30, 2026
Stacked on #1750, which has merged; `origin/main` is merged in, so the
diff is only this change.

Every visible positional now declares how shell completion handles it,
and positionals that can complete now do. Before this, 53 of the 126
positionals had no kind. `sentry alert issues <TAB>`, `sentry sourcemap
upload <TAB>`, `sentry help <TAB>`, and `sentry cli completion <TAB>`
all returned nothing.

**What changed**
- `completion-target.ts` adds the kinds `file`, `directory`,
`org-project-or-directory`, `command-path`, `choice`, `account`,
`project-spec`, and `text` (free text, no suggestions). Commands import
pre-tagged parsers: `parseFilePath`, `parseDirectoryPath`, `parseText`,
`parseCommandPath`, `parseAccountSelector`, and `choiceParser(values)`.
They never tag `String`, and the #1750 ban on `withCompletionTarget` in
commands stays. `choiceParser` returns its input unchanged, so commands
keep their own validation.
- The generator now also writes choice values, including Stricli `enum`
flag values, so zsh and fish get them through `__complete`. It also
writes every route group's subcommands. `__complete` uses these to
complete nested subcommands (`alert issues <TAB>`, `dashboard widget
<TAB>`) and `help`'s command path, and it lists directory entries for
path arguments. Directories get a trailing `/`, and dotfiles show only
when the partial starts with `.`.
- `project create` now uses the `project-spec` kind instead of the
`cmdPath` special case. `parseLoginEmail` moves to `db/accounts.ts` so
`PARSER_TARGETS` can list it. `auth switch`, `auth logout`, and `auth
login` complete stored accounts. `init` completes `org/project` targets,
and directories only once the word looks like a path (`./`, `/`, `~/`),
since init reads any other word as the target.
- `cli completion` completes bash/zsh/fish. `cli defaults` completes its
registry keys, on the first word only. `cli upgrade` completes
nightly/stable/undo.
- `test/lib/completion-coverage.test.ts` walks the real route tree and
fails, naming the command and placeholder, for any visible positional
without a kind. It has no allow-list. The "Shell completion" section of
`packages/cli/AGENTS.md` explains which parser to use for each argument
type and how to add a kind or an entity.

**Follow-ups**
- Positionals marked `text` that could complete: `release deploy`
environment, `issue tags` key, `debug-files find` id, `monitor run`
slug, `build download` id, `api` endpoint (from the API schema),
`schema` query, and local sessions. Local sessions live only in the
daemon's memory, so there is no cheap synchronous read. `event send`
completes paths only, not its optional target.
- Flags: the 184 `String`-parsed flags, numeric parsers, `--fields` from
output schemas, and `--org`/`--project`/`--platform`/`--environment`.
- Shell scripts: zsh flag specs; static nested groups; file directives
(`-o nospace`/`filenames` in bash so a directory doesn't get a trailing
space).
- Entity kinds: releases, environments, teams, monitors, alert rules.

<!-- junior-session-footer:start -->
<!-- junior-conversation-id:agent%3A77d4f761a7cb5e1bf375330d5c1525f1 -->

--

[View Session in
Sentry](https://sentry.sentry.io/explore/conversations/agent%3A77d4f761a7cb5e1bf375330d5c1525f1/?project=4510944073809921)

<!-- junior-session-footer:end -->

---------

Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: BYK <burak.kaya@sentry.io>
Co-authored-by: Claude <noreply@anthropic.com>

This branch had an error being deployed

1 failed deployment
Preview — d69f0bde Deployed Oct 30, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: low PR risk score: low

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant