Generate CLI output schemas from command output types
维护者通常 1 天内回复
已经有一个关联 PR 被合并了。
- #1830 来自 @sentry-junior —— 已合并
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 12/100
- Issue 类型
- 重构
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- typescript
调研方向
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.
由索引模型根据 Issue 内容生成。
描述
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.
--
- 主要语言
- TypeScript
- 星标
- 949
- 派生
- 171
- 平均合并
- 23 小时 5 分钟
- 30 天内合并 PR
- 320
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
getsentry/toolkit 的其他 Issue
-
CLI enhancement MCP
难度 2/5 1-3 小时 新手友好度 63/100
getsentry/toolkit#1908 · 1 条评论 ·
维护者通常 1 天内回复
-
Docs MCP URL normalization retains query strings and fragments可能已有人在做 @pcbeingused333 于 4 天前认领。 未关闭bug MCP
难度 2/5 1-3 小时 新手友好度 73/100
getsentry/toolkit#1618 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
getsentry/toolkit#1471 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 35/100
getsentry/toolkit#1925 · 1 条评论 ·
维护者通常 1 天内回复
-
enhancement MCP
难度 5/5 一周以上 新手友好度 25/100
getsentry/toolkit#1911 · 1 条评论 ·
维护者通常 1 天内回复
查看 getsentry/toolkit 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
paperclipai/paperclip#19120 ·
维护者通常 1 天内回复
-
Gradle liquibaseDiffChangelog drops jhi_date_time_wrapper可能已有人在做 @mraible 今天认领。 未关闭area: triage theme: undefined
难度 2/5 1-3 小时 新手友好度 88/100
jhipster/generator-jhipster#35998 ·
维护者通常 1 天内回复
-
ai:assign:coding feature p3 ui-ux windows
难度 1/5 1 小时以内 新手友好度 82/100
CherryHQ/cherry-studio#23569 · 2 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
难度 1/5 1 小时以内 新手友好度 78/100
lingdojo/kana-dojo#33602 · 1 条评论 · 5 个 reaction ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 78/100
GoogleCloudPlatform/BigQuery-Agent-Analytics-Plugins#16 ·
维护者通常 1 天内回复