1use serde::{Deserialize, Serialize};
2use std::path::PathBuf;
3
4#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5#[serde(default)]
6pub struct SkillFrontmatter {
7 pub name: String,
8 pub description: String,
9 pub tags: Vec<String>,
10}
11
12#[derive(Debug, Clone)]
13pub struct ParsedSkill {
14 pub name: String,
15 pub description: String,
16 pub tags: Vec<String>,
17 pub body: String,
18}
19
20#[derive(Debug, Clone, Serialize)]
21pub struct SkillDocument {
22 pub id: String,
23 pub name: String,
24 pub description: String,
25 pub tags: Vec<String>,
26 pub body: String,
27 pub path: PathBuf,
28 pub hash: String,
29 pub last_modified: Option<i64>,
30}
31
32#[derive(Debug, Clone, Serialize)]
33pub struct SkillSummary {
34 pub id: String,
35 pub name: String,
36 pub description: String,
37 pub tags: Vec<String>,
38 pub path: PathBuf,
39 pub hash: String,
40 pub last_modified: Option<i64>,
41}
42
43impl From<&SkillDocument> for SkillSummary {
44 fn from(value: &SkillDocument) -> Self {
45 Self {
46 id: value.id.clone(),
47 name: value.name.clone(),
48 description: value.description.clone(),
49 tags: value.tags.clone(),
50 path: value.path.clone(),
51 hash: value.hash.clone(),
52 last_modified: value.last_modified,
53 }
54 }
55}
56
57#[derive(Debug, Clone, Default)]
58pub struct SkillIndex {
59 skills: Vec<SkillDocument>,
60}
61
62impl SkillIndex {
63 pub fn new(skills: Vec<SkillDocument>) -> Self {
64 Self { skills }
65 }
66
67 pub fn is_empty(&self) -> bool {
68 self.skills.is_empty()
69 }
70
71 pub fn len(&self) -> usize {
72 self.skills.len()
73 }
74
75 pub fn skills(&self) -> &[SkillDocument] {
76 &self.skills
77 }
78
79 pub fn summaries(&self) -> Vec<SkillSummary> {
80 self.skills.iter().map(SkillSummary::from).collect()
81 }
82}
83
84#[derive(Debug, Clone)]
85pub struct SelectionPolicy {
86 pub top_k: usize,
87 pub min_score: f32,
88 pub include_tags: Vec<String>,
89 pub exclude_tags: Vec<String>,
90}
91
92impl Default for SelectionPolicy {
93 fn default() -> Self {
94 Self { top_k: 1, min_score: 1.0, include_tags: Vec::new(), exclude_tags: Vec::new() }
95 }
96}
97
98#[derive(Debug, Clone, Serialize)]
99pub struct SkillMatch {
100 pub score: f32,
101 pub skill: SkillSummary,
102}