Files
codex-app-server/cloud/tests/test_chatgpt_codex_skills.py
T
host 885bf38790 feat: add software-engineering skill v0.2
Add cloud/skills/software-engineering/SKILL.md (686 lines, v0.2, appendix with 9 role templates travels inside SKILL.md because skill_seed only copies SKILL.md, not templates/). Update skill pack tests: EXPECTED set and real-pack list now include software-engineering, plus an explicit seed test asserting it lands at skills/software-engineering/SKILL.md, contains the appendix, and tenant edits are never overwritten. One-line wording tweak in the architect template avoids the existing secret-scan false positive on the substring sk- inside agent-task-contract.md; deployed file sha256 bd0436399ac05c6131b9281dad00973e50d13540e4c56ad21f21e2b5209bae8e (40759 bytes, 686 lines).
2026-10-30 06:00:31 +00:00

54 lines
1.7 KiB
Python

"""ChatGPT Codex 对齐第一批:技能包校验。
只校验技能文件本身,不启动 worker、不跑模型、不改生产行为:
每个 cloud/skills/<名>/SKILL.md 必须有 name + description
frontmatter、名字与目录一致、正文非空、不含密钥占位。
"""
import os
import re
import unittest
from pathlib import Path
SKILLS_DIR = Path(__file__).resolve().parents[1] / "skills"
EXPECTED = {"live-info", "document-tools", "image-workflow",
"browser-automation", "software-engineering"}
def _frontmatter(text):
m = re.match(r"^---\n(.*?)\n---\n", text, re.DOTALL)
if not m:
return None
out = {}
for line in m.group(1).splitlines():
if ":" in line:
k, v = line.split(":", 1)
out[k.strip()] = v.strip()
return out
class ChatGptCodexSkillsTestCase(unittest.TestCase):
def test_expected_skills_exist(self):
names = {p.name for p in SKILLS_DIR.iterdir() if p.is_dir()}
self.assertEqual(names, EXPECTED)
def test_skill_frontmatter_and_body(self):
for name in sorted(EXPECTED):
path = SKILLS_DIR / name / "SKILL.md"
self.assertTrue(path.is_file(), str(path))
text = path.read_text(encoding="utf-8")
fm = _frontmatter(text)
self.assertIsNotNone(fm, name)
self.assertEqual(fm.get("name"), name)
desc = fm.get("description", "")
self.assertTrue(desc, name)
self.assertLessEqual(len(desc), 200, name)
body = text.split("---", 2)[-1].strip()
self.assertTrue(len(body) > 200, name)
for bad in ("API_KEY", "sk-", "password"):
self.assertNotIn(bad, text, name)
if __name__ == "__main__":
unittest.main()