Quickstart
Install the module, wire the Scan → Render loop into your host, and run the bundled example.
Install
go get github.com/joestump-agent/a2tea
Wire up a host
Scan the reply into parts, render each part's prose, and hand its messages to
Render. Render returns an embeddable model — it never owns the terminal.
parts, err := a2tea.Scan(reply)
if err != nil {
// not valid A2UI — render reply as plain text
}
for _, p := range parts {
if p.Text != "" {
renderProse(p.Text)
}
if len(p.Messages) > 0 {
model, err := a2tea.Render(p.Messages)
if err != nil {
continue
}
draw(model)
}
}
tip
Use a2tea.Contains(reply) as a cheap gate before taking the Scan path at all.
Run the example
A runnable version of the whole flow lives in
examples/hello.
It wraps a single surface with Standalone so it runs on its own.
go run ./examples/hello
╭──────────────────────────╮
│ Hello from A2UI │
│ rendered by a2tea │
│ ──────────────────────── │
│ [ OK ] │
╰──────────────────────────╯
tab cycle • enter select • q quit