MCPcopy Create free account
hub / github.com/VectifyAI/OpenKB / _validate_skill_name

Function _validate_skill_name

openkb/cli.py:305–324  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

303
304
305def _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
327def _preflight_skill_new(kb_dir: Path, name: str) -> str | None:

Callers 5

_preflight_skill_newFunction · 0.85
skill_historyFunction · 0.85
skill_rollbackFunction · 0.85

Calls

no outgoing calls

Tested by 2