Help us shape the future of Go! Take the 2026 Go Developer Survey

config

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Version = "dev"

Version is the release version embedded in the binary. It defaults to "dev" for plain `go build` runs and is stamped at build time via:

go build -ldflags "-X github.com/bethropolis/sift/internal/config.Version=v1.2.0"

GoReleaser, the justfile build recipe, and scripts/install.sh all pass the current git tag this way, so no source edit is needed per release.

Functions

func DefaultProfileName

func DefaultProfileName() (string, error)

DefaultProfileName returns the configured default profile name, if any. The local .sift.toml takes precedence over the global config.

func LoadConfigFile added in v1.2.0

func LoadConfigFile() (configFile, error)

LoadConfigFile returns the merged global+local config file for inspection (used by `sift config show`).

func RegisterFlags

func RegisterFlags(c *Config, fs *pflag.FlagSet)

RegisterFlags binds every config option to fs, using the current field values as flag defaults.

func ResolveConfig added in v1.2.0

func ResolveConfig(c *Config, fs *pflag.FlagSet, opts ...ResolveOption) error

ResolveConfig builds a resolved Config from global + local config files, profile selection, optional target and prompt ref, and the caller's FlagSet (whose Changed flags always win). It mirrors the precedence chain:

Config.New() → global [sift] → local [sift] → profile (+extends) → target → flags

Types

type Automation added in v1.2.0

type Automation struct {
	Watch         *bool    `toml:"watch"`
	WatchInterval string   `toml:"watch_interval"`
	GitHook       string   `toml:"git_hook"`
	HookTargets   []string `toml:"hook_targets"`
}

Automation holds optional declarative automation hints.

type Config

type Config struct {
	// Directory settings
	RootDir string

	// Logging settings
	Verbose     bool
	Quiet       bool
	LogLevel    string
	NoColor     bool
	UseColors   bool
	Highlight   bool
	NoHighlight bool
	Theme       string
	// UITheme is the persisted interactive picker palette. It is separate
	// from Theme, which controls syntax highlighting.
	UITheme           string
	HighlightMaxBytes int
	WindowTitle       string
	NoWindowTitle     bool
	OutputFile        string
	ShowSkipped       bool

	// Processing settings
	Concurrent    bool
	MaxWorkers    int
	MaxFileSizeMB int64
	ShowProgress  bool
	Timeout       time.Duration

	// Filtering settings
	IgnoreHidden  bool
	IgnoreGit     bool
	CustomIgnore  string
	Extensions    string
	IncludeBinary bool
	// SmartFilter skips generated/lock/minified artifacts and oversized files.
	SmartFilter    bool
	SmartMaxTokens int

	// Output format
	Style          string
	JSONOutput     bool
	MarkdownOutput bool
	// NoNerdFonts forces ASCII glyphs in the interactive picker.
	NoNerdFonts bool

	// Scoring tunes the relevance and selection optimizer. Zero fields mean
	// "use the default"; the shared engine fills them in. Values are loaded
	// from a [scoring] section and apply to both rank scoring and the utility
	// optimizer, so no tuning numbers are hardcoded outside internal/lang.
	Scoring Scoring

	// Profile selection
	Profile string
	// Target selection (named [[targets]] entry)
	Target string

	// Token and context settings
	Budget        int
	TokenizeModel string
	Mode          string
	// Prompt is an optional task/directive section prepended to the output.
	Prompt string

	// Safety
	SecretScan   bool
	ForceSecrets bool
	Clipboard    bool

	// Version info
	ShowVersion bool
	Version     string
}

Config holds all application configuration settings.

func New

func New() *Config

New returns a Config populated with built-in defaults.

func (*Config) EffectiveStyle

func (c *Config) EffectiveStyle() string

EffectiveStyle returns the resolved output style, honoring the legacy --json and --markdown flags.

func (*Config) ResolveColors

func (c *Config) ResolveColors()

ResolveColors determines whether colored output should be used.

type Profile

type Profile struct {
	Style             string     `toml:"style"`
	TokenizeModel     string     `toml:"tokenize_model"`
	Budget            int        `toml:"budget"`
	Mode              string     `toml:"compress_mode"`
	Output            string     `toml:"output"`
	Prompt            string     `toml:"prompt"`
	PromptFile        string     `toml:"prompt_file"`
	SecretScan        *bool      `toml:"secret_scan"`
	ForceSecrets      *bool      `toml:"force_secrets"`
	IgnoreHidden      *bool      `toml:"ignore_hidden"`
	IgnoreGit         *bool      `toml:"ignore_git"`
	Extensions        StringList `toml:"extensions"`
	Ignore            StringList `toml:"ignore"`
	SmartFilter       *bool      `toml:"smart_filter"`
	SmartMaxTokens    int        `toml:"smart_max_tokens"`
	Highlight         *bool      `toml:"highlight"`
	NoHighlight       *bool      `toml:"no_highlight"`
	Theme             string     `toml:"theme"`
	HighlightMaxBytes int        `toml:"highlight_max_bytes"`
	WindowTitle       string     `toml:"window_title"`
	NoWindowTitle     *bool      `toml:"no_window_title"`
	Scoring           *Scoring   `toml:"scoring"`
	Extends           []string   `toml:"extends"`
}

Profile is a named set of configuration overrides loaded from TOML. Pointer fields distinguish "not set" from an explicit value.

func LoadProfile

func LoadProfile(name string) (Profile, error)

LoadProfile returns the merged profile with the given name. Global config values are applied first, then local overrides them.

func (Profile) Apply

func (p Profile) Apply(c *Config, fs *pflag.FlagSet)

Apply overlays the profile onto c, without overriding any flag the user explicitly set on the command line.

type PromptRef added in v1.2.0

type PromptRef struct {
	Text string `toml:"text"`
	File string `toml:"file"`
}

PromptRef holds either inline text or a file path for a prompt.

func (PromptRef) ResolvedPrompt added in v1.2.0

func (p PromptRef) ResolvedPrompt() (string, error)

ResolvedPrompt returns the prompt string, reading from file if needed.

type ResolveOption added in v1.2.0

type ResolveOption func(*resolveOpts)

ResolveOption configures ResolveConfig.

func WithPromptRef added in v1.2.0

func WithPromptRef(name string) ResolveOption

WithPromptRef selects a named [prompts.NAME] entry as the prompt.

func WithTarget added in v1.2.0

func WithTarget(name string) ResolveOption

WithTarget selects a named [[targets]] entry.

type Scoring

type Scoring struct {
	// Composite weights for the git/role/centrality relevance score.
	RecencyWeight    float64 `toml:"recency_weight"`
	ChurnWeight      float64 `toml:"churn_weight"`
	CentralityWeight float64 `toml:"centrality_weight"`
	RoleWeight       float64 `toml:"role_weight"`
	// Mode bands for the relevance score.
	FullBand float64 `toml:"full_band"`
	SkipBand float64 `toml:"skip_band"`

	// Utility optimizer knobs.
	BaseMin         float64 `toml:"base_min"`
	BaseMax         float64 `toml:"base_max"`
	RelevanceWeight float64 `toml:"relevance_weight"`
	PreferenceBonus float64 `toml:"preference_bonus"`
	SignatureBonus  float64 `toml:"signature_bonus"`
	SkipMultiplier  float64 `toml:"skip_multiplier"`
	SigQualityMin   float64 `toml:"sig_quality_min"`
	SigQualityMax   float64 `toml:"sig_quality_max"`

	// Retention overrides per lang role name (e.g. "entrypoint", "docs").
	// An empty map leaves the lang-default retention in place; a present key
	// overrides it. Config takes priority over the default.
	Retention map[string]float64 `toml:"retention"`
}

Scoring holds the numeric tuning for the relevance ranker and the selection optimizer. Every field defaults to 0, which the consuming engine interprets as "use the built-in default". This keeps tuning values config-driven from a [scoring] TOML section while letting the defaults live once, in the engine.

func (*Scoring) Merge

func (s *Scoring) Merge(o Scoring)

Merge overlays the non-zero fields of o onto s. Pointer/zero semantics mean a profile's explicit values win while unset fields keep s's value.

type SiftDefaults added in v1.2.0

type SiftDefaults struct {
	Style             string     `toml:"style"`
	TokenizeModel     string     `toml:"tokenize_model"`
	Budget            int        `toml:"budget"`
	Mode              string     `toml:"compress_mode"`
	Output            string     `toml:"output"`
	Prompt            string     `toml:"prompt"`
	PromptFile        string     `toml:"prompt_file"`
	SecretScan        *bool      `toml:"secret_scan"`
	ForceSecrets      *bool      `toml:"force_secrets"`
	IgnoreHidden      *bool      `toml:"ignore_hidden"`
	IgnoreGit         *bool      `toml:"ignore_git"`
	Extensions        StringList `toml:"extensions"`
	Ignore            StringList `toml:"ignore"`
	SmartFilter       *bool      `toml:"smart_filter"`
	SmartMaxTokens    int        `toml:"smart_max_tokens"`
	Highlight         *bool      `toml:"highlight"`
	NoHighlight       *bool      `toml:"no_highlight"`
	Theme             string     `toml:"theme"`
	HighlightMaxBytes int        `toml:"highlight_max_bytes"`
	WindowTitle       string     `toml:"window_title"`
	NoWindowTitle     *bool      `toml:"no_window_title"`
	Scoring           *Scoring   `toml:"scoring"`
}

SiftDefaults holds top-level [sift] defaults. Every field is optional; zero/nil means "use Config.New() default". Mirrors a subset of Config.

type StringList added in v1.2.0

type StringList []string

StringList is an array-of-strings TOML field. The canonical TOML form is array (e.g. extensions = ["go", "md"]). String form is intentionally not handled here — TOML extensions/ignore should always be arrays so the file stays readable and shell-escaping is avoided. Comma-separated strings are a CLI concern (Config.Extensions is a plain string joined at Apply time).

type Target added in v1.2.0

type Target struct {
	Name           string     `toml:"name"`
	Profile        string     `toml:"profile"`
	Output         string     `toml:"output"`
	Style          string     `toml:"style"`
	TokenizeModel  string     `toml:"tokenize_model"`
	Budget         int        `toml:"budget"`
	Mode           string     `toml:"compress_mode"`
	Prompt         string     `toml:"prompt"`
	PromptFile     string     `toml:"prompt_file"`
	SecretScan     *bool      `toml:"secret_scan"`
	ForceSecrets   *bool      `toml:"force_secrets"`
	IgnoreHidden   *bool      `toml:"ignore_hidden"`
	IgnoreGit      *bool      `toml:"ignore_git"`
	Extensions     StringList `toml:"extensions"`
	Ignore         StringList `toml:"ignore"`
	SmartFilter    *bool      `toml:"smart_filter"`
	SmartMaxTokens int        `toml:"smart_max_tokens"`
	Scoring        *Scoring   `toml:"scoring"`
}

Target is one named dump artifact declared via [[targets]].

Jump to

Keyboard shortcuts

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