tui

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GroupCode     = "Code"
	GroupGo       = "Go Tools"
	GroupPython   = "Python Tools"
	GroupSecurity = "Security"
	GroupSkills   = "Skills"
	GroupMCP      = "MCP & Serve"
	GroupSystem   = "System"
)

Group constants.

View Source
const ConfigDir = ".config/sin"

ConfigDir is the directory under $HOME holding TUI config. Kept consistent with `sin config` so users can locate it without a flag.

View Source
const ConfigFileName = "tui.toml"

ConfigFileName is the TOML file name within ConfigDir.

View Source
const MaxHistoryItems = 20

MaxHistoryItems caps the number of past search terms kept in memory. 20 ≈ a session's worth of distinct queries without bloating recall; chosen to match shell HISTSIZE conventions where 10–50 is typical.

Variables

View Source
var Commands = []Command{

	{Key: "code", Title: "🚀 sin code", Description: "Unified coding workflow hub", Group: GroupCode},
	{Key: "code review", Title: "🔍 review", Description: "Semantic review of a change (IBD)", Group: GroupCode, Args: "<files>"},
	{Key: "code debt", Title: "🏚️  debt", Description: "Show current architectural debt", Group: GroupCode, Args: "<path>"},
	{Key: "code verify", Title: "✅ verify", Description: "Independent execution-based verification", Group: GroupCode, Args: "<target>"},
	{Key: "code preflight", Title: "✈️  preflight", Description: "Fresh GitNexus index for coder agents", Group: GroupCode},
	{Key: "code codocs", Title: "📚 codocs", Description: "Validate co-located .doc.md companions", Group: GroupCode, Args: "<path>"},
	{Key: "code sckg", Title: "🕸️  sckg", Description: "Semantic codebase knowledge graph", Group: GroupCode, Args: "<path>"},
	{Key: "code audit", Title: "🛡️  audit", Description: "47-gate CEO-audit (security/perf/quality)", Group: GroupCode, Args: "<path>"},
	{Key: "code full", Title: "⚡ full pipeline", Description: "preflight → codocs → debt → sckg → ...", Group: GroupCode, Args: "<path>"},

	{Key: "sin-code run discover", Title: "🗂️  discover", Description: "File discovery with relevance scoring", Group: GroupGo, Args: "<path>"},
	{Key: "sin-code run map", Title: "🗺️  map", Description: "Architecture map + dependency graph", Group: GroupGo, Args: "<path>"},
	{Key: "sin-code run grasp", Title: "🤖 grasp", Description: "Deep single-file analysis", Group: GroupGo, Args: "<file>"},
	{Key: "sin-code run scout", Title: "🔭 scout", Description: "Regex/semantic/symbol code search", Group: GroupGo, Args: "<query>"},
	{Key: "sin-code run harvest", Title: "🌾 harvest", Description: "URL fetch + cache + structure extract", Group: GroupGo, Args: "<url>"},
	{Key: "sin-code run execute", Title: "⚙️  execute", Description: "Safe exec with secret redaction", Group: GroupGo, Args: "<cmd>"},
	{Key: "sin-code run orchestrate", Title: "🪄 orchestrate", Description: "Task deps + parallel exec + rollback", Group: GroupGo},

	{Key: "ibd", Title: "🧬 ibd", Description: "Intent-Based Diffing (semantic AST)", Group: GroupPython, Args: "<files>"},
	{Key: "poc", Title: "📐 poc", Description: "Proof-of-Correctness verification", Group: GroupPython, Args: "<target>"},
	{Key: "adw", Title: "🏛️  adw", Description: "Architectural Debt Watchdog", Group: GroupPython, Args: "<path>"},
	{Key: "oracle", Title: "🔮 oracle", Description: "Independent Verification Oracle", Group: GroupPython, Args: "<target>"},
	{Key: "efm", Title: "🧪 efm", Description: "Ephemeral Full-Stack Mocking", Group: GroupPython, Args: "<spec>"},
	{Key: "sckg", Title: "🕸️  sckg", Description: "SCKG — knowledge graph (11 cmds)", Group: GroupPython, Args: "<cmd> [args]"},

	{Key: "security secrets", Title: "🔐 secrets", Description: "Scan for hardcoded secrets (regex + entropy)", Group: GroupSecurity, Args: "[path]"},
	{Key: "security sast", Title: "🛡️  sast", Description: "Static application security testing", Group: GroupSecurity, Args: "[path]"},
	{Key: "security sca", Title: "📦 sca", Description: "Software composition analysis (deps + CVEs)", Group: GroupSecurity, Args: "[path]"},
	{Key: "security sbom", Title: "📋 sbom", Description: "Generate SBOM (SPDX + CycloneDX)", Group: GroupSecurity, Args: "[path]"},
	{Key: "security container", Title: "🐳 container", Description: "Scan container images", Group: GroupSecurity, Args: "<image>"},
	{Key: "security iac", Title: "🏗️  iac", Description: "Scan IaC (Terraform, CloudFormation, K8s)", Group: GroupSecurity, Args: "[path]"},
	{Key: "security license", Title: "📜 license", Description: "License compliance check", Group: GroupSecurity, Args: "[path]"},
	{Key: "security dast", Title: "🎯 dast", Description: "Dynamic application security testing", Group: GroupSecurity, Args: "<target>"},
	{Key: "security full", Title: "🛡️  full", Description: "Run all 8 security tools in sequence", Group: GroupSecurity, Args: "<path>"},

	{Key: "brain", Title: "🧠 brain", Description: "Global/project behavioral rules", Group: GroupSkills},
	{Key: "context-bridge", Title: "🌉 context-bridge", Description: "Unified SCKG+brain+gitnexus query", Group: GroupSkills, Args: "<query>"},
	{Key: "websearch", Title: "🔎 websearch", Description: "SerpAPI multi-key pool", Group: GroupSkills, Args: "<query>"},
	{Key: "scheduler", Title: "⏰ scheduler", Description: "Cron/interval job scheduling", Group: GroupSkills},
	{Key: "goal-mode", Title: "🎯 goal-mode", Description: "Goal tracking with checkpoints", Group: GroupSkills},
	{Key: "grill-me", Title: "🔥 grill-me", Description: "Adversarial design-review interview", Group: GroupSkills, Args: "<topic>"},
	{Key: "doc-coauthoring", Title: "📝 doc-coauthoring", Description: "Collaborative README/ADR/SPEC", Group: GroupSkills},
	{Key: "codocs", Title: "📘 codocs", Description: "CoDocs standard + sprint", Group: GroupSkills, Args: "<path>"},
	{Key: "marketplace", Title: "🛍️  marketplace", Description: "Skill catalog search/install", Group: GroupSkills},
	{Key: "browser", Title: "🌐 browser", Description: "106 browser-automation tools", Group: GroupSkills},

	{Key: "serve", Title: "📡 serve", Description: "Expose tools as unified MCP server", Group: GroupMCP},
	{Key: "serve-mcp", Title: "🛰️  serve-mcp", Description: "Start MCP server (stdio)", Group: GroupMCP},
	{Key: "mcp-config", Title: "📋 mcp-config", Description: "Generate ready-to-use MCP config", Group: GroupMCP},
	{Key: "simone", Title: "🔬 simone", Description: "Simone-MCP code analysis", Group: GroupMCP},

	{Key: "status", Title: "📊 status", Description: "Which subsystems are installed", Group: GroupSystem},
	{Key: "doctor", Title: "🩺 doctor", Description: "Diagnose environment + audit chain", Group: GroupSystem},
	{Key: "bootstrap", Title: "🎬 bootstrap", Description: "Initialize subsystems for repo", Group: GroupSystem, Args: "<path>"},
	{Key: "agents-md", Title: "🤝 agents-md", Description: "Create/update AGENTS.md", Group: GroupSystem},
	{Key: "policy", Title: "📜 policy", Description: "Inspect/init SIN policy + audit log", Group: GroupSystem},
	{Key: "skills", Title: "🎓 skills", Description: "Compile portable skills to agent fmt", Group: GroupSystem},
	{Key: "update", Title: "⬆️  update", Description: "Self-update stack (pipx + Go)", Group: GroupSystem},
	{Key: "config", Title: "⚙️  config", Description: "Unified config management", Group: GroupSystem},
}

