walrus-daemon 0.0.10

Walrus agent runtime with memory, tools, and local inference
Documentation
//! Walrus skill registry — skill storage and lookup.

use std::collections::BTreeMap;

/// A registry of loaded skills.
#[derive(Debug, Clone, Default)]
pub struct SkillRegistry {
    skills: Vec<Skill>,
}

impl SkillRegistry {
    /// Create an empty registry.
    pub fn new() -> Self {
        Self::default()
    }

    /// Add a skill to the registry.
    pub fn add(&mut self, skill: Skill) {
        self.skills.push(skill);
    }

    /// Add or replace a skill by name.
    pub fn upsert(&mut self, skill: Skill) {
        self.skills.retain(|s| s.name != skill.name);
        self.skills.push(skill);
    }

    /// Get all loaded skills.
    pub fn skills(&self) -> Vec<&Skill> {
        self.skills.iter().collect()
    }

    /// Number of loaded skills.
    pub fn len(&self) -> usize {
        self.skills.len()
    }

    /// Whether the registry has no skills.
    pub fn is_empty(&self) -> bool {
        self.skills.is_empty()
    }
}

/// A named unit of agent behavior (agentskills.io format).
///
/// Pure data struct — parsing logic lives in the [`loader`] module.
/// Fields mirror the agentskills.io specification.
#[derive(Debug, Clone)]
pub struct Skill {
    /// Skill identifier (lowercase, hyphens, 1-64 chars).
    pub name: String,
    /// Human-readable description (1-1024 chars).
    pub description: String,
    /// License name or reference to a bundled license file.
    pub license: Option<String>,
    /// Compatibility constraints (e.g. "Requires git, docker").
    pub compatibility: Option<String>,
    /// Arbitrary key-value metadata map.
    pub metadata: BTreeMap<String, String>,
    /// Tool names this skill is pre-approved to use (experimental).
    pub allowed_tools: Vec<String>,
    /// Skill body (Markdown instructions).
    pub body: String,
}