Skip to content

[WIP] Add --generate-skeleton flag#5407

Draft
janniklasrose wants to merge 10 commits into
mainfrom
janniklasrose/generate-skel
Draft

[WIP] Add --generate-skeleton flag#5407
janniklasrose wants to merge 10 commits into
mainfrom
janniklasrose/generate-skel

Conversation

@janniklasrose

@janniklasrose janniklasrose commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Changes

Why

Tests


collapse review tree to hide auto-generated files:

Screenshot 2026-07-14 at 15 51 27

@eng-dev-ecosystem-bot

eng-dev-ecosystem-bot commented Jun 2, 2026

Copy link
Copy Markdown
Collaborator

Integration test report

Commit: 1fbdbe5

Run: 29341655843

Env 🔄​flaky 💚​RECOVERED 🙈​SKIP ✅​pass 🙈​skip Time
💚​ aws linux 4 4 230 1088 5:26
💚​ aws windows 4 4 232 1086 7:10
🔄​ aws-ucws linux 1 3 4 316 1005 6:56
💚​ aws-ucws windows 4 4 318 1003 7:36
💚​ azure linux 4 4 230 1087 5:23
💚​ azure windows 4 4 232 1085 7:16
💚​ azure-ucws linux 4 4 318 1002 7:39
🔄​ azure-ucws windows 1 4 4 319 1000 7:45
💚​ gcp linux 4 4 229 1089 4:55
💚​ gcp windows 4 4 231 1087 7:10
9 interesting tests: 4 SKIP, 3 RECOVERED, 2 flaky
Test Name aws linux aws windows aws-ucws linux aws-ucws windows azure linux azure windows azure-ucws linux azure-ucws windows gcp linux gcp windows
💚​ TestAccept 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R
🙈​ TestAccept/bundle/invariant/no_drift 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/vector_search_endpoints/drift/recreated_same_name 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/vector_search_indexes/recreate/embedding_dimension 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/ssh/connection 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🔄​ TestSyncIncrementalFileOverwritesFolder ✅​p ✅​p ✅​p ✅​p ✅​p ✅​p ✅​p 🔄​f ✅​p ✅​p
🔄​ TestFetchRepositoryInfoAPI_FromRepo 💚​R 💚​R 🔄​f 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R
💚​ TestFetchRepositoryInfoAPI_FromRepo/root 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R
💚​ TestFetchRepositoryInfoAPI_FromRepo/subdir 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R
Top 10 slowest tests (at least 2 minutes):
duration env testname
6:20 azure windows TestAccept
6:16 gcp windows TestAccept
6:13 aws-ucws windows TestAccept
6:12 azure-ucws windows TestAccept
6:08 aws windows TestAccept
2:58 gcp linux TestAccept
2:56 aws-ucws linux TestAccept
2:55 azure linux TestAccept
2:52 aws linux TestAccept
2:50 azure-ucws linux TestAccept

@janniklasrose janniklasrose changed the title WIP Add --generate-skeleton flag [WIP] Add --generate-skeleton flag Jun 4, 2026
Remove the two demo wirings of RegisterGenerateSkeleton (jobs create and
vector-search-endpoints create-endpoint). These were per-command overrides
added while the command scaffolding was still generated in the universe repo,
where the flag could not be added generically from the CLI repo.

Now that codegen is driven by the in-repo internal/cligen generator and its
templates, the flag will be emitted for every --json command from the template
instead. RegisterGenerateSkeleton is intentionally left unreferenced here; the
template wiring and regeneration in the following commits restore its call
sites.

Co-authored-by: Isaac
Define a reusable template block that emits a RegisterGenerateSkeleton call
for a --json command. The skeleton target mirrors the --json unmarshal target
(&req, or &req.<RequestBodyField> when the body is a nested field), so the
printed skeleton always matches what --json accepts.

The block is defined but not yet invoked, so regeneration produces no output
change; the following commit wires the call.

Co-authored-by: Isaac
Invoke the "generate-skeleton" template block from new<Method>(), guarded by
$canUseJson so it only fires for commands that accept a --json request body.
$canUseJson is declared at the top of the method body and implies a
non-legacy-empty request, so the <method>Req variable the block references is
always in scope.

The call is emitted after the override loop so it wraps any RunE a manual
override installed; --generate-skeleton then short-circuits the whole command.

This is a template-only change; the generated stubs are regenerated in the
next commit.

Co-authored-by: Isaac
Run ./task generate-cligen after wiring the template. Every generated command
that accepts a --json request body now registers --generate-skeleton. Purely
additive: 482 commands across cmd/workspace/** and cmd/account/**, no manual
edits.

Co-authored-by: Isaac
Add coverage at three levels:

- cmd/root/skeleton_test.go: unit tests for jsonSkeleton (primitives,
  pointers, slices, maps, time.Time, JSON-tag handling, recursion
  termination) and for RegisterGenerateSkeleton wiring (offline skeleton
  print, positional-arg relaxation, --json rejection, normal path
  preserved).
- internal/cligen/skeleton_test.go: render service.go.tmpl and assert the
  emitted RegisterGenerateSkeleton target matches the --json unmarshal target
  (plain request vs request-body field), and that non-JSON commands get no
  flag.
- acceptance/cmd/workspace/generate-skeleton: end-to-end output for a plain
  request, a request-body-field command with relaxed positional args, and the
  --json incompatibility error. Offline, so it opts out of the engine matrix.

Also modernize skeleton.go for the linters that tightened after this branch
forked (errors.New, reflect.TypeFor, reflect.Type.Fields iterator); behavior
is unchanged.

Co-authored-by: Isaac
Replace the single --generate-skeleton flag with two mutually exclusive flags:

- --generate-skeleton-full: every field of the --json request body.
- --generate-skeleton-required-only: only fields the API requires.

Required-ness comes from the SDK struct tags: a field whose json tag lacks
",omitempty" is required. This is the SDK's own required-field convention and,
unlike cli.json (which carries required only for the top-level request and one
level into a request-body field), it holds recursively at every nesting level,
so required-only prunes deep optional subtrees correctly.

Keys stay sorted by name in both variants (json.MarshalIndent sorts map keys),
so the two skeletons differ only in which fields are present, not their order.

Mutual exclusion of the two flags is enforced by cobra
(MarkFlagsMutuallyExclusive); combining either with --json is rejected with an
actionable error naming the offending flag. The generated command stubs are
unchanged: they still emit a single RegisterGenerateSkeleton call, and the two
flags are registered inside it.

Co-authored-by: Isaac
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.

2 participants