Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion tools/skills_guard.py
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,15 @@ def _content_digest(skill_path: Path) -> str:
"""Canonical SHA-256 over relative paths and exact file bytes."""
h = hashlib.sha256()
if skill_path.is_dir():
for file_path in sorted(skill_path.rglob("*")):
# Sort by relative path string to stay symmetric with
# tools.skills_hub.bundle_content_hash (which sorts string keys).
# Sorting Path objects uses component-wise POSIX comparison and can
# produce a different order than string comparison when a file and a
# directory share a name prefix (e.g. styles.md vs styles/x.md).
for file_path in sorted(
skill_path.rglob("*"),
key=lambda p: p.relative_to(skill_path).as_posix(),
):
if file_path.is_file():
rel = file_path.relative_to(skill_path).as_posix()
h.update(rel.encode("utf-8") + b"\x00")
Expand Down