protocolgen

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2026 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package protocolgen generates the Go types for the codex app-server v2 protocol from the vendored JSON Schema snapshot under schema/.

The snapshot is produced by the pinned codex CLI (`codex app-server generate-json-schema --experimental`). Generic JSON-Schema code generators cannot represent the serde union encodings this protocol uses, so this package implements a small purpose-built generator that handles exactly the schema shapes present in the snapshot and fails loudly on anything else.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Generate

func Generate() (map[string][]byte, error)

Generate produces the generated protocol source files, keyed by file name. Output is deterministic for a given schema snapshot and subset config.

Types

type Schema

type Schema struct {
	// Any marks the boolean schema `true`, which accepts any value.
	Any bool `json:"-"`

	Ref         string             `json:"$ref"`
	SchemaTag   string             `json:"$schema"`
	Type        typeList           `json:"type"`
	Properties  map[string]*Schema `json:"properties"`
	Required    []string           `json:"required"`
	Items       *Schema            `json:"items"`
	AddlProps   *addlProps         `json:"additionalProperties"`
	Enum        []json.RawMessage  `json:"enum"`
	OneOf       []*Schema          `json:"oneOf"`
	AnyOf       []*Schema          `json:"anyOf"`
	AllOf       []*Schema          `json:"allOf"`
	Format      string             `json:"format"`
	Title       string             `json:"title"`
	Description string             `json:"description"`
	Definitions map[string]*Schema `json:"definitions"`
	Default     json.RawMessage    `json:"default"`
	Minimum     json.RawMessage    `json:"minimum"`
	MinLength   json.RawMessage    `json:"minLength"`
}

Schema models the subset of JSON Schema draft-07 that the codex snapshot actually uses. Loading fails if a document contains anything outside it. The boolean schema form (`true` = anything) is represented by Any.

func (*Schema) UnmarshalJSON

func (s *Schema) UnmarshalJSON(b []byte) error

Jump to

Keyboard shortcuts

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