Skip to content

ythx-101/live-panel-skill

live-panel

Verified

Build a terminal-style, always-running animated architecture diagram (a "live panel") from a JSON config and render it to an mp4. Use when the user wants a system, agent or org architecture diagram that looks like a monitoring dashboard in a terminal window - fixed layout, glowing packets on the wires, scrolling log, counters, bars that flip state - as a screen-recording-style video or a live web page, instead of a static picture or a step-by-step reveal. 中文:当用户要做"活的"架构图、agent 树或系统监控面板风格的动画(mp4 视频或循环网页)时使用——终端里一直在跑的监控面板外观,固定布局、线上流动的数据包、滚动日志、翻转的计数器和状态条;不是静态图,也不是分步演示。

FileKindSize
SKILL.mdskill md11.2 KB
assets/fonts/Excalifont-OFL.txtmarkdown5.1 KB
assets/fonts/Excalifont-Regular-Latin.woff2binary24.4 KB
assets/fonts/SmileySans-OFL.txtmarkdown4.3 KB
assets/fonts/SmileySans-Oblique.woff2binary1.1 MB
assets/fonts/Xiaolai-OFL.txtmarkdown4.3 KB
assets/template.htmlother35.9 KB
assets/views/LUCIDE-LICENSE.txtmarkdown3.1 KB
assets/views/ROUGH-LICENSE.txtmarkdown1.0 KB
assets/views/excalidraw.jsscript50.0 KB
assets/views/funnel.jsscript15.5 KB
assets/views/loop.jsscript74.3 KB
assets/views/ring.jsscript15.2 KB
assets/views/sketchboard.jsscript18.7 KB
examples/agent-architecture/agent-architecture.mp4binary1.4 MB
examples/agent-architecture/config.jsonconfig37.1 KB
examples/agent-architecture/preview.webpbinary1.2 MB
examples/airbnb/airbnb.mp4binary1.9 MB
examples/airbnb/config.jsonconfig20.3 KB
examples/airbnb/preview.webpbinary1.4 MB
examples/codex-agents/codex-agents.mp4binary1.8 MB
examples/codex-agents/config.jsonconfig19.1 KB
examples/codex-agents/preview.webpbinary1.6 MB
examples/excalidraw-aqua/README.mdmarkdown760 B
examples/excalidraw-aqua/build_config.pyscript6.6 KB
examples/excalidraw-aqua/config-3x4.jsonconfig8.3 KB
examples/excalidraw-aqua/config-4x5.jsonconfig8.3 KB
examples/excalidraw-aqua/preview.webpbinary2.3 MB
examples/excalidraw-gardener/README.mdmarkdown671 B
examples/excalidraw-gardener/build_config.pyscript6.4 KB
examples/excalidraw-gardener/config-3x4.jsonconfig7.6 KB
examples/excalidraw-gardener/config-4x5.jsonconfig7.6 KB
examples/excalidraw-gardener/preview.webpbinary1.2 MB
examples/excalidraw-import/agent-loop.excalidrawother6.7 KB
examples/excalidraw-import/agent-loop.mp4binary1.6 MB
examples/excalidraw-import/config.jsonconfig3.9 KB
examples/funnel-karpathy/config.jsonconfig1.2 KB
examples/funnel/config.jsonconfig1.2 KB
examples/funnel/funnel.mp4binary1.1 MB
examples/funnel/preview.webpbinary475.3 KB
examples/hybrid-agent/README.mdmarkdown729 B
examples/hybrid-agent/config.jsonconfig6.2 KB
examples/loop-poteto/config.jsonconfig6.6 KB
examples/loop-poteto/loop-poteto.mp4binary2.1 MB
examples/loop-poteto/preview-dark.webpbinary638.3 KB
examples/loop-poteto/preview-light.webpbinary627.2 KB
examples/minimal/config.jsonconfig1.9 KB
examples/minimal/preview.webpbinary146.3 KB
examples/ring/config.jsonconfig940 B
examples/ring/preview.webpbinary150.9 KB
examples/ring/ring.mp4binary593.1 KB
references/config-schema.mdmarkdown4.9 KB
references/motion-grammar.mdmarkdown6.4 KB
references/verify-view.mdmarkdown3.3 KB
references/view-rules.mdmarkdown4.3 KB
references/views.mdmarkdown24.7 KB
scripts/check_frames.pyexecutablescript4.6 KB
scripts/excalidraw_import.pyscript14.7 KB
scripts/fetch_fonts.shexecutablescript528 B
scripts/livepanel.pyexecutablescript10.2 KB
scripts/render.pyexecutablescript3.8 KB
scripts/scaffold.pyexecutablescript25.0 KB
scripts/verify_view.pyscript28.5 KB

assets/template.html

View on GitHub
<!doctype html>
<html lang="en"><head><meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>live-panel</title>
<style>
/* live-panel template. Content, colours, sizes: all come from the JSON config (see references/config-schema.md).
   Layout never moves. Everything that changes is a pure function of time: window.seek(t). */
