rig

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package rig provides rig management functionality. This file implements the property layer lookup API for unified config access.

Package rig provides rig management functionality.

Index

Constants

View Source
const CurrentRigConfigVersion = 1

CurrentRigConfigVersion is the current schema version.

Variables

View Source
var (
	ErrRigNotFound = errors.New("rig not found")
	ErrRigExists   = errors.New("rig already exists")
)

Common errors

View Source
var AgentDirs = []string{
	"polecats",
	"crew",
	"refinery/rig",
	"witness",
	"mayor/rig",
}

AgentDirs are the standard agent directories in a rig. Note: witness doesn't have a /rig subdirectory (no clone needed).

View Source
var StackingKeys = map[string]bool{
	"priority_adjustment": true,
}

StackingKeys defines which keys use stacking semantics (values add up). All other keys use override semantics (first non-nil wins).

View Source
var SystemDefaults = map[string]interface{}{
	"status":              "operational",
	"auto_restart":        true,
	"max_polecats":        10,
	"priority_adjustment": 0,
	"dnd":                 false,
}

SystemDefaults contains compiled-in default values. These are the fallback when no other layer provides a value.

Functions

This section is empty.

Types

type AddRigOptions

type AddRigOptions struct {
	Name          string // Rig name (directory name)
	GitURL        string // Repository URL
	BeadsPrefix   string // Beads issue prefix (defaults to derived from name)
	LocalRepo     string // Optional local repo for reference clones
	DefaultBranch string // Default branch (defaults to auto-detected from remote)
}

AddRigOptions configures rig creation.

type BeadsConfig

type BeadsConfig struct {
	Prefix     string `json:"prefix"`                // issue prefix (e.g., "gt")
	SyncRemote string `json:"sync_remote,omitempty"` // git remote for bd sync
}

BeadsConfig represents beads configuration for the rig.

type ConfigResult

type ConfigResult struct {
	Value  interface{}
	Source ConfigSource
}

ConfigResult holds a config lookup result with its source.

type ConfigSource

type ConfigSource string

ConfigSource identifies which layer a config value came from.

const (
	SourceWisp    ConfigSource = "wisp"    // Local wisp layer (.beads-wisp/config/)
	SourceBead    ConfigSource = "bead"    // Rig identity bead labels
	SourceTown    ConfigSource = "town"    // Town defaults (~/gt/settings/config.json)
	SourceSystem  ConfigSource = "system"  // Compiled-in system defaults
	SourceBlocked ConfigSource = "blocked" // Explicitly blocked at wisp layer
	SourceNone    ConfigSource = "none"    // No value found
)

type Manager

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

Manager handles rig discovery, loading, and creation.

func NewManager

func NewManager(townRoot string, rigsConfig *config.RigsConfig, g *git.Git) *Manager

NewManager creates a new rig manager.

func (*Manager) AddRig

func (m *Manager) AddRig(opts AddRigOptions) (*Rig, error)

AddRig creates a new rig as a container with clones for each agent. The rig structure is:

<name>/                    # Container (NOT a git clone)
├── config.json            # Rig configuration
├── .beads/                # Rig-level issue tracking
├── refinery/rig/          # Canonical main clone
├── mayor/rig/             # Mayor's working clone
├── witness/               # Witness agent (no clone)
├── polecats/              # Worker directories (empty)
└── crew/<crew>/           # Default human workspace

func (*Manager) DiscoverRigs

func (m *Manager) DiscoverRigs() ([]*Rig, error)

DiscoverRigs returns all rigs registered in the workspace. Rigs that fail to load are logged to stderr and skipped; partial results are returned.

func (*Manager) GetRig

func (m *Manager) GetRig(name string) (*Rig, error)

GetRig returns a specific rig by name.

func (*Manager) ListRigNames

func (m *Manager) ListRigNames() []string

ListRigNames returns the names of all registered rigs.

func (*Manager) RemoveRig

func (m *Manager) RemoveRig(name string) error

RemoveRig unregisters a rig (does not delete files).

