config

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2026 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StateFileName     = "state.json"
	InstancesFileName = "instances.json"
)
View Source
const (
	ConfigFileName = "config.json"
)

Variables

This section is empty.

Functions

func AtomicWriteFile added in v0.2.2

func AtomicWriteFile(path string, data []byte, perm os.FileMode) error

AtomicWriteFile writes data to a temporary file and then renames it to the target path. This prevents partial writes from corrupting the file if the process crashes or is interrupted mid-write.

func GetClaudeCommand

func GetClaudeCommand() (string, error)

GetClaudeCommand attempts to find the "claude" command in the user's shell It checks in the following order: 1. Shell alias resolution: using "which" command 2. PATH lookup

If both fail, it returns an error.

func GetConfigDir

func GetConfigDir() (string, error)

GetConfigDir returns the path to the application's configuration directory

func IsWorktreePath added in v0.2.2

func IsWorktreePath(path string) bool

IsWorktreePath checks whether a path is under the hivemind worktrees directory.

func NextRunTime added in v0.2.2

func NextRunTime(schedule string, lastRun time.Time, now time.Time) (time.Time, error)

NextRunTime computes the next run time for a schedule based on the last run time and now.

func ParseSchedule added in v0.2.2

func ParseSchedule(s string) (scheduleSpec, error)

ParseSchedule parses a schedule string and returns its spec. Supported formats: "hourly", "daily", "weekly", "every 30m", "every 4h", "@06:00". Returns an error for unrecognised or invalid strings.

func SaveAutomations added in v0.2.2

func SaveAutomations(automations []*Automation) error

SaveAutomations persists automations to disk atomically.

func SaveConfig

func SaveConfig(config *Config) error

SaveConfig exports the saveConfig function for use by other packages

func SaveState

func SaveState(state *State) error

SaveState saves the state to disk

Types

type AppState

type AppState interface {
	// GetHelpScreensSeen returns the bitmask of seen help screens
	GetHelpScreensSeen() uint32
	// SetHelpScreensSeen updates the bitmask of seen help screens
	SetHelpScreensSeen(seen uint32) error
	// GetOnboarded returns whether the onboarding ritual has been completed.
	GetOnboarded() bool
	// SetOnboarded marks onboarding as complete and persists the state.
	SetOnboarded(onboarded bool) error
}

AppState handles application-level state

type Automation added in v0.2.2

type Automation struct {
	ID           string `json:"id"`
	Name         string `json:"name"`
	Instructions string `json:"instructions"`
	// Program is the agent command used for automation runs (e.g. claude, codex).
	Program string `json:"program,omitempty"`
	// RepoPath is the repository path where this automation should run.
	RepoPath string    `json:"repo_path,omitempty"`
	Schedule string    `json:"schedule"`
	Enabled  bool      `json:"enabled"`
	LastRun  time.Time `json:"last_run,omitempty"`
	NextRun  time.Time `json:"next_run"`
}

Automation represents a scheduled agent task.

func LoadAutomations added in v0.2.2

func LoadAutomations() ([]*Automation, error)

LoadAutomations loads automations from disk. Returns an empty slice (not an error) when the file does not exist yet.

func NewAutomation added in v0.2.2

func NewAutomation(name, instructions, schedule, program, repoPath string) (*Automation, error)

NewAutomation creates a new Automation with a generated ID and a computed NextRun.

type Config

type Config struct {
	// DefaultProgram is the default program to run in new instances
	DefaultProgram string `json:"default_program"`
	// AutoYes is a flag to automatically accept all prompts.
	AutoYes bool `json:"auto_yes"`
	// DaemonPollInterval is the interval (ms) at which the daemon polls sessions for autoyes mode.
	DaemonPollInterval int `json:"daemon_poll_interval"`
	// BranchPrefix is the prefix used for git branches created by the application.
	BranchPrefix string `json:"branch_prefix"`
	// NotificationsEnabled controls whether macOS/Linux desktop notifications
	// are sent when an agent finishes (Running -> Ready).
	NotificationsEnabled *bool `json:"notifications_enabled,omitempty"`
	// SkipGitHooks controls whether --no-verify is passed to git commit.
	// Defaults to true (skip hooks) for reliability — pre-commit hooks can
	// block pause/resume. Set to false if your repo has mandatory hooks
	// (e.g. secret scanning).
	SkipGitHooks *bool `json:"skip_git_hooks,omitempty"`
	// Memory configures the IDE-wide memory system.
	Memory *MemoryConfig `json:"memory,omitempty"`
}

Config represents the application configuration

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns the default configuration

func LoadConfig

func LoadConfig() *Config

func (*Config) AreNotificationsEnabled

func (c *Config) AreNotificationsEnabled() bool

AreNotificationsEnabled returns whether desktop notifications are enabled. Defaults to true when the field is not set.

func (*Config) ShouldSkipGitHooks added in v0.2.1

func (c *Config) ShouldSkipGitHooks() bool

ShouldSkipGitHooks returns whether --no-verify should be passed to git commit. Defaults to true when the field is not set.

type InstanceStorage

type InstanceStorage interface {
	// SaveInstances saves the raw instance data
	SaveInstances(instancesJSON json.RawMessage) error
	// GetInstances returns the raw instance data
	GetInstances() json.RawMessage
	// DeleteAllInstances removes all stored instances
	DeleteAllInstances() error
}

InstanceStorage handles instance-related operations

type MemoryConfig added in v0.2.2