*{box-sizing:border-box;margin:0;padding:0}
html,body{width:100%;height:100%;overflow:hidden}
body{background:var(--c-bg,#111);}
#stage{position:absolute;left:0;top:0;transform-origin:0 0;overflow:hidden;white-space:pre;color:var(--c-fg);font-family:var(--font);font-size:var(--fs);line-height:var(--lh)}
#stage>*{position:absolute}
b,.b{font-weight:700}
.tb{left:0;top:0;text-align:center;background:var(--c-bar);color:var(--c-dim)}
.tb i{position:absolute;border-radius:50%}
.sw{display:inline-block;width:.62em;height:.62em;margin-right:.55em;vertical-align:baseline}
.box{border-top:2px solid;border-bottom:2px solid}
.box::before,.box::after{content:"";position:absolute;top:0;bottom:0;width:2px;background:repeating-linear-gradient(180deg,currentColor 0 calc(var(--lh) - 7px),transparent calc(var(--lh) - 7px) var(--lh))}
.box.solid{border:var(--bw,2px) solid currentColor;border-radius:var(--radius,0px)}
.box.solid::before,.box.solid::after{display:none}
.box.dashed{border-style:dashed}
.box::before{left:0}.box::after{right:0}
.box .ln{color:var(--c-fg);height:var(--lh);padding-right:0}
.ln.flex{display:flex;align-items:center}
.ln.flex>div{overflow:visible}
.wire{background:var(--c-line)}
.dashv{background:repeating-linear-gradient(180deg,var(--c-line) 0 5px,transparent 5px 9px)}
.dashh{background:repeating-linear-gradient(90deg,var(--c-line) 0 5px,transparent 5px 9px)}
.pk{border-radius:50%;width:12px;height:12px;margin:-6px 0 0 -6px;display:none}
.pk.s{width:6px;height:6px;margin:-3px 0 0 -3px}
.bar{position:relative;display:block;height:20px;background-image:radial-gradient(var(--c-dots,#566078) 1px,transparent 1.3px);background-size:4px 4px}
.bar u{position:absolute;left:0;top:0;bottom:0;text-decoration:none}
.bar u.end::after{content:"";position:absolute;right:0;top:0;bottom:0;width:8px;background:repeating-conic-gradient(var(--c-bg) 0 25%,transparent 0 50%) 0 0/4px 4px;opacity:.55}
.bar s{position:absolute;top:-4px;bottom:-4px;width:2px;background:var(--c-fg);text-decoration:none}
.cur{display:inline-block;width:.62em;height:1.05em;vertical-align:-.18em;margin-left:.4em}
.tarrow{height:0;border-top:2px dashed var(--c-line)}
.glyph{text-align:center;line-height:1}
.logframe{border:2px solid var(--c-line2,#3a4154);border-top:0}
.logtop{height:0;border-top:2px solid var(--c-line2,#3a4154)}
.lgrow{position:absolute}
.lgrow span{position:absolute;top:0}
#err{position:absolute;left:10px;top:10px;color:#f66;font:14px monospace;white-space:pre-wrap;z-index:9}
</style><!--LIVE_FONTS--></head><body>
<div id="stage"></div>
<!--LIVE_CONFIG-->
<script>window.LP=window.LP||{_q:[],registerView:function(k,i){this._q.push([k,i])}};</script>
<!--LIVE_VIEWS-->
<script>
(function(){
'use strict';
var mod=function(a,n){return ((a%n)+n)%n};
var esc=function(s){return String(s).replace(/&/g,'&amp;').replace(/</g,'&lt;')};
// deterministic "random": a pure hash of (seed, index). Never Math.random, never the wall clock.
function hash(seed,k){var h=Math.imul((seed|0)+0x9e3779b9,0x85ebca6b)^Math.imul(k|0,0xc2b2ae35);h=Math.imul(h^(h>>>16),0x7feb352d);h=Math.imul(h^(h>>>15),0x846ca68b);return ((h^(h>>>16))>>>0)/4294967296}

var cfg=null, ST=document.getElementById('stage'), V={}, DYN=[], PK=[], EVT=[], MACH=[], CHK=[];
var CW=1200, CH=1500, LH=30, PRE=0, FS=21;
window.__ready=false; window.__pending=null;

function fail(e){var d=document.getElementById('err')||document.body.appendChild(Object.assign(document.createElement('div'),{id:'err'}));d.textContent+=String(e&&e.stack||e)+'\n';window.__error=(window.__error||'')+String(e)+'\n'}

function loadConfig(){
  var el=document.getElementById('live-config');
  if(el&&el.textContent.trim()) return Promise.resolve(JSON.parse(el.textContent));
  var m=/[?&]config=([^&]+)/.exec(location.search);
  if(m) return fetch(decodeURIComponent(m[1])).then(function(r){return r.json()});
  return Promise.reject(new Error('no config: embed <script id="live-config" type="application/json"> or use ?config=path.json (over http)'));
}

// ---------- value access / templating ----------
function tv(k){var v=V[k]; if(v==null) return ''; return typeof v==='object'?v.text:String(v)}
function fill(s,sc){return String(s).replace(/\{([\w.\-]+)\}/g,function(m,k){var v=sc?sc(k):null; if(v==null) v=V[k]; if(v==null) return m; return typeof v==='object'?v.text:String(v)})}
function cond(w){if(!w) return true; if(Array.isArray(w)) return w.every(cond); var v=tv(w['var']); if('eq' in w) return v===String(w.eq); if('ne' in w) return v!==String(w.ne); if('in' in w) return w['in'].map(String).indexOf(v)>=0; return !!v}
function cc(n){return n?'var(--c-'+n+')':''}
function fmtNum(n,f){n=Math.floor(n); return f==='comma'?String(n).replace(/\B(?=(\d{3})+(?!\d))/g,','):String(n)}

// ---------- runs / lines ----------
function runHtml(r){
  if(typeof r==='string') r={t:r};
  var c=r.c,b=r.b,sty='';
  if(r.when&&r.then&&cond(r.when)){ if(r.then.c) c=r.then.c; if(r.then.b!=null) b=r.then.b; }
  if(r.cursor){ var on=mod(V.__t,r.period||1.1)<(r.on||0.6); return '<span class="cur" style="background:'+cc(c||'gr')+';opacity:'+(on?1:0)+'"></span>'; }
  if(r.sw) return '<i class="sw" style="background:'+cc(r.sw)+'"></i>';
  var txt;
  if(r.v){ var v=V[r.v]; if(v==null) v=''; if(typeof v==='object'){ txt=v.text; if(!c&&v.c) c=v.c; if(b==null&&v.b!=null) b=v.b; } else txt=String(v); }
  else txt=fill(r.t==null?'':r.t);
  if(c) sty+='color:'+cc(c)+';';
  if(b) sty+='font-weight:700;';
  if(r.size) sty+='font-size:'+r.size+'px;';
  return sty?'<span style="'+sty+'">'+esc(txt)+'</span>':esc(txt);
}
function runsHtml(rs){return (rs||[]).map(runHtml).join('')}
function barHtml(b){
  var segs, mark=b.mark, w=b.w||127, h=b.h||20;
  if(b.gauge){ var n=V[b.gauge+'.num'], low=V[b.gauge+'.low']==='1', c=low?(b.low||'cy'):(b.high||'gr');
    segs=[{from:0,to:n,c:c,end:true}]; }
  else if(b.segments) segs=b.segments; else segs=[{from:0,to:b.fixed,c:b.c||'cy'}];
  var out='<span class="bar" style="width:'+w+'px;height:'+h+'px">';
  segs.forEach(function(s){ out+='<u class="'+(s.end?'end':'')+'" style="left:'+(s.from*100)+'%;width:'+((s.to-s.from)*100)+'%;background:'+cc(s.c)+'"></u>'; });
  if(mark!=null) out+='<s style="left:'+(mark*100)+'%"></s>';
  return out+'</span>';
}
function normLine(l,mach){
  if(typeof l==='string') l={runs:[l]};
  if(l.trigger){ // sugar: a trigger-point row bound to a triggers machine
    var m=cfg.machines[l.trigger[0]], i=l.trigger[1], hl=m.hl||'hl', col=m.color||'pu';
    l=Object.assign({align:'left',indent:l.indent==null?13:l.indent,runs:[{v:l.trigger[0]+'.label'+i,c:'dim',when:{'var':l.trigger[0]+'.active',eq:i},then:{c:col,b:1}}],
      when:{'var':l.trigger[0]+'.active',eq:i},then:{bg:hl,c:col,b:1}},l);
  }
  if(l.t!=null&&!l.runs&&!l.items) l.runs=[{t:l.t}];
  return l;
}
function addLine(parent,l,boxAlign){
  l=normLine(l);
  var d=document.createElement('div'); d.className='ln'+(l.items?' flex':'');
  var al=l.align||boxAlign||'center';
  d.style.textAlign=al;
  if(l.indent) d.style.paddingLeft=l.indent+'px';
  if(l.h) d.style.height=(l.h*LH)+'px';
  if(l.size) d.style.fontSize=l.size+'px';
  if(l.c) d.style.color=cc(l.c);
  if(l.b) d.style.fontWeight=700;
  if(l.inset) { d.style.marginLeft=l.inset+'px'; }
  parent.appendChild(d);
  var empty=!l.items&&(!l.runs||(l.runs.length===1&&l.runs[0]===''));
  if(l.items){
    d.style.gap=(l.gap||0)+'px';
    l.items.forEach(function(it){
      var e=document.createElement('div'); e.setAttribute('data-t','text');
      if(it.w) e.style.flex='0 0 '+it.w+'px'; else if(it.grow) e.style.flex='1 1 0'; else e.style.flex='0 0 auto';
      if(it.ml) e.style.marginLeft=it.ml;
      e.style.textAlign=it.align||'left'; if(it.size) e.style.fontSize=it.size+'px';
      d.appendChild(e);
      DYN.push({el:e,fn:function(){return it.bar?barHtml(it.bar):runsHtml(it.runs)},last:null,chk:it.bar?'bar':'text'});
    });
    DYN.push({el:d,fn:function(){return null},cls:function(){return lineStyle(l)},last:null});
  } else {
    if(!empty) d.setAttribute('data-t','text');
    DYN.push({el:d,fn:function(){return runsHtml(l.runs)},cls:function(){return lineStyle(l)},last:null});
  }
  return d;
}
function lineStyle(l){ // line-level when/then: background / colour / weight
  if(l.when&&l.then&&cond(l.when)) return {bg:l.then.bg?cc(l.then.bg):'',c:l.then.c?cc(l.then.c):'',b:l.then.b?'700':''};
  return {bg:'',c:l.c?cc(l.c):'',b:l.b?'700':''};
}
function applyDyn(){
  DYN.forEach(function(d){
    var h=d.fn(); if(h!==null&&h!==d.last){ d.el.innerHTML=h; d.last=h; }
    if(d.cls){ var s=d.cls(), k=s.bg+'|'+s.c+'|'+s.b; if(k!==d.lk){ d.el.style.background=s.bg; d.el.style.color=s.c||''; d.el.style.fontWeight=s.b; d.lk=k; } }
  });
}

// ---------- packets ----------
function mkpk(color,small){var e=document.createElement('div'); e.className='pk'+(small?' s':''); var col=cc(color)||color; e.style.background=col;
  var sz=(TH.packetSize||12)*(small?0.5:1); e.style.width=e.style.height=sz+'px'; e.style.margin=(-sz/2)+'px 0 0 '+(-sz/2)+'px';
  if(TH.glow) e.style.boxShadow='0 0 '+(small?3:8)+'px '+col; ST.appendChild(e); return e}
function prepPath(P){P.len=0;P.seg=[];for(var i=1;i<P.path.length;i++){var d=Math.abs(P.path[i][0]-P.path[i-1][0])+Math.abs(P.path[i][1]-P.path[i-1][1]);P.seg.push(d);P.len+=d}}
function atPath(P,d){if(d<0||d>P.len)return null;for(var i=0;i<P.seg.length;i++){if(d<=P.seg[i]){var a=P.path[i],b=P.path[i+1],f=P.seg[i]?d/P.seg[i]:0;return [a[0]+(b[0]-a[0])*f,a[1]+(b[1]-a[1])*f]}d-=P.seg[i]}return P.path[P.path.length-1]}
function putPk(e,P,d){var q=atPath(P,d); if(!q||(P.gap&&q[1]>P.gap[0]&&q[1]<P.gap[1])){e.style.display='none';return} e.style.display='block';e.style.left=q[0]+'px';e.style.top=q[1]+'px'}

// ---------- machines (each is a pure function of t) ----------
function pickIdx(m,k){var n=m.values.length,b=Math.floor(hash(m.seed||1,k)*n); if(n>1&&b===Math.floor(hash(m.seed||1,k-1)*n)) b=(b+1)%n; return b}
var MK={
 counter:function(id,m){return {vars:function(t){V[id]=(m.prefix||'')+fmtNum((m.start||0)+(m.rate||0)*t,m.format)+(m.suffix||'')},events:function(){return []}}},
 cycle:function(id,m){
  var n=m.values.length, fields=[];
  function idx(j){return m.order?m.order[mod(j,m.order.length)]:mod(j,n)}
  function val(j){var v=m.values[idx(j)]; return typeof v==='object'?v:{t:v}}
  return {vars:function(t){var j=Math.floor((t-(m.t0||0))/m.period), v=val(j);
     // Drop fields from the previous value so optional fields cannot survive a seek.
     fields.forEach(function(k){delete V[id+'.'+k]}); fields=Object.keys(v);
     V[id]=v.t!=null?v.t:(v.m||''); V[id+'.i']=String(idx(j));
     fields.forEach(function(k){V[id+'.'+k]=String(v[k])})},
   events:function(lo,hi){var o=[]; if(!m.log) return o; for(var j=Math.floor((lo-(m.t0||0))/m.period);j<=Math.ceil((hi-(m.t0||0))/m.period);j++){var v=val(j); o.push({t:(m.t0||0)+j*m.period,who:m.log.who,c:m.log.c,m:v.m!=null?v.m:(v.t||''),g:v.g||''})} return o}}},
 gauge:function(id,m){
  var th=m.threshold, dec=m.decimals==null?2:m.decimals;
  function st(k){var v=m.values[pickIdx(m,k)], low=v<th, L=low?(m.low||{}):(m.high||{}); return {v:v,low:low,label:L.label||'',dest:L.dest||''}}
  return {vars:function(t){var k=Math.floor((t-(m.t0||0))/m.period), s=st(k);
     V[id]=s.v.toFixed(dec); V[id+'.num']=s.v; V[id+'.low']=s.low?'1':''; V[id+'.label']={text:s.label,c:s.low?(m.lowColor||'cy'):(m.highColor||'gr'),b:s.low?1:0}; V[id+'.dest']=s.dest},
   events:function(lo,hi){var o=[]; if(!m.log) return o; for(var k=Math.floor((lo-(m.t0||0))/m.period);k<=Math.ceil((hi-(m.t0||0))/m.period);k++){var s=st(k),sc={value:s.v.toFixed(dec),label:s.label,dest:s.dest};
     var f=function(x){return String(x).replace(/\{(\w+)\}/g,function(a,b){return sc[b]!=null?sc[b]:a})};
     o.push({t:(m.t0||0)+k*m.period,who:m.log.who,c:m.log.c,m:m.log.msgs[mod(k,m.log.msgs.length)],g:f(m.log.tail||'')})} return o}}},
 any_low:function(id,m){return {vars:function(){V[id]=m.of.some(function(g){return V[g+'.low']==='1'})?'low':'high'},events:function(){return []}}},
 lane:function(id,m){
  var sp=m.spin||['◐','◓','◑','◒'];
  return {vars:function(t){var c=Math.floor((t-m.off)/m.period), p=(t-m.off)-c*m.period, run=p<m.run;
     if(run) V[id]={text:sp[mod(Math.floor(t/(m.spinStep||0.3))+(m.phase||0),sp.length)]+' '+m.busy,c:m.busyColor||'bl'};
     else V[id]={text:'✓ '+m.done[mod(c,m.done.length)],c:m.doneColor||'gr'};
     V[id+'.state']=run?'busy':'done'},
   events:function(lo,hi){var o=[]; if(!m.log) return o; for(var c=Math.floor((lo-m.off)/m.period);c<=Math.ceil((hi-m.off)/m.period);c++){var e=m.log.msgs[mod(c,m.log.msgs.length)]; o.push({t:m.off+c*m.period+m.run,who:m.log.who,c:m.log.c,m:e[0],g:e[1]||''})} return o}}},
 triggers:function(id,m){
  var it=m.items, n=it.length, cps=m.cps||9;
  return {vars:function(t){var k=Math.floor((t-m.t0)/m.period), ph=(t-m.t0)-k*m.period, on=ph<m.on, cur=mod(k,n), I=it[cur];
     V[id+'.active']=on?String(cur):'-1'; V[id+'.cur']=String(cur); V[id+'.phase']=ph;
     Object.keys(I).forEach(function(f){ if(typeof I[f]!=='object') V[id+'.'+f]=String(I[f]) });
     for(var i=0;i<n;i++) V[id+'.label'+i]=(on&&i===cur?'◆ ':'◇ ')+it[i].name;
     V[id+'.calls']=String(k+(m.callsStart==null?1:m.callsStart));
     var tk=m.tokens||{start:0,step:0}; V[id+'.tokens']=fmtNum(tk.start+k*tk.step)+(tk.unit||'');
     var q=on?Math.max(0,Math.floor((ph-0.35)*cps)):99999, a0=I.adv[0],a1=I.adv[1]||'';
     V[id+'.adv0']=a0.slice(0,q); V[id+'.adv1']=q>a0.length+2?a1.slice(0,q-a0.length-2):'';
     V[id+'.status']={text:on?(m.onText||'advising'):(m.offText||'on call'),c:m.color||'pu',b:1};
   },
   events:function(lo,hi){var o=[]; if(!m.log) return o; for(var k=Math.floor((lo-m.t0)/m.period);k<=Math.ceil((hi-m.t0)/m.period);k++){var I=it[mod(k,n)];
     var f=function(x){return String(x).replace(/\{(\w+)\}/g,function(a,b){return I[b]!=null?I[b]:a})};
     o.push({t:m.t0+k*m.period,who:m.log.who,c:m.log.c,m:f(m.log.start.m),g:f(m.log.start.g||'')});
     o.push({t:m.t0+k*m.period+m.on,who:m.log.who,c:m.log.c,m:f(m.log.end.m),g:f(m.log.end.g||'')})} return o}}}
};

// ---------- element builders ----------
function place(d,e){ if(e.x!=null) d.style.left=e.x+'px'; if(e.y!=null) d.style.top=e.y+'px'; if(e.w!=null) d.style.width=e.w+'px'; if(e.h!=null) d.style.height=e.h+'px'; }
var B={
 text:function(e){
  var size=e.size||FS, lh=e.lh||(e.size?Math.round(e.size*1.4):LH), d=document.createElement('div');
  d.style.left=e.x+'px'; d.style.top=(e.y-lh/2)+'px'; if(e.w!=null) d.style.width=e.w+'px'; d.style.height=lh+'px'; d.style.lineHeight=lh+'px';
  d.style.textAlign=e.align||'left'; if(e.size) d.style.fontSize=size+'px'; if(e.c) d.style.color=cc(e.c); if(e.b) d.style.fontWeight=700; if(e.ls) d.style.letterSpacing=e.ls+'px'; if(e.font) d.style.fontFamily=(e.font==='title'?'var(--font-title)':e.font);
  d.setAttribute('data-t','text'); if(e.noCheck) d.setAttribute('data-nocheck','1'); if(e.inside) d.setAttribute('data-in','1');
  var runs=e.runs||[{t:e.t!=null?e.t:e.text}];
  DYN.push({el:d,fn:function(){return runsHtml(runs)},last:null}); ST.appendChild(d);
 },
 box:function(e){
  var d=document.createElement('div'), solid=(e.sides||TH.boxMode)==='solid';
  d.className='box'+(solid?' solid':'')+(e.dash?' dashed':''); place(d,e); d.style.color=cc(e.color||'fg');
  if(e.radius!=null) d.style.borderRadius=e.radius+'px'; if(e.border!=null) d.style.setProperty('--bw',e.border+'px');
  if(e.fill) d.style.background=cc(e.fill);
  var p=e.pad||[10,14,14]; d.style.padding=p[0]+'px '+(p[2]==null?p[1]:p[2])+'px 0 '+p[1]+'px';
  d.setAttribute('data-t',e.container?'frame':'box'); ST.appendChild(d);
  (e.lines||[]).forEach(function(l){addLine(d,l,e.align)});
  if(e.when&&e.then) BOXES.push({el:d,e:e,last:null});
 },
 path:function(e){ // polyline (optionally with rounded corners) with an arrow head; may carry packets and change colour on a condition
  var NS='http://www.w3.org/2000/svg', pts=e.points, r=e.r||0, svg=document.createElementNS(NS,'svg');
  svg.setAttribute('width',CW); svg.setAttribute('height',CH); svg.style.cssText='left:0;top:0;overflow:visible;pointer-events:none';
  var dd='M'+pts[0][0]+' '+pts[0][1];
  for(var i=1;i<pts.length;i++){ var a=pts[i-1],b=pts[i],c=pts[i+1];
    if(r&&c){ var l1=Math.hypot(b[0]-a[0],b[1]-a[1]), l2=Math.hypot(c[0]-b[0],c[1]-b[1]), rr=Math.min(r,l1/2,l2/2);
      dd+=' L'+(b[0]-(b[0]-a[0])/l1*rr)+' '+(b[1]-(b[1]-a[1])/l1*rr)+' Q'+b[0]+' '+b[1]+' '+(b[0]+(c[0]-b[0])/l2*rr)+' '+(b[1]+(c[1]-b[1])/l2*rr); }
    else dd+=' L'+b[0]+' '+b[1]; }
  var pa=document.createElementNS(NS,'path'); pa.setAttribute('d',dd); pa.setAttribute('fill','none'); pa.setAttribute('stroke-linecap','round'); pa.setAttribute('stroke-linejoin','round');
  if(e.dash) pa.setAttribute('stroke-dasharray',e.dash===true?'6 5':e.dash); svg.appendChild(pa);
  var hd=null; if(e.arrow!==false){ hd=document.createElementNS(NS,'polygon'); svg.appendChild(hd); }
  var P={e:e,pa:pa,hd:hd,last:null}; PATHS.push(P);
  function head(from,to,sz){ var dx=to[0]-from[0],dy=to[1]-from[1],L=Math.hypot(dx,dy)||1; dx/=L; dy/=L; var bx=to[0]-dx*sz,by=to[1]-dy*sz;
    return to[0]+','+to[1]+' '+(bx-dy*sz*0.5)+','+(by+dx*sz*0.5)+' '+(bx+dy*sz*0.5)+','+(by-dx*sz*0.5); }
  P.headPts=hd?head(pts[pts.length-2],pts[pts.length-1],e.head||9):null;
  ST.appendChild(svg);
  if(e.flow) B.flow(Object.assign({color:e.color,path:pts},e.flow));
 },
 line:function(e){ // axis-aligned wire from [x1,y1] to [x2,y2]
  var a=e.from,b=e.to,w=e.width||TH.wireWidth||2,d=document.createElement('div');
  d.className=e.dash?(a[0]===b[0]?'dashv':'dashh'):'wire';
  if(a[0]===b[0]){d.style.left=(a[0]-w/2)+'px';d.style.top=Math.min(a[1],b[1])+'px';d.style.width=w+'px';d.style.height=Math.abs(b[1]-a[1])+'px'}
  else{d.style.top=(a[1]-w/2)+'px';d.style.left=Math.min(a[0],b[0])+'px';d.style.height=w+'px';d.style.width=Math.abs(b[0]-a[0])+'px'}
  if(e.color) { d.style.background=cc(e.color); }
  ST.appendChild(d);
 },
 glyph:function(e){
  var s=e.size||17,d=document.createElement('div'); d.className='glyph'; d.style.fontSize=s+'px'; d.style.width='24px'; d.style.height=s+'px';
  d.style.left=(e.x-12)+'px'; d.style.top=(e.y-s/2)+'px'; d.style.color=cc(e.c||'dim'); d.textContent=e.ch||'▼'; ST.appendChild(d);
 },
 rule:function(e){var d=document.createElement('div'); d.style.left=e.x+'px'; d.style.top=e.y+'px'; d.style.width=e.w+'px'; d.style.height='5px'; d.style.borderTop='1px solid '+cc(e.c||'line'); d.style.borderBottom=d.style.borderTop; ST.appendChild(d)},
 flow:function(e){
  var P=Object.assign({},e); prepPath(P); P.when=e.when; P.o=e.offsets||[0]; P.tail=e.tail==null?15:e.tail;
  P.el=P.o.map(function(){return [mkpk(e.color,false),mkpk(e.color,true)]}); PK.push(P);
 },
 tarrow:function(e){ // dashed arrow from a trigger row to its target; colours up and carries a packet while that trigger is active
  var m=e.machine, i=e.i, x1=e.from[0], y=e.from[1], x2=e.to[0], head=e.head||'▶', hs=17;
  var ln=document.createElement('div'); ln.className='tarrow'; ln.style.left=x1+'px'; ln.style.top=(y-1)+'px'; ln.style.width=Math.max(0,x2-x1-8)+'px'; ST.appendChild(ln);
  var hd=document.createElement('div'); hd.className='glyph'; hd.style.fontSize=hs+'px'; hd.style.width='20px'; hd.style.height=hs+'px'; hd.style.left=(x2-18)+'px'; hd.style.top=(y-hs/2)+'px'; hd.textContent=head; ST.appendChild(hd);
  var P={path:[[x1,y],[x2-8,y]]}; prepPath(P); P.el=[mkpk(e.packet||cfg.machines[m].color||'pu',false),mkpk(e.packet||cfg.machines[m].color||'pu',true)];
  var col=cc(cfg.machines[m].color||'pu');
  DYN.push({el:ln,fn:function(){return null},cls:function(){return {bg:'',c:'',b:''}},last:null});
  TA.push({ln:ln,hd:hd,P:P,m:m,i:i,col:col});
 },
 log:function(e){
  var rows=e.rows||4, h=rows*LH+(e.padBottom==null?16:e.padBottom), x=e.x, y=e.y, w=e.w;
  var fr=document.createElement('div'); fr.className='logframe'; fr.style.left=x+'px'; fr.style.top=y+'px'; fr.style.width=w+'px'; fr.style.height=h+'px'; fr.setAttribute('data-t','frame'); ST.appendChild(fr);
  var tx=e.titleX||60, tw=e.titleW||180;
  [[x,tx],[x+tx+tw,w-tx-tw]].forEach(function(s){var t=document.createElement('div'); t.className='logtop'; t.style.left=s[0]+'px'; t.style.top=y+'px'; t.style.width=s[1]+'px'; ST.appendChild(t)});
  [x+tx,x+tx+tw].forEach(function(px){var t=document.createElement('div'); t.className='wire'; t.style.background='var(--c-line2,#3a4154)'; t.style.left=px+'px'; t.style.top=(y-10)+'px'; t.style.width='2px'; t.style.height='20px'; ST.appendChild(t)});
  var lab=document.createElement('div'); lab.style.left=(x+tx+18)+'px'; lab.style.top=(y-LH/2)+'px'; lab.style.height=LH+'px'; lab.style.color=cc('dim'); lab.textContent=e.title||'log'; lab.setAttribute('data-t','text'); ST.appendChild(lab);
  LOG={rows:[],cols:e.cols,clock:cfg.clock||{start:'00:00:00',rate:1}};
  for(var i=0;i<rows;i++){ var r=document.createElement('div'); r.className='lgrow'; r.style.left=(x+(e.padLeft==null?20:e.padLeft))+'px'; r.style.top=(y+(e.padTop==null?8:e.padTop)+i*LH)+'px'; r.style.height=LH+'px'; r.style.width=(w-30)+'px'; ST.appendChild(r);
   var cells=e.cols.map(function(c){var s=document.createElement('span'); s.style.left=c.x+'px'; s.style.height=LH+'px'; s.setAttribute('data-t','text'); r.appendChild(s); return s});
   LOG.rows.push({el:r,cells:cells,last:null}); }
 }
};
var TA=[], LOG=null, BOXES=[], PATHS=[], TH={};
// ---------- views (auto-laid-out diagrams; see references/views.md) ----------
var VIEW_IMPL={}, VIEWS=[], MCTX=null;
var LPQ=(window.LP&&window.LP._q)||[];
window.LP={registerView:function(kind,impl){ if(VIEW_IMPL[kind]) fail(new Error('view kind "'+kind+'" registered twice')); VIEW_IMPL[kind]=impl},
  ease:{inOut:function(x){x=Math.max(0,Math.min(1,x));return x<.5?2*x*x:1-Math.pow(-2*x+2,2)/2},out:function(x){x=Math.max(0,Math.min(1,x));return 1-Math.pow(1-x,3)},smooth:function(x){x=Math.max(0,Math.min(1,x));return x*x*(3-2*x)}}};
LPQ.forEach(function(q){window.LP.registerView(q[0],q[1])});
function vFont(f){ f=f||TH.font; return String(f).replace('var(--font-title)',TH.titleFont||TH.font).replace('var(--font)',TH.font); }
function vMeasure(text,px,font,bold){ if(!MCTX) MCTX=document.createElement('canvas').getContext('2d'); MCTX.font=(bold?'700 ':'')+px+'px '+vFont(font); return MCTX.measureText(String(text)).width; }
function vFit(text,px,maxW,font,minPx,bold){ text=String(text); minPx=minPx||11; var sz=px;
  while(sz>minPx&&vMeasure(text,sz,font,bold)>maxW) sz-=0.5;
  if(vMeasure(text,sz,font,bold)<=maxW) return {text:text,size:sz};
  var t=text; while(t.length>1&&vMeasure(t+'…',sz,font,bold)>maxW) t=t.slice(0,-1);
  return {text:t+'…',size:sz}; }
B.view=function(e){
  var tbh=cfg.titlebar?(cfg.titlebar.height||38):0, crh=cfg.credit?34:0;
  var rect={x:e.x!=null?e.x:0,y:e.y!=null?e.y:tbh,w:e.w!=null&&e.w>0?e.w:CW,h:e.h!=null&&e.h>0?e.h:CH-tbh-crh};
  if(e.w==null||!(e.w>0)) rect.w=CW-rect.x; if(e.h==null||!(e.h>0)) rect.h=CH-crh-rect.y;
  var root=document.createElement('div'); root.style.cssText='left:'+rect.x+'px;top:'+rect.y+'px;width:'+rect.w+'px;height:'+rect.h+'px;overflow:visible;white-space:pre';
  root.dataset.view=e.kind; root.dataset.rect=[rect.x,rect.y,rect.w,rect.h].join(','); ST.appendChild(root);
  VIEWS.push({e:e,rect:rect,root:root,kind:e.kind});
};
function viewCtx(v){
  var NS='http://www.w3.org/2000/svg';
  return {e:v.e,rect:v.rect,root:v.root,CW:CW,CH:CH,TH:TH,dark:TH.preset!=='light-pastel',
    svg:function(tag,attrs){var n=document.createElementNS(NS,tag); if(attrs) Object.keys(attrs).forEach(function(k){n.setAttribute(k,attrs[k])}); return n},
    el:function(tag,cls,style){var n=document.createElement(tag||'div'); if(cls) n.className=cls; if(style) n.style.cssText=style; return n},
    cc:cc, col:function(n){return getComputedStyle(document.documentElement).getPropertyValue('--c-'+n).trim()},
    acc:function(i){return 'acc'+(mod(i,6)+1)}, accf:function(i){return 'accf'+(mod(i,6)+1)},
    hash:hash, mod:mod, fill:function(s){return fill(s)}, V:V, measure:vMeasure, fit:vFit,
    mark:function(node,kind){node.setAttribute('data-t',kind); return node}};
}
function buildViews(){
  VIEWS.forEach(function(v){ var impl=VIEW_IMPL[v.kind]; if(!impl) throw new Error('unknown view kind "'+v.kind+'" (is assets/views/'+v.kind+'.js inlined?)');
    v.impl=impl; v.ctx=viewCtx(v); v.state=impl.build(v.ctx); v.ctx.state=v.state; });
  if(VIEWS.length){ var D=(cfg.canvas&&cfg.canvas.duration)||30, lo=-120, hi=D+120, add=[];
    VIEWS.forEach(function(v){ if(v.impl.events) add=add.concat(v.impl.events.call(v.impl,lo,hi,v.ctx)||[]) });
    if(add.length){ EVT=EVT.concat(add); EVT=EVT.map(function(e,i){e.__i=i;return e}).sort(function(a,b){return a.t-b.t||a.__i-b.__i}); } }
}

function clockStr(t){var p=LOG.clock.start.split(':').map(Number), s=Math.floor(p[0]*3600+p[1]*60+p[2]+t*LOG.clock.rate); s=mod(s,86400); var z=function(n){return (n<10?'0':'')+n}; return z(Math.floor(s/3600))+':'+z(Math.floor(s/60)%60)+':'+z(s%60)}
function renderLog(t){
  if(!LOG) return;
  var last=-1; for(var i=0;i<EVT.length;i++){ if(EVT[i].t<=t) last=i; else break; }
  var n=LOG.rows.length;
  LOG.rows.forEach(function(R,i){ var ev=EVT[last-(n-1)+i], isNew=(i===n-1), key=ev?(ev.t+'|'+ev.m+'|'+isNew):'';
    if(key===R.last) return; R.last=key;
    LOG.cols.forEach(function(c,ci){ var s=R.cells[ci], txt='', col='dim', bold=false, op=1;
      if(ev){ if(c.key==='time') txt=clockStr(ev.t);
        else if(c.key==='who'){ txt=ev.who; col=ev.c; bold=true; op=isNew?1:.8; }
        else if(c.key==='m'){ txt=ev.m; if(isNew){col='fg';bold=true} }
        else if(c.key==='g'){ txt=ev.g; if(isNew){col='fg';bold=true} } }
      s.textContent=txt; s.style.color=cc(col); s.style.fontWeight=bold?700:400; s.style.opacity=op; });
  });
}

function styleBoxes(){ BOXES.forEach(function(B_){ var e=B_.e, on=cond(e.when), th=on?e.then:{}, k=on?'1':'0'; if(k===B_.last) return; B_.last=k;
  var el=B_.el; el.style.background=cc(th.fill||e.fill)||''; el.style.color=cc(th.color||e.color||'fg');
  el.style.setProperty('--bw',(th.border!=null?th.border:(e.border!=null?e.border:(TH.borderWidth||2)))+'px');
  el.style.boxShadow=th.glow?'0 0 0 4px color-mix(in srgb, '+cc(th.glow)+' 30%, transparent), 0 0 16px color-mix(in srgb, '+cc(th.glow)+' 55%, transparent)':''; }); }
function stylePaths(){ PATHS.forEach(function(P){ var e=P.e, on=e.when&&cond(e.when), th=on?e.then:{}, k=on?'1':'0'; if(k===P.last) return; P.last=k;
  var col=cc(th.color||e.color||'line'), w=th.width||e.width||TH.wireWidth||2;
  P.pa.setAttribute('stroke',col); P.pa.setAttribute('stroke-width',w); P.pa.style.opacity=th.opacity!=null?th.opacity:(e.opacity!=null?e.opacity:1);
  if(P.hd){ P.hd.setAttribute('fill',col); P.hd.setAttribute('points',P.headPts); P.hd.style.opacity=P.pa.style.opacity; } }); }

// ---------- the one entry point ----------
window.seek=function(t){
  if(!window.__ready){ window.__pending=t; return; }
  try{
    V.__t=t;
    MACH.forEach(function(m){m.vars(t)});
    // packets on the main flow; count deliveries so "the number on the graph" is the number of packets that arrived
    var sig=0;
    PK.forEach(function(P){ if(P.when&&!cond(P.when)){ P.el.forEach(function(q){q[0].style.display='none';q[1].style.display='none'}); return; } P.o.forEach(function(o,n){ var u=(t+PRE+o)/P.period, d=(u-Math.floor(u))*P.len; sig+=Math.floor(u); putPk(P.el[n][0],P,d); putPk(P.el[n][1],P,d-P.tail); }); });
    V.packets=fmtNum(sig,'comma');
    V.clock=LOG?clockStr(t):'';
    TA.forEach(function(A){ var on=V[A.m+'.active']===String(A.i);
      A.ln.style.borderColor=on?A.col:''; A.hd.style.color=on?A.col:'var(--c-dim)';
      if(on){ var ph=Number(V[A.m+'.phase']), u=ph/0.9, d=(u-Math.floor(u))*(A.P.len+10); putPk(A.P.el[0],A.P,d); putPk(A.P.el[1],A.P,d-12); }
      else { A.P.el[0].style.display='none'; A.P.el[1].style.display='none'; } });
    VIEWS.forEach(function(v){ if(v.impl&&v.impl.seek) v.impl.seek.call(v.impl,t,v.ctx,v.state); });
    styleBoxes(); stylePaths(); applyDyn(); renderLog(t);
    window.__t=t;
  }catch(e){fail(e)}
};
window.render=window.seek;

// ---------- layout self-check (used by scripts/check_frames.py) ----------
window.__check=function(){
  var prob=[], items=[], boxes=[], sr=ST.getBoundingClientRect(), sc=sr.width/CW;
  function R(rc){return {l:(rc.left-sr.left)/sc,t:(rc.top-sr.top)/sc,r:(rc.right-sr.left)/sc,b:(rc.bottom-sr.top)/sc}}
  function contentRect(el){var g=document.createRange(); g.selectNodeContents(el); var rs=g.getClientRects(), o=null; for(var i=0;i<rs.length;i++){var q=rs[i]; if(q.width<0.5||q.height<0.5) continue; if(!o) o={left:q.left,top:q.top,right:q.right,bottom:q.bottom}; else {o.left=Math.min(o.left,q.left);o.top=Math.min(o.top,q.top);o.right=Math.max(o.right,q.right);o.bottom=Math.max(o.bottom,q.bottom)}} if(!o&&el.namespaceURI==='http://www.w3.org/2000/svg'){var bb=el.getBoundingClientRect(); if(bb.width>=0.5&&bb.height>=0.5) o={left:bb.left,top:bb.top,right:bb.right,bottom:bb.bottom};} return o}
  var els=ST.querySelectorAll('[data-t]');
  for(var i=0;i<els.length;i++){ var el=els[i], k=el.getAttribute('data-t');
    if(k==='edge') continue;
    if(!el.getClientRects().length) continue;
    if(k==='box'||k==='frame'){ boxes.push({el:el,r:R(el.getBoundingClientRect()),k:k}); continue; }
    if(el.getAttribute('data-nocheck')) continue;
    var cr=contentRect(el); if(!cr) continue; var rr=R(cr); rr.el=el; rr.txt=el.textContent.trim().slice(0,28);
    // a flex item holding a bar has no text range; use its box
    items.push(rr); }
  function ov(a,b){return Math.min(a.r,b.r)-Math.max(a.l,b.l)>1.5&&Math.min(a.b,b.b)-Math.max(a.t,b.t)>1.5}
  // 1 text inside canvas
  items.forEach(function(a){ if(a.l<-0.5||a.t<-0.5||a.r>CW+0.5||a.b>CH+0.5) prob.push('outside canvas: "'+a.txt+'"'); });
  // 2 text inside its own box
  items.forEach(function(a){ var bx=boxes.filter(function(b){return b.el.contains(a.el)})[0];
    if(bx){ var r=bx.r; if(a.l<r.l+1||a.r>r.r-1||a.t<r.t-1||a.b>r.b+1) prob.push('text overflows its box: "'+a.txt+'" ['+Math.round(a.l)+'-'+Math.round(a.r)+'] box ['+Math.round(r.l)+'-'+Math.round(r.r)+']'); } });
  // 3 text vs text
  for(var x=0;x<items.length;x++)for(var y=x+1;y<items.length;y++){ var a=items[x],b=items[y]; if(a.el.contains(b.el)||b.el.contains(a.el)) continue; if(ov(a,b)) prob.push('text overlap: "'+a.txt+'" x "'+b.txt+'"'); }
  // 4 text vs foreign boxes, box vs box
  items.forEach(function(a){ boxes.forEach(function(b){ if(b.k==='frame') return; if(b.el.contains(a.el)||a.el.getAttribute('data-in')) return; if(ov(a,b.r)) prob.push('text over a box: "'+a.txt+'"'); }); });
  for(var p=0;p<boxes.length;p++)for(var q=p+1;q<boxes.length;q++){ if(boxes[p].k==='frame'||boxes[q].k==='frame') continue; if(ov(boxes[p].r,boxes[q].r)) prob.push('box overlap: #'+p+' x #'+q); }
  VIEWS.forEach(function(v){ if(v.impl&&v.impl.check){ (v.impl.check.call(v.impl,v.ctx)||[]).forEach(function(m){prob.push('view '+v.kind+': '+m)}); } });
  return prob;
};

// ---------- boot ----------
function fit(){ var s=Math.min(innerWidth/CW,innerHeight/CH); ST.style.transform='scale('+s+')'; ST.style.left=((innerWidth-CW*s)/2)+'px'; ST.style.top=((innerHeight-CH*s)/2)+'px'; }
var CANVAS_PRESETS={'4:5':[1200,1500],'3:4':[1080,1440],'1:1':[1080,1080]};
var THEME_PRESETS={
 'terminal-dark':{font:'"JetBrains Mono","IBM Plex Mono","DejaVu Sans Mono","Noto Sans Mono CJK SC",monospace',fontSize:21,lineHeight:30,boxMode:'segmented',
   colors:{bg:'#14171c',bar:'#262a32',line:'#4a5367',line2:'#3a4154',dim:'#6f788c',fg:'#e4e8f0',wh:'#ffffff',cy:'#86e1e6',bl:'#8fb4f6',gr:'#7fdba8',pu:'#b9a2f2',ye:'#e3c07a',hl:'#302d45',dots:'#566078',
     acc1:'#86e1e6',acc2:'#8fb4f6',acc3:'#7fdba8',acc4:'#b9a2f2',acc5:'#e3c07a',acc6:'#f28fb0',accf1:'#22343a',accf2:'#232d3e',accf3:'#22342e',accf4:'#2c2a3e',accf5:'#332f27',accf6:'#36272f',panel:'#1b1f26',grid:'#2a303b',ok:'#7fdba8',warn:'#e3c07a',bad:'#f08080',muted:'#949db0'}},
 'light-pastel':{font:'"Noto Sans CJK SC","PingFang SC","Microsoft YaHei","Helvetica Neue",Arial,sans-serif',fontSize:17,lineHeight:24,boxMode:'solid',radius:9,borderWidth:1.5,wireWidth:2.2,glow:true,packetSize:10,
   colors:{bg:'#fcfcfb',bar:'#f1f1ef',line:'#2d3138',line2:'#c9ccd1',dim:'#7b828c',fg:'#23272e',wh:'#ffffff',ink:'#111111',
     gn:'#6fb34f',gnf:'#e7f4de',bl:'#5f93e0',blf:'#e4eefc',blt:'#3a6fc8',yl:'#e3b93d',ylf:'#fff5d6',or:'#e79a4c',orf:'#fdeedc',ort:'#d9731a',
     rd:'#e47b7b',rdf:'#fde7e7',rdt:'#d24a4a',pu:'#b389d9',puf:'#f2eafa',put:'#7d4fb0',mc:'#9a92d9',mcf:'#eeebfa',tl:'#5fbdb2',tlf:'#e0f4f1',
     gy:'#b9bdc4',gyf:'#f5f5f4',pk:'#f0575f',lit:'#fff1b8',
     acc1:'#5f93e0',acc2:'#6fb34f',acc3:'#e79a4c',acc4:'#b389d9',acc5:'#5fbdb2',acc6:'#e47b7b',accf1:'#e4eefc',accf2:'#e7f4de',accf3:'#fdeedc',accf4:'#f2eafa',accf5:'#e0f4f1',accf6:'#fde7e7',panel:'#ffffff',grid:'#ececea',ok:'#2f7d47',warn:'#9a6a0a',bad:'#c43c3c',muted:'#5f6670'}}
};
function mergeTheme(u){ var base=THEME_PRESETS[u.preset||'terminal-dark']||THEME_PRESETS['terminal-dark'], o=Object.assign({},base,u); o.colors=Object.assign({},base.colors,u.colors||{}); o.preset=THEME_PRESETS[u.preset]?u.preset:'terminal-dark'; o.titleFont=u.titleFont==='smiley'?'"Smiley Sans",'+(o.font||'monospace'):(u.titleFont||o.font); return o; }
function boot(c){
  cfg=c; var cv=Object.assign({},c.canvas||{}), th=mergeTheme(c.theme||{}); TH=th;
  if(cv.preset&&CANVAS_PRESETS[cv.preset]){ cv.width=cv.width||CANVAS_PRESETS[cv.preset][0]; cv.height=cv.height||CANVAS_PRESETS[cv.preset][1]; }
  CW=cv.width||1200; CH=cv.height||1500; PRE=cv.preroll||0; FS=th.fontSize||21; LH=th.lineHeight||30;
  document.title=(c.meta&&c.meta.title)||'live-panel'; if(c.meta&&c.meta.lang) document.documentElement.lang=c.meta.lang;
  var root=document.documentElement.style, cols=th.colors||{};
  Object.keys(cols).forEach(function(k){root.setProperty('--c-'+k,cols[k])});
  root.setProperty('--font',th.font||'monospace'); root.setProperty('--font-title',th.titleFont||th.font||'monospace'); root.setProperty('--radius',(th.radius||0)+'px'); root.setProperty('--bw',(th.borderWidth||2)+'px'); root.setProperty('--fs',FS+'px'); root.setProperty('--lh',LH+'px');
  ST.style.width=CW+'px'; ST.style.height=CH+'px'; ST.style.background='var(--c-bg)';
  // machines
  var M=c.machines||{}; Object.keys(M).forEach(function(id){ var m=M[id]; var f=MK[m.type]; if(!f) throw new Error('unknown machine type '+m.type); MACH.push(f(id,m)); });
  var lo=-120, hi=(cv.duration||60)+120; MACH.forEach(function(m){ EVT=EVT.concat(m.events(lo,hi)) });
  // stable sort by time (ties keep config order)
  EVT=EVT.map(function(e,i){e.__i=i;return e}).sort(function(a,b){return a.t-b.t||a.__i-b.__i});
  // titlebar
  if(c.titlebar){ var tb=c.titlebar, h=tb.height||38, d=document.createElement('div'); d.className='tb'; d.style.width=CW+'px'; d.style.height=h+'px'; d.style.lineHeight=h+'px'; d.style.fontSize=(tb.size||14)+'px';
    [['#f2645a',20],['#f1bd3c',42],['#55c552',64]].forEach(function(o){var i=document.createElement('i'); i.style.left=(o[1]-7)+'px'; i.style.top=(h/2-7)+'px'; i.style.width='14px'; i.style.height='14px'; i.style.background=o[0]; d.appendChild(i)});
    d.appendChild(document.createTextNode(tb.text||'')); ST.appendChild(d); }
  (c.elements||[]).forEach(function(e){ var f=B[e.type]; if(!f) throw new Error('unknown element type '+e.type); f(e); });
  if(c.credit){ B.text(Object.assign({type:'text',x:0,w:CW,align:'center',y:CH-14,size:12,c:'dim'},c.credit)); }
  fit(); addEventListener('resize',fit);
  var fontsFor=function(){ if(!VIEWS.length||!document.fonts||!document.fonts.load) return Promise.resolve(); var f=TH.titleFont||TH.font;
    return Promise.all(['20px '+f,'700 20px '+f,'20px '+TH.font,'700 20px '+TH.font].map(function(q){return document.fonts.load(q).catch(function(){})})); };
  var go=function(){ try{ buildViews(); }catch(e){ fail(e); } window.__ready=true; window.seek(window.__pending==null?0:window.__pending);
    if(!/[?&]manual/.test(location.search)){ var t0=performance.now(), D=cv.duration||30; (function loop(now){ window.seek(((now-t0)/1000)%D); requestAnimationFrame(loop); })(t0); } };
  (document.fonts&&document.fonts.ready?document.fonts.ready:Promise.resolve()).then(fontsFor).then(go);
}
loadConfig().then(boot).catch(fail);
})();
</script></body></html>
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 471kUpdated Claude CodeCodexVerifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 322kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 322kUpdated Claude CodeCodexVerifiedInstall
executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is availableStars: 322kUpdated Claude CodeCodexVerifiedInstall