cmd: add CLI-surface description overrides overlay (API-488)#169
Open
somanshreddy wants to merge 1 commit into
Open
cmd: add CLI-surface description overrides overlay (API-488)#169somanshreddy wants to merge 1 commit into
somanshreddy wants to merge 1 commit into
Conversation
This was referenced Jun 12, 2026
96ec708 to
d25524a
Compare
Some OpenAPI descriptions are written in raw HTTP terms ("poll via
GET /v3/videos/{id}", "Pass to POST /v3/video-agents") that mislead a CLI
user, who drives the API with commands and flags. This adds a sparse,
CLI-authored overlay that reframes those few cases in CLI terms.
The overlay lives in internal/clidesc (an importable package, so the builder
and a future tool can share one source of truth). It is keyed by
(Endpoint, Method) and resolved at command-build time in buildCobraCommand;
command.Spec is generated and immutable and is never mutated. Mirrors the
DefaultColumns curated-lookup pattern (see AGENTS.md). Precedence: overlay
wins, everything else falls through to the generated spec text unchanged.
Applies to cobra Short (summary), Long (description), flag usage, and
schema-field descriptions surfaced via --request-schema/--response-schema.
21 overrides land across video/voice/brand/avatar/video-agent/video-translate/
lipsync/asset commands.
An earlier spec-extension approach (x-cli-description) was considered and
dropped: the API spec (EF) will not own CLI-surface descriptions, so this
runtime overlay is the single mechanism. Default *values* (e.g. aspect_ratio)
remain owned by the existing x-cli-default extension.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
d25524a to
d840978
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Scope
Surfaces: CLI | Module: Output/Builder
Description
The CLI generates its command surface from HeyGen's OpenAPI spec. A handful of spec descriptions are written in raw HTTP terms —
poll via GET /v3/videos/{id},Pass to POST /v3/video-agents,Use GET /v3/video-translations/languages— which mislead a CLI user, who drives the API with commands and flags rather than raw HTTP calls. This PR adds a sparse, CLI-authored description overlay that reframes those few cases (e.g. "poll withheygen video get <video-id>, or pass--wait").Runtime overlay, not a spec/codegen change.
command.Specis generated and immutable (AGENTS.md), so the overlay is resolved at command-build time inbuildCobraCommandand never mutates the Spec. It mirrors the existingDefaultColumnscurated-lookup pattern: hand-written data ininternal/clidesc(an importable package so the builder and tooling share one source of truth), looked up by Spec and applied as the Cobra command/flag/schema text is built. Putting this ingen/was a non-starter (regenerated and wiped bymake generate); mutating the Spec at runtime is explicitly forbidden.Keyed by
(Endpoint, Method). That pair uniquely identifies aSpec, so a key survives a command rename in the generated surface. A test asserts every override key matches a real generated command, so a stale key fails loudly on the next resync.Precedence: overlay wins; everything else falls through.
SummaryoverridesShort,DescriptionoverridesLong,Flags[name]overrides a flag's usage, andFields[json_name]overrides a schema property's description in--request-schema/--response-schemaoutput (applied to a copy of the schema JSON at render time; the Spec's schema string is untouched). Any field left empty/absent falls through to the generated spec text unchanged. Most commands have no override.An earlier spec-extension approach (
x-cli-description, #167) was considered and closed: the API spec (EF) will not own CLI-surface descriptions, so this runtime overlay is the single mechanism. Default values (e.g.aspect_ratio) remain owned by the existingx-cli-defaultextension.Override coverage
21 of the 22 reviewed overrides landed: 5 operation descriptions, 5 flag-help reframes, 11 schema-field reframes. One was dropped —
ExternalCreateVideoAgentSessionResponse.video_id(theGET /v2/videos/{video_id}polling field): it does not exist anywhere in the generated surface (MCP-only/v2model), as the draft anticipated. One draft item (GenerateVideoResponse.video_translation_id) was re-mapped: the CLI'svideo-translate createresponse actually returnsvideo_translation_ids(plural array, no poll text); the singularvideo_translation_idpoll field lives onvideo-translate proofreads generate, which is where the override was keyed. Thelook_idpositional-arg reframe was not applied as a standalone entry because positional-arg help is never rendered in Cobra--help; the same guidance is already delivered via theAvatarLookItem.idresponse-schema field, which is overridden.Flag-help overrides use plain quotes rather than backticks: Cobra/pflag treats the first backtick-delimited token in a flag's usage string as the value placeholder (it would render
--style-id heygen video-agent styles listinstead of--style-id string). Backticks are kept inSummary/Descriptionand schema fields, where they render fine.Testing
make buildandmake testpass.make lintis currently broken on cleanmain(golangci-lint built for go1.23 vs the go1.25 toolchain) — unrelated to this change; rangofmt -l(clean) andgo vet ./...(clean) as substitutes.New tests in
cmd/heygen/descriptions_test.gocover: operationLongoverride applied (and HTTP text gone); flag-usage override applied while a sibling flag falls through; response-schema field override applied while a sibling field is untouched; a fully non-overridden command keeping its generated Short/Long/flag text; the resolver helpers directly (override-wins and fall-through, including malformed/no-op schema); and a guard that every override key maps to a real generated command.