#!/usr/bin/env python3 """Verification script for Hermes Agent - outputs JSON report.""" import json import os import subprocess def run_cmd(cmd): """Run a shell command and return output.""" try: result = subprocess.run(cmd, shell=True, capture_output=True, text=True, timeout=30) return result.stdout.strip(), result.returncode except Exception as e: return str(e), 1 def main(): results = { "status": "ok", "checks": [] } # Check 1: Terminal works output, code = run_cmd("echo hermes-verification-pong") if code == 0 and "hermes-verification-pong" in output: results["checks"].append({"name": "terminal", "status": "passed", "output": output}) else: results["checks"].append({"name": "terminal", "status": "failed"}) results["status"] = "error" # Check 2: Skills directory exists if os.path.isdir("/root/.hermes/skills"): skill_count = len([f for f in os.listdir("/root/.hermes/skills") if f.endswith(".py") or os.path.isdir(os.path.join("/root/.hermes/skills", f))]) results["checks"].append({"name": "skills_dir", "status": "passed", "item_count": skill_count}) else: results["checks"].append({"name": "skills_dir", "status": "failed"}) results["status"] = "error" # Check 3: Python json module works try: test = json.loads('{"verify": true}') if test.get("verify") == True: results["checks"].append({"name": "json_module", "status": "passed"}) else: results["checks"].append({"name": "json_module", "status": "failed"}) results["status"] = "error" except Exception as e: results["checks"].append({"name": "json_module", "status": "failed", "error": str(e)}) results["status"] = "error" # Check 4: Config file readable try: with open("/root/.hermes/profiles/spark/config.yaml", "r") as f: content = f.read(100) results["checks"].append({"name": "config_read", "status": "passed", "preview": content[:50]}) except Exception as e: results["checks"].append({"name": "config_read", "status": "failed", "error": str(e)}) results["status"] = "error" # Check 5: Output directory writable try: os.makedirs("/root/.hermes/wizard-outputs/spark", exist_ok=True) with open("/root/.hermes/wizard-outputs/spark/verification_report.json", "w") as f: json.dump(results, f, indent=2) results["checks"].append({"name": "output_write", "status": "passed"}) except Exception as e: results["checks"].append({"name": "output_write", "status": "failed", "error": str(e)}) results["status"] = "error" return results if __name__ == "__main__": report = main() print(json.dumps(report, indent=2))