LemonCore.Config (lemon_core v0.1.0)

View Source

Canonical Lemon configuration loader.

Loads TOML configuration from:

  • Global: ~/.lemon/config.toml
  • Project: <project>/.lemon/config.toml

Both locations are configurable; see LemonCore.Paths.

Project values override global values. Environment variables override both.

Configuration is delegated to LemonCore.Config.Modular which enforces the canonical config schema and rejects deprecated sections ([agent], [agents], [agent.tools]).

Summary

Functions

Load config using the supervised cache when available.

Get a nested config value.

Path to global config file.

Load merged config (global + project) with environment overrides.

Load a single TOML file without environment overrides.

Path to project config file for a given cwd.

Force a reload from disk (and update the cache when available).

Return config as a plain map.

Types

provider_config()

@type provider_config() :: %{
  optional(:api_key) => String.t() | nil,
  optional(:base_url) => String.t() | nil,
  optional(:api_key_secret) => String.t() | nil,
  optional(:auth_source) => String.t() | nil,
  optional(:oauth_secret) => String.t() | nil,
  optional(:project) => String.t() | nil,
  optional(:project_id) => String.t() | nil,
  optional(:project_secret) => String.t() | nil
}

t()

@type t() :: %LemonCore.Config{
  agent: map(),
  agents: map(),
  gateway: map(),
  logging: map(),
  providers: %{optional(String.t()) => provider_config()},
  tui: map()
}

Functions

cached(cwd \\ nil, opts \\ [])

@spec cached(
  String.t() | nil,
  keyword()
) :: t()

Load config using the supervised cache when available.

This is the default hot-path read. It avoids re-reading/parsing TOML on every call.

get(config, key, default \\ nil)

@spec get(t(), [atom()] | atom(), term()) :: term()

Get a nested config value.

global_path()

@spec global_path() :: String.t()

Path to global config file.

load(cwd \\ nil, opts \\ [])

@spec load(
  String.t() | nil,
  keyword()
) :: t()

Load merged config (global + project) with environment overrides.

load_file(path)

@spec load_file(String.t()) :: map()

Load a single TOML file without environment overrides.

project_path(cwd)

@spec project_path(String.t()) :: String.t()

Path to project config file for a given cwd.

reload(cwd \\ nil, opts \\ [])

@spec reload(
  String.t() | nil,
  keyword()
) :: t()

Force a reload from disk (and update the cache when available).

Use this for explicit reload flows (e.g. admin reload, control plane refresh).

to_map(config)

@spec to_map(t()) :: map()

Return config as a plain map.