Parse a Skill directory and create a SkillSchema. Args: directory_path: Path to Skill directory Returns: SkillSchema if valid, None otherwise
(directory_path: Path)
| 245 | |
| 246 | @staticmethod |
| 247 | def parse_skill_directory(directory_path: Path) -> Optional[SkillSchema]: |
| 248 | """ |
| 249 | Parse a Skill directory and create a SkillSchema. |
| 250 | |
| 251 | Args: |
| 252 | directory_path: Path to Skill directory |
| 253 | |
| 254 | Returns: |
| 255 | SkillSchema if valid, None otherwise |
| 256 | """ |
| 257 | if not directory_path.exists() or not directory_path.is_dir(): |
| 258 | return None |
| 259 | |
| 260 | # Read SKILL.md |
| 261 | skill_md_path = directory_path / 'SKILL.md' |
| 262 | if not skill_md_path.exists(): |
| 263 | return None |
| 264 | |
| 265 | with open(skill_md_path, 'r', encoding='utf-8') as f: |
| 266 | content = f.read() |
| 267 | |
| 268 | # Parse metadata |
| 269 | frontmatter = SkillSchemaParser.parse_yaml_frontmatter(content) |
| 270 | if not frontmatter or 'name' not in frontmatter or 'description' not in frontmatter: |
| 271 | return None |
| 272 | |
| 273 | # Generate skill_id from directory name |
| 274 | skill_id = directory_path.name |
| 275 | |
| 276 | # Collect all files |
| 277 | files = [] |
| 278 | scripts = [] |
| 279 | references = [] |
| 280 | resources = [] |
| 281 | |
| 282 | for file_path in directory_path.rglob('*'): |
| 283 | if file_path.is_file(): |
| 284 | if SkillSchemaParser.is_ignored_path(file_path): |
| 285 | continue |
| 286 | |
| 287 | file_type = file_path.suffix if file_path.suffix else '.unknown' |
| 288 | |
| 289 | skill_file = SkillFile( |
| 290 | name=file_path.name, |
| 291 | type=file_type, |
| 292 | path=file_path, |
| 293 | required=(file_path.name == 'SKILL.md')) |
| 294 | files.append(skill_file) |
| 295 | |
| 296 | # Get scripts, references and resources |
| 297 | if skill_file.type in SUPPORTED_SCRIPT_EXT: |
| 298 | scripts.append(skill_file) |
| 299 | elif skill_file.type in ['.md' |
| 300 | ] and skill_file.name != 'SKILL.md': |
| 301 | references.append(skill_file) |
| 302 | else: |
| 303 | resources.append(skill_file) |
| 304 |
no test coverage detected