Repository navigation
feat(harness): check which plugin formats each harness accepts #538
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
chrisknvidia
merged 4 commits into
main
from
feat/christopherk/harness-11-plugin-formats
Nov 14, 2026
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
42cae03
feat(harness): flag Hermes platforms and OpenClaw requirements
chrisknvidia 0e2784f
feat(harness): check which plugin formats each harness accepts
chrisknvidia c11fc4b
fix(harness): treat an unreadable or malformed plugin manifest as a f…
chrisknvidia 9163484
Merge branch 'main' into feat/christopherk/harness-11-plugin-formats
chrisknvidia File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| """Static plugin facts and per-harness plugin rules. | ||
|
|
||
| A profile's ``plugin`` section has ``rules`` (format acceptance, same expression | ||
| language as skill rules). Like the skill overlay, this is advisory and never | ||
| changes Tier 1 results. | ||
| """ | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import json | ||
| from pathlib import Path | ||
| from typing import Any | ||
|
|
||
| from skillevaluator.harness.overlay import _EFFECT_RANK, HarnessResult, _fill, _Rule | ||
|
|
||
| MANIFESTS = { | ||
| "claude": ".claude-plugin/plugin.json", | ||
| "codex": ".codex-plugin/plugin.json", | ||
| "cursor": ".cursor-plugin/plugin.json", | ||
| "copilot": ".github/plugin/plugin.json", | ||
| "copilot_alt": ".plugin/plugin.json", | ||
| "root_json": "plugin.json", | ||
| "hermes_native": "plugin.yaml", | ||
| } | ||
| AGENT_PLUGINS_SCHEMA = "https://agent-plugins.org/schemas/" | ||
| # Folders a harness can pick up without any manifest (Claude Code inline plugins). | ||
| DEFAULT_DIRS = ("skills", "commands", "agents", "hooks") | ||
|
|
||
|
|
||
| def is_plugin_root(path: Path) -> bool: | ||
| return any((path / rel).is_file() for rel in MANIFESTS.values()) | ||
|
|
||
|
|
||
| def plugin_facts(root: Path) -> dict[str, Any]: | ||
| """Facts about a plugin folder: manifest formats, manifest validity and name.""" | ||
| facts: dict[str, Any] = {"plugin_name": root.name, "manifest_invalid": False} | ||
| for fmt, rel in MANIFESTS.items(): | ||
| path = root / rel | ||
| facts[f"fmt_{fmt}"] = path.is_file() | ||
| if not path.is_file() or path.suffix != ".json": | ||
| continue | ||
| try: | ||
| data = json.loads(path.read_text(encoding="utf-8")) | ||
| except (OSError, ValueError, UnicodeDecodeError): | ||
| facts["manifest_invalid"] = True | ||
|
devin-ai-integration[bot] marked this conversation as resolved.
Resolved
|
||
| facts[f"fmt_{fmt}"] = False | ||
| continue | ||
| if isinstance(data, dict) and isinstance(data.get("name"), str) and data["name"]: | ||
| facts["plugin_name"] = data["name"] | ||
| if fmt == "root_json": | ||
| facts["fmt_agent_v1"] = isinstance(data, dict) and str(data.get("$schema", "")).startswith( | ||
| AGENT_PLUGINS_SCHEMA | ||
| ) | ||
|
chrisknvidia marked this conversation as resolved.
Resolved
|
||
| facts["fmt_copilot"] = facts["fmt_copilot"] or facts.pop("fmt_copilot_alt") | ||
| facts.setdefault("fmt_agent_v1", False) | ||
| facts["any_manifest"] = any(v for k, v in facts.items() if k.startswith("fmt_")) | ||
| facts["default_dirs"] = any((root / d).is_dir() for d in DEFAULT_DIRS) | ||
| return facts | ||
|
|
||
|
|
||
| def evaluate_plugin(profile: dict[str, Any], facts: dict[str, Any]) -> HarnessResult: | ||
| """Apply a profile's plugin rules.""" | ||
| section = profile.get("plugin") or {} | ||
| findings: list[dict[str, str]] = [] | ||
| worst = -1 | ||
| for rule in section.get("rules", []): | ||
| if not _Rule.evaluate(str(rule["when"]), {**facts, "always": True}): | ||
| continue | ||
| finding = {"id": rule["id"], "effect": rule["effect"], "message": _fill(rule["message"], facts)} | ||
| for key in ("fix", "outcome"): | ||
| if rule.get(key): | ||
| finding[key] = _fill(rule[key], facts) | ||
| findings.append(finding) | ||
| worst = max(worst, _EFFECT_RANK[rule["effect"]]) | ||
| verified = profile.get("verified", {}) | ||
| return HarnessResult( | ||
| harness=profile["harness"], | ||
| display_name=profile.get("display_name", profile["harness"]), | ||
| status="not_loaded" if worst == 2 else "degraded" if worst == 1 else "loads", | ||
| version=str(verified.get("version", "")), | ||
| verified_date=str(verified.get("date", "")), | ||
| findings=findings, | ||
| ) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,111 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| """Tests for plugin facts and per-harness plugin rules.""" | ||
|
|
||
| import json | ||
| from pathlib import Path | ||
|
|
||
| from click.testing import CliRunner | ||
|
|
||
| from skillevaluator.cli import cli | ||
| from skillevaluator.harness import evaluate_plugin, is_plugin_root, load_profiles, plugin_facts | ||
|
|
||
| AGENT_V1 = "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json" | ||
|
|
||
|
|
||
| def _plugin( | ||
| root: Path, manifest: str | None, data: dict | None = None, components: tuple[str, ...] = ("skills",) | ||
| ) -> Path: | ||
| root.mkdir(parents=True) | ||
| if manifest: | ||
| (root / manifest).parent.mkdir(parents=True, exist_ok=True) | ||
| (root / manifest).write_text(json.dumps(data or {"name": "demo", "version": "0.1.0"})) | ||
| if "skills" in components: | ||
| (root / "skills/demo").mkdir(parents=True) | ||
| (root / "skills/demo/SKILL.md").write_text("---\nname: demo\ndescription: Use when testing.\n---\nBody\n") | ||
| if "commands" in components: | ||
| (root / "commands").mkdir() | ||
| (root / "commands/run.md").write_text("---\ndescription: Run\n---\nRun $ARGUMENTS\n") | ||
| if "mcp" in components: | ||
| (root / ".mcp.json").write_text(json.dumps({"mcpServers": {"a": {"command": "x"}, "b": {"command": "y"}}})) | ||
| return root | ||
|
|
||
|
|
||
| def _status(root: Path) -> dict[str, tuple[str, list[str]]]: | ||
| facts = plugin_facts(root) | ||
| out = {} | ||
| for profile in load_profiles(): | ||
| result = evaluate_plugin(profile, facts) | ||
| out[result.harness] = (result.status, [f["id"] for f in result.findings]) | ||
| return out | ||
|
|
||
|
|
||
| def test_every_profile_has_plugin_section(): | ||
| for profile in load_profiles(): | ||
| assert "rules" in profile["plugin"] | ||
|
|
||
|
|
||
| def test_facts_detect_formats_name_and_components(tmp_path: Path): | ||
| root = _plugin(tmp_path / "p", ".claude-plugin/plugin.json", components=("skills", "commands", "mcp")) | ||
| facts = plugin_facts(root) | ||
| assert is_plugin_root(root) and facts["fmt_claude"] and not facts["fmt_codex"] | ||
| assert facts["plugin_name"] == "demo" | ||
|
|
||
|
|
||
| def test_claude_format_acceptance_matrix(tmp_path: Path): | ||
| s = _status(_plugin(tmp_path / "p", ".claude-plugin/plugin.json")) | ||
| assert {h: v[0] for h, v in s.items()} == { | ||
| "claude-code": "loads", | ||
| "codex": "loads", | ||
| "copilot-cli": "loads", | ||
| "hermes": "not_loaded", | ||
| "openclaw": "loads", | ||
| "opencode": "not_loaded", | ||
| } | ||
|
|
||
|
|
||
| def test_codex_only_bundle_is_refused_by_copilot(tmp_path: Path): | ||
| s = _status(_plugin(tmp_path / "p", ".codex-plugin/plugin.json")) | ||
| assert s["copilot-cli"][0] == "not_loaded" and s["codex"][0] == "loads" | ||
|
|
||
|
|
||
| def test_agent_v1_needs_schema_for_hermes(tmp_path: Path): | ||
| good = _status(_plugin(tmp_path / "a", "plugin.json", {"$schema": AGENT_V1, "name": "demo", "version": "1"})) | ||
| plain = _status(_plugin(tmp_path / "b", "plugin.json", {"name": "demo"})) | ||
| assert good["hermes"][0] == "loads" | ||
| assert plain["hermes"][0] == "not_loaded" | ||
|
|
||
|
|
||
| def test_claude_inline_plugin_needs_default_folders(tmp_path: Path): | ||
| inline = tmp_path / "inline" | ||
| _plugin(inline, None) | ||
| (inline / "plugin.json").write_text(json.dumps({"name": "inline"})) | ||
| empty = tmp_path / "empty" | ||
| empty.mkdir() | ||
| (empty / "plugin.json").write_text(json.dumps({"name": "empty"})) | ||
| assert plugin_facts(inline)["default_dirs"] and _status(inline)["claude-code"][0] == "loads" | ||
| assert _status(empty)["claude-code"] == ("not_loaded", ["CC-PLUGIN-EMPTY"]) | ||
|
|
||
|
|
||
| def test_malformed_manifest_is_a_fact_not_a_crash(tmp_path: Path): | ||
| root = _plugin(tmp_path / "p", None) | ||
| (root / ".claude-plugin").mkdir() | ||
| (root / ".claude-plugin/plugin.json").write_text("{not json") | ||
| facts = plugin_facts(root) | ||
| assert facts["manifest_invalid"] and facts["plugin_name"] == "p" | ||
|
|
||
|
|
||
| def test_harness_check_prints_plugin_panel(tmp_path: Path): | ||
| root = _plugin(tmp_path / "p", ".claude-plugin/plugin.json") | ||
| result = CliRunner().invoke(cli, ["harness-check", str(root)]) | ||
| assert result.exit_code == 0, result.output | ||
| assert "Plugin compatibility" in result.output and "opencode" in result.output | ||
|
|
||
|
|
||
| def test_unreadable_or_malformed_manifest_is_not_an_accepted_format(tmp_path: Path): | ||
| from skillevaluator.harness.plugin import plugin_facts | ||
|
|
||
| (tmp_path / ".claude-plugin").mkdir() | ||
| (tmp_path / ".claude-plugin" / "plugin.json").write_text("{not json", encoding="utf-8") | ||
| facts = plugin_facts(tmp_path) | ||
| assert facts["manifest_invalid"] and not facts["fmt_claude"] and not facts["any_manifest"] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.