func (*Manager) RigExists

func (m *Manager) RigExists(name string) bool

RigExists checks if a rig is registered.

type Rig

type Rig struct {
	// Name is the rig identifier (directory name).
	Name string `json:"name"`

	// Path is the absolute path to the rig directory.
	Path string `json:"path"`

	// GitURL is the remote repository URL.
	GitURL string `json:"git_url"`

	// LocalRepo is an optional local repository used for reference clones.
	LocalRepo string `json:"local_repo,omitempty"`

	// Config is the rig-level configuration.
	Config *config.BeadsConfig `json:"config,omitempty"`

	// Polecats is the list of polecat names in this rig.
	Polecats []string `json:"polecats,omitempty"`

	// Crew is the list of crew worker names in this rig.
	// Crew workers are user-managed persistent workspaces.
	Crew []string `json:"crew,omitempty"`

	// HasWitness indicates if the rig has a witness agent.
	HasWitness bool `json:"has_witness"`

	// HasRefinery indicates if the rig has a refinery agent.
	HasRefinery bool `json:"has_refinery"`

	// HasMayor indicates if the rig has a mayor clone.
	HasMayor bool `json:"has_mayor"`
}

Rig represents a managed repository in the workspace.

func (*Rig) BeadsPath

func (r *Rig) BeadsPath() string

BeadsPath returns the path to use for beads operations. Returns the mayor/rig clone path if available (has proper sync-branch config), otherwise falls back to the rig root path. This ensures beads commands read from a location with git-synced beads data.

func (*Rig) DefaultBranch

func (r *Rig) DefaultBranch() string

DefaultBranch returns the configured default branch for this rig. Falls back to "main" if not configured or if config cannot be loaded.

func (*Rig) GetBoolConfig

func (r *Rig) GetBoolConfig(key string) bool

GetBoolConfig looks up a boolean config value. Returns false if not set, not a bool, or blocked.

func (*Rig) GetConfig

func (r *Rig) GetConfig(key string) interface{}

GetConfig looks up a config value through all layers. Override semantics: first non-nil value wins. Layers are checked in order: wisp -> bead -> town -> system

func (*Rig) GetConfigWithSource

func (r *Rig) GetConfigWithSource(key string) ConfigResult

GetConfigWithSource looks up a config value and returns which layer it came from.

func (*Rig) GetIntConfig

func (r *Rig) GetIntConfig(key string) int

GetIntConfig looks up an integer config value with stacking semantics. For stacking keys, values from wisp and bead layers ADD to the base. For non-stacking keys, uses override semantics.

func (*Rig) GetStringConfig

func (r *Rig) GetStringConfig(key string) string

GetStringConfig looks up a string config value. Returns empty string if not set or blocked.

func (*Rig) Summary

func (r *Rig) Summary() RigSummary

Summary returns a RigSummary for this rig.

type RigConfig

type RigConfig struct {
	Type          string       `json:"type"`                     // "rig"
	Version       int          `json:"version"`                  // schema version
	Name          string       `json:"name"`                     // rig name
	GitURL        string       `json:"git_url"`                  // repository URL
	LocalRepo     string       `json:"local_repo,omitempty"`     // optional local reference repo
	DefaultBranch string       `json:"default_branch,omitempty"` // main, master, etc.
	CreatedAt     time.Time    `json:"created_at"`               // when rig was created
	Beads         *BeadsConfig `json:"beads,omitempty"`
}

RigConfig represents the rig-level configuration (config.json at rig root).

func LoadRigConfig

func LoadRigConfig(rigPath string) (*RigConfig, error)

LoadRigConfig reads the rig configuration from config.json.

type RigSummary

type RigSummary struct {
	Name         string `json:"name"`
	PolecatCount int    `json:"polecat_count"`
	CrewCount    int    `json:"crew_count"`
	HasWitness   bool   `json:"has_witness"`
	HasRefinery  bool   `json:"has_refinery"`
}

RigSummary provides a concise overview of a rig.

Jump to

Keyboard shortcuts

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