Help us shape the future of Go! Take the 2026 Go Developer Survey

chatcmd

package
v0.2.7 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package chatcmd is `steerloop chat`. Start at chat.go.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseOptions

func ParseOptions(args []string, stderr io.Writer) (bootstrap.Options, error)

ParseOptions reads the `steerloop chat` command line: the flags shared with run, and an optional first prompt.

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

func NewChat(ctx context.Context, env cli.Environment, opts bootstrap.Options) (*Chat, error)

NewChat builds a Chat from options. Command.Run has already checked that stdin is a terminal.

func (*Chat) Execute

func (c *Chat) Execute(parent context.Context) int

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:

  1. stdin lines — c.input.Read; blocks on stdin, so it can outlive the session (the process exits right after, so that is harmless)
  2. Ctrl-C — c.interrupts.Watch; cancel (deferred) ends it

turn starts the goroutines of each turn.

type Command

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

Command is `steerloop chat`. It implements cli.Command.

func New

func New(env cli.Environment) *Command

func (*Command) Run

func (c *Command) Run(ctx context.Context, args []string) int

Run reads top to bottom: parse, validate, build, execute.

type EventSink

type EventSink interface {
	Write(evt event.Event)
}

EventSink receives every event the loop emits. → cmd/steerloop/internal/render (the screen), bootstrap.Recording (the file)

Jump to

Keyboard shortcuts

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