fix(provider): prevent case-insensitive name + key duplicates; migrate and startup dedupe

- Use case-insensitive compare for name + API key in migration
- Add runtime uniqueness checks in add/update commands
- Startup dedupe prefers current provider; archives others
- Keep original display casing; only normalize for comparisons
- Validate Codex config.toml as before; archive before overwrite
This commit is contained in:
Jason
2025-09-05 14:26:11 +08:00
parent 5624a2d11a
commit 79ad0b9368
3 changed files with 109 additions and 4 deletions

View File

@@ -66,6 +66,11 @@ pub fn run() {
// 确保两个 App 条目存在
config_guard.ensure_app(&app_config::AppType::Claude);
config_guard.ensure_app(&app_config::AppType::Codex);
// 启动去重:名称(忽略大小写)+API Key
let removed = migration::dedupe_config(&mut *config_guard);
if removed > 0 {
log::info!("已去重重复供应商 {} 个", removed);
}
}
// 保存配置