| 193 | } |
| 194 | |
| 195 | fn sample_skill_files(skill: &SkillInfo, limit: usize) -> Vec<PathBuf> { |
| 196 | let Some(base_dir) = skill.location.parent() else { |
| 197 | return Vec::new(); |
| 198 | }; |
| 199 | |
| 200 | let mut files: Vec<PathBuf> = WalkDir::new(base_dir) |
| 201 | .follow_links(false) |
| 202 | .into_iter() |
| 203 | .filter_map(Result::ok) |
| 204 | .filter(|entry| entry.file_type().is_file()) |
| 205 | .map(|entry| entry.path().to_path_buf()) |
| 206 | .filter(|path| { |
| 207 | path.file_name() |
| 208 | .and_then(|name| name.to_str()) |
| 209 | .map(|name| name != "SKILL.md") |
| 210 | .unwrap_or(false) |
| 211 | }) |
| 212 | .collect(); |
| 213 | files.sort(); |
| 214 | files.truncate(limit); |
| 215 | files |
| 216 | } |
| 217 | |
| 218 | #[async_trait] |
| 219 | impl Tool for SkillTool { |