LemonCore. Config. Modular
(lemon_core v0.1.0)
View Source
Modular configuration interface for Lemon.
This module is the canonical runtime configuration loader for Lemon.
It delegates to specialized sub-modules for each config domain and is the
source of truth behind LemonCore.Config.
Configuration Priority
Configuration values are resolved in the following priority:
- Environment variables (highest priority)
- Project config (
.lemon/config.toml) - Global config (
~/.lemon/config.toml)
Both config locations are configurable; see LemonCore.Paths.
- Default values (lowest priority)
Example Usage
# Load full configuration using modular approach
config = LemonCore.Config.Modular.load()
# Access specific sections
config.agent.default_model
config.gateway.enable_telegram
config.providers.providers["anthropic"].api_keySub-modules
LemonCore.Config.Agent- Agent behavior settingsLemonCore.Config.Tools- Web tools and WASM configurationLemonCore.Config.Gateway- Telegram, SMS, and engine bindingsLemonCore.Config.Logging- Log file and rotation settingsLemonCore.Config.TUI- Terminal UI theme and debugLemonCore.Config.Providers- LLM provider configurations
See LemonCore.Config for the legacy configuration interface.
Summary
Functions
Checks for deprecated TOML sections and raises ValidationError if found.
Returns the path to the global config file.
Loads the full configuration from all sources using the modular approach.
Loads and validates configuration, raising on validation errors.
Loads configuration with validation, returning ok/error tuple.
Returns the path to the project config file for the given directory.
Types
@type t() :: %LemonCore.Config.Modular{ agent: LemonCore.Config.Agent.t(), features: LemonCore.Config.Features.t(), gateway: LemonCore.Config.Gateway.t(), logging: LemonCore.Config.Logging.t(), providers: LemonCore.Config.Providers.t(), tools: LemonCore.Config.Tools.t(), tui: LemonCore.Config.TUI.t() }
Functions
@spec check_deprecated_sections!(map()) :: :ok
Checks for deprecated TOML sections and raises ValidationError if found.
Deprecated sections:
[agent]- use[defaults]and[runtime]instead[agents]- use[profiles.<id>]instead[agent.tools]- use[runtime.tools.*]instead[tools]- use[runtime.tools.*]instead
@spec global_path() :: String.t()
Returns the path to the global config file.
Loads the full configuration from all sources using the modular approach.
Merges global config, project config, and environment variables.
Options
:project_dir- Project directory to load config from (default: current directory):validate- Whether to validate the config (default: false)
Examples
config = LemonCore.Config.Modular.load()
config = LemonCore.Config.Modular.load(project_dir: "~/my-project")
config = LemonCore.Config.Modular.load(validate: true)
Loads and validates configuration, raising on validation errors.
Options
:project_dir- Project directory to load config from (default: current directory)
Examples
config = LemonCore.Config.Modular.load!()Raises
LemonCore.Config.ValidationError- If configuration is invalid
Loads configuration with validation, returning ok/error tuple.
Options
:project_dir- Project directory to load config from (default: current directory)
Examples
case LemonCore.Config.Modular.load_with_validation() do
{:ok, config} -> use_config(config)
{:error, errors} -> handle_errors(errors)
end
Returns the path to the project config file for the given directory.