robit_agent/skill/mod.rs
1//! Skill system — predefined prompt templates loaded from YAML frontmatter + Markdown body files.
2//!
3//! Skills are declarative data (no trait, no execute method). They are loaded at startup,
4//! their descriptions are injected into the system prompt, and their full content is injected
5//! when a user triggers them via a slash command.
6
7pub mod loader;
8mod registry;
9
10use std::path::PathBuf;
11
12use serde::Deserialize;
13
14pub use loader::{load_skills, parse_skill_file, SkillLoadError};
15pub use registry::SkillRegistry;
16
17// ============================================================================
18// Frontmatter
19// ============================================================================
20
21/// YAML frontmatter fields parsed from the skill file header.
22#[derive(Debug, Clone, Deserialize)]
23pub struct SkillFrontmatter {
24 /// Skill unique identifier (required).
25 pub name: String,
26 /// Skill description for user and Agent (required).
27 pub description: String,
28 /// Semantic version (optional, default "1.0.0").
29 #[serde(default = "default_version")]
30 pub version: String,
31 /// Trigger command list (optional, e.g. "/review"). Empty = only system prompt injection.
32 #[serde(default)]
33 pub triggers: Vec<String>,
34 /// Required tools list (optional). If a required tool is unavailable, a warning is logged.
35 #[serde(default)]
36 pub tools_required: Vec<String>,
37 /// Whether this skill is enabled (optional, default true).
38 #[serde(default = "default_enabled")]
39 pub enabled: bool,
40}
41
42fn default_version() -> String {
43 "1.0.0".to_string()
44}
45
46fn default_enabled() -> bool {
47 true
48}
49
50// ============================================================================
51// Skill
52// ============================================================================
53
54/// A fully parsed skill with its frontmatter and markdown body content.
55#[derive(Debug, Clone)]
56pub struct Skill {
57 /// The parsed frontmatter metadata.
58 pub frontmatter: SkillFrontmatter,
59 /// The markdown body content (everything after the closing `---`).
60 pub content: String,
61 /// The source file path (for debugging and display).
62 pub source_path: PathBuf,
63}