config

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const ConfigKey = "devgeta-config-context"

Variables

This section is empty.

Functions

func CanonicalRepoPath

func CanonicalRepoPath(path string) string

CanonicalRepoPath normalizes a repo path to one canonical string form so the same repo is never tracked under multiple representations: expand a leading "~", make it absolute, clean it, then best-effort resolve symlinks (falling back to the cleaned absolute path when a path doesn't exist yet or symlink resolution otherwise fails). Every source that feeds the repo-candidates provider (recent-repos store, cursor repo, zoxide results) must canonicalize through this same function to dedupe correctly.

func WithConfig

func WithConfig(ctx context.Context, config ContextConfig) context.Context

Function to store the config in context

Types

type AlreadyInstalledConfig

type AlreadyInstalledConfig struct {
	Packages      []string `yaml:"packages"`
	DesktopApps   []string `yaml:"desktop_apps"`
	Fonts         []string `yaml:"fonts"`
	Themes        []string `yaml:"themes"`
	TerminalTools []string `yaml:"terminal_tools"`
	DevLanguages  []string `yaml:"dev_languages"`
	Databases     []string `yaml:"databases"`
}

Used to store config that user already had installed before using this app

type ContextConfig

type ContextConfig struct {
	SelectedLanguages   []string
	SelectedDbs         []string
	SelectedDesktopApps []string
}

func GetConfig

func GetConfig(ctx context.Context) (ContextConfig, bool)

Function to retrieve the config from context

type FailedInstallation

type FailedInstallation struct {
	PackageName  string    `yaml:"package_name"`
	Category     string    `yaml:"category"` // "package" | "dev_language" | "database"
	ErrorMessage string    `yaml:"error_message"`
	FailedAt     time.Time `yaml:"failed_at"`
	AttemptCount int       `yaml:"attempt_count"`
}

FailedInstallation tracks packages that failed to install

type GlobalConfig

type GlobalConfig struct {
	AppPath             string                 `yaml:"app_path"`
	ConfigPath          string                 `yaml:"config_path"`
	AlreadyInstalled    AlreadyInstalledConfig `yaml:"already_installed"`
	CurrentFont         string                 `yaml:"current_font"`
	CurrentTheme        string                 `yaml:"current_theme"`
	Installed           InstalledConfig        `yaml:"installed"`
	Shortcuts           map[string]string      `yaml:"shortcuts"`
	Shell               ShellFeatures          `yaml:"shell"`
	FailedInstallations []FailedInstallation   `yaml:"failed_installations,omitempty"`
	Worktree            WorktreeConfig         `yaml:"worktree"`
	Integrations        IntegrationsConfig     `yaml:"integrations,omitempty"`
}

func (*GlobalConfig) AddToAlreadyInstalled

func (gc *GlobalConfig) AddToAlreadyInstalled(itemName, itemType string)

func (*GlobalConfig) AddToConfig

func (gc *GlobalConfig) AddToConfig(itemName, itemType, configType string)

func (*GlobalConfig) AddToFailed

func (gc *GlobalConfig) AddToFailed(packageName, category, errorMessage string, attemptCount int)

AddToFailed adds a package to the failed installations list It stores the package name, category, error message, timestamp, and attempt count

func (*GlobalConfig) AddToInstalled

func (gc *GlobalConfig) AddToInstalled(itemName, itemType string)

AddToInstalled adds an item to the installed config

func (*GlobalConfig) Create

func (gc *GlobalConfig) Create() error

func (*GlobalConfig) DisableShellFeature

func (gc *GlobalConfig) DisableShellFeature(featureName string)

DisableShellFeature disables a shell feature by name

func (*GlobalConfig) EnableShellFeature

func (gc *GlobalConfig) EnableShellFeature(featureName string)

EnableShellFeature enables a shell feature by name

func (*GlobalConfig) IsAlreadyInstalled

func (gc *GlobalConfig) IsAlreadyInstalled(itemName, itemType string) bool

func (*GlobalConfig) IsInstalledByDevgeta

func (gc *GlobalConfig) IsInstalledByDevgeta(itemName, itemType string) bool

func (*GlobalConfig) IsShellFeatureEnabled

func (gc *GlobalConfig) IsShellFeatureEnabled(featureName string) bool

IsShellFeatureEnabled checks if a shell feature is enabled

func (*GlobalConfig) IsTracked

func (gc *GlobalConfig) IsTracked(itemName, itemType, configType string) bool

func (*GlobalConfig) Load

func (gc *GlobalConfig) Load() error

func (*GlobalConfig) ReconcileShellFeatures

func (gc *GlobalConfig) ReconcileShellFeatures()

ReconcileShellFeatures detects which tools are installed on the system and enables their corresponding shell features. This makes the config self-healing: even if shell feature booleans were lost, they are restored based on what's actually installed.

func (*GlobalConfig) RegenerateShellConfig

func (gc *GlobalConfig) RegenerateShellConfig() error

func (*GlobalConfig) RemoveFromInstalled

func (gc *GlobalConfig) RemoveFromInstalled(itemName, itemType string)

RemoveFromInstalled removes itemName from the installed tracking list for itemType.

func (*GlobalConfig) Reset

func (gc *GlobalConfig) Reset() error

func (*GlobalConfig) Save

func (gc *GlobalConfig) Save() error

type InstalledConfig

type InstalledConfig struct {
	Packages      []string `yaml:"packages"`
	DesktopApps   []string `yaml:"desktop_apps"`
	Fonts         []string `yaml:"fonts"`
	Themes        []string `yaml:"themes"`
	TerminalTools []string `yaml:"terminal_tools"`
	DevLanguages  []string `yaml:"dev_languages"`
	Databases     []string `yaml:"databases"`
}

Used to store what this app installed

type IntegrationsConfig

type IntegrationsConfig struct {
	RtkClaudeHook bool `yaml:"rtk_claude_hook,omitempty"`
}

IntegrationsConfig tracks explicit cross-app opt-ins that devgeta must preserve when re-rendering another app's config. RtkClaudeHook records that the user opted into rtk's command-rewriting hook (ADR-0004: the hook is never enabled automatically), so claude's settings.json template keeps the hook entry across every `dg configure claude --force`.

type RecentRepo

type RecentRepo struct {
	Path     string    `yaml:"path"`
	LastUsed time.Time `yaml:"last_used"`
}

RecentRepo tracks a repo root devgeta has created a worktree in, so the worktree TUI's repo picker can offer it again (most-recently-used first) even after every worktree under it has been removed.

type ShellFeatures

type ShellFeatures struct {
	IsMac                 bool `yaml:"is_mac"`
	Mise                  bool `yaml:"mise"`
	Zoxide                bool `yaml:"zoxide"`
	ZshAutosuggestions    bool `yaml:"zsh_autosuggestions"`
	ZshSyntaxHighlighting bool `yaml:"zsh_syntax_highlighting"`
	Powerlevel10k         bool `yaml:"powerlevel10k"`
	ExtendedCapabilities  bool `yaml:"extended_capabilities"`
	LazyGit               bool `yaml:"lazy_git"`
	LazyDocker            bool `yaml:"lazy_docker"`
	Fzf                   bool `yaml:"fzf"`
	Neovim                bool `yaml:"neovim"`
	Tmux                  bool `yaml:"tmux"`
	Eza                   bool `yaml:"eza"`
	Bat                   bool `yaml:"bat"`
	Opencode              bool `yaml:"opencode"`
	Claude                bool `yaml:"claude"`
}

ShellFeatures tracks which shell enhancements are enabled

type WorktreeConfig

type WorktreeConfig struct {
	DefaultAI     string       `yaml:"default_ai"`               // "opencode" | "claude"; empty = fallback to "opencode"
	RecentRepos   []RecentRepo `yaml:"recent_repos,omitempty"`   // MRU-ordered; new field, absent in old configs
	SearchPaths   []string     `yaml:"search_paths,omitempty"`   // dirs to scan for git repos for the worktree picker; empty = scanning disabled (the only off-switch)
	ScanDepth     int          `yaml:"scan_depth,omitempty"`     // max dir depth for the repo scan; 0 (or unset) = use the default of 4
	DefaultLayout string       `yaml:"default_layout,omitempty"` // default tmux window layout for `dg ws`'s create; empty = derive a single-pane layout from DefaultAI
}

WorktreeConfig stores worktree-specific settings

func (*WorktreeConfig) PrunedRecentRepos

func (wc *WorktreeConfig) PrunedRecentRepos() []RecentRepo

PrunedRecentRepos returns RecentRepos with any entry whose Path no longer exists on disk removed. It is a pure read-time filter: it does not mutate the receiver or persist anything, so callers decide separately whether and when to save the pruned result.

func (*WorktreeConfig) UpsertRecentRepo

func (wc *WorktreeConfig) UpsertRecentRepo(path string, now time.Time)

UpsertRecentRepo records path as the most-recently-used repo: if path is already present it is moved to the front with LastUsed bumped to now, otherwise it is prepended. The list is capped at maxRecentRepos entries, dropping the least-recently-used. path must already be canonicalized (see CanonicalRepoPath) so the same repo is never stored under two string forms.

Jump to

Keyboard shortcuts

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