Files
weval-l99/agent-persona-coverage-check.sh
2026-04-20 04:10:40 +02:00

24 lines
1008 B
Bash
Executable File

#!/bin/bash
python3 << 'PY'
import json, re, urllib.request, os, subprocess
with urllib.request.urlopen('https://weval-consulting.com/api/agent-avatars-v2.json', timeout=5) as r:
v2 = json.load(r)
missing = []
c = open('/var/www/html/agents-archi.html').read()
for m in re.finditer(r"\{n:'([^']+)',t:(\d+)", c):
name = m.group(1)
if name not in v2 and not any(k.lower()==name.lower() for k in v2.keys()):
missing.append(name)
report = {
'ts': __import__('datetime').datetime.now().isoformat(),
'v2_entries': len(v2),
'missing_count': len(missing),
'missing_agents': missing,
'status': 'OK' if len(missing)==0 else 'WARN',
}
json.dump(report, open('/var/www/html/api/agent-persona-coverage.json','w'), indent=2, ensure_ascii=False)
os.chmod('/var/www/html/api/agent-persona-coverage.json', 0o644)
subprocess.run(['chown','www-data:www-data','/var/www/html/api/agent-persona-coverage.json'])
print(f"coverage: {report['status']} missing={len(missing)} v2={len(v2)}")
PY