Validate a skill slug. Returns None if OK, an error message if not. Rules: lowercase ``[a-z0-9-]``, no leading/trailing dash, no consecutive dashes, 1-64 characters. This matches the directory name we'll create under `` /output/skills/`` and the ``name:`` frontmatter field.
(name: str)
| 303 | |
| 304 | |
| 305 | def _validate_skill_name(name: str) -> str | None: |
| 306 | """Validate a skill slug. Returns None if OK, an error message if not. |
| 307 | |
| 308 | Rules: lowercase ``[a-z0-9-]``, no leading/trailing dash, no consecutive |
| 309 | dashes, 1-64 characters. This matches the directory name we'll create |
| 310 | under ``<kb>/output/skills/`` and the ``name:`` frontmatter field. |
| 311 | """ |
| 312 | if not name: |
| 313 | return "Skill name must not be empty." |
| 314 | if len(name) > 64: |
| 315 | return "Skill name must be at most 64 characters." |
| 316 | if not all(("a" <= c <= "z") or ("0" <= c <= "9") or c == "-" for c in name): |
| 317 | return "Skill name must contain only lowercase letters, digits, and dashes." |
| 318 | if name.startswith("-"): |
| 319 | return "Skill name must not have a leading dash." |
| 320 | if name.endswith("-"): |
| 321 | return "Skill name must not have a trailing dash." |
| 322 | if "--" in name: |
| 323 | return "Skill name must not contain consecutive dashes." |
| 324 | return None |
| 325 | |
| 326 | |
| 327 | def _preflight_skill_new(kb_dir: Path, name: str) -> str | None: |
no outgoing calls