Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ jobs:
- run: pnpm install --frozen-lockfile
- run: pnpm test
- run: python -m pip install -r skills/skillhone/assets/requirements.txt
- run: python .test/test_static_check_name.py
- run: python skills/skillhone/scripts/quality/static_check.py skills/skillhone
- run: python skills/skillhone/scripts/quality/static_check.py skills/skillhone-auto-optimization
- run: node dist/cli.js --help
Expand Down
50 changes: 50 additions & 0 deletions .test/test_static_check_name.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
"""Regression test for Agent Skills name validation."""
from __future__ import annotations

import importlib.util
import tempfile
import unittest
from pathlib import Path


REPOSITORY_ROOT = Path(__file__).resolve().parents[1]
CHECKER_PATH = (
REPOSITORY_ROOT
/ "skills"
/ "skillhone"
/ "scripts"
/ "quality"
/ "static_check.py"
)
SPEC = importlib.util.spec_from_file_location("skillhone_static_check", CHECKER_PATH)
assert SPEC is not None and SPEC.loader is not None
STATIC_CHECK = importlib.util.module_from_spec(SPEC)
SPEC.loader.exec_module(STATIC_CHECK)


class SkillNameValidationTest(unittest.TestCase):
def check_name(self, name: str) -> set[str]:
with tempfile.TemporaryDirectory() as temporary_directory:
skill_directory = Path(temporary_directory) / name
skill_directory.mkdir()
(skill_directory / "SKILL.md").write_text(
"---\n"
f"name: {name}\n"
"description: Minimal Skill name fixture.\n"
"---\n",
encoding="utf-8",
)

report = STATIC_CHECK.check(skill_directory)

return {error["kind"] for error in report.errors}

def test_consecutive_hyphens_are_rejected(self) -> None:
self.assertIn("invalid_name", self.check_name("pdf--processing"))

def test_single_hyphens_remain_valid(self) -> None:
self.assertNotIn("invalid_name", self.check_name("pdf-processing"))


if __name__ == "__main__":
unittest.main()
2 changes: 1 addition & 1 deletion skills/skillhone/scripts/quality/static_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
MAX_DESC_LEN = 1024
MAX_COMPAT_LEN = 500
RECOMMENDED_BODY_LINES = 500
NAME_RE = re.compile(r"^[a-z0-9]([a-z0-9-]*[a-z0-9])?$")
NAME_RE = re.compile(r"^(?!.*--)[a-z0-9]([a-z0-9-]*[a-z0-9])?$")
ALLOWED_FRONTMATTER = {
"name", "description", "license",
"allowed-tools", "metadata", "compatibility",
Expand Down