config

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AllCapabilities = []string{
	"issue.read",
	"issue.create",
	"issue.update",
	"issue.comment",
	"issue.start",
	"issue.merge",
	"issue.delete",
	"issue.link",
}

AllCapabilities is the canonical list of capabilities.

View Source
var BuiltinLabelOrder = []string{"bug", "feature", "epic", "improvement"}

BuiltinLabelOrder defines the canonical display order for built-in labels.

View Source
var BuiltinLabels = map[string]string{
	"bug":         "#eb5757",
	"feature":     "#b36cd9",
	"epic":        "#5e6ad2",
	"improvement": "#4da6e8",
}

BuiltinLabels are the default labels seeded into new projects. Config labels take precedence over these when both exist.

View Source
var EstimationSystems = map[string][]int{
	"fibonacci":   {1, 2, 3, 5, 8},
	"exponential": {1, 2, 4, 8, 16},
	"linear":      {1, 2, 3, 4, 5},
	"shirt":       {1, 2, 3, 5, 8},
}

Estimation system allowed values

View Source
var ShirtLabels = map[int]string{
	1: "XS",
	2: "S",
	3: "M",
	5: "L",
	8: "XL",
}

ShirtLabels maps shirt-size estimate values to display labels

View Source
var ShirtValues = map[string]int{
	"XS": 1,
	"S":  2,
	"M":  3,
	"L":  5,
	"XL": 8,
}

ShirtValues maps shirt-size display labels to estimate values

Functions

func AddLabel

func AddLabel(name, color string) error

AddLabel writes a label and its color to the project config file, preserving existing formatting via yaml.Node manipulation.

func DeleteLabel

func DeleteLabel(name string) error

DeleteLabel removes a label from the project config file.

func EstimateDisplayValue

func EstimateDisplayValue(system string, value int) string

EstimateDisplayValue returns the display string for an estimate value. For shirt system, returns the shirt label; for others, returns the number as string.

func GetInboxLastRead

func GetInboxLastRead(remoteURL string) time.Time

GetInboxLastRead returns the per-user inbox read cursor. In distributed mode (remoteURL set) it is stored under the server host; in local mode it is stored under the absolute .xpo path. A zero time means never read.

func IsLocalProjectConfig

func IsLocalProjectConfig() bool

IsLocalProjectConfig returns true if .xpo/config.yaml looks like a server-side project config (has a prefix field) rather than a minimal remote-only config.

func ParseEstimateInput

func ParseEstimateInput(system string, input string) (int, error)

ParseEstimateInput parses user input into an int estimate value. For shirt system, accepts both numeric and shirt-size labels (XS, S, M, L, XL).

func ReadRemoteURL

func ReadRemoteURL() string

ReadRemoteURL returns the remote.url from .xpo/config.yaml, if any.

func RemoveServerCredential

func RemoveServerCredential(serverURL string) error

RemoveServerCredential removes a stored server credential.

func SaveServerCredential

func SaveServerCredential(serverURL, token string) error

SaveServerCredential stores a token for a server URL, preserving any existing per-user state (e.g. last_read) for that server.

func SaveUserConfig

func SaveUserConfig(c UserConfig) error

SaveUserConfig writes all per-user state.

func SetInboxLastRead

func SetInboxLastRead(remoteURL string, t time.Time) error

SetInboxLastRead persists the per-user inbox read cursor, routing to the server host (distributed) or absolute .xpo path (local) as appropriate.

func SetRemoteURL

func SetRemoteURL(serverURL string) error

SetRemoteURL writes the remote.url field into .xpo/config.yaml, creating the file if it doesn't exist. Preserves existing content.

func UpdateLabel

func UpdateLabel(oldName, newName, color string) error

UpdateLabel renames a label and/or changes its color in the project config file.

func ValidateEstimate

func ValidateEstimate(system string, value int) error

ValidateEstimate checks if a value is valid for the given estimation system.

Types

type Automations

type Automations struct {
	FirstStart    bool `mapstructure:"first_start" yaml:"first_start"`
	LastCompleted bool `mapstructure:"last_completed" yaml:"last_completed"`
}

type Config

type Config struct {
	Name              string            `mapstructure:"name" yaml:"name"`
	Prefix            string            `mapstructure:"prefix" yaml:"prefix"`
	User              string            `mapstructure:"user" yaml:"user"`
	DefaultLabels     []string          `mapstructure:"default_labels" yaml:"default_labels"`
	HideDefaultLabels bool              `mapstructure:"hide_default_labels" yaml:"hide_default_labels"`
	Editor            string            `mapstructure:"editor" yaml:"editor"`
	AutoCommit        bool              `mapstructure:"auto_commit" yaml:"auto_commit"`
	Style             Style             `mapstructure:"style" yaml:"style"`
	Version           int               `mapstructure:"version" yaml:"version"`
	EstimationSystem  string            `mapstructure:"estimation_system" yaml:"estimation_system"`
	CountUnestimated  bool              `mapstructure:"count_unestimated" yaml:"count_unestimated"`
	Automations       Automations       `mapstructure:"automations" yaml:"automations"`
	Labels            map[string]string `mapstructure:"labels" yaml:"labels"`
	Cycles            CycleConfig       `mapstructure:"cycles" yaml:"cycles"`
	Contributors      []string          `mapstructure:"contributors" yaml:"contributors"`
	Remote            RemoteConfig      `mapstructure:"remote" yaml:"remote"`
	Permissions       PermissionsConfig `mapstructure:"permissions" yaml:"permissions,omitempty"`
	Drive             DriveConfig       `mapstructure:"drive" yaml:"drive,omitempty"`
}

func LoadConfig

func LoadConfig() (*Config, error)

LoadConfig reads configuration from file or environment variables.

type Cycle

type Cycle struct {
	ID     string    // start date as YYYY-MM-DD
	Number int       // sequential, 1-based from anchor
	Start  time.Time // first day of cycle (inclusive)
	End    time.Time // last day of cycle (inclusive)
}

func (Cycle) Contains

func (c Cycle) Contains(date time.Time) bool

func (Cycle) IsBefore

func (c Cycle) IsBefore(other Cycle) bool

type CycleConfig

type CycleConfig struct {
	Enabled    bool   `mapstructure:"enabled" yaml:"enabled"`
	Duration   string `mapstructure:"duration" yaml:"duration"`
	StartDay   string `mapstructure:"start_day" yaml:"start_day"`
	AnchorDate string `mapstructure:"anchor_date" yaml:"anchor_date"`
}

func (CycleConfig) CurrentCycle

func (cfg CycleConfig) CurrentCycle() Cycle

func (CycleConfig) CycleForDate

func (cfg CycleConfig) CycleForDate(date time.Time) Cycle

func (CycleConfig) CycleForID

func (cfg CycleConfig) CycleForID(id string) (Cycle, error)

func (CycleConfig) DurationDays

func (cfg CycleConfig) DurationDays() int

func (CycleConfig) EnumerateCycles

func (cfg CycleConfig) EnumerateCycles(now time.Time, pastCount, futureCount int) []Cycle

func (CycleConfig) IsPastCycle

func (cfg CycleConfig) IsPastCycle(cycleID string, now time.Time) bool

func (CycleConfig) Validate

func (cfg CycleConfig) Validate() error

type DriveAgentConfig added in v1.0.2

type DriveAgentConfig struct {
	Agent string `mapstructure:"agent" yaml:"agent"`
	Model string `mapstructure:"model" yaml:"model,omitempty"`
}

type DriveConfig

type DriveConfig struct {
	Supervisor DriveAgentConfig `mapstructure:"supervisor" yaml:"supervisor"`
	Coder      DriveAgentConfig `mapstructure:"coder" yaml:"coder"`
	MaxRetries int              `mapstructure:"max_retries" yaml:"max_retries"`
	TestCmd    string           `mapstructure:"test_cmd" yaml:"test_cmd"`
	Timeout    string           `mapstructure:"timeout" yaml:"timeout"`
}

type PermissionsConfig

type PermissionsConfig struct {
	Roles map[string][]string `mapstructure:"roles" yaml:"roles,omitempty"`
	Users map[string]string   `mapstructure:"users" yaml:"users,omitempty"`
}

func (PermissionsConfig) Capabilities

func (p PermissionsConfig) Capabilities(role string) []string

Capabilities returns the capability list for a role name, expanding the wildcard "*" into all known capabilities.

func (PermissionsConfig) Enabled

func (p PermissionsConfig) Enabled() bool

Enabled reports whether a permissions section is configured.

func (PermissionsConfig) HasCapability

func (p PermissionsConfig) HasCapability(email, capability string) bool

HasCapability reports whether the given email is allowed to perform the named capability. Returns true when no permissions are configured (open-access default) or when the user's role includes the capability or the wildcard.

func (PermissionsConfig) RoleFor

func (p PermissionsConfig) RoleFor(email string) string

RoleFor returns the role name for the given email. Returns "" if no permissions are configured or the user has no explicit mapping.

type ProjectState

type ProjectState struct {
	LastRead string `yaml:"last_read,omitempty"`
}

ProjectState holds per-user state for a local project, keyed by the absolute path to its .xpo directory. Read state is always per-user and never shared in .xpo/, even in local mode.

type RemoteConfig

type RemoteConfig struct {
	URL   string `mapstructure:"url" yaml:"url"`
	Token string `mapstructure:"token" yaml:"token"`
}

func ResolveRemote

func ResolveRemote(rc RemoteConfig) RemoteConfig

ResolveRemote fills in the token for a RemoteConfig by looking up the server URL in the user's credential store.

type ServerCredential

type ServerCredential struct {
	URL      string `yaml:"url"`
	Token    string `yaml:"token"`
	LastRead string `yaml:"last_read,omitempty"`
}

ServerCredential holds auth info and per-user state for a single server.

func GetServerCredential

func GetServerCredential(serverURL string) (ServerCredential, bool)

GetServerCredential retrieves the token for a server URL.

type Style

type Style struct {
	Theme string `mapstructure:"theme" yaml:"theme"`
}

type UserConfig

type UserConfig struct {
	Servers  map[string]ServerCredential `yaml:"servers"`
	Projects map[string]ProjectState     `yaml:"projects,omitempty"`
}

UserConfig stores all per-user state. Server credentials and the distributed-mode inbox cursor live under Servers (keyed by host); the local-mode inbox cursor lives under Projects (keyed by absolute .xpo path). It is the single file for per-user concerns.

func LoadUserConfig

func LoadUserConfig() UserConfig

LoadUserConfig reads all stored per-user state.

Jump to

Keyboard shortcuts

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