config

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const FileMode fs.FileMode = 0o600

FileMode is the permission of config.toml. The file can hold API keys in plaintext (like ~/.aws/credentials or ~/.netrc), so only the owner may read it. Environment variables (INODE_LLM_API_KEY, ...) avoid storing keys at all.

View Source
const FileName = "config.toml"

FileName is the config file inside the config directory.

Variables

View Source
var Keys = []Key{
	{Name: "llm.backend", Allowed: []string{"ollama", "claude-api", "openai"}, Help: "LLM for tagging, summaries and answers"},
	{Name: "llm.model", Help: "e.g. llama3.2, claude-sonnet-5-5, gpt-4o-mini"},
	{Name: "llm.base_url", Help: "Ollama URL, or an OpenAI-compatible endpoint"},
	{Name: "llm.api_key", Secret: true, Help: "Anthropic or OpenAI API key (or set INODE_LLM_API_KEY)"},
	{Name: "embedding.backend", Allowed: []string{"ollama", "voyage"}, Help: "embedding provider"},
	{Name: "embedding.model", Help: "e.g. nomic-embed-text, voyage-3"},
	{Name: "embedding.base_url", Help: "Ollama URL for embeddings"},
	{Name: "embedding.api_key", Secret: true, Help: "Voyage AI API key (or set INODE_EMBEDDING_API_KEY)"},
	{Name: "embedding.dimension", Kind: Int, Help: "vector size of the embedding model"},
	{Name: "db.backend", Allowed: []string{"sqlite", "postgres"}, Help: "storage engine"},
	{Name: "db.path", Help: "SQLite database file"},
	{Name: "db.dsn", Secret: true, Help: "Postgres connection string"},
	{Name: "defaults.sensitive", Kind: Bool, Help: "treat notes as sensitive when unsure"},
	{Name: "search.top_k", Kind: Int, Help: "candidates fetched per search"},
	{Name: "search.max_distance", Kind: Float, Help: "drop matches farther than this (<0 disables)"},
	{Name: "mcp.reveal_sensitive", Kind: Bool, Help: "let MCP clients read sensitive notes"},
	{Name: "log.level", Allowed: []string{"debug", "info", "warn", "error"}, Help: "log verbosity (not read by any command yet)"},
}

Keys lists every setting, in the order `inode config show` prints them.

Functions

func ConfigDir

func ConfigDir() (string, error)

ConfigDir returns the path to the inode config directory (~/.inode).

func LooseMode

func LooseMode(dir string) (mode fs.FileMode, ok bool)

LooseMode reports the permissions of <dir>/config.toml when group or other users can read or write it. ok is false when the file is private or absent.

func Set

func Set(dir, key string, value any) error

Set writes key = value into <dir>/config.toml, keeping the other keys, and leaves the file at FileMode. An existing file with looser permissions (as written by inode before v0.5.0) is tightened. The directory is created with mode 0700 if missing.

func Values added in v0.5.1

func Values(cfg *Config) map[string]any

Values returns the value of every key in cfg, by key name.

Types

type Config

type Config struct {
	LLM       LLMConfig       `mapstructure:"llm"`
	Embedding EmbeddingConfig `mapstructure:"embedding"`
	DB        DBConfig        `mapstructure:"db"`
	Defaults  DefaultsConfig  `mapstructure:"defaults"`
	Search    SearchConfig    `mapstructure:"search"`
	MCP       MCPConfig       `mapstructure:"mcp"`
	Log       LogConfig       `mapstructure:"log"`
}

func Load

func Load() (*Config, error)

Load reads config from (in priority order):

  1. CLI flags (handled by cobra, passed in via overrides)
  2. Environment variables (INODE_* prefix)
  3. .env file (development only — loaded if present)
  4. ~/.inode/config.toml
  5. Hardcoded defaults

type DBConfig

type DBConfig struct {
	// Backend selects the storage engine: "sqlite" (default) or "postgres".
	Backend string `mapstructure:"backend"`
	// Path is the SQLite database file. Used only when Backend = sqlite.
	Path string `mapstructure:"path"`
	// DSN is the Postgres connection string (e.g. postgres://user:pass@host:5432/db?sslmode=disable).
	// Used only when Backend = postgres.
	DSN string `mapstructure:"dsn"`
}

type DefaultsConfig

type DefaultsConfig struct {
	Sensitive bool `mapstructure:"sensitive"`
}

type EmbeddingConfig

type EmbeddingConfig struct {
	Backend   string `mapstructure:"backend"`
	Model     string `mapstructure:"model"`
	APIKey    string `mapstructure:"api_key"`
	BaseURL   string `mapstructure:"base_url"`
	Dimension int    `mapstructure:"dimension"`
}

type Key added in v0.5.1

type Key struct {
	Name    string
	Kind    Kind
	Allowed []string // non-empty: the only accepted values
	Secret  bool     // redacted by `inode config show`
	Help    string
}

Key describes one setting in config.toml. Keys is the single list that `inode config set` validates against and `inode config show` prints; a test checks it matches the fields of Config.

func LookupKey added in v0.5.1

func LookupKey(name string) (Key, bool)

LookupKey returns the Key with the given name.

func (Key) Parse added in v0.5.1

func (k Key) Parse(raw string) (any, error)

Parse converts command-line input to the value written to config.toml, so that `search.top_k 10` is stored as the integer 10, not the string "10".

type Kind added in v0.5.1

type Kind int

Kind is the type of a config value, used to parse `inode config set` input.

const (
	String Kind = iota
	Bool
	Int
	Float
)

func (Kind) String added in v0.5.1

func (k Kind) String() string

type LLMConfig

type LLMConfig struct {
	Backend string `mapstructure:"backend"`
	Model   string `mapstructure:"model"`
	APIKey  string `mapstructure:"api_key"`
	BaseURL string `mapstructure:"base_url"`
}

type LogConfig

type LogConfig struct {
	Level string `mapstructure:"level"`
}

type MCPConfig

type MCPConfig struct {
	// RevealSensitive, when true, lets the MCP server include plaintext
	// content of notes marked sensitive (search_notes will surface them
	// to the LLM, get_note will return unmasked content). Default false:
	// sensitive notes are excluded from search candidates and masked in
	// get_note responses.
	RevealSensitive bool `mapstructure:"reveal_sensitive"`
}

MCPConfig tunes the `inode mcp` Model Context Protocol server.

type SearchConfig

type SearchConfig struct {
	// MaxDistance drops notes whose L2 distance exceeds this value (0 = use built-in default, <0 = disable).
	MaxDistance float32 `mapstructure:"max_distance"`
	// TopK is the number of nearest-neighbour candidates fetched before threshold filtering (0 = use built-in default).
	TopK int `mapstructure:"top_k"`
}

SearchConfig tunes the RAG retrieval pipeline.

Jump to

Keyboard shortcuts

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