feat(cli): derive catalog defaults and validate enum groups - #66
TristanSpeakEasy wants to merge 8 commits into
Conversation
There was a problem hiding this comment.
All reported issues were addressed across 6 files
Shadow auto-approve: would not auto-approve because issues were found.
Fix all with cubic | Re-trigger cubic
There was a problem hiding this comment.
0 issues found across 1 file (changes from recent commits).
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Shadow auto-approve: would auto-approve. Adds optional per-command defaults and ordered groups to generated CLI enum catalogs, gated so existing output is unchanged; tests cover legacy, grouped, and malformed cases, and invalid groups fall back to Other.
Re-trigger cubic
|
Catalog normalization updated in dd77aea:
Added human and JSON assertions for these cases, including a long-label fixture that checks exact legacy spacing, and updated the documentation. Validation passed: primary CLI generation, compilation and staticcheck; focused catalog tests; template type-check; formatting and diff checks; and human-output smoke checks. The full test matrix is left to CI. Full repository lint was not repeated because the existing local permissions-file formatting failure is unchanged. |
There was a problem hiding this comment.
0 issues found across 4 files (changes from recent commits).
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Shadow auto-approve: would auto-approve. Adds optional per-command defaults and ordered groups to generated CLI enum catalogs, with tests, docs, changeset, and a release-workflow version-check snapshot; existing output is preserved when the new options are unused.
Re-trigger cubic
There was a problem hiding this comment.
0 issues found across 4 files (changes from recent commits).
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Shadow auto-approve: would auto-approve. Adds optional per-command defaults and ordered groups to CLI enum catalogs while preserving legacy output when unused, fixes PHP constructor enum default namespace qualification with a regression test, and adds a release-tag version guard; all changes are additive or corrective with test coverage.
Re-trigger cubic
There was a problem hiding this comment.
- The PHP enum-default qualification fix (
php/includes/sanitization.ts,php/includes/templating.ts, the PHP test, and the second changeset) is an independent bug fix with its own changelog entry. It is correct as far as I can tell, sinceusageLocationalready exists onTemplateValueContext, but it should probably land in its own PR so the PHP changelog entry and any revert are not tied to a CLI feature. testSharedEnumConstructorDefaultdoes not callCommonHelpers::recordTest, unlike the other tests in that file.
|
Propose this refinement in configuration:
|
ThomasRooney
left a comment
There was a problem hiding this comment.
Temporarily blocking this with proposals for improved interface to reach same functionality. Non-blocking though: happy for push-back / review dismissal if you disagree.
This reverts commit 74631fa.
|
@AshGodfrey, the PHP enum-constructor fix from your review is now in #71 and removed from this PR in bfe14f5. Its changeset is included only in #71. The regression test now uses an independent enum-default fixture, calls |
There was a problem hiding this comment.
0 issues found across 4 files (changes from recent commits).
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Shadow auto-approve: would auto-approve. Adds optional per-command defaults and ordered groups to generated CLI enum catalogs, preserving legacy output when unused, with tests/docs, plus a CI release-tag version guard. Additive, tested, bounded; the PHP fix was reverted.
Re-trigger cubic
|
@ThomasRooney, implemented the interface proposed in your comment in 09dfd39:
Validation: focused Go suites, primary/review CLI generation and staticcheck, 1,455 primary runtime tests, 547 review tests (two existing skips), and regenerated catalog tests passed. Repository lint still fails only on the existing gofmt complaint in unchanged |
There was a problem hiding this comment.
All reported issues were addressed across 19 files (changes from recent commits).
Shadow auto-approve: would not auto-approve because issues were found.
Tip: Review your code locally with the cubic CLI to iterate faster.
Fix all with cubic | Re-trigger cubic
There was a problem hiding this comment.
0 issues found across 4 files (changes from recent commits).
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Shadow auto-approve: would auto-approve. Adds extension-gated enum grouping and preset-derived defaults without changing legacy output. Validation confirms the previously identified issues are fixed.
Re-trigger cubic
Why
Offline enum catalogs support a scalar default and a flat list, but shared enums also need to show which values command presets select and organise options into sections. Command defaults should come from the commands themselves, rather than a second configuration that can drift.
What changed
default_forfrom effective command and route presets in Go, following the bound schema through references, composition and array items. Different route defaults use the actual selector in their labels; defaults shared by every route use the plain command name.x-speakeasy-enum-groups, accepting a sparse value-to-title map or positional string list. Go validates malformed shapes, non-string titles, unknown values, duplicate map keys and list lengths instead of silently dropping invalid input.Othersection only when an explicit group exists. If a group is already titledOther, merge the remainder into it in enum order without moving the declared section or creating a duplicate heading.default, its machine-output boolean, legacy flat output and spacing when the new metadata is absent. Replace this PR's proposed nested catalogdefaultsandgroupskeys with presets and the enum extension.Othergroup. The independent PHP fix was merged in fix(php): qualify enum defaults in model constructors #71; this PR has no PHP or permissions-file diff againstmain. Review SDK generation has no catalog output changes.Configuration and output example
Given a request property
choicereferencing this enum:Commands declare their defaults once, through presets:
cli widget-optionsdisplays:Each enum member is one
CliCatalogValuerow.CliCatalog.Groupscollects those same rows into human-output sections;CliCatalog.Valuesflattens them in the same section order for machine output. Group titles do not alter enum values or request bodies.JSON remains a flat array. For example, the first row contains
value: "alpha",default: false,default_for: ["create-widget"]andgroup: "Primary". Only an explicit scalar catalogdefaultchanges the existingdefaultboolean.A positional group list must match the original enum declaration, including null and duplicate slots. Null slots create no rows; duplicate values use their first non-empty title. Empty titles and omitted map entries are ungrouped. SDK enum-description rendering is outside this change.
Testing
go test ./internal/extensions ./internal/validation ./internal/schemas ./internal/ast -count=1passed, including schema association, route overrides, union ambiguity, enum-group validation and metadata equality/clone checks.main,./scripts/test-target.sh cli primarypassed with 1,584 tests. Focused catalog tests also passed withgo test -C testSDKs/sdk-cli-primary ./tests -run '^TestCatalog' -count=1 -v../scripts/test-target.sh cli reviewpassed with 589 tests and two existing skips.npm run format, all template TypeScript checks, both module tidy checks andgit diff --checkpassed.make lintis blocked by local permissions generation. After restoring the generated file, runninggolangci-lintdirectly reports only the existing gofmt complaint in unchangedtemplates/perms.go. No permissions-file changes are included. The full cross-target runtime matrix was not run locally; CI checks are pending.Public-safety check
.claude/skills/public-repo-communication/SKILL.md).git diff --check.