Documentation
¶
Overview ¶
Package tui holds PlugIt's terminal screens (SPEC §2.3), built on Bubble Tea. Spec-derived text is untrusted: everything drawn is stripped of control and format characters first, so a spec can't drive the terminal.
Index ¶
- Variables
- func HumanBytes(n int64) string
- func Millis(d time.Duration) string
- func NoColor() bool
- func RunChooser(ctx context.Context, title, subtitle string, choices []Choice, r io.Reader, ...) ([]int, error)
- func RunInspector(ctx context.Context, in InspectorInput, r io.Reader, w io.Writer) error
- func RunPicker(ctx context.Context, in PickerInput, r io.Reader, w io.Writer) (config.Toolset, policy.Mode, error)
- func RunStats(ctx context.Context, in StatsInput, r io.Reader, w io.Writer) error
- func RunSync(ctx context.Context, in SyncInput, r io.Reader, w io.Writer) ([]model.OpKey, error)
- func RunTryIt(ctx context.Context, in TryInput, r io.Reader, w io.Writer) error
- func Safe(s string) string
- func SafeText(s string) string
- func SetNoColor(on bool)
- type CallsMsg
- type Choice
- type Chooser
- type Inspector
- type InspectorInput
- type Picker
- type PickerInput
- type Stats
- type StatsInput
- type StatsMsg
- type SyncInput
- type SyncScreen
- type TryInput
- type TryIt
- type TryResult
Constants ¶
This section is empty.
Variables ¶
var ErrCancelled = errors.New("cancelled; nothing saved")
ErrCancelled means the user left the picker without saving.
Functions ¶
func RunChooser ¶
func RunChooser(ctx context.Context, title, subtitle string, choices []Choice, r io.Reader, w io.Writer) ([]int, error)
RunChooser shows a chooser on a terminal and returns the chosen indexes, or ErrCancelled.
func RunInspector ¶
RunInspector shows the inspector until the user quits.
func RunPicker ¶
func RunPicker(ctx context.Context, in PickerInput, r io.Reader, w io.Writer) (config.Toolset, policy.Mode, error)
RunPicker runs the picker on a terminal and returns the saved selection and policy mode, or ErrCancelled.
func Safe ¶
Safe strips control and format characters from untrusted text before it is printed to a terminal.
func SafeText ¶ added in v0.2.0
SafeText is Safe for text of several lines: line breaks and tabs are kept, every other control or format character is removed.
func SetNoColor ¶
func SetNoColor(on bool)
SetNoColor turns colour off (or back on) for every screen: the global --no-color flag. NO_COLOR in the environment works without it.
Types ¶
type Chooser ¶
type Chooser struct {
// contains filtered or unexported fields
}
Chooser is a small inline multi-select (used to pick MCP clients).
func NewChooser ¶
NewChooser builds a chooser with nothing selected.
func (*Chooser) Result ¶
Result returns the chosen indexes in order, and false if the user cancelled.
type Inspector ¶
type Inspector struct {
// contains filtered or unexported fields
}
Inspector is a live tail of the call log: a Bubble Tea model.
func NewInspector ¶
func NewInspector(in InspectorInput) *Inspector
NewInspector builds an inspector.
type InspectorInput ¶
type InspectorInput struct {
Title string
AllAPIs bool
Source func(ctx context.Context, afterID int64) ([]store.Call, error)
Interval time.Duration
}
InspectorInput configures the call inspector (SPEC §2.3).
type Picker ¶
type Picker struct {
// contains filtered or unexported fields
}
Picker is the tool picker: a Bubble Tea model.
func (*Picker) Init ¶
Init implements tea.Model. It asks the terminal for its background colour to pick the palette.
type PickerInput ¶
type PickerInput struct {
API string
Tools []model.Tool
Prefix string
Mode policy.Mode
Selected config.Toolset
Lint func(config.Toolset) []lint.Finding
}
PickerInput is what the picker edits.
type Stats ¶
type Stats struct {
// contains filtered or unexported fields
}
Stats is the per-API, per-tool summary of the call log.
func NewStats ¶
func NewStats(in StatsInput) *Stats
NewStats builds the stats screen, showing the last 7 days.
type StatsInput ¶
type StatsInput struct {
Title string
Source func(ctx context.Context, since time.Time) ([]store.ToolStats, error)
Budgets map[string]string
Interval time.Duration
Now func() time.Time
}
StatsInput configures the stats screen (SPEC §2.3).
type SyncInput ¶
type SyncInput struct {
API string
Diff curate.SyncDiff
BaseURL string
Toolset string
LintNote string
}
SyncInput configures the Sync diff screen (SPEC §2.3).
type SyncScreen ¶
type SyncScreen struct {
// contains filtered or unexported fields
}
SyncScreen shows what a new spec changes and lets the user pick which new operations to add. Overrides are always kept.
func NewSyncScreen ¶
func NewSyncScreen(in SyncInput) *SyncScreen
NewSyncScreen builds the screen with no new operations chosen.
func (*SyncScreen) Result ¶
func (s *SyncScreen) Result() ([]model.OpKey, bool)
Result returns the chosen new operations and whether to apply.
type TryInput ¶
type TryInput struct {
API string
Tool model.Tool
Mode policy.Mode
Confirm string
Send func(ctx context.Context, args map[string]string) TryResult
}
TryInput configures the Try it screen (SPEC §2.3).
type TryIt ¶
type TryIt struct {
// contains filtered or unexported fields
}
TryIt is a form generated from a tool's parameters that makes one call and shows the redacted request and the response.
func NewTryIt ¶
NewTryIt builds the form. Hidden params (credentials, fixed values) get no field: plugit fills them in.