use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::path::PathBuf;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SkillMetadata {
pub name: String,
pub description: String,
#[serde(default)]
pub license: Option<String>,
#[serde(default)]
pub compatibility: Option<String>,
#[serde(default)]
pub metadata: Option<HashMap<String, String>>,
#[serde(default, rename = "allowed-tools")]
pub allowed_tools: Option<String>,
}
#[derive(Debug, Clone)]
pub struct Skill {
pub metadata: SkillMetadata,
pub path: PathBuf,
pub skill_md_path: PathBuf,
}
#[derive(Debug, Default)]
pub struct SkillReloadResult {
pub added: Vec<String>,
pub removed: Vec<String>,
pub errors: Vec<SkillDiscoveryError>,
}
#[derive(Debug, Clone)]
pub struct SkillDiscoveryError {
pub path: PathBuf,
pub message: String,
}
impl std::fmt::Display for SkillDiscoveryError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}: {}", self.path.display(), self.message)
}
}
impl std::error::Error for SkillDiscoveryError {}
impl SkillDiscoveryError {
pub fn new(path: PathBuf, message: impl Into<String>) -> Self {
Self {
path,
message: message.into(),
}
}
}