LemonCore.Update.ConfigMigrator (lemon_core v0.1.0)

View Source

Detects and migrates deprecated configuration sections.

Deprecated sections

Old sectionNew location
[agent] fields[defaults] (provider, model, thinking_level) or [runtime]
[agents.<id>][profiles.<id>]
[agent.tools.*][runtime.tools.*]
[tools.*][runtime.tools.*]

Usage

# Check what would be migrated (dry run):
{:needs_migration, issues} = ConfigMigrator.check(path)

# Apply migration:
:ok = ConfigMigrator.migrate!(path)

Summary

Functions

Returns the backup path for a given config path.

Checks the config at path for deprecated sections.

Applies automated config migration to path in-place.

Types

issue()

@type issue() :: String.t()

Functions

backup_path(path)

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

Returns the backup path for a given config path.

check(path)

@spec check(String.t()) :: :ok | {:needs_migration, [issue()]} | {:error, term()}

Checks the config at path for deprecated sections.

Returns:

  • :ok — config is clean, no migration needed.
  • {:needs_migration, issues} — deprecated sections found; issues describes each one.
  • {:error, reason} — could not read or parse the file.

migrate!(path)

@spec migrate!(String.t()) :: :ok | {:error, term()}

Applies automated config migration to path in-place.

Creates a backup at <path>.pre-update-bak before writing.

Returns :ok on success, {:error, reason} on failure.