Documentation
¶
Overview ¶
Package chat is the terminal side of the interactive mode: the slash-command table and its menu, a small line editor with key decoding, and a console that keeps the input line intact while session events print above it. It knows nothing about the API.
Index ¶
Constants ¶
const MaxMenu = 6
MaxMenu is how many commands the menu shows at once.
Variables ¶
var Commands = []Command{ {Name: "new", Args: "[prompt]", Desc: "Start a new session from this repo"}, {Name: "sessions", Desc: "List recent sessions and pick one by number"}, {Name: "switch", Args: "<id>", Desc: "Follow another session"}, {Name: "status", Desc: "Run, queue, last outcome, pull request"}, {Name: "stop", Desc: "Stop the running work (changes are kept)"}, {Name: "steer", Args: "<text>", Desc: "Redirect the run that is going"}, {Name: "queue", Desc: "Show the prompts waiting behind the run"}, {Name: "logs", Args: "[N]", Desc: "Show the last N events (default 30)"}, {Name: "diff", Desc: "What the session changed, per repo"}, {Name: "pr", Desc: "Show and open the pull request"}, {Name: "preview", Desc: "Print preview links (one-time, 60 seconds)"}, {Name: "open", Desc: "Open the session in the browser"}, {Name: "share", Args: "[viewer|collaborator]", Desc: "Turn on a share link and print it"}, {Name: "export", Args: "[csv|xlsx]", Desc: "Save this session's summary row to a file"}, {Name: "mode", Args: "auto|build|plan|ask", Desc: "How the next prompts run"}, {Name: "model", Args: "<id>", Desc: "Model for the next prompts"}, {Name: "attach", Args: "<file>", Desc: "Attach a file to the next prompt"}, {Name: "whoami", Desc: "Who you are and where"}, {Name: "workspace", Args: "[name]", Desc: "List workspaces, or switch for this chat"}, {Name: "login", Desc: "Sign in"}, {Name: "logout", Desc: "Sign out and leave"}, {Name: "clear", Desc: "Clear the screen (the session keeps going)"}, {Name: "help", Aliases: []string{"?"}, Desc: "List every command"}, {Name: "quit", Aliases: []string{"exit"}, Desc: "Leave; the session keeps running"}, }
Commands are all the slash commands, in the order the menu shows them.
Functions ¶
Types ¶
type Command ¶
Command is a slash command: its name, the argument hint and a one-line description.
type Console ¶
type Console struct {
Out io.Writer
Raw bool
Width func() int
Prompt func() string // the prompt text, plain
Ed *Editor
Bold func(string) string // styling for the selected menu item; nil: none
Dim func(string) string
// contains filtered or unexported fields
}
Console is the chat's output. In Raw mode (a terminal in raw input mode) it keeps the input line and the command menu at the bottom: text written to it appears above them, and they are drawn again after. Otherwise it is a plain writer.
func (*Console) Hide ¶
func (c *Console) Hide()
Hide clears the input area, leaving the cursor at the start of an empty line.
type Editor ¶
type Editor struct {
Buf []rune
Pos int
Sel int // selected menu item
Dismissed bool // Esc closed the menu until the text changes
Line string
// contains filtered or unexported fields
}
Editor is a one-line editor with history and the slash-command menu. It is pure: it takes keys and changes its state; the Console draws it.