type MemoryConfig struct {
	// Enabled turns the memory system on/off. Default false until configured.
	Enabled bool `json:"enabled"`
	// EmbeddingProvider selects the embedding backend: "openai", "ollama", or "none".
	// When "none" or unset, memory search falls back to keyword-only (FTS).
	EmbeddingProvider string `json:"embedding_provider,omitempty"`
	// OpenAIAPIKey is the API key for OpenAI embeddings.
	OpenAIAPIKey string `json:"openai_api_key,omitempty"`
	// OpenAIModel is the embedding model name. Default "text-embedding-3-small".
	OpenAIModel string `json:"openai_model,omitempty"`
	// OllamaURL is the Ollama server URL. Default "http://localhost:11434".
	OllamaURL string `json:"ollama_url,omitempty"`
	// OllamaModel is the Ollama model name. Default "nomic-embed-text".
	OllamaModel string `json:"ollama_model,omitempty"`
	// ClaudeModel is the model used for re-ranking with the "claude" provider.
	// Defaults to "claude-haiku-4-5-20251001" — works with both API key and Max subscription.
	ClaudeModel string `json:"claude_model,omitempty"`
	// StartupInjectCount controls how many memory snippets are injected into
	// CLAUDE.md when starting an agent. Default 5.
	StartupInjectCount int `json:"startup_inject_count,omitempty"`
	// GitEnabled controls whether memory changes are git-versioned.
	// Default true. Set to false to disable auto-commits in the memory directory.
	GitEnabled *bool `json:"git_enabled,omitempty"`
	// SystemBudgetChars is the max characters of system/ file content injected
	// into CLAUDE.md at startup. Default 4000.
	SystemBudgetChars int `json:"system_budget_chars,omitempty"`
}

MemoryConfig configures the IDE-wide memory system.

type Skill added in v0.2.2

type Skill struct {
	Name         string   // display name
	Description  string   // short description shown in picker
	ContextFiles []string // absolute or ~-relative paths to include as context
	SetupScript  string   // shell command to run before agent starts
	Instructions string   // the markdown body — prepended to the agent prompt
	SourceFile   string   // path to the .md file (for display)
}

Skill represents a reusable task template stored in ~/.hivemind/skills/.

func LoadSkills added in v0.2.2

func LoadSkills() ([]Skill, error)

LoadSkills loads all skills from ~/.hivemind/skills/.

func LoadSkillsFrom added in v0.2.2

func LoadSkillsFrom(dir string) ([]Skill, error)

LoadSkillsFrom loads all *.md skill files from the given directory. Files with malformed frontmatter are skipped with a warning log.

type State

type State struct {
	// HelpScreensSeen is a bitmask tracking which help screens have been shown
	HelpScreensSeen uint32 `json:"help_screens_seen"`
	// Instances stores the serialized instance data as raw JSON
	InstancesData json.RawMessage `json:"instances"`
	// TopicsData stores the serialized topic data as raw JSON
	TopicsData json.RawMessage `json:"topics,omitempty"`
	// RecentRepos stores recently opened repo paths so they persist in the picker
	RecentRepos []string `json:"recent_repos,omitempty"`
	// Onboarded indicates the companion bootstrap ritual has been completed.
	Onboarded bool `json:"onboarded,omitempty"`
}

State represents the application state that persists between sessions

func DefaultState

func DefaultState() *State

DefaultState returns the default state

func LoadState

func LoadState() *State

LoadState loads the state from disk. If it cannot be done, we return the default state.

func (*State) AddRecentRepo

func (s *State) AddRecentRepo(path string) error

AddRecentRepo adds a repo path to the recent list if not already present. Worktree paths are silently rejected.

func (*State) CleanRecentRepos added in v0.2.2

func (s *State) CleanRecentRepos() error

CleanRecentRepos removes worktree paths from the recent repos list.

func (*State) DeleteAllInstances

func (s *State) DeleteAllInstances() error

DeleteAllInstances removes all stored instances

func (*State) GetHelpScreensSeen

func (s *State) GetHelpScreensSeen() uint32

GetHelpScreensSeen returns the bitmask of seen help screens

func (*State) GetInstances

func (s *State) GetInstances() json.RawMessage

GetInstances returns the raw instance data

func (*State) GetOnboarded added in v0.2.2

func (s *State) GetOnboarded() bool

GetOnboarded returns whether the onboarding ritual has been completed.

func (*State) GetRecentRepos

func (s *State) GetRecentRepos() []string

GetRecentRepos returns the list of recently opened repo paths.

func (*State) GetTopics

func (s *State) GetTopics() json.RawMessage

GetTopics returns the raw topic data

func (*State) SaveInstances

func (s *State) SaveInstances(instancesJSON json.RawMessage) error

SaveInstances saves the raw instance data

func (*State) SaveTopics

func (s *State) SaveTopics(topicsJSON json.RawMessage) error

SaveTopics saves the raw topic data

func (*State) SetHelpScreensSeen

func (s *State) SetHelpScreensSeen(seen uint32) error

SetHelpScreensSeen updates the bitmask of seen help screens

func (*State) SetOnboarded added in v0.2.2

func (s *State) SetOnboarded(onboarded bool) error

SetOnboarded marks onboarding as complete and persists the state.

type StateManager

type StateManager interface {
	InstanceStorage
	TopicStorage
	AppState
}

StateManager combines instance storage, topic storage, and app state management

type TopicStorage

type TopicStorage interface {
	SaveTopics(topicsJSON json.RawMessage) error
	GetTopics() json.RawMessage
}

TopicStorage handles topic-related operations

Jump to

Keyboard shortcuts

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