tui

package
v0.5.58 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2026 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Overview

Package tui provides an interactive terminal UI for browsing and running scenarios.

Index

Constants

This section is empty.

Variables

View Source
var AdapterChoices = []string{"cli", "mcp", "a2a"}

AdapterChoices are the available adapters for cycling.

View Source
var CategoryFilters = []string{"", "kubernetes", "terraform", "helm", "argocd", "aws"}

CategoryFilters defines the rotation of category filters.

View Source
var ModelChoices = []string{"", "sonnet", "haiku", "opus"}

ModelChoices are the available models for cycling.

View Source
var ProviderChoices = []string{"", "bifrost", "claude"}

ProviderChoices are the available providers for cycling.

Functions

func ActiveSignals

func ActiveSignals(signals map[string]int) []string

ActiveSignals returns signal names with count > 0.

func Run

func Run(scenariosDir, cfgPath string, cfg LabConfig, deps harness.Deps) error

Run starts the TUI application.

func SaveLabConfig

func SaveLabConfig(path string, cfg LabConfig) error

SaveLabConfig writes config to the given path.

Types

type App

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

App is the top-level Bubble Tea model.

func NewApp

func NewApp(scenariosDir, cfgPath string, cfg LabConfig, deps harness.Deps) (*App, error)

NewApp creates a new TUI app.

func (*App) Init

func (a *App) Init() tea.Cmd

func (*App) Update

func (a *App) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (*App) View

func (a *App) View() string

type CatalogItem

type CatalogItem struct {
	Scenario   *scenario.Scenario
	LastResult string // "pass", "fail", or ""
}

CatalogItem wraps a scenario for display in the TUI catalog.

func BuildCatalog

func BuildCatalog(scenarios []*scenario.Scenario) []CatalogItem

BuildCatalog creates a catalog from loaded scenarios.

func FilterCatalog

func FilterCatalog(items []CatalogItem, query, category string) []CatalogItem

FilterCatalog returns items matching the given text query and category filter.

type LabConfig

type LabConfig struct {
	Adapter             string `yaml:"adapter"`
	A2AAgentURL         string `yaml:"a2a_agent_url,omitempty"`
	EnvironmentProvider string `yaml:"environment_provider,omitempty"`
	Provider            string `yaml:"provider,omitempty"`
	AgentCommand        string `yaml:"agent_command"`
	Model               string `yaml:"model,omitempty"`
	RunsDir             string `yaml:"runs_dir,omitempty"`
	ClusterName         string `yaml:"cluster_name,omitempty"`
	Timeout             string `yaml:"timeout"`
	DryRun              bool   `yaml:"dry_run"`
	EvidenceDir         string `yaml:"evidence_dir,omitempty"`
	BenchURL            string `yaml:"bench_url,omitempty"`
	BenchAPIKey         string `yaml:"bench_api_key,omitempty"`
	MemoryWindow        int    `yaml:"memory_window,omitempty"`
	ReuseCluster        bool   `yaml:"reuse_cluster,omitempty"`
	SystemPromptFile    string `yaml:"system_prompt_file,omitempty"`
	SkillFile           string `yaml:"skill_file,omitempty"`
	SkillID             string `yaml:"skill_id,omitempty"`
	SkillVersion        string `yaml:"skill_version,omitempty"`
	SkillSource         string `yaml:"skill_source,omitempty"`
	SkillSHA256         string `yaml:"skill_sha256,omitempty"`
	MCPServer           string `yaml:"mcp_server,omitempty"`
	ToolServerID        string `yaml:"tool_server_id,omitempty"`
	ToolServerVersion   string `yaml:"tool_server_version,omitempty"`
	ReportID            string `yaml:"report_id,omitempty"`
	ContractVersion     string `yaml:"contract_version,omitempty"`
	Parallel            int    `yaml:"parallel,omitempty"`
	DatabaseURL         string `yaml:"database_url,omitempty"`
}

LabConfig holds persistent TUI settings.

func DefaultLabConfig

func DefaultLabConfig() LabConfig

DefaultLabConfig returns sensible defaults.

func LoadLabConfig

func LoadLabConfig(path string) LabConfig

LoadLabConfig reads config from the given path, returning defaults if missing.

func (LabConfig) TimeoutDuration

func (c LabConfig) TimeoutDuration() time.Duration

TimeoutDuration parses the timeout string.

type RunArtifacts added in v0.5.37

type RunArtifacts struct {
	Dir          string
	RunID        string
	ScenarioID   string
	Passed       bool
	Transcript   string
	ToolCallsRaw string
	ToolCalls    []bench.ToolCall
	Timeline     *bench.Timeline
	ReviewRaw    string
	AutopsyRaw   string
	VerifierRaw  string
	ScorecardRaw string
}

RunArtifacts is the local artifact bundle rendered by the TUI artifact view.

func LoadRunArtifacts added in v0.5.37

func LoadRunArtifacts(dir string) RunArtifacts

func (RunArtifacts) Has added in v0.5.37

func (a RunArtifacts) Has(tab artifactTab) bool

func (RunArtifacts) Render added in v0.5.37

func (a RunArtifacts) Render(tab artifactTab) string

type RunFinishedMsg

type RunFinishedMsg struct {
	Result *harness.RunResult
	Err    error
}

RunFinishedMsg is sent when a scenario run completes.

type RunRecord

type RunRecord struct {
	artifact.RunBundle
	Dir       string                 `json:"-"`
	Checks    *verifier.VerifyResult `json:"checks,omitempty"`
	Signals   map[string]int         `json:"-"`
	Score     float64                `json:"-"`
	ScoreBand string                 `json:"-"`
}

RunRecord is a historical run read from run.json, augmented with data derived from the run directory (scorecard.json) and the parsed verifier.VerifyResult. The JSON shape comes from artifact.RunBundle, so any schema change there is picked up here automatically.

func HistoryForScenario

func HistoryForScenario(records []RunRecord, scenarioID string) []RunRecord

HistoryForScenario returns runs for a specific scenario, most recent first.

func LoadHistory

func LoadHistory(runsDir string) []RunRecord

LoadHistory reads all run.json files under the runs directory, recursively.

func (RunRecord) Duration

func (r RunRecord) Duration() time.Duration

Duration returns the run duration.

type ScenarioStats

type ScenarioStats struct {
	TotalRuns  int
	PassCount  int
	FailCount  int
	LastResult string // "pass", "fail", or ""
}

ScenarioStats summarizes run history for a scenario.

func ComputeStats

func ComputeStats(records []RunRecord) ScenarioStats

ComputeStats computes stats for a scenario from history records.

Jump to

Keyboard shortcuts

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