Represents a file within a Skill directory. Attributes: name: File name (e.g., "SKILL.md", "script.py") type: File extension/type (e.g., ".md", ".py", ".js") path: Relative path within Skill directory required: Whether this file is required
| 22 | |
| 23 | @dataclass |
| 24 | class SkillFile: |
| 25 | """ |
| 26 | Represents a file within a Skill directory. |
| 27 | |
| 28 | Attributes: |
| 29 | name: File name (e.g., "SKILL.md", "script.py") |
| 30 | type: File extension/type (e.g., ".md", ".py", ".js") |
| 31 | path: Relative path within Skill directory |
| 32 | required: Whether this file is required |
| 33 | """ |
| 34 | name: str |
| 35 | type: str |
| 36 | path: Path |
| 37 | required: bool = False |
| 38 | |
| 39 | def __post_init__(self): |
| 40 | """ |
| 41 | Validate file attributes after initialization. |
| 42 | |
| 43 | Raises: |
| 44 | ValueError: If file attributes are invalid |
| 45 | """ |
| 46 | if not self.name: |
| 47 | raise ValueError('File name cannot be empty') |
| 48 | if not self.type: |
| 49 | raise ValueError('File type cannot be empty') |
| 50 | |
| 51 | def to_dict(self): |
| 52 | """ |
| 53 | Convert SkillFile to dictionary representation. |
| 54 | |
| 55 | Returns: |
| 56 | Dictionary containing file information |
| 57 | """ |
| 58 | return { |
| 59 | 'name': self.name, |
| 60 | 'type': self.type, |
| 61 | 'path': str(self.path), |
| 62 | 'required': self.required |
| 63 | } |
| 64 | |
| 65 | |
| 66 | @dataclass |
no outgoing calls