#!/usr/bin/env python3 """Validate Hermes profile structure and output status report.""" import os import json from pathlib import Path PROFILE_DIR = Path("/root/.hermes/profiles/spark") WIZARD_OUTPUT = Path("/root/.hermes/wizard-outputs/spark") VALID_CATEGORIES = { "notes", "projects", "research", "skills", "tools", "skills", "templates", "scripts", "config", "cache", "memories", "plugins", "cron", "scratch" } def validate_profile(): """Validate profile directory structure.""" results = { "profile_exists": PROFILE_DIR.exists(), "profile_is_dir": PROFILE_DIR.is_dir() if PROFILE_DIR.exists() else False, "stats": {}, "valid_structure": True, "issues": [] } if not results["profile_exists"]: results["issues"].append("Profile directory does not exist") results["valid_structure"] = False return results # List contents contents = [] for item in PROFILE_DIR.iterdir(): item_type = "dir" if item.is_dir() else "file" contents.append({"name": item.name, "type": item_type}) results["stats"]["item_count"] = len(contents) results["stats"]["contents"] = sorted(contents, key=lambda x: x["name"]) # Check for expected subdirectories expected_dirs = {"skills", "memories", "cache"} found_dirs = {c["name"] for c in contents if c["type"] == "dir"} missing = expected_dirs - found_dirs if missing: results["issues"].append(f"Missing expected dirs: {missing}") results["valid_structure"] = False results["stats"]["found_dirs"] = list(found_dirs) results["valid_structure"] = results["valid_structure"] and len(results["issues"]) == 0 return results def main(): results = validate_profile() # Output as JSON to stdout print(json.dumps(results, indent=2)) # Also write to wizard output output_file = WIZARD_OUTPUT / "validation_report.json" with open(output_file, "w") as f: json.dump(results, f, indent=2) # Return exit code based on validation return 0 if results["valid_structure"] else 1 if __name__ == "__main__": exit(main())