How It Works
Each ChatCLI version defines aCurrentConfigVersion. When the user updates the binary, the system compares the saved version with the current version and applies the necessary migrations:
Migration Cycle
1
Detects need
Compares the current version with
CurrentConfigVersion.2
Creates backup
Saves the full configuration to
~/.chatcli/backups/config_backup_<timestamp>.json.3
Applies migrations
Executes each migration in sequence (v0 -> v1, v1 -> v2, …).
4
Updates version
Writes the new version to
~/.chatcli/config_version.json.5
In case of failure
Preserves the original values and the backup remains available.
Migration v0 -> v1
The included migration normalizes legacy configurations:API
Check Migration Need
Run Migration
Backup and Rollback
Register Custom Migration
Version File
The version is stored in~/.chatcli/config_version.json:
Backups
Backups are stored in~/.chatcli/backups/ with a timestamp:
Safety
Atomicity
Each migration is applied on a copy of the values. If it fails, the originals are preserved.
Sequentiality
Migrations are executed strictly in ascending version order.
Mandatory backup
A backup is automatically created before any migration.
Idempotency
If already at the current version,
Migrate() returns the values unchanged.