Documentation
¶
Index ¶
- Constants
- func CreateDetached(r Runner, name, dir string, argv []string) error
- func SessionName(projectDir string) string
- func ShellQuote(s string) string
- type ExecRunner
- type Multiplexer
- type PaneID
- type Runner
- type Session
- type TmuxMultiplexer
- func (t *TmuxMultiplexer) Close() error
- func (t *TmuxMultiplexer) CreateSession(id string) error
- func (t *TmuxMultiplexer) NewPane(role bus.AgentRole) (PaneID, error)
- func (t *TmuxMultiplexer) SendCommand(id PaneID, cmd string) error
- func (t *TmuxMultiplexer) SpawnAgent(pane PaneID, role bus.AgentRole, sessionID, socketPath string) error
- func (t *TmuxMultiplexer) WriteToPane(id PaneID, text string) error
Constants ¶
const ( // SessionPrefix starts the name of every tmux session decsr creates. SessionPrefix = "decsr-" // ProjectOption is the tmux user option (set on the session when decsr // creates it) that holds the absolute project path. ProjectOption = "@decsr_project" )
Variables ¶
This section is empty.
Functions ¶
func CreateDetached ¶ added in v0.7.0
CreateDetached starts a detached session running argv in dir with DECSR_TMUX=1 in its environment, and records dir in @decsr_project.
func SessionName ¶ added in v0.7.0
SessionName returns the tmux session name for a project directory: "decsr-<slug>-<4 hex of sha1(abs path)>". The slug is the lowercased base name with every character outside [a-z0-9-] replaced by "-" (tmux session names must not contain "." or ":"); the hash keeps projects with the same base name apart.
func ShellQuote ¶ added in v0.7.0
ShellQuote single-quotes s for a POSIX shell.
Types ¶
type Multiplexer ¶
type Multiplexer interface {
// CreateSession creates a new detached session with the given ID.
CreateSession(id string) error
// NewPane creates a new pane (window or split) for the given agent role.
NewPane(role bus.AgentRole) (PaneID, error)
// WriteToPane sends text to the pane (does not press Enter).
WriteToPane(id PaneID, text string) error
// Close kills the entire session.
Close() error
}
Multiplexer manages a terminal multiplexer session with per-agent panes.
type Runner ¶ added in v0.7.0
Runner runs a command and returns its standard output. On failure the error carries the command's standard error. Tests inject a fake.
type Session ¶ added in v0.7.0
type Session struct {
Name string
Project string // "" when the session carries no @decsr_project
Attached bool
Created time.Time
}
Session is one running decsr tmux session.
func ListSessions ¶ added in v0.7.0
ListSessions returns the running decsr-* tmux sessions. A missing tmux server means there are none.
func ParseSessions ¶ added in v0.7.0
ParseSessions parses `tmux list-sessions -F` output produced with listFormat. Malformed lines and sessions that are not decsr's are skipped.
type TmuxMultiplexer ¶
type TmuxMultiplexer struct {
// contains filtered or unexported fields
}
TmuxMultiplexer implements Multiplexer via the tmux CLI.
func New ¶
func New(sessionID string) *TmuxMultiplexer
New creates a TmuxMultiplexer for the given session ID. Call CreateSession before using other methods.
func (*TmuxMultiplexer) Close ¶
func (t *TmuxMultiplexer) Close() error
Close kills the tmux session.
func (*TmuxMultiplexer) CreateSession ¶
func (t *TmuxMultiplexer) CreateSession(id string) error
CreateSession runs: tmux new-session -d -s <id> -x 220 -y 50
func (*TmuxMultiplexer) NewPane ¶
func (t *TmuxMultiplexer) NewPane(role bus.AgentRole) (PaneID, error)
NewPane creates tmux panes for the first 4 roles using splits in the initial "agents" window. Additional roles use dedicated windows so panes stay legible.
func (*TmuxMultiplexer) SendCommand ¶
func (t *TmuxMultiplexer) SendCommand(id PaneID, cmd string) error
SendCommand sends a shell command to the pane and presses Enter.
func (*TmuxMultiplexer) SpawnAgent ¶
func (t *TmuxMultiplexer) SpawnAgent(pane PaneID, role bus.AgentRole, sessionID, socketPath string) error
SpawnAgent sends DECSR agent sub-command to a pane.
func (*TmuxMultiplexer) WriteToPane ¶
func (t *TmuxMultiplexer) WriteToPane(id PaneID, text string) error
WriteToPane sends text to the pane without pressing Enter.