form

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package form contains a presentation-only JSON Schema argument editor. It never authenticates, calls a tool, submits a write, or applies schema defaults.

Index

Constants

View Source
const MaxInputBytes = 8 << 20

MaxInputBytes matches the existing CLI's bounded JSON input. Oversized edits are rejected atomically, never truncated by the underlying widgets.

Variables

This section is empty.

Functions

This section is empty.

Types

type Model

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

Model is an argument draft. SetArguments starts a fresh, clean draft; Arguments returns a detached object only after complete schema validation.

func New

func New(input schema.JSONSchema, rawJSON bool) Model

New creates a form without filling defaults or inventing required values. rawJSON locks live/unreviewed schemas to exact JSON-object input.

func (Model) Arguments

func (m Model) Arguments() (map[string]any, error)

Arguments validates the complete original schema, including constraints that cannot be represented by a typed control. Diagnostics never contain values.

func (Model) Dirty

func (m Model) Dirty() bool

Dirty includes invalid and currently omitted edits, so navigating away never silently loses an unfinished draft. Only SetArguments resets the baseline.

func (Model) JSONMode

func (m Model) JSONMode() bool

JSONMode reports whether the full-object JSON editor is active.

func (*Model) SetArguments

func (m *Model) SetArguments(arguments map[string]any) error

SetArguments accepts even a schema-invalid draft (e.g. after schema drift), but rejects non-JSON values without changing the existing form. It retains unknown properties; only Arguments performs full input validation.

func (*Model) SetSize

func (m *Model) SetSize(width, height int)

SetSize changes the available viewport without modifying the draft.

func (Model) Update

func (m Model) Update(msg tea.Msg) (Model, tea.Cmd)

Update only edits draft state. Enter never emits an invocation/submission.

func (Model) View

func (m Model) View() string

View bounds both columns and rows using terminal display width, not bytes. Names/descriptions are sanitized before presentation. Editor contents are either safe literal text or escaped JSON and cannot inject terminal controls.

Jump to

Keyboard shortcuts

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