Documentation
¶
Overview ¶
Package chatcmd is `steerloop chat`. Start at chat.go.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Chat ¶
type Chat struct {
// contains filtered or unexported fields
}
Chat is one fully wired session at a terminal, ready to execute. NewChat builds it. A chat has one mode, a person typing, so it holds concrete types: one reader of stdin feeds both the steering while a turn runs and the "❯ " prompt after it.
func NewChat ¶
NewChat builds a Chat from options. Command.Run has already checked that stdin is a terminal.
func (*Chat) Execute ¶
Execute runs the session: a prompt, then a turn, again and again, with the conversation carried into a fresh loop each time. However a turn ends (an answer, /stop, Ctrl-C, max iterations, an error) the next prompt follows. The session ends at end of input (exit 0), on Ctrl-C at the prompt or a second Ctrl-C during a turn (exit 130).
Two goroutines live for the whole session, both started here:
- stdin lines — c.input.Read; blocks on stdin, so it can outlive the session (the process exits right after, so that is harmless)
- Ctrl-C — c.interrupts.Watch; cancel (deferred) ends it
turn starts the goroutines of each turn.