Skip to content

codegen: add examples.yaml and simplify ArgSpec (PRINFRA-121) - #11

Merged
somanshreddy merged 1 commit into
mainfrom
03-31-codegen_add_overrides_system_for_group_renames_skip_patterns_positional_promotions
Apr 1, 2026
Merged

somanshreddy merged 1 commit into
mainfrom
03-31-codegen_add_overrides_system_for_group_renames_skip_patterns_positional_promotions

Conversation

@somanshreddy

@somanshreddy somanshreddy commented Mar 31, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Adds curated examples, simplifies the type system, and introduces dependencies for the codegen pipeline.

examples.yaml — hand-written CLI usage examples for every generated command. Mandatory — make generate fails if any endpoint is missing. Examples help both humans (copy-paste) and agents (pattern-matching working commands). This is the only CLI-side configuration file — naming and visibility are controlled in the OpenAPI spec.

ArgSpec simplified — positional arguments now only come from URL path parameters. Body fields and file paths are always named flags (--flag), never positional. This is an agent-first design: named flags are self-documenting.

FlagSpec extended — Source field gains a third value "file" (alongside "query" and "body"). Flags with Source: "file" route to inv.FilePath for multipart upload (e.g., --file ./video.mp4). BuildInvocation handles the routing.

command.Groups type — named type map[string][]*Spec with a SortedNames() helper. Used as the return type for the grouper and input to the renderer. Reads command.Groups instead of raw map type everywhere.

Libraries added:

  • jinzhu/inflection — singularize group names from OpenAPI tags
  • kin-openapi — parse OpenAPI specs (used by the grouper in a later PR)
  • iancoleman/strcase — kebab-case and PascalCase conversion

Testing

Existing tests updated: ArgSpec Target field removed, body/file positional arg tests removed. All remaining tests pass.

Files

  • internal/command/spec.go — ArgSpec simplified, FlagSpec Source:"file" added, Groups type added, BuildInvocation updated
  • internal/command/spec_test.go — updated for simplified ArgSpec
  • cmd/heygen/builder_test.go — updated for simplified ArgSpec
  • codegen/examples.go — Examples type, YAML loading
  • codegen/examples.yaml — curated examples for all v3 endpoints
  • codegen/testdata/test_examples.yaml — test fixture
  • go.mod / go.sum — dependencies added

somanshreddy commented Mar 31, 2026 •

Copy link
Copy Markdown
Collaborator Author

@somanshreddy somanshreddy changed the title codegen: add overrides system for group renames, skip patterns, positional promotions codegen: add overrides config system (PRINFRA-121) Mar 31, 2026
@linear

linear Bot commented Mar 31, 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 03-31-codegen_add_overrides_system_for_group_renames_skip_patterns_positional_promotions branch 2 times, most recently from 24ee2cb to ee89581 Compare March 31, 2026 20:59
@somanshreddy
somanshreddy force-pushed the 03-31-client_add_multipart_form-data_file_upload_support branch from b1e332c to 3ddc75a Compare March 31, 2026 21:06
@somanshreddy
somanshreddy force-pushed the 03-31-codegen_add_overrides_system_for_group_renames_skip_patterns_positional_promotions branch 2 times, most recently from 15e4901 to cae4380 Compare March 31, 2026 21:25
@somanshreddy
somanshreddy force-pushed the 03-31-client_add_multipart_form-data_file_upload_support branch from 3ddc75a to 1c9bc16 Compare March 31, 2026 21:25
@somanshreddy
somanshreddy force-pushed the 03-31-codegen_add_overrides_system_for_group_renames_skip_patterns_positional_promotions branch from cae4380 to 9e4f567 Compare March 31, 2026 21:55
@somanshreddy
somanshreddy force-pushed the 03-31-client_add_multipart_form-data_file_upload_support branch 2 times, most recently from 0a899f1 to 7c07ef5 Compare March 31, 2026 21:58
@somanshreddy
somanshreddy force-pushed the 03-31-codegen_add_overrides_system_for_group_renames_skip_patterns_positional_promotions branch from 9e4f567 to 89d91d3 Compare March 31, 2026 21:58
@somanshreddy
somanshreddy force-pushed the 03-31-client_add_multipart_form-data_file_upload_support branch from 7c07ef5 to aea9abd Compare March 31, 2026 22:02
@somanshreddy
somanshreddy force-pushed the 03-31-codegen_add_overrides_system_for_group_renames_skip_patterns_positional_promotions branch from 89d91d3 to 1a1881e Compare March 31, 2026 22:02
@somanshreddy
somanshreddy force-pushed the 03-31-client_add_multipart_form-data_file_upload_support branch from aea9abd to 7eff426 Compare March 31, 2026 22:04
@somanshreddy
somanshreddy force-pushed the 03-31-codegen_add_overrides_system_for_group_renames_skip_patterns_positional_promotions branch from 1a1881e to 545c7f1 Compare March 31, 2026 22:04
@somanshreddy
somanshreddy force-pushed the 03-31-client_add_multipart_form-data_file_upload_support branch from 7eff426 to f9090ec Compare March 31, 2026 22:34
@somanshreddy
somanshreddy force-pushed the 03-31-codegen_add_overrides_system_for_group_renames_skip_patterns_positional_promotions branch from 545c7f1 to 85397ad Compare March 31, 2026 22:34
@somanshreddy
somanshreddy changed the base branch from 03-31-client_add_multipart_form-data_file_upload_support to graphite-base/11 March 31, 2026 22:45
@somanshreddy
somanshreddy force-pushed the 03-31-codegen_add_overrides_system_for_group_renames_skip_patterns_positional_promotions branch from 85397ad to 0c9a4f9 Compare March 31, 2026 22:48
@graphite-app
graphite-app Bot changed the base branch from graphite-base/11 to main March 31, 2026 22:48
@somanshreddy
somanshreddy force-pushed the 03-31-codegen_add_overrides_system_for_group_renames_skip_patterns_positional_promotions branch 3 times, most recently from 2810bf7 to b240371 Compare March 31, 2026 23:29
Comment thread codegen/overrides.yaml Outdated
@somanshreddy
somanshreddy force-pushed the 03-31-codegen_add_overrides_system_for_group_renames_skip_patterns_positional_promotions branch 3 times, most recently from 5a3e6ad to b08f6d2 Compare April 1, 2026 06:41
@somanshreddy somanshreddy changed the title codegen: add overrides config system (PRINFRA-121) codegen: add examples.yaml and simplify ArgSpec (PRINFRA-121) Apr 1, 2026
@somanshreddy
somanshreddy force-pushed the 03-31-codegen_add_overrides_system_for_group_renames_skip_patterns_positional_promotions branch from b08f6d2 to 6e8db51 Compare April 1, 2026 07:26
Comment thread codegen/examples.yaml Outdated
# Mandatory — make generate fails if any endpoint is missing.
# Format: "METHOD /path" → list of example commands.

"GET /v3/videos":

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will work on proper examples once we have more of the CLI complete. This is just for basic functionality.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of one massive examples.yaml can we split it by command/request or something? alongside the command code? basicaly a cleaner structure and will keep files smaller

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now, these are manual examples. Is this suggestion that we split these manual examples into a per-command file? Like

codegen/examples/video.yaml`` ``codegen/examples/avatar.yaml`` ``codegen/examples/voice.yaml

These don't sit beside the command code until the codegen pipeline (PR #14) runs.

We can also auto-generate them as well and place it in the command files directly but we need to come up with an algorithm to determine appropriate/representative examples. This seemed a bit too complex so I skipped it for now.

@somanshreddy
somanshreddy marked this pull request as ready for review April 1, 2026 07:32
@somanshreddy
somanshreddy requested a review from jrusso1020 April 1, 2026 07:33
@somanshreddy
somanshreddy force-pushed the 03-31-codegen_add_overrides_system_for_group_renames_skip_patterns_positional_promotions branch from 6e8db51 to ef458e1 Compare April 1, 2026 07:41
Hand-curated usage examples for every generated command. Mandatory —
make generate fails if any endpoint is missing. Examples help both
humans (copy-paste) and agents (pattern-matching working commands).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@somanshreddy
somanshreddy force-pushed the 03-31-codegen_add_overrides_system_for_group_renames_skip_patterns_positional_promotions branch from ef458e1 to 89e818b Compare April 1, 2026 17:01

somanshreddy commented Apr 1, 2026 •

Copy link
Copy Markdown
Collaborator Author

Merge activity

  • Apr 1, 7:16 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Apr 1, 7:17 PM UTC: @somanshreddy merged this pull request with Graphite.

@somanshreddy
somanshreddy merged commit ae701f1 into main Apr 1, 2026
9 checks passed
@somanshreddy
somanshreddy deleted the 03-31-codegen_add_overrides_system_for_group_renames_skip_patterns_positional_promotions branch April 1, 2026 19:17
@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