feat: add skill storage location toggle between CC Switch and ~/.agents/skills

Allow users to choose between storing skills in CC Switch's managed
directory (~/.cc-switch/skills/) or the Agent Skills open standard
directory (~/.agents/skills/). Includes migration logic that safely
moves files before updating settings, with confirmation dialog for
non-empty installations.
This commit is contained in:
Jason
2026-04-05 20:21:51 +08:00
parent 6d220b2528
commit 8cfce8abfc
12 changed files with 383 additions and 5 deletions
+11 -2
View File
@@ -7,8 +7,8 @@
use crate::app_config::{AppType, InstalledSkill, UnmanagedSkill};
use crate::error::format_skill_error;
use crate::services::skill::{
DiscoverableSkill, ImportSkillSelection, Skill, SkillBackupEntry, SkillRepo, SkillService,
SkillUninstallResult, SkillUpdateInfo,
DiscoverableSkill, ImportSkillSelection, MigrationResult, Skill, SkillBackupEntry, SkillRepo,
SkillService, SkillStorageLocation, SkillUninstallResult, SkillUpdateInfo,
};
use crate::store::AppState;
use std::sync::Arc;
@@ -161,6 +161,15 @@ pub async fn update_skill(
.map_err(|e| e.to_string())
}
/// 迁移 Skill 存储位置
#[tauri::command]
pub async fn migrate_skill_storage(
target: SkillStorageLocation,
app_state: State<'_, AppState>,
) -> Result<MigrationResult, String> {
SkillService::migrate_storage(&app_state.db, target).map_err(|e| e.to_string())
}
// ========== 兼容旧 API 的命令 ==========
/// 获取技能列表(兼容旧 API)