feat: platform-conditional skill loading + Apple/macOS skills
Add a 'platforms' field to SKILL.md frontmatter that restricts skills to specific operating systems. Skills with platforms: [macos] only appear in the system prompt, skills_list(), and slash commands on macOS. Skills without the field load everywhere (backward compatible). Implementation: - skill_matches_platform() in tools/skills_tool.py — core filter - Wired into all 3 discovery paths: prompt_builder.py, skills_tool.py, skill_commands.py - 28 new tests across 3 test files New bundled Apple/macOS skills (all platforms: [macos]): - imessage — Send/receive iMessages via imsg CLI - apple-reminders — Manage Reminders via remindctl CLI - apple-notes — Manage Notes via memo CLI - findmy — Track devices/AirTags via AppleScript + screen capture Docs updated: CONTRIBUTING.md, AGENTS.md, creating-skills.md, skills.md (user guide)
This commit is contained in:
parent
74fe1e2254
commit
f668e9fc75
15 changed files with 803 additions and 2 deletions
|
|
@ -165,6 +165,52 @@ class TestBuildSkillsSystemPrompt:
|
|||
# "search" should appear only once per category
|
||||
assert result.count("- search") == 1
|
||||
|
||||
def test_excludes_incompatible_platform_skills(self, monkeypatch, tmp_path):
|
||||
"""Skills with platforms: [macos] should not appear on Linux."""
|
||||
monkeypatch.setenv("HERMES_HOME", str(tmp_path))
|
||||
skills_dir = tmp_path / "skills" / "apple"
|
||||
skills_dir.mkdir(parents=True)
|
||||
|
||||
# macOS-only skill
|
||||
mac_skill = skills_dir / "imessage"
|
||||
mac_skill.mkdir()
|
||||
(mac_skill / "SKILL.md").write_text(
|
||||
"---\nname: imessage\ndescription: Send iMessages\nplatforms: [macos]\n---\n"
|
||||
)
|
||||
|
||||
# Universal skill
|
||||
uni_skill = skills_dir / "web-search"
|
||||
uni_skill.mkdir()
|
||||
(uni_skill / "SKILL.md").write_text(
|
||||
"---\nname: web-search\ndescription: Search the web\n---\n"
|
||||
)
|
||||
|
||||
from unittest.mock import patch
|
||||
with patch("tools.skills_tool.sys") as mock_sys:
|
||||
mock_sys.platform = "linux"
|
||||
result = build_skills_system_prompt()
|
||||
|
||||
assert "web-search" in result
|
||||
assert "imessage" not in result
|
||||
|
||||
def test_includes_matching_platform_skills(self, monkeypatch, tmp_path):
|
||||
"""Skills with platforms: [macos] should appear on macOS."""
|
||||
monkeypatch.setenv("HERMES_HOME", str(tmp_path))
|
||||
skills_dir = tmp_path / "skills" / "apple"
|
||||
mac_skill = skills_dir / "imessage"
|
||||
mac_skill.mkdir(parents=True)
|
||||
(mac_skill / "SKILL.md").write_text(
|
||||
"---\nname: imessage\ndescription: Send iMessages\nplatforms: [macos]\n---\n"
|
||||
)
|
||||
|
||||
from unittest.mock import patch
|
||||
with patch("tools.skills_tool.sys") as mock_sys:
|
||||
mock_sys.platform = "darwin"
|
||||
result = build_skills_system_prompt()
|
||||
|
||||
assert "imessage" in result
|
||||
assert "Send iMessages" in result
|
||||
|
||||
|
||||
# =========================================================================
|
||||
# Context files prompt builder
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue