feat(commit-message): bundle policy and validator

This commit is contained in:
csh
2026-07-22 17:26:20 +08:00
parent d83707de23
commit 38ea8caaeb
4 changed files with 738 additions and 75 deletions
+33 -13
View File
@@ -52,10 +52,11 @@ def copy_subtree_source(destination: Path) -> None:
)
(destination / "skills").mkdir()
shutil.copytree(
ROOT / "skills" / "style-cleanup",
destination / "skills" / "style-cleanup",
)
for name in ("commit-message",):
shutil.copytree(
ROOT / "skills" / name,
destination / "skills" / name,
)
def write_config(project_root: Path, install_mode: str, playbook_root: Path) -> Path:
@@ -86,7 +87,7 @@ no_backup = true
[install_skills]
agents_home = ".test-agents"
mode = "list"
skills = ["style-cleanup"]
skills = ["commit-message"]
no_backup = true
""".lstrip(),
encoding="utf-8",
@@ -153,7 +154,9 @@ class PlaybookDeploymentTests(unittest.TestCase):
".agents/index.md",
".agents/tsl/index.md",
".agents/markdown/index.md",
".test-agents/skills/style-cleanup/SKILL.md",
".test-agents/skills/commit-message/SKILL.md",
".test-agents/skills/commit-message/references/commit_policy.json",
".test-agents/skills/commit-message/scripts/validate_commit_message.py",
)
missing = [
path
@@ -189,14 +192,31 @@ class PlaybookDeploymentTests(unittest.TestCase):
)
self.assertIn(f"- {docs_prefix}", agents_index)
installed_skill = (
project_root
/ ".test-agents/skills/style-cleanup/SKILL.md"
).read_text(encoding="utf-8")
self.assertIn(
f"`{docs_prefix}/tsl/code_style.md`", installed_skill
source_skill = ROOT / "skills" / "commit-message"
installed_commit_skill = (
project_root / ".test-agents/skills/commit-message"
)
self.assertEqual(
(installed_commit_skill / "SKILL.md").read_text(encoding="utf-8"),
(source_skill / "SKILL.md").read_text(encoding="utf-8"),
)
self.assertEqual(
(
installed_commit_skill / "references/commit_policy.json"
).read_text(encoding="utf-8"),
(source_skill / "references/commit_policy.json").read_text(
encoding="utf-8"
),
)
self.assertEqual(
(
installed_commit_skill
/ "scripts/validate_commit_message.py"
).read_text(encoding="utf-8"),
(
source_skill / "scripts/validate_commit_message.py"
).read_text(encoding="utf-8"),
)
self.assertNotIn("`docs/tsl/code_style.md`", installed_skill)
rules_text = (project_root / "AGENT_RULES.md").read_text(
encoding="utf-8"