Commands is the full menu catalog. Order within a group = display order.

Functions

func ByGroup

func ByGroup(cmds []Command) map[string][]Command

ByGroup groups commands by their Group field, preserving catalog order.

func ConfigPath

func ConfigPath() (string, error)

ConfigPath returns the absolute path to the TUI config file. Exported so tests and `sin config` can locate it.

func CopyToClipboard

func CopyToClipboard(text string) error

CopyToClipboard writes text to the system clipboard via pbcopy. Returns any I/O or exec error verbatim so the caller can decide whether to log, toast, or silently ignore.

func Groups

func Groups() []string

Groups returns the menu groups in display order.

func SaveConfig

func SaveConfig(cfg Config) error

SaveConfig writes the config file, creating the parent dir if needed. File mode is 0o644 — config is non-secret and the user may want to read it with `cat`.

Types

type AppState

type AppState int

AppState — the finite-state machine of the TUI.

const (
	StateMenu    AppState = iota // user is browsing the menu
	StateSearch                  // user is typing in the search bar
	StatePrompt                  // user is providing Args value
	StateRunning                 // a command is currently executing
	StateOutput                  // command finished; showing output
)

type Command

type Command struct {
	// Key is the canonical subcommand name, e.g. "sckg", "code", "doctor".
	Key string
	// Title is shown in the menu, supports emojis and short labels.
	Title string
	// Description is a one-line explanation shown beside the menu item.
	Description string
	// Group classifies the command in the menu (Code, Skills, MCP, ...).
	Group string
	// Args is the raw argument template. If non-empty, the TUI prompts for
	// a value before running. The placeholder is rendered as the prompt hint.
	Args string
	// Danger marks destructive commands (e.g. "policy reset") for red styling.
	Danger bool
}

