fix: harden registry tooling, make tests hermetic, and restore metadata consistency (#168)
* chore: upgrade maintenance scripts to robust PyYAML parsing - Replaces fragile regex frontmatter parsing with PyYAML/yaml library - Ensures multi-line descriptions and complex characters are handled safely - Normalizes quoting and field ordering across all maintenance scripts - Updates validator to strictly enforce description quality * fix: restore and refine truncated skill descriptions - Recovered 223+ truncated descriptions from git history (6.5.0 regression) - Refined long descriptions into concise, complete sentences (<200 chars) - Added missing descriptions for brainstorming and orchestration skills - Manually fixed imagen skill description - Resolved dangling links in competitor-alternatives skill * chore: sync generated registry files and document fixes - Regenerated skills index with normalized forward-slash paths - Updated README and CATALOG to reflect restored descriptions - Documented restoration and script improvements in CHANGELOG.md * fix: restore missing skill and align metadata for full 955 count - Renamed SKILL.MD to SKILL.md in andruia-skill-smith to ensure indexing - Fixed risk level and missing section in andruia-skill-smith - Synchronized all registry files for final 955 skill count * chore(scripts): add cross-platform runners and hermetic test orchestration * fix(scripts): harden utf-8 output and clone target writeability * fix(skills): add missing date metadata for strict validation * chore(index): sync generated metadata dates * fix(catalog): normalize skill paths to prevent CI drift * chore: sync generated registry files * fix: enforce LF line endings for generated registry files
This commit is contained in:
@@ -26,45 +26,39 @@ def get_project_root():
|
||||
"""Get the project root directory."""
|
||||
return os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
import yaml
|
||||
|
||||
def parse_frontmatter(content):
|
||||
"""Parse frontmatter from SKILL.md content."""
|
||||
"""Parse frontmatter from SKILL.md content using PyYAML."""
|
||||
fm_match = re.search(r'^---\s*\n(.*?)\n---', content, re.DOTALL)
|
||||
if not fm_match:
|
||||
return None, content
|
||||
|
||||
fm_text = fm_match.group(1)
|
||||
metadata = {}
|
||||
for line in fm_text.split('\n'):
|
||||
if ':' in line and not line.strip().startswith('#'):
|
||||
key, val = line.split(':', 1)
|
||||
metadata[key.strip()] = val.strip().strip('"').strip("'")
|
||||
|
||||
return metadata, content
|
||||
try:
|
||||
metadata = yaml.safe_load(fm_text) or {}
|
||||
return metadata, content
|
||||
except yaml.YAMLError as e:
|
||||
print(f"⚠️ YAML parsing error: {e}")
|
||||
return None, content
|
||||
|
||||
def reconstruct_frontmatter(metadata):
|
||||
"""Reconstruct frontmatter from metadata dict."""
|
||||
lines = ["---"]
|
||||
|
||||
# Order: id, name, description, category, risk, source, tags, date_added
|
||||
priority_keys = ['id', 'name', 'description', 'category', 'risk', 'source', 'tags']
|
||||
"""Reconstruct frontmatter from metadata dict using PyYAML."""
|
||||
# Ensure important keys are at the top if they exist
|
||||
ordered = {}
|
||||
priority_keys = ['id', 'name', 'description', 'category', 'risk', 'source', 'tags', 'date_added']
|
||||
|
||||
for key in priority_keys:
|
||||
if key in metadata:
|
||||
val = metadata[key]
|
||||
if isinstance(val, list):
|
||||
# Handle list fields like tags
|
||||
lines.append(f'{key}: {val}')
|
||||
elif ' ' in str(val) or any(c in str(val) for c in ':#"'):
|
||||
lines.append(f'{key}: "{val}"')
|
||||
else:
|
||||
lines.append(f'{key}: {val}')
|
||||
ordered[key] = metadata[key]
|
||||
|
||||
# Add date_added at the end
|
||||
if 'date_added' in metadata:
|
||||
lines.append(f'date_added: "{metadata["date_added"]}"')
|
||||
|
||||
lines.append("---")
|
||||
return '\n'.join(lines)
|
||||
# Add any remaining keys
|
||||
for key, value in metadata.items():
|
||||
if key not in ordered:
|
||||
ordered[key] = value
|
||||
|
||||
fm_text = yaml.dump(ordered, sort_keys=False, allow_unicode=True, width=1000).strip()
|
||||
return f"---\n{fm_text}\n---"
|
||||
|
||||
def update_skill_frontmatter(skill_path, metadata):
|
||||
"""Update a skill's frontmatter with new metadata."""
|
||||
|
||||
Reference in New Issue
Block a user