Repository navigation
feat(cli): Generate completion command sets from route metadata - #1557
Conversation
Commands now declare `completionTarget: "org" | "org/project"` in buildCommand (also accepted by buildListCommand/buildDeleteCommand; buildOrgListCommand sets "org"). A new `generate:completions` step walks the route tree and writes the gitignored src/generated/completion-targets.ts, which the `__complete` fast path imports instead of the hand-maintained ORG_PROJECT_COMMANDS and ORG_ONLY_COMMANDS sets. The placeholder-heuristic drift test is replaced with a check that the generated sets match the route tree. `project create` keeps its explicit name:platform completer. Fixes #1527 Co-Authored-By: byk <burak.kaya@sentry.io>
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
The command takes LIST_TARGET_POSITIONAL (org/, org/project, project), so it should use the org/project completer like its peer list commands.
|
Wouldn't it be better to bake this into the existing |
Instead of a separate `completionTarget` builder option, target positionals now use `parseOrgTarget` / `parseOrgProjectTarget` from src/lib/completion-target.ts in place of `String`. The generator reads the kind straight from each command's `parameters`. Commands sharing a tagged positional pick up completion automatically: `alert issues list` (LIST_TARGET_POSITIONAL) and `feedback resolve|unresolve|spam` (feedbackIdPositional). Org-scoped list commands use the new LIST_ORG_TARGET_POSITIONAL.
|
Done in 68d6f53. I removed the Positionals that several commands share carry the kind automatically: |
Add ORG_TARGET / ORG_PROJECT_TARGET / COMPLETION_TARGETS constants and use them instead of string literals across introspect, complete, and tests. The generator now writes src/generated/completion-targets.json via JSON.stringify (like api-schema.json) instead of hand-assembling a TypeScript module; complete.ts builds its path → target map from it. Co-Authored-By: byk <burak.kaya@sentry.io>
Fixes #1527.
The
ORG_PROJECT_COMMANDSandORG_ONLY_COMMANDSlists incomplete.tswere maintained by hand. The only safeguard was a test that guessed org-scoped commands from their placeholder text, so a missing entry was caught after the fact, or not at all.Target positionals now declare the completion kind through their parser. They use
parseOrgProjectTargetorparseOrgTargetfromsrc/lib/completion-target.tsinstead ofString. Both return their input unchanged. The kind is identified by which parser the positional uses, so it lives inparametersnext to the placeholder. Shared positionals carry it automatically:LIST_TARGET_POSITIONAL,issueIdPositional, andfeedbackIdPositionalare tagged org/project.LIST_ORG_TARGET_POSITIONALis new and is used by org-scoped lists (team, repo, integration, monitor and release list). A command whose positionals mix both kinds fails generation.A new
generate:completionsstep walks the route tree and writessrc/generated/completion-targets.ts, which the__completefast path imports. The file is gitignored likeskill-content.ts. It runs insidegenerate:docs, so it is regenerated duringdev,build,bundle,typecheckandtest.complete.tsstill doesn't load the route tree at runtime.Completion changes compared with the old hand-written lists:
agent-conversation listnow completes org/project instead of org only, because it takes the standard list target.alert issues listandfeedback resolve|unresolve|spamgain org/project completion, because they share a tagged positional with commands that already had it.project createkeeps its dedicatedname:platformcompleter.Command lookup in
complete.tsnow matches the first prefix of the typed words that names a command, instead of always using the first two words. Without this, nested commands likealert issues listcould not be completed.The placeholder-heuristic drift test is replaced with a check that the generated sets match
extractCompletionTargets(routes). There are also unit tests for nested, variadic, hidden, and mixed-kind positionals.via Junior system actor
event.--
View Junior Session in Sentry