protocolgen

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 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 JSON Schema a codex CLI exports (`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 codex exports and fails loudly on anything else.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Generate

func Generate(schemas fs.FS, version string) (map[string][]byte, error)

Generate produces the generated protocol source files, keyed by file name, from the schema documents codex version exported.

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 codex actually exports. 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