From a05717221603d6d8b59f5eed3dedf00ed2c89591 Mon Sep 17 00:00:00 2001 From: Christopher Kevin Date: Fri, 13 Nov 2026 22:06:53 +0000 Subject: [PATCH 1/6] feat(harness): flag descriptions harnesses drop, cut or hide Signed-off-by: Christopher Kevin --- CHANGELOG.md | 6 ++ docs/tier1-validation.mdx | 3 + src/skillevaluator/constants.py | 8 +++ src/skillevaluator/harness/__init__.py | 2 + src/skillevaluator/harness/overlay.py | 32 +++++++++- .../harness/profiles/claude-code.yaml | 2 + .../harness/profiles/codex.yaml | 2 + .../harness/profiles/copilot-cli.yaml | 4 ++ .../harness/profiles/hermes.yaml | 3 + .../harness/profiles/openclaw.yaml | 2 + .../harness/profiles/opencode.yaml | 3 + src/skillevaluator/harness/report.py | 26 ++++++++ src/skillevaluator/validators/schema.py | 37 ++++++++++- tests/golden/test_policy_behavior.py | 2 +- tests/harness/test_overlay.py | 63 +++++++++++++++++++ tests/test_commands.py | 7 +++ tests/validators/test_schema.py | 35 ++++++++++- 17 files changed, 231 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 92c6687db..25c3ed66d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,12 @@ All notable changes to SkillEvaluator are documented in this file. ### Added +- `harness` rules for descriptions: missing or empty descriptions, Claude Code and + Codex listing cuts, Copilot CLI's 1,024 UTF-16 unit limit, quotes escaped in the + Copilot CLI and OpenClaw lists, and Hermes's 60-character listing; `-v` shows + the description each harness lists. Tier 1 `schema` now reports a description + over 1,024 UTF-16 units (MEDIUM) and no "Use when ..." trigger in its first 60 + characters (LOW). - `harness` rules for frontmatter parsing: duplicate keys and tab indentation (strict YAML parsers drop the skill), a UTF-8 BOM (Codex), no front matter (Copilot CLI) and long custom frontmatter that never reaches the model. Tier 1 diff --git a/docs/tier1-validation.mdx b/docs/tier1-validation.mdx index e8d40b727..a56ee063b 100644 --- a/docs/tier1-validation.mdx +++ b/docs/tier1-validation.mdx @@ -259,6 +259,7 @@ For `validate`, the default set is `schema`, `version`, `security`, `pii`, `lice - `SKILL.md` should stay at or below 500 lines; larger files receive an advisory finding. - Harness portability: patterns the spec allows but common agent harnesses (Claude Code, Codex, OpenCode, OpenClaw, Hermes, Copilot CLI) load differently are reported; override any of them with `SCHEMA.` in the validation policy. - A duplicate frontmatter key is HIGH (`duplicate_key`; several harnesses drop the skill), and a UTF-8 BOM is MEDIUM (`manifest_bom`). + - A description within 1,024 characters but over 1,024 UTF-16 units is MEDIUM (`description_utf16_length`), and no "Use when ..." trigger in the first 60 characters is LOW (`description_trigger`). - `metadata.author` is optional under the `default` profile. Use `Name ` to include a contact address, or a person, team, or organization name such as `NVIDIA cuOpt Team` or `Jane Doe (@jdoe)`. A value that is malformed or unsafe is a HIGH `author_format` finding: a bare email or an email outside `Name `, stray angle brackets, control, private-use, or bidirectional formatting characters (joiners such as ZWNJ and ZWJ, which Persian, Arabic and Devanagari names need, are accepted), no letters or digits, or more than 256 characters. A bare address counts even when its domain has no dot (`root@buildhost`), while a social handle such as `Jane Doe (@jdoe)` does not. The `registry` profile requires the `Name ` form. - `metadata.id` is an optional stable skill ID. When present it must be an exact 1–64 character lowercase ASCII slug (`^[a-z0-9]+(-[a-z0-9]+)*$`, no surrounding whitespace); it may differ from `name`. A collection run reports an ID that more than one discovered skill declares; `validate` on a catalog also lists these in `catalog-summary.json` under `metadata_id_conflicts`. Under `registry` a shared ID blocks: the run exits nonzero, and each sharing skill's entry is `"passed": false` with the conflict repeated under `catalog_findings` and counted in its `severity_counts`. A catalog validates each skill on its own, so that skill's own report was written before the catalog-wide check ran and keeps its single-skill verdict, which the entry carries alongside as `report_verdict` beside `report_scope: "single_skill"`. Uniqueness is checked only across the skills validated together, never against a registry, and a single-skill run does not claim it. The ID does not change local catalog identity, which stays keyed by content type and relative path. - `metadata.domain` accepts one category string or a list of them, such as `domain: [backend, ai-ml]`. Values are trimmed and deduplicated in order; a blank or null scalar means no domain. A list with more than 16 entries, or a non-string, blank, or over-128-character entry, is a HIGH `Field 'metadata.domain'` finding. The 128-character limit also applies to a single string. @@ -276,6 +277,8 @@ For `validate`, the default set is `schema`, `version`, `security`, `pii`, `lice `validate` also shows a "Harness compatibility" panel after Tier 1, `! harness` in the checks line when a harness drops or degrades the skill, a `harness` line in the Tier 1 summary (kept out of the advisories count) and a note in the result box. `skillevaluator harness-check ` runs only this check and shows the same panel, updated as each harness is checked. It accepts a folder of skills, `--harness`, `-v` and `--json PATH`, always exits 0, and points to `validate --tiers 1` when Tier 1 schema also fails. By default the panel is compact: one line per harness with its most serious finding (not loaded, then degraded, then note; ties go to the rule listed first in the profile) labelled with its outcome (`not found`, `rejected`, `listing shortened`, `delivery truncated` and so on), then `+N more` and the number of notes. `-v` (also on `validate`) lists every finding with its fix and each harness's verified version. Frontmatter rules: duplicate keys (Codex, Copilot CLI, OpenClaw and OpenCode drop the skill), tab indentation (Codex, Copilot CLI and OpenClaw), a UTF-8 BOM (Codex), no front matter (Copilot CLI), and long custom frontmatter that never reaches the model. + + Description rules: missing or empty descriptions, Claude Code and Codex listing cuts, Copilot CLI's 1,024 UTF-16 unit limit, quotes escaped in the Copilot CLI and OpenClaw lists, and Hermes's 60-character listing. `-v` also shows the description each harness puts in the model's skill list. diff --git a/src/skillevaluator/constants.py b/src/skillevaluator/constants.py index 1df0b2cfd..685247dce 100644 --- a/src/skillevaluator/constants.py +++ b/src/skillevaluator/constants.py @@ -156,6 +156,14 @@ # Skill manifest file name variants (case-insensitive search) SKILL_MANIFEST_VARIANTS = ("SKILL.md", "skill.md") +# Some harnesses show only the first ~60 characters of each description in +# their skill list, so the "when to use" trigger should appear within it. +DESCRIPTION_TRIGGER_WINDOW = 60 +DESCRIPTION_TRIGGER_PATTERN = ( + r"\buse (?:this (?:skill )?|it )?(?:when|for|to|if|whenever)\b" + r"|\bwhen (?:the user|a user|you|asked)\b|\btriggers?\b" +) + # Banned/deprecated packages BANNED_PACKAGES = [ "subprocess32", # Use subprocess from stdlib diff --git a/src/skillevaluator/harness/__init__.py b/src/skillevaluator/harness/__init__.py index 9d79ce1c8..07472d2c9 100644 --- a/src/skillevaluator/harness/__init__.py +++ b/src/skillevaluator/harness/__init__.py @@ -14,6 +14,7 @@ evaluate_harnesses, evaluate_profile, facts_for, + listed_description, load_profiles, model_config, skill_facts, @@ -25,6 +26,7 @@ "evaluate_harnesses", "evaluate_profile", "facts_for", + "listed_description", "load_profiles", "model_config", "skill_facts", diff --git a/src/skillevaluator/harness/overlay.py b/src/skillevaluator/harness/overlay.py index 98d114fc7..c6616aa11 100644 --- a/src/skillevaluator/harness/overlay.py +++ b/src/skillevaluator/harness/overlay.py @@ -12,13 +12,14 @@ import yaml -from skillevaluator.constants import SKILL_MANIFEST_VARIANTS +from skillevaluator.constants import DESCRIPTION_TRIGGER_PATTERN, SKILL_MANIFEST_VARIANTS from skillevaluator.validators.frontmatter_parser import FRONTMATTER_PATTERN from skillevaluator.validators.schema import _duplicate_frontmatter_keys PROFILES_DIR = Path(__file__).parent / "profiles" HARNESS_STATUSES = ("loads", "degraded", "not_loaded") _EFFECT_RANK = {"advisory": 0, "degraded": 1, "not_loaded": 2} +_TRIGGER_RE = re.compile(DESCRIPTION_TRIGGER_PATTERN, re.IGNORECASE) _CLAUDE_ONLY_FIELDS = ( "argument-hint", "when_to_use", @@ -67,9 +68,11 @@ class HarnessResult: version: str verified_date: str findings: list[dict[str, str]] = field(default_factory=list) + listed: dict[str, Any] = field(default_factory=dict) def to_dict(self) -> dict[str, Any]: return { + "listed": self.listed, "harness": self.harness, "display_name": self.display_name, "status": self.status, @@ -160,20 +163,31 @@ def skill_facts(skill_path: Path) -> dict[str, Any]: """Compute the facts profile rules refer to.""" manifest, raw, text, fm_yaml, data = _read_manifest(skill_path) description = data.get("description") + trigger = _TRIGGER_RE.search(description) if isinstance(description, str) else None root, depth = _install_root(skill_path) custom = {k: v for k, v in data.items() if str(k) not in _KNOWN_FIELDS} name = _skill_name(skill_path, data) return { "skill_name": name, + "description_text": description if isinstance(description, str) else "", "install_root": root, "grouping_depth": depth, "frontmatter_missing": manifest.is_file() and FRONTMATTER_PATTERN.match(text) is None, + "description_missing": "description" not in data, + "description_empty": isinstance(description, str) and not description.strip(), "description_type": type(description).__name__ if description is not None else "none", + "description_codepoints": len(description) if isinstance(description, str) else 0, + "description_has_quote": isinstance(description, str) and '"' in description, + "description_utf16_units": len(description.encode("utf-16-le")) // 2 if isinstance(description, str) else 0, + "trigger_offset": trigger.start() if trigger else None, + "name_missing": "name" not in data, "frontmatter_bom": raw.startswith(b"\xef\xbb\xbf"), "frontmatter_duplicate_keys": bool(_duplicate_frontmatter_keys(fm_yaml)), "frontmatter_tab_indent": _tab_indent_breaks_yaml(fm_yaml), "custom_fields": ", ".join(map(str, custom)), "custom_field_chars": sum(len(v) if isinstance(v, str) else len(yaml.safe_dump(v)) for v in custom.values()), + "description_over": max(0, (len(description) if isinstance(description, str) else 0) - 1024), + "utf16_over": max(0, (len(description.encode("utf-16-le")) // 2 if isinstance(description, str) else 0) - 1024), } @@ -182,6 +196,21 @@ def facts_for(skills: list[Path]) -> dict[Path, dict[str, Any]]: return {skill: skill_facts(skill) for skill in skills} +def listed_description(profile: dict[str, Any], facts: dict[str, Any]) -> dict[str, Any]: + """What the profile says this harness puts in the model's skill list for the description.""" + listing = profile.get("listing") or {} + text = facts["description_text"] + limit = listing.get("drop_over_utf16") + if limit and facts["description_utf16_units"] > limit: + return {"mode": "dropped", "text": ""} + if not text or (listing.get("name_only_over") and len(text) > listing["name_only_over"]): + return {"mode": "name_only", "text": ""} + cut = listing.get("cut") + if cut and len(text) > cut: + return {"mode": "cut", "text": text[:cut], "limit": cut} + return {"mode": "full", "text": text} + + class _Rule: _ALLOWED = ( ast.Expression, @@ -320,6 +349,7 @@ def evaluate_profile( version=str(verified.get("version", "")), verified_date=str(verified.get("date", "")), findings=findings, + listed=listed_description(profile, facts), ) diff --git a/src/skillevaluator/harness/profiles/claude-code.yaml b/src/skillevaluator/harness/profiles/claude-code.yaml index f3a722517..6a51dab32 100644 --- a/src/skillevaluator/harness/profiles/claude-code.yaml +++ b/src/skillevaluator/harness/profiles/claude-code.yaml @@ -8,6 +8,8 @@ roots: listing: {cut: 1536} rules: - {id: CC-ROOT, when: "install_root not in roots", effect: not_loaded, outcome: not found, message: "Claude Code reads only .claude/skills and ~/.claude/skills; .agents/skills is not scanned.", fix: "Install it under .claude/skills or ~/.claude/skills (a symlink from .agents/skills works)."} + - {id: CC-DESC-CUT, when: "description_codepoints > 1536", effect: degraded, outcome: listing shortened, message: "Description cut at 1,536 characters.", fix: "Keep the description at or under 1,536 characters."} + - {id: CC-DESC-MISSING, when: "description_missing or description_empty or description_type != 'str'", effect: degraded, message: "No usable description: Claude Code shows body text instead.", fix: "Add a non-empty string description."} - {id: CC-DUP-KEY, when: "frontmatter_duplicate_keys", effect: advisory, message: "Duplicate keys: Claude Code keeps the last value (four other harnesses drop the skill).", fix: "Remove the duplicate frontmatter key."} - {id: CC-FM-STRIPPED, when: "custom_field_chars > 200", effect: advisory, message: "Frontmatter is stripped when the skill is used, so the text in {custom_fields} never reaches the model.", fix: "Move instructions from frontmatter into the SKILL.md body."} notes: diff --git a/src/skillevaluator/harness/profiles/codex.yaml b/src/skillevaluator/harness/profiles/codex.yaml index cfe4333bb..5b9eabe1d 100644 --- a/src/skillevaluator/harness/profiles/codex.yaml +++ b/src/skillevaluator/harness/profiles/codex.yaml @@ -8,6 +8,8 @@ limits: {scan_depth: 6, skips_hidden_dirs: true, catalog_desc_codepoints: 1024, listing: {cut: 1024} rules: - {id: CX-ROOT, when: "install_root not in roots", effect: not_loaded, outcome: not found, message: "Codex reads .agents/skills and .codex/skills (project and user).", fix: "Install it under .agents/skills or .codex/skills."} + - {id: CX-DESC-CUT, when: "description_codepoints > 1024", effect: degraded, outcome: listing shortened, message: "Description cut to 1,021 chars + '...' in the skill list ({description_codepoints} chars, {description_over} over 1,024).", fix: "Cut the description by at least {description_over} characters."} + - {id: CX-DESC-MISSING, when: "description_missing or description_empty or description_type != 'str'", effect: not_loaded, message: "Skill dropped: Codex requires a string description.", fix: "Add a non-empty string description."} - {id: CX-STRICT-YAML, when: "frontmatter_tab_indent or frontmatter_duplicate_keys", effect: not_loaded, message: "Skill dropped: invalid YAML (tabs or duplicate keys).", fix: "Use spaces, not tabs, and remove duplicate keys."} - {id: CX-BOM, when: "frontmatter_bom", effect: not_loaded, outcome: rejected, message: "Skill dropped: SKILL.md starts with a UTF-8 BOM.", fix: "Save SKILL.md as UTF-8 without a BOM."} notes: diff --git a/src/skillevaluator/harness/profiles/copilot-cli.yaml b/src/skillevaluator/harness/profiles/copilot-cli.yaml index 0bc9d9940..82a964d5a 100644 --- a/src/skillevaluator/harness/profiles/copilot-cli.yaml +++ b/src/skillevaluator/harness/profiles/copilot-cli.yaml @@ -4,11 +4,15 @@ verified: {version: 1.0.105, source: closed (cli-main.js inspected), date: 2026- roots: project: [.github/skills, .agents/skills, .claude/skills] user: [~/.copilot/skills, ~/.agents/skills] +listing: {drop_over_utf16: 1024} rules: - {id: CP-ROOT, when: "install_root not in roots", effect: not_loaded, outcome: not found, message: "Copilot reads .github/.agents/.claude skills (project) and ~/.copilot or ~/.agents skills (user).", fix: "Install it under .github/skills, .agents/skills or .claude/skills."} + - {id: CP-DESC-LIMIT, when: "description_utf16_units > 1024", effect: not_loaded, outcome: rejected, message: "Skill dropped: description is {description_utf16_units} UTF-16 units, {utf16_over} over the 1,024 limit (an emoji counts as 2).", fix: "Cut the description by at least {utf16_over} UTF-16 units."} - {id: CP-STRICT-YAML, when: "frontmatter_tab_indent or frontmatter_duplicate_keys or description_type not in ['str', 'none']", effect: not_loaded, message: "Skill dropped: Copilot's YAML parsing is strict.", fix: "Use spaces, not tabs, remove duplicate keys, and make the description a string."} - {id: CP-NO-FRONTMATTER, when: "frontmatter_missing", effect: not_loaded, outcome: not found, message: "Skill dropped: a SKILL.md with no front matter, or an unclosed one, is not registered ('Skill not found'; canary pair 3/3, drift NOCLOSE canary in 4 releases, Trial I 2/2).", fix: "Add front matter with a name and a description."} + - {id: CP-DESC-MISSING, when: "description_missing", effect: degraded, message: "No description: Copilot shows body text instead.", fix: "Add a non-empty string description."} - {id: CP-FM-STRIPPED, when: "custom_field_chars > 200", effect: advisory, message: "Frontmatter is stripped when the skill is used, so the text in {custom_fields} never reaches the model.", fix: "Move instructions from frontmatter into the SKILL.md body."} + - {id: CP-DESC-ESCAPED, when: "description_has_quote", effect: advisory, outcome: text rewritten, message: "Double quotes in the description are shown to the model as " in the skill list.", fix: "Use single quotes in the description if the exact text matters."} notes: - "Docs say skills only in immediate subfolders; runtime finds them 3 grouping levels deep." - "Follows symlinks inside and outside the checkout (SDK docs say inside only)." diff --git a/src/skillevaluator/harness/profiles/hermes.yaml b/src/skillevaluator/harness/profiles/hermes.yaml index 1c97b7085..657062c3c 100644 --- a/src/skillevaluator/harness/profiles/hermes.yaml +++ b/src/skillevaluator/harness/profiles/hermes.yaml @@ -7,8 +7,11 @@ roots: user: [~/.hermes/skills] not_scanned: [~/.agents/skills] limits: {listing_desc_chars: 60} +listing: {cut: 60} rules: - {id: HM-ROOT, when: "install_root not in roots", effect: not_loaded, outcome: not found, message: "Hermes reads ~/.hermes/skills, and project .hermes/skills or .agents/skills only when trusted.", fix: "Install it under ~/.hermes/skills, or .hermes/skills or .agents/skills in a trusted repo."} + - {id: HM-DESC-60, when: "trigger_offset is None or trigger_offset > 60", effect: advisory, outcome: listing shortened, message: "The skill list shows only the first ~60 chars of the description (57 + '...' in 0.16, a word boundary near 59 on main), and the trigger isn't in them.", fix: "Put the trigger (\"Use when …\") in the first 57 characters."} + - {id: HM-DESC-MISSING, when: "description_missing or description_empty", effect: degraded, message: "Listed by name with an empty description.", fix: "Add a non-empty string description."} - {id: HM-DUP-KEY, when: "frontmatter_duplicate_keys", effect: advisory, message: "Duplicate keys: last value wins.", fix: "Remove the duplicate frontmatter key."} notes: - "Precedence: project > ~/.hermes/skills > skills.create_dir > external_dirs (project wins, 3/3)." diff --git a/src/skillevaluator/harness/profiles/openclaw.yaml b/src/skillevaluator/harness/profiles/openclaw.yaml index 09bd2af5f..032fbdbac 100644 --- a/src/skillevaluator/harness/profiles/openclaw.yaml +++ b/src/skillevaluator/harness/profiles/openclaw.yaml @@ -7,7 +7,9 @@ roots: limits: {max_skills_in_prompt: 150, max_prompt_chars: 18000, compact_desc_chars: 220, max_skill_file_bytes: 256000, read_budget: "16,000-64,000 weighted chars of the skills_read result by model context"} rules: - {id: OW-ROOT, when: "install_root not in roots", effect: not_loaded, outcome: not found, message: "OpenClaw reads skills/, .agents/skills, ~/.agents/skills and ~/.openclaw/skills.", fix: "Install it under skills/ or .agents/skills in the workspace, or ~/.openclaw/skills."} + - {id: OW-DESC-MISSING, when: "description_missing or description_empty", effect: not_loaded, outcome: rejected, message: "Skill dropped: no description.", fix: "Add a non-empty string description."} - {id: OW-STRICT-YAML, when: "frontmatter_tab_indent or frontmatter_duplicate_keys", effect: not_loaded, outcome: rejected, message: "Skill dropped: invalid YAML (tabs or duplicate keys).", fix: "Use spaces, not tabs, and remove duplicate keys."} + - {id: OW-DESC-ESCAPED, when: "description_has_quote", effect: advisory, outcome: text rewritten, message: "Double quotes in the description are shown to the model as " in the skill list.", fix: "Use single quotes in the description if the exact text matters."} notes: - "Precedence: workspace skills/ > .agents/skills > ~/.agents/skills > managed > bundled > extra dirs (project wins, 3/3)." - "Description given as a YAML list is stringified and listed. BOM, CRLF, bare colons tolerated." diff --git a/src/skillevaluator/harness/profiles/opencode.yaml b/src/skillevaluator/harness/profiles/opencode.yaml index d1078c8f3..271e44a19 100644 --- a/src/skillevaluator/harness/profiles/opencode.yaml +++ b/src/skillevaluator/harness/profiles/opencode.yaml @@ -8,6 +8,9 @@ limits: {scan_depth: unlimited, desc_cap: none, list_cap: none, tool_output: "2, listing: {} rules: - {id: OC-ROOT, when: "install_root not in roots", effect: not_loaded, outcome: not found, message: "OpenCode reads .opencode, .claude and .agents skill folders.", fix: "Install it under .opencode/skills, .claude/skills or .agents/skills."} + - {id: OC-NAME-MISSING, when: "name_missing", effect: not_loaded, outcome: rejected, message: "Skill dropped: OpenCode requires a name.", fix: "Add a name field matching the folder name."} + - {id: OC-DESC-MISSING, when: "description_missing or description_type != 'str'", effect: not_loaded, message: "Loaded but hidden from the model's skill list (no string description).", fix: "Add a non-empty string description."} + - {id: OC-DESC-EMPTY, when: "description_empty", effect: degraded, message: "Listed by name only.", fix: "Add a non-empty string description."} - {id: OC-DUP-KEY, when: "frontmatter_duplicate_keys", effect: not_loaded, outcome: rejected, message: "Skill dropped: duplicate frontmatter keys.", fix: "Remove the duplicate frontmatter key."} - {id: OC-FM-STRIPPED, when: "custom_field_chars > 200", effect: advisory, message: "Frontmatter is stripped when the skill is used, so the text in {custom_fields} never reaches the model.", fix: "Move instructions from frontmatter into the SKILL.md body."} notes: diff --git a/src/skillevaluator/harness/report.py b/src/skillevaluator/harness/report.py index d439d451b..6bd536275 100644 --- a/src/skillevaluator/harness/report.py +++ b/src/skillevaluator/harness/report.py @@ -138,6 +138,29 @@ def _detail_grid(rows: list[dict[str, Any]], verbose: bool) -> Table | None: return grid if grid.row_count else None +_LISTING = { + "cut": "cut to {limit} chars", + "name_only": "name only", + "dropped": "not listed", + "shortened": "shortened (over list budget)", +} + + +def _listing_grid(rows: list[dict[str, Any]]) -> Table | None: + grid = Table.grid(padding=(0, 2), expand=True) + grid.add_column(no_wrap=True, style=TEXT) + grid.add_column(no_wrap=True, style=MUTED) + grid.add_column(ratio=1, style=MUTED) + for row in rows: + listed = row.get("listed") or {} + if listed.get("mode", "full") == "full": + continue + text = listed.get("text", "") + shown = f"“{text[:57]}…”" if len(text) > 57 else f"“{text}”" if text else "-" + grid.add_row(row["harness"], _LISTING[listed["mode"]].format(limit=listed.get("limit", "")), shown) + return grid if grid.row_count else None + + def _subtitle(rows: list[dict[str, Any]]) -> tuple[Text, str]: done = [row for row in rows if row["status"] not in ("pending", "checking")] if len(done) < len(rows): @@ -170,6 +193,9 @@ def harness_panel( grid = _detail_grid(rows, verbose) if verbose else _compact_grid(rows) if grid is not None: parts.extend([Text(), grid]) + listing = _listing_grid(rows) if verbose else None + if listing is not None: + parts.extend([Text(), Text("Description in the model's skill list (from the profile):", MUTED), listing]) flagged = any(row.get("findings") for row in all_rows) if footer and (flagged or verbose): parts.extend([Text(), Text(footer + ("" if verbose else VERBOSE_HINT), MUTED)]) diff --git a/src/skillevaluator/validators/schema.py b/src/skillevaluator/validators/schema.py index f2a4b62ba..0b8e0a41c 100644 --- a/src/skillevaluator/validators/schema.py +++ b/src/skillevaluator/validators/schema.py @@ -18,6 +18,9 @@ from skillevaluator.constants import ( DEFAULT_ALLOWED_SKILL_DIRS, + DESCRIPTION_MAX_LENGTH, + DESCRIPTION_TRIGGER_PATTERN, + DESCRIPTION_TRIGGER_WINDOW, KEBAB_CASE_PATTERN, MAX_SKILL_MD_LINES, RECOMMENDED_BODY_SECTIONS, @@ -182,6 +185,7 @@ def _display_metadata_id(value: Any) -> str: _UTF8_BOM = b"\xef\xbb\xbf" +_TRIGGER_RE = re.compile(DESCRIPTION_TRIGGER_PATTERN, re.IGNORECASE) def _duplicate_frontmatter_keys(frontmatter_yaml: str) -> list[tuple[str, int]]: @@ -412,7 +416,7 @@ def _validate_single_skill(self, skill_path: Path) -> ValidationResult: result.merge(self._validate_name_matches_directory(skill_path, frontmatter)) result.merge(self._validate_author(frontmatter, str(skill_md))) result.merge(self._validate_metadata_id(frontmatter, str(skill_md))) - result.merge(self._validate_portability(skill_md)) + result.merge(self._validate_portability(skill_md, frontmatter)) return result @@ -712,7 +716,7 @@ def _portability_finding( metadata=dict(metadata), ) - def _validate_portability(self, skill_md: Path) -> ValidationResult: + def _validate_portability(self, skill_md: Path, frontmatter: SkillFrontmatter) -> ValidationResult: """Flag spec-valid patterns that common agent harnesses load differently or not at all.""" result = ValidationResult() file_path = str(skill_md) @@ -732,6 +736,35 @@ def _validate_portability(self, skill_md: Path) -> ValidationResult: "Save SKILL.md as UTF-8 without BOM", ) ) + description = frontmatter.description + utf16_units = len(description.encode("utf-16-le")) // 2 + if len(description) <= DESCRIPTION_MAX_LENGTH < utf16_units: + findings.append( + self._portability_finding( + "description_utf16_length", + Severity.MEDIUM, + f"Description is {len(description)} characters but {utf16_units} UTF-16 units; " + f"Copilot CLI counts UTF-16 units and drops descriptions over {DESCRIPTION_MAX_LENGTH}", + file_path, + "Shorten the description or replace emoji and other non-BMP characters", + utf16_units=utf16_units, + ) + ) + + trigger = _TRIGGER_RE.search(description) + if trigger is None or trigger.start() >= DESCRIPTION_TRIGGER_WINDOW: + where = "no 'Use when ...' trigger" if trigger is None else f"trigger starts at character {trigger.start()}" + findings.append( + self._portability_finding( + "description_trigger", + Severity.LOW, + f"Description has {where}; some harnesses show only the first " + f"~{DESCRIPTION_TRIGGER_WINDOW} characters in their skill list", + file_path, + f"State when to use the skill within the first {DESCRIPTION_TRIGGER_WINDOW} characters", + ) + ) + for finding in findings: result.add_finding(finding) return result diff --git a/tests/golden/test_policy_behavior.py b/tests/golden/test_policy_behavior.py index 521b7550d..a97c01028 100644 --- a/tests/golden/test_policy_behavior.py +++ b/tests/golden/test_policy_behavior.py @@ -33,7 +33,7 @@ def _write_skill(root: Path, name: str, author_line: str | None) -> Path: skill.mkdir(parents=True) meta = f"metadata:\n author: {author_line}\n" if author_line else "" (skill / "SKILL.md").write_text( - f"---\nname: {name}\ndescription: A test skill for policy behavior checks.\n{meta}---\n" + f"---\nname: {name}\ndescription: Use when checking policy behavior. A test skill for policy behavior checks.\n{meta}---\n" + _BODY.format(name=name), encoding="utf-8", ) diff --git a/tests/harness/test_overlay.py b/tests/harness/test_overlay.py index 637f1ccb5..52a013f8e 100644 --- a/tests/harness/test_overlay.py +++ b/tests/harness/test_overlay.py @@ -80,6 +80,24 @@ def test_bom_is_not_loaded_by_codex_only(tmp_path: Path): assert {h for h, s in status.items() if s != "loads"} == {"codex"} +def test_utf16_overflow_is_not_loaded_by_copilot(tmp_path: Path): + status = _status(_skill(tmp_path, desc="Use when testing emoji. " + "\U0001f600" * 600)) + + assert status["copilot-cli"] == "not_loaded" + assert status["codex"] == "loads" + + +def test_copilot_shows_body_for_missing_description_but_drops_non_string(tmp_path: Path): + skill = tmp_path / "skills" / "no-desc" + skill.mkdir(parents=True) + (skill / "SKILL.md").write_text("---\nname: no-desc\n---\nCustom skill\n", encoding="utf-8") + rows = _rows(skill) + assert rows["copilot-cli"]["status"] == "degraded" + assert "CP-DESC-MISSING" in _ids(rows, "copilot-cli") and "CP-STRICT-YAML" not in _ids(rows, "copilot-cli") + listed = _skill(tmp_path / "list", desc="[a, b]") + assert "CP-STRICT-YAML" in _ids(_rows(listed), "copilot-cli") + + def test_install_root_only_applies_inside_known_harness_roots(tmp_path: Path): skill = tmp_path / ".claude" / "skills" / "demo-skill" skill.parent.mkdir(parents=True) @@ -283,6 +301,45 @@ def test_harness_check_command_rejects_unknown_harness(tmp_path: Path): assert "Unknown harness: nope" in result.output +def _rows(skill: Path) -> dict[str, dict]: + return {r.harness: r.to_dict() for r in evaluate_harnesses(skill)} + + +def _ids(rows: dict[str, dict], harness: str) -> set[str]: + return {f["id"] for f in rows[harness]["findings"]} + + +def test_listed_description_projection(tmp_path: Path): + desc = "Use when " + "a" * 1600 + rows = _rows(_skill(tmp_path, desc=desc)) + + assert rows["hermes"]["listed"] == {"mode": "cut", "text": desc[:60], "limit": 60} + assert rows["claude-code"]["listed"]["limit"] == 1536 + assert rows["codex"]["listed"]["limit"] == 1024 + assert rows["copilot-cli"]["listed"]["mode"] == "dropped" + assert rows["opencode"]["listed"]["mode"] == rows["openclaw"]["listed"]["mode"] == "full" + + +def test_fix_reaches_findings_and_panels(tmp_path: Path): + skill = _skill(tmp_path, desc="Use when testing emoji. " + "\U0001f600" * 600) + result = HarnessValidator().validate(skill) + finding = next(f for f in result.findings if f.check_name == "CP-DESC-LIMIT") + + assert finding.suggestion == "Cut the description by at least 200 UTF-16 units." + out = CliRunner().invoke(cli, ["harness-check", str(skill), "-v"], env={"COLUMNS": "120"}).output + assert "→ Cut the description by at least 200 UTF-16 units." in out + assert "Description in the model's skill list" in out + + +@pytest.mark.parametrize(("harness", "rule"), [("codex", "CX-DESC-CUT"), ("copilot-cli", "CP-DESC-LIMIT")]) +def test_description_limit_is_1024(tmp_path: Path, harness: str, rule: str): + at = _rows(_skill(tmp_path / "at", desc="Use when " + "a" * 1015)) + over = _rows(_skill(tmp_path / "over", desc="Use when " + "a" * 1016)) + + assert rule not in _ids(at, harness) + assert any(f["id"] == rule and "1 over" in f["message"] for f in over[harness]["findings"]) + + def test_tier1_summary_gives_harness_its_own_line(tmp_path: Path): results = run_validation(_rooted(tmp_path), checks="schema,harness", harness="all") _, rows = summarize_tier1(results) @@ -292,6 +349,12 @@ def test_tier1_summary_gives_harness_its_own_line(tmp_path: Path): assert "harness" not in labels.get("advisories", "") +def test_quotes_in_description_are_escaped_in_copilot_and_openclaw_lists(tmp_path: Path): + rows = _rows(_skill(tmp_path, desc='Use when asked to "summarize" a file.')) + assert "CP-DESC-ESCAPED" in _ids(rows, "copilot-cli") and "OW-DESC-ESCAPED" in _ids(rows, "openclaw") + assert "CC-DESC-ESCAPED" not in _ids(rows, "claude-code") and rows["copilot-cli"]["status"] == "loads" + + def _rule_ids(skill: Path, harness: str, config: dict | None = None) -> set[str]: return {f["id"] for r in evaluate_harnesses(skill, harness, config=config) for f in r.findings} diff --git a/tests/test_commands.py b/tests/test_commands.py index 0c4307975..732583fc1 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -506,6 +506,13 @@ def test_validate_json_names_a_clean_single_skill_and_records_the_evaluator( repo = tmp_path / "repo" skill = repo / "skills" / "simple" shutil.copytree(FIXTURE, skill) + manifest = skill / "SKILL.md" + manifest.write_text( + manifest.read_text(encoding="utf-8").replace( + "description: Summarize", "description: Use when notes need action items. Summarize" + ), + encoding="utf-8", + ) if in_git_checkout: subprocess.run(["git", "init", "-q", str(repo)], check=True) subprocess.run( diff --git a/tests/validators/test_schema.py b/tests/validators/test_schema.py index 6ac2bd8b2..88633a00e 100644 --- a/tests/validators/test_schema.py +++ b/tests/validators/test_schema.py @@ -1229,7 +1229,7 @@ def _write_skill(root: Path, name: str, id_line: str | None) -> Path: (skill_dir / "SKILL.md").write_text( f"""--- name: {name} -description: A skill used by the test suite to check the metadata.id contract +description: Use when testing the metadata.id contract. A skill used by the test suite to check the contract metadata: author: Jane Doe {id_block}--- @@ -1422,7 +1422,7 @@ def _write_skill(root: Path, name: str, *, author_line: str, id_line: str | None (skill_dir / "SKILL.md").write_text( f"""--- name: {name} -description: A skill used by the test suite to check collection-level advisory handling +description: Use when testing collection advisories. A skill used by the test suite to check collection-level advisory handling metadata: author: {author_line} {id_block}--- @@ -1614,6 +1614,37 @@ def test_bom_is_medium_and_does_not_fail(self, tmp_path: Path): assert result.passed, result.errors assert [f.severity for f in _checks(result, "manifest_bom")] == ["medium"] + def test_description_over_utf16_limit_is_medium(self, tmp_path: Path): + description = "Use when testing. " + "\U0001f600" * 600 + fm = _BASE_FM.replace("Use when checking harness portability of a skill.", description) + result = SchemaValidator().validate(_write_skill(tmp_path, fm)) + + findings = _checks(result, "description_utf16_length") + assert result.passed, result.errors + assert [f.metadata["utf16_units"] for f in findings] == [len(description.encode("utf-16-le")) // 2] + + def test_bmp_description_at_limit_has_no_utf16_finding(self, tmp_path: Path): + fm = _BASE_FM.replace("Use when checking harness portability of a skill.", "Use when x. " + "a" * 1012) + result = SchemaValidator().validate(_write_skill(tmp_path, fm)) + + assert not _checks(result, "description_utf16_length") + + @pytest.mark.parametrize( + ("description", "expected"), + [ + ("Formats tables. Use when the user asks for a table.", False), + ("Use this skill to format tables in reports.", False), + ("Formats tables, charts and other structured report content nicely. Use when needed.", True), + ("Formats tables in reports.", True), + ], + ) + def test_description_trigger_window(self, tmp_path: Path, description: str, expected: bool): + fm = _BASE_FM.replace("Use when checking harness portability of a skill.", description) + findings = _checks(SchemaValidator().validate(_write_skill(tmp_path, fm)), "description_trigger") + + assert bool(findings) is expected + assert all(f.severity == "low" for f in findings) + def test_portability_severity_can_be_overridden_by_policy(self, tmp_path: Path): from skillevaluator.validators.policy import ValidationPolicy From 209a4cd3a55143d167e1f540d3d651e569121fc1 Mon Sep 17 00:00:00 2001 From: Christopher Kevin Date: Fri, 13 Nov 2026 22:06:53 +0000 Subject: [PATCH 2/6] feat(harness): flag SKILL.md locations harnesses miss or load twice Signed-off-by: Christopher Kevin --- CHANGELOG.md | 5 ++ docs/tier1-validation.mdx | 3 + src/skillevaluator/harness/overlay.py | 60 ++++++++++++++++++- .../harness/profiles/claude-code.yaml | 1 + .../harness/profiles/codex.yaml | 4 ++ .../harness/profiles/copilot-cli.yaml | 2 + .../harness/profiles/hermes.yaml | 5 ++ .../harness/profiles/openclaw.yaml | 4 ++ .../harness/profiles/opencode.yaml | 2 + src/skillevaluator/validators/schema.py | 43 +++++++++++-- tests/harness/test_overlay.py | 25 ++++++++ tests/validators/test_schema.py | 28 +++++++++ 12 files changed, 177 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 25c3ed66d..707ad00b3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,11 @@ All notable changes to SkillEvaluator are documented in this file. ### Added +- `harness` rules for where `SKILL.md` lives: casing, nested manifests, symlinked + manifests and resources, OpenClaw symlink escapes, Codex scan depth, and files + Hermes leaves out of its file list. Tier 1 `schema` now reports a symlinked or + nested `SKILL.md` (MEDIUM), and the `skill.md` naming finding explains the + macOS/Linux difference. - `harness` rules for descriptions: missing or empty descriptions, Claude Code and Codex listing cuts, Copilot CLI's 1,024 UTF-16 unit limit, quotes escaped in the Copilot CLI and OpenClaw lists, and Hermes's 60-character listing; `-v` shows diff --git a/docs/tier1-validation.mdx b/docs/tier1-validation.mdx index a56ee063b..115dff461 100644 --- a/docs/tier1-validation.mdx +++ b/docs/tier1-validation.mdx @@ -260,6 +260,7 @@ For `validate`, the default set is `schema`, `version`, `security`, `pii`, `lice - Harness portability: patterns the spec allows but common agent harnesses (Claude Code, Codex, OpenCode, OpenClaw, Hermes, Copilot CLI) load differently are reported; override any of them with `SCHEMA.` in the validation policy. - A duplicate frontmatter key is HIGH (`duplicate_key`; several harnesses drop the skill), and a UTF-8 BOM is MEDIUM (`manifest_bom`). - A description within 1,024 characters but over 1,024 UTF-16 units is MEDIUM (`description_utf16_length`), and no "Use when ..." trigger in the first 60 characters is LOW (`description_trigger`). + - A symlinked `SKILL.md` (`manifest_symlink`) or a `SKILL.md` nested inside the skill (`nested_manifest`) is MEDIUM. - `metadata.author` is optional under the `default` profile. Use `Name ` to include a contact address, or a person, team, or organization name such as `NVIDIA cuOpt Team` or `Jane Doe (@jdoe)`. A value that is malformed or unsafe is a HIGH `author_format` finding: a bare email or an email outside `Name `, stray angle brackets, control, private-use, or bidirectional formatting characters (joiners such as ZWNJ and ZWJ, which Persian, Arabic and Devanagari names need, are accepted), no letters or digits, or more than 256 characters. A bare address counts even when its domain has no dot (`root@buildhost`), while a social handle such as `Jane Doe (@jdoe)` does not. The `registry` profile requires the `Name ` form. - `metadata.id` is an optional stable skill ID. When present it must be an exact 1–64 character lowercase ASCII slug (`^[a-z0-9]+(-[a-z0-9]+)*$`, no surrounding whitespace); it may differ from `name`. A collection run reports an ID that more than one discovered skill declares; `validate` on a catalog also lists these in `catalog-summary.json` under `metadata_id_conflicts`. Under `registry` a shared ID blocks: the run exits nonzero, and each sharing skill's entry is `"passed": false` with the conflict repeated under `catalog_findings` and counted in its `severity_counts`. A catalog validates each skill on its own, so that skill's own report was written before the catalog-wide check ran and keeps its single-skill verdict, which the entry carries alongside as `report_verdict` beside `report_scope: "single_skill"`. Uniqueness is checked only across the skills validated together, never against a registry, and a single-skill run does not claim it. The ID does not change local catalog identity, which stays keyed by content type and relative path. - `metadata.domain` accepts one category string or a list of them, such as `domain: [backend, ai-ml]`. Values are trimmed and deduplicated in order; a blank or null scalar means no domain. A list with more than 16 entries, or a non-string, blank, or over-128-character entry, is a HIGH `Field 'metadata.domain'` finding. The 128-character limit also applies to a single string. @@ -279,6 +280,8 @@ For `validate`, the default set is `schema`, `version`, `security`, `pii`, `lice Frontmatter rules: duplicate keys (Codex, Copilot CLI, OpenClaw and OpenCode drop the skill), tab indentation (Codex, Copilot CLI and OpenClaw), a UTF-8 BOM (Codex), no front matter (Copilot CLI), and long custom frontmatter that never reaches the model. Description rules: missing or empty descriptions, Claude Code and Codex listing cuts, Copilot CLI's 1,024 UTF-16 unit limit, quotes escaped in the Copilot CLI and OpenClaw lists, and Hermes's 60-character listing. `-v` also shows the description each harness puts in the model's skill list. + + Location rules: `SKILL.md` casing, nested manifests, symlinked manifests and resources, OpenClaw symlink escapes, Codex scan depth, and files Hermes leaves out of its file list (outside `references/`, `templates/`, `assets/` and `scripts/`). diff --git a/src/skillevaluator/harness/overlay.py b/src/skillevaluator/harness/overlay.py index c6616aa11..b0225832e 100644 --- a/src/skillevaluator/harness/overlay.py +++ b/src/skillevaluator/harness/overlay.py @@ -12,7 +12,7 @@ import yaml -from skillevaluator.constants import DESCRIPTION_TRIGGER_PATTERN, SKILL_MANIFEST_VARIANTS +from skillevaluator.constants import DESCRIPTION_TRIGGER_PATTERN, SCAN_EXCLUDED_DIRS, SKILL_MANIFEST_VARIANTS from skillevaluator.validators.frontmatter_parser import FRONTMATTER_PATTERN from skillevaluator.validators.schema import _duplicate_frontmatter_keys @@ -159,12 +159,61 @@ def _tab_indent_breaks_yaml(fm_yaml: str) -> bool: return False +def _bundle_files(skill_path: Path, manifest: Path) -> list[Path]: + files = [] + for path in sorted(skill_path.rglob("*")): + parts = path.relative_to(skill_path).parts + if path == manifest or any(part in _NOT_SHIPPED_DIRS for part in parts): + continue + if path.is_symlink() or path.is_file(): + files.append(path) + return files + + +# Harnesses read every file a skill ships, evals/ included; only VCS and caches are skipped. +_NOT_SHIPPED_DIRS = frozenset({".git", "__pycache__", "node_modules", ".venv"}) +_HERMES_LINKED_DIRS = ("references", "templates", "assets", "scripts") + + +def _paths(items: list[str]) -> str: + return ", ".join(items[:3]) + (f" +{len(items) - 3} more" if len(items) > 3 else "") + + +def _bundle_facts(skill_path: Path, manifest: Path) -> dict[str, Any]: + base = skill_path.resolve() + links, escapes, unlisted = [], [], [] + for path in _bundle_files(skill_path, manifest): + rel = path.relative_to(skill_path).as_posix() + if path.is_symlink(): + links.append(rel) + target = path.resolve() + if target != base and base not in target.parents: + escapes.append(rel) + continue + if rel.split("/", 1)[0] not in _HERMES_LINKED_DIRS: + unlisted.append(rel) + return { + "resource_symlinks": len(links), + "resource_symlink_paths": _paths(links), + "resource_symlink_escapes": len(escapes), + "resource_symlink_escape_paths": _paths(escapes), + "hermes_unlisted_files": len(unlisted), + "hermes_unlisted_dirs": _paths(list(dict.fromkeys(rel.split("/", 1)[0] for rel in unlisted))), + } + + def skill_facts(skill_path: Path) -> dict[str, Any]: """Compute the facts profile rules refer to.""" manifest, raw, text, fm_yaml, data = _read_manifest(skill_path) description = data.get("description") trigger = _TRIGGER_RE.search(description) if isinstance(description, str) else None root, depth = _install_root(skill_path) + target = "none" + if skill_path.is_symlink(): + resolved = skill_path.resolve() + base = skill_path.parent.resolve() + target = "inside_root" if base in resolved.parents else "outside_root" + names = {p.name for p in skill_path.iterdir()} if skill_path.is_dir() else set() custom = {k: v for k, v in data.items() if str(k) not in _KNOWN_FIELDS} name = _skill_name(skill_path, data) return { @@ -172,6 +221,14 @@ def skill_facts(skill_path: Path) -> dict[str, Any]: "description_text": description if isinstance(description, str) else "", "install_root": root, "grouping_depth": depth, + "manifest_name_exact": "SKILL.md" in names, + "nested_skill_md": any( + p.parent != skill_path and not any(part in SCAN_EXCLUDED_DIRS for part in p.relative_to(skill_path).parts) + for n in SKILL_MANIFEST_VARIANTS + for p in skill_path.rglob(n) + ), + "skill_md_symlink": manifest.is_symlink(), + "skill_dir_symlink_target": target, "frontmatter_missing": manifest.is_file() and FRONTMATTER_PATTERN.match(text) is None, "description_missing": "description" not in data, "description_empty": isinstance(description, str) and not description.strip(), @@ -188,6 +245,7 @@ def skill_facts(skill_path: Path) -> dict[str, Any]: "custom_field_chars": sum(len(v) if isinstance(v, str) else len(yaml.safe_dump(v)) for v in custom.values()), "description_over": max(0, (len(description) if isinstance(description, str) else 0) - 1024), "utf16_over": max(0, (len(description.encode("utf-16-le")) // 2 if isinstance(description, str) else 0) - 1024), + **_bundle_facts(skill_path, manifest), } diff --git a/src/skillevaluator/harness/profiles/claude-code.yaml b/src/skillevaluator/harness/profiles/claude-code.yaml index 6a51dab32..3099d755a 100644 --- a/src/skillevaluator/harness/profiles/claude-code.yaml +++ b/src/skillevaluator/harness/profiles/claude-code.yaml @@ -11,6 +11,7 @@ rules: - {id: CC-DESC-CUT, when: "description_codepoints > 1536", effect: degraded, outcome: listing shortened, message: "Description cut at 1,536 characters.", fix: "Keep the description at or under 1,536 characters."} - {id: CC-DESC-MISSING, when: "description_missing or description_empty or description_type != 'str'", effect: degraded, message: "No usable description: Claude Code shows body text instead.", fix: "Add a non-empty string description."} - {id: CC-DUP-KEY, when: "frontmatter_duplicate_keys", effect: advisory, message: "Duplicate keys: Claude Code keeps the last value (four other harnesses drop the skill).", fix: "Remove the duplicate frontmatter key."} + - {id: CC-CASING, when: "not manifest_name_exact", effect: degraded, message: "Non-canonical name (skill.md/Skill.md): loaded on case-insensitive filesystems (macOS default APFS, 3/3), ignored on case-sensitive Linux (3/3). Works or breaks depending on the OS.", fix: "Rename the file to SKILL.md (exact casing)."} - {id: CC-FM-STRIPPED, when: "custom_field_chars > 200", effect: advisory, message: "Frontmatter is stripped when the skill is used, so the text in {custom_fields} never reaches the model.", fix: "Move instructions from frontmatter into the SKILL.md body."} notes: - "Follows symlinked skill folders and symlinked SKILL.md files, inside or outside the root." diff --git a/src/skillevaluator/harness/profiles/codex.yaml b/src/skillevaluator/harness/profiles/codex.yaml index 5b9eabe1d..757fababb 100644 --- a/src/skillevaluator/harness/profiles/codex.yaml +++ b/src/skillevaluator/harness/profiles/codex.yaml @@ -12,6 +12,10 @@ rules: - {id: CX-DESC-MISSING, when: "description_missing or description_empty or description_type != 'str'", effect: not_loaded, message: "Skill dropped: Codex requires a string description.", fix: "Add a non-empty string description."} - {id: CX-STRICT-YAML, when: "frontmatter_tab_indent or frontmatter_duplicate_keys", effect: not_loaded, message: "Skill dropped: invalid YAML (tabs or duplicate keys).", fix: "Use spaces, not tabs, and remove duplicate keys."} - {id: CX-BOM, when: "frontmatter_bom", effect: not_loaded, outcome: rejected, message: "Skill dropped: SKILL.md starts with a UTF-8 BOM.", fix: "Save SKILL.md as UTF-8 without a BOM."} + - {id: CX-NESTED, when: "nested_skill_md", effect: degraded, message: "The nested SKILL.md is loaded as a second, separate skill.", fix: "Move the nested skill to its own folder under the skills root, or rename its SKILL.md."} + - {id: CX-DEPTH, when: "grouping_depth > 5", effect: not_loaded, outcome: not found, message: "Beyond Codex's scan depth of 6.", fix: "Install the skill at most 5 folders below the skills root."} + - {id: CX-SYMLINK-FILE, when: "skill_md_symlink", effect: not_loaded, message: "Symlinked SKILL.md files are skipped (codex#15756).", fix: "Copy SKILL.md into the folder instead of symlinking the file (a symlinked folder works)."} + - {id: CX-CASING, when: "not manifest_name_exact", effect: not_loaded, message: "Non-canonical name (skill.md/Skill.md): never loaded, on Linux or macOS (3/3 each).", fix: "Rename the file to SKILL.md (exact casing)."} notes: - "Explicit $skill injects the whole SKILL.md (145 KB tested)." - "Follows symlinked skill folders (inside or outside the root)." diff --git a/src/skillevaluator/harness/profiles/copilot-cli.yaml b/src/skillevaluator/harness/profiles/copilot-cli.yaml index 82a964d5a..d54dec537 100644 --- a/src/skillevaluator/harness/profiles/copilot-cli.yaml +++ b/src/skillevaluator/harness/profiles/copilot-cli.yaml @@ -11,6 +11,8 @@ rules: - {id: CP-STRICT-YAML, when: "frontmatter_tab_indent or frontmatter_duplicate_keys or description_type not in ['str', 'none']", effect: not_loaded, message: "Skill dropped: Copilot's YAML parsing is strict.", fix: "Use spaces, not tabs, remove duplicate keys, and make the description a string."} - {id: CP-NO-FRONTMATTER, when: "frontmatter_missing", effect: not_loaded, outcome: not found, message: "Skill dropped: a SKILL.md with no front matter, or an unclosed one, is not registered ('Skill not found'; canary pair 3/3, drift NOCLOSE canary in 4 releases, Trial I 2/2).", fix: "Add front matter with a name and a description."} - {id: CP-DESC-MISSING, when: "description_missing", effect: degraded, message: "No description: Copilot shows body text instead.", fix: "Add a non-empty string description."} + - {id: CP-NESTED, when: "nested_skill_md", effect: advisory, message: "Nested SKILL.md is ignored.", fix: "Move the nested skill to its own folder under the skills root, or rename its SKILL.md."} + - {id: CP-CASING, when: "not manifest_name_exact", effect: degraded, message: "Non-canonical name (skill.md/Skill.md): loaded on case-insensitive filesystems (macOS default APFS, 3/3), ignored on case-sensitive Linux (3/3). Works or breaks depending on the OS.", fix: "Rename the file to SKILL.md (exact casing)."} - {id: CP-FM-STRIPPED, when: "custom_field_chars > 200", effect: advisory, message: "Frontmatter is stripped when the skill is used, so the text in {custom_fields} never reaches the model.", fix: "Move instructions from frontmatter into the SKILL.md body."} - {id: CP-DESC-ESCAPED, when: "description_has_quote", effect: advisory, outcome: text rewritten, message: "Double quotes in the description are shown to the model as " in the skill list.", fix: "Use single quotes in the description if the exact text matters."} notes: diff --git a/src/skillevaluator/harness/profiles/hermes.yaml b/src/skillevaluator/harness/profiles/hermes.yaml index 657062c3c..8bb4c8302 100644 --- a/src/skillevaluator/harness/profiles/hermes.yaml +++ b/src/skillevaluator/harness/profiles/hermes.yaml @@ -12,7 +12,12 @@ rules: - {id: HM-ROOT, when: "install_root not in roots", effect: not_loaded, outcome: not found, message: "Hermes reads ~/.hermes/skills, and project .hermes/skills or .agents/skills only when trusted.", fix: "Install it under ~/.hermes/skills, or .hermes/skills or .agents/skills in a trusted repo."} - {id: HM-DESC-60, when: "trigger_offset is None or trigger_offset > 60", effect: advisory, outcome: listing shortened, message: "The skill list shows only the first ~60 chars of the description (57 + '...' in 0.16, a word boundary near 59 on main), and the trigger isn't in them.", fix: "Put the trigger (\"Use when …\") in the first 57 characters."} - {id: HM-DESC-MISSING, when: "description_missing or description_empty", effect: degraded, message: "Listed by name with an empty description.", fix: "Add a non-empty string description."} + - {id: HM-NESTED, when: "nested_skill_md", effect: degraded, message: "The nested SKILL.md is loaded as a second, separate skill (hidden folders are walked too).", fix: "Move the nested skill to its own folder under the skills root, or rename its SKILL.md."} + - {id: HM-SYMLINK-FILE, when: "skill_md_symlink", effect: not_loaded, message: "Symlinked SKILL.md files are not loaded.", fix: "Copy SKILL.md into the folder instead of symlinking the file (a symlinked folder works)."} - {id: HM-DUP-KEY, when: "frontmatter_duplicate_keys", effect: advisory, message: "Duplicate keys: last value wins.", fix: "Remove the duplicate frontmatter key."} + - {id: HM-CASING, when: "not manifest_name_exact", effect: not_loaded, message: "Non-canonical name (skill.md/Skill.md): never loaded, on Linux or macOS (3/3 each).", fix: "Rename the file to SKILL.md (exact casing)."} + - {id: HM-RESOURCE-SYMLINK, when: "resource_symlinks > 0", effect: degraded, message: "Symlinked files ({resource_symlink_paths}) are left out of the skill's file list.", fix: "Copy those files into the skill instead of symlinking them."} + - {id: HM-LINKED-LAYOUT, when: "hermes_unlisted_files > 0", effect: advisory, message: "{hermes_unlisted_files} files outside references/, templates/, assets/ and scripts/ ({hermes_unlisted_dirs}) are left out of the skill's file list; the model finds them only if SKILL.md names their paths.", fix: "Move supporting files under references/, templates/, assets/ or scripts/."} notes: - "Precedence: project > ~/.hermes/skills > skills.create_dir > external_dirs (project wins, 3/3)." - "Large bodies are spilled and paged through in small reads." diff --git a/src/skillevaluator/harness/profiles/openclaw.yaml b/src/skillevaluator/harness/profiles/openclaw.yaml index 032fbdbac..0039f720b 100644 --- a/src/skillevaluator/harness/profiles/openclaw.yaml +++ b/src/skillevaluator/harness/profiles/openclaw.yaml @@ -9,6 +9,10 @@ rules: - {id: OW-ROOT, when: "install_root not in roots", effect: not_loaded, outcome: not found, message: "OpenClaw reads skills/, .agents/skills, ~/.agents/skills and ~/.openclaw/skills.", fix: "Install it under skills/ or .agents/skills in the workspace, or ~/.openclaw/skills."} - {id: OW-DESC-MISSING, when: "description_missing or description_empty", effect: not_loaded, outcome: rejected, message: "Skill dropped: no description.", fix: "Add a non-empty string description."} - {id: OW-STRICT-YAML, when: "frontmatter_tab_indent or frontmatter_duplicate_keys", effect: not_loaded, outcome: rejected, message: "Skill dropped: invalid YAML (tabs or duplicate keys).", fix: "Use spaces, not tabs, and remove duplicate keys."} + - {id: OW-SYMLINK-ESCAPE, when: "skill_dir_symlink_target == 'outside_root'", effect: not_loaded, message: "Symlink target is outside the skills root (even inside the repo): rejected.", fix: "Copy the skill into the skills folder instead of symlinking it from elsewhere."} + - {id: OW-SYMLINK-FILE, when: "skill_md_symlink", effect: not_loaded, message: "Symlinked SKILL.md files are not loaded.", fix: "Copy SKILL.md into the folder instead of symlinking the file (a symlinked folder works)."} + - {id: OW-NESTED, when: "nested_skill_md", effect: advisory, message: "Nested SKILL.md is ignored.", fix: "Move the nested skill to its own folder under the skills root, or rename its SKILL.md."} + - {id: OW-CASING, when: "not manifest_name_exact", effect: degraded, message: "Non-canonical name (skill.md/Skill.md): loaded on case-insensitive filesystems (macOS default APFS, 3/3), ignored on case-sensitive Linux (3/3). Works or breaks depending on the OS.", fix: "Rename the file to SKILL.md (exact casing)."} - {id: OW-DESC-ESCAPED, when: "description_has_quote", effect: advisory, outcome: text rewritten, message: "Double quotes in the description are shown to the model as " in the skill list.", fix: "Use single quotes in the description if the exact text matters."} notes: - "Precedence: workspace skills/ > .agents/skills > ~/.agents/skills > managed > bundled > extra dirs (project wins, 3/3)." diff --git a/src/skillevaluator/harness/profiles/opencode.yaml b/src/skillevaluator/harness/profiles/opencode.yaml index 271e44a19..6bc5c0ce8 100644 --- a/src/skillevaluator/harness/profiles/opencode.yaml +++ b/src/skillevaluator/harness/profiles/opencode.yaml @@ -12,6 +12,8 @@ rules: - {id: OC-DESC-MISSING, when: "description_missing or description_type != 'str'", effect: not_loaded, message: "Loaded but hidden from the model's skill list (no string description).", fix: "Add a non-empty string description."} - {id: OC-DESC-EMPTY, when: "description_empty", effect: degraded, message: "Listed by name only.", fix: "Add a non-empty string description."} - {id: OC-DUP-KEY, when: "frontmatter_duplicate_keys", effect: not_loaded, outcome: rejected, message: "Skill dropped: duplicate frontmatter keys.", fix: "Remove the duplicate frontmatter key."} + - {id: OC-NESTED, when: "nested_skill_md", effect: degraded, message: "The nested SKILL.md is loaded as a second, separate skill.", fix: "Move the nested skill to its own folder under the skills root, or rename its SKILL.md."} + - {id: OC-CASING, when: "not manifest_name_exact", effect: degraded, message: "Non-canonical name (skill.md/Skill.md): loaded on case-insensitive filesystems (macOS default APFS, 3/3), ignored on case-sensitive Linux (3/3). Works or breaks depending on the OS.", fix: "Rename the file to SKILL.md (exact casing)."} - {id: OC-FM-STRIPPED, when: "custom_field_chars > 200", effect: advisory, message: "Frontmatter is stripped when the skill is used, so the text in {custom_fields} never reaches the model.", fix: "Move instructions from frontmatter into the SKILL.md body."} notes: - "Docs (V1) say one level deep and a 1-1024 description; runtime matches the V2 docs: recursive, no length cap." diff --git a/src/skillevaluator/validators/schema.py b/src/skillevaluator/validators/schema.py index 0b8e0a41c..44d83455e 100644 --- a/src/skillevaluator/validators/schema.py +++ b/src/skillevaluator/validators/schema.py @@ -25,9 +25,11 @@ MAX_SKILL_MD_LINES, RECOMMENDED_BODY_SECTIONS, REQUIRED_BODY_SECTIONS, + SCAN_EXCLUDED_DIRS, SCAN_EXCLUDED_FILES, SCHEMA_ALLOWED_DIRS_ENV, SKILL_MANIFEST_FILE, + SKILL_MANIFEST_VARIANTS, ) from skillevaluator.logging_config import get_logger from skillevaluator.models.result import Finding, Severity @@ -390,8 +392,9 @@ def _validate_single_skill(self, skill_path: Path) -> ValidationResult: message=( "Skill manifest uses non-canonical name 'skill.md' — " "the agentskills.io spec requires 'SKILL.md' (uppercase). " - "On case-sensitive filesystems (Linux), this will not be " - "recognized by spec-compliant tooling" + "Codex and Hermes never load it; Claude Code, OpenCode, Copilot CLI " + "and OpenClaw load it only on case-insensitive filesystems (macOS), " + "so it can work locally and be missing on Linux" ), file_path=str(skill_md), suggestion="Rename 'skill.md' to 'SKILL.md' to comply with the agentskills.io spec", @@ -416,7 +419,7 @@ def _validate_single_skill(self, skill_path: Path) -> ValidationResult: result.merge(self._validate_name_matches_directory(skill_path, frontmatter)) result.merge(self._validate_author(frontmatter, str(skill_md))) result.merge(self._validate_metadata_id(frontmatter, str(skill_md))) - result.merge(self._validate_portability(skill_md, frontmatter)) + result.merge(self._validate_portability(skill_path, skill_md, frontmatter)) return result @@ -716,12 +719,25 @@ def _portability_finding( metadata=dict(metadata), ) - def _validate_portability(self, skill_md: Path, frontmatter: SkillFrontmatter) -> ValidationResult: + def _validate_portability( + self, skill_path: Path, skill_md: Path, frontmatter: SkillFrontmatter + ) -> ValidationResult: """Flag spec-valid patterns that common agent harnesses load differently or not at all.""" result = ValidationResult() file_path = str(skill_md) findings: list[Finding] = [] + if skill_md.is_symlink(): + findings.append( + self._portability_finding( + "manifest_symlink", + Severity.MEDIUM, + "SKILL.md is a symlink; Codex, Hermes and OpenClaw do not load symlinked manifests", + file_path, + "Replace the symlink with a regular SKILL.md file", + ) + ) + try: raw = skill_md.read_bytes() except OSError: @@ -736,6 +752,25 @@ def _validate_portability(self, skill_md: Path, frontmatter: SkillFrontmatter) - "Save SKILL.md as UTF-8 without BOM", ) ) + nested = sorted( + path + for name in SKILL_MANIFEST_VARIANTS + for path in skill_path.rglob(name) + if path.parent != skill_path + and not any(part in SCAN_EXCLUDED_DIRS for part in path.relative_to(skill_path).parts) + ) + for path in nested: + findings.append( + self._portability_finding( + "nested_manifest", + Severity.MEDIUM, + f"Nested skill manifest '{path.relative_to(skill_path).as_posix()}' inside this skill; " + "Codex, OpenCode and Hermes load it as a separate skill, others ignore it", + str(path), + "Rename the nested file or move it out of the skill folder", + ) + ) + description = frontmatter.description utf16_units = len(description.encode("utf-16-le")) // 2 if len(description) <= DESCRIPTION_MAX_LENGTH < utf16_units: diff --git a/tests/harness/test_overlay.py b/tests/harness/test_overlay.py index 52a013f8e..86e82cd2b 100644 --- a/tests/harness/test_overlay.py +++ b/tests/harness/test_overlay.py @@ -98,6 +98,17 @@ def test_copilot_shows_body_for_missing_description_but_drops_non_string(tmp_pat assert "CP-STRICT-YAML" in _ids(_rows(listed), "copilot-cli") +def test_symlinked_manifest(tmp_path: Path): + skill = _skill(tmp_path) + target = tmp_path / "real.md" + (skill / "SKILL.md").rename(target) + (skill / "SKILL.md").symlink_to(target) + + status = _status(skill) + + assert {h for h, s in status.items() if s == "not_loaded"} == {"codex", "hermes", "openclaw"} + + def test_install_root_only_applies_inside_known_harness_roots(tmp_path: Path): skill = tmp_path / ".claude" / "skills" / "demo-skill" skill.parent.mkdir(parents=True) @@ -320,6 +331,20 @@ def test_listed_description_projection(tmp_path: Path): assert rows["opencode"]["listed"]["mode"] == rows["openclaw"]["listed"]["mode"] == "full" +def test_bundle_files_symlinks_and_large_references(tmp_path: Path): + skill = _skill(tmp_path) + (skill / "references").mkdir() + (skill / "references" / "big.md").write_text("line\n" * 20000) + outside = tmp_path / "shared.md" + outside.write_text("shared") + (skill / "references" / "shared.md").symlink_to(outside) + facts = skill_facts(skill) + rows = _rows(skill) + + assert facts["resource_symlinks"] == facts["resource_symlink_escapes"] == 1 + assert "HM-RESOURCE-SYMLINK" in _ids(rows, "hermes") + + def test_fix_reaches_findings_and_panels(tmp_path: Path): skill = _skill(tmp_path, desc="Use when testing emoji. " + "\U0001f600" * 600) result = HarnessValidator().validate(skill) diff --git a/tests/validators/test_schema.py b/tests/validators/test_schema.py index 88633a00e..6e1721ed4 100644 --- a/tests/validators/test_schema.py +++ b/tests/validators/test_schema.py @@ -1614,6 +1614,34 @@ def test_bom_is_medium_and_does_not_fail(self, tmp_path: Path): assert result.passed, result.errors assert [f.severity for f in _checks(result, "manifest_bom")] == ["medium"] + def test_symlinked_manifest_is_medium(self, tmp_path: Path): + skill_dir = _write_skill(tmp_path, _BASE_FM) + target = tmp_path / "real.md" + (skill_dir / "SKILL.md").rename(target) + (skill_dir / "SKILL.md").symlink_to(target) + + result = SchemaValidator().validate(skill_dir) + + assert result.passed, result.errors + assert len(_checks(result, "manifest_symlink")) == 1 + + def test_nested_manifest_is_medium(self, tmp_path: Path): + skill_dir = _write_skill(tmp_path, _BASE_FM) + (skill_dir / "references" / "inner").mkdir(parents=True) + (skill_dir / "references" / "inner" / "SKILL.md").write_text("---\nname: inner\n---\n") + + findings = _checks(SchemaValidator().validate(skill_dir), "nested_manifest") + + assert len(findings) == 1 + assert "references/inner/SKILL.md" in findings[0].message + + def test_nested_manifest_under_excluded_dir_is_ignored(self, tmp_path: Path): + skill_dir = _write_skill(tmp_path, _BASE_FM) + (skill_dir / "evals" / "snapshot").mkdir(parents=True) + (skill_dir / "evals" / "snapshot" / "SKILL.md").write_text("---\nname: snapshot\n---\n") + + assert not _checks(SchemaValidator().validate(skill_dir), "nested_manifest") + def test_description_over_utf16_limit_is_medium(self, tmp_path: Path): description = "Use when testing. " + "\U0001f600" * 600 fm = _BASE_FM.replace("Use when checking harness portability of a skill.", description) From 0af7fbf2f225b5db1840bae91b4fe0b2f4e5b1f2 Mon Sep 17 00:00:00 2001 From: Christopher Kevin Date: Fri, 13 Nov 2026 22:18:07 +0000 Subject: [PATCH 3/6] fix(harness): address review findings on descriptions and manifest location Signed-off-by: Christopher Kevin --- src/skillevaluator/harness/overlay.py | 10 +++++++--- src/skillevaluator/harness/profiles/hermes.yaml | 2 +- src/skillevaluator/validators/schema.py | 6 +++--- tests/harness/test_overlay.py | 12 ++++++++++++ tests/validators/test_schema.py | 1 + 5 files changed, 24 insertions(+), 7 deletions(-) diff --git a/src/skillevaluator/harness/overlay.py b/src/skillevaluator/harness/overlay.py index c6616aa11..7f660a3b0 100644 --- a/src/skillevaluator/harness/overlay.py +++ b/src/skillevaluator/harness/overlay.py @@ -178,8 +178,8 @@ def skill_facts(skill_path: Path) -> dict[str, Any]: "description_type": type(description).__name__ if description is not None else "none", "description_codepoints": len(description) if isinstance(description, str) else 0, "description_has_quote": isinstance(description, str) and '"' in description, - "description_utf16_units": len(description.encode("utf-16-le")) // 2 if isinstance(description, str) else 0, - "trigger_offset": trigger.start() if trigger else None, + "description_utf16_units": _utf16_units(description), + "trigger_end": trigger.end() if trigger else None, "name_missing": "name" not in data, "frontmatter_bom": raw.startswith(b"\xef\xbb\xbf"), "frontmatter_duplicate_keys": bool(_duplicate_frontmatter_keys(fm_yaml)), @@ -187,7 +187,7 @@ def skill_facts(skill_path: Path) -> dict[str, Any]: "custom_fields": ", ".join(map(str, custom)), "custom_field_chars": sum(len(v) if isinstance(v, str) else len(yaml.safe_dump(v)) for v in custom.values()), "description_over": max(0, (len(description) if isinstance(description, str) else 0) - 1024), - "utf16_over": max(0, (len(description.encode("utf-16-le")) // 2 if isinstance(description, str) else 0) - 1024), + "utf16_over": max(0, (_utf16_units(description)) - 1024), } @@ -196,6 +196,10 @@ def facts_for(skills: list[Path]) -> dict[Path, dict[str, Any]]: return {skill: skill_facts(skill) for skill in skills} +def _utf16_units(value: Any) -> int: + return len(value.encode("utf-16-le", "surrogatepass")) // 2 if isinstance(value, str) else 0 + + def listed_description(profile: dict[str, Any], facts: dict[str, Any]) -> dict[str, Any]: """What the profile says this harness puts in the model's skill list for the description.""" listing = profile.get("listing") or {} diff --git a/src/skillevaluator/harness/profiles/hermes.yaml b/src/skillevaluator/harness/profiles/hermes.yaml index 657062c3c..d0b4083be 100644 --- a/src/skillevaluator/harness/profiles/hermes.yaml +++ b/src/skillevaluator/harness/profiles/hermes.yaml @@ -10,7 +10,7 @@ limits: {listing_desc_chars: 60} listing: {cut: 60} rules: - {id: HM-ROOT, when: "install_root not in roots", effect: not_loaded, outcome: not found, message: "Hermes reads ~/.hermes/skills, and project .hermes/skills or .agents/skills only when trusted.", fix: "Install it under ~/.hermes/skills, or .hermes/skills or .agents/skills in a trusted repo."} - - {id: HM-DESC-60, when: "trigger_offset is None or trigger_offset > 60", effect: advisory, outcome: listing shortened, message: "The skill list shows only the first ~60 chars of the description (57 + '...' in 0.16, a word boundary near 59 on main), and the trigger isn't in them.", fix: "Put the trigger (\"Use when …\") in the first 57 characters."} + - {id: HM-DESC-60, when: "trigger_end is None or trigger_end > 60", effect: advisory, outcome: listing shortened, message: "The skill list shows only the first ~60 chars of the description (57 + '...' in 0.16, a word boundary near 59 on main), and the trigger isn't in them.", fix: "Put the trigger (\"Use when …\") in the first 57 characters."} - {id: HM-DESC-MISSING, when: "description_missing or description_empty", effect: degraded, message: "Listed by name with an empty description.", fix: "Add a non-empty string description."} - {id: HM-DUP-KEY, when: "frontmatter_duplicate_keys", effect: advisory, message: "Duplicate keys: last value wins.", fix: "Remove the duplicate frontmatter key."} notes: diff --git a/src/skillevaluator/validators/schema.py b/src/skillevaluator/validators/schema.py index 0b8e0a41c..96435a1a4 100644 --- a/src/skillevaluator/validators/schema.py +++ b/src/skillevaluator/validators/schema.py @@ -737,7 +737,7 @@ def _validate_portability(self, skill_md: Path, frontmatter: SkillFrontmatter) - ) ) description = frontmatter.description - utf16_units = len(description.encode("utf-16-le")) // 2 + utf16_units = len(description.encode("utf-16-le", "surrogatepass")) // 2 if len(description) <= DESCRIPTION_MAX_LENGTH < utf16_units: findings.append( self._portability_finding( @@ -752,8 +752,8 @@ def _validate_portability(self, skill_md: Path, frontmatter: SkillFrontmatter) - ) trigger = _TRIGGER_RE.search(description) - if trigger is None or trigger.start() >= DESCRIPTION_TRIGGER_WINDOW: - where = "no 'Use when ...' trigger" if trigger is None else f"trigger starts at character {trigger.start()}" + if trigger is None or trigger.end() > DESCRIPTION_TRIGGER_WINDOW: + where = "no 'Use when ...' trigger" if trigger is None else f"its trigger at characters {trigger.start()}-{trigger.end()}" findings.append( self._portability_finding( "description_trigger", diff --git a/tests/harness/test_overlay.py b/tests/harness/test_overlay.py index 52a013f8e..bdcbd77c2 100644 --- a/tests/harness/test_overlay.py +++ b/tests/harness/test_overlay.py @@ -403,3 +403,15 @@ def test_tab_after_spaces_that_breaks_yaml_is_flagged(tmp_path: Path): (skill / "SKILL.md").write_text("---\nname: demo-skill\nmetadata:\n \tauthor: x\n---\nBody\n") assert skill_facts(skill)["frontmatter_tab_indent"] is True + + +def test_lone_surrogate_description_is_counted_not_fatal(tmp_path: Path): + skill = _skill(tmp_path, desc='"Use when checking \\ud800 harness compatibility."') + + assert skill_facts(skill)["description_utf16_units"] > 0 + + +def test_trigger_cut_at_the_listing_window_counts_as_missing(tmp_path: Path): + facts = skill_facts(_skill(tmp_path, desc="x" * 55 + " Use when checking harness compatibility.")) + + assert facts["trigger_end"] > 60 diff --git a/tests/validators/test_schema.py b/tests/validators/test_schema.py index 88633a00e..c0f233501 100644 --- a/tests/validators/test_schema.py +++ b/tests/validators/test_schema.py @@ -1636,6 +1636,7 @@ def test_bmp_description_at_limit_has_no_utf16_finding(self, tmp_path: Path): ("Use this skill to format tables in reports.", False), ("Formats tables, charts and other structured report content nicely. Use when needed.", True), ("Formats tables in reports.", True), + ("Formats tables, charts and structured report sections. Use when needed.", True), ], ) def test_description_trigger_window(self, tmp_path: Path, description: str, expected: bool): From 61ccfa4942959e9b619673ed94a03611ca3807e9 Mon Sep 17 00:00:00 2001 From: Christopher Kevin Date: Fri, 13 Nov 2026 22:18:14 +0000 Subject: [PATCH 4/6] fix(harness): address review findings on descriptions and manifest location Signed-off-by: Christopher Kevin --- src/skillevaluator/harness/overlay.py | 39 +++++++++++-------- .../harness/profiles/codex.yaml | 2 +- .../harness/profiles/hermes.yaml | 2 +- tests/harness/test_overlay.py | 31 +++++++++++++++ 4 files changed, 56 insertions(+), 18 deletions(-) diff --git a/src/skillevaluator/harness/overlay.py b/src/skillevaluator/harness/overlay.py index f36ec7630..f678f4cd3 100644 --- a/src/skillevaluator/harness/overlay.py +++ b/src/skillevaluator/harness/overlay.py @@ -5,6 +5,7 @@ from __future__ import annotations import ast +import os import re from dataclasses import dataclass, field from pathlib import Path @@ -12,7 +13,7 @@ import yaml -from skillevaluator.constants import DESCRIPTION_TRIGGER_PATTERN, SCAN_EXCLUDED_DIRS, SKILL_MANIFEST_VARIANTS +from skillevaluator.constants import DESCRIPTION_TRIGGER_PATTERN, SKILL_MANIFEST_VARIANTS from skillevaluator.validators.frontmatter_parser import FRONTMATTER_PATTERN from skillevaluator.validators.schema import _duplicate_frontmatter_keys @@ -159,15 +160,19 @@ def _tab_indent_breaks_yaml(fm_yaml: str) -> bool: return False +def _shipped_paths(skill_path: Path) -> list[Path]: + """Files and symlinks a skill ships, without descending into VCS or cache folders.""" + found = [] + for folder, dirs, files in os.walk(skill_path): + dirs[:] = [d for d in dirs if d not in _NOT_SHIPPED_DIRS] + here = Path(folder) + found.extend(here / name for name in files) + found.extend(here / name for name in dirs if (here / name).is_symlink()) + return sorted(found) + + def _bundle_files(skill_path: Path, manifest: Path) -> list[Path]: - files = [] - for path in sorted(skill_path.rglob("*")): - parts = path.relative_to(skill_path).parts - if path == manifest or any(part in _NOT_SHIPPED_DIRS for part in parts): - continue - if path.is_symlink() or path.is_file(): - files.append(path) - return files + return [path for path in _shipped_paths(skill_path) if path != manifest] # Harnesses read every file a skill ships, evals/ included; only VCS and caches are skipped. @@ -211,9 +216,14 @@ def skill_facts(skill_path: Path) -> dict[str, Any]: target = "none" if skill_path.is_symlink(): resolved = skill_path.resolve() - base = skill_path.parent.resolve() + base = (Path(*_link_location_parts(skill_path)).parents[depth] if root else skill_path.parent).resolve() target = "inside_root" if base in resolved.parents else "outside_root" names = {p.name for p in skill_path.iterdir()} if skill_path.is_dir() else set() + nested = ( + [p for p in _shipped_paths(skill_path) if p.name in SKILL_MANIFEST_VARIANTS and p.parent != skill_path] + if skill_path.is_dir() + else [] + ) custom = {k: v for k, v in data.items() if str(k) not in _KNOWN_FIELDS} name = _skill_name(skill_path, data) return { @@ -222,11 +232,8 @@ def skill_facts(skill_path: Path) -> dict[str, Any]: "install_root": root, "grouping_depth": depth, "manifest_name_exact": "SKILL.md" in names, - "nested_skill_md": any( - p.parent != skill_path and not any(part in SCAN_EXCLUDED_DIRS for part in p.relative_to(skill_path).parts) - for n in SKILL_MANIFEST_VARIANTS - for p in skill_path.rglob(n) - ), + "nested_skill_md": bool(nested), + "nested_skill_md_exact": any(p.name == "SKILL.md" and not p.is_symlink() for p in nested), "skill_md_symlink": manifest.is_symlink(), "skill_dir_symlink_target": target, "frontmatter_missing": manifest.is_file() and FRONTMATTER_PATTERN.match(text) is None, @@ -244,7 +251,7 @@ def skill_facts(skill_path: Path) -> dict[str, Any]: "custom_fields": ", ".join(map(str, custom)), "custom_field_chars": sum(len(v) if isinstance(v, str) else len(yaml.safe_dump(v)) for v in custom.values()), "description_over": max(0, (len(description) if isinstance(description, str) else 0) - 1024), - "utf16_over": max(0, (len(description.encode("utf-16-le")) // 2 if isinstance(description, str) else 0) - 1024), + "utf16_over": max(0, (_utf16_units(description)) - 1024), **_bundle_facts(skill_path, manifest), } diff --git a/src/skillevaluator/harness/profiles/codex.yaml b/src/skillevaluator/harness/profiles/codex.yaml index 757fababb..3a13ee90c 100644 --- a/src/skillevaluator/harness/profiles/codex.yaml +++ b/src/skillevaluator/harness/profiles/codex.yaml @@ -12,7 +12,7 @@ rules: - {id: CX-DESC-MISSING, when: "description_missing or description_empty or description_type != 'str'", effect: not_loaded, message: "Skill dropped: Codex requires a string description.", fix: "Add a non-empty string description."} - {id: CX-STRICT-YAML, when: "frontmatter_tab_indent or frontmatter_duplicate_keys", effect: not_loaded, message: "Skill dropped: invalid YAML (tabs or duplicate keys).", fix: "Use spaces, not tabs, and remove duplicate keys."} - {id: CX-BOM, when: "frontmatter_bom", effect: not_loaded, outcome: rejected, message: "Skill dropped: SKILL.md starts with a UTF-8 BOM.", fix: "Save SKILL.md as UTF-8 without a BOM."} - - {id: CX-NESTED, when: "nested_skill_md", effect: degraded, message: "The nested SKILL.md is loaded as a second, separate skill.", fix: "Move the nested skill to its own folder under the skills root, or rename its SKILL.md."} + - {id: CX-NESTED, when: "nested_skill_md_exact", effect: degraded, message: "The nested SKILL.md is loaded as a second, separate skill.", fix: "Move the nested skill to its own folder under the skills root, or rename its SKILL.md."} - {id: CX-DEPTH, when: "grouping_depth > 5", effect: not_loaded, outcome: not found, message: "Beyond Codex's scan depth of 6.", fix: "Install the skill at most 5 folders below the skills root."} - {id: CX-SYMLINK-FILE, when: "skill_md_symlink", effect: not_loaded, message: "Symlinked SKILL.md files are skipped (codex#15756).", fix: "Copy SKILL.md into the folder instead of symlinking the file (a symlinked folder works)."} - {id: CX-CASING, when: "not manifest_name_exact", effect: not_loaded, message: "Non-canonical name (skill.md/Skill.md): never loaded, on Linux or macOS (3/3 each).", fix: "Rename the file to SKILL.md (exact casing)."} diff --git a/src/skillevaluator/harness/profiles/hermes.yaml b/src/skillevaluator/harness/profiles/hermes.yaml index c13acaff3..41a6c518e 100644 --- a/src/skillevaluator/harness/profiles/hermes.yaml +++ b/src/skillevaluator/harness/profiles/hermes.yaml @@ -12,7 +12,7 @@ rules: - {id: HM-ROOT, when: "install_root not in roots", effect: not_loaded, outcome: not found, message: "Hermes reads ~/.hermes/skills, and project .hermes/skills or .agents/skills only when trusted.", fix: "Install it under ~/.hermes/skills, or .hermes/skills or .agents/skills in a trusted repo."} - {id: HM-DESC-60, when: "trigger_end is None or trigger_end > 60", effect: advisory, outcome: listing shortened, message: "The skill list shows only the first ~60 chars of the description (57 + '...' in 0.16, a word boundary near 59 on main), and the trigger isn't in them.", fix: "Put the trigger (\"Use when …\") in the first 57 characters."} - {id: HM-DESC-MISSING, when: "description_missing or description_empty", effect: degraded, message: "Listed by name with an empty description.", fix: "Add a non-empty string description."} - - {id: HM-NESTED, when: "nested_skill_md", effect: degraded, message: "The nested SKILL.md is loaded as a second, separate skill (hidden folders are walked too).", fix: "Move the nested skill to its own folder under the skills root, or rename its SKILL.md."} + - {id: HM-NESTED, when: "nested_skill_md_exact", effect: degraded, message: "The nested SKILL.md is loaded as a second, separate skill (hidden folders are walked too).", fix: "Move the nested skill to its own folder under the skills root, or rename its SKILL.md."} - {id: HM-SYMLINK-FILE, when: "skill_md_symlink", effect: not_loaded, message: "Symlinked SKILL.md files are not loaded.", fix: "Copy SKILL.md into the folder instead of symlinking the file (a symlinked folder works)."} - {id: HM-DUP-KEY, when: "frontmatter_duplicate_keys", effect: advisory, message: "Duplicate keys: last value wins.", fix: "Remove the duplicate frontmatter key."} - {id: HM-CASING, when: "not manifest_name_exact", effect: not_loaded, message: "Non-canonical name (skill.md/Skill.md): never loaded, on Linux or macOS (3/3 each).", fix: "Rename the file to SKILL.md (exact casing)."} diff --git a/tests/harness/test_overlay.py b/tests/harness/test_overlay.py index 521e22538..87fa7ef52 100644 --- a/tests/harness/test_overlay.py +++ b/tests/harness/test_overlay.py @@ -440,3 +440,34 @@ def test_trigger_cut_at_the_listing_window_counts_as_missing(tmp_path: Path): facts = skill_facts(_skill(tmp_path, desc="x" * 55 + " Use when checking harness compatibility.")) assert facts["trigger_end"] > 60 + + +def test_grouped_skill_linked_to_a_sibling_group_stays_inside_the_root(tmp_path: Path): + root = tmp_path / ".agents" / "skills" + real = root / "group-b" / "demo-skill" + real.parent.mkdir(parents=True) + _skill(tmp_path / "src").rename(real) + link = root / "group-a" / "demo-skill" + link.parent.mkdir() + link.symlink_to(real, target_is_directory=True) + + assert skill_facts(link)["skill_dir_symlink_target"] == "inside_root" + + +def test_nested_manifest_under_evals_is_reported(tmp_path: Path): + skill = _rooted(tmp_path) + (skill / "evals" / "fixture").mkdir(parents=True) + (skill / "evals" / "fixture" / "SKILL.md").write_text("---\nname: fixture\n---\n", encoding="utf-8") + + assert skill_facts(skill)["nested_skill_md"] is True + + +def test_lowercase_nested_manifest_is_not_a_second_skill_in_codex(tmp_path: Path): + skill = _rooted(tmp_path) + (skill / "sub").mkdir() + (skill / "sub" / "skill.md").write_text("---\nname: sub\n---\n", encoding="utf-8") + + facts = skill_facts(skill) + assert facts["nested_skill_md"] is True + assert facts["nested_skill_md_exact"] is False + assert _status(skill)["codex"] == "loads" From 47cf931522da06c90d8ff40769bcc57a47429940 Mon Sep 17 00:00:00 2001 From: Christopher Kevin Date: Fri, 13 Nov 2026 14:26:35 -0800 Subject: [PATCH 5/6] fix(harness): report nested manifests under evals/ in both checks The harness check counts a nested SKILL.md under evals/ or versions/ as a second skill, because harnesses scan those folders like any other. The schema nested_manifest check still skipped them, so the same skill got different findings depending on which check you read. Both checks now skip the same folders (VCS data, caches, dependencies), taken from one shared constant. The schema test that expected evals/ to be ignored now expects it to be reported, and a new test runs both checks on the same skill to keep them in agreement. Signed-off-by: Christopher Kevin --- src/skillevaluator/constants.py | 4 ++++ src/skillevaluator/harness/overlay.py | 6 ++---- src/skillevaluator/validators/schema.py | 11 ++++++++--- tests/harness/test_overlay.py | 16 ++++++++++++++++ tests/validators/test_schema.py | 11 ++++++++++- 5 files changed, 40 insertions(+), 8 deletions(-) diff --git a/src/skillevaluator/constants.py b/src/skillevaluator/constants.py index 685247dce..f42bbcf99 100644 --- a/src/skillevaluator/constants.py +++ b/src/skillevaluator/constants.py @@ -752,6 +752,10 @@ class ExitCode: SCAN_ARTIFACT_DIRS = frozenset({"evals", ".evals", "results", ".results", "versions", ".versions"}) +# Folders no harness reads as part of a skill: VCS data, caches and dependencies. The artifact +# folders above are not in this set because harnesses scan them like any other folder. +SKILL_NOT_SHIPPED_DIRS = SCAN_EXCLUDED_DIRS - SCAN_ARTIFACT_DIRS + PLUGIN_TREE_PRUNED_DIRS = SCAN_EXCLUDED_DIRS - {"__pycache__"} PLUGIN_TREE_MAX_DISCOVERED_PATHS = 20_000 diff --git a/src/skillevaluator/harness/overlay.py b/src/skillevaluator/harness/overlay.py index f678f4cd3..515f6de27 100644 --- a/src/skillevaluator/harness/overlay.py +++ b/src/skillevaluator/harness/overlay.py @@ -13,7 +13,7 @@ import yaml -from skillevaluator.constants import DESCRIPTION_TRIGGER_PATTERN, SKILL_MANIFEST_VARIANTS +from skillevaluator.constants import DESCRIPTION_TRIGGER_PATTERN, SKILL_MANIFEST_VARIANTS, SKILL_NOT_SHIPPED_DIRS from skillevaluator.validators.frontmatter_parser import FRONTMATTER_PATTERN from skillevaluator.validators.schema import _duplicate_frontmatter_keys @@ -164,7 +164,7 @@ def _shipped_paths(skill_path: Path) -> list[Path]: """Files and symlinks a skill ships, without descending into VCS or cache folders.""" found = [] for folder, dirs, files in os.walk(skill_path): - dirs[:] = [d for d in dirs if d not in _NOT_SHIPPED_DIRS] + dirs[:] = [d for d in dirs if d not in SKILL_NOT_SHIPPED_DIRS] here = Path(folder) found.extend(here / name for name in files) found.extend(here / name for name in dirs if (here / name).is_symlink()) @@ -175,8 +175,6 @@ def _bundle_files(skill_path: Path, manifest: Path) -> list[Path]: return [path for path in _shipped_paths(skill_path) if path != manifest] -# Harnesses read every file a skill ships, evals/ included; only VCS and caches are skipped. -_NOT_SHIPPED_DIRS = frozenset({".git", "__pycache__", "node_modules", ".venv"}) _HERMES_LINKED_DIRS = ("references", "templates", "assets", "scripts") diff --git a/src/skillevaluator/validators/schema.py b/src/skillevaluator/validators/schema.py index e2a92b2bd..90f6f1f7f 100644 --- a/src/skillevaluator/validators/schema.py +++ b/src/skillevaluator/validators/schema.py @@ -25,11 +25,11 @@ MAX_SKILL_MD_LINES, RECOMMENDED_BODY_SECTIONS, REQUIRED_BODY_SECTIONS, - SCAN_EXCLUDED_DIRS, SCAN_EXCLUDED_FILES, SCHEMA_ALLOWED_DIRS_ENV, SKILL_MANIFEST_FILE, SKILL_MANIFEST_VARIANTS, + SKILL_NOT_SHIPPED_DIRS, ) from skillevaluator.logging_config import get_logger from skillevaluator.models.result import Finding, Severity @@ -752,12 +752,13 @@ def _validate_portability( "Save SKILL.md as UTF-8 without BOM", ) ) + # Same folders the harness check skips: evals/ and versions/ are scanned like any other folder. nested = sorted( path for name in SKILL_MANIFEST_VARIANTS for path in skill_path.rglob(name) if path.parent != skill_path - and not any(part in SCAN_EXCLUDED_DIRS for part in path.relative_to(skill_path).parts) + and not any(part in SKILL_NOT_SHIPPED_DIRS for part in path.relative_to(skill_path).parts) ) for path in nested: findings.append( @@ -788,7 +789,11 @@ def _validate_portability( trigger = _TRIGGER_RE.search(description) if trigger is None or trigger.end() > DESCRIPTION_TRIGGER_WINDOW: - where = "no 'Use when ...' trigger" if trigger is None else f"its trigger at characters {trigger.start()}-{trigger.end()}" + where = ( + "no 'Use when ...' trigger" + if trigger is None + else f"its trigger at characters {trigger.start()}-{trigger.end()}" + ) findings.append( self._portability_finding( "description_trigger", diff --git a/tests/harness/test_overlay.py b/tests/harness/test_overlay.py index 87fa7ef52..701dba3d3 100644 --- a/tests/harness/test_overlay.py +++ b/tests/harness/test_overlay.py @@ -16,6 +16,7 @@ from skillevaluator.reporting.console_ui import final_check_ticker_row, summarize_tier1 from skillevaluator.tier1.commands import DEFAULT_CHECKS, run_validation from skillevaluator.validators.harness import HarnessValidator +from skillevaluator.validators.schema import SchemaValidator HARNESSES = ["claude-code", "codex", "copilot-cli", "hermes", "openclaw", "opencode"] BODY = "\n# Demo\n\n## Instructions\n\n1. Step\n\n## Examples\n\nExample.\n" @@ -462,6 +463,21 @@ def test_nested_manifest_under_evals_is_reported(tmp_path: Path): assert skill_facts(skill)["nested_skill_md"] is True +@pytest.mark.parametrize( + ("folder", "reported"), + [("evals", True), ("versions", True), ("references", True), ("node_modules", False), (".git", False)], +) +def test_schema_and_harness_agree_on_where_a_nested_manifest_counts(tmp_path: Path, folder: str, reported: bool): + skill = _rooted(tmp_path) + (skill / folder / "fixture").mkdir(parents=True) + (skill / folder / "fixture" / "SKILL.md").write_text("---\nname: fixture\n---\n", encoding="utf-8") + + schema = [f for f in SchemaValidator().validate(skill).findings if f.check_name == "nested_manifest"] + + assert skill_facts(skill)["nested_skill_md"] is reported + assert bool(schema) is reported + + def test_lowercase_nested_manifest_is_not_a_second_skill_in_codex(tmp_path: Path): skill = _rooted(tmp_path) (skill / "sub").mkdir() diff --git a/tests/validators/test_schema.py b/tests/validators/test_schema.py index d67322282..a0bea2169 100644 --- a/tests/validators/test_schema.py +++ b/tests/validators/test_schema.py @@ -1635,11 +1635,20 @@ def test_nested_manifest_is_medium(self, tmp_path: Path): assert len(findings) == 1 assert "references/inner/SKILL.md" in findings[0].message - def test_nested_manifest_under_excluded_dir_is_ignored(self, tmp_path: Path): + def test_nested_manifest_under_evals_is_reported(self, tmp_path: Path): skill_dir = _write_skill(tmp_path, _BASE_FM) (skill_dir / "evals" / "snapshot").mkdir(parents=True) (skill_dir / "evals" / "snapshot" / "SKILL.md").write_text("---\nname: snapshot\n---\n") + findings = _checks(SchemaValidator().validate(skill_dir), "nested_manifest") + + assert [f.file_path for f in findings] == [str(skill_dir / "evals" / "snapshot" / "SKILL.md")] + + def test_nested_manifest_under_dependency_dir_is_ignored(self, tmp_path: Path): + skill_dir = _write_skill(tmp_path, _BASE_FM) + (skill_dir / "node_modules" / "pkg").mkdir(parents=True) + (skill_dir / "node_modules" / "pkg" / "SKILL.md").write_text("---\nname: pkg\n---\n") + assert not _checks(SchemaValidator().validate(skill_dir), "nested_manifest") def test_description_over_utf16_limit_is_medium(self, tmp_path: Path): From 04eec015d6d0b62b5122254b8223462ec55fa969 Mon Sep 17 00:00:00 2001 From: Christopher Kevin Date: Fri, 13 Nov 2026 14:29:38 -0800 Subject: [PATCH 6/6] test(validators): give the valid-skill folder fixture a "Use when" trigger The schema validator now reports a low-severity description_trigger advisory for descriptions with no "Use when ..." trigger. The valid-skill fixture in test_schema_validator_mixed_valid_invalid had the description "Valid skill", so it picked up that advisory and its roll-up message changed from "All schema and structure checks passed" to "No blocking schema or structure findings (1 advisory finding(s))". The assertion looks for "passed", so it no longer matched. Give the fixture a description with a trigger phrase so it is a skill with no findings under the new rules. The assertion is unchanged. Signed-off-by: Christopher Kevin --- tests/validators/test_folder_validation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/validators/test_folder_validation.py b/tests/validators/test_folder_validation.py index 605353b9c..edef56de2 100644 --- a/tests/validators/test_folder_validation.py +++ b/tests/validators/test_folder_validation.py @@ -77,7 +77,7 @@ def test_schema_validator_mixed_valid_invalid(self, tmp_path): skill1_dir.mkdir() (skill1_dir / "SKILL.md").write_text("""--- name: valid-skill -description: Valid skill +description: Use when checking that a valid skill passes folder validation metadata: author: Test User ---