Documentation
¶
Index ¶
- func ArchiveDir() string
- func BuiltInLabels() map[string]LabelConfig
- func ConfigPath() (string, error)
- func EnsureRepoHooksTrusted(repoPath string) error
- func ExpandPath(path string) string
- func ExperimentKey(repo, name string) string
- func GetWorktreePath(cfg *Config, repoName string, wt *Worktree) string
- func HashFile(path string) (string, error)
- func LegacyStatePath(cfg *Config) string
- func SetTestStateDir(dir string)
- func StatePath() string
- func TrustRegistryPath() (string, error)
- func WorktreePath(cfg *Config, repoName, name string) string
- type Config
- func (c *Config) ExperimentsDir() string
- func (c *Config) GetBaseDir() string
- func (c *Config) GetLabelConfig(label string) (LabelConfig, bool)
- func (c *Config) GetRepoCopyFiles(repoPath string) []string
- func (c *Config) ProjectsDir() string
- func (c *Config) ReposDir() string
- func (c *Config) Save() error
- func (c *Config) ScratchDir() string
- func (c *Config) SetRepoCopyFiles(repoPath string, files []string)
- type Experiment
- type LabelConfig
- type Project
- type ProjectRepo
- type RepoSettings
- type Scratch
- type State
- func (s *State) AddExperiment(exp *Experiment)
- func (s *State) AddScratch(scratch *Scratch)
- func (s *State) AddWorktree(repoName string, wt *Worktree)
- func (s *State) FindExperimentByName(name string) *Experiment
- func (s *State) FindWorktreeByName(name string) (string, *Worktree)
- func (s *State) GetExperiment(key string) *Experiment
- func (s *State) GetScratch(name string) *Scratch
- func (s *State) GetWorktree(repoName, name string) *Worktree
- func (s *State) RemoveExperiment(key string)
- func (s *State) RemoveScratch(name string)
- func (s *State) RemoveWorktree(repoName, name string)
- func (s *State) Save(cfg *Config) error
- type TrustEntry
- type TrustRegistry
- type Worktree
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ArchiveDir ¶
func ArchiveDir() string
ArchiveDir returns the path to the session archive directory Archives are stored in ~/.config/clade/archive/ to persist across base_dir changes
func BuiltInLabels ¶
func BuiltInLabels() map[string]LabelConfig
BuiltInLabels returns the built-in label configurations
func ConfigPath ¶
ConfigPath returns the path to the config file Always uses ~/.config/clade/ for consistency across platforms
func EnsureRepoHooksTrusted ¶
EnsureRepoHooksTrusted checks if repo hooks are trusted, prompting if not Returns error if user declines or an error occurs
Set CLADE_TRUST_REPO_HOOKS=1 (or legacy PACER_TRUST_REPO_HOOKS=1) to auto-trust all repo hooks (for testing/CI).
func ExperimentKey ¶
ExperimentKey generates a unique key for an experiment (v1 format)
func GetWorktreePath ¶
GetWorktreePath returns the actual path for a worktree, using custom Path if set
func LegacyStatePath ¶
LegacyStatePath returns the old state file location (in base_dir) Used for auto-migration from v2 to v3
func SetTestStateDir ¶
func SetTestStateDir(dir string)
SetTestStateDir sets a custom state directory for testing Pass empty string to reset to default behavior
func StatePath ¶
func StatePath() string
StatePath returns the path to the state file State is stored in ~/.config/clade/ alongside other metadata
func TrustRegistryPath ¶
TrustRegistryPath returns the path to the trust registry file
func WorktreePath ¶
WorktreePath returns the path for a worktree given config and repo name
Types ¶
type Config ¶
type Config struct {
BaseDir string `json:"base_dir"`
Agent string `json:"agent"`
AgentFlags []string `json:"agent_flags"`
Editor string `json:"editor,omitempty"`
AutoInit bool `json:"auto_init"`
Repos map[string]string `json:"repos"`
RepoSettings map[string]RepoSettings `json:"repo_settings,omitempty"`
LastRepo string `json:"last_repo"`
TmuxSplitDirection string `json:"tmux_split_direction,omitempty"`
CustomLabels map[string]LabelConfig `json:"custom_labels,omitempty"`
CopyFiles []string `json:"copy_files,omitempty"` // Additional files to copy to worktrees (beyond defaults)
}
Config holds the user configuration for clade
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig returns a config with default values
func (*Config) ExperimentsDir ¶
ExperimentsDir returns the path to experiments directory (legacy v0.2 structure) Deprecated: Use ReposDir() for new worktrees
func (*Config) GetBaseDir ¶
GetBaseDir returns the expanded base directory
func (*Config) GetLabelConfig ¶
func (c *Config) GetLabelConfig(label string) (LabelConfig, bool)
GetLabelConfig returns the configuration for a label (built-in or custom)
func (*Config) GetRepoCopyFiles ¶
GetRepoCopyFiles returns the copy_files setting for a repo
func (*Config) ProjectsDir ¶
ProjectsDir returns the path to projects directory
func (*Config) ReposDir ¶
ReposDir returns the path to repos directory (v0.3+ repo-centric structure)
func (*Config) ScratchDir ¶
ScratchDir returns the path to scratch directory
func (*Config) SetRepoCopyFiles ¶
SetRepoCopyFiles saves the copy_files setting for a repo
type Experiment ¶
type Experiment struct {
Name string `json:"name"`
Repo string `json:"repo"`
Path string `json:"path"`
Branch string `json:"branch"`
Ticket string `json:"ticket,omitempty"`
Created time.Time `json:"created"`
LastUsed time.Time `json:"last_used"`
}
Experiment represents a tracked experiment (v1 format, deprecated) Kept for backward compatibility during migration
type LabelConfig ¶
type LabelConfig struct {
BranchPrefix string `json:"branch_prefix"`
MergeExpected bool `json:"merge_expected"`
}
LabelConfig defines a custom label configuration
type Project ¶
type Project struct {
Name string `json:"name"`
Path string `json:"path"`
Branch string `json:"branch"`
Repos []ProjectRepo `json:"repos"`
Created time.Time `json:"created"`
LastUsed time.Time `json:"last_used"`
}
Project represents a tracked multi-repo project
type ProjectRepo ¶
ProjectRepo represents a repo within a project
type RepoSettings ¶
type RepoSettings struct {
CopyFiles []string `json:"copy_files,omitempty"`
}
RepoSettings holds per-repo configuration
type Scratch ¶
type Scratch struct {
Name string `json:"name"`
Path string `json:"path"`
Ticket string `json:"ticket,omitempty"`
Created time.Time `json:"created"`
LastUsed time.Time `json:"last_used"`
}
Scratch represents a no-git scratch folder
type State ¶
type State struct {
Version int `json:"version"`
// v2 format: nested worktrees by repo name
// map[repoName]map[worktreeName]*Worktree
Worktrees map[string]map[string]*Worktree `json:"worktrees,omitempty"`
// v1 format (deprecated): flat experiments map
// Kept for backward compatibility during migration
Experiments map[string]*Experiment `json:"experiments,omitempty"`
Projects map[string]*Project `json:"projects"`
Scratches map[string]*Scratch `json:"scratches,omitempty"`
}
State holds the runtime state of clade
func LoadState ¶
LoadState reads the state from disk Automatically migrates from legacy location if needed
func (*State) AddExperiment ¶
func (s *State) AddExperiment(exp *Experiment)
AddExperiment adds or updates an experiment in state (v1 format, deprecated)
func (*State) AddScratch ¶
AddScratch adds or updates a scratch in state
func (*State) AddWorktree ¶
AddWorktree adds or updates a worktree in v2 state
func (*State) FindExperimentByName ¶
func (s *State) FindExperimentByName(name string) *Experiment
FindExperimentByName searches for an experiment by name in v1 format Returns the experiment or nil if not found
func (*State) FindWorktreeByName ¶
FindWorktreeByName searches for a worktree by name across all repos Returns (repoName, worktree) or ("", nil) if not found
func (*State) GetExperiment ¶
func (s *State) GetExperiment(key string) *Experiment
GetExperiment retrieves an experiment by key (v1 format)
func (*State) GetScratch ¶
GetScratch retrieves a scratch by name
func (*State) GetWorktree ¶
GetWorktree retrieves a worktree by repo name and worktree name
func (*State) RemoveExperiment ¶
RemoveExperiment removes an experiment from state (v1 format)
func (*State) RemoveScratch ¶
RemoveScratch removes a scratch from state
func (*State) RemoveWorktree ¶
RemoveWorktree removes a worktree from v2 state
type TrustEntry ¶
type TrustEntry struct {
Hash string `json:"hash"` // SHA-256 hash of hooks.yaml content
TrustedAt time.Time `json:"trusted_at"` // When the user approved
}
TrustEntry represents a trusted repo's hook configuration
type TrustRegistry ¶
type TrustRegistry struct {
Repos map[string]TrustEntry `json:"repos"` // repo path -> trust entry
}
TrustRegistry holds trust information for repos with hooks
func LoadTrustRegistry ¶
func LoadTrustRegistry() (*TrustRegistry, error)
LoadTrustRegistry loads the trust registry from disk
func (*TrustRegistry) IsTrusted ¶
func (t *TrustRegistry) IsTrusted(repoPath, hooksPath string) (bool, error)
IsTrusted checks if a repo's hooks are trusted and unchanged
func (*TrustRegistry) Revoke ¶
func (t *TrustRegistry) Revoke(repoPath string) error
Revoke removes trust for a repo
func (*TrustRegistry) Save ¶
func (t *TrustRegistry) Save() error
Save writes the trust registry to disk
func (*TrustRegistry) Trust ¶
func (t *TrustRegistry) Trust(repoPath, hooksPath string) error
Trust marks a repo's hooks as trusted
type Worktree ¶
type Worktree struct {
Name string `json:"name"`
Label string `json:"label"` // feature, bug, spike, chore, hotfix, docs, or custom
Branch string `json:"branch"`
Path string `json:"path,omitempty"` // Actual path if not in ~/clade/repos/ (for adopted worktrees)
Ticket string `json:"ticket,omitempty"`
Created time.Time `json:"created"`
LastUsed time.Time `json:"last_used"`
}
Worktree represents a tracked worktree (v2 format)