config

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package config handles staghorn configuration.

Index

Constants

View Source
const (
	DefaultVersion  = 1
	DefaultPath     = "CLAUDE.md"
	DefaultCacheTTL = "24h"
)

Default values.

Variables

This section is empty.

Functions

func Exists

func Exists() bool

Exists checks if a config file exists at the default location.

func ProjectClaudeCommandsDir added in v0.2.0

func ProjectClaudeCommandsDir(projectRoot string) string

ProjectClaudeCommandsDir returns the path for project-level Claude Code commands.

func ProjectCommandsDir added in v0.2.0

func ProjectCommandsDir(projectRoot string) string

ProjectCommandsDir returns the path for project-specific commands. This is relative to the project root (.staghorn/commands/).

func Save

func Save(cfg *Config) error

Save writes config to the default location.

func SaveTo

func SaveTo(cfg *Config, path string) error

SaveTo writes config to a specific path.

Types

type CacheConfig

type CacheConfig struct {
	TTL string `yaml:"ttl"` // e.g., "24h"
}

CacheConfig contains cache settings.

func (*CacheConfig) TTLDuration

func (c *CacheConfig) TTLDuration() time.Duration

TTLDuration returns the cache TTL as a time.Duration.

type Config

type Config struct {
	Version   int            `yaml:"version"`
	Team      TeamConfig     `yaml:"team"`
	Cache     CacheConfig    `yaml:"cache"`
	Languages LanguageConfig `yaml:"languages,omitempty"`
}

Config represents the staghorn configuration file.

func Load

func Load() (*Config, error)

Load reads and validates config from the default location.

func LoadFrom

func LoadFrom(path string) (*Config, error)

LoadFrom reads and validates config from a specific path.

func (*Config) Validate

func (c *Config) Validate() error

Validate checks config for required fields and valid values.

type LanguageConfig

type LanguageConfig struct {
	AutoDetect bool     `yaml:"auto_detect"`
	Enabled    []string `yaml:"enabled,omitempty"`
	Disabled   []string `yaml:"disabled,omitempty"`
}

LanguageConfig contains language-specific settings.

type Paths

type Paths struct {
	ConfigDir         string // ~/.config/staghorn
	CacheDir          string // ~/.cache/staghorn
	ConfigFile        string // ~/.config/staghorn/config.yaml
	PersonalMD        string // ~/.config/staghorn/personal.md
	PersonalCommands  string // ~/.config/staghorn/commands
	PersonalLanguages string // ~/.config/staghorn/languages
}

Paths provides all staghorn-related filesystem paths.

func NewPaths

func NewPaths() *Paths

NewPaths creates Paths using ~/.config and ~/.cache directories. We use these paths explicitly for cross-platform consistency rather than platform-specific defaults (like ~/Library/Application Support on macOS).

func NewPathsWithOverrides

func NewPathsWithOverrides(configDir, cacheDir string) *Paths

NewPathsWithOverrides allows overriding directories for testing.

func (*Paths) CacheFile

func (p *Paths) CacheFile(owner, repo string) string

CacheFile returns the path for a cached team config.

func (*Paths) CacheMetadataFile

func (p *Paths) CacheMetadataFile(owner, repo string) string

CacheMetadataFile returns the path for cache metadata sidecar.

func (*Paths) ClaudeCommandsDir added in v0.2.0

func (p *Paths) ClaudeCommandsDir() string

ClaudeCommandsDir returns the path for Claude Code custom commands.

func (*Paths) TeamCommandsDir added in v0.2.0

func (p *Paths) TeamCommandsDir(owner, repo string) string

TeamCommandsDir returns the path for cached team commands.

func (*Paths) TeamLanguagesDir

func (p *Paths) TeamLanguagesDir(owner, repo string) string

TeamLanguagesDir returns the path for cached team language configs.

func (*Paths) TeamTemplatesDir

func (p *Paths) TeamTemplatesDir(owner, repo string) string

TeamTemplatesDir returns the path for cached team project templates.

type ProjectPaths

type ProjectPaths struct {
	Root         string // Project root directory
	StaghornDir  string // .staghorn/
	SourceMD     string // .staghorn/project.md (source of truth)
	OutputMD     string // ./CLAUDE.md (generated output)
	CommandsDir  string // .staghorn/commands/
	LanguagesDir string // .staghorn/languages/
	ConfigFile   string // .staghorn/config.yaml (optional project config)
}

ProjectPaths holds paths for project-level config management.

func NewProjectPaths

func NewProjectPaths(projectRoot string) *ProjectPaths

NewProjectPaths creates ProjectPaths for a given project root.

type TeamConfig

type TeamConfig struct {
	Repo   string `yaml:"repo"`   // e.g., "github.com/acme/standards" or "acme/standards"
	Branch string `yaml:"branch"` // optional, defaults to repo's default branch
	Path   string `yaml:"path"`   // optional, defaults to "CLAUDE.md"
}

TeamConfig contains team repository settings.

func (*TeamConfig) ParseRepo

func (t *TeamConfig) ParseRepo() (owner, repo string, err error)

ParseRepo extracts owner and repo name from the repo string. Accepts formats:

Jump to

Keyboard shortcuts

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