talos_skill/types.rs
1use serde::Deserialize;
2use std::path::PathBuf;
3
4/// Identifies where a skill was discovered.
5#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize, Default)]
6pub enum SkillSource {
7 /// `.talos/skills/` in the active workspace.
8 #[default]
9 Project,
10 /// Parent `.talos/skills/` directories (monorepo inheritance).
11 Parent,
12 /// `~/.talos/skills/` (user-global Talos-owned).
13 UserGlobal,
14 /// `~/.agents/skills/` (shared, opt-in).
15 Shared,
16}
17
18impl std::fmt::Display for SkillSource {
19 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
20 match self {
21 SkillSource::Project => write!(f, "project"),
22 SkillSource::Parent => write!(f, "parent"),
23 SkillSource::UserGlobal => write!(f, "user"),
24 SkillSource::Shared => write!(f, "shared"),
25 }
26 }
27}
28
29/// YAML frontmatter extracted from a SKILL.md file.
30///
31/// `name` and `description` are required. `triggers` is optional and defaults to
32/// an empty list. The frontmatter must appear between `---` delimiters at the
33/// start of the file.
34#[derive(Debug, Clone, Deserialize)]
35pub struct SkillFrontmatter {
36 /// Unique name identifier for the skill.
37 pub name: String,
38 /// Human-readable description of what the skill does.
39 pub description: String,
40 /// Keywords or patterns that activate this skill, or an empty list when omitted.
41 #[serde(default)]
42 pub triggers: Vec<String>,
43}
44
45/// A fully parsed skill with frontmatter metadata and Markdown body.
46#[derive(Debug, Clone)]
47pub struct Skill {
48 /// Unique name identifier for the skill.
49 pub name: String,
50 /// Human-readable description of what the skill does.
51 pub description: String,
52 /// Keywords or patterns that activate this skill.
53 pub triggers: Vec<String>,
54 /// Markdown instructions (body content after frontmatter).
55 pub body: String,
56 /// Absolute path to the source SKILL.md file.
57 pub source_path: PathBuf,
58 /// Where this skill was discovered from.
59 pub source: SkillSource,
60}
61
62/// Lightweight skill index entry for Level 0 progressive disclosure.
63///
64/// Contains only the metadata needed to inject into a system prompt,
65/// without loading the full Markdown body.
66#[derive(Debug, Clone)]
67pub struct SkillIndex {
68 /// Unique name identifier for the skill.
69 pub name: String,
70 /// Human-readable description of what the skill does.
71 pub description: String,
72 /// Keywords or patterns that activate this skill.
73 pub triggers: Vec<String>,
74 /// Estimated token count for this skill's Level 0 entry (name + description).
75 pub estimated_tokens: usize,
76 /// Where this skill was discovered from.
77 pub source: SkillSource,
78}
79
80/// Disclosure level for progressive skill loading.
81///
82/// Skills are loaded in three levels to minimize system prompt size:
83/// - **Level 0**: Name + description only — always present in the system prompt
84/// so the agent knows which skills are available (~50 tokens each).
85/// - **Level 1**: Full SKILL.md body — loaded on demand when the agent's task
86/// matches a skill's triggers.
87/// - **Level 2**: Specific reference files — loaded when the skill body
88/// references external files (e.g., templates, schemas, scripts).
89#[derive(Debug, Clone, Copy, PartialEq, Eq)]
90pub enum SkillDisclosure {
91 /// Name + description only (always loaded).
92 Level0,
93 /// Full SKILL.md body (loaded on demand when task matches triggers).
94 Level1,
95 /// Specific reference files (loaded when skill body references them).
96 Level2,
97}