mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-12 07:20:45 +00:00
fix(skill-creator): exclude .git and VCS internals from .skill archives (#23180)
The packager included .git directory contents in .skill archives, causing unnecessary bloat, metadata leakage, and poor artifact hygiene. Hard-exclude .git, .svn, .hg, __pycache__, and node_modules from packaged archives. These paths are never useful in distributable skills. Fixes #23149 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -64,6 +64,8 @@ def package_skill(skill_path, output_dir=None):
|
|||||||
|
|
||||||
skill_filename = output_path / f"{skill_name}.skill"
|
skill_filename = output_path / f"{skill_name}.skill"
|
||||||
|
|
||||||
|
EXCLUDED_DIRS = {".git", ".svn", ".hg", "__pycache__", "node_modules"}
|
||||||
|
|
||||||
# Create the .skill file (zip format)
|
# Create the .skill file (zip format)
|
||||||
try:
|
try:
|
||||||
with zipfile.ZipFile(skill_filename, "w", zipfile.ZIP_DEFLATED) as zipf:
|
with zipfile.ZipFile(skill_filename, "w", zipfile.ZIP_DEFLATED) as zipf:
|
||||||
@@ -75,6 +77,10 @@ def package_skill(skill_path, output_dir=None):
|
|||||||
print(" This is a security restriction to prevent including arbitrary files.")
|
print(" This is a security restriction to prevent including arbitrary files.")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
rel_parts = file_path.relative_to(skill_path).parts
|
||||||
|
if any(part in EXCLUDED_DIRS for part in rel_parts):
|
||||||
|
continue
|
||||||
|
|
||||||
if file_path.is_file():
|
if file_path.is_file():
|
||||||
# Calculate the relative path within the zip
|
# Calculate the relative path within the zip
|
||||||
arcname = file_path.relative_to(skill_path.parent)
|
arcname = file_path.relative_to(skill_path.parent)
|
||||||
|
|||||||
Reference in New Issue
Block a user