configschema

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package configschema renders the JSON Schema artifacts of Pi's configuration files (models.json, settings.json, keybindings.json and themes) from Go schema trees. The trees mirror the TypeBox schemas of Pi's coding-agent and ai packages, and Render mirrors packages/coding-agent/scripts/generate-schemas.ts: node order, annotation placement and $defs extraction follow the TypeScript output.

Index

Constants

View Source
const KeybindingsArtifactPath = "schemas/keybindings.schema.json"

KeybindingsArtifactPath is the path of the keybindings artifact, which the caller supplies to Render and ArtifactPaths.

Variables

This section is empty.

Functions

func ArtifactPaths

func ArtifactPaths() []string

ArtifactPaths lists the artifact paths in generation order (generate-schemas.ts schemaArtifacts).

func Render

func Render(keybindings Artifact) (map[string]string, error)

Render returns the rendered artifacts by path; keybindings is the keybindings artifact (codingagent.KeybindingsSchemaArtifact).

Types

type Artifact

type Artifact struct {
	Path        string
	Schema      *Schema
	Definitions []Definition
}

Artifact is one generated schema file and the shared sub-schemas its generator turns into $defs.

func (Artifact) Render

func (a Artifact) Render() (string, error)

Render serializes one artifact the way generate-schemas.ts serializeSchema does.

type CompatSchemaEntry

type CompatSchemaEntry struct{ API, Schema string }

CompatSchemaEntry is one entry of CompatSchemasByApi: an API and the name of its compat schema.

func CompatSchemasByApi

func CompatSchemasByApi() []CompatSchemaEntry

CompatSchemasByApi is compat-schema.ts CompatSchemasByApi: the compatibility schema of each API whose models accept compat, in Pi's key order (Pi 4954d760 adds azure-openai-responses and openai-codex-responses, which share the Responses schema).

type Definition

type Definition struct {
	Name   string
	Schema *Schema
}

Definition is one named $defs entry.

type Opt

type Opt struct {
	K string
	V any
}

Opt is one schema keyword, in the order the TypeScript options object lists it.

func D

func D(text string) Opt

D is the description option and Default the default option.

func Default

func Default(v any) Opt

type Prop

type Prop struct {
	Name     string
	Schema   *Schema
	Optional bool
}

Prop is one object property.

func Optional

func Optional(name string, s *Schema) Prop

func P

func P(name string, s *Schema) Prop

P is a required property and Optional an optional one (Type.Optional).

type Schema

type Schema struct {
	// contains filtered or unexported fields
}

Schema is one JSON Schema node whose keys keep their insertion order, the order in which JSON.stringify writes a TypeBox schema.

func AnthropicAllowedFallbackModelSchema

func AnthropicAllowedFallbackModelSchema() *Schema

func AnthropicMessagesCompatSchema

func AnthropicMessagesCompatSchema() *Schema

func Array

func Array(items *Schema, opts ...Opt) *Schema

func BedrockCompatSchema

func BedrockCompatSchema() *Schema

func Boolean

func Boolean(opts ...Opt) *Schema

func CacheRetentionSchema

func CacheRetentionSchema() *Schema

func ChatTemplateKwargValueSchema

func ChatTemplateKwargValueSchema() *Schema

func Enum

func Enum(values []string, opts ...Opt) *Schema

Enum is Type.Enum over a list of string values.

func Integer

func Integer(opts ...Opt) *Schema

func Literal

func Literal(value any, opts ...Opt) *Schema

Literal is Type.Literal of a string, a boolean or a number.

func MistralConversationsCompatSchema

func MistralConversationsCompatSchema() *Schema

func ModelCostRatesSchema

func ModelCostRatesSchema() *Schema

func ModelCostSchema

func ModelCostSchema() *Schema

func ModelCostTierSchema

func ModelCostTierSchema() *Schema

func ModelImageInputLimitsSchema

func ModelImageInputLimitsSchema() *Schema

func ModelImageResizeOptionsSchema

func ModelImageResizeOptionsSchema() *Schema

func ModelInputLimitsSchema

func ModelInputLimitsSchema() *Schema

func ModelInputModalitySchema

func ModelInputModalitySchema() *Schema

func ModelPromptCacheSchema

func ModelPromptCacheSchema() *Schema

func ModelThinkingLevelSchema

func ModelThinkingLevelSchema() *Schema

func ModelsConfigSchema

func ModelsConfigSchema() *Schema

func Null

func Null(opts ...Opt) *Schema

func Number

func Number(opts ...Opt) *Schema

func Object

func Object(props []Prop, opts ...Opt) *Schema

Object is Type.Object: the required list holds the properties that are not Optional.

func OpenAICompletionsCompatSchema

func OpenAICompletionsCompatSchema() *Schema

func OpenAIResponsesCompatSchema

func OpenAIResponsesCompatSchema() *Schema

func OpenRouterRoutingSchema

func OpenRouterRoutingSchema() *Schema

func Partial

func Partial(s *Schema, opts ...Opt) *Schema

Partial is Type.Partial of an object: no property is required.

func ProviderCompatSchema

func ProviderCompatSchema() *Schema

ProviderCompatSchema is mergeCompatProperties: a property keeps the position of its first schema, and an override replaces its value.

func Record

func Record(value *Schema, opts ...Opt) *Schema

Record is Type.Record(Type.String(), value): an object whose every property matches value.

func RecordOf

func RecordOf(keys []string, value *Schema, opts ...Opt) *Schema

RecordOf is Type.Record over the string literals keys: an object with one required property per key.

func SessionAffinityFormatSchema

func SessionAffinityFormatSchema() *Schema

func String

func String(opts ...Opt) *Schema

func SystemOneCompatSchema

func SystemOneCompatSchema() *Schema

SystemOneCompatSchema is compat-schema.ts SystemOneCompatSchema.

func ThinkingLevelMapSchema

func ThinkingLevelMapSchema() *Schema

func ThinkingLevelSchema

func ThinkingLevelSchema() *Schema

func ThinkingTokenBudgetFieldSchema

func ThinkingTokenBudgetFieldSchema() *Schema

func Union

func Union(alternatives []*Schema, opts ...Opt) *Schema

Union is Type.Union.

func Unknown

func Unknown(opts ...Opt) *Schema

Unknown is Type.Unknown, which accepts any value.

func VercelGatewayRoutingSchema

func VercelGatewayRoutingSchema() *Schema

func (*Schema) Errors

func (s *Schema) Errors(content []byte) ([]string, error)

Errors is validate.Errors(parsed) of the compiled schema as ModelConfig.load lists them: " - path: message" per error, at most eight, in typebox's order. The error is the JSON syntax error of content; a document that matches the schema returns no lines.

func (*Schema) With

func (s *Schema) With(opts ...Opt) *Schema

With returns a copy of the schema with the options set (Type options passed as the last TypeBox argument).

Jump to

Keyboard shortcuts

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