herdr

package
v0.29.0 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package herdr is the binary's door to Herdr, the terminal multiplexer `f10 start` opens a task's worktree in, `f10 forward` reaches its agent through and `f10 finish` closes it from. Every call goes through the herdr CLI as JSON, and the ids the next call needs are read from the answer rather than predicted.

Index

Constants

View Source
const (
	CodePaneBusy      = "agent_pane_busy"
	CodeAgentNotFound = "agent_not_found"
)

The error codes this package acts on. Herdr answers agent_pane_busy while the pane runs anything but an idle shell, its rc files included.

Variables

View Source
var (
	StartDeadline = 5 * time.Second
	StartPoll     = 200 * time.Millisecond
	StartReport   = time.Second
)

How long StartAgent waits for a pane whose shell is still starting, how often it asks, and the longest gap between two progress reports. Variables so tests need not wait.

View Source
var ErrNotInside = errors.New("f10 start, forward, drive and finish run inside a Herdr session: " +
	"open a pane there, or install it from https://herdr.dev")

ErrNotInside is the one refusal: start, forward, drive and finish run inside a Herdr session and nowhere else, with no fallback by design.

Functions

func AgentExists added in v0.27.0

func AgentExists(ctx context.Context, dir, target string) (bool, error)

AgentExists reports whether a live agent answers to target: its name, or the id of the pane hosting it.

func Available

func Available() error

Available reports whether this process can reach Herdr: the session marks itself in the environment, and the CLI has to be on PATH.

func CloseWorkspace

func CloseWorkspace(ctx context.Context, dir, id string) error

CloseWorkspace closes the workspace, its tabs and panes, and whatever agent ran in them.

func FocusWorkspace

func FocusWorkspace(ctx context.Context, dir, id string) error

FocusWorkspace brings the workspace to the front.

func IsCode added in v0.27.0

func IsCode(err error, code string) bool

IsCode reports whether err is herdr's refusal with code.

func PaneIdleShell added in v0.27.0

func PaneIdleShell(ctx context.Context, dir, pane string) (bool, error)

PaneIdleShell reports whether pane sits at its shell's prompt: the shell owns the terminal's foreground process group. Anything the shell runs, an rc child or a program, owns a group of its own.

func Prompt

func Prompt(ctx context.Context, dir, name, text string) error

Prompt submits text to the named agent and returns as soon as it is submitted. Never --wait: the caller may itself be an agent in Herdr.

func StartAgent

func StartAgent(ctx context.Context, dir, name, kind, pane string, waiting func(waited time.Duration)) error

StartAgent launches an agent of kind in pane under name. A pane whose shell is still running its rc files answers busy, so that one refusal is retried until StartDeadline; past it, herdr's error stands. While it waits, waiting (when not nil) hears how long it has waited: on the first busy answer, then within StartReport of the last. Once started, waiting for the agent to be ready for input is herdr's wait, not ours.

Types

type Error added in v0.27.0

type Error struct {
	Op      string // the command, as `herdr <verb> <sub>`
	Code    string
	Message string
}

An Error is herdr's own refusal: the error envelope it printed on stderr.

func (*Error) Error added in v0.27.0

func (e *Error) Error() string

type Listed

type Listed struct {
	ID      string
	Label   string
	Path    string
	Focused bool
	Agent   string // herdr's agent_status: idle, working, done, unknown
}

A Listed is one workspace as `workspace list` reports it. Path is the checkout the workspace shows, or "" for a workspace with no worktree.

func Workspaces

func Workspaces(ctx context.Context, dir string) ([]Listed, error)

Workspaces lists every workspace the session shows.

type Pane added in v0.27.0

type Pane struct {
	ID    string
	Agent string
}

A Pane is one pane of a workspace as `pane list` reports it. Agent is the kind of agent the pane hosts, or "" for none.

func Panes added in v0.27.0

func Panes(ctx context.Context, dir, workspace string) ([]Pane, error)

Panes lists the panes of one workspace, in Herdr's order.

type Workspace

type Workspace struct {
	ID          string
	RootPane    string
	AlreadyOpen bool // Herdr was showing this checkout before the call
}

A Workspace is what opening a worktree yields: the ids the agent calls are addressed by.

func OpenWorktree

func OpenWorktree(ctx context.Context, dir, path, label string) (Workspace, error)

OpenWorktree turns the checkout at path into a workspace labelled label, or returns the one already showing it. dir is the main checkout, passed as --cwd: without it Herdr takes the repo from the focused workspace, and refuses when that one shows a linked worktree.

Jump to

Keyboard shortcuts

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