config

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfigPath

func ConfigPath() string

ConfigPath returns the path to the configuration file. Follows XDG Base Directory Specification on Unix. Uses %APPDATA% on Windows.

func DataPath

func DataPath() string

DataPath returns the path to the data directory. Follows XDG Base Directory Specification on Unix. Uses %LOCALAPPDATA% on Windows.

func DatabasePath

func DatabasePath() string

DatabasePath returns the path to the SQLite database.

func HooksPath

func HooksPath() string

HooksPath returns the path to the hooks directory.

func LogPath

func LogPath() string

LogPath returns the path to the log file.

func ProjectPath

func ProjectPath() string

ProjectPath returns the canonical path for the current working directory. Resolves symlinks for accurate project matching.

Types

type AlertsConfig

type AlertsConfig struct {
	Enabled             bool    `mapstructure:"enabled"`
	DailyTokenLimit     int64   `mapstructure:"daily_token_limit"`
	WeeklyTokenLimit    int64   `mapstructure:"weekly_token_limit"`
	UsageSpikeThreshold float64 `mapstructure:"usage_spike_threshold"`
}

AlertsConfig controls alert thresholds.

type CommandContext

type CommandContext struct {
	Command    string `mapstructure:"command"`    // "git", "npm", "cargo", etc.
	Subcommand string `mapstructure:"subcommand"` // "status", "test", "build"
	ExitCode   int    `mapstructure:"exit_code"`  // Non-zero = likely has errors
	Intent     string `mapstructure:"intent"`     // "debug", "review", "deploy", "search"
	IsTest     bool   `mapstructure:"is_test"`    // Test output detection
	IsBuild    bool   `mapstructure:"is_build"`   // Build output detection
	IsError    bool   `mapstructure:"is_error"`   // Error output detection
}

CommandContext provides metadata about the command being executed. Used for intelligent filtering decisions.

type Config

type Config struct {
	Tracking  TrackingConfig  `mapstructure:"tracking"`
	Filter    FilterConfig    `mapstructure:"filter"`
	Pipeline  PipelineConfig  `mapstructure:"pipeline"`
	Hooks     HooksConfig     `mapstructure:"hooks"`
	Dashboard DashboardConfig `mapstructure:"dashboard"`
	Alerts    AlertsConfig    `mapstructure:"alerts"`
	Export    ExportConfig    `mapstructure:"export"`
}

Config represents the main configuration structure.

func Defaults

func Defaults() *Config

Defaults returns the default configuration.

func Load

func Load(cfgFile string) (*Config, error)

Load reads configuration from file and environment.

func LoadFromFile

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

LoadFromFile reads a TOML configuration file directly.

func (*Config) GetDatabasePath

func (c *Config) GetDatabasePath() string

GetDatabasePath returns the effective database path.

func (*Config) Save

func (c *Config) Save(path string) error

Save writes the configuration to a TOML file.

type DashboardConfig

type DashboardConfig struct {
	Port           int    `mapstructure:"port"`
	Bind           string `mapstructure:"bind"`
	UpdateInterval int    `mapstructure:"update_interval"`
	Theme          string `mapstructure:"theme"`
	EnableExport   bool   `mapstructure:"enable_export"`
}

DashboardConfig controls dashboard behavior.

type ExportConfig

type ExportConfig struct {
	DefaultFormat    string `mapstructure:"default_format"`
	IncludeTimestamp bool   `mapstructure:"include_timestamps"`
	MaxRecords       int    `mapstructure:"max_records"`
}

ExportConfig controls export behavior.

type FilterConfig

type FilterConfig struct {
	NoiseDirs   []string `mapstructure:"noise_dirs"`
	IgnoreFiles []string `mapstructure:"ignore_files"` // File patterns to ignore (e.g., "*.lock", "*.min.js")
	Mode        string   `mapstructure:"mode"`         // "minimal" or "aggressive"
	MaxWidth    int      `mapstructure:"max_width"`    // Max display width (0 = auto)
}

FilterConfig controls output filtering behavior.

type HooksConfig

type HooksConfig struct {
	ExcludedCommands []string `mapstructure:"excluded_commands"`
	AuditDir         string   `mapstructure:"audit_dir"` // Directory for hook audit logs
	TeeDir           string   `mapstructure:"tee_dir"`   // Directory for failure tee logs
}

HooksConfig controls shell hook behavior.

type PipelineConfig

type PipelineConfig struct {
	// Context limits
	MaxContextTokens int `mapstructure:"max_context_tokens"` // Max input context (default: 2M)
	ChunkSize        int `mapstructure:"chunk_size"`         // Processing chunk size for large inputs

	// Layer enable/disable
	EnableEntropy      bool `mapstructure:"enable_entropy"`
	EnablePerplexity   bool `mapstructure:"enable_perplexity"`
	EnableGoalDriven   bool `mapstructure:"enable_goal_driven"`
	EnableAST          bool `mapstructure:"enable_ast"`
	EnableContrastive  bool `mapstructure:"enable_contrastive"`
	EnableNgram        bool `mapstructure:"enable_ngram"`
	EnableEvaluator    bool `mapstructure:"enable_evaluator"`
	EnableGist         bool `mapstructure:"enable_gist"`
	EnableHierarchical bool `mapstructure:"enable_hierarchical"`
	EnableBudget       bool `mapstructure:"enable_budget"`

	// Layer thresholds (tunable)
	EntropyThreshold      float64 `mapstructure:"entropy_threshold"`       // Layer 1: 0.0-1.0 (default: 0.3)
	PerplexityThreshold   float64 `mapstructure:"perplexity_threshold"`    // Layer 2: 0.0-1.0 (default: 0.5)
	GoalDrivenThreshold   float64 `mapstructure:"goal_driven_threshold"`   // Layer 3: 0.0-1.0 (default: 0.4)
	ASTPreserveThreshold  float64 `mapstructure:"ast_preserve_threshold"`  // Layer 4: 0.0-1.0 (default: 0.6)
	ContrastiveThreshold  float64 `mapstructure:"contrastive_threshold"`   // Layer 5: 0.0-1.0 (default: 0.5)
	NgramMinOccurrences   int     `mapstructure:"ngram_min_occurrences"`   // Layer 6: min repeats (default: 3)
	EvaluatorThreshold    float64 `mapstructure:"evaluator_threshold"`     // Layer 7: 0.0-1.0 (default: 0.4)
	GistMinChunkSize      int     `mapstructure:"gist_min_chunk_size"`     // Layer 8: chars (default: 100)
	HierarchicalMaxLevels int     `mapstructure:"hierarchical_max_levels"` // Layer 9: depth (default: 3)
	HierarchicalRatio     float64 `mapstructure:"hierarchical_ratio"`      // Layer 9: 0.0-1.0 (default: 0.3)

	// Budget enforcement
	DefaultBudget      int    `mapstructure:"default_budget"`       // Default token budget (0 = unlimited)
	HardBudgetLimit    bool   `mapstructure:"hard_budget_limit"`    // Strict enforcement
	BudgetOverflowFile string `mapstructure:"budget_overflow_file"` // File to save overflow content

	// Resilience
	TeeOnFailure       bool   `mapstructure:"tee_on_failure"`       // Save raw output on failure
	TeeDir             string `mapstructure:"tee_dir"`              // Directory for tee files
	FailSafeMode       bool   `mapstructure:"failsafe_mode"`        // Return original on corruption
	ValidateOutput     bool   `mapstructure:"validate_output"`      // Check output validity
	ShortCircuitBudget bool   `mapstructure:"short_circuit_budget"` // Skip layers if budget met

	// Performance
	ParallelLayers  bool `mapstructure:"parallel_layers"`  // Run independent layers in parallel
	CacheEnabled    bool `mapstructure:"cache_enabled"`    // Cache compression results
	CacheMaxSize    int  `mapstructure:"cache_max_size"`   // Max cache entries
	StreamThreshold int  `mapstructure:"stream_threshold"` // Stream if input > N tokens

	// LLM Compaction (Layer 11) - Semantic compression
	EnableCompaction        bool   `mapstructure:"enable_compaction"`         // Enable LLM-based compaction
	CompactionThreshold     int    `mapstructure:"compaction_threshold"`      // Minimum tokens to trigger
	CompactionPreserveTurns int    `mapstructure:"compaction_preserve_turns"` // Recent turns to keep verbatim
	CompactionMaxTokens     int    `mapstructure:"compaction_max_tokens"`     // Max summary tokens
	CompactionStateSnapshot bool   `mapstructure:"compaction_state_snapshot"` // Use state snapshot format
	CompactionAutoDetect    bool   `mapstructure:"compaction_auto_detect"`    // Auto-detect conversation content
	LLMProvider             string `mapstructure:"llm_provider"`              // ollama, lmstudio, openai
	LLMModel                string `mapstructure:"llm_model"`                 // Model name
	LLMBaseURL              string `mapstructure:"llm_base_url"`              // API endpoint

	// Attribution Filter (Layer 12) - ProCut-style pruning
	EnableAttribution     bool    `mapstructure:"enable_attribution"`     // Enable attribution filtering
	AttributionThreshold  float64 `mapstructure:"attribution_threshold"`  // Importance threshold (0.0-1.0)
	AttributionPositional bool    `mapstructure:"attribution_positional"` // Use positional bias
	AttributionFrequency  bool    `mapstructure:"attribution_frequency"`  // Use frequency bias
	AttributionSemantic   bool    `mapstructure:"attribution_semantic"`   // Use semantic preservation

	// H2O Filter (Layer 13) - Heavy-Hitter Oracle
	EnableH2O          bool `mapstructure:"enable_h2o"`            // Enable H2O compression
	H2OSinkSize        int  `mapstructure:"h2o_sink_size"`         // Attention sink tokens to preserve
	H2ORecentSize      int  `mapstructure:"h2o_recent_size"`       // Recent tokens to preserve
	H2OHeavyHitterSize int  `mapstructure:"h2o_heavy_hitter_size"` // Heavy hitter tokens to preserve

	// Attention Sink Filter (Layer 14) - StreamingLLM-style
	EnableAttentionSink  bool `mapstructure:"enable_attention_sink"`  // Enable attention sink filtering
	AttentionSinkCount   int  `mapstructure:"attention_sink_count"`   // Initial tokens to preserve as sinks
	AttentionRecentCount int  `mapstructure:"attention_recent_count"` // Recent lines to preserve
}

PipelineConfig controls the 12-layer compression pipeline. Supports contexts up to 2M tokens with streaming processing.

type TrackingConfig

type TrackingConfig struct {
	Enabled      bool   `mapstructure:"enabled"`
	DatabasePath string `mapstructure:"database_path"`
	Telemetry    bool   `mapstructure:"telemetry"`
}

TrackingConfig controls token tracking behavior.

Jump to

Keyboard shortcuts

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