Documentation
¶
Overview ¶
Package config handles configuration loading and validation for hive.
Index ¶
- Constants
- Variables
- func DefaultUserCommands() map[string]UserCommand
- func ParseExitCondition(s string) bool
- type AgentProfile
- type AgentsConfig
- type BatchSpawnTemplateData
- type BeadsPluginConfig
- type ClaudePluginConfig
- type Config
- func (c *Config) BinDir() string
- func (c *Config) ContextDir() string
- func (c *Config) DatabaseFile() string
- func (c *Config) GetMaxRecycled(remote string) int
- func (c *Config) GetRecycleCommands(remote string) []string
- func (c *Config) HistoryFile() string
- func (c *Config) LogsDir() string
- func (c *Config) MergedUserCommands() map[string]UserCommand
- func (c *Config) RepoContextDir(owner, repo string) string
- func (c *Config) ReposDir() string
- func (c *Config) SessionsFile() string
- func (c *Config) SharedContextDir() string
- func (c *Config) Validate() error
- func (c *Config) ValidateDeep(configPath string) error
- func (c *Config) Warnings() []ValidationWarning
- type ContextConfig
- type ContextDirPluginConfig
- type DatabaseConfig
- type FormField
- type GitConfig
- type GitHubPluginConfig
- type HistoryConfig
- type Keybinding
- type LazyGitPluginConfig
- type MessagingConfig
- type NeovimPluginConfig
- type PluginsConfig
- type PreviewConfig
- type RecycleTemplateData
- type ReviewConfig
- type Rule
- type SpawnStrategy
- type SpawnTemplateData
- type TUIConfig
- type TmuxConfig
- type TmuxPluginConfig
- type UserCommand
- type UserCommandOptions
- type ValidationWarning
- type ViewsConfig
- type WindowConfig
Constants ¶
const ( FormTypeText = "text" FormTypeTextArea = "textarea" FormTypeSelect = "select" FormTypeMultiSelect = "multi-select" )
Form field type constants.
const ( FormPresetSessionSelector = "SessionSelector" FormPresetProjectSelector = "ProjectSelector" )
Form preset constants.
const ( FormFilterActive = "active" // Only active sessions (default) FormFilterAll = "all" // All sessions regardless of state )
Form filter constants for SessionSelector preset.
const CurrentConfigVersion = "0.2.5"
CurrentConfigVersion is the latest config schema version. Increment this when making breaking changes to config format.
const DefaultMaxRecycled = 5
DefaultMaxRecycled is the default limit for recycled sessions per repository.
Variables ¶
var DefaultRecycleCommands = []string{
"git fetch origin",
"git checkout -f {{ .DefaultBranch }}",
"git reset --hard origin/{{ .DefaultBranch }}",
"git clean -fd",
}
DefaultRecycleCommands are the default commands run when recycling a session.
var ValidFormPresets = []string{FormPresetSessionSelector, FormPresetProjectSelector}
ValidFormPresets lists all valid form field presets.
var ValidFormTypes = []string{FormTypeText, FormTypeTextArea, FormTypeSelect, FormTypeMultiSelect}
ValidFormTypes lists all valid form field types.
var ValidSessionFilters = []string{FormFilterActive, FormFilterAll}
ValidSessionFilters lists valid filter values for SessionSelector.
Functions ¶
func DefaultUserCommands ¶
func DefaultUserCommands() map[string]UserCommand
DefaultUserCommands returns the built-in system commands. Used by plugin manager to properly merge system → plugin → user commands.
func ParseExitCondition ¶
ParseExitCondition evaluates an exit condition string. If the string starts with $, it checks the env var value. Otherwise it parses the string directly as a boolean. Returns false if parsing fails or env var is unset.
Types ¶
type AgentProfile ¶
type AgentProfile struct {
Command string `yaml:"command"` // CLI binary (defaults to profile key if omitted)
Flags []string `yaml:"flags"` // extra CLI args appended to command on spawn
}
AgentProfile defines an agent's command and flags.
func (AgentProfile) CommandOrDefault ¶
func (p AgentProfile) CommandOrDefault(key string) string
CommandOrDefault returns the command, falling back to the given key name.
func (AgentProfile) ShellFlags ¶
func (p AgentProfile) ShellFlags() string
ShellFlags returns the flags as a space-joined string. Individual flags are NOT quoted — the caller is responsible for quoting the entire value (e.g., via shq in templates) or relying on shell word splitting when consuming the value.
type AgentsConfig ¶
type AgentsConfig struct {
Default string // reserved key selecting the active profile
Profiles map[string]AgentProfile // profile name → agent configuration
}
AgentsConfig holds agent profile configuration. The "default" key selects which profile to use; all other keys are profile definitions.
func (AgentsConfig) DefaultProfile ¶
func (a AgentsConfig) DefaultProfile() AgentProfile
DefaultProfile returns the profile selected by the Default key. Returns a zero AgentProfile if the default is not found.
func (*AgentsConfig) UnmarshalYAML ¶
func (a *AgentsConfig) UnmarshalYAML(node *yaml.Node) error
UnmarshalYAML separates the "default" key from profile entries.
type BatchSpawnTemplateData ¶
type BatchSpawnTemplateData struct {
Path string // Absolute path to the session directory
Name string // Session name (directory basename)
Prompt string // User-provided prompt (batch only)
Slug string // Session slug (URL-safe version of name)
ContextDir string // Path to context directory
Owner string // Repository owner
Repo string // Repository name
}
BatchSpawnTemplateData defines available fields for batch_spawn command templates (hive batch).
type BeadsPluginConfig ¶
type BeadsPluginConfig struct {
Enabled *bool `yaml:"enabled"` // nil = auto-detect, true/false = override
ResultsCache time.Duration `yaml:"results_cache"` // status cache duration (default: 30s)
}
BeadsPluginConfig holds Beads plugin configuration.
type ClaudePluginConfig ¶
type ClaudePluginConfig struct {
Enabled *bool `yaml:"enabled"` // nil = auto-detect, true/false = override
CacheTTL time.Duration `yaml:"cache_ttl"` // status cache duration (default: 30s)
YellowThreshold int `yaml:"yellow_threshold"` // yellow above this % (default: 60)
RedThreshold int `yaml:"red_threshold"` // red above this % (default: 80)
ModelLimit int `yaml:"model_limit"` // context limit (default: 200000)
}
ClaudePluginConfig holds Claude Code plugin configuration.
type Config ¶
type Config struct {
Version string `yaml:"version"`
CopyCommand string `yaml:"copy_command"` // command to copy to clipboard (e.g., pbcopy, xclip)
Git GitConfig `yaml:"git"`
GitPath string `yaml:"git_path"`
Keybindings map[string]Keybinding `yaml:"keybindings"`
UserCommands map[string]UserCommand `yaml:"usercommands"`
Rules []Rule `yaml:"rules"`
Agents AgentsConfig `yaml:"agents"`
AutoDeleteCorrupted bool `yaml:"auto_delete_corrupted"`
History HistoryConfig `yaml:"history"`
Context ContextConfig `yaml:"context"`
TUI TUIConfig `yaml:"tui"`
Review ReviewConfig `yaml:"review"`
Messaging MessagingConfig `yaml:"messaging"`
Tmux TmuxConfig `yaml:"tmux"`
Database DatabaseConfig `yaml:"database"`
Plugins PluginsConfig `yaml:"plugins"`
RepoDirs []string `yaml:"repo_dirs"` // directories containing git repositories for new session dialog
DataDir string `yaml:"-"` // set by caller, not from config file
}
Config holds the application configuration.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns a Config with sensible defaults.
func Load ¶
Load reads configuration from the given path and sets the data directory. If configPath is empty or doesn't exist, returns defaults with the provided dataDir.
func (*Config) ContextDir ¶
ContextDir returns the base context directory path.
func (*Config) DatabaseFile ¶
DatabaseFile returns the path to the SQLite database file.
func (*Config) GetMaxRecycled ¶
GetMaxRecycled returns the max recycled sessions limit for the given remote URL. Returns DefaultMaxRecycled (5) if no limit is configured. Returns 0 for unlimited.
func (*Config) GetRecycleCommands ¶
GetRecycleCommands returns the recycle commands for the given remote URL. Rules are evaluated in order; the last matching rule with recycle commands wins. If no rules define recycle commands, returns DefaultRecycleCommands.
func (*Config) HistoryFile ¶
HistoryFile returns the path to the command history JSON file.
func (*Config) MergedUserCommands ¶
func (c *Config) MergedUserCommands() map[string]UserCommand
MergedUserCommands returns user commands merged with system defaults. System defaults (Recycle, Delete) can be overridden by user config.
func (*Config) RepoContextDir ¶
RepoContextDir returns the context directory for a specific owner/repo.
func (*Config) SessionsFile ¶
SessionsFile returns the path to the sessions JSON file.
func (*Config) SharedContextDir ¶
SharedContextDir returns the shared context directory.
func (*Config) ValidateDeep ¶
ValidateDeep performs comprehensive validation of the configuration including template syntax, regex patterns, and file accessibility. The configPath argument specifies the config file location to validate (empty string skips config file check). This calls Validate() first for basic structural validation, then adds I/O checks.
func (*Config) Warnings ¶
func (c *Config) Warnings() []ValidationWarning
Warnings returns non-fatal configuration issues.
type ContextConfig ¶
type ContextConfig struct {
SymlinkName string `yaml:"symlink_name"` // default: ".hive"
}
ContextConfig configures context directory behavior.
type ContextDirPluginConfig ¶
type ContextDirPluginConfig struct {
Enabled *bool `yaml:"enabled"` // nil = auto-detect, true/false = override
}
ContextDirPluginConfig holds context directory plugin configuration.
type DatabaseConfig ¶
type DatabaseConfig struct {
MaxOpenConns int `yaml:"max_open_conns"` // max open connections (default: 2)
MaxIdleConns int `yaml:"max_idle_conns"` // max idle connections (default: 2)
BusyTimeout int `yaml:"busy_timeout"` // busy timeout in milliseconds (default: 5000)
}
DatabaseConfig holds SQLite database configuration.
type FormField ¶
type FormField struct {
Variable string `yaml:"variable"` // Template variable name (under .Form)
Type string `yaml:"type,omitempty"` // text, textarea, select, multi-select
Preset string `yaml:"preset,omitempty"` // SessionSelector, ProjectSelector
Label string `yaml:"label"` // Display label
Placeholder string `yaml:"placeholder,omitempty"` // Input placeholder text
Default string `yaml:"default,omitempty"` // Default value (text/textarea/select)
Options []string `yaml:"options,omitempty"` // Static options for select/multi-select
Multi bool `yaml:"multi,omitempty"` // For presets: enable multi-select
Filter string `yaml:"filter,omitempty"` // For SessionSelector: "active" (default) or "all"
}
FormField defines an input field in a UserCommand form.
type GitConfig ¶
type GitConfig struct {
StatusWorkers int `yaml:"status_workers"`
}
GitConfig holds git-related configuration.
type GitHubPluginConfig ¶
type GitHubPluginConfig struct {
Enabled *bool `yaml:"enabled"` // nil = auto-detect, true/false = override
ResultsCache time.Duration `yaml:"results_cache"` // status cache duration (default: 8m)
}
GitHubPluginConfig holds GitHub plugin configuration.
type HistoryConfig ¶
type HistoryConfig struct {
MaxEntries int `yaml:"max_entries"`
}
HistoryConfig holds command history configuration.
type Keybinding ¶
type Keybinding struct {
Cmd string `yaml:"cmd"` // command name (required, references UserCommand)
Help string `yaml:"help"` // optional override for help text
Confirm string `yaml:"confirm"` // optional override for confirmation prompt
}
Keybinding defines a TUI keybinding that references a UserCommand.
type LazyGitPluginConfig ¶
type LazyGitPluginConfig struct {
Enabled *bool `yaml:"enabled"` // nil = auto-detect, true/false = override
}
LazyGitPluginConfig holds lazygit plugin configuration.
type MessagingConfig ¶
type MessagingConfig struct {
TopicPrefix string `yaml:"topic_prefix"` // default: "agent"
MaxMessages int `yaml:"max_messages"` // max messages per topic (default: 100, 0 = unlimited)
}
MessagingConfig holds messaging-related configuration.
type NeovimPluginConfig ¶
type NeovimPluginConfig struct {
Enabled *bool `yaml:"enabled"` // nil = auto-detect, true/false = override
}
NeovimPluginConfig holds neovim plugin configuration.
type PluginsConfig ¶
type PluginsConfig struct {
ShellWorkers int `yaml:"shell_workers"` // shared subprocess pool size (default: 5)
GitHub GitHubPluginConfig `yaml:"github"`
Beads BeadsPluginConfig `yaml:"beads"`
LazyGit LazyGitPluginConfig `yaml:"lazygit"`
Neovim NeovimPluginConfig `yaml:"neovim"`
ContextDir ContextDirPluginConfig `yaml:"contextdir"`
Claude ClaudePluginConfig `yaml:"claude"`
Tmux TmuxPluginConfig `yaml:"tmux"`
}
PluginsConfig holds configuration for the plugin system.
type PreviewConfig ¶
type PreviewConfig struct {
TitleTemplate string `yaml:"title_template"` // Go template for panel title (e.g., "{{ .Name }} • #{{ .ShortID }}")
StatusTemplate string `yaml:"status_template"` // Go template for status line (e.g., "{{ .Icon.GitBranch }} {{ .Branch }}")
}
PreviewConfig holds preview panel template configuration.
type RecycleTemplateData ¶
type RecycleTemplateData struct {
DefaultBranch string // Default branch name (e.g., "main" or "master")
}
RecycleTemplateData defines available fields for recycle command templates.
type ReviewConfig ¶
type ReviewConfig struct {
CommentLineWidth int `yaml:"comment_line_width"` // minimum width for comment wrapping (default: 80)
}
ReviewConfig holds review-related configuration.
func (ReviewConfig) CommentLineWidthOrDefault ¶
func (r ReviewConfig) CommentLineWidthOrDefault() int
CommentLineWidthOrDefault returns the configured comment line width or 80 if not set.
type Rule ¶
type Rule struct {
// Pattern matches against remote URL (regex). Empty = matches all.
Pattern string `yaml:"pattern"`
// Commands to run in the session directory after clone/recycle.
Commands []string `yaml:"commands,omitempty"`
// Copy are glob patterns to copy from source directory.
Copy []string `yaml:"copy,omitempty"`
// MaxRecycled sets the max recycled sessions for matching repos.
// nil = inherit from previous rule or default (5), 0 = unlimited, >0 = limit
MaxRecycled *int `yaml:"max_recycled,omitempty"`
// Windows defines tmux windows to create when spawning a session.
// Mutually exclusive with Spawn/BatchSpawn.
Windows []WindowConfig `yaml:"windows,omitempty"`
// Spawn commands to run when creating a new session (hive new).
Spawn []string `yaml:"spawn,omitempty"`
// BatchSpawn commands to run when creating a batch session (hive batch).
BatchSpawn []string `yaml:"batch_spawn,omitempty"`
// Recycle commands to run when recycling a session.
Recycle []string `yaml:"recycle,omitempty"`
}
Rule defines actions to take for matching repositories.
type SpawnStrategy ¶ added in v0.32.0
type SpawnStrategy struct {
Windows []WindowConfig
Commands []string
}
SpawnStrategy holds the resolved spawn method for a session. Exactly one of Windows or Commands is populated.
func ResolveSpawn ¶ added in v0.32.0
func ResolveSpawn(rules []Rule, remote string, batch bool) SpawnStrategy
ResolveSpawn determines the spawn strategy for the given remote URL. Rules are evaluated in order (last-match-wins). If the last matching rule has windows, those are used. If it has spawn/batch_spawn commands, those are used. If nothing matches, DefaultWindows() is returned.
func (SpawnStrategy) IsWindows ¶ added in v0.32.0
func (s SpawnStrategy) IsWindows() bool
IsWindows returns true if the strategy uses declarative window config.
type SpawnTemplateData ¶
type SpawnTemplateData struct {
Path string // Absolute path to the session directory
Name string // Session name (directory basename)
Slug string // Session slug (URL-safe version of name)
ContextDir string // Path to context directory
Owner string // Repository owner
Repo string // Repository name
}
SpawnTemplateData defines available fields for spawn command templates (hive new).
type TUIConfig ¶
type TUIConfig struct {
Theme string `yaml:"theme"` // built-in theme name (default: "tokyo-night")
RefreshInterval time.Duration `yaml:"refresh_interval"` // default: 15s, 0 to disable
PreviewEnabled bool `yaml:"preview_enabled"` // enable tmux pane preview sidebar
Icons *bool `yaml:"icons"` // enable nerd font icons (nil = true by default)
Preview PreviewConfig `yaml:"preview"` // preview panel configuration
Views ViewsConfig `yaml:"views"` // toggle optional TUI tabs
}
TUIConfig holds TUI-related configuration.
func (TUIConfig) IconsEnabled ¶
IconsEnabled returns true if nerd font icons should be shown.
type TmuxConfig ¶
type TmuxConfig struct {
PollInterval time.Duration `yaml:"poll_interval"` // status check frequency, default 1.5s
PreviewWindowMatcher []string `yaml:"preview_window_matcher"` // regex patterns for preferred window names (e.g., ["claude", "aider"])
}
TmuxConfig holds tmux integration configuration.
type TmuxPluginConfig ¶
type TmuxPluginConfig struct {
Enabled *bool `yaml:"enabled"` // nil = auto-detect, true/false = override
}
TmuxPluginConfig holds tmux plugin configuration.
type UserCommand ¶
type UserCommand struct {
Action action.Type `yaml:"action,omitempty"` // built-in action (Recycle, Delete, etc.) - mutually exclusive with sh
Sh string `yaml:"sh"` // shell command template - mutually exclusive with action
Windows []WindowConfig `yaml:"windows,omitempty"` // Tmux windows to open after sh: completes
Options UserCommandOptions `yaml:"options,omitempty"` // Execution options for window-based commands
Form []FormField `yaml:"form,omitempty"` // interactive input fields collected before sh execution
Help string `yaml:"help"` // description shown in palette/help
Confirm string `yaml:"confirm"` // confirmation prompt (empty = no confirm)
Silent bool `yaml:"silent"` // skip loading popup for fast commands
Exit string `yaml:"exit"` // exit hive after command (bool or $ENV_VAR)
Scope []string `yaml:"scope,omitempty"` // views where command is active (empty = global)
}
UserCommand defines a named command accessible via command palette or keybindings.
func (UserCommand) ShouldExit ¶
func (u UserCommand) ShouldExit() bool
ShouldExit evaluates the Exit condition.
func (*UserCommand) UnmarshalYAML ¶
func (u *UserCommand) UnmarshalYAML(node *yaml.Node) error
UnmarshalYAML supports string shorthand: "cmd" → {sh: "cmd"}
type UserCommandOptions ¶ added in v0.32.0
type UserCommandOptions struct {
// SessionName is a template string. When non-empty, a new Hive session is created
// with this name before sh: runs and windows are opened.
SessionName string `yaml:"session_name,omitempty"`
// Remote overrides the remote URL for new session creation.
// Only valid when SessionName is also set.
Remote string `yaml:"remote,omitempty"`
// Background creates windows without attaching or switching to the tmux session.
Background bool `yaml:"background,omitempty"`
}
UserCommandOptions controls execution behaviour for UserCommands with windows.
type ValidationWarning ¶
type ValidationWarning struct {
Category string `json:"category"`
Item string `json:"item,omitempty"`
Message string `json:"message"`
}
ValidationWarning represents a non-fatal configuration issue.
type ViewsConfig ¶
type ViewsConfig struct {
Store bool `yaml:"store"` // KV store browser (default: false)
}
ViewsConfig controls which optional TUI tabs are enabled. All optional views default to disabled.
type WindowConfig ¶ added in v0.32.0
type WindowConfig struct {
Name string `yaml:"name"` // Window name (template string, required)
Command string `yaml:"command,omitempty"` // Command to run (template string, empty = shell)
Dir string `yaml:"dir,omitempty"` // Working directory override (template string)
Focus bool `yaml:"focus,omitempty"` // Select this window after creation
}
WindowConfig defines a tmux window to create when spawning a session.
func DefaultWindows ¶ added in v0.32.0
func DefaultWindows() []WindowConfig
DefaultWindows returns the default window layout for new sessions. Uses template strings rendered at spawn time from the active agent profile.