From 242e254018c18f60936a15d7cf872618c11fc544 Mon Sep 17 00:00:00 2001 From: helix4u <4317663+helix4u@users.noreply.github.com> Date: Sun, 3 May 2026 01:19:09 -0600 Subject: [PATCH] fix(skills): hash bytes bundle contents --- tests/tools/test_skills_hub.py | 11 +++++++++++ tools/skills_hub.py | 6 +++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/tests/tools/test_skills_hub.py b/tests/tools/test_skills_hub.py index 8e3453c04d8e..b955384f3c6e 100644 --- a/tests/tools/test_skills_hub.py +++ b/tests/tools/test_skills_hub.py @@ -901,6 +901,17 @@ def test_bundle_content_hash_matches_installed_content_hash(self, tmp_path): assert bundle_content_hash(bundle) == content_hash(skill_dir) + def test_bundle_content_hash_accepts_bytes_file_content(self): + bundle = SkillBundle( + name="demo-skill", + files={"SKILL.md": b"same content"}, + source="github", + identifier="owner/repo/demo-skill", + trust_level="community", + ) + + assert bundle_content_hash(bundle) == "sha256:a636bd7cd42060a4" + def test_reports_update_when_remote_hash_differs(self): lock = MagicMock() lock.list_installed.return_value = [{ diff --git a/tools/skills_hub.py b/tools/skills_hub.py index 0ce1d9b34e3b..aaeabd2c289b 100644 --- a/tools/skills_hub.py +++ b/tools/skills_hub.py @@ -2801,7 +2801,11 @@ def bundle_content_hash(bundle: SkillBundle) -> str: """Compute a deterministic hash for an in-memory skill bundle.""" h = hashlib.sha256() for rel_path in sorted(bundle.files): - h.update(bundle.files[rel_path].encode("utf-8")) + content = bundle.files[rel_path] + if isinstance(content, bytes): + h.update(content) + else: + h.update(content.encode("utf-8")) return f"sha256:{h.hexdigest()[:16]}"