110 lines
3.3 KiB
Python
110 lines
3.3 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Hermes Skills Inventory - Measures and reports on available Hermes skills.
|
|
Produces a JSON report with skill metadata.
|
|
|
|
Usage: python measure_hermes_skills.py [--output <file>]
|
|
"""
|
|
|
|
import json
|
|
import os
|
|
from pathlib import Path
|
|
from datetime import datetime
|
|
from typing import Dict, List, Any
|
|
|
|
def discover_skills(skills_dir: str = None) -> List[Dict[str, Any]]:
|
|
"""Discover all skills in the skills directory."""
|
|
if skills_dir is None:
|
|
skills_dir = Path.home() / ".hermes" / "profiles" / "spark" / "skills"
|
|
else:
|
|
skills_dir = Path(skills_dir)
|
|
|
|
if not skills_dir.exists():
|
|
return []
|
|
|
|
skills = []
|
|
for item in skills_dir.iterdir():
|
|
if item.is_dir() and not item.name.startswith('.'):
|
|
skill_info = {
|
|
"name": item.name,
|
|
"path": str(item),
|
|
"has_skill_md": (item / "SKILL.md").exists(),
|
|
"files": [],
|
|
"categories": []
|
|
}
|
|
|
|
# List files in skill directory
|
|
for f in item.iterdir():
|
|
if f.is_file():
|
|
skill_info["files"].append(f.name)
|
|
if f.suffix in ['.py']:
|
|
skill_info["categories"].append("python")
|
|
elif f.suffix in ['.md', '.txt']:
|
|
skill_info["categories"].append("documentation")
|
|
|
|
skills.append(skill_info)
|
|
|
|
return sorted(skills, key=lambda x: x["name"])
|
|
|
|
def measure_skills(skills: List[Dict]) -> Dict[str, Any]:
|
|
"""Measure skill inventory metrics."""
|
|
python_scripts = 0
|
|
total_files = 0
|
|
|
|
for skill in skills:
|
|
total_files += len(skill.get("files", []))
|
|
for cat in skill.get("categories", []):
|
|
if cat == "python":
|
|
python_scripts += 1
|
|
|
|
return {
|
|
"total_skills": len(skills),
|
|
"total_files": total_files,
|
|
"python_scripts": python_scripts,
|
|
"skipped": 0
|
|
}
|
|
|
|
def generate_report(output_file: str = None) -> Dict[str, Any]:
|
|
"""Generate the complete skills inventory report."""
|
|
skills = discover_skills()
|
|
metrics = measure_skills(skills)
|
|
|
|
report = {
|
|
"generated_at": datetime.now().isoformat(),
|
|
"timestamp_utc": datetime.utcnow().isoformat() + "Z",
|
|
"profile": "spark",
|
|
"metrics": metrics,
|
|
"skills": skills
|
|
}
|
|
|
|
if output_file:
|
|
with open(output_file, 'w', encoding='utf-8') as f:
|
|
json.dump(report, f, indent=2)
|
|
print(f"Report written to: {output_file}")
|
|
|
|
return report
|
|
|
|
def main():
|
|
import sys
|
|
output_file = None
|
|
|
|
if "--output" in sys.argv:
|
|
idx = sys.argv.index("--output")
|
|
if idx + 1 < len(sys.argv):
|
|
output_file = sys.argv[idx + 1]
|
|
|
|
report = generate_report(output_file)
|
|
|
|
print(f"Hermes Skills Inventory Report")
|
|
print(f"==============================")
|
|
print(f"Profile: spark")
|
|
print(f"Total skills found: {report['metrics']['total_skills']}")
|
|
print(f"Total files: {report['metrics']['total_files']}")
|
|
print(f"Python scripts: {report['metrics']['python_scripts']}")
|
|
print()
|
|
print("Skills by name:")
|
|
for skill in report['skills']:
|
|
print(f" - {skill['name']} ({len(skill['files'])} files)")
|
|
|
|
if __name__ == "__main__":
|
|
main() |