feat: complete SHD MCP plugin workflows and widget
Validate SHD MCP plugin / validate (push) Has been cancelled

This commit is contained in:
2026-08-24 17:25:38 +03:00
parent 39fb5c02b7
commit 08cf3672a4
86 changed files with 1707 additions and 5 deletions
+84
View File
@@ -0,0 +1,84 @@
import json
import re
import unittest
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
PLUGIN = ROOT / "plugins" / "shd-mcp-plugin"
SKILLS = PLUGIN / "skills"
EXPECTED_SKILLS = {
"shd-active-projects",
"shd-analytics",
"shd-agents-operations",
"shd-discussions",
"shd-documents",
"shd-entity-resolution",
"shd-estimate-management",
"shd-event-positions",
"shd-finance-crm",
"shd-financial-account-audit",
"shd-gitea",
"shd-inventory",
"shd-notifications",
"shd-organizations-acl",
"shd-project-db-audit",
"shd-project-files",
"shd-project-status",
"shd-realtime-activity",
"shd-routing",
"shd-safe-bulk-change",
"shd-status-page",
"shd-task-workflow",
"shd-terms-contracts",
"shd-wiki-management",
}
class PluginPackageTests(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.manifest = json.loads(
(PLUGIN / ".codex-plugin" / "plugin.json").read_text(encoding="utf-8")
)
def test_manifest_points_to_real_package_parts(self):
self.assertEqual(self.manifest["name"], "shd-mcp-plugin")
self.assertRegex(self.manifest["version"], r"^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?$")
self.assertTrue((PLUGIN / self.manifest["skills"].removeprefix("./")).is_dir())
self.assertTrue((PLUGIN / self.manifest["mcpServers"].removeprefix("./")).is_file())
interface = self.manifest["interface"]
for field in ("composerIcon", "logo"):
asset = interface[field]
self.assertTrue((PLUGIN / asset.removeprefix("./")).is_file(), field)
self.assertLessEqual(len(interface["defaultPrompt"]), 3)
def test_all_expected_skills_have_contract_files(self):
actual = {path.parent.name for path in SKILLS.glob("*/SKILL.md")}
self.assertEqual(actual, EXPECTED_SKILLS)
routing = (SKILLS / "shd-routing" / "SKILL.md").read_text(encoding="utf-8")
for name in EXPECTED_SKILLS - {"shd-routing"}:
self.assertIn(f"`{name}`", routing, name)
for name in sorted(EXPECTED_SKILLS):
skill_dir = SKILLS / name
skill_text = (skill_dir / "SKILL.md").read_text(encoding="utf-8")
self.assertTrue(skill_text.startswith("---\n"), name)
self.assertRegex(skill_text, r"(?m)^name:\s*\S+", name)
self.assertRegex(skill_text, r"(?m)^description:\s*.+", name)
self.assertNotIn("[TODO:", skill_text, name)
references = list((skill_dir / "references").glob("*.md"))
self.assertTrue(references, f"{name} has no reference contract")
agents = skill_dir / "agents" / "openai.yaml"
agent_text = agents.read_text(encoding="utf-8")
self.assertIn("interface:", agent_text, name)
self.assertIn("display_name:", agent_text, name)
self.assertIn("short_description:", agent_text, name)
self.assertIn("allow_implicit_invocation: false", agent_text, name)
if __name__ == "__main__":
unittest.main()
+47
View File
@@ -0,0 +1,47 @@
import hashlib
import json
import unittest
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
WIDGET = ROOT / "plugins" / "shd-mcp-plugin" / "widgets" / "active-projects" / "v1"
class WidgetArtifactTests(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.manifest = json.loads((WIDGET / "manifest.json").read_text(encoding="utf-8"))
cls.resource = next(item for item in cls.manifest["resources"] if item["file"] == "index.html")
cls.html = (WIDGET / "index.html").read_text(encoding="utf-8")
def test_manifest_and_checksums_match_artifact(self):
digest = hashlib.sha256(self.html.encode("utf-8")).hexdigest()
self.assertEqual(self.resource["uri"], "ui://shd/active-projects/v1.html")
self.assertEqual(self.resource["mediaType"], "text/html;profile=mcp-app")
self.assertEqual(self.resource["bytes"], len(self.html.encode("utf-8")))
self.assertEqual(self.resource["sha256"], digest)
checksum = (WIDGET / "SHA256SUMS").read_text(encoding="utf-8").strip().split()
self.assertEqual(checksum, [digest, "index.html"])
license_path = (WIDGET / self.manifest["license"]).resolve()
self.assertEqual(license_path, (ROOT / "LICENSE").resolve())
source_path = (ROOT / self.manifest["source"]["path"]).resolve()
self.assertEqual(source_path, (WIDGET / "index.html").resolve())
def test_widget_uses_portable_bridge_and_no_external_script(self):
for marker in (
"ui/initialize",
"ui/notifications/initialized",
"ui/notifications/tool-input",
"ui/notifications/tool-result",
"tools/call",
"window.openai",
):
self.assertIn(marker, self.html, marker)
self.assertNotIn("<script src=", self.html.lower())
if __name__ == "__main__":
unittest.main()