schemagen

command
v0.2026331.148 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 27, 2026 License: MIT Imports: 13 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Command schemagen is the dev-time companion code generator for the `spec` package. It is invoked ONLY at development time — by `charly task cue-gen` here, and by a CONSUMER repo's own generator task that runs it by module ref (`go run github.com/opencharly/spec/schemagen@<tag> -mode=params -schema=<dir> -pkg=<pkg> -out=<file>`), which is why it lives at the module root rather than under internal/ — one generator, no copied script per repo (opencharly/plugin-builder#10). It never runs at runtime and has two modes:

-mode=params -out=<file>   Concatenate schema/*.cue into one file
                           headed `package spec` + the file-level `@go(spec)`
                           attribute, and generate the Go types in-process
                           through schemaparams (CUE Go API).
-mode=vocab  -out=<file>   Compile the concatenation via the embedded
                           cuelang.org/go API and emit spec/vocab_gen.go
                           — the single-source vocabulary lists (kind keywords,
                           document directives, step keywords, contexts, the
                           flat #Op verb/modifier field set, and the live-verb
                           method allowlists).

CONCATENATION CONTRACT (R3): concatSchema replicates EXACTLY the mechanism the runtime uses in charly core (cue_schema.go) `sharedCueSchema` — every schema/*.cue file (its `package schema` clause normalized away by `schemaconcat`), sorted by name, joined with a trailing newline. The runtime reads the files from `//go:embed`; this tool reads them from disk (it runs at dev time with the working tree present). If you change the runtime concatenation order, change it here too — the two MUST stay byte-identical or the generated Go types drift from what the runtime validates.

PARAM-GEN SCOPE (the two modes diverge by INPUT, not by mechanism): the `vocab` mode reads the FULL schema (every schema/*.cue) — it needs #Node's arms (node.cue) to derive KindWords, so its concatenation stays byte-identical to the runtime `sharedCueSchema`. The `params` mode (which feeds the in-process Go generator → the Go param structs) reads the schema MINUS node.cue: it defines the node-disjunction wrappers (#Node/#NodeDoc/#*Arm/#*Value), which the generator degrades to `map[string]any` and which are NOT charly param structs. (The egress validation schemas moved to candy/plugin-egress in M16, so they no longer live here to exclude.) The entity defs (#Box/#Deploy/#Op/#Vm/…) do not reference node.cue, so the exclusion is compile-clean. Both modes share the ONE concatSchema helper (R3); only the file filter differs.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL