treeman

package
v0.3.20 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: MIT Imports: 18 Imported by: 1 module, 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

Overview

Package treeman is the treeman daemon client: worktree health as a status snapshot from the `treeman status` CLI, refreshed whenever the daemon's event socket signals activity.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SocketPath

func SocketPath() (string, bool)

SocketPath mirrors treeman's own lookup order: $TREEMAN_SOCKET → $XDG_RUNTIME_DIR/treeman.sock → $XDG_DATA_HOME/treeman/treeman.sock → ~/.local/share/treeman/treeman.sock.

Types

type Action

type Action int

Action is a worktree mutation (service.rs's Action).

const (
	// ActionPrepare re-runs the prepare pipeline.
	ActionPrepare Action = iota
	// ActionReset drops and re-seeds the branch-scoped databases.
	ActionReset
	// ActionTeardown removes the worktree entirely.
	ActionTeardown
)

Actions.

func (Action) Args

func (a Action) Args(path string) []string

Args are the treeman CLI arguments for the action on a worktree.

type Bucket

type Bucket int

Bucket is the coarse worktree state, mirroring treeman's bucket strings.

const (
	BucketStable Bucket = iota
	BucketUp
	BucketDown
	BucketFailed
)

Buckets, most severe last for the comparison in WorstBucket.

func ParseBucket

func ParseBucket(s string) Bucket

ParseBucket is Bucket::parse: up, down, failed, anything else stable.

type Repo

type Repo struct {
	Repo      string     `json:"repo"`
	Total     uint32     `json:"total"`
	Worktrees []Worktree `json:"worktrees"`
}

Repo is one registered repo and its active worktrees.

type Source

type Source interface {
	// Status is the latest snapshot (the Rust service's status
	// property): nil until treeman reported one, and for good when
	// treeman is not installed.
	Status() *Status
	// Subscribe ticks when Status changes. The channel closes when the
	// source stops; stop unsubscribes.
	Subscribe(ctx context.Context) (<-chan struct{}, func(), error)
	// RunAction queues an action with the treeman daemon; the status
	// subscription reports its progress. A failure carries the
	// command's stderr.
	RunAction(ctx context.Context, action Action, path string) error
}

Source is the module's seam.

type Status

type Status struct {
	Total  uint32 `json:"total"`
	Stable uint32 `json:"stable"`
	Up     uint32 `json:"up"`
	Down   uint32 `json:"down"`
	Failed uint32 `json:"failed"`
	Class  string `json:"class"`
	Repos  []Repo `json:"repos"`
}

Status is the aggregated worktree health across every registered repo (treeman status's JSON).

func (Status) FindWorktree

func (s Status) FindWorktree(path string) (Repo, Worktree, bool)

FindWorktree is find_worktree: the worktree at path and its repo.

func (Status) WorstBucket

func (s Status) WorstBucket() Bucket

WorstBucket is model.rs's worst_bucket: failed > down > up > stable.

type System

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

System is the real client, built by New.

func New

func New(binary string) *System

New builds the client for the given treeman binary.

func (*System) RunAction

func (s *System) RunAction(ctx context.Context, action Action, path string) error

RunAction implements Source (run_action): the CLI's stderr is the error on a non-zero exit.

func (*System) Status

func (s *System) Status() *Status

Status implements Source.

func (*System) Stop

func (s *System) Stop()

Stop terminates the event loop and closes every subscriber.

func (*System) Subscribe

func (s *System) Subscribe(ctx context.Context) (<-chan struct{}, func(), error)

Subscribe implements Source; the first subscription starts the service loop.

type Worktree

type Worktree struct {
	// Branch is the branch name ("-" when detached or unknown).
	Branch string `json:"branch"`
	Slug   string `json:"slug"`
	// State is the fine lifecycle state (ready, preparing, error, …);
	// Bucket the coarse one it maps to.
	State  string `json:"state"`
	Bucket string `json:"bucket"`
	IsMain bool   `json:"is_main"`
	// Path is the absolute worktree path.
	Path string `json:"path"`
}

Worktree is one active worktree (model.rs's TreemanWorktree).

Jump to

Keyboard shortcuts

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