fix(opencode): add OpenCode support to skills functionality

Add missing OpenCode branch in parse_app_type() and include OpenCode
in all app iteration loops for skills operations (uninstall, scan,
import, migrate).
This commit is contained in:
Jason
2026-01-16 21:23:54 +08:00
parent e06c6176d9
commit 2cc36b3950
2 changed files with 6 additions and 4 deletions

View File

@@ -20,6 +20,7 @@ fn parse_app_type(app: &str) -> Result<AppType, String> {
"claude" => Ok(AppType::Claude),
"codex" => Ok(AppType::Codex),
"gemini" => Ok(AppType::Gemini),
"opencode" => Ok(AppType::OpenCode),
_ => Err(format!("不支持的 app 类型: {app}")),
}
}

View File

@@ -323,7 +323,7 @@ impl SkillService {
.ok_or_else(|| anyhow!("Skill not found: {id}"))?;
// 从所有应用目录删除
for app in [AppType::Claude, AppType::Codex, AppType::Gemini] {
for app in [AppType::Claude, AppType::Codex, AppType::Gemini, AppType::OpenCode] {
let _ = Self::remove_from_app(&skill.directory, &app);
}
@@ -382,7 +382,7 @@ impl SkillService {
let mut unmanaged: HashMap<String, UnmanagedSkill> = HashMap::new();
for app in [AppType::Claude, AppType::Codex, AppType::Gemini] {
for app in [AppType::Claude, AppType::Codex, AppType::Gemini, AppType::OpenCode] {
let app_dir = match Self::get_app_skills_dir(&app) {
Ok(d) => d,
Err(_) => continue,
@@ -464,7 +464,7 @@ impl SkillService {
let mut source_path: Option<PathBuf> = None;
let mut found_in: Vec<String> = Vec::new();
for app in [AppType::Claude, AppType::Codex, AppType::Gemini] {
for app in [AppType::Claude, AppType::Codex, AppType::Gemini, AppType::OpenCode] {
if let Ok(app_dir) = Self::get_app_skills_dir(&app) {
let skill_path = app_dir.join(&dir_name);
if skill_path.exists() {
@@ -514,6 +514,7 @@ impl SkillService {
"claude" => apps.claude = true,
"codex" => apps.codex = true,
"gemini" => apps.gemini = true,
"opencode" => apps.opencode = true,
_ => {}
}
}
@@ -984,7 +985,7 @@ pub fn migrate_skills_to_ssot(db: &Arc<Database>) -> Result<usize> {
let mut discovered: HashMap<String, SkillApps> = HashMap::new();
// 扫描各应用目录
for app in [AppType::Claude, AppType::Codex, AppType::Gemini] {
for app in [AppType::Claude, AppType::Codex, AppType::Gemini, AppType::OpenCode] {
let app_dir = match SkillService::get_app_skills_dir(&app) {
Ok(d) => d,
Err(_) => continue,