Purpose
Thetui package is a thin interactive shell around loop.Loop with a small persisted provider config.
Main entrypoints
tui.New(systemPrompt string, opts ...Option)
Constructs a TUIApp with a system prompt and registered tools.
Useful option helpers:
tui.WithTool(name, tool)tui.WithTools(map[string]loop.Tool)
(*TUIApp).Run(ctx)
Starts the read-eval-print loop:
- loads
~/.config/hrns/config.json - runs onboarding if the config file is missing or empty
- builds
openai.Clientfor the current provider - constructs
loop.Loopfrom the stored system prompt and tools - prints the banner
- prints the active provider and model
- reads a line from stdin
- handles slash commands
- appends user messages
- runs the agent loop
- prints streamed chunks
- stores the final message history for the next turn
Slash commands
The package currently handles:/model <model>/new/providers/connect/help
/connect.
Rendering behavior
The package usesgithub.com/fatih/color for simple terminal coloring.
It renders:
- harness messages in blue
- errors in red
- tool names in red with yellow arguments
- reasoning text in gray
Relationship to the rest of hrns
The TUI is the easiest way to try the loop, but it is not the core abstraction. If you want a web UI, service, editor integration, or batch runner, you usually replacetui rather than extend it.