Skip to main content

vv_agent/skills/
models.rs

1use std::collections::BTreeMap;
2use std::path::PathBuf;
3
4use serde_json::{json, Value};
5
6#[derive(Debug, Clone, Default, PartialEq, Eq)]
7pub struct SkillProperties {
8    pub name: String,
9    pub description: String,
10    pub license: Option<String>,
11    pub compatibility: Option<String>,
12    pub allowed_tools: Option<String>,
13    pub metadata: BTreeMap<String, String>,
14}
15
16impl SkillProperties {
17    pub fn to_value(&self) -> Value {
18        let mut payload = serde_json::Map::from_iter([
19            ("name".to_string(), Value::String(self.name.clone())),
20            (
21                "description".to_string(),
22                Value::String(self.description.clone()),
23            ),
24        ]);
25        if let Some(license) = &self.license {
26            payload.insert("license".to_string(), Value::String(license.clone()));
27        }
28        if let Some(compatibility) = &self.compatibility {
29            payload.insert(
30                "compatibility".to_string(),
31                Value::String(compatibility.clone()),
32            );
33        }
34        if let Some(allowed_tools) = &self.allowed_tools {
35            payload.insert(
36                "allowed-tools".to_string(),
37                Value::String(allowed_tools.clone()),
38            );
39        }
40        if !self.metadata.is_empty() {
41            payload.insert("metadata".to_string(), json!(self.metadata));
42        }
43        Value::Object(payload)
44    }
45}
46
47#[derive(Debug, Clone, Default, PartialEq, Eq)]
48pub struct LoadedSkill {
49    pub properties: SkillProperties,
50    pub skill_md_path: PathBuf,
51    pub instructions: String,
52    pub warnings: Vec<String>,
53}
54
55impl LoadedSkill {
56    pub fn name(&self) -> &str {
57        &self.properties.name
58    }
59}
60
61#[derive(Debug, Clone, Default, PartialEq, Eq)]
62pub struct SkillEntry {
63    pub name: String,
64    pub description: String,
65    pub location: Option<String>,
66    pub instructions: Option<String>,
67    pub compatibility: Option<String>,
68    pub allowed_tools: Option<String>,
69    pub metadata: BTreeMap<String, String>,
70    pub load_error: Option<String>,
71}