Skip to content

Open-source skills for designing and reviewing software with AI agents

fix(packaging): read plugin manifests as UTF-8 (#283)

Rishab Dugar Jain5ba5afa03f62
diff --git a/scripts/pack_plugin.py b/scripts/pack_plugin.py
index bf20013..bc40d2f 100644
--- a/scripts/pack_plugin.py
+++ b/scripts/pack_plugin.py
@@ -77,8 +77,8 @@ def build(root: Path, target: str, output: Path) -> tuple[Path, Path]:
for name in REQUIRED_SHARED + (HOST[target][0],):
if Path(name) not in files:
raise ValueError(f"Missing required file: {name}")
- manifest = json.loads((root / HOST[target][0]).read_text())
- portable = json.loads((root / "plugin.json").read_text())
+ manifest = json.loads((root / HOST[target][0]).read_text(encoding="utf-8"))
+ portable = json.loads((root / "plugin.json").read_text(encoding="utf-8"))
openai = portable.get("extensions", {}).get("com.openai", {})
if manifest.get("hooks") or portable.get("hooks") or openai.get("hooks"):
raise ValueError("Directory packages cannot contain hooks")
diff --git a/tests/unit/test_packaging.py b/tests/unit/test_packaging.py
index dd04b4b..12b721f 100644
--- a/tests/unit/test_packaging.py
+++ b/tests/unit/test_packaging.py
@@ -151,6 +151,21 @@ def test_rejects_symlinked_runtime_paths(
build(source, "openai", tmp_path / "output")
[email protected]("target", ["claude", "openai"])
+def test_reads_manifests_as_utf8(source: Path, tmp_path: Path, target: str) -> None:
+ # Only a non-UTF-8 default encoding, like cp1252 on the windows-2025 runner,
+ # fails this. The UTF-8 bytes of "Ё" include 0x81, which cp1252 cannot decode.
+ for name in ("plugin.json", ".claude-plugin/plugin.json",
+ ".codex-plugin/plugin.json"):
+ path = source / name
+ manifest = json.loads(path.read_text(encoding="utf-8"))
+ manifest["description"] = "Ёlephant — goldfish"
+ path.write_text(json.dumps(manifest, ensure_ascii=False), encoding="utf-8")
+ _, archive = build(source, target, tmp_path / "output")
+ with zipfile.ZipFile(archive) as bundle:
+ assert "Ёlephant" in bundle.read("plugin.json").decode("utf-8")
+
+
@pytest.mark.parametrize("reference", ["../escape.svg", "/tmp/icon.svg",
"./assets/missing.svg"])
def test_rejects_escaping_or_missing_manifest_assets(