stynx_code_skills/domain/
skill.rs1use std::path::PathBuf;
2use serde::Deserialize;
3
4#[derive(Debug, Clone, PartialEq, Eq, Hash)]
5pub struct SkillId(pub String);
6
7impl SkillId {
8 pub fn new(id: impl Into<String>) -> Self {
9 Self(id.into())
10 }
11
12 pub fn as_str(&self) -> &str {
13 &self.0
14 }
15}
16
17impl std::fmt::Display for SkillId {
18 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
19 write!(f, "{}", self.0)
20 }
21}
22
23#[derive(Debug, Clone, Deserialize)]
24pub struct SkillMetadata {
25 pub name: String,
26 #[serde(default)]
27 pub description: String,
28 #[serde(default)]
29 pub triggers: Vec<String>,
30 pub model: Option<String>,
31 #[serde(default)]
32 pub is_hidden: bool,
33}
34
35#[derive(Debug, Clone)]
36pub enum SkillSource {
37 UserSkill(PathBuf),
38 ProjectSkill(PathBuf),
39 Bundled,
40 Plugin(String),
41}
42
43#[derive(Debug, Clone)]
44pub struct Skill {
45 pub metadata: SkillMetadata,
46
47 pub content: String,
48 pub source: SkillSource,
49}
50
51impl Skill {
52
53 pub fn expand_template(&self, arguments: &str) -> String {
54 self.content.replace("{{ARGUMENTS}}", arguments)
55 }
56}