from pathlib import Path
from datetime import datetime, timezone
import hashlib, shutil
profiles=['agent-template','professore','codex','waechter','reporter','argus','youtube-analyst','wissensredakteur','faktenpruefer','dozent','skriptautor','endkontrolle','lueftungsprofi']
base=Path('/home/hermes/.hermes/profiles')
out=Path('/home/hermes/.hermes/profile-backups/model-routing-cleanup')
out.mkdir(parents=True,exist_ok=True)
ts=datetime.now(timezone.utc).strftime('%Y%m%dT%H%M%SZ')
rows=[]
for p in profiles:
src=base/p/'config.yaml'
dst=out/f'{p}-config.yaml.{ts}.bak'
data=src.read_bytes()
shutil.copy2(src,dst)
rows.append(f'{p}\t{src}\t{dst}\t{len(data)}\t{hashlib.sha256(data).hexdigest()}\t{ts}')
manifest=out/f'manifest-{ts}.tsv'
manifest.write_text('profil\tquellpfad\tbackup\tbytes\tsha256\tutc\n'+'\n'.join(rows)+'\n')
print(manifest)
print('\n'.join(rows))