Load a skill from a file
(path: impl AsRef<Path>)
| 162 | |
| 163 | /// Load a skill from a file |
| 164 | pub fn from_file(path: impl AsRef<Path>) -> anyhow::Result<Self> { |
| 165 | let content = std::fs::read_to_string(path.as_ref())?; |
| 166 | let mut skill = |
| 167 | Self::parse(&content).ok_or_else(|| anyhow::anyhow!("Failed to parse skill file"))?; |
| 168 | |
| 169 | // Use filename as name if not specified |
| 170 | if skill.name.is_empty() { |
| 171 | if let Some(stem) = path.as_ref().file_stem() { |
| 172 | skill.name = stem.to_string_lossy().to_string(); |
| 173 | } |
| 174 | } |
| 175 | |
| 176 | Ok(skill) |
| 177 | } |
| 178 | |
| 179 | /// Parse allowed tools into a set of tool permissions |
| 180 | /// |