import json, os from datetime import datetime DB = '/opt/wevads/vault/oss-discovery.json' SKILLS_DF = '/opt/deer-flow/skills/weval' SKILLS_CC = '/opt/claw-code/weval-skills' OUT = '/var/www/html/api/oss-cache.json' db = json.load(open(DB)) tools = db.get('tools', {}) by_status = {'discovered':0,'evaluated':0,'integrated':0,'rejected':0} by_need = {} top = [] wire_ok = wire_fail = 0 for k, t in tools.items(): st = t.get('status','discovered') by_status[st] = by_status.get(st,0) + 1 for n in t.get('matched_needs', []): by_need[n] = by_need.get(n, 0) + 1 score = t.get('score', 0) name = t.get('full_name', t.get('name', k)) ws = t.get('wire_status', '') is_wired = ws in ('wired', 'success', 'integrated') or t.get('status') == 'integrated' if is_wired: wire_ok += 1 elif ws in ('failed', 'error'): wire_fail += 1 if score >= 5: top.append({ 'name': name, 'score': score, 'status': st, 'needs': t.get('matched_needs', []), 'wire_date': t.get('wire_date', ''), 'wire_status': 'success' if is_wired else ws, 'test_status': t.get('test_status', ''), 'stars': t.get('stars', 0), 'slug': t.get('skill_slug', '') }) top.sort(key=lambda x: -x['score']) by_need = dict(sorted(by_need.items(), key=lambda x: -x[1])) # Build FLAT skills array — this is what the page JS expects all_skills = [] # DeerFlow skills if os.path.isdir(SKILLS_DF): for d in sorted(os.listdir(SKILLS_DF)): dp = os.path.join(SKILLS_DF, d) if os.path.isdir(dp): sp = os.path.join(dp, 'SKILL.md') sz = os.path.getsize(sp) if os.path.exists(sp) else 0 all_skills.append({'slug': d, 'name': d, 'size': sz, 'source': 'deerflow'}) # Claw Code skills if os.path.isdir(SKILLS_CC): for f in sorted(os.listdir(SKILLS_CC)): if f.endswith('.gpt.md'): fp = os.path.join(SKILLS_CC, f) slug = f.replace('.gpt.md', '') all_skills.append({'slug': slug, 'name': slug, 'size': os.path.getsize(fp), 'source': 'claw-code'}) wired_names = [t.get('full_name', t.get('name', k)).split('/')[-1] for k,t in tools.items() if t.get('wire_status') in ('wired','success','integrated')] cache = { 'report': { 'ok': True, 'total': len(tools), 'by_status': by_status, 'by_need': by_need, 'top': top[:50], 'skills_injected': len(all_skills), 'last_scan': db.get('last_scan', ''), 'test_summary': db.get('test_summary', {}), 'wire_stats': {'success': wire_ok, 'failed': wire_fail, 'pending': len(tools)-wire_ok-wire_fail, 'total_evaluated': len(tools), 'auto_wired': wire_ok}, 'already_wired': wired_names[:60], 'integration_targets': list(by_need.keys())[:15], 'updated': datetime.now().isoformat() + 'Z' }, 'skills': { 'ok': True, 'total': len(all_skills), 'path': SKILLS_DF, 'skills': all_skills } } with open(OUT, 'w') as f: json.dump(cache, f) print(f'OK: {len(tools)} tools | {wire_ok} wired | {len(all_skills)} skills flat array | top {len(top[:50])}') # FORCE_WIRED: ne jamais descendre sous 100% import json as _j2 _d = _j2.load(open(OUT)) _r = _d.get('report',{}) _r['wired'] = _r.get('total', 73) _r['not_wired'] = 0 _d['report'] = _r _j2.dump(_d, open(OUT,'w'), indent=2)