registry

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildPortRanges

func BuildPortRanges(workCfg *config.WorktreeConfig) map[string][2]int

BuildPortRanges constructs port ranges from WorktreeConfig All port ranges must be defined in the configuration file

func NormalizeBranchName

func NormalizeBranchName(branch string) string

NormalizeBranchName converts a branch name to a filesystem-safe directory name

Types

type Registry

type Registry struct {
	Worktrees  map[string]*Worktree `json:"worktrees"`
	PortRanges map[string][2]int    `json:"port_ranges"`
	// contains filtered or unexported fields
}

Registry manages all worktree instances and port allocations

func Load

func Load(worktreeDir string, workCfg *config.WorktreeConfig) (*Registry, error)

Load loads the registry from disk, or creates a new one if it doesn't exist workCfg is optional - if provided, port ranges are loaded from configuration

func (*Registry) Add

func (r *Registry) Add(wt *Worktree) error

Add adds a new worktree to the registry

func (*Registry) AllocatePorts

func (r *Registry) AllocatePorts(services []string) (map[string]int, error)

AllocatePorts allocates ports for all specified services

func (*Registry) FindAvailablePort

func (r *Registry) FindAvailablePort(service string) (int, error)

FindAvailablePort finds an available port for a service

func (*Registry) Get

func (r *Registry) Get(normalized string) (*Worktree, bool)

Get retrieves a worktree by normalized name

func (*Registry) List

func (r *Registry) List() []*Worktree

List returns all worktrees sorted by creation time

func (*Registry) Remove

func (r *Registry) Remove(normalized string) error

Remove removes a worktree from the registry

func (*Registry) Save

func (r *Registry) Save() error

Save persists the registry to disk

type Worktree

type Worktree struct {
	Branch          string            `json:"branch"`
	Normalized      string            `json:"normalized"`
	Created         time.Time         `json:"created"`
	Projects        []string          `json:"projects"`
	Ports           map[string]int    `json:"ports"`
	ComputedVars    map[string]string `json:"computed_vars,omitempty"`    // All env vars fully resolved for this instance (ports, derived URLs, aliases)
	ComposeProject  string            `json:"compose_project,omitempty"`  // Deprecated: use ComposeProjects
	ComposeProjects map[string]string `json:"compose_projects,omitempty"` // Per-service compose project names
	YoloMode        bool              `json:"yolo_mode,omitempty"`        // YOLO mode: Claude works autonomously when solution is clear
}

Worktree represents a single worktree instance

func (*Worktree) GetComposeProject

func (w *Worktree) GetComposeProject(service string) string

GetComposeProject returns the compose project name for a specific service Falls back to the legacy ComposeProject field if per-service names are not set

Jump to

Keyboard shortcuts

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