|
| 1 | +name: Plugin sanity |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + pull_request: |
| 6 | + workflow_dispatch: |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: read |
| 10 | + |
| 11 | +jobs: |
| 12 | + sanity: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + steps: |
| 15 | + - uses: actions/checkout@v4 |
| 16 | + |
| 17 | + - uses: actions/setup-python@v5 |
| 18 | + with: |
| 19 | + python-version: "3.12" |
| 20 | + |
| 21 | + - name: Validate Claude Code plugin package |
| 22 | + run: | |
| 23 | + python - <<'PY' |
| 24 | + import json |
| 25 | + import re |
| 26 | + from pathlib import Path |
| 27 | +
|
| 28 | + root = Path.cwd() |
| 29 | +
|
| 30 | + def fail(message: str) -> None: |
| 31 | + raise SystemExit(message) |
| 32 | +
|
| 33 | + def load_json(path: Path) -> dict: |
| 34 | + try: |
| 35 | + return json.loads(path.read_text(encoding="utf-8")) |
| 36 | + except Exception as exc: |
| 37 | + fail(f"{path} is not valid JSON: {exc}") |
| 38 | +
|
| 39 | + marketplace = load_json(root / ".claude-plugin" / "marketplace.json") |
| 40 | + entries = marketplace.get("plugins") |
| 41 | + if not isinstance(entries, list): |
| 42 | + fail("marketplace plugins must be a list") |
| 43 | +
|
| 44 | + docent_entries = [entry for entry in entries if entry.get("name") == "docent"] |
| 45 | + if len(docent_entries) != 1: |
| 46 | + fail("marketplace must contain exactly one docent plugin entry") |
| 47 | +
|
| 48 | + entry = docent_entries[0] |
| 49 | + plugin_dir = root / entry.get("source", "") |
| 50 | + if not plugin_dir.is_dir(): |
| 51 | + fail(f"marketplace source does not exist: {plugin_dir}") |
| 52 | +
|
| 53 | + manifest = load_json(plugin_dir / ".claude-plugin" / "plugin.json") |
| 54 | + if manifest.get("name") != "docent": |
| 55 | + fail("plugin manifest name must be docent") |
| 56 | +
|
| 57 | + version = manifest.get("version") |
| 58 | + if not isinstance(version, str) or not re.fullmatch(r"\d+\.\d+\.\d+", version): |
| 59 | + fail("plugin manifest version must be plain major.minor.patch") |
| 60 | + if entry.get("version") != version: |
| 61 | + fail("marketplace docent version must match plugin manifest version") |
| 62 | +
|
| 63 | + required_files = [ |
| 64 | + ".claude-plugin/plugin.json", |
| 65 | + ".mcp.json", |
| 66 | + "skills/docent/SKILL.md", |
| 67 | + "skills/docent/analysis.md", |
| 68 | + "skills/docent/dql-reference.md", |
| 69 | + "skills/docent/ingestion-reference.md", |
| 70 | + "skills/docent/ingestion.md", |
| 71 | + "skills/docent/readings-reference.md", |
| 72 | + "skills/docent/report.md", |
| 73 | + ] |
| 74 | + for rel_path in required_files: |
| 75 | + path = plugin_dir / rel_path |
| 76 | + if not path.is_file(): |
| 77 | + fail(f"required plugin file is missing: {rel_path}") |
| 78 | + if path.suffix == ".md" and not path.read_text(encoding="utf-8").strip(): |
| 79 | + fail(f"markdown file is empty: {rel_path}") |
| 80 | +
|
| 81 | + mcp = load_json(plugin_dir / ".mcp.json") |
| 82 | + server = mcp.get("mcpServers", {}).get("docent") |
| 83 | + if not isinstance(server, dict): |
| 84 | + fail(".mcp.json must define mcpServers.docent") |
| 85 | + if server.get("type") != "stdio" or server.get("command") != "uv": |
| 86 | + fail("docent MCP server must run as uv stdio") |
| 87 | + args = server.get("args") |
| 88 | + if not isinstance(args, list) or "--from" not in args: |
| 89 | + fail("docent MCP server args must include --from") |
| 90 | + package = args[args.index("--from") + 1] |
| 91 | + if package != "docent-python>=0.1.73": |
| 92 | + fail("docent MCP server must require docent-python>=0.1.73") |
| 93 | +
|
| 94 | + forbidden_names = {".mcp.local.json", "docent.env"} |
| 95 | + for path in plugin_dir.rglob("*"): |
| 96 | + if path.name in forbidden_names or path.name.startswith("docent.env."): |
| 97 | + fail(f"local credential/config file must not be published: {path}") |
| 98 | +
|
| 99 | + print("Claude Code plugin sanity checks passed") |
| 100 | + PY |
0 commit comments