Skip to content

feat(codegen): generate initial command specs from OpenAPI (PRINFRA-121) - #19

Merged
somanshreddy merged 1 commit into
mainfrom
04-01-feat_codegen_generate_initial_command_specs
Apr 2, 2026
Merged

somanshreddy merged 1 commit into
mainfrom
04-01-feat_codegen_generate_initial_command_specs

Conversation

@somanshreddy

@somanshreddy somanshreddy commented Apr 1, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Runs make generate against the real HeyGen OpenAPI spec to produce command specs for all CLI-visible v3 endpoints.

What gets generated: One Go file per group in gen/, each containing command.Spec struct literals. Plus gen/registry.go with the Groups map. These are the data definitions — zero logic. The builder (PR #18) and runtime (PR #20) handle execution.

Groups generated (10):

  • video (4 commands), avatar (6), voice (2), video-agent (7)
  • video-translate (12), webhook (7), asset (1), user (1), overdub (5)

Also in this PR:

  • codegen/examples/overdub.yaml — examples for the new overdub endpoints
  • Grouper tweak: singleton GET endpoints (like GET /v3/user/me) use get verb instead of list, detected from the operation summary. This is the one heuristic in the naming algorithm — documented with an inline comment.
  • Test spec and examples updated for the user me get pattern

Reviewer note: ~1800 lines but ~1700 are generated boilerplate in gen/. Review the template output by spot-checking 2-3 files, not line-by-line.

Testing

All codegen golden tests pass. Generated code compiles.

Files

  • gen/*.go — generated command specs (10 files + registry)
  • codegen/examples/overdub.yaml — examples for overdub endpoints
  • codegen/grouper.go — singleton GET heuristic
  • codegen/grouper_test.go — test for user me get
  • codegen/testdata/test_spec.yaml — user endpoint added
  • codegen/testdata/test_examples.yaml — user example added

somanshreddy commented Apr 1, 2026 •

Copy link
Copy Markdown
Collaborator Author

@somanshreddy somanshreddy changed the title feat(codegen): generate initial command specs feat(codegen): generate initial command specs from OpenAPI (PRINFRA-121) Apr 1, 2026
@linear

linear Bot commented Apr 1, 2026

Copy link
Copy Markdown
PRINFRA-121 CLI M1: OpenAPI codegen pipeline

Build the code generation pipeline that reads openapi/external-api.json and produces CommandSpec structs.

Scope

  • Go program in codegen/ using text/template
  • Parse OpenAPI spec, filter to v3 endpoints only
  • Generate CommandSpec data structs in gen/ (zero logic)
  • overrides.yaml for:
    • Positional arg promotion (prompt, text, file)
    • Command group naming (video-translations → translate, webhooks/endpoints → webhook)
    • Help examples per command
  • make generate SPEC=... target
  • Nested path collapsing (e.g., /webhooks/endpoints/{id}/rotate-secret → webhook rotate-secret)
  • Golden file tests for codegen output stability
  • Generate all ~30 commands, wire into Cobra at startup

Mapping Rules

  • OpenAPI tag → command group
  • POST → create, GET (list) → list, GET (by id) → get, DELETE → delete, PATCH → update
  • Path params → positional args, query params → flags, body fields → flags
  • overrides.yaml exceptions for positional promotion and group naming

Acceptance Criteria

  • make generate produces compilable CommandSpec files for all v3 endpoints
  • Adding a new endpoint to spec + re-running codegen produces new command
  • Generated help text includes descriptions and examples
  • Golden file tests pass
  • Override validation: make generate fails if overrides reference non-existent endpoints

@somanshreddy
somanshreddy force-pushed the 04-01-feat_codegen_generate_initial_command_specs branch from 770922b to cf47353 Compare April 1, 2026 22:10
@somanshreddy
somanshreddy marked this pull request as ready for review April 1, 2026 22:16
@somanshreddy
somanshreddy requested a review from jrusso1020 April 1, 2026 22:49

somanshreddy commented Apr 2, 2026 •

Copy link
Copy Markdown
Collaborator Author

Merge activity

  • Apr 2, 12:01 AM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Apr 2, 12:02 AM UTC: Graphite rebased this pull request as part of a merge.
  • Apr 2, 12:04 AM UTC: @somanshreddy merged this pull request with Graphite.

@somanshreddy
somanshreddy changed the base branch from 04-01-fix_cmd_register_generated_commands_as_nested_cobra_paths to graphite-base/19 April 2, 2026 00:01
@somanshreddy
somanshreddy changed the base branch from graphite-base/19 to main April 2, 2026 00:01
@somanshreddy
somanshreddy force-pushed the 04-01-feat_codegen_generate_initial_command_specs branch from cf47353 to 99c26e0 Compare April 2, 2026 00:02
@somanshreddy
somanshreddy merged commit 8431964 into main Apr 2, 2026
9 checks passed
@somanshreddy
somanshreddy deleted the 04-01-feat_codegen_generate_initial_command_specs branch April 2, 2026 00:04
@somanshreddy somanshreddy added this to the M1: Codegen Pipeline milestone Apr 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants