Files
cc-switch/src/lib/api/skills.ts
YoVinchen 5e54656d45 fix(skills): resolve third-party skills installation failure (#268)
- Add skills_path field to Skill struct
- Use skills_path to construct correct source path during installation
- Fix installation for repos with custom skill subdirectories
2025-11-21 15:02:01 +08:00

49 lines
1.2 KiB
TypeScript

import { invoke } from "@tauri-apps/api/core";
export interface Skill {
key: string;
name: string;
description: string;
directory: string;
readmeUrl?: string;
installed: boolean;
repoOwner?: string;
repoName?: string;
repoBranch?: string;
skillsPath?: string; // 技能所在的子目录路径,如 "skills"
}
export interface SkillRepo {
owner: string;
name: string;
branch: string;
enabled: boolean;
skillsPath?: string; // 可选:技能所在的子目录路径,如 "skills"
}
export const skillsApi = {
async getAll(): Promise<Skill[]> {
return await invoke("get_skills");
},
async install(directory: string): Promise<boolean> {
return await invoke("install_skill", { directory });
},
async uninstall(directory: string): Promise<boolean> {
return await invoke("uninstall_skill", { directory });
},
async getRepos(): Promise<SkillRepo[]> {
return await invoke("get_skill_repos");
},
async addRepo(repo: SkillRepo): Promise<boolean> {
return await invoke("add_skill_repo", { repo });
},
async removeRepo(owner: string, name: string): Promise<boolean> {
return await invoke("remove_skill_repo", { owner, name });
},
};