"""The plugin ships two manifests — one for Claude Code, one for Codex.

`.claude-plugin/plugin.json` and `.codex-plugin/plugin.json` are separate files
with no build-time generation between them, so their `version` fields can drift.
A drifted Codex manifest ships a stale version to the Codex marketplace. These
tests fail loudly the moment the two fall out of sync.
"""

import json
from pathlib import Path

PLUGIN_ROOT = Path(__file__).resolve().parents[1]
CLAUDE_MANIFEST = PLUGIN_ROOT / ".claude-plugin" / "plugin.json"
CODEX_MANIFEST = PLUGIN_ROOT / ".codex-plugin" / "plugin.json"


def _load(path):
    return json.loads(path.read_text(encoding="utf-8"))


def test_both_manifests_exist():
    assert CLAUDE_MANIFEST.is_file(), ".claude-plugin/plugin.json missing"
    assert CODEX_MANIFEST.is_file(), ".codex-plugin/plugin.json missing"


def test_manifest_versions_match():
    claude_version = _load(CLAUDE_MANIFEST)["version"]
    codex_version = _load(CODEX_MANIFEST)["version"]
    assert claude_version == codex_version, (
        f".claude-plugin ({claude_version}) and .codex-plugin "
        f"({codex_version}) version drift — bump both together every release."
    )


def test_manifest_names_match():
    assert _load(CLAUDE_MANIFEST)["name"] == _load(CODEX_MANIFEST)["name"]
