Skip to content

feat(cli): add generate-types subcommand - #84

Merged
gsmith85 merged 1 commit into
feat/codegen-compile-typesfrom
feat/codegen-cli-generate-types
Oct 15, 2026
Merged

gsmith85 merged 1 commit into
feat/codegen-compile-typesfrom
feat/codegen-cli-generate-types

Conversation

@gsmith85

@gsmith85 gsmith85 commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Implements Task 4 (PR 1d) of the two-layer ucp-schema code-generation pipeline: wires the ucp-schema generate-types CLI subcommand in src/bin/ucp-schema.rs and adds end-to-end CLI integration tests in tests/generate_types_test.rs.

Changes

  • CLI Subcommand (src/bin/ucp-schema.rs):
    • Adds Commands::GenerateTypes (#[command(name = "generate-types")]) with --capability (--capabilities, comma-delimited), --extension (--extensions, comma-delimited), --schema-dir (-s, alias --schema-local-base), --output (-o), and --pretty (defaults to true).
    • Implements CliExitCode for CodegenError and generalizes write_json_output to <T: serde::Serialize + ?Sized>.
  • CLI Integration Tests (tests/generate_types_test.rs):
    • Verifies stdout pretty/compact JSON output, --output <file> generation, repeatable and comma-separated --capability / --extension flags, --schema-local-base alias, and expected CLI exit codes (0, 2, 3).

Stacked PR Series Roadmap

  1. PR 1a (feat(codegen): add identifier naming, UCP keyword stripping, and $defs ref rewriting #81): Identifier qualification, UCP keyword stripping, $ref rewriting (src/codegen/normalizer.rs)
  2. PR 1b (feat(codegen): add directional schema slicing and $ref alignment #82): Directional schema slicing & $ref alignment (src/codegen/normalizer.rs)
  3. PR 1c (feat(codegen): add capability reachability, composition, and generate_types() API #83): Capability/extension reachability, composition & generate_types() library API (src/codegen/{mod,reachability,hoist,compose}.rs)
  4. PR 1d (this PR): CLI generate-types subcommand (src/bin/ucp-schema.rs, tests/generate_types_test.rs)
  5. PR 2 (feat(codegen): add self-contained .well-known/ucp profile scoping for generate-types #85): Self-contained .well-known/ucp --profile scoping (src/codegen/profile.rs)
  6. PR 3a (feat(codegen): add AST shape normalizers and inline conditional variant hoisting #86): Codegen AST shape normalizers & inline conditional variant hoisting (src/codegen/normalizer.rs, src/codegen/reify.rs)
  7. PR 3b (feat(codegen): lower open string discriminator unions into ordered anyOf with <Union>Base #87): Open string discriminator union lowering (<Union>Base) (src/codegen/reify.rs)
  8. PR 3c (feat(codegen): discover and register decentralized extended subtypes into open unions #88): Cross-file extended subtype discovery & registration (src/codegen/reify.rs)
  9. PR 4a (python-sdk#101): Python SDK direct JSON Schema codegen (generate_models.sh, postprocess_models.py, src/ucp_sdk/models/)
  10. PR 4b (js-sdk#87): JS/TS SDK direct JSON Schema codegen (generate_models.sh, scripts/generate-zod-from-types.mjs, src/spec_generated.ts)
  11. PR 5 (feat(openapi): add profile-driven OpenAPI 3.1 service and type binding (generate-openapi) #89): OpenAPI 3.1 REST service & type binding (ucp-schema generate-openapi, src/openapi/mod.rs)

Test Plan

  • cargo test --all-targets
  • cargo clippy --all-targets -- -D warnings
  • cargo fmt --check

@gsmith85 gsmith85 changed the title feat(cli): add generate-types subcommand (PR 1d) feat(cli): add generate-types subcommand Oct 1, 2026
@gsmith85
gsmith85 force-pushed the feat/codegen-cli-generate-types branch from 0c820b7 to f0bc7be Compare October 1, 2026 18:51
@damaz91 damaz91 added the status:needs-triage Signal that the PR is ready for human triage label Oct 1, 2026
@gsmith85
gsmith85 force-pushed the feat/codegen-cli-generate-types branch 2 times, most recently from 05a8dee to 4ba168f Compare October 1, 2026 20:17
@gsmith85
gsmith85 force-pushed the feat/codegen-compile-types branch from 19346d4 to 1ab4348 Compare October 1, 2026 23:45
@gsmith85
gsmith85 force-pushed the feat/codegen-cli-generate-types branch 2 times, most recently from 129075f to 0452980 Compare October 2, 2026 01:11
@gsmith85
gsmith85 force-pushed the feat/codegen-compile-types branch from a85a726 to 8cac42b Compare October 2, 2026 16:37
@gsmith85
gsmith85 force-pushed the feat/codegen-cli-generate-types branch from 0452980 to 095e38d Compare October 2, 2026 16:37
@gsmith85
gsmith85 force-pushed the feat/codegen-cli-generate-types branch from 095e38d to eae1f7e Compare October 7, 2026 06:00
@gsmith85
gsmith85 force-pushed the feat/codegen-compile-types branch from 8cac42b to 9d93d16 Compare October 7, 2026 06:00
@gsmith85
gsmith85 force-pushed the feat/codegen-cli-generate-types branch from eae1f7e to 5a86208 Compare October 7, 2026 22:04
@gsmith85
gsmith85 force-pushed the feat/codegen-compile-types branch from 9d93d16 to 33ec2f4 Compare October 7, 2026 22:04
@gsmith85
gsmith85 force-pushed the feat/codegen-cli-generate-types branch from 5a86208 to f7cdac2 Compare October 8, 2026 00:32
@gsmith85
gsmith85 force-pushed the feat/codegen-compile-types branch from 33ec2f4 to 31aae2f Compare October 8, 2026 00:32
@damaz91 damaz91 added status:under-review and removed status:needs-triage Signal that the PR is ready for human triage labels Oct 14, 2026
@gsmith85
gsmith85 force-pushed the feat/codegen-compile-types branch from 31aae2f to b1e72bf Compare October 14, 2026 22:04
@gsmith85
gsmith85 force-pushed the feat/codegen-cli-generate-types branch from f7cdac2 to 2033502 Compare October 14, 2026 22:04
@gsmith85
gsmith85 force-pushed the feat/codegen-compile-types branch from b1e72bf to ef101e9 Compare October 14, 2026 23:23
@gsmith85
gsmith85 force-pushed the feat/codegen-cli-generate-types branch from 2033502 to f7a1e9d Compare October 14, 2026 23:23
@gsmith85
gsmith85 force-pushed the feat/codegen-compile-types branch from ef101e9 to bebd94f Compare October 15, 2026 01:18
@gsmith85
gsmith85 force-pushed the feat/codegen-cli-generate-types branch from f7a1e9d to 013e1cf Compare October 15, 2026 01:18
Comment thread src/bin/ucp-schema.rs
Comment thread src/bin/ucp-schema.rs
Implement Task 4 (PR 1d) of the ucp-schema codegen pipeline:
- Wire Commands::GenerateTypes in src/bin/ucp-schema.rs with --profile, --capability, --extension, --schema-dir (alias --schema-local-base), --schema-remote-base, --output, and --pretty.
- Implement CliExitCode for CodegenError and generalize write_json_output to <T: serde::Serialize + ?Sized>.
- Add CLI integration tests in tests/generate_types_test.rs covering stdout pretty/compact output, file output, repeatable/comma-delimited flags, and error exit codes.

Stacked PR Roadmap:
- PR 1a (#81): Identifier qualification, UCP keyword stripping, $ref rewriting
- PR 1b (#82): Directional schema slicing and $ref alignment
- PR 1c (#83): Capability/extension reachability, composition, and generate_types() library API
- PR 1d (this PR): CLI generate-types subcommand
- PR 2: Self-contained .well-known/ucp --profile scoping
- PR 3: Inline conditional variant hoisting and ordered anyOf union lowering
- PR 4: OpenAPI 3.1 REST binding assembly (generate-openapi)
@gsmith85
gsmith85 force-pushed the feat/codegen-cli-generate-types branch from 013e1cf to bc1c420 Compare October 15, 2026 20:22
@gsmith85
gsmith85 merged commit c85e008 into feat/codegen-compile-types Oct 15, 2026
4 checks passed
@gsmith85
gsmith85 deleted the feat/codegen-cli-generate-types branch October 15, 2026 22:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants