config

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package config loads ~/.culi/config.yaml with defaults. The base directory is overridable via CULI_HOME so tests and sandboxes never touch the real user store.

Index

Constants

View Source
const InternalEnv = "CULI_INTERNAL"

InternalEnv marks a culi-spawned subprocess (the headless `claude -p` learning calls in internal/llmgen). Those calls run under the user's Claude Code settings, so they inherit culi's own hooks; the hook path checks this var and no-ops for every event. Without it, each mining call would get context injected into its prompt (UserPromptSubmit) and its transcript enqueued (SessionEnd) — culi mining its own mining calls (self-ingestion loop).

Variables

This section is empty.

Functions

func BaseDir

func BaseDir() (string, error)

BaseDir returns the culi home directory: $CULI_HOME if set, else ~/.culi.

func DBPath

func DBPath(base string) string

DBPath returns the SQLite index path under base.

func InboxDir

func InboxDir(base string) string

InboxDir returns the learn-queue directory under base.

func KnowledgeDir

func KnowledgeDir(base string) string

KnowledgeDir returns the canonical card store directory under base.

func LogDir

func LogDir(base string) string

LogDir returns the log directory under base.

func SetKnobs added in v0.2.0

func SetKnobs(base string, values map[string]string) (int, error)

SetKnobs writes the given safe knobs into config.yaml in place, preserving comments and every unlisted key (C4: never destroy user content). Values arrive as strings (the console's form fields); non-whitelisted keys are ignored. Returns the number of keys applied. A parse error on any value aborts the whole write — config.yaml is left untouched.

func SetRepos

func SetRepos(base string, repos []string) error

SetRepos rewrites only the `repos:` list in config.yaml, preserving every other key and all of the operator's comments. It round-trips through yaml.Node and replaces just the repos sequence node — a full Marshal of the Config struct would strip comments (C4: never destroy user content).

func StateDir

func StateDir(base string) string

StateDir returns the directory for culi-internal state (export manifest, learning ledgers) under base.

Types

type Config

type Config struct {
	// PushBudget is the max estimated tokens injected per UserPromptSubmit.
	PushBudget int `yaml:"push_budget"`
	// BaselineBudget is the max estimated tokens injected at SessionStart.
	BaselineBudget int `yaml:"baseline_budget"`
	// Ollama configures the local embedding endpoint (used from Phase 3).
	Ollama OllamaConfig `yaml:"ollama"`
	// ExtraAcks extends the built-in acknowledgement lexicon (the
	// inject-nothing gate) with the user's own phrases, any language.
	ExtraAcks []string `yaml:"extra_acks"`
	// ExtraStopwords extends the built-in stopword packs.
	ExtraStopwords []string `yaml:"extra_stopwords"`
	// Repos lists absolute paths of repositories whose .claude directories
	// and CLAUDE.md files `culi import` reconciles into the canonical store.
	Repos []string `yaml:"repos"`
	// Import configures the drift-reconcile pipeline.
	Import ImportConfig `yaml:"import"`
	// Learn configures the background learning pipelines.
	Learn LearnConfig `yaml:"learn"`
}

Config holds user-tunable settings. Zero values are replaced by defaults in Load so a partial (or absent) config.yaml always yields a usable Config.

func Load

func Load(base string) (Config, error)

Load reads base/config.yaml. A missing file is not an error: defaults apply.

type ImportConfig

type ImportConfig struct {
	// Provider selects the merge backend: auto (default — anthropic when
	// ANTHROPIC_API_KEY is set, else claude-cli when the claude binary is in
	// PATH), anthropic, claude-cli, ollama, or none (mechanical only).
	Provider string `yaml:"provider"`
	// MergeModel is the model used to reconcile diverged clusters and
	// decompose CLAUDE.md files. For anthropic/claude-cli this is a Claude
	// model ID; for ollama it MUST be a local generation model (e.g. qwen3).
	MergeModel string `yaml:"merge_model"`
}

ImportConfig tunes `culi import merge`.

type LearnConfig

type LearnConfig struct {
	// Enabled is the master switch (default true).
	Enabled bool `yaml:"enabled"`
	// Provider selects the mining backend like import.provider: auto (default),
	// anthropic, claude-cli, ollama, or none.
	Provider string `yaml:"provider"`
	// CheapModel handles routine mining; StrongModel is the one-step
	// escalation on schema failures. For ollama both MUST be local models.
	CheapModel  string `yaml:"cheap_model"`
	StrongModel string `yaml:"strong_model"`
	// DailyUSDCap bounds estimated API spend per day (anthropic backend only;
	// claude-cli and ollama cost $0). 0 = default.
	DailyUSDCap float64 `yaml:"daily_usd_cap"`
	// DailyCallCap bounds model calls per day on every backend — the
	// subscription-quota guard for claude-cli. 0 = default.
	DailyCallCap int `yaml:"daily_call_cap"`
	// CandidateTTLDays auto-retires mined candidate cards left unreinforced for
	// this many days (file mtime is the clock). 0 = default (30); a negative
	// value disables the janitor. Confirmed cards are NEVER auto-retired —
	// dormant ones are only reported by `culi stats` (C4).
	CandidateTTLDays int `yaml:"candidate_ttl_days"`
	// MaxJobsPerRun caps how many queued transcripts one `culi learn` run mines,
	// newest first (recent conversations carry the most relevant lessons). 0 =
	// default (50); a negative value = unlimited. `culi learn --no-cap` always
	// drains the whole backlog regardless of this.
	MaxJobsPerRun int `yaml:"max_jobs_per_run"`
	// ConfirmAt is how many independent observations promote a mined candidate
	// to a confirmed, injecting card without manual review. 0 = default (2:
	// corroboration from two separate sessions). 1 = auto-confirm on first
	// sighting (trust the model — noisier); higher = more conservative.
	// `culi review` can always confirm/reject sooner regardless of this.
	ConfirmAt int `yaml:"confirm_at"`
	// OAuthTokenFile points the claude-cli backend at a file holding a
	// CLAUDE_CODE_OAUTH_TOKEN. Empty (default) = off. Set it when background
	// learning runs headless: Claude Code does not propagate its OAuth token to
	// hook-spawned processes, so `claude -p` has no auth; culi reads the token
	// from this file and injects it into the subprocess env. Leading ~ expands.
	OAuthTokenFile string `yaml:"oauth_token_file"`
	// AnthropicAPIKeyFile points the anthropic backend at a file holding an
	// ANTHROPIC_API_KEY, for users who prefer the metered API over the
	// subscription CLI. Empty (default) = off; the env var is used when set.
	// Its presence also makes provider:auto prefer the Anthropic API. ~ expands.
	AnthropicAPIKeyFile string `yaml:"anthropic_api_key_file"`
}

LearnConfig tunes transcript mining (Phase 4). Both caps must pass for a model call to run; hooks always enqueue regardless (the queue drains when caps reset). To spend nothing, set enabled: false or provider: none.

type OllamaConfig

type OllamaConfig struct {
	Endpoint string `yaml:"endpoint"`
	Model    string `yaml:"model"`
}

OllamaConfig points at the local embedding server.

Jump to

Keyboard shortcuts

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