Files
hermes-agent/tests/agent/test_skill_session_platform_gate.py
Teknium c49fa88b80 refactor(skills): shipped-set slim — 15 to optional, github 6-way merge, pdf absorbs OCR, channel-gated teams pipeline (index −26%) (#98539)
* refactor(skills): shipped-set slim — 15 skills to optional, github six-way merge, pdf absorbs OCR+nano-pdf, channel-gated teams pipeline

Maintainer-directed shipped-skills curation (skills index 1,900 -> ~1,400
tok/call on desktop; every session pays the index, so this is a per-call
diet on all installs):

- optional-skills moves (installable via skills hub, history preserved):
  creative comfyui/ascii-art/excalidraw/pretext/sketch/touchdesigner-mcp;
  ALL of mlops (huggingface-hub, llama-cpp, serving-llms-vllm,
  weights-and-biases, evaluating-llms-harness — subcategory structure
  kept); research-paper-writing (55 supporting files, 17.3K-tok load);
  openhue; blogwatcher (first taught the cronjob monitor-field watch
  pattern + web_extract instead of pre-cron manual workflows)
- DELETED session-librarian (Aug-12 'inspired by Perplexity Computer'
  port, never maintainer-intended; session_search covers discovery)
- github: six skills (auth, issues, pr-workflow, issue-to-pr,
  code-review, repo-management) merged into ONE software-development/
  github skill — routing body + complete per-workflow references;
  benbarclay authorship credited; codebase-inspection rides along;
  discipline pins from test_github_issue_to_pr_skill.py preserved
  against the reference body in the new test_github_skill.py
- pdf absorbs ocr-and-documents + nano-pdf as references/ + scripts
  (extract_pymupdf, extract_marker converted to the argparse house
  standard its contract test enforces)
- NEW session_platforms frontmatter gate (metadata.hermes): hides a
  skill from the index on gateway channels it is not for; fail-open on
  unknown platform; teams-meeting-pipeline gated to [teams, cron]
- blocked-page-recovery: research -> new web category; trigger-first
  description ('Use when a fetch fails: 403/429, paywall, WAF, bot
  wall.') so the model actually reaches for it on blocked fetches
- docs regenerated via generate-skill-docs.py (195 pages); related_skills
  swept repo-wide; tests: 1672 passed (2 openclaw failures pre-existing
  on clean main, Windows-local)

* chore: ignore .skills_prompt_snapshot.json (local index cache, accidentally committed)
2026-08-30 04:53:39 -07:00

49 lines
2.2 KiB
Python

"""The session_platforms frontmatter gate (skills-index slim PR).
A skill whose metadata.hermes.session_platforms names gateway channels is
hidden from the skills index on every other channel; unknown platform
fails OPEN (offline builds/tests must not hide skills).
"""
from agent.prompt_builder import _skill_should_show
from agent.skill_utils import extract_skill_conditions
def _conds(platforms):
return extract_skill_conditions(
{"metadata": {"hermes": {"session_platforms": platforms}}}
)
class TestSessionPlatformGate:
def test_hidden_on_other_channel(self):
assert _skill_should_show(_conds(["teams", "cron"]), {"terminal"}, set(), "desktop") is False
assert _skill_should_show(_conds(["teams", "cron"]), {"terminal"}, set(), "telegram") is False
def test_shown_on_named_channel(self):
assert _skill_should_show(_conds(["teams", "cron"]), {"terminal"}, set(), "teams") is True
assert _skill_should_show(_conds(["teams", "cron"]), {"terminal"}, set(), "cron") is True
def test_case_insensitive(self):
assert _skill_should_show(_conds(["Teams"]), {"terminal"}, set(), "TEAMS") is True
def test_unknown_platform_fails_open(self):
assert _skill_should_show(_conds(["teams"]), {"terminal"}, set(), None) is True
assert _skill_should_show(_conds(["teams"]), {"terminal"}, set(), "") is True
def test_empty_list_visible_everywhere(self):
assert _skill_should_show(_conds([]), {"terminal"}, set(), "desktop") is True
def test_gate_runs_even_without_tool_info(self):
# The channel gate is independent of tool-filtering backward compat.
assert _skill_should_show(_conds(["teams"]), None, None, "desktop") is False
def test_teams_meeting_pipeline_carries_the_gate(self):
from pathlib import Path
import re, yaml
p = Path(__file__).resolve().parents[2] / "skills" / "productivity" / "teams-meeting-pipeline" / "SKILL.md"
content = p.read_text(encoding="utf-8")
m = re.search(r"\n---\s*\n", content[3:])
fm = yaml.safe_load(content[3 : m.start() + 3])
assert fm["metadata"]["hermes"]["session_platforms"] == ["teams", "cron"]