Update plugin manifest versions, uvx pin args, and bundled skills/ directory.
(version: str | None = None, root: Path | None = None)
| 19 | |
| 20 | |
| 21 | def sync_manifests(version: str | None = None, root: Path | None = None) -> list[Path]: |
| 22 | """Update plugin manifest versions, uvx pin args, and bundled skills/ directory.""" |
| 23 | repo = root or ROOT |
| 24 | ver = version or read_package_version(repo / "pyproject.toml") |
| 25 | pkg_spec = f"graphifyy[sql,mcp]=={ver}" |
| 26 | updated: list[Path] = [] |
| 27 | |
| 28 | marketplace_path = repo / ".claude-plugin" / "marketplace.json" |
| 29 | marketplace = json.loads(marketplace_path.read_text(encoding="utf-8")) |
| 30 | marketplace["metadata"]["version"] = ver |
| 31 | for plugin in marketplace.get("plugins", []): |
| 32 | if plugin.get("name") == "graphify": |
| 33 | plugin["version"] = ver |
| 34 | marketplace_path.write_text(json.dumps(marketplace, indent=2) + "\n", encoding="utf-8") |
| 35 | updated.append(marketplace_path) |
| 36 | |
| 37 | for rel in (".claude-plugin/plugin.json", ".codex-plugin/plugin.json"): |
| 38 | p = repo / rel |
| 39 | data = json.loads(p.read_text(encoding="utf-8")) |
| 40 | data["version"] = ver |
| 41 | data["mcpServers"]["graphify"]["args"] = ["--from", pkg_spec, "graphify-mcp"] |
| 42 | p.write_text(json.dumps(data, indent=2) + "\n", encoding="utf-8") |
| 43 | updated.append(p) |
| 44 | |
| 45 | hooks_path = repo / "hooks" / "hooks.json" |
| 46 | hooks_data = json.loads(hooks_path.read_text(encoding="utf-8")) |
| 47 | for event_entries in hooks_data.get("hooks", {}).values(): |
| 48 | for entry in event_entries: |
| 49 | for hook in entry.get("hooks", []): |
| 50 | cmd = hook.get("command", "") |
| 51 | hook["command"] = re.sub( |
| 52 | r"graphifyy\[sql,mcp\]==\S+", |
| 53 | pkg_spec, |
| 54 | cmd, |
| 55 | ) |
| 56 | hooks_path.write_text(json.dumps(hooks_data, indent=2) + "\n", encoding="utf-8") |
| 57 | updated.append(hooks_path) |
| 58 | |
| 59 | skill_dst = repo / "skills" / "graphify" |
| 60 | refs_dst = skill_dst / "references" |
| 61 | refs_dst.mkdir(parents=True, exist_ok=True) |
| 62 | shutil.copyfile(repo / "graphify" / "skill.md", skill_dst / "SKILL.md") |
| 63 | updated.append(skill_dst / "SKILL.md") |
| 64 | for src_ref in sorted((repo / "graphify" / "skills" / "claude" / "references").glob("*.md")): |
| 65 | dst_ref = refs_dst / src_ref.name |
| 66 | shutil.copyfile(src_ref, dst_ref) |
| 67 | updated.append(dst_ref) |
| 68 | |
| 69 | return updated |
| 70 | |
| 71 | |
| 72 | if __name__ == "__main__": |