Command describes one callable sin subcommand exposed in the TUI menu.

func Filter

func Filter(query string) []Command

Filter returns the commands matching the current query (case-insensitive substring match on key, title, or description).

type Config

type Config struct {
	// Theme is "dark" (default) or "light". Other values are rejected
	// on load to keep us forward-compatible with future palettes.
	Theme string
}

Config holds persisted TUI preferences. Add fields here as they become persistent (window split %, last opened command, etc.).

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns the baseline preferences used when no config file is present or it cannot be read.

func LoadConfig

func LoadConfig() Config

LoadConfig reads the config file. Missing file, parse error, or invalid values all degrade silently to DefaultConfig — a corrupt config must never wedge the TUI on launch.

type History

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

History is an in-memory ring buffer with a single cursor for up/down recall. It is intentionally not persisted — search history can contain PII (paths, secrets typed by accident) and the TUI is a developer tool, not a system shell.

Cursor semantics:

  • cursor == -1 → no recall active; Next returns "".
  • cursor in [0, len) → currently recalling items[cursor].

func NewHistory

func NewHistory() *History

NewHistory returns an empty history with no active cursor.

func (*History) Items

func (h *History) Items() []string

Items returns a snapshot of stored items, oldest → newest. The slice is a copy so callers cannot mutate the buffer.

func (*History) Len

func (h *History) Len() int

Len returns the number of stored items.

func (*History) Next

func (h *History) Next() string

Next recalls the following (newer) term. Returns "" when stepping past the newest entry, which the UI should treat as "back to a blank input".

func (*History) Prev

func (h *History) Prev() string

Prev recalls the previous (older) term. Returns "" if history is empty. On the first call after Push/Reset, returns the newest entry.

func (*History) Push

func (h *History) Push(q string)

Push appends a query and resets the cursor. Empty strings and exact duplicates of the most recent entry are ignored (matches readline/bash HISTCONTROL=ignoredups default). At capacity, the oldest entry is evicted.

func (*History) Reset

func (h *History) Reset()

Reset clears the cursor without dropping items. Call when the user dismisses the search bar so the next Prev starts from the newest entry.

type Model

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

Model is the Bubbletea top-level model.

func NewModel

func NewModel() *Model

NewModel builds a fresh TUI model. Theme preference is loaded from ~/.config/sin/tui.toml so the user's choice survives across sessions.

func (*Model) Accent

func (m *Model) Accent() lipgloss.Style

Accent returns a style for an inline accent (workaround helper).

func (*Model) Init

func (m *Model) Init() tea.Cmd

Init starts the spinner.

func (*Model) Update

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

func (*Model) View

func (m *Model) View() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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