Generate CLI output schemas from command output types
Les mainteneurs répondent en général sous 1 jour
Une pull request liée a déjà été fusionnée.
- #1830 par @sentry-junior — fusionnée
Évaluation
- Difficulté
- 5/5
- Temps estimé
- Plus d'une semaine
- Accessibilité débutants
- 12/100
- Type d'issue
- Refactorisation
- Clarté
- Plutôt claire
- Activité
- À l'abandon
- Stack technique
- typescript
Piste de recherche
Start with packages/cli/src/commands/alert/output-schemas.ts to see how API fields and hand-written CLI fields are declared alongside the TypeScript output types. The existing completion-target and command-api generators are the model for any build step, and packages/cli/AGENTS.md is where the new declaration convention would be documented. This is design work, and PR #1830 is already open against it, so pick it up only after confirming with maintainers which option is chosen.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Problem
Command output schemas (OutputConfig.schema) drive --fields completion, the JSON field tables in --help, and the generated skill references. Since #1783, the fields that come from the Sentry API are taken from the generated @sentry/api/valibot response schemas (for example packages/cli/src/commands/alert/output-schemas.ts). Fields the CLI adds itself are still written by hand, next to a TypeScript output type that describes the same data:
- target context:
org,project,orgSlug,targetProject - status and result flags: the alert
statuslabel,deleted,dryRun(DryRunOutputField) - computed values:
dsn,url, dashboardperiod/fetchedAt, widgetdata
So every command declares its JSON output twice: once as the TypeScript type its func yields and output.human consumes, and once as a valibot schema. Nothing checks that the two agree. The schema is documentation only (nothing validates output against it), so drift goes unnoticed. A field added to the type silently stops completing, and a renamed field keeps completing a path that no longer exists. Raised by @BYK in https://github.com/getsentry/toolkit/pull/1783#discussion_r4448809546 ("Shouldn't this be auto-generated?").
Goal
One source of truth per command's JSON output: the API part from @sentry/api, and the CLI-added part derived from the command's output type instead of written by hand.
Options
- Generate schemas from TypeScript types at build time. Add a
generate:*step, like the existing completion-target and command-api generators, that reads each command's declared output type and emits a valibot (or plain field-path) description. Candidates: the TS compiler API, or a types-to-schema tool. Descriptions would come from TSDoc on the type's properties.- Pros: types stay the source of truth, and descriptions sit next to the fields.
- Cons: output types are often inferred or built from
Pick/intersections over SDK types. The generator has to resolve those, and it has to know which type belongs to which command.
- Invert it: schema first, types derived. Write the CLI-added entries once as valibot and derive the TS type with
InferOutput<typeof Schema>, sofunc's return type andoutput.human's parameter come from the schema.- Pros: no new generator, and the compiler enforces that the two agree.
- Cons: valibot becomes the authoring format for output types, which means touching many commands.
- Keep both, add a type-level check. Keep hand-written schemas, but add a compile-time assertion per command, e.g.
Expect<Equal<keyof InferOutput<typeof Schema>, keyof Output>>, or a test that compares field paths.- Pros: smallest change.
- Cons: still two copies to maintain, and only drift is caught.
Option 2 looks like the best fit for buildCommand. Option 1 is worth it only if descriptions can come from TSDoc reliably.
Dependencies
- Descriptions for API fields need the upstream change from the #1783 plan:
@sentry/api's generated valibot has nov.description()actions today, so the CLI wraps generated fields inpipe(field, description(...))by hand. Until that lands, this issue only covers the CLI-added fields. - Related: #1387 (migrate fully to
@sentry/apiSDK types), and #1808 / thesentry-cli/json-transform-uses-fieldslint rule (jsonTransformmust applyfields).
Done when
- No command's output schema writes out by hand a field that also exists in its TypeScript output type, or a test/compile error fails when they diverge.
--fieldscompletion,--helpfield tables and the skill references keep working unchanged, and the generated docs don't change unexpectedly.packages/cli/AGENTS.mddocuments how to declare output for a new command.
via @BYK.
--
- Langage dominant
- TypeScript
- Étoiles
- 957
- Forks
- 174
- Merge moyen
- 13 h 16 min
- PR mergées (30 j)
- 407
Préparer son environnement
Ce projet ne fournit ni conteneur de développement, ni Dockerfile, ni guide de contribution : l'installation est à votre charge. Commencez par son README, et consultez notre guide de la première contribution pour les étapes générales.
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de getsentry/toolkit
-
CLI enhancement MCP
Difficulté 2/5 1-3 heures Accessibilité débutants 63/100
getsentry/toolkit#1908 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
Docs MCP URL normalization retains query strings and fragmentsPeut-être pris @pcbeingused333 l’a pris il y a 8 jours. Ouvertebug MCP
Difficulté 2/5 1-3 heures Accessibilité débutants 73/100
getsentry/toolkit#1618 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
getsentry/toolkit#1471 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
Remote MCP: let Bearer-only clients opt into direct token auth (a `Sentry-Bearer` equivalent)Ouverte
Difficulté 4/5 3-5 jours Accessibilité débutants 48/100
getsentry/toolkit#2065 · 7 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 4/5 3-5 jours Accessibilité débutants 48/100
getsentry/toolkit#2047 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de getsentry/toolkit
Issues similaires
-
Difficulté 2/5 1-3 heures Accessibilité débutants 91/100
marimo-team/marimo#11768 ·
Les mainteneurs répondent en général sous 1 jour
-
enhancement good first issue priority: high size: XS
Difficulté 2/5 1-3 heures Accessibilité débutants 85/100
Les mainteneurs répondent en général sous 1 jour
-
clawsweeper:needs-maintainer-review clawsweeper:needs-product-decision clawsweeper:no-new-fix-pr clawsweeper:source-repro impact:ux-friction issue-rating: 🦞 diamond lobster P2
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
openclaw/openclaw#195577 · 1 commentaire · 1 réaction ·
Les mainteneurs répondent en général sous 1 jour
-
[Studio feedback] 对话内容向下滚动时执行过程吸顶时,由于背景色是透明的,导致执行过程标题与下面的具体执行内容重叠,导致了两行信息重叠显示;建议执行过程的背景色设置为会话界面的背景Ouvertebug from-studio
Difficulté 2/5 1-3 heures Accessibilité débutants 66/100
esengine/DeepSeek-Reasonix#15044 ·
Les mainteneurs répondent en général sous 1 jour
-
Web wizard: "Launch without Sandbox" can switch a Structured create to Terminal in the same clickOuvertearea:web bug needs-triage P3
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
agent-of-empires/agent-of-empires#5489 · 1 commentaire · 1 réaction ·
Les mainteneurs répondent en général sous 1 jour