use std::path::PathBuf;
use serde::Serialize;
use crate::model::{Agent, RegistryEntry};
#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
pub struct ToolStatus {
pub name: String,
pub display_name: Option<String>,
pub optional: bool,
pub installed: bool,
pub version: Option<String>,
pub required_version: Option<String>,
pub outdated: bool,
pub installable: bool,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
pub struct SkillStatus {
pub name: String,
pub display_name: Option<String>,
pub optional: bool,
pub agent: Agent,
pub agent_dir: Option<PathBuf>,
pub installed: bool,
pub installable: bool,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
pub struct InstallPreview {
pub tools: Vec<ToolStatus>,
pub skills: Vec<SkillStatus>,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
pub struct InstallReport {
pub entries: Vec<RegistryEntry>,
pub final_preview: InstallPreview,
pub tools: Vec<ToolInstallResult>,
pub outcome: InstallOutcome,
pub duration_ms: u128,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize)]
#[serde(rename_all = "snake_case")]
pub enum ToolInstallOutcome {
AlreadyPresent,
Installed,
Cancelled,
VerificationFailed,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
pub struct ToolInstallResult {
pub name: String,
pub outcome: ToolInstallOutcome,
pub message: Option<String>,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize)]
#[serde(rename_all = "snake_case")]
pub enum InstallOutcome {
Success,
Cancelled,
Failed,
}
impl InstallPreview {
pub fn missing_tools(&self) -> Vec<&ToolStatus> {
self.tools
.iter()
.filter(|status| !status.installed)
.collect()
}
pub fn missing_skills(&self) -> Vec<&SkillStatus> {
self.skills
.iter()
.filter(|status| !status.installed && status.installable)
.collect()
}
}