MCPcopy Create free account
hub / github.com/GCWing/BitFun / delete_skill

Function delete_skill

src/apps/desktop/src/api/skill_api.rs:891–966  ·  view source on GitHub ↗
(
    state: State<'_, AppState>,
    skill_key: String,
    workspace_path: Option<String>,
)

Source from the content-addressed store, hash-verified

889
890#[tauri::command]
891pub async fn delete_skill(
892 state: State<'_, AppState>,
893 skill_key: String,
894 workspace_path: Option<String>,
895) -> Result<String, String> {
896 let registry = SkillRegistry::global();
897 if let Some((remote_root, entry)) =
898 resolve_remote_workspace(&state, workspace_path.as_deref()).await?
899 {
900 let remote_fs = state
901 .get_remote_file_service_async()
902 .await
903 .map_err(|e| format!("Remote file service not available: {}", e))?;
904 let remote_workspace_fs =
905 RemoteWorkspaceFs::new(entry.connection_id.clone(), remote_fs.clone());
906 let skill_info = registry
907 .find_skill_by_key_for_remote_workspace(&remote_workspace_fs, &remote_root, &skill_key)
908 .await
909 .ok_or_else(|| format!("Skill '{}' not found", skill_key))?;
910
911 match skill_info.level {
912 SkillLocation::Project => {
913 remote_fs
914 .remove_dir_all(&entry.connection_id, &skill_info.path)
915 .await
916 .map_err(|e| format!("Failed to delete remote skill folder: {}", e))?;
917 info!(
918 "Remote project skill deleted: key={}, path={}",
919 skill_key, skill_info.path
920 );
921 }
922 SkillLocation::User => {
923 let skill_path = std::path::PathBuf::from(&skill_info.path);
924 if skill_path.exists() {
925 tokio::fs::remove_dir_all(&skill_path)
926 .await
927 .map_err(|e| format!("Failed to delete local skill folder: {}", e))?;
928 }
929 info!(
930 "Local user skill deleted in remote workspace context: key={}, path={}",
931 skill_key,
932 skill_path.display()
933 );
934 }
935 }
936
937 registry.refresh().await;
938
939 return Ok(format!("Skill '{}' deleted successfully", skill_info.name));
940 }
941
942 let workspace_root = workspace_root_from_input(workspace_path.as_deref());
943 let skill_info = registry
944 .find_skill_by_key_for_workspace(&skill_key, workspace_root.as_deref())
945 .await
946 .ok_or_else(|| format!("Skill '{}' not found", skill_key))?;
947
948 let skill_path = std::path::PathBuf::from(&skill_info.path);

Callers

nothing calls this directly

Calls 11

globalFunction · 0.85
resolve_remote_workspaceFunction · 0.85
refresh_for_workspaceMethod · 0.80
cloneMethod · 0.45
remove_dir_allMethod · 0.45
existsMethod · 0.45
refreshMethod · 0.45

Tested by

no test coverage detected