#!/usr/bin/env python3 """ Spark Environment Verification Script Verifies key facts about the current Hermes/AI setup. Outputs results to: /root/.hermes/wizard-outputs/spark/env-verification.txt """ import os import platform import subprocess import sys from pathlib import Path def run_cmd(cmd, timeout=10): """Run a shell command and return output or error.""" try: result = subprocess.run( cmd, shell=True, capture_output=True, text=True, timeout=timeout ) return result.stdout.strip() if result.returncode == 0 else None except Exception: return None def check_python_version(): """Check Python version.""" return f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}" def check_git(): """Check git version.""" return run_cmd("git --version") or "git not found" def check_os(): """Check OS info.""" return f"{platform.system()} {platform.release()}" def check_model_config(): """Read model config from YAML file.""" config_path = Path("/root/.hermes/profiles/spark/config.yaml") if not config_path.exists(): return None result = {} with open(config_path) as f: content = f.read() # Parse key values for line in content.split('\n'): if 'default:' in line and 'aliases' not in content.split('default:')[0]: result['default_model'] = line.split(':', 1)[1].strip() if 'provider:' in line and 'base_url' not in content.split('provider:')[0]: result['provider'] = line.split(':', 1)[1].strip() if 'base_url:' in line: result['base_url'] = line.split(':', 1)[1].strip() return result def check_profile_path(): """Verify profile path.""" return str(Path("/root/.hermes/profiles/spark").resolve()) def main(): output_lines = [] output_lines.append("=" * 60) output_lines.append("SPARK HERMES ENVIRONMENT VERIFICATION") output_lines.append("=" * 60) output_lines.append("") # Collect facts facts = {} # Python facts['python_version'] = check_python_version() output_lines.append(f"Python Version: {facts['python_version']}") # OS facts['os'] = check_os() output_lines.append(f"OS: {facts['os']}") # Git facts['git'] = check_git() output_lines.append(f"Git: {facts['git']}") # Profile facts['profile_path'] = check_profile_path() output_lines.append(f"Profile Path: {facts['profile_path']}") # Model config facts['model_config'] = check_model_config() if facts['model_config']: output_lines.append(f"Default Model: {facts['model_config'].get('default_model', 'N/A')}") output_lines.append(f"Provider: {facts['model_config'].get('provider', 'N/A')}") output_lines.append("") output_lines.append("=" * 60) output_lines.append("VERIFICATION COMPLETE") output_lines.append("=" * 60) output = '\n'.join(output_lines) # Write to output file out_dir = Path("/root/.hermes/wizard-outputs/spark") out_dir.mkdir(parents=True, exist_ok=True) out_path = out_dir / "env-verification.txt" with open(out_path, 'w') as f: f.write(output) print(output) print(f"\nOutput written to: {out_path}") # Verify file exists if out_path.exists(): return 0 else: return 1 if __name__ == "__main__": sys.exit(main())