feat(migration): import provider copy files into cc-switch config on first run\n\n- Scan Claude settings-*.json and Codex auth-*.json/config-*.toml\n- Merge into ~/.cc-switch/config.json, de-dupe by provider name (override with copies)\n- Backup old config.json and archive all scanned copy files\n- Add migration marker to avoid re-importing\n- Stop writing provider copy files in ProviderManager::add_provider

This commit is contained in:
Jason
2025-09-04 16:16:51 +08:00
parent 79370dd8a1
commit 5176134c28
3 changed files with 220 additions and 46 deletions

View File

@@ -2,7 +2,7 @@ use serde::{Deserialize, Serialize};
use serde_json::Value;
use std::collections::HashMap;
use crate::config::{get_provider_config_path, write_json_file};
// SSOT 模式:不再写供应商副本文件
/// 供应商结构体
#[derive(Debug, Clone, Serialize, Deserialize)]
@@ -52,11 +52,7 @@ impl Default for ProviderManager {
impl ProviderManager {
/// 添加供应商
pub fn add_provider(&mut self, provider: Provider) -> Result<(), String> {
// 保存供应商配置到独立文件
let config_path = get_provider_config_path(&provider.id, Some(&provider.name));
write_json_file(&config_path, &provider.settings_config)?;
// 添加到管理器
// 仅添加到管理器SSOT统一由 cc-switch/config.json 持久化)
self.providers.insert(provider.id.clone(), provider);
Ok(())
}