183 lines
5.8 KiB
Python
183 lines
5.8 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Hermes Agent System Verification
|
|
Verifies that the hermes-agent skill system is properly configured.
|
|
Produces a machine-readable verification report.
|
|
|
|
Exit codes:
|
|
0 - All verifications passed
|
|
1 - One or more verifications failed
|
|
"""
|
|
|
|
import json
|
|
import sys
|
|
import os
|
|
|
|
def verify_hermes_setup():
|
|
"""Verify Hermes Agent is properly configured."""
|
|
results = []
|
|
all_passed = True
|
|
|
|
# 1. Check HERMES_HOME environment
|
|
hermes_home = os.environ.get('HERMES_HOME', os.path.expanduser('~/.hermes'))
|
|
results.append({
|
|
'check': 'HERMES_HOME environment',
|
|
'value': hermes_home,
|
|
'passed': os.path.isdir(hermes_home)
|
|
})
|
|
if results[-1]['passed']:
|
|
print(f"✓ HERMES_HOME: {hermes_home}")
|
|
else:
|
|
print(f"✗ HERMES_HOME directory not found: {hermes_home}")
|
|
all_passed = False
|
|
|
|
# 2. Check profile directory
|
|
profile_dir = os.path.join(hermes_home, 'profiles', 'spark')
|
|
results.append({
|
|
'check': 'Active profile directory',
|
|
'path': profile_dir,
|
|
'passed': os.path.isdir(profile_dir)
|
|
})
|
|
if results[-1]['passed']:
|
|
print(f"✓ Profile directory: {profile_dir}")
|
|
else:
|
|
print(f"✗ Profile directory not found: {profile_dir}")
|
|
all_passed = False
|
|
|
|
# 3. Check skills directory
|
|
skills_dir = os.path.join(hermes_home, 'skills')
|
|
results.append({
|
|
'check': 'Skills directory',
|
|
'path': skills_dir,
|
|
'passed': os.path.isdir(skills_dir)
|
|
})
|
|
if results[-1]['passed']:
|
|
skill_files = [f for f in os.listdir(skills_dir) if f.endswith('.py') or f.endswith('.md')]
|
|
results[-1]['skill_count'] = len(skill_files)
|
|
print(f"✓ Skills directory: {skills_dir} ({len(skill_files)} skills)")
|
|
else:
|
|
print(f"✗ Skills directory not found: {skills_dir}")
|
|
all_passed = False
|
|
|
|
# 4. Check for hermes_agent.py tool
|
|
tool_path = os.path.join(skills_dir, 'hermes_agent.py') if os.path.isdir(skills_dir) else None
|
|
results.append({
|
|
'check': 'hermes_agent.py tool',
|
|
'path': tool_path,
|
|
'exists': tool_path and os.path.isfile(tool_path),
|
|
'passed': tool_path and os.path.isfile(tool_path)
|
|
})
|
|
if results[-1]['passed']:
|
|
print(f"✓ hermes_agent.py found at {tool_path}")
|
|
else:
|
|
print(f"✗ hermes_agent.py not found")
|
|
all_passed = False
|
|
|
|
# 5. Verify pip can import hermes_tools
|
|
try:
|
|
from hermes_tools import web_search, terminal, read_file, write_file
|
|
results.append({
|
|
'check': 'hermes_tools import',
|
|
'passed': True
|
|
})
|
|
print(f"✓ hermes_tools imports successfully")
|
|
except ImportError as e:
|
|
results.append({
|
|
'check': 'hermes_tools import',
|
|
'passed': False,
|
|
'error': str(e)
|
|
})
|
|
print(f"✗ hermes_tools import failed: {e}")
|
|
all_passed = False
|
|
|
|
# 6. Check scratch directory permissions
|
|
scratch_dir = os.path.join(hermes_home, 'profiles', 'spark', 'cache', 'scratch')
|
|
results.append({
|
|
'check': 'Scratch directory writable',
|
|
'path': scratch_dir,
|
|
'passed': os.path.isdir(scratch_dir)
|
|
})
|
|
if results[-1]['passed']:
|
|
test_file = os.path.join(scratch_dir, '.write_test')
|
|
try:
|
|
with open(test_file, 'w') as f:
|
|
f.write('test')
|
|
os.remove(test_file)
|
|
results[-1]['writable'] = True
|
|
print(f"✓ Scratch directory writable: {scratch_dir}")
|
|
except IOError as e:
|
|
results[-1]['writable'] = False
|
|
results[-1]['error'] = str(e)
|
|
all_passed = False
|
|
print(f"✗ Scratch directory not writable: {e}")
|
|
else:
|
|
print(f"✗ Scratch directory not found: {scratch_dir}")
|
|
all_passed = False
|
|
|
|
# 7. Count Python files in wizard outputs
|
|
wizard_out = '/root/.hermes/wizard-outputs/spark'
|
|
if os.path.isdir(wizard_out):
|
|
py_files = [f for f in os.listdir(wizard_out) if f.endswith('.py')]
|
|
results.append({
|
|
'check': 'Wizard outputs Python files',
|
|
'count': len(py_files),
|
|
'passed': True
|
|
})
|
|
print(f"✓ Wizard outputs: {len(py_files)} Python files in {wizard_out}")
|
|
else:
|
|
results.append({
|
|
'check': 'Wizard outputs directory',
|
|
'passed': False,
|
|
'error': 'Directory not found'
|
|
})
|
|
all_passed = False
|
|
print(f"✗ Wizard outputs not found")
|
|
|
|
return results, all_passed
|
|
|
|
def main():
|
|
print("=" * 50)
|
|
print("Hermes Agent System Verification")
|
|
print("=" * 50)
|
|
print()
|
|
|
|
results, all_passed = verify_hermes_setup()
|
|
|
|
print()
|
|
print("=" * 50)
|
|
if all_passed:
|
|
print("VERIFICATION RESULT: PASS")
|
|
print("=" * 50)
|
|
|
|
# Write JSON report
|
|
report = {
|
|
'status': 'pass',
|
|
'timestamp': __import__('datetime').datetime.utcnow().isoformat() + 'Z',
|
|
'checks': results
|
|
}
|
|
|
|
output_path = '/root/.hermes/wizard-outputs/spark/hermes_verification_report.json'
|
|
with open(output_path, 'w') as f:
|
|
json.dump(report, f, indent=2)
|
|
print(f"Report written to: {output_path}")
|
|
|
|
return 0
|
|
else:
|
|
print("VERIFICATION RESULT: FAIL")
|
|
print("=" * 50)
|
|
|
|
report = {
|
|
'status': 'fail',
|
|
'timestamp': __import__('datetime').datetime.utcnow().isoformat() + 'Z',
|
|
'checks': results
|
|
}
|
|
|
|
output_path = '/root/.hermes/wizard-outputs/spark/hermes_verification_report.json'
|
|
with open(output_path, 'w') as f:
|
|
json.dump(report, f, indent=2)
|
|
print(f"Report written to: {output_path}")
|
|
|
|
return 1
|
|
|
|
if __name__ == '__main__':
|
|
sys.exit(main()) |