Explorer
/tmp/compare-skills.sh
← Zurück ↓ Download
#!/usr/bin/env bash
set -u
python3 - <<'PY'
import csv, hashlib, os, re
ws='/opt/struktur/hermes-werkstandard/data/skills'
ca='/opt/struktur/hermes-carlo/data/skills'
def sha(p):
    h=hashlib.sha256()
    with open(p,'rb') as f:
        for b in iter(lambda:f.read(1024*1024),b''): h.update(b)
    return h.hexdigest()
def skills(root):
    out={}
    for d,dirs,files in os.walk(root):
        if 'SKILL.md' in files:
            rel=os.path.relpath(d,root).replace(os.sep,'/')
            out[rel]={'path':d,'hash':sha(os.path.join(d,'SKILL.md')),'files':sum(len(fs) for _,_,fs in os.walk(d))}
    return out
w=skills(ws); c=skills(ca)
names=set(w)|set(c)
with open('/tmp/SKILL-VERGLEICH.csv','w',newline='',encoding='utf-8') as f:
    wr=csv.writer(f); wr.writerow(['Skill','Werkstandard-Pfad','Carlo-Pfad','Status','fachlicher Nutzen','technische Kompatibilität','Sicherheitsbewertung','Empfehlung','Begründung'])
    for n in sorted(names):
        a,b=w.get(n),c.get(n)
        if a and b and a['hash']==b['hash']: st='identisch'; rec='redundant'; reason='Gleicher SKILL.md-Inhalt und gleicher relativer Skillpfad.'
        elif a and b: st='abweichend'; rec='ungeklärt'; reason='Gleicher relativer Skillpfad, aber abweichender SKILL.md-Inhalt; Einzelvergleich erforderlich.'
        elif a: st='nur Werkstandard'; rec='archivieren'; reason='Im Werkstandard vorhanden, im Carlo-Pfad kein gleicher relativer Skill gefunden.'
        else: st='nur Carlo'; rec='nicht betroffen'; reason='Nur im Carlo-Pfad vorhanden.'
        wr.writerow([n,a['path'] if a else '',b['path'] if b else '',st,'fachlich potenziell nutzbar','nicht ausgeführt; statische Prüfung','Inhalt nicht pauschal sicherheitsfrei; vor Übernahme prüfen',rec,reason])
print('werkstandard_skill_dirs',len(w)); print('carlo_skill_dirs',len(c)); print('identical',sum(1 for n in names if n in w and n in c and w[n]['hash']==c[n]['hash'])); print('different_shared',sum(1 for n in names if n in w and n in c and w[n]['hash']!=c[n]['hash'])); print('only_werkstandard',sum(1 for n in names if n in w and n not in c)); print('only_carlo',sum(1 for n in names if n not in w and n in c))
PY