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