multiplexer

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: MIT Imports: 13 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
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

func CreateDetached(r Runner, name, dir string, argv []string) error

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

func SessionName(projectDir string) string

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

func ShellQuote(s string) string

ShellQuote single-quotes s for a POSIX shell.

Types

type ExecRunner added in v0.7.0

type ExecRunner struct{}

ExecRunner runs real commands.

func (ExecRunner) Run added in v0.7.0

func (ExecRunner) Run(name string, args ...string) (string, error)

Run implements Runner.

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 PaneID

type PaneID string

PaneID identifies a terminal pane within a multiplexer session.

type Runner added in v0.7.0

type Runner interface {
	Run(name string, args ...string) (string, error)
}

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

func ListSessions(r Runner) ([]Session, error)

ListSessions returns the running decsr-* tmux sessions. A missing tmux server means there are none.

func ParseSessions added in v0.7.0

func ParseSessions(out string) []Session

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.

Jump to

Keyboard shortcuts

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