cli

package
v0.46.0 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

ABOUTME: A terminal REPL transport — a second consumer of transport/chatops that ABOUTME: proves the boundary: type a request, answer gates inline, watch it run.

This is a first-class peer to the Slack bot, built from the same core: a chatops.ThreadUI for output + gate rendering, and an inbound loop that routes each stdin line to the Runner (a fresh request, or an answer to a pending gate). It needs no external service, so it's exercised end-to-end in tests via the Dispatcher seam.

Index

Constants

View Source
const (
	Thread  = "cli"
	Channel = "cli"
)

The REPL is one conversation, so it uses one fixed thread/channel identity — the Runner keys every run and command on it, exactly as Slack keys on thread_ts.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dispatcher

type Dispatcher interface {
	OnMention(ctx context.Context, channel, threadTS, text string)
	OnInteraction(threadTS, gateID string, answer chatops.GateAnswer) bool
}

Dispatcher is the slice of *chatops.Runner the REPL drives. Narrowing to an interface keeps the loop testable with a fake — no LLM or pipeline needed.

type Session

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

Session holds the terminal transport's output writer and the single pending gate (the one the next input line answers). Bind its ThreadUI into RunnerDeps.NewThreadUI, then call Run with the Runner as the Dispatcher.

func NewSession

func NewSession(out io.Writer) *Session

NewSession returns a REPL session writing to out (usually os.Stdout).

func (*Session) Run

func (s *Session) Run(ctx context.Context, in io.Reader, disp Dispatcher) error

Run reads input lines and routes each: an answer to a pending gate, a control line (/quit, /exit), or a fresh request. Requests dispatch on a goroutine so the loop stays free to read the gate answers a run will ask for — mirroring the Slack event loop's non-blocking mention handling. Returns when input ends or the user quits.

func (*Session) ThreadUI

func (s *Session) ThreadUI(_, _ string) chatops.ThreadUI

ThreadUI returns the session's ThreadUI. Wire it as RunnerDeps.NewThreadUI; the REPL is single-thread, so every (channel, thread) maps to this one UI.

Jump to

Keyboard shortcuts

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