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
Migration v0 -> v1
The included migration normalizes legacy configurations:| Transformation | Before | After |
|---|---|---|
| Normalize provider | openai | OPENAI |
| Rename API key | CHATCLI_API_KEY | OPENAI_API_KEY |
| Rename model | CHATCLI_MODEL | OPENAI_MODEL |
| Default skills | (absent) | CHATCLI_SKILLS_ENABLED=true |
| Default safety | (absent) | CHATCLI_SAFETY_ENABLED=false |
| Default tool use | (absent) | CHATCLI_NATIVE_TOOL_USE=true |
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.