feat: add browser script skill execution

This commit is contained in:
zyl
2026-03-30 02:15:07 +08:00
parent f7e2ff256e
commit d2c9902966
22 changed files with 1775 additions and 249 deletions

View File

@@ -53,13 +53,18 @@ class SkillLibValidationTest(unittest.TestCase):
if name == "office-export-xlsx":
self.assertIn("office", record.tags)
self.assertIn("xlsx", record.tags)
self.assertEqual(record.location, SKILLS_DIR / name / "SKILL.md")
expected_location = (
SKILLS_DIR / name / "SKILL.toml"
if name == "zhihu-hotlist"
else SKILLS_DIR / name / "SKILL.md"
)
self.assertEqual(record.location, expected_location)
self.assertTrue(record.prompt_body.lstrip().startswith("# "))
self.assertNotIn("\n---\n", record.prompt_body)
def test_each_skill_passes_audit_without_scripts(self):
def test_each_skill_passes_audit_with_current_script_policy(self):
for skill_dir in self.validator.discover_skill_dirs():
report = self.validator.audit_skill_directory(skill_dir, allow_scripts=False)
report = self.validator.audit_skill_directory(skill_dir, allow_scripts=True)
self.assertEqual(
report.findings,
[],
@@ -69,9 +74,15 @@ class SkillLibValidationTest(unittest.TestCase):
def test_current_packages_keep_required_structure(self):
for name in EXPECTED_SKILL_NAMES:
skill_dir = SKILLS_DIR / name
self.assertTrue((skill_dir / "SKILL.md").is_file())
self.assertTrue(
(skill_dir / "SKILL.md").is_file() or (skill_dir / "SKILL.toml").is_file()
)
self.assertTrue((skill_dir / "references").is_dir())
self.assertTrue((skill_dir / "assets").is_dir())
self.assertTrue((SKILLS_DIR / "zhihu-hotlist" / "SKILL.toml").is_file())
self.assertTrue(
(SKILLS_DIR / "zhihu-hotlist" / "scripts" / "extract_hotlist.js").is_file()
)
def test_each_skill_declares_superrpa_browser_contract(self):
for name in [name for name in EXPECTED_SKILL_NAMES if name.startswith("zhihu-")]:
@@ -106,7 +117,7 @@ class SkillLibValidationTest(unittest.TestCase):
self.assertIn("presentation", content)
def test_validate_all_skills_reports_pass(self):
results = self.validator.validate_all_skills(allow_scripts=False)
results = self.validator.validate_all_skills(allow_scripts=True)
self.assertEqual([result.record.name for result in results], EXPECTED_SKILL_NAMES)
self.assertTrue(all(result.ok for